summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorIma Mechanique <ima.mechanique@secondlife.com>2013-11-09 11:31:32 +0000
committerIma Mechanique <ima.mechanique@secondlife.com>2013-11-09 11:31:32 +0000
commit4af21580297dd85727ffdc5d4eee89ad58ead271 (patch)
tree74618b6018e557adf1273971800cf9676098fe5f /indra/newview
parentc8b8c29371a0eb4d53537030d0b007afcc500b3d (diff)
Adding method to load cached/default syntax file and method to access sKeyWordsXML.
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llpreviewscript.cpp15
-rwxr-xr-xindra/newview/llpreviewscript.h1
-rw-r--r--indra/newview/llsyntaxid.cpp47
-rw-r--r--indra/newview/llsyntaxid.h4
4 files changed, 53 insertions, 14 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 5f23249c8d..705872328a 100755
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -406,11 +406,7 @@ BOOL LLScriptEdCore::postBuild()
initMenu();
-// Make this work ;-)
- mSyntaxIdLSL.initialise();
- // ...
- mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml");
-// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec());
+ LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLScriptEdCore::initKeywords(), this));
// FIX: Refactor LLTextEditor::loadKeywords so these can be removed.
std::vector<std::string> funcs;
@@ -456,6 +452,15 @@ BOOL LLScriptEdCore::postBuild()
return TRUE;
}
+void LLScriptEdCore::initKeywords()
+{
+ // Make this work ;-)
+ mSyntaxIdLSL.initialise();
+ // ...
+ mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml");
+ // mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML());
+}
+
void LLScriptEdCore::initMenu()
{
// *TODO: Skinning - make these callbacks data driven
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 73ccaab0b8..149c27461e 100755
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -78,6 +78,7 @@ public:
~LLScriptEdCore();
void initMenu();
+ void initKeywords();
virtual void draw();
/*virtual*/ BOOL postBuild();
diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp
index 0249607834..00e6086546 100644
--- a/indra/newview/llsyntaxid.cpp
+++ b/indra/newview/llsyntaxid.cpp
@@ -248,7 +248,7 @@ void LLSyntaxIdLSL::initialise()
LL_WARNS("LSLSyntax")
<< "Filename is cached, no need to download!"
<< LL_ENDL;
- openKeywordsFile();
+ loadKeywordsFileIntoLLSD();
}
}
else
@@ -256,27 +256,58 @@ void LLSyntaxIdLSL::initialise()
LL_WARNS("LSLSyntax")
<< "ID is null so SyntaxID does not need to be processed!"
<< LL_ENDL;
- openKeywordsFile();
+ loadKeywordsFileIntoLLSD();
}
- // TODO add a signal here to tell the editor the hash has changed?
+ mFileNameCurrent = mFileNameNew;
+ mSyntaxIdCurrent = mSyntaxIdNew;
}
else
{
LL_WARNS("LSLSyntax")
<< "No change to Syntax! Nothing to see here. Move along now!"
<< LL_ENDL;
-
}
- //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this));
}
//-----------------------------------------------------------------------------
-// openKeywordsFile
+// loadKeywordsFileIntoLLSD
//-----------------------------------------------------------------------------
-void LLSyntaxIdLSL::openKeywordsFile()
+/**
+ * @brief Load xml serialised LLSD
+ * @desc Opens the specified filespec and attempts to deserialise the
+ * contained data to the specified LLSD object.
+ * @return Returns boolean true/false indicating success or failure.
+ */
+bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD()
{
LL_WARNS("LSLSyntax")
<< "Trying to open default or cached keyword file ;-)"
<< LL_ENDL;
- // TODO Open the file and load LLSD into sKeywordsXml
+
+ bool loaded = false;
+ LLSD content;
+ llifstream file;
+ file.open(mFullFileSpec);
+ if (file.is_open())
+ {
+ loaded = (bool)LLSDSerialize::fromXML(content, file);
+ if (!loaded)
+ {
+ LL_WARNS("LSLSyntax") << "Unable to deserialise file: " << filename << LL_ENDL;
+
+ // Is this the right thing to do, or should we leave the old content
+ // even if it isn't entirely accurate anymore?
+ sKeywordsXml = LLSD.emptyMap();
+ }
+ else
+ {
+ sKeywordsXml = content;
+ LL_INFOS("LSLSyntax") << "Deserialised file: " << filename << LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_WARNS("LSLSyntax") << "Unable to open file: " << filename << LL_ENDL;
+ }
+ return loaded;
}
diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h
index d9f2572863..50013a8380 100644
--- a/indra/newview/llsyntaxid.h
+++ b/indra/newview/llsyntaxid.h
@@ -39,6 +39,7 @@ public:
bool checkSyntaxIdChanged();
std::string getFileNameCurrent() const { return mFileNameCurrent; }
ELLPath getFilePath() const { return mFilePath; }
+ LLSD getKeywordsXML() const { return sKeywordsXml; }
LLUUID getSyntaxId() const { return mSyntaxIdCurrent; }
void initialise();
@@ -50,7 +51,8 @@ protected:
std::string buildFileNameNew();
std::string buildFullFileSpec();
void fetchKeywordsFile();
- void openKeywordsFile();
+ //void openKeywordsFile();
+ bool loadKeywordsFileIntoLLSD();
void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; }
void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; }
void setFileNameDefault(std::string& name) { mFileNameDefault = name; }