summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llfloaterbulkpermission.cpp2
-rwxr-xr-xindra/newview/llpreviewscript.cpp26
-rwxr-xr-xindra/newview/llpreviewscript.h1
-rw-r--r--indra/newview/llsyntaxid.cpp267
-rw-r--r--indra/newview/llsyntaxid.h83
-rwxr-xr-xindra/newview/llviewerregion.cpp1
-rwxr-xr-xindra/newview/skins/default/xui/en/panel_script_ed.xml2
7 files changed, 238 insertions, 144 deletions
diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp
index 76f62a7880..c3e9a6f5fb 100755
--- a/indra/newview/llfloaterbulkpermission.cpp
+++ b/indra/newview/llfloaterbulkpermission.cpp
@@ -36,7 +36,7 @@
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
-#include "lscript_rt_interface.h"
+//#include "lscript_rt_interface.h"
#include "llviewercontrol.h"
#include "llviewerinventory.h"
#include "llviewerobject.h"
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 5f23249c8d..c662343238 100755
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -34,6 +34,7 @@
#include "llcheckboxctrl.h"
#include "llcombobox.h"
#include "lldir.h"
+#include "llenvmanager.h"
#include "llexternaleditor.h"
#include "llfilepicker.h"
#include "llfloaterreg.h"
@@ -406,18 +407,22 @@ BOOL LLScriptEdCore::postBuild()
initMenu();
-// Make this work ;-)
+ // Intialise keyword highlighting for the current simulator's version of LSL
+ onRegionChangeInitialiseKeywords();
+ // Set up a callback for region changes, so that highlighting is updated to the new region's version of LSL
+ LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this));
+
+ return TRUE;
+}
+
+void LLScriptEdCore::onRegionChangeInitialiseKeywords()
+{
+ mEditor->mKeywords.clearLoaded();
mSyntaxIdLSL.initialise();
- // ...
- mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml");
-// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec());
+ mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML());
- // FIX: Refactor LLTextEditor::loadKeywords so these can be removed.
- std::vector<std::string> funcs;
- std::vector<std::string> tooltips;
-
LLColor3 color(0.5f, 0.0f, 0.15f);
- mEditor->loadKeywords(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords.ini"), funcs, tooltips, color);
+ mEditor->loadKeywords();
std::vector<std::string> primary_keywords;
std::vector<std::string> secondary_keywords;
@@ -439,6 +444,7 @@ BOOL LLScriptEdCore::postBuild()
// Case-insensitive dictionary sort for primary keywords. We don't sort the secondary
// keywords. They're intelligently grouped in keywords.ini.
+ // As we don't use keywords.ini, this is no longer true. Do we need to sort now?
std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() );
for (std::vector<std::string>::const_iterator iter= primary_keywords.begin();
@@ -452,8 +458,6 @@ BOOL LLScriptEdCore::postBuild()
{
mFunctions->add(*iter);
}
-
- return TRUE;
}
void LLScriptEdCore::initMenu()
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 73ccaab0b8..2dd5a1b6a7 100755
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -78,6 +78,7 @@ public:
~LLScriptEdCore();
void initMenu();
+ void onRegionChangeInitialiseKeywords();
virtual void draw();
/*virtual*/ BOOL postBuild();
diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp
index b917134037..66e0777525 100644
--- a/indra/newview/llsyntaxid.cpp
+++ b/indra/newview/llsyntaxid.cpp
@@ -28,58 +28,53 @@
#include "llviewerprecompiledheaders.h"
-#include "llhttpclient.h"
#include "llagent.h"
#include "llappviewer.h"
-#include "llcurl.h"
-#include "llenvmanager.h"
+#include "llhttpclient.h"
#include "llsdserialize.h"
#include "llsyntaxid.h"
+
//-----------------------------------------------------------------------------
// fetchKeywordsFileResponder
//-----------------------------------------------------------------------------
-class fetchKeywordsFileResponder : public LLCurl::Responder
+fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec)
{
-public:
- std::string mFileSpec;
+ mFileSpec = filespec;
+ LL_WARNS("LSLSyntax")
+ << "Instantiating with file saving to: '" << filespec << "'"
+ << LL_ENDL;
+}
- fetchKeywordsFileResponder(std::string filespec)
- {
- mFileSpec = filespec;
- }
+void fetchKeywordsFileResponder::errorWithContent(U32 status,
+ const std::string& reason,
+ const LLSD& content)
+{
+ LL_WARNS("LSLSyntax")
+ << "fetchKeywordsFileResponder error [status:"
+ << status
+ << "]: "
+ << content
+ << LL_ENDL;
+}
- void errorWithContent(U32 status,
- const std::string& reason,
- const LLSD& content)
- {
- LL_WARNS("")
- << "fetchKeywordsFileResponder error [status:"
- << status
- << "]: "
- << content
- << LL_ENDL;
- }
+void fetchKeywordsFileResponder::result(const LLSD& content_ref)
+{
+ LLSyntaxIdLSL::setKeywordsXml(content_ref);
- void result(const LLSD& content_ref)
- {
- //LLSyntaxIdLSL::setKeywordsXml(content_ref);
- std::stringstream str;
- LLSDSerialize::toPrettyXML(content_ref, str);
-
- LLSD& xml = LLSD::emptyMap();
- LLSDSerialize::deserialize(xml, str, 10485760);
- LL_WARNS("")
- << "fetchKeywordsFileResponder result:" << str.str()
- << "filename: '" << mFileSpec << "'"
- << LL_ENDL;
+ std::stringstream str;
+ LLSDSerialize::toPrettyXML(content_ref, str);
+ const std::string xml = str.str();
+
+ // save the str to disc, usually to the cache.
+ llofstream file(mFileSpec, std::ios_base::out);
+ file.write(xml.c_str(), str.str().size());
+ file.close();
+
+ LL_WARNS("LSLSyntax")
+ << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL;
+}
- // TODO save the damn str to disc
- //llofstream file(mFileSpec, std::ios_base::out);
- //file.write(str.str(), str.str().size());
- //file.close();
- }
-};
//-----------------------------------------------------------------------------
// LLSyntaxIdLSL
@@ -92,16 +87,36 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() :
mFileNameDefault("keywords_lsl_default.xml"),
mSimulatorFeature("LSLSyntaxId"),
mCapabilityName("LSLSyntax"),
+ mCapabilityURL(""),
mFilePath(LL_PATH_APP_SETTINGS)
{
- mCurrentSyntaxId = LLUUID();
+ mSyntaxIdCurrent = LLUUID();
mFileNameCurrent = mFileNameDefault;
}
-std::string LLSyntaxIdLSL::buildFileName(LLUUID& SyntaxId)
+LLSD LLSyntaxIdLSL::sKeywordsXml;
+
+std::string LLSyntaxIdLSL::buildFileNameNew()
+{
+ std::string filename = "keywords_lsl_";
+ if (!mSyntaxIdNew.isNull())
+ {
+ filename += gLastVersionChannel + "_" + mSyntaxIdNew.asString();
+ }
+ else
+ {
+ filename += mFileNameDefault;
+ }
+ mFileNameNew = filename + ".llsd.xml";
+ return mFileNameNew;
+}
+
+std::string LLSyntaxIdLSL::buildFullFileSpec()
{
- std::string filename = "keywords_lsl_" + SyntaxId.asString() + "_" + gLastVersionChannel + ".llsd.xml";
- return filename;
+ ELLPath path = mSyntaxIdNew.isNull() ? LL_PATH_APP_SETTINGS : LL_PATH_CACHE;
+ buildFileNameNew();
+ mFullFileSpec = gDirUtilp->getExpandedFilename(path, mFileNameNew);
+ return mFullFileSpec;
}
//-----------------------------------------------------------------------------
@@ -114,39 +129,30 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged()
if (region)
{
- /*
- LL_WARNS("LSLSyntax")
- << "REGION is '" << region->getName() << "'"
- << LL_ENDL;
- */
-
if (!region->capabilitiesReceived())
- { // Shouldn't be possible, but experience shows that it's needed
-// region->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this));
+ { // Shouldn't be possible, but experience shows that it may be needed.
LL_WARNS("LSLSyntax")
<< "region '" << region->getName()
- << "' has not received capabilities yet! Setting a callback for when they arrive."
+ << "' has not received capabilities yet! Cannot process SyntaxId."
<< LL_ENDL;
}
else
{
- // get and check the hash
LLSD simFeatures;
+ std::string message;
region->getSimulatorFeatures(simFeatures);
+
+ // get and check the hash
if (simFeatures.has("LSLSyntaxId"))
{
- LLUUID SyntaxId = simFeatures["LSLSyntaxId"].asUUID();
- if (mCurrentSyntaxId != SyntaxId)
+ mSyntaxIdNew = simFeatures["LSLSyntaxId"].asUUID();
+ mCapabilityURL = region->getCapability(mCapabilityName);
+ if (mSyntaxIdCurrent != mSyntaxIdNew)
{
- // set the properties for the fetcher to use
- mFileNameCurrent = buildFileName(SyntaxId);
- mFilePath = LL_PATH_CACHE;
- mCurrentSyntaxId = SyntaxId;
-
LL_WARNS("LSLSyntax")
- << "Region changed to '" << region->getName()
+ << "Region is '" << region->getName()
<< "' it has LSLSyntaxId capability, and the new hash is '"
- << SyntaxId << "'"
+ << mSyntaxIdNew << "'"
<< LL_ENDL;
changed = true;
@@ -154,35 +160,28 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged()
else
{
LL_WARNS("LSLSyntax")
- << "Region changed to '" << region->getName()
+ << "Region is '" << region->getName()
<< "' it has the same LSLSyntaxId! Leaving hash as '"
- << mCurrentSyntaxId << "'"
+ << mSyntaxIdCurrent << "'"
<< LL_ENDL;
}
+
}
else
{
- // Set the hash to NULL_KEY to indicate use of default keywords file
- if ( mCurrentSyntaxId.isNull() )
+ if ( mSyntaxIdCurrent.isNull() )
{
- LL_WARNS("LSLSyntax")
- << "Region changed to '" << region->getName()
- << " it does not have LSLSyntaxId capability, remaining with default keywords file!"
- << LL_ENDL;
+ message = " it does not have LSLSyntaxId capability, remaining with default keywords file!";
}
else
{
- mCurrentSyntaxId = LLUUID();
- mFileNameCurrent = mFileNameDefault;
- mFilePath = LL_PATH_APP_SETTINGS;
-
- LL_WARNS("LSLSyntax")
- << "Region changed to '" << region->getName()
- << " it does not have LSLSyntaxId capability, using default keywords file!"
- << LL_ENDL;
-
+ // The hash is set to NULL_KEY to indicate use of default keywords file
+ mSyntaxIdNew = LLUUID();
+ message = " it does not have LSLSyntaxId capability, using default keywords file!";
changed = true;
}
+ LL_WARNS("LSLSyntax")
+ << "Region is '" << region->getName() << message << LL_ENDL;
}
}
}
@@ -192,56 +191,114 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged()
//-----------------------------------------------------------------------------
// fetchKeywordsFile
//-----------------------------------------------------------------------------
-bool LLSyntaxIdLSL::fetchKeywordsFile()
+void LLSyntaxIdLSL::fetchKeywordsFile()
{
- LLViewerRegion* region = gAgent.getRegion();
- bool fetched = false;
-
- std::string cap_url = region->getCapability(mCapabilityName);
- if ( !cap_url.empty() )
+ if ( !mCapabilityURL.empty() )
{
- LLHTTPClient::get(cap_url, new fetchKeywordsFileResponder(mFullFileSpec));
+ LLHTTPClient::get(mCapabilityURL,
+ new fetchKeywordsFileResponder(mFullFileSpec),
+ LLSD(), 30.f
+ );
+ LL_INFOS("LSLSyntax")
+ << "LSLSyntaxId capability URL is: " << mCapabilityURL
+ << ". Filename to use is: '" << mFullFileSpec << "'."
+ << LL_ENDL;
+ }
+ else
+ {
+ LL_WARNS("LSLSyntax")
+ << "LSLSyntaxId capability URL is empty!!" << LL_ENDL;
}
-
- return fetched;
}
void LLSyntaxIdLSL::initialise()
{
if (checkSyntaxIdChanged())
{
- LL_WARNS("LSLSyntax")
- << "Change to syntax, setting up new file."
+ LL_INFOS("LSLSyntax")
+ << "LSL version has changed, getting appropriate file."
<< LL_ENDL;
- setFileNameNew(gDirUtilp->getExpandedFilename(
- mFilePath,
- mFileNameCurrent
- ));
- if ( !mCurrentSyntaxId.isNull() )
+ // Need a full spec regardless of file source, so build it now.
+ buildFullFileSpec();
+ if ( !mSyntaxIdNew.isNull() )
{
- bool success = false;
+ LL_INFOS("LSLSyntax")
+ << "We have an ID for the version, processing it!"
+ << LL_ENDL;
+
if ( !gDirUtilp->fileExists(mFullFileSpec) )
{ // Does not exist, so fetch it from the capability
- success = fetchKeywordsFile();
+ fetchKeywordsFile();
+ LL_INFOS("LSLSyntax")
+ << "File is not cached, we will try to download it!"
+ << LL_ENDL;
+ }
+ else
+ {
+ LL_INFOS("LSLSyntax")
+ << "File is cached, no need to download!"
+ << LL_ENDL;
+ loadKeywordsIntoLLSD();
}
}
- // TODO add a signal here to tell the editor the hash has changed?
+ else
+ { // Need to open the default
+ LL_INFOS("LSLSyntax")
+ << "LSLSyntaxId is null so we will use the default file!"
+ << LL_ENDL;
+ loadKeywordsIntoLLSD();
+ }
+ mFileNameCurrent = mFileNameNew;
+ mSyntaxIdCurrent = mSyntaxIdNew;
}
else
{
- LL_WARNS("LSLSyntax")
- << "Apparently there is no change to Syntax!"
+ LL_INFOS("LSLSyntax")
+ << "No change to Syntax! Nothing to see. Move along now!"
<< LL_ENDL;
-
}
- //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this));
}
//-----------------------------------------------------------------------------
-// openKeywordsFile
+// loadKeywordsFileIntoLLSD
//-----------------------------------------------------------------------------
-void 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::loadKeywordsIntoLLSD()
{
- ;
+ LL_INFOS("LSLSyntax")
+ << "Trying to open cached or default keyword file ;-)"
+ << LL_ENDL;
+
+ 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: " << mFullFileSpec << 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: " << mFullFileSpec << LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_WARNS("LSLSyntax") << "Unable to open file: " << mFullFileSpec << LL_ENDL;
+ }
+ return loaded;
}
diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h
index f7e3d6896e..472e88744f 100644
--- a/indra/newview/llsyntaxid.h
+++ b/indra/newview/llsyntaxid.h
@@ -11,38 +11,40 @@
#include "llhttpclient.h"
#include "llviewerregion.h"
+/**
+ * @file llsyntaxid.h
+ * @brief Handles responses for the LSLSyntax capability's get call.
+ */
+class fetchKeywordsFileResponder : public LLHTTPClient::Responder
+{
+public:
+ std::string mFileSpec;
+
+ /**
+ * @brief fetchKeywordsFileResponder
+ * @param filespec File path and name of where to save the returned data
+ */
+ fetchKeywordsFileResponder(std::string filespec);
+
+ void errorWithContent(U32 status,
+ const std::string& reason,
+ const LLSD& content);
+
+ /**
+ * @brief Saves the returned file to the location provided at instantiation.
+ * @param content_ref The LSL syntax file for the sim.
+ */
+ void result(const LLSD& content_ref);
+};
+
/**
* @file llsyntaxid.h
- * @brief The LLSyntaxIdLSL class
+ * @brief Tracks the file needed to decorate the current sim's version of LSL.
*/
class LLSyntaxIdLSL
{
public:
- LLSyntaxIdLSL();
-
- bool checkSyntaxIdChanged();
- std::string getFileNameCurrent() const { return mFileNameCurrent; }
- ELLPath getFilePath() const { return mFilePath; }
- LLUUID getSyntaxId() const { return mCurrentSyntaxId; }
-
- void initialise();
-
- static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; }
-
-
-protected:
- std::string buildFileName(LLUUID& SyntaxId);
- bool fetchKeywordsFile();
- void openKeywordsFile();
- void setSyntaxId(LLUUID SyntaxId) { mCurrentSyntaxId = SyntaxId; }
- void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; }
- void setFileNameDefault(std::string& name) { mFileNameDefault = name; }
- void setFileNameNew(std::string& name) { mFileNameNew = name; }
- void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; }
-
-
-//public:
protected:
@@ -51,13 +53,42 @@ protected:
private:
std::string mCapabilityName;
- LLUUID mCurrentSyntaxId;
+ std::string mCapabilityURL;
std::string mFileNameCurrent;
std::string mFileNameDefault;
std::string mFileNameNew;
ELLPath mFilePath;
std::string mFullFileSpec;
std::string mSimulatorFeature;
+ LLUUID mSyntaxIdCurrent;
+ LLUUID mSyntaxIdNew;
static LLSD sKeywordsXml;
+
+
+public:
+ LLSyntaxIdLSL();
+
+ bool checkSyntaxIdChanged();
+ std::string getFileNameCurrent() const { return mFileNameCurrent; }
+ ELLPath getFilePath() const { return mFilePath; }
+ std::string getFileSpec() const { return mFullFileSpec; }
+ LLSD getKeywordsXML() const { return sKeywordsXml; }
+ LLUUID getSyntaxId() const { return mSyntaxIdCurrent; }
+
+ void initialise();
+
+ static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; }
+
+
+protected:
+ std::string buildFileNameNew();
+ std::string buildFullFileSpec();
+ void fetchKeywordsFile();
+ bool loadKeywordsIntoLLSD();
+ void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; }
+ void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; }
+ void setFileNameDefault(std::string& name) { mFileNameDefault = name; }
+ void setFileNameNew(std::string name) { mFileNameNew = name; }
+ void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; }
};
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 678f24fb3c..854f05f116 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1614,6 +1614,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
capabilityNames.append("GroupProposalBallot");
capabilityNames.append("HomeLocation");
capabilityNames.append("LandResources");
+ capabilityNames.append("LSLSyntax");
capabilityNames.append("MapLayer");
capabilityNames.append("MapLayerGod");
capabilityNames.append("MeshUploadFlag");
diff --git a/indra/newview/skins/default/xui/en/panel_script_ed.xml b/indra/newview/skins/default/xui/en/panel_script_ed.xml
index bcdef96138..d1b35dce9d 100755
--- a/indra/newview/skins/default/xui/en/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml
@@ -157,7 +157,7 @@
height="376"
ignore_tab="false"
layout="topleft"
- max_length="65536"
+ max_length="262144"
name="Script Editor"
text_readonly_color="DkGray"
width="487"