summaryrefslogtreecommitdiff
path: root/indra/newview/llexternaleditor.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-04-15 14:13:57 -0500
committerDave Parks <davep@lindenlab.com>2011-04-15 14:13:57 -0500
commitaf6133dfa5c6f4e3a00752f2885bd2f30c0e1c8c (patch)
tree71335616be646d8dd8e793732b508ea77ed197db /indra/newview/llexternaleditor.cpp
parent7e7ff13b49f6f806a385bd92d675123ff7db7232 (diff)
parent6a491424677086a84d180ace0b91f1eefaeb67ba (diff)
merge
Diffstat (limited to 'indra/newview/llexternaleditor.cpp')
-rw-r--r--indra/newview/llexternaleditor.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/indra/newview/llexternaleditor.cpp b/indra/newview/llexternaleditor.cpp
index 54968841ab..ed1d7e860a 100644
--- a/indra/newview/llexternaleditor.cpp
+++ b/indra/newview/llexternaleditor.cpp
@@ -27,6 +27,7 @@
#include "llviewerprecompiledheaders.h"
#include "llexternaleditor.h"
+#include "lltrans.h"
#include "llui.h"
// static
@@ -35,13 +36,13 @@ const std::string LLExternalEditor::sFilenameMarker = "%s";
// static
const std::string LLExternalEditor::sSetting = "ExternalEditor";
-bool LLExternalEditor::setCommand(const std::string& env_var, const std::string& override)
+LLExternalEditor::EErrorCode LLExternalEditor::setCommand(const std::string& env_var, const std::string& override)
{
std::string cmd = findCommand(env_var, override);
if (cmd.empty())
{
- llwarns << "Empty editor command" << llendl;
- return false;
+ llwarns << "Editor command is empty or not set" << llendl;
+ return EC_NOT_SPECIFIED;
}
// Add the filename marker if missing.
@@ -55,7 +56,7 @@ bool LLExternalEditor::setCommand(const std::string& env_var, const std::string&
if (tokenize(tokens, cmd) < 2) // 2 = bin + at least one arg (%s)
{
llwarns << "Error parsing editor command" << llendl;
- return false;
+ return EC_PARSE_ERROR;
}
// Check executable for existence.
@@ -63,7 +64,7 @@ bool LLExternalEditor::setCommand(const std::string& env_var, const std::string&
if (!LLFile::isfile(bin_path))
{
llwarns << "Editor binary [" << bin_path << "] not found" << llendl;
- return false;
+ return EC_BINARY_NOT_FOUND;
}
// Save command.
@@ -76,16 +77,16 @@ bool LLExternalEditor::setCommand(const std::string& env_var, const std::string&
}
llinfos << "Setting command [" << bin_path << " " << mArgs << "]" << llendl;
- return true;
+ return EC_SUCCESS;
}
-bool LLExternalEditor::run(const std::string& file_path)
+LLExternalEditor::EErrorCode LLExternalEditor::run(const std::string& file_path)
{
std::string args = mArgs;
if (mProcess.getExecutable().empty() || args.empty())
{
llwarns << "Editor command not set" << llendl;
- return false;
+ return EC_NOT_SPECIFIED;
}
// Substitute the filename marker in the command with the actual passed file name.
@@ -111,7 +112,22 @@ bool LLExternalEditor::run(const std::string& file_path)
mProcess.orphan();
}
- return result == 0;
+ return result == 0 ? EC_SUCCESS : EC_FAILED_TO_RUN;
+}
+
+// static
+std::string LLExternalEditor::getErrorMessage(EErrorCode code)
+{
+ switch (code)
+ {
+ case EC_SUCCESS: return LLTrans::getString("ok");
+ case EC_NOT_SPECIFIED: return LLTrans::getString("ExternalEditorNotSet");
+ case EC_PARSE_ERROR: return LLTrans::getString("ExternalEditorCommandParseError");
+ case EC_BINARY_NOT_FOUND: return LLTrans::getString("ExternalEditorNotFound");
+ case EC_FAILED_TO_RUN: return LLTrans::getString("ExternalEditorFailedToRun");
+ }
+
+ return LLTrans::getString("Unknown");
}
// static