From a0607d45ca12c930b9fb8018243e62aed0e09dc9 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 21 Oct 2013 22:20:33 +0100 Subject: STORM-1831 Adding the llsyntaxid.* files let were left out of commit 7c74a59eeee4 OOPS --- indra/newview/llsyntaxid.cpp | 226 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 indra/newview/llsyntaxid.cpp (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp new file mode 100644 index 0000000000..9ecbe8698d --- /dev/null +++ b/indra/newview/llsyntaxid.cpp @@ -0,0 +1,226 @@ +/** + * @file LLSyntaxId + * @author Ima Mechanique + * @brief Handles downloading, saving, and checking of LSL keyword/syntax files + * for each region. + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llhttpclient.h" +#include "llagent.h" +#include "llappviewer.h" +#include "llcurl.h" +#include "llenvmanager.h" +#include "llsdserialize.h" +#include "llsyntaxid.h" + +//----------------------------------------------------------------------------- +// fetchKeywordsFileResponder +//----------------------------------------------------------------------------- +class fetchKeywordsFileResponder : public LLCurl::Responder +{ + std::string mFileSpec; +public: + fetchKeywordsFileResponder(std::string filespec) + { + mFileSpec = filespec; + } + + void errorWithContent(U32 status, const std::string& reason, const LLSD& content) + { + LL_WARNS("") + << "fetchKeywordsFileResponder error [status:" + << status + << "]: " + << content + << LL_ENDL; + } + + void result(LLSD& content_ref) + { + LLSyntaxIdLSL::setKeywordsXml(content_ref); + + std::stringstream str; + LLSDSerialize::toPrettyXML(content_ref, str); + LL_WARNS("") + << "fetchKeywordsFileResponder result:" + << str.str() + << "filename: '" << 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 +//----------------------------------------------------------------------------- +LLSyntaxIdLSL::LLSyntaxIdLSL() : + // Move these to signature? + mFilenameDefault("keywords_lsl_default.xml"), + mSimulatorFeature("LSLSyntaxId"), + mCapabilityName("LSLSyntax") +{ + mCurrentSyntaxId = LLUUID(); + mFilenameCurrent = mFilenameDefault; + mFilenameLocation = LL_PATH_APP_SETTINGS; + checkSyntaxIdChange(); + //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); +} + +std::string LLSyntaxIdLSL::buildFilename(LLUUID& SyntaxId) +{ + std::string filename = "keywords_lsl_" + SyntaxId.asString() + "_" + gLastVersionChannel + ".llsd.xml"; + return filename; +} + +//----------------------------------------------------------------------------- +// checkSyntaxIdChange() +//----------------------------------------------------------------------------- +bool LLSyntaxIdLSL::checkSyntaxIdChange() +{ + bool changed = false; + if (mRegion) + { + LL_WARNS("LSLSyntax") + << "REGION is '" + << mRegion->getName() + << "'" + << LL_ENDL; + + if (!mRegion->capabilitiesReceived()) + { // Shouldn't be possible, but experience shows that it's needed +// mRegion->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this)); + LL_WARNS("LSLSyntax") + << "mRegion '" + << mRegion->getName() + << "' has not received capabilities yet! Setting a callback for when they arrive." + << LL_ENDL; + } else { + // get and check the hash + LLSD simFeatures; + mRegion->getSimulatorFeatures(simFeatures); + if (simFeatures.has("LSLSyntaxId")) + { + LLUUID SyntaxId = simFeatures["LSLSyntaxId"].asUUID(); + if (mCurrentSyntaxId != SyntaxId) + { + // set the properties for the fetcher to use + mFilenameCurrent = buildFilename(SyntaxId); + mFilenameLocation = LL_PATH_CACHE; + mCurrentSyntaxId = SyntaxId; + + LL_WARNS("LSLSyntax") + << "Region changed to '" + << mRegion->getName() + << "' it has LSLSyntaxId capability, and the new hash is '" + << SyntaxId + << "'" + << LL_ENDL; + + changed = true; + } else { + LL_WARNS("LSLSyntax") + << "Region changed to '" + << mRegion->getName() + << "' it has the same LSLSyntaxId! Leaving hash as '" + << mCurrentSyntaxId + << "'" + << LL_ENDL; + } + } else { + // Set the hash to NULL_KEY to indicate use of default keywords file + if ( mCurrentSyntaxId.isNull() ) + { + LL_WARNS("LSLSyntax") + << "Region does not have LSLSyntaxId capability, remaining with default keywords file!" + << LL_ENDL; + } else { + mCurrentSyntaxId = LLUUID(); + mFilenameCurrent = mFilenameDefault; + mFilenameLocation = LL_PATH_APP_SETTINGS; + + LL_WARNS("LSLSyntax") + << "Region does not have LSLSyntaxId capability, using default keywords file!" + << LL_ENDL; + + changed = true; + } + } + } + } + return changed; +} + +//----------------------------------------------------------------------------- +// fetchKeywordsFile +//----------------------------------------------------------------------------- +bool LLSyntaxIdLSL::fetchKeywordsFile() +{ + bool fetched = false; + std::string cap_url = mRegion->getCapability(mCapabilityName); +// mResponder->setFileSpec(mFilenameSpec); + if ( !cap_url.empty() ) + { + LLHTTPClient::get(cap_url, mResponder); + } + + return fetched; +} + +void LLSyntaxIdLSL::initialise() +{ + mRegion = gAgent.getRegion(); + if (checkSyntaxIdChange()) + { + mFilenameFull = gDirUtilp->getExpandedFilename( + mFilenameLocation, + mFilenameCurrent + ); + if ( !mCurrentSyntaxId.isNull() ) + { + bool success = true; + if (!gDirUtilp->fileExists(mFilenameSpec)) + { + mResponder = new fetchKeywordsFileResponder(mFilenameSpec); + success = fetchKeywordsFile(); + } + } + // TODO add a signal here to tell the editor the hash has changed? + } + + mRegion = NULL; +} + +//----------------------------------------------------------------------------- +// openKeywordsFile +//----------------------------------------------------------------------------- +void openKeywordsFile() +{ + ; +} -- cgit v1.3 From dfa8a78c2895e16a4887786d522a70cae59b081e Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 22 Oct 2013 22:41:08 +0100 Subject: STORM-1831 Style cleanup/fixes --- indra/newview/llsyntaxid.cpp | 20 ++++++++++++++------ indra/newview/llsyntaxid.h | 5 +++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 9ecbe8698d..deaa64c0e7 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -121,7 +121,9 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() << mRegion->getName() << "' has not received capabilities yet! Setting a callback for when they arrive." << LL_ENDL; - } else { + } + else + { // get and check the hash LLSD simFeatures; mRegion->getSimulatorFeatures(simFeatures); @@ -144,7 +146,9 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() << LL_ENDL; changed = true; - } else { + } + else + { LL_WARNS("LSLSyntax") << "Region changed to '" << mRegion->getName() @@ -153,14 +157,18 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() << "'" << LL_ENDL; } - } else { + } + else + { // Set the hash to NULL_KEY to indicate use of default keywords file if ( mCurrentSyntaxId.isNull() ) { LL_WARNS("LSLSyntax") << "Region does not have LSLSyntaxId capability, remaining with default keywords file!" << LL_ENDL; - } else { + } + else + { mCurrentSyntaxId = LLUUID(); mFilenameCurrent = mFilenameDefault; mFilenameLocation = LL_PATH_APP_SETTINGS; @@ -187,7 +195,7 @@ bool LLSyntaxIdLSL::fetchKeywordsFile() // mResponder->setFileSpec(mFilenameSpec); if ( !cap_url.empty() ) { - LLHTTPClient::get(cap_url, mResponder); + LLHTTPClient::get(cap_url, new fetchKeywordsFileResponder(mFilenameSpec)); } return fetched; @@ -207,7 +215,7 @@ void LLSyntaxIdLSL::initialise() bool success = true; if (!gDirUtilp->fileExists(mFilenameSpec)) { - mResponder = new fetchKeywordsFileResponder(mFilenameSpec); + //mResponder = new fetchKeywordsFileResponder(mFilenameSpec); success = fetchKeywordsFile(); } } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 6e5a97fd31..e32fcf209e 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -33,7 +33,7 @@ public: std::string filenameCurrent() { return mFilenameCurrent; } ELLPath filenamePath() { return mFilenameLocation; } void initialise(); - static void setKeywordsXml(LLSD& content) { LLSyntaxIdLSL::mKeywordsXml = content; } + static void setKeywordsXml(const LLSD& content) { LLSyntaxIdLSL::sKeywordsXml = content; } protected: std::string buildFilename(LLUUID& SyntaxId); @@ -60,6 +60,7 @@ private: std::string mFilenameFull; ELLPath mFilenameLocation; std::string mFilenameSpec; - static LLSD mKeywordsXml; std::string mSimulatorFeature; + + static LLSD sKeywordsXml; }; -- cgit v1.3 From bad5179f276f6913bfb9a313d25d02d0e883d678 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 25 Oct 2013 14:42:04 +0100 Subject: storm-1831 Fixing viewer crash and clean up. No idea why storing the region pointer in mRegion causes crashes, when doing it locally in each method doesn't. --- indra/newview/llpreviewscript.cpp | 10 +--- indra/newview/llpreviewscript.h | 2 +- indra/newview/llsyntaxid.cpp | 113 +++++++++++++++++++++----------------- indra/newview/llsyntaxid.h | 63 ++++++++++----------- 4 files changed, 96 insertions(+), 92 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 62e1d765b3..5f23249c8d 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -407,14 +407,10 @@ BOOL LLScriptEdCore::postBuild() initMenu(); // Make this work ;-) - mSyntaxLSL = LLSyntaxIdLSL(); - -// mSyntaxLSL.initialise(); -// mSyntaxLSL.mKeywords = &mEditor->mKeywords; + mSyntaxIdLSL.initialise(); // ... -// mSyntaxLSL->mKeywords.initialise(); -// Move into the SyntaxIdLSL class - mEditor->mKeywords.initialise(mSyntaxLSL.filenamePath(), mSyntaxLSL.filenameCurrent()); + mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); +// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec()); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 21e33f30d5..73ccaab0b8 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -150,7 +150,7 @@ private: BOOL mEnableSave; BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; - LLSyntaxIdLSL mSyntaxLSL; + LLSyntaxIdLSL mSyntaxIdLSL; LLScriptEdContainer* mContainer; // parent view }; diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index deaa64c0e7..442793bff1 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -41,14 +41,17 @@ //----------------------------------------------------------------------------- class fetchKeywordsFileResponder : public LLCurl::Responder { - std::string mFileSpec; public: + std::string mFileSpec; + fetchKeywordsFileResponder(std::string filespec) { mFileSpec = filespec; } - void errorWithContent(U32 status, const std::string& reason, const LLSD& content) + void errorWithContent(U32 status, + const std::string& reason, + const LLSD& content) { LL_WARNS("") << "fetchKeywordsFileResponder error [status:" @@ -58,15 +61,14 @@ public: << LL_ENDL; } - void result(LLSD& content_ref) + void result(const LLSD& content_ref) { - LLSyntaxIdLSL::setKeywordsXml(content_ref); + //LLSyntaxIdLSL::setKeywordsXml(content_ref); std::stringstream str; LLSDSerialize::toPrettyXML(content_ref, str); LL_WARNS("") - << "fetchKeywordsFileResponder result:" - << str.str() + << "fetchKeywordsFileResponder result:" << str.str() << "filename: '" << mFileSpec << "'" << LL_ENDL; @@ -80,20 +82,21 @@ public: //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- +/** + * @brief LLSyntaxIdLSL constructor + */ LLSyntaxIdLSL::LLSyntaxIdLSL() : // Move these to signature? - mFilenameDefault("keywords_lsl_default.xml"), + mFileNameDefault("keywords_lsl_default.xml"), mSimulatorFeature("LSLSyntaxId"), - mCapabilityName("LSLSyntax") + mCapabilityName("LSLSyntax"), + mFilePath(LL_PATH_APP_SETTINGS) { mCurrentSyntaxId = LLUUID(); - mFilenameCurrent = mFilenameDefault; - mFilenameLocation = LL_PATH_APP_SETTINGS; - checkSyntaxIdChange(); - //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); + mFileNameCurrent = mFileNameDefault; } -std::string LLSyntaxIdLSL::buildFilename(LLUUID& SyntaxId) +std::string LLSyntaxIdLSL::buildFileName(LLUUID& SyntaxId) { std::string filename = "keywords_lsl_" + SyntaxId.asString() + "_" + gLastVersionChannel + ".llsd.xml"; return filename; @@ -102,23 +105,24 @@ std::string LLSyntaxIdLSL::buildFilename(LLUUID& SyntaxId) //----------------------------------------------------------------------------- // checkSyntaxIdChange() //----------------------------------------------------------------------------- -bool LLSyntaxIdLSL::checkSyntaxIdChange() +bool LLSyntaxIdLSL::checkSyntaxIdChanged() { bool changed = false; - if (mRegion) + LLViewerRegion* region = gAgent.getRegion(); + + if (region) { + /* LL_WARNS("LSLSyntax") - << "REGION is '" - << mRegion->getName() - << "'" + << "REGION is '" << region->getName() << "'" << LL_ENDL; + */ - if (!mRegion->capabilitiesReceived()) + if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it's needed -// mRegion->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this)); +// region->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this)); LL_WARNS("LSLSyntax") - << "mRegion '" - << mRegion->getName() + << "region '" << region->getName() << "' has not received capabilities yet! Setting a callback for when they arrive." << LL_ENDL; } @@ -126,23 +130,21 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() { // get and check the hash LLSD simFeatures; - mRegion->getSimulatorFeatures(simFeatures); + region->getSimulatorFeatures(simFeatures); if (simFeatures.has("LSLSyntaxId")) { LLUUID SyntaxId = simFeatures["LSLSyntaxId"].asUUID(); if (mCurrentSyntaxId != SyntaxId) { // set the properties for the fetcher to use - mFilenameCurrent = buildFilename(SyntaxId); - mFilenameLocation = LL_PATH_CACHE; + mFileNameCurrent = buildFileName(SyntaxId); + mFilePath = LL_PATH_CACHE; mCurrentSyntaxId = SyntaxId; LL_WARNS("LSLSyntax") - << "Region changed to '" - << mRegion->getName() + << "Region changed to '" << region->getName() << "' it has LSLSyntaxId capability, and the new hash is '" - << SyntaxId - << "'" + << SyntaxId << "'" << LL_ENDL; changed = true; @@ -150,11 +152,9 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() else { LL_WARNS("LSLSyntax") - << "Region changed to '" - << mRegion->getName() + << "Region changed to '" << region->getName() << "' it has the same LSLSyntaxId! Leaving hash as '" - << mCurrentSyntaxId - << "'" + << mCurrentSyntaxId << "'" << LL_ENDL; } } @@ -164,17 +164,19 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() if ( mCurrentSyntaxId.isNull() ) { LL_WARNS("LSLSyntax") - << "Region does not have LSLSyntaxId capability, remaining with default keywords file!" + << "Region changed to '" << region->getName() + << " it does not have LSLSyntaxId capability, remaining with default keywords file!" << LL_ENDL; } else { mCurrentSyntaxId = LLUUID(); - mFilenameCurrent = mFilenameDefault; - mFilenameLocation = LL_PATH_APP_SETTINGS; + mFileNameCurrent = mFileNameDefault; + mFilePath = LL_PATH_APP_SETTINGS; LL_WARNS("LSLSyntax") - << "Region does not have LSLSyntaxId capability, using default keywords file!" + << "Region changed to '" << region->getName() + << " it does not have LSLSyntaxId capability, using default keywords file!" << LL_ENDL; changed = true; @@ -190,12 +192,13 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() //----------------------------------------------------------------------------- bool LLSyntaxIdLSL::fetchKeywordsFile() { + LLViewerRegion* region = gAgent.getRegion(); bool fetched = false; - std::string cap_url = mRegion->getCapability(mCapabilityName); -// mResponder->setFileSpec(mFilenameSpec); + + std::string cap_url = region->getCapability(mCapabilityName); if ( !cap_url.empty() ) { - LLHTTPClient::get(cap_url, new fetchKeywordsFileResponder(mFilenameSpec)); + LLHTTPClient::get(cap_url, new fetchKeywordsFileResponder(mFullFileSpec)); } return fetched; @@ -203,26 +206,34 @@ bool LLSyntaxIdLSL::fetchKeywordsFile() void LLSyntaxIdLSL::initialise() { - mRegion = gAgent.getRegion(); - if (checkSyntaxIdChange()) + if (checkSyntaxIdChanged()) { - mFilenameFull = gDirUtilp->getExpandedFilename( - mFilenameLocation, - mFilenameCurrent - ); + LL_WARNS("LSLSyntax") + << "Change to syntax, setting up new file." + << LL_ENDL; + + setFileNameNew(gDirUtilp->getExpandedFilename( + mFilePath, + mFileNameCurrent + )); if ( !mCurrentSyntaxId.isNull() ) { - bool success = true; - if (!gDirUtilp->fileExists(mFilenameSpec)) - { - //mResponder = new fetchKeywordsFileResponder(mFilenameSpec); + bool success = false; + if ( !gDirUtilp->fileExists(mFullFileSpec) ) + { // Does not exist, so fetch it from the capability success = fetchKeywordsFile(); } } // TODO add a signal here to tell the editor the hash has changed? } + else + { + LL_WARNS("LSLSyntax") + << "Apparently there is no change to Syntax!" + << LL_ENDL; - mRegion = NULL; + } + //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); } //----------------------------------------------------------------------------- diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index e32fcf209e..f7e3d6896e 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -12,9 +12,6 @@ #include "llviewerregion.h" -//class LLKeywords; - - /** * @file llsyntaxid.h * @brief The LLSyntaxIdLSL class @@ -22,45 +19,45 @@ class LLSyntaxIdLSL { public: - /** - * @brief LLSyntaxIdLSL constructor - */ LLSyntaxIdLSL(); - LLUUID getSyntaxId() const { return mCurrentSyntaxId; } + 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; } - bool checkSyntaxIdChange(); - std::string filenameCurrent() { return mFilenameCurrent; } - ELLPath filenamePath() { return mFilenameLocation; } - void initialise(); - static void setKeywordsXml(const LLSD& content) { LLSyntaxIdLSL::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 setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; } + 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: - static LLHTTPClient::ResponderPtr mResponder; + +//public: protected: -// LLKeywords& mKeywords; - LLViewerRegion* mRegion; + LLViewerRegion* region; + private: - std::string mCapabilityName; - LLUUID mCurrentSyntaxId; - std::string mFilenameCurrent; - std::string mFilenameDefault; - std::string mFilenameFull; - ELLPath mFilenameLocation; - std::string mFilenameSpec; - std::string mSimulatorFeature; - - static LLSD sKeywordsXml; + std::string mCapabilityName; + LLUUID mCurrentSyntaxId; + std::string mFileNameCurrent; + std::string mFileNameDefault; + std::string mFileNameNew; + ELLPath mFilePath; + std::string mFullFileSpec; + std::string mSimulatorFeature; + + static LLSD sKeywordsXml; }; -- cgit v1.3 From 87978dc481b54b0b5528949e291c5fe06e5e10eb Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 25 Oct 2013 16:30:33 +0100 Subject: storm-1831 fixes for setKeywordsXml --- indra/newview/llsyntaxid.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 442793bff1..4b7a420384 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -64,9 +64,12 @@ public: 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); + //LLSyntaxIdLSL::setKeywordsXml(xml); LL_WARNS("") << "fetchKeywordsFileResponder result:" << str.str() << "filename: '" << mFileSpec << "'" -- cgit v1.3 From bf2aad25f4db1564483f3450623775e53822346d Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 25 Oct 2013 19:29:06 +0100 Subject: cleaning out extra (commented) setKeywordsXml call --- indra/newview/llsyntaxid.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 4b7a420384..b917134037 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -69,11 +69,10 @@ public: LLSD& xml = LLSD::emptyMap(); LLSDSerialize::deserialize(xml, str, 10485760); - //LLSyntaxIdLSL::setKeywordsXml(xml); LL_WARNS("") - << "fetchKeywordsFileResponder result:" << str.str() - << "filename: '" << mFileSpec << "'" - << LL_ENDL; + << "fetchKeywordsFileResponder result:" << str.str() + << "filename: '" << mFileSpec << "'" + << LL_ENDL; // TODO save the damn str to disc //llofstream file(mFileSpec, std::ios_base::out); -- cgit v1.3 From 0ce27cfdebfd7722bb51c229abf26a5ee1c11d43 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 7 Nov 2013 18:12:45 +0000 Subject: storm-1831 General cleanup of cruft created during caps experiments ;-) --- indra/newview/llsyntaxid.cpp | 191 ++++++++++++++++++++++++++----------------- indra/newview/llsyntaxid.h | 31 +++++-- 2 files changed, 142 insertions(+), 80 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 442793bff1..7d0c7e376a 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -31,53 +31,54 @@ #include "llhttpclient.h" #include "llagent.h" #include "llappviewer.h" -#include "llcurl.h" -#include "llenvmanager.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("") + << "Instantiating with file saving to: '" << filespec << "'" + << LL_ENDL; +} - fetchKeywordsFileResponder(std::string filespec) - { - mFileSpec = filespec; - } - void errorWithContent(U32 status, +void fetchKeywordsFileResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content) - { - LL_WARNS("") - << "fetchKeywordsFileResponder error [status:" - << status - << "]: " - << content - << LL_ENDL; - } +{ + LL_WARNS("") + << "fetchKeywordsFileResponder error [status:" + << status + << "]: " + << content + << LL_ENDL; +} - void result(const LLSD& content_ref) - { - //LLSyntaxIdLSL::setKeywordsXml(content_ref); +void fetchKeywordsFileResponder::result(const LLSD& content_ref) +{ + LLSyntaxIdLSL::setKeywordsXml(content_ref); - std::stringstream str; - LLSDSerialize::toPrettyXML(content_ref, str); - LL_WARNS("") - << "fetchKeywordsFileResponder result:" << str.str() - << "filename: '" << mFileSpec << "'" - << LL_ENDL; + std::stringstream str; + LLSDSerialize::toPrettyXML(content_ref, str); + const std::string xml = str.str(); - // TODO save the damn str to disc - //llofstream file(mFileSpec, std::ios_base::out); - //file.write(str.str(), str.str().size()); - //file.close(); - } -}; + // save the str to disc + llofstream file(mFileSpec, std::ios_base::out); + file.write(xml.c_str(), str.str().size()); + file.close(); + + LL_WARNS("") + << "Syntax file received, saving as: '" << mFileSpec << "'" + << LL_ENDL; +} + + +LLSD LLSyntaxIdLSL::sKeywordsXml; //----------------------------------------------------------------------------- // LLSyntaxIdLSL @@ -90,16 +91,34 @@ 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) +std::string LLSyntaxIdLSL::buildFileNameNew() { - std::string filename = "keywords_lsl_" + SyntaxId.asString() + "_" + gLastVersionChannel + ".llsd.xml"; - return filename; + 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() +{ + ELLPath path = mSyntaxIdNew.isNull() ? LL_PATH_APP_SETTINGS : LL_PATH_CACHE; + buildFileNameNew(); + mFullFileSpec = gDirUtilp->getExpandedFilename(path, mFileNameNew); + return mFullFileSpec; } //----------------------------------------------------------------------------- @@ -112,15 +131,9 @@ 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)); + //region->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this)); LL_WARNS("LSLSyntax") << "region '" << region->getName() << "' has not received capabilities yet! Setting a callback for when they arrive." @@ -133,18 +146,18 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() region->getSimulatorFeatures(simFeatures); 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; + //mFileNameNew = buildFileNameNew(mSyntaxIdNew); + //mFilePath = LL_PATH_CACHE; LL_WARNS("LSLSyntax") << "Region changed to '" << region->getName() << "' it has LSLSyntaxId capability, and the new hash is '" - << SyntaxId << "'" + << mSyntaxIdNew << "'" << LL_ENDL; changed = true; @@ -154,14 +167,14 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() LL_WARNS("LSLSyntax") << "Region changed to '" << 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() @@ -170,9 +183,9 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() } else { - mCurrentSyntaxId = LLUUID(); - mFileNameCurrent = mFileNameDefault; - mFilePath = LL_PATH_APP_SETTINGS; + mSyntaxIdNew = LLUUID(); + //mFileNameNew = mFileNameDefault; + //mFilePath = LL_PATH_APP_SETTINGS; LL_WARNS("LSLSyntax") << "Region changed to '" << region->getName() @@ -190,18 +203,27 @@ 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)); + //buildFullFileSpec(); + LLHTTPClient::get(mCapabilityURL, + new fetchKeywordsFileResponder(mFullFileSpec), + LLSD(), 30.f + ); + LL_WARNS("LSLSyntax") + << "LSLSyntaxId capability URL is: " << mCapabilityURL + << ". Filename to use is: '" << mFullFileSpec << "'." + << LL_ENDL; + } + else + { + LL_WARNS("LSLSyntax") + << "LSLSyntaxId capability URL is empty using capability: '" + << mCapabilityName << "'" + << LL_ENDL; } - - return fetched; } void LLSyntaxIdLSL::initialise() @@ -212,24 +234,42 @@ void LLSyntaxIdLSL::initialise() << "Change to syntax, setting up new file." << LL_ENDL; - setFileNameNew(gDirUtilp->getExpandedFilename( - mFilePath, - mFileNameCurrent - )); - if ( !mCurrentSyntaxId.isNull() ) + // Need a full spec built regardless of file source + buildFullFileSpec(); + if ( !mSyntaxIdNew.isNull() ) { - bool success = false; + LL_WARNS("LSLSyntax") + << "ID is not null so must be processed!" + << LL_ENDL; + if ( !gDirUtilp->fileExists(mFullFileSpec) ) { // Does not exist, so fetch it from the capability - success = fetchKeywordsFile(); + fetchKeywordsFile(); + LL_WARNS("LSLSyntax") + << "Filename is not cached, we will try to download it!" + << LL_ENDL; + } + else + { + LL_WARNS("LSLSyntax") + << "Filename is cached, no need to download!" + << LL_ENDL; + openKeywordsFile(); } } + else + { // Need to open the default + LL_WARNS("LSLSyntax") + << "ID is null so SyntaxID does not need to be processed!" + << LL_ENDL; + openKeywordsFile(); + } // TODO add a signal here to tell the editor the hash has changed? } else { LL_WARNS("LSLSyntax") - << "Apparently there is no change to Syntax!" + << "No change to Syntax! Nothing to see here. Move along now!" << LL_ENDL; } @@ -239,7 +279,10 @@ void LLSyntaxIdLSL::initialise() //----------------------------------------------------------------------------- // openKeywordsFile //----------------------------------------------------------------------------- -void openKeywordsFile() +void LLSyntaxIdLSL::openKeywordsFile() { - ; + LL_WARNS("LSLSyntax") + << "Trying to open default or cached keyword file ;-)" + << LL_ENDL; + // TODO Open the file and load LLSD into sKeywordsXml } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index f7e3d6896e..d9f2572863 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -12,6 +12,21 @@ #include "llviewerregion.h" +class fetchKeywordsFileResponder : public LLHTTPClient::Responder +{ +public: + std::string mFileSpec; + + fetchKeywordsFileResponder(std::string filespec); + + void errorWithContent(U32 status, + const std::string& reason, + const LLSD& content); + + void result(const LLSD& content_ref); +}; + + /** * @file llsyntaxid.h * @brief The LLSyntaxIdLSL class @@ -24,7 +39,7 @@ public: bool checkSyntaxIdChanged(); std::string getFileNameCurrent() const { return mFileNameCurrent; } ELLPath getFilePath() const { return mFilePath; } - LLUUID getSyntaxId() const { return mCurrentSyntaxId; } + LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } void initialise(); @@ -32,13 +47,14 @@ public: protected: - std::string buildFileName(LLUUID& SyntaxId); - bool fetchKeywordsFile(); + std::string buildFileNameNew(); + std::string buildFullFileSpec(); + void fetchKeywordsFile(); void openKeywordsFile(); - void setSyntaxId(LLUUID SyntaxId) { mCurrentSyntaxId = SyntaxId; } + 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 setFileNameNew(std::string name) { mFileNameNew = name; } void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; } @@ -51,13 +67,16 @@ 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; + }; -- cgit v1.3 From c8b8c29371a0eb4d53537030d0b007afcc500b3d Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 7 Nov 2013 18:31:05 +0000 Subject: Fixing LL_WARNS without labels and removing some crufty comments missed before --- indra/newview/llsyntaxid.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 7d0c7e376a..0249607834 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -41,7 +41,7 @@ fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec) { mFileSpec = filespec; - LL_WARNS("") + LL_WARNS("LSLSyntax") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; } @@ -51,7 +51,7 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content) { - LL_WARNS("") + LL_WARNS("LSLSyntax") << "fetchKeywordsFileResponder error [status:" << status << "]: " @@ -72,7 +72,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) file.write(xml.c_str(), str.str().size()); file.close(); - LL_WARNS("") + LL_WARNS("LSLSyntax") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; } @@ -150,10 +150,6 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() mCapabilityURL = region->getCapability(mCapabilityName); if (mSyntaxIdCurrent != mSyntaxIdNew) { - // set the properties for the fetcher to use - //mFileNameNew = buildFileNameNew(mSyntaxIdNew); - //mFilePath = LL_PATH_CACHE; - LL_WARNS("LSLSyntax") << "Region changed to '" << region->getName() << "' it has LSLSyntaxId capability, and the new hash is '" @@ -184,8 +180,6 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() else { mSyntaxIdNew = LLUUID(); - //mFileNameNew = mFileNameDefault; - //mFilePath = LL_PATH_APP_SETTINGS; LL_WARNS("LSLSyntax") << "Region changed to '" << region->getName() -- cgit v1.3 From 4af21580297dd85727ffdc5d4eee89ad58ead271 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:31:32 +0000 Subject: Adding method to load cached/default syntax file and method to access sKeyWordsXML. --- indra/llui/llkeywords.cpp | 12 +++++----- indra/llui/llkeywords.h | 20 ++++++++--------- indra/newview/llpreviewscript.cpp | 15 ++++++++----- indra/newview/llpreviewscript.h | 1 + indra/newview/llsyntaxid.cpp | 47 ++++++++++++++++++++++++++++++++------- indra/newview/llsyntaxid.h | 4 +++- 6 files changed, 69 insertions(+), 30 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 687c2fb31d..832264f074 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,7 +34,7 @@ #include "lltexteditor.h" #include "llstl.h" -inline BOOL LLKeywordToken::isHead(const llwchar* s) const +inline bool LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; @@ -51,7 +51,7 @@ inline BOOL LLKeywordToken::isHead(const llwchar* s) const return res; } -inline BOOL LLKeywordToken::isTail(const llwchar* s) const +inline bool LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; const llwchar* t = mDelimiter.c_str(); @@ -198,7 +198,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -BOOL LLKeywords::initialise(ELLPath path, const std::string filename) +bool LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); @@ -214,7 +214,7 @@ BOOL LLKeywords::initialise(ELLPath path, const std::string filename) return mReady; } -BOOL LLKeywords::loadFromFile() +bool LLKeywords::loadFromFile() { processTokens(); return true; @@ -226,14 +226,14 @@ BOOL LLKeywords::loadFromFile() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +bool LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) { mLoaded = false; llifstream file; file.open(filename); if(file.is_open()) { - mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); + mLoaded = (bool)LLSDSerialize::fromXML(data, file); if (!mLoaded) { LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 1bd23549d2..f98453405d 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -83,8 +83,8 @@ public: S32 getLengthHead() const { return mToken.size(); } S32 getLengthTail() const { return mDelimiter.size(); } - BOOL isHead(const llwchar* s) const; - BOOL isTail(const llwchar* s) const; + bool isHead(const llwchar* s) const; + bool isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } @@ -111,13 +111,13 @@ public: void addColorGroup(const std::string key_in, const LLColor4 color); LLColor4 getColorGroup(const std::string key_in); - BOOL loadFromFile(); - BOOL loadFromFile(const std::string& filename); - BOOL isLoaded() const { return mLoaded; } + bool loadFromFile(); + bool loadFromFile(const std::string& filename); + bool isLoaded() const { return mLoaded; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - BOOL initialise(ELLPath path, const std::string filename); + bool initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); @@ -176,10 +176,10 @@ protected: LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); - BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); + bool loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - BOOL mLoaded; + bool mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,8 +194,8 @@ protected: std::string getArguments(LLSD& args); private: - BOOL ready() { return mReady; } - BOOL mReady; + bool ready() { return mReady; } + bool mReady; std::string mFilenameSyntax; }; 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 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; } -- cgit v1.3 From 29b2129e1eec0dbbb909422e82766a58f14c5da3 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:32:08 +0000 Subject: Backed out changeset: e82d9467bec8 --- indra/llui/llkeywords.cpp | 12 +++++----- indra/llui/llkeywords.h | 20 ++++++++--------- indra/newview/llpreviewscript.cpp | 15 +++++-------- indra/newview/llpreviewscript.h | 1 - indra/newview/llsyntaxid.cpp | 47 +++++++-------------------------------- indra/newview/llsyntaxid.h | 4 +--- 6 files changed, 30 insertions(+), 69 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 832264f074..687c2fb31d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,7 +34,7 @@ #include "lltexteditor.h" #include "llstl.h" -inline bool LLKeywordToken::isHead(const llwchar* s) const +inline BOOL LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; @@ -51,7 +51,7 @@ inline bool LLKeywordToken::isHead(const llwchar* s) const return res; } -inline bool LLKeywordToken::isTail(const llwchar* s) const +inline BOOL LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; const llwchar* t = mDelimiter.c_str(); @@ -198,7 +198,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -bool LLKeywords::initialise(ELLPath path, const std::string filename) +BOOL LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); @@ -214,7 +214,7 @@ bool LLKeywords::initialise(ELLPath path, const std::string filename) return mReady; } -bool LLKeywords::loadFromFile() +BOOL LLKeywords::loadFromFile() { processTokens(); return true; @@ -226,14 +226,14 @@ bool LLKeywords::loadFromFile() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -bool LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) { mLoaded = false; llifstream file; file.open(filename); if(file.is_open()) { - mLoaded = (bool)LLSDSerialize::fromXML(data, file); + mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); if (!mLoaded) { LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index f98453405d..1bd23549d2 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -83,8 +83,8 @@ public: S32 getLengthHead() const { return mToken.size(); } S32 getLengthTail() const { return mDelimiter.size(); } - bool isHead(const llwchar* s) const; - bool isTail(const llwchar* s) const; + BOOL isHead(const llwchar* s) const; + BOOL isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } @@ -111,13 +111,13 @@ public: void addColorGroup(const std::string key_in, const LLColor4 color); LLColor4 getColorGroup(const std::string key_in); - bool loadFromFile(); - bool loadFromFile(const std::string& filename); - bool isLoaded() const { return mLoaded; } + BOOL loadFromFile(); + BOOL loadFromFile(const std::string& filename); + BOOL isLoaded() const { return mLoaded; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - bool initialise(ELLPath path, const std::string filename); + BOOL initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); @@ -176,10 +176,10 @@ protected: LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); - bool loadIntoLLSD( const std::string& filename, LLSD& data ); + BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - bool mLoaded; + BOOL mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,8 +194,8 @@ protected: std::string getArguments(LLSD& args); private: - bool ready() { return mReady; } - bool mReady; + BOOL ready() { return mReady; } + BOOL mReady; std::string mFilenameSyntax; }; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 705872328a..5f23249c8d 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -406,7 +406,11 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLScriptEdCore::initKeywords(), this)); +// Make this work ;-) + mSyntaxIdLSL.initialise(); + // ... + mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); +// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec()); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; @@ -452,15 +456,6 @@ 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 149c27461e..73ccaab0b8 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -78,7 +78,6 @@ 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 00e6086546..0249607834 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; - loadKeywordsFileIntoLLSD(); + openKeywordsFile(); } } else @@ -256,58 +256,27 @@ void LLSyntaxIdLSL::initialise() LL_WARNS("LSLSyntax") << "ID is null so SyntaxID does not need to be processed!" << LL_ENDL; - loadKeywordsFileIntoLLSD(); + openKeywordsFile(); } - mFileNameCurrent = mFileNameNew; - mSyntaxIdCurrent = mSyntaxIdNew; + // TODO add a signal here to tell the editor the hash has changed? } 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)); } //----------------------------------------------------------------------------- -// loadKeywordsFileIntoLLSD +// 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() +void LLSyntaxIdLSL::openKeywordsFile() { LL_WARNS("LSLSyntax") << "Trying to open default or cached 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: " << 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; + // TODO Open the file and load LLSD into sKeywordsXml } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 50013a8380..d9f2572863 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -39,7 +39,6 @@ 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(); @@ -51,8 +50,7 @@ protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); void fetchKeywordsFile(); - //void openKeywordsFile(); - bool loadKeywordsFileIntoLLSD(); + void openKeywordsFile(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } void setFileNameDefault(std::string& name) { mFileNameDefault = name; } -- cgit v1.3 From 3b03ffbd70bff48a747f9f3a45056069724fc42f Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:39:53 +0000 Subject: Changing method openKeywordFile to loadKeywordFileIntoLLSD to load cached/default syntax file and method to access sKeyWordsXML. loadKeywordFileIntoLLSD was taken almost verbatim from LLKeywords::loadIntoLLSD which can be removed later. I know the name is long but I wanted to remember where it came from and why it is how it is. Removed a little cruft also. --- indra/newview/llsyntaxid.cpp | 47 ++++++++++++++++++++++++++++++++++++-------- indra/newview/llsyntaxid.h | 4 +++- 2 files changed, 42 insertions(+), 9 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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; } -- cgit v1.3 From bea2e9822b52b66e3644925143b852526c669248 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:51:45 +0000 Subject: Fixing some references to 'filename' I forgot to rename to mFullFileSpec. --- doc/contributions.txt | 3 ++- indra/newview/llsyntaxid.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/doc/contributions.txt b/doc/contributions.txt index 4ce074506b..03f0194a47 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -514,7 +514,8 @@ Ima Mechanique VWR-10791 VWR-20553 VWR-19213 - VWR-23739 + VWR-22401 + VWR-23739 VWR-24766 VWR-28065 Imnotgoing Sideways diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 00e6086546..c5960fb16e 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -293,7 +293,7 @@ bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD() loaded = (bool)LLSDSerialize::fromXML(content, file); if (!loaded) { - LL_WARNS("LSLSyntax") << "Unable to deserialise file: " << filename << LL_ENDL; + 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? @@ -302,12 +302,12 @@ bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD() else { sKeywordsXml = content; - LL_INFOS("LSLSyntax") << "Deserialised file: " << filename << LL_ENDL; + LL_INFOS("LSLSyntax") << "Deserialised file: " << mFullFileSpec << LL_ENDL; } } else { - LL_WARNS("LSLSyntax") << "Unable to open file: " << filename << LL_ENDL; + LL_WARNS("LSLSyntax") << "Unable to open file: " << mFullFileSpec << LL_ENDL; } return loaded; } -- cgit v1.3 From a4c5b5c416e9a289fa2caa6d61d05e1f68605b5a Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 17:39:34 +0000 Subject: Fixing missing parenthesis. --- indra/newview/llsyntaxid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index c5960fb16e..2388f1c5ef 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -297,7 +297,7 @@ bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD() // 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(); + sKeywordsXml = LLSD().emptyMap(); } else { -- cgit v1.3 From da0cd7b845028f679e6ce7243715d52481f0c430 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 17:43:17 +0000 Subject: Adding getter for mFullFileSpec, shortening loadKeywordsFileIntoLLSD to loadKeywordsIntoLLSD. --- indra/newview/llsyntaxid.cpp | 6 +++--- indra/newview/llsyntaxid.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 2388f1c5ef..18869c215d 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; - loadKeywordsFileIntoLLSD(); + loadKeywordsIntoLLSD(); } } else @@ -256,7 +256,7 @@ void LLSyntaxIdLSL::initialise() LL_WARNS("LSLSyntax") << "ID is null so SyntaxID does not need to be processed!" << LL_ENDL; - loadKeywordsFileIntoLLSD(); + loadKeywordsIntoLLSD(); } mFileNameCurrent = mFileNameNew; mSyntaxIdCurrent = mSyntaxIdNew; @@ -278,7 +278,7 @@ void LLSyntaxIdLSL::initialise() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD() +bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() { LL_WARNS("LSLSyntax") << "Trying to open default or cached keyword file ;-)" diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 50013a8380..fc875a835f 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; } + std::string getFileSpec() const { return mFullFileSpec; } LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } @@ -51,8 +52,7 @@ protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); void fetchKeywordsFile(); - //void openKeywordsFile(); - bool loadKeywordsFileIntoLLSD(); + bool loadKeywordsIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } void setFileNameDefault(std::string& name) { mFileNameDefault = name; } -- cgit v1.3 From 06ed74f177983e2eb170426712f422253a0b48e7 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 18:29:22 +0000 Subject: Tidying up llsyntaxid files --- indra/newview/llsyntaxid.cpp | 40 ++++++++++++++--------------- indra/newview/llsyntaxid.h | 60 ++++++++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 46 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 18869c215d..5d8879195a 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -28,9 +28,9 @@ #include "llviewerprecompiledheaders.h" -#include "llhttpclient.h" #include "llagent.h" #include "llappviewer.h" +#include "llhttpclient.h" #include "llsdserialize.h" #include "llsyntaxid.h" @@ -46,10 +46,9 @@ fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec) << LL_ENDL; } - void fetchKeywordsFileResponder::errorWithContent(U32 status, - const std::string& reason, - const LLSD& content) + const std::string& reason, + const LLSD& content) { LL_WARNS("LSLSyntax") << "fetchKeywordsFileResponder error [status:" @@ -67,7 +66,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) LLSDSerialize::toPrettyXML(content_ref, str); const std::string xml = str.str(); - // save the str to disc + // 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(); @@ -78,8 +77,6 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) } -LLSD LLSyntaxIdLSL::sKeywordsXml; - //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- @@ -98,6 +95,8 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() : mFileNameCurrent = mFileNameDefault; } +LLSD LLSyntaxIdLSL::sKeywordsXml; + std::string LLSyntaxIdLSL::buildFileNameNew() { std::string filename = "keywords_lsl_"; @@ -151,7 +150,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() if (mSyntaxIdCurrent != mSyntaxIdNew) { LL_WARNS("LSLSyntax") - << "Region changed to '" << region->getName() + << "Region is '" << region->getName() << "' it has LSLSyntaxId capability, and the new hash is '" << mSyntaxIdNew << "'" << LL_ENDL; @@ -161,7 +160,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() else { LL_WARNS("LSLSyntax") - << "Region changed to '" << region->getName() + << "Region is '" << region->getName() << "' it has the same LSLSyntaxId! Leaving hash as '" << mSyntaxIdCurrent << "'" << LL_ENDL; @@ -173,7 +172,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() if ( mSyntaxIdCurrent.isNull() ) { LL_WARNS("LSLSyntax") - << "Region changed to '" << region->getName() + << "Region is '" << region->getName() << " it does not have LSLSyntaxId capability, remaining with default keywords file!" << LL_ENDL; } @@ -182,7 +181,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() mSyntaxIdNew = LLUUID(); LL_WARNS("LSLSyntax") - << "Region changed to '" << region->getName() + << "Region is '" << region->getName() << " it does not have LSLSyntaxId capability, using default keywords file!" << LL_ENDL; @@ -201,7 +200,6 @@ void LLSyntaxIdLSL::fetchKeywordsFile() { if ( !mCapabilityURL.empty() ) { - //buildFullFileSpec(); LLHTTPClient::get(mCapabilityURL, new fetchKeywordsFileResponder(mFullFileSpec), LLSD(), 30.f @@ -225,28 +223,28 @@ void LLSyntaxIdLSL::initialise() if (checkSyntaxIdChanged()) { LL_WARNS("LSLSyntax") - << "Change to syntax, setting up new file." + << "Change to LSL version, getting appropriate file." << LL_ENDL; - // Need a full spec built regardless of file source + // Need a full spec regardless of file source, so build it now. buildFullFileSpec(); if ( !mSyntaxIdNew.isNull() ) { LL_WARNS("LSLSyntax") - << "ID is not null so must be processed!" + << "We have an ID for the version, so we will process it!" << LL_ENDL; if ( !gDirUtilp->fileExists(mFullFileSpec) ) { // Does not exist, so fetch it from the capability fetchKeywordsFile(); LL_WARNS("LSLSyntax") - << "Filename is not cached, we will try to download it!" + << "File is not cached, we will try to download it!" << LL_ENDL; } else { LL_WARNS("LSLSyntax") - << "Filename is cached, no need to download!" + << "File is cached, no need to download!" << LL_ENDL; loadKeywordsIntoLLSD(); } @@ -254,7 +252,7 @@ void LLSyntaxIdLSL::initialise() else { // Need to open the default LL_WARNS("LSLSyntax") - << "ID is null so SyntaxID does not need to be processed!" + << "ID is null so we will use the default file!" << LL_ENDL; loadKeywordsIntoLLSD(); } @@ -263,8 +261,8 @@ void LLSyntaxIdLSL::initialise() } else { - LL_WARNS("LSLSyntax") - << "No change to Syntax! Nothing to see here. Move along now!" + LL_INFOS("LSLSyntax") + << "No change to Syntax! Nothing to see. Move along now!" << LL_ENDL; } } @@ -281,7 +279,7 @@ void LLSyntaxIdLSL::initialise() bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() { LL_WARNS("LSLSyntax") - << "Trying to open default or cached keyword file ;-)" + << "Trying to open cached or default keyword file ;-)" << LL_ENDL; bool loaded = false; diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index fc875a835f..472e88744f 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -11,28 +11,61 @@ #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: + + +protected: + LLViewerRegion* region; + + +private: + std::string mCapabilityName; + 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(); @@ -58,27 +91,4 @@ protected: void setFileNameDefault(std::string& name) { mFileNameDefault = name; } void setFileNameNew(std::string name) { mFileNameNew = name; } void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; } - - -//public: - - -protected: - LLViewerRegion* region; - - -private: - std::string mCapabilityName; - 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; - }; -- cgit v1.3 From 483c829aa370dabfc18cbba770a347b25ec80010 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 21 Nov 2013 02:37:40 +0000 Subject: storm-1831 Removing am uneccessary message. --- indra/newview/llsyntaxid.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 66e0777525..e09b083d9c 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -223,10 +223,6 @@ void LLSyntaxIdLSL::initialise() buildFullFileSpec(); if ( !mSyntaxIdNew.isNull() ) { - 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 fetchKeywordsFile(); -- cgit v1.3 From b5eb40cfd4849685274f9545b22becd90ba7c858 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 21 Nov 2013 19:28:35 +0000 Subject: storm-1831 Cleaning up output messages SyntaxLSL. --- indra/newview/llsyntaxid.cpp | 55 ++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index e09b083d9c..605d49b175 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -41,7 +41,7 @@ fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec) { mFileSpec = filespec; - LL_WARNS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; } @@ -50,11 +50,9 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content) { - LL_WARNS("LSLSyntax") + LL_ERRS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" - << status - << "]: " - << content + << status << "]: " << content << LL_ENDL; } @@ -71,7 +69,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) file.write(xml.c_str(), str.str().size()); file.close(); - LL_WARNS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; } @@ -131,8 +129,8 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() { if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it may be needed. - LL_WARNS("LSLSyntax") - << "region '" << region->getName() + LL_WARNS("SyntaxLSL") + << "Region '" << region->getName() << "' has not received capabilities yet! Cannot process SyntaxId." << LL_ENDL; } @@ -149,23 +147,16 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() mCapabilityURL = region->getCapability(mCapabilityName); if (mSyntaxIdCurrent != mSyntaxIdNew) { - LL_WARNS("LSLSyntax") - << "Region is '" << region->getName() - << "' it has LSLSyntaxId capability, and the new hash is '" - << mSyntaxIdNew << "'" - << LL_ENDL; + message = "' it has LSLSyntaxId capability, and the new hash is '" + + mSyntaxIdNew.asString() + "'"; changed = true; } else { - LL_WARNS("LSLSyntax") - << "Region is '" << region->getName() - << "' it has the same LSLSyntaxId! Leaving hash as '" - << mSyntaxIdCurrent << "'" - << LL_ENDL; + message = "' it has the same LSLSyntaxId! Leaving hash as '" + + mSyntaxIdCurrent + "'"; } - } else { @@ -180,9 +171,9 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() message = " it does not have LSLSyntaxId capability, using default keywords file!"; changed = true; } - LL_WARNS("LSLSyntax") - << "Region is '" << region->getName() << message << LL_ENDL; } + LL_INFOS("SyntaxLSL") + << "Region is '" << region->getName() << message << LL_ENDL; } } return changed; @@ -199,14 +190,14 @@ void LLSyntaxIdLSL::fetchKeywordsFile() new fetchKeywordsFileResponder(mFullFileSpec), LLSD(), 30.f ); - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << mFullFileSpec << "'." << LL_ENDL; } else { - LL_WARNS("LSLSyntax") + LL_ERRS("SyntaxLSL") << "LSLSyntaxId capability URL is empty!!" << LL_ENDL; } } @@ -215,7 +206,7 @@ void LLSyntaxIdLSL::initialise() { if (checkSyntaxIdChanged()) { - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "LSL version has changed, getting appropriate file." << LL_ENDL; @@ -226,13 +217,13 @@ void LLSyntaxIdLSL::initialise() if ( !gDirUtilp->fileExists(mFullFileSpec) ) { // Does not exist, so fetch it from the capability fetchKeywordsFile(); - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "File is not cached, we will try to download it!" << LL_ENDL; } else { - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "File is cached, no need to download!" << LL_ENDL; loadKeywordsIntoLLSD(); @@ -240,7 +231,7 @@ void LLSyntaxIdLSL::initialise() } else { // Need to open the default - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; loadKeywordsIntoLLSD(); @@ -250,7 +241,7 @@ void LLSyntaxIdLSL::initialise() } else { - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "No change to Syntax! Nothing to see. Move along now!" << LL_ENDL; } @@ -267,7 +258,7 @@ void LLSyntaxIdLSL::initialise() */ bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() { - LL_INFOS("LSLSyntax") + LL_INFOS("SyntaxLSL") << "Trying to open cached or default keyword file ;-)" << LL_ENDL; @@ -280,7 +271,7 @@ bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() loaded = (bool)LLSDSerialize::fromXML(content, file); if (!loaded) { - LL_WARNS("LSLSyntax") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; + LL_ERRS("SyntaxLSL") << "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? @@ -289,12 +280,12 @@ bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() else { sKeywordsXml = content; - LL_INFOS("LSLSyntax") << "Deserialised file: " << mFullFileSpec << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; } } else { - LL_WARNS("LSLSyntax") << "Unable to open file: " << mFullFileSpec << LL_ENDL; + LL_ERRS("SyntaxLSL") << "Unable to open file: " << mFullFileSpec << LL_ENDL; } return loaded; } -- cgit v1.3 From 380334956c6689c2091e95969a7f79a29db49a4d Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 21 Nov 2013 21:29:24 +0000 Subject: storm-1831 Fixing message string UUID assignment --- indra/newview/llsyntaxid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 605d49b175..43f840544c 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -155,7 +155,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() else { message = "' it has the same LSLSyntaxId! Leaving hash as '" - + mSyntaxIdCurrent + "'"; + + mSyntaxIdCurrent.asString() + "'"; } } else -- cgit v1.3 From b18c9578b58ed7f98cd162adcecbf9df253263c9 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 19 Dec 2013 04:27:28 +0000 Subject: Fixing loading of default keywords file when nothing has been previously loaded. --- indra/newview/llsyntaxid.cpp | 40 +++++++++++++++++++++++----------------- indra/newview/llsyntaxid.h | 1 + 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 43f840544c..94226b82b1 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -96,16 +96,7 @@ 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"; + mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + gLastVersionChannel + "_" + mSyntaxIdNew.asString() + ".llsd.xml"; return mFileNameNew; } @@ -204,6 +195,8 @@ void LLSyntaxIdLSL::fetchKeywordsFile() void LLSyntaxIdLSL::initialise() { + mFileNameNew = mFileNameCurrent; + mSyntaxIdNew = mSyntaxIdCurrent; if (checkSyntaxIdChanged()) { LL_INFOS("SyntaxLSL") @@ -231,20 +224,33 @@ void LLSyntaxIdLSL::initialise() } else { // Need to open the default - LL_INFOS("SyntaxLSL") - << "LSLSyntaxId is null so we will use the default file!" - << LL_ENDL; - loadKeywordsIntoLLSD(); + loadDefaultKeywordsIntoLLSD("LSLSyntaxId is null so we will use the default file!"); } - mFileNameCurrent = mFileNameNew; - mSyntaxIdCurrent = mSyntaxIdNew; } - else + else if (sKeywordsXml.isDefined()) { LL_INFOS("SyntaxLSL") << "No change to Syntax! Nothing to see. Move along now!" << LL_ENDL; } + else + { // Need to open the default + loadDefaultKeywordsIntoLLSD("LSLSyntaxId is null so we will use the default file!"); + } + + mFileNameCurrent = mFileNameNew; + mSyntaxIdCurrent = mSyntaxIdNew; +} + +//----------------------------------------------------------------------------- +// loadDefaultKeywordsIntoLLSD() +//----------------------------------------------------------------------------- +void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD(const std::string message) +{ + LL_INFOS("SyntaxLSL") << message << LL_ENDL; + mSyntaxIdNew = LLUUID(); + buildFullFileSpec(); + loadKeywordsIntoLLSD(); } //----------------------------------------------------------------------------- diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 3a711d7460..b968dd233d 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -111,6 +111,7 @@ protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); void fetchKeywordsFile(); + void loadDefaultKeywordsIntoLLSD(const std::string message); bool loadKeywordsIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } -- cgit v1.3 From 11f7dd8cc7516a75aaf012cc47b90d33c3289033 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 14 Jan 2014 18:28:04 +0000 Subject: Adding TODO for LLSD validating and version check, while I wait for some info on how to do it. --- indra/newview/llsyntaxid.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 94226b82b1..2784939199 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -58,6 +58,8 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, void fetchKeywordsFileResponder::result(const LLSD& content_ref) { + // TODO check for llsd-lsl-syntax-version key and return if not present or not 1. + LLSyntaxIdLSL::setKeywordsXml(content_ref); std::stringstream str; -- cgit v1.3 From f14521e1d424425e2684467a829be38740332676 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 30 Jan 2014 12:59:24 +0000 Subject: strom-1832 Adding checks for validity and version when downloading XML --- indra/newview/llsyntaxid.cpp | 84 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 71 insertions(+), 13 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 2784939199..d54cc06490 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -34,7 +34,6 @@ #include "llsdserialize.h" #include "llsyntaxid.h" - //----------------------------------------------------------------------------- // fetchKeywordsFileResponder //----------------------------------------------------------------------------- @@ -58,21 +57,44 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, void fetchKeywordsFileResponder::result(const LLSD& content_ref) { - // TODO check for llsd-lsl-syntax-version key and return if not present or not 1. + // Continue only if a valid LLSD object was returned. + if (content_ref.isMap()) + { + LL_DEBUGS("SyntaxLSL") + << "content_ref isMap so assuming valid XML." << LL_ENDL; - LLSyntaxIdLSL::setKeywordsXml(content_ref); + if (LLSyntaxIdLSL::isSupportedVersion(content_ref)) + { + LL_INFOS("SyntaxLSL") + << "Is a supported verson of syntax file." << LL_ENDL; - std::stringstream str; - LLSDSerialize::toPrettyXML(content_ref, str); - const std::string xml = str.str(); + LLSyntaxIdLSL::setKeywordsXml(content_ref); + LLSyntaxIdLSL::sLoaded = true; - // 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(); + std::stringstream str; + LLSDSerialize::toPrettyXML(content_ref, str); + const std::string xml = str.str(); - LL_INFOS("SyntaxLSL") - << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; + // 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_INFOS("SyntaxLSL") + << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; + } + else + { + LL_WARNS("SyntaxLSL") + << "Unknown or unsupported version of syntax file." << LL_ENDL; + } + } + else + { + LLSyntaxIdLSL::sLoaded = false; + LL_ERRS("SyntaxLSL") + << "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL; + } } @@ -95,6 +117,7 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() : } LLSD LLSyntaxIdLSL::sKeywordsXml; +bool LLSyntaxIdLSL::sLoaded; std::string LLSyntaxIdLSL::buildFileNameNew() { @@ -179,6 +202,7 @@ void LLSyntaxIdLSL::fetchKeywordsFile() { if ( !mCapabilityURL.empty() ) { + //LLSyntaxIdLSL::sLoaded = false; LLHTTPClient::get(mCapabilityURL, new fetchKeywordsFileResponder(mFullFileSpec), LLSD(), 30.f @@ -195,6 +219,9 @@ void LLSyntaxIdLSL::fetchKeywordsFile() } } +//----------------------------------------------------------------------------- +// initialise +//----------------------------------------------------------------------------- void LLSyntaxIdLSL::initialise() { mFileNameNew = mFileNameCurrent; @@ -211,10 +238,10 @@ void LLSyntaxIdLSL::initialise() { if ( !gDirUtilp->fileExists(mFullFileSpec) ) { // Does not exist, so fetch it from the capability - fetchKeywordsFile(); LL_INFOS("SyntaxLSL") << "File is not cached, we will try to download it!" << LL_ENDL; + fetchKeywordsFile(); } else { @@ -244,6 +271,37 @@ void LLSyntaxIdLSL::initialise() mSyntaxIdCurrent = mSyntaxIdNew; } +//----------------------------------------------------------------------------- +// isSupportedVersion +//----------------------------------------------------------------------------- +bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) +{ + bool isValid = false; + /* + * If the schema used to store lsl keywords and hints changes, this value is incremented + * Note that it should _not_ be changed if the keywords and hints _content_ changes. + */ + const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; + const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); + + if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY)) + { + LL_INFOS("SyntaxLSL") + << "Syntax file version: " << content[LLSD_SYNTAX_LSL_VERSION_KEY].asString() << LL_ENDL; + + if (content[LLSD_SYNTAX_LSL_VERSION_KEY].asInteger() == LLSD_SYNTAX_LSL_VERSION_EXPECTED) + { + isValid = true; + } + } + else + { + LL_WARNS("SyntaxLSL") << "No version key available!" << LL_ENDL; + } + + return isValid; +} + //----------------------------------------------------------------------------- // loadDefaultKeywordsIntoLLSD() //----------------------------------------------------------------------------- -- cgit v1.3 From 93322ff17609ff4bb4f8f87f0b53783b68515279 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 30 Jan 2014 14:03:34 +0000 Subject: Removing duplication of messages --- indra/newview/llsyntaxid.cpp | 13 +++++++------ indra/newview/llsyntaxid.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index d54cc06490..f868d82f11 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -248,12 +248,12 @@ void LLSyntaxIdLSL::initialise() LL_INFOS("SyntaxLSL") << "File is cached, no need to download!" << LL_ENDL; - loadKeywordsIntoLLSD(); + sLoaded = loadKeywordsIntoLLSD(); } } else { // Need to open the default - loadDefaultKeywordsIntoLLSD("LSLSyntaxId is null so we will use the default file!"); + loadDefaultKeywordsIntoLLSD(); } } else if (sKeywordsXml.isDefined()) @@ -264,7 +264,7 @@ void LLSyntaxIdLSL::initialise() } else { // Need to open the default - loadDefaultKeywordsIntoLLSD("LSLSyntaxId is null so we will use the default file!"); + loadDefaultKeywordsIntoLLSD(); } mFileNameCurrent = mFileNameNew; @@ -305,12 +305,13 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) //----------------------------------------------------------------------------- // loadDefaultKeywordsIntoLLSD() //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD(const std::string message) +void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") << message << LL_ENDL; + LL_INFOS("SyntaxLSL") + << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; mSyntaxIdNew = LLUUID(); buildFullFileSpec(); - loadKeywordsIntoLLSD(); + sLoaded = loadKeywordsIntoLLSD(); } //----------------------------------------------------------------------------- diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 824454f9a1..78ea98e3cf 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -89,7 +89,7 @@ protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); void fetchKeywordsFile(); - void loadDefaultKeywordsIntoLLSD(const std::string message); + void loadDefaultKeywordsIntoLLSD(); bool loadKeywordsIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } -- cgit v1.3 From 2dc2ce995983bfa87527b4ca94d4f13eb94b5c80 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 31 Jan 2014 11:44:54 +0000 Subject: strom-1831 Cleaning up a number of issues raised. Adding some constants and member variables. Moving arguments into constructor signature and adding new signature. Breaking saving of file into its own method to separate it from checking the LLSD. Cleaning up severla of the logging messages. Differentiating between successful and failed loads/fetches using sLoaded/sLoadFail. --- indra/newview/llsyntaxid.cpp | 183 ++++++++++++++++++++++++++----------------- indra/newview/llsyntaxid.h | 28 +++++-- 2 files changed, 135 insertions(+), 76 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index f868d82f11..886dcfaac0 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -49,6 +49,7 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content) { + LLSyntaxIdLSL::sLoadFailed = true; LL_ERRS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" << status << "]: " << content @@ -70,21 +71,14 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) LLSyntaxIdLSL::setKeywordsXml(content_ref); LLSyntaxIdLSL::sLoaded = true; + LLSyntaxIdLSL::sLoadFailed = false; - 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_INFOS("SyntaxLSL") - << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; + cacheFile(content_ref); } else { + LLSyntaxIdLSL::sLoaded = false; + LLSyntaxIdLSL::sLoadFailed = true; LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } @@ -92,32 +86,59 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) else { LLSyntaxIdLSL::sLoaded = false; + LLSyntaxIdLSL::sLoadFailed = true; LL_ERRS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL; } } +void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) +{ + 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_INFOS("SyntaxLSL") + << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; +} + //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- +const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; +const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; +const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE ="LSLSyntaxId"; + +LLSD LLSyntaxIdLSL::sKeywordsXml; +bool LLSyntaxIdLSL::sLoaded; +bool LLSyntaxIdLSL::sLoadFailed; +bool LLSyntaxIdLSL::sVersionChanged; + /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL() : +LLSyntaxIdLSL::LLSyntaxIdLSL(std::string filenameDefault, std::string simulatorFeature, std::string capabilityName) : // Move these to signature? - mFileNameDefault("keywords_lsl_default.xml"), - mSimulatorFeature("LSLSyntaxId"), - mCapabilityName("LSLSyntax"), mCapabilityURL(""), mFilePath(LL_PATH_APP_SETTINGS) { + mCapabilityName = capabilityName; + mFileNameCurrent = filenameDefault; + mFileNameDefault = filenameDefault; + mSimulatorFeature = simulatorFeature; mSyntaxIdCurrent = LLUUID(); - mFileNameCurrent = mFileNameDefault; } -LLSD LLSyntaxIdLSL::sKeywordsXml; -bool LLSyntaxIdLSL::sLoaded; +LLSyntaxIdLSL::LLSyntaxIdLSL() +{ + LLSyntaxIdLSL(LLSyntaxIdLSL::FILENAME_DEFAULT, LLSyntaxIdLSL::SIMULATOR_FEATURE, LLSyntaxIdLSL::CAPABILITY_NAME); +} std::string LLSyntaxIdLSL::buildFileNameNew() { @@ -156,35 +177,42 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() std::string message; region->getSimulatorFeatures(simFeatures); + LL_INFOS("SyntaxLSL") << "Region is '" << region->getName() << "' ..." << LL_ENDL; + // get and check the hash if (simFeatures.has("LSLSyntaxId")) { mSyntaxIdNew = simFeatures["LSLSyntaxId"].asUUID(); - mCapabilityURL = region->getCapability(mCapabilityName); if (mSyntaxIdCurrent != mSyntaxIdNew) { - message = "' it has LSLSyntaxId capability, and the new hash is '" - + mSyntaxIdNew.asString() + "'"; + LL_INFOS("SyntaxLSL") + << "It has LSLSyntaxId capability, and the new hash is '" + << mSyntaxIdNew.asString() << "'" << LL_ENDL; changed = true; } else { - message = "' it has the same LSLSyntaxId! Leaving hash as '" - + mSyntaxIdCurrent.asString() + "'"; + LL_INFOS("SyntaxLSL") + << "It has the same LSLSyntaxId! Leaving hash as '" + << mSyntaxIdCurrent.asString() << "'" << LL_ENDL; } } else { if ( mSyntaxIdCurrent.isNull() ) { - message = " it does not have LSLSyntaxId capability, remaining with default keywords file!"; + LL_INFOS("SyntaxLSL") + << "It does not have LSLSyntaxId capability, remaining with default keywords file!" + << LL_ENDL; } else { // 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!"; + LL_INFOS("SyntaxLSL") + << "It does not have LSLSyntaxId capability, using default keywords file!" + << LL_ENDL; changed = true; } } @@ -192,31 +220,33 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() << "Region is '" << region->getName() << message << LL_ENDL; } } + sVersionChanged = changed; return changed; } +/** + * @brief LLSyntaxIdLSL::fetching + * If the XML has not loaded yet and it hasn't failed, then we're still fetching it. + * @return bool Whether the file fetch is still in process. + */ +bool LLSyntaxIdLSL::fetching() +{ + return (!sLoaded && !sLoadFailed); +} + //----------------------------------------------------------------------------- // fetchKeywordsFile //----------------------------------------------------------------------------- void LLSyntaxIdLSL::fetchKeywordsFile() { - if ( !mCapabilityURL.empty() ) - { - //LLSyntaxIdLSL::sLoaded = false; - LLHTTPClient::get(mCapabilityURL, - new fetchKeywordsFileResponder(mFullFileSpec), - LLSD(), 30.f - ); - LL_INFOS("SyntaxLSL") - << "LSLSyntaxId capability URL is: " << mCapabilityURL - << ". Filename to use is: '" << mFullFileSpec << "'." - << LL_ENDL; - } - else - { - LL_ERRS("SyntaxLSL") - << "LSLSyntaxId capability URL is empty!!" << LL_ENDL; - } + LLHTTPClient::get(mCapabilityURL, + new fetchKeywordsFileResponder(mFullFileSpec), + LLSD(), 30.f + ); + LL_INFOS("SyntaxLSL") + << "LSLSyntaxId capability URL is: " << mCapabilityURL + << ". Filename to use is: '" << mFullFileSpec << "'." + << LL_ENDL; } //----------------------------------------------------------------------------- @@ -228,33 +258,47 @@ void LLSyntaxIdLSL::initialise() mSyntaxIdNew = mSyntaxIdCurrent; if (checkSyntaxIdChanged()) { - LL_INFOS("SyntaxLSL") - << "LSL version has changed, getting appropriate file." - << LL_ENDL; - - // Need a full spec regardless of file source, so build it now. - buildFullFileSpec(); - if ( !mSyntaxIdNew.isNull() ) + sKeywordsXml = LLSD(); + sLoaded = sLoadFailed = false; + LLViewerRegion* region = gAgent.getRegion(); + mCapabilityURL = region->getCapability(mCapabilityName); + if (!mCapabilityURL.empty()) { - if ( !gDirUtilp->fileExists(mFullFileSpec) ) - { // Does not exist, so fetch it from the capability - LL_INFOS("SyntaxLSL") - << "File is not cached, we will try to download it!" - << LL_ENDL; - fetchKeywordsFile(); + LL_INFOS("SyntaxLSL") + << "LSL version has changed, getting appropriate file." + << LL_ENDL; + + // Need a full spec regardless of file source, so build it now. + buildFullFileSpec(); + if ( !mSyntaxIdNew.isNull() ) + { + if ( !gDirUtilp->fileExists(mFullFileSpec) ) + { // Does not exist, so fetch it from the capability + LL_INFOS("SyntaxLSL") + << "File is not cached, we will try to download it!" + << LL_ENDL; + fetchKeywordsFile(); + } + else + { + LL_INFOS("SyntaxLSL") + << "File is cached, no need to download!" + << LL_ENDL; + loadKeywordsIntoLLSD(); + } } else - { - LL_INFOS("SyntaxLSL") - << "File is cached, no need to download!" - << LL_ENDL; - sLoaded = loadKeywordsIntoLLSD(); + { // Need to open the default + loadDefaultKeywordsIntoLLSD(); } } else - { // Need to open the default - loadDefaultKeywordsIntoLLSD(); + { + sLoadFailed = true; + LL_ERRS("SyntaxLSL") + << "LSLSyntaxId capability URL is empty!!" << LL_ENDL; } + } else if (sKeywordsXml.isDefined()) { @@ -311,7 +355,7 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; mSyntaxIdNew = LLUUID(); buildFullFileSpec(); - sLoaded = loadKeywordsIntoLLSD(); + loadKeywordsIntoLLSD(); } //----------------------------------------------------------------------------- @@ -320,23 +364,22 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() /** * @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. + * contained data to the specified LLSD object. indicate success/failure with + * sLoaded/sLoadFailed members. */ -bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() +void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { LL_INFOS("SyntaxLSL") << "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) + sLoaded = (bool)LLSDSerialize::fromXML(content, file); + if (!sLoaded) { LL_ERRS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; @@ -354,5 +397,5 @@ bool LLSyntaxIdLSL::loadKeywordsIntoLLSD() { LL_ERRS("SyntaxLSL") << "Unable to open file: " << mFullFileSpec << LL_ENDL; } - return loaded; + sLoadFailed = !sLoaded; } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 78ea98e3cf..3c27a91ce4 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -47,9 +47,17 @@ class LLSyntaxIdLSL friend class fetchKeywordsFileResponder; public: +static const std::string CAPABILITY_NAME; +static const std::string FILENAME_DEFAULT; +static const std::string SIMULATOR_FEATURE; protected: - LLViewerRegion* region; + //LLViewerRegion* region; + + static LLSD sKeywordsXml; + static bool sLoaded; + static bool sLoadFailed; + static bool sVersionChanged; private: @@ -64,19 +72,19 @@ private: LLUUID mSyntaxIdCurrent; LLUUID mSyntaxIdNew; - static LLSD sKeywordsXml; - static bool sLoaded; - public: LLSyntaxIdLSL(); + LLSyntaxIdLSL(std::string filenameDefault, std::string simulatorFeature, std::string capabilityName); bool checkSyntaxIdChanged(); + bool fetching(); 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; } + bool isDifferentVersion() const { return sVersionChanged; } void initialise(); bool isLoaded() { return sLoaded; } @@ -90,7 +98,7 @@ protected: std::string buildFullFileSpec(); void fetchKeywordsFile(); void loadDefaultKeywordsIntoLLSD(); - bool loadKeywordsIntoLLSD(); + void loadKeywordsIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } void setFileNameDefault(std::string& name) { mFileNameDefault = name; } @@ -118,9 +126,17 @@ public: const std::string& reason, const LLSD& content); + /** + * @brief Checks the returned LLSD for version and stores it in the LLSyntaxIdLSL object. + * @param content_ref The returned LLSD. + */ + void result(const LLSD& content_ref); + /** * @brief Saves the returned file to the location provided at instantiation. + * Could be extended to manage cached entries. * @param content_ref The LSL syntax file for the sim. */ - void result(const LLSD& content_ref); + void cacheFile(const LLSD& content_ref); + }; -- cgit v1.3 From 566b10e2250e484b2d3211565d387c3c73864e82 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Wed, 5 Feb 2014 15:27:22 +0000 Subject: Cleaning up a little. Using assigned values for simFeature/Capability name instead of literal values. --- indra/newview/llsyntaxid.cpp | 34 ++++++++++++++++------------------ indra/newview/llsyntaxid.h | 4 ++-- 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 886dcfaac0..4d7cc550af 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -113,7 +113,7 @@ void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) //----------------------------------------------------------------------------- const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; -const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE ="LSLSyntaxId"; +const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; LLSD LLSyntaxIdLSL::sKeywordsXml; bool LLSyntaxIdLSL::sLoaded; @@ -123,21 +123,24 @@ bool LLSyntaxIdLSL::sVersionChanged; /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL(std::string filenameDefault, std::string simulatorFeature, std::string capabilityName) : - // Move these to signature? - mCapabilityURL(""), +LLSyntaxIdLSL::LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName) : mFilePath(LL_PATH_APP_SETTINGS) { mCapabilityName = capabilityName; mFileNameCurrent = filenameDefault; mFileNameDefault = filenameDefault; - mSimulatorFeature = simulatorFeature; + mSimulatorFeature = simFeatureName; mSyntaxIdCurrent = LLUUID(); } -LLSyntaxIdLSL::LLSyntaxIdLSL() +LLSyntaxIdLSL::LLSyntaxIdLSL() : + mFilePath(LL_PATH_APP_SETTINGS) { - LLSyntaxIdLSL(LLSyntaxIdLSL::FILENAME_DEFAULT, LLSyntaxIdLSL::SIMULATOR_FEATURE, LLSyntaxIdLSL::CAPABILITY_NAME); + mCapabilityName = CAPABILITY_NAME; + mFileNameCurrent = FILENAME_DEFAULT; + mFileNameDefault = FILENAME_DEFAULT; + mSimulatorFeature = SIMULATOR_FEATURE; + mSyntaxIdCurrent = LLUUID(); } std::string LLSyntaxIdLSL::buildFileNameNew() @@ -166,7 +169,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() { if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it may be needed. - LL_WARNS("SyntaxLSL") + LL_ERRS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities yet! Cannot process SyntaxId." << LL_ENDL; @@ -174,15 +177,14 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() else { LLSD simFeatures; - std::string message; region->getSimulatorFeatures(simFeatures); - LL_INFOS("SyntaxLSL") << "Region is '" << region->getName() << "' ..." << LL_ENDL; - - // get and check the hash - if (simFeatures.has("LSLSyntaxId")) + // Does the sim have the required feature + if (simFeatures.has(mSimulatorFeature)) { - mSyntaxIdNew = simFeatures["LSLSyntaxId"].asUUID(); + // get and check the hash + mSyntaxIdNew = simFeatures[mSimulatorFeature].asUUID(); + mCapabilityURL = region->getCapability(mCapabilityName); if (mSyntaxIdCurrent != mSyntaxIdNew) { LL_INFOS("SyntaxLSL") @@ -216,8 +218,6 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() changed = true; } } - LL_INFOS("SyntaxLSL") - << "Region is '" << region->getName() << message << LL_ENDL; } } sVersionChanged = changed; @@ -260,8 +260,6 @@ void LLSyntaxIdLSL::initialise() { sKeywordsXml = LLSD(); sLoaded = sLoadFailed = false; - LLViewerRegion* region = gAgent.getRegion(); - mCapabilityURL = region->getCapability(mCapabilityName); if (!mCapabilityURL.empty()) { LL_INFOS("SyntaxLSL") diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 3c27a91ce4..a24edf7204 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -75,7 +75,7 @@ private: public: LLSyntaxIdLSL(); - LLSyntaxIdLSL(std::string filenameDefault, std::string simulatorFeature, std::string capabilityName); + LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName); bool checkSyntaxIdChanged(); bool fetching(); @@ -103,7 +103,7 @@ protected: 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; } +// void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; } }; -- cgit v1.3 From 5551e8f04c84d1427fc39b0927eebc6dd58a772f Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Wed, 5 Feb 2014 16:29:43 +0000 Subject: Checking version for cached files so older versions cannot sneak through on upgrading of format. --- indra/newview/llsyntaxid.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 4d7cc550af..4b84098b39 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -371,6 +371,10 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() << "Trying to open cached or default keyword file ;-)" << 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(); + LLSD content; llifstream file; file.open(mFullFileSpec); @@ -379,16 +383,25 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() sLoaded = (bool)LLSDSerialize::fromXML(content, file); if (!sLoaded) { - LL_ERRS("SyntaxLSL") << "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(); + LL_ERRS("SyntaxLSL") + << "Unable to deserialise file: " + << mFullFileSpec << LL_ENDL; } else { - sKeywordsXml = content; - LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; + if (isSupportedVersion(content)) + { + sKeywordsXml = content; + LL_INFOS("SyntaxLSL") + << "Deserialised file: " << mFullFileSpec << LL_ENDL; + } + else + { + LLSyntaxIdLSL::sLoaded = false; + LLSyntaxIdLSL::sLoadFailed = true; + LL_WARNS("SyntaxLSL") + << "Unknown or unsupported version of syntax file." << LL_ENDL; + } } } else -- cgit v1.3 From 01b7ae8abe7efc101202fea786e97862c44e1d21 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Feb 2014 16:41:07 +0000 Subject: Changing how state of loading is reported to better allow other classes to know what is happening. --- indra/newview/llsyntaxid.cpp | 45 +++++++++++++++++++++++--------------------- indra/newview/llsyntaxid.h | 3 ++- 2 files changed, 26 insertions(+), 22 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 4b84098b39..3ee9859ccd 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -67,9 +67,10 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) if (LLSyntaxIdLSL::isSupportedVersion(content_ref)) { LL_INFOS("SyntaxLSL") - << "Is a supported verson of syntax file." << LL_ENDL; + << "Supported verson of syntax file." << LL_ENDL; LLSyntaxIdLSL::setKeywordsXml(content_ref); + LLSyntaxIdLSL::sInitialised = true; LLSyntaxIdLSL::sLoaded = true; LLSyntaxIdLSL::sLoadFailed = false; @@ -115,6 +116,7 @@ const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; +bool LLSyntaxIdLSL::sInitialised; LLSD LLSyntaxIdLSL::sKeywordsXml; bool LLSyntaxIdLSL::sLoaded; bool LLSyntaxIdLSL::sLoadFailed; @@ -162,13 +164,14 @@ std::string LLSyntaxIdLSL::buildFullFileSpec() //----------------------------------------------------------------------------- bool LLSyntaxIdLSL::checkSyntaxIdChanged() { - bool changed = false; + sVersionChanged = false; LLViewerRegion* region = gAgent.getRegion(); if (region) { if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it may be needed. + sLoadFailed = true; LL_ERRS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities yet! Cannot process SyntaxId." @@ -191,7 +194,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() << "It has LSLSyntaxId capability, and the new hash is '" << mSyntaxIdNew.asString() << "'" << LL_ENDL; - changed = true; + sVersionChanged = true; } else { @@ -202,7 +205,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() } else { - if ( mSyntaxIdCurrent.isNull() ) + if ( mSyntaxIdCurrent.isNull() && isInitialised()) { LL_INFOS("SyntaxLSL") << "It does not have LSLSyntaxId capability, remaining with default keywords file!" @@ -215,13 +218,12 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() LL_INFOS("SyntaxLSL") << "It does not have LSLSyntaxId capability, using default keywords file!" << LL_ENDL; - changed = true; + sVersionChanged = true; } } } } - sVersionChanged = changed; - return changed; + return sVersionChanged; } /** @@ -231,7 +233,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() */ bool LLSyntaxIdLSL::fetching() { - return (!sLoaded && !sLoadFailed); + return !(sLoaded || sLoadFailed); } //----------------------------------------------------------------------------- @@ -256,11 +258,17 @@ void LLSyntaxIdLSL::initialise() { mFileNameNew = mFileNameCurrent; mSyntaxIdNew = mSyntaxIdCurrent; + if (checkSyntaxIdChanged()) { sKeywordsXml = LLSD(); sLoaded = sLoadFailed = false; - if (!mCapabilityURL.empty()) + + if (mSyntaxIdNew.isNull()) + { // Need to open the default + loadDefaultKeywordsIntoLLSD(); + } + else if (!mCapabilityURL.empty() ) { LL_INFOS("SyntaxLSL") << "LSL version has changed, getting appropriate file." @@ -268,7 +276,7 @@ void LLSyntaxIdLSL::initialise() // Need a full spec regardless of file source, so build it now. buildFullFileSpec(); - if ( !mSyntaxIdNew.isNull() ) + if ( !mSyntaxIdNew.isNull()) { if ( !gDirUtilp->fileExists(mFullFileSpec) ) { // Does not exist, so fetch it from the capability @@ -295,17 +303,11 @@ void LLSyntaxIdLSL::initialise() sLoadFailed = true; LL_ERRS("SyntaxLSL") << "LSLSyntaxId capability URL is empty!!" << LL_ENDL; + loadDefaultKeywordsIntoLLSD(); } - } - else if (sKeywordsXml.isDefined()) + else if (!isInitialised()) { - LL_INFOS("SyntaxLSL") - << "No change to Syntax! Nothing to see. Move along now!" - << LL_ENDL; - } - else - { // Need to open the default loadDefaultKeywordsIntoLLSD(); } @@ -320,7 +322,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) { bool isValid = false; /* - * If the schema used to store lsl keywords and hints changes, this value is incremented + * If the schema used to store LSL keywords and hints changes, this value is incremented * Note that it should _not_ be changed if the keywords and hints _content_ changes. */ const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; @@ -392,13 +394,14 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() if (isSupportedVersion(content)) { sKeywordsXml = content; + sLoaded = true; + sInitialised = true; LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; } else { - LLSyntaxIdLSL::sLoaded = false; - LLSyntaxIdLSL::sLoadFailed = true; + sLoaded = false; LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index a24edf7204..226f1f4941 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -54,12 +54,12 @@ static const std::string SIMULATOR_FEATURE; protected: //LLViewerRegion* region; + static bool sInitialised; static LLSD sKeywordsXml; static bool sLoaded; static bool sLoadFailed; static bool sVersionChanged; - private: std::string mCapabilityName; std::string mCapabilityURL; @@ -85,6 +85,7 @@ public: LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } bool isDifferentVersion() const { return sVersionChanged; } + bool isInitialised() const { return sInitialised; } void initialise(); bool isLoaded() { return sLoaded; } -- cgit v1.3 From 64816059b68188842ada767b5a2b6145b62017d4 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 25 Feb 2014 14:44:53 -0500 Subject: don't use the simulator channel in the keywords cache file name --- indra/newview/llsyntaxid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 3ee9859ccd..b558a113fb 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -147,7 +147,7 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() : std::string LLSyntaxIdLSL::buildFileNameNew() { - mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + gLastVersionChannel + "_" + mSyntaxIdNew.asString() + ".llsd.xml"; + mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + "_" + mSyntaxIdNew.asString() + ".llsd.xml"; return mFileNameNew; } -- cgit v1.3 From acc71d628dd024059bb221ef260c9d6d12a0cbd2 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 25 Feb 2014 17:20:44 -0500 Subject: fix typo --- indra/newview/llsyntaxid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index b558a113fb..3d63ab93a0 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -147,7 +147,7 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() : std::string LLSyntaxIdLSL::buildFileNameNew() { - mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + "_" + mSyntaxIdNew.asString() + ".llsd.xml"; + mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + mSyntaxIdNew.asString() + ".llsd.xml"; return mFileNameNew; } -- cgit v1.3 From 5067f1eed9f00e93bf287bf0fce69c8212a51ff2 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Mar 2014 13:11:48 +0000 Subject: storm-1831 Converting LLSyntaxIdLSL to a singleton. Adding callback for signalling arrival of Syntax file from capability. --- indra/newview/llsyntaxid.cpp | 15 ++++++++++++++- indra/newview/llsyntaxid.h | 16 +++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 3d63ab93a0..7deb976c2a 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -91,6 +91,8 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) LL_ERRS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL; } + + LLSyntaxIdLSL::sFileFetchedSignal(); } void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) @@ -108,7 +110,6 @@ void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; } - //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- @@ -121,6 +122,7 @@ LLSD LLSyntaxIdLSL::sKeywordsXml; bool LLSyntaxIdLSL::sLoaded; bool LLSyntaxIdLSL::sLoadFailed; bool LLSyntaxIdLSL::sVersionChanged; +LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor @@ -251,6 +253,7 @@ void LLSyntaxIdLSL::fetchKeywordsFile() << LL_ENDL; } + //----------------------------------------------------------------------------- // initialise //----------------------------------------------------------------------------- @@ -413,3 +416,13 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() } sLoadFailed = !sLoaded; } + +boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb) +{ + return sFileFetchedSignal.connect(cb); +} + +void LLSyntaxIdLSL::removeFileFetchedCallback(boost::signals2::connection callback) +{ + sFileFetchedSignal.disconnect(callback); +} diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 226f1f4941..1b6903f2a2 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -35,6 +35,7 @@ #include "llagent.h" #include "llenvmanager.h" #include "llhttpclient.h" +#include "llsingleton.h" #include "llviewerregion.h" @@ -42,14 +43,15 @@ * @file llsyntaxid.h * @brief Tracks the file needed to decorate the current sim's version of LSL. */ -class LLSyntaxIdLSL +class LLSyntaxIdLSL: public LLSingleton { friend class fetchKeywordsFileResponder; public: + typedef boost::signals2::signal file_fetched_signal_t; -static const std::string CAPABILITY_NAME; -static const std::string FILENAME_DEFAULT; -static const std::string SIMULATOR_FEATURE; + static const std::string CAPABILITY_NAME; + static const std::string FILENAME_DEFAULT; + static const std::string SIMULATOR_FEATURE; protected: //LLViewerRegion* region; @@ -59,6 +61,7 @@ protected: static bool sLoaded; static bool sLoadFailed; static bool sVersionChanged; + static file_fetched_signal_t sFileFetchedSignal; private: std::string mCapabilityName; @@ -73,6 +76,7 @@ private: LLUUID mSyntaxIdNew; + public: LLSyntaxIdLSL(); LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName); @@ -93,6 +97,9 @@ public: static bool isSupportedVersion(const LLSD& content); static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } + boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); + void removeFileFetchedCallback(boost::signals2::connection callback); + protected: std::string buildFileNameNew(); @@ -139,5 +146,4 @@ public: * @param content_ref The LSL syntax file for the sim. */ void cacheFile(const LLSD& content_ref); - }; -- cgit v1.3 From 3ee3d4a8f4b74a5f0b75fa54cb8e1cef0b1ef28e Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 14 Mar 2014 16:19:21 -0400 Subject: correct logging levels (ERR causes a crash), and a minor style fix --- indra/llui/llkeywords.cpp | 17 ++++++++--------- indra/llui/lltextbase.cpp | 3 ++- indra/newview/llsyntaxid.cpp | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index a251c2e4f5..9b924c84a9 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -163,15 +163,14 @@ std::string LLKeywords::getArguments(LLSD& arguments) } else { - LL_INFOS("SyntaxLSL") - << "Argument array does not comtain a map element!" << LL_ENDL; + LL_WARNS("SyntaxLSL") + << "Argument array comtains a non-map element!" << LL_ENDL; } } } else if (!arguments.isUndefined()) { - LL_WARNS("SyntaxLSL") - << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; } return argString == "" ? "" : argString; } @@ -251,7 +250,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) } else { - LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognised!" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognized!" << LL_ENDL; } return LLUIColorTable::instance().getColor(ColourGroup); @@ -287,7 +286,7 @@ void LLKeywords::processTokens() } else { - LL_ERRS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; + LL_WARNS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; } } } @@ -356,7 +355,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else { - LL_ERRS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; } } @@ -403,7 +402,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness { - LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << Color << LL_ENDL; for (int count = 0; count < Tokens.size(); ++count) { addToken(token_type, Tokens[count], Color, ""); @@ -411,7 +410,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else { - LL_INFOS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; + LL_WARNS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; } } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 5ec4cf4fe5..bc11d59a65 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -571,7 +571,8 @@ void LLTextBase::drawText() if ( (getSpellCheck()) && (getWText().length() > 2) ) { // Calculate start and end indices for the spell checking range - S32 start = line_start, end = getLineEnd(last_line); + S32 start = line_start; + S32 end = getLineEnd(last_line); if ( (mSpellCheckStart != start) || (mSpellCheckEnd != end) ) { diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 7deb976c2a..80511cd73f 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -50,7 +50,7 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, const LLSD& content) { LLSyntaxIdLSL::sLoadFailed = true; - LL_ERRS("SyntaxLSL") + LL_WARNS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" << status << "]: " << content << LL_ENDL; @@ -88,7 +88,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) { LLSyntaxIdLSL::sLoaded = false; LLSyntaxIdLSL::sLoadFailed = true; - LL_ERRS("SyntaxLSL") + LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL; } @@ -174,7 +174,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it may be needed. sLoadFailed = true; - LL_ERRS("SyntaxLSL") + LL_WARNS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities yet! Cannot process SyntaxId." << LL_ENDL; @@ -304,7 +304,7 @@ void LLSyntaxIdLSL::initialise() else { sLoadFailed = true; - LL_ERRS("SyntaxLSL") + LL_WARNS("SyntaxLSL") << "LSLSyntaxId capability URL is empty!!" << LL_ENDL; loadDefaultKeywordsIntoLLSD(); } @@ -388,7 +388,7 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() sLoaded = (bool)LLSDSerialize::fromXML(content, file); if (!sLoaded) { - LL_ERRS("SyntaxLSL") + LL_WARNS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; } -- cgit v1.3 From 08ca5279ffbf3e47fc42a32e38339ce806df1741 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 28 Mar 2014 21:32:30 +0000 Subject: storm-1831: Fixing the remaining LL_ERRS. --- indra/newview/llsyntaxid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 80511cd73f..14265fd3af 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -412,7 +412,7 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() } else { - LL_ERRS("SyntaxLSL") << "Unable to open file: " << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unable to open file: " << mFullFileSpec << LL_ENDL; } sLoadFailed = !sLoaded; } -- cgit v1.3 From e8422e5bed6c593c8a26b533f33103911a1d3da6 Mon Sep 17 00:00:00 2001 From: Cinder Date: Tue, 6 May 2014 11:09:50 -0600 Subject: Let's get started: some code policy cleanup, reference arguments where we can, correct spelling --- indra/llui/llkeywords.cpp | 130 ++++++++++----------- indra/llui/llkeywords.h | 6 +- .../newview/app_settings/keywords_lsl_default.xml | 20 ++-- indra/newview/llpreviewscript.cpp | 79 ++++++------- indra/newview/llpreviewscript.h | 1 - indra/newview/llsyntaxid.cpp | 17 +-- indra/newview/llsyntaxid.h | 8 +- 7 files changed, 125 insertions(+), 136 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 07c84e57c0..bae604e270 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -82,7 +82,7 @@ LLKeywords::~LLKeywords() mDelimiterTokenList.clear(); } -void LLKeywords::addColorGroup(const std::string key_in, const LLColor4 color) +void LLKeywords::addColorGroup(const std::string& key_in, const LLColor4& color) { WStringMapIndex key ( utf8str_to_wstring(key_in) ); mColorGroupMap[key] = color; @@ -176,79 +176,79 @@ std::string LLKeywords::getAttribute(const std::string& key) return (it != mAttributes.end()) ? it->second : ""; } -LLColor4 LLKeywords::getColorGroup(const std::string key_in) +LLColor4 LLKeywords::getColorGroup(const std::string& key_in) { - std::string ColourGroup = "Black"; + std::string color_group = "Black"; if (key_in == "constants-float") { - ColourGroup = "SyntaxLslConstantFloat"; + color_group = "SyntaxLslConstantFloat"; } else if (key_in == "constants-integer") { - ColourGroup = "SyntaxLslConstantInteger"; + color_group = "SyntaxLslConstantInteger"; } else if (key_in == "constants-key") { - ColourGroup = "SyntaxLslConstantKey"; + color_group = "SyntaxLslConstantKey"; } else if (key_in == "constants-rotation") { - ColourGroup = "SyntaxLslConstantRotation"; + color_group = "SyntaxLslConstantRotation"; } else if (key_in == "constants-string") { - ColourGroup = "SyntaxLslConstantString"; + color_group = "SyntaxLslConstantString"; } else if (key_in == "constants-vector") { - ColourGroup = "SyntaxLslConstantVector"; + color_group = "SyntaxLslConstantVector"; } else if (key_in == "misc-flow-label") { - ColourGroup = "SyntaxLslControlFlow"; + color_group = "SyntaxLslControlFlow"; } else if (key_in =="deprecated") { - ColourGroup = "SyntaxLslDeprecated"; + color_group = "SyntaxLslDeprecated"; } else if (key_in == "events") { - ColourGroup = "SyntaxLslEvent"; + color_group = "SyntaxLslEvent"; } else if (key_in == "functions") { - ColourGroup = "SyntaxLslFunction"; + color_group = "SyntaxLslFunction"; } else if (key_in =="god-mode") { - ColourGroup = "SyntaxLslGodMode"; + color_group = "SyntaxLslGodMode"; } else if (key_in == "types") { - ColourGroup = "SyntaxLslDataType"; + color_group = "SyntaxLslDataType"; } else if (key_in == "sections") { - ColourGroup = "SyntaxLslSection"; + color_group = "SyntaxLslSection"; } else if (key_in == "misc-double_quotation_marks") { - ColourGroup = "SyntaxLslStringLiteral"; + color_group = "SyntaxLslStringLiteral"; } else if (key_in == "misc-comments_1_sided") { - ColourGroup = "SyntaxLslComment1Sided"; + color_group = "SyntaxLslComment1Sided"; } else if (key_in == "misc-comments_2_sided") { - ColourGroup = "SyntaxLslComment2Sided"; + color_group = "SyntaxLslComment2Sided"; } else { LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognized!" << LL_ENDL; } - return LLUIColorTable::instance().getColor(ColourGroup); + return LLUIColorTable::instance().getColor(color_group); } void LLKeywords::initialise(LLSD SyntaxXML) @@ -271,107 +271,107 @@ void LLKeywords::processTokens() addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" ); addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" ); - LLSD::map_iterator outerIt = mSyntax.beginMap(); - for ( ; outerIt != mSyntax.endMap(); ++outerIt) + LLSD::map_iterator itr = mSyntax.beginMap(); + for ( ; itr != mSyntax.endMap(); ++itr) { - if (outerIt->first == "llsd-lsl-syntax-version") + if (itr->first == "llsd-lsl-syntax-version") { // Skip over version key. } else { - if (outerIt->second.isMap()) + if (itr->second.isMap()) { - processTokensGroup(outerIt->second, outerIt->first); + processTokensGroup(itr->second, itr->first); } else { - LL_WARNS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; + LL_WARNS("LSL-Tokens-Processing") << "Map for " + itr->first + " entries is missing! Ignoring." << LL_ENDL; } } } LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } -void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) +void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group) { - LLColor4 Color; - LLColor4 ColorGroup; - LLColor4 ColorDeprecated = getColorGroup("deprecated"); - LLColor4 ColorGM = getColorGroup("god-mode"); + LLColor4 color; + LLColor4 color_group; + LLColor4 color_deprecated = getColorGroup("deprecated"); + LLColor4 color_god_mode = getColorGroup("god-mode"); LLKeywordToken::ETokenType token_type = LLKeywordToken::TT_UNKNOWN; // If a new token type is added here, it must also be added to the 'addToken' method - if (Group == "constants") + if (group == "constants") { token_type = LLKeywordToken::TT_CONSTANT; } - else if (Group == "controls") + else if (group == "controls") { token_type = LLKeywordToken::TT_CONTROL; } - else if (Group == "events") + else if (group == "events") { token_type = LLKeywordToken::TT_EVENT; } - else if (Group == "functions") + else if (group == "functions") { token_type = LLKeywordToken::TT_FUNCTION; } - else if (Group == "label") + else if (group == "label") { token_type = LLKeywordToken::TT_LABEL; } - else if (Group == "types") + else if (group == "types") { token_type = LLKeywordToken::TT_TYPE; } - ColorGroup = getColorGroup(Group); - LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << ColorGroup << "'" << LL_ENDL; + color_group = getColorGroup(group); + LL_INFOS("Tokens") << "Group: '" << group << "', using color: '" << color_group << "'" << LL_ENDL; - if (Tokens.isMap()) + if (tokens.isMap()) { - LLSD::map_iterator outerIt = Tokens.beginMap(); - for ( ; outerIt != Tokens.endMap(); ++outerIt) + LLSD::map_const_iterator outer_itr = tokens.beginMap(); + for ( ; outer_itr != tokens.endMap(); ++outer_itr) { - if (outerIt->second.isMap()) + if (outer_itr->second.isMap()) { mAttributes.clear(); - LLSD arguments = LLSD (); - LLSD::map_iterator innerIt = outerIt->second.beginMap(); - for ( ; innerIt != outerIt->second.endMap(); ++innerIt) + LLSD arguments = LLSD(); + LLSD::map_const_iterator inner_itr = outer_itr->second.beginMap(); + for ( ; inner_itr != outer_itr->second.endMap(); ++inner_itr) { - if (innerIt->first == "arguments") + if (inner_itr->first == "arguments") { - if (innerIt->second.isArray()) + if (inner_itr->second.isArray()) { - arguments = innerIt->second; + arguments = inner_itr->second; } } - else if (!innerIt->second.isMap() && !innerIt->second.isArray()) + else if (!inner_itr->second.isMap() && !inner_itr->second.isArray()) { - mAttributes[innerIt->first] = innerIt->second.asString(); + mAttributes[inner_itr->first] = inner_itr->second.asString(); } else { - LL_WARNS("SyntaxLSL") << "Not a valid attribute: " << innerIt->first << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not a valid attribute: " << inner_itr->first << LL_ENDL; } } std::string tooltip = ""; if (token_type == LLKeywordToken::TT_CONSTANT) { - ColorGroup = getColorGroup(Group + "-" + getAttribute("type")); + color_group = getColorGroup(group + "-" + getAttribute("type")); tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value"); } else if (token_type == LLKeywordToken::TT_EVENT) { - tooltip = outerIt->first + "(" + getArguments(arguments) + ")"; + tooltip = outer_itr->first + "(" + getArguments(arguments) + ")"; } else if (token_type == LLKeywordToken::TT_FUNCTION) { - tooltip = getAttribute("return") + " " + outerIt->first + "(" + getArguments(arguments) + ");"; + tooltip = getAttribute("return") + " " + outer_itr->first + "(" + getArguments(arguments) + ");"; tooltip += "\nEnergy: "; tooltip += getAttribute("energy") == "" ? "0.0" : getAttribute("energy"); if (getAttribute("sleep") != "") @@ -389,28 +389,28 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) tooltip += getAttribute("tooltip"); } - Color = getAttribute("deprecated") == "true" ? ColorDeprecated : ColorGroup; + color = getAttribute("deprecated") == "true" ? color_deprecated : color_group; if (getAttribute("god-mode") == "true") { - Color = ColorGM; + color = color_god_mode; } - addToken(token_type, outerIt->first, Color, tooltip); + addToken(token_type, outer_itr->first, color, tooltip); } } } - else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness + else if (tokens.isArray()) // Currently nothing should need this, but it's here for completeness { - LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << Color << LL_ENDL; - for (int count = 0; count < Tokens.size(); ++count) + LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << color << LL_ENDL; + for (int count = 0; count < tokens.size(); ++count) { - addToken(token_type, Tokens[count], Color, ""); + addToken(token_type, tokens[count], color, ""); } } else { - LL_WARNS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; + LL_WARNS("Tokens") << "Invalid map/array passed: '" << tokens << "'" << LL_ENDL; } } @@ -511,11 +511,11 @@ LLColor4 LLKeywords::readColor(LLSD& sd) { if (sd.isArray()) { - return LLColor4 (sd, 1.f); + return LLColor4(sd, 1.f); } else if (sd.isMap()) { - return LLColor4 ( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal(), 1.f ); + return LLColor4( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal(), 1.f ); } else { diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 69bc8919db..b17e9dd942 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -109,9 +109,9 @@ public: LLKeywords(); ~LLKeywords(); - void addColorGroup(const std::string key_in, const LLColor4 color); + void addColorGroup(const std::string& key_in, const LLColor4& color); void clearLoaded() { mLoaded = false; } - LLColor4 getColorGroup(const std::string key_in); + LLColor4 getColorGroup(const std::string& key_in); bool isLoaded() const { return mLoaded; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); @@ -167,7 +167,7 @@ public: #endif protected: - void processTokensGroup(LLSD& Tokens, const std::string Group); + void processTokensGroup(const LLSD& Tokens, const std::string& Group); LLColor4 readColor(const std::string& s); LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); diff --git a/indra/newview/app_settings/keywords_lsl_default.xml b/indra/newview/app_settings/keywords_lsl_default.xml index 83801a7e1e..53a89f0f09 100755 --- a/indra/newview/app_settings/keywords_lsl_default.xml +++ b/indra/newview/app_settings/keywords_lsl_default.xml @@ -89,7 +89,7 @@ vector tooltip - A vector is a data type that contains a set of three float values.\nVectors are used to represent colours (RGB), positions, and directions/velocities. + A vector is a data type that contains a set of three float values.\nVectors are used to represent colors (RGB), positions, and directions/velocities. constants @@ -852,7 +852,7 @@ value 0x2 tooltip - The object colour has changed. + The object color has changed. CHANGED_INVENTORY @@ -4372,7 +4372,7 @@ value 3 tooltip - A vector <r, g, b> which determines the ending colour of the object. + A vector <r, g, b> which determines the ending color of the object. PSYS_PART_END_GLOW @@ -4426,7 +4426,7 @@ value 0x1 tooltip - Interpolate both the colour and alpha from the start value to the end value. + Interpolate both the color and alpha from the start value to the end value. PSYS_PART_INTERP_SCALE_MASK @@ -4471,7 +4471,7 @@ value 1 tooltip - A vector <r.r, g.g, b.b> which determines the starting colour of the object. + A vector <r.r, g.g, b.b> which determines the starting color of the object. PSYS_PART_START_GLOW @@ -9032,7 +9032,7 @@ tooltip - Returns the color on Face.\nReturns the colour of Face as a vector of red, green, and blue values between 0 and 1. If face is ALL_SIDES the colour returned is the mean average of each channel. + Returns the color on Face.\nReturns the color of Face as a vector of red, green, and blue values between 0 and 1. If face is ALL_SIDES the color returned is the mean average of each channel. llGetCreator @@ -15304,7 +15304,7 @@ arguments - Colour + Color type vector @@ -15323,7 +15323,7 @@ tooltip - Sets the color, for the face.\nSets the colour of the side specified. If Face is ALL_SIDES, sets the colour on all faces. + Sets the color, for the face.\nSets the color of the side specified. If Face is ALL_SIDES, sets the color on all faces. llSetContentType @@ -15671,7 +15671,7 @@ - Colour + Color type vector @@ -15690,7 +15690,7 @@ tooltip - If a task exists in the link chain at LinkNumber, set the Face to color.\nSets the colour of the linked child's side, specified by LinkNumber. + If a task exists in the link chain at LinkNumber, set the Face to color.\nSets the color of the linked child's side, specified by LinkNumber. llSetLinkMedia diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 1d95276c51..fae4aeb7bc 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -374,6 +374,7 @@ LLScriptEdCore::LLScriptEdCore( setXMLFilename("panel_script_ed.xml"); llassert_always(mContainer != NULL); + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); } LLScriptEdCore::~LLScriptEdCore() @@ -389,6 +390,7 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; + mRegionChangedCallback.disconnect(); } BOOL LLScriptEdCore::postBuild() @@ -407,25 +409,20 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL - mSyntaxIdLSL.initialise(); + LLSyntaxIdLSL::getInstance()->initialise(); - if (mSyntaxIdLSL.isDifferentVersion()) + if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) { processLoaded(); } else { - LL_INFOS("SyntaxLSL") - << "Hashes are the same, no need to update highlighter." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are the same, no need to update highlighter." << LL_ENDL; } - - // Set up a callback for region changes - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); - return TRUE; } @@ -434,7 +431,6 @@ void LLScriptEdCore::updateKeywords() if (mLive) { mEditor->clearSegments(); - mRegionChangedCallback.disconnect(); } else { @@ -444,61 +440,54 @@ void LLScriptEdCore::updateKeywords() void LLScriptEdCore::processLoaded() { - mSyntaxIdLSL.initialise(); - if (mSyntaxIdLSL.isLoaded()) + LLSyntaxIdLSL::getInstance()->initialise(); + if (LLSyntaxIdLSL::getInstance()->isLoaded()) { processKeywords(); } else { - LL_INFOS("SyntaxLSL") - << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; } } void LLScriptEdCore::processKeywords() { - if (mSyntaxIdLSL.isLoaded()) + if (LLSyntaxIdLSL::getInstance()->isLoaded()) { - LL_INFOS("SyntaxLSL") - << "Hashes are different, updating highlighter." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; mEditor->clearSegments(); - if (mSyntaxIdLSL.isLoaded()) - { - mEditor->initKeywords(); - mEditor->loadKeywords(); - - std::vector primary_keywords; - std::vector secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) - { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else - { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - } + mEditor->initKeywords(); + mEditor->loadKeywords(); - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + string_vec_t primary_keywords; + string_vec_t secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + { + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) { - mFunctions->add(*iter); + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } - - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) + else { - mFunctions->add(*iter); + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } } + for (string_vec_t::const_iterator iter = primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } + for (string_vec_t::const_iterator iter = secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 3ac48ae9c4..966c149d3d 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -156,7 +156,6 @@ private: BOOL mEnableSave; BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; - LLSyntaxIdLSL mSyntaxIdLSL; LLScriptEdContainer* mContainer; // parent view diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 14265fd3af..3f726fa8b5 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -127,13 +127,13 @@ LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName) : - mFilePath(LL_PATH_APP_SETTINGS) +LLSyntaxIdLSL::LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability) +: mFilePath(LL_PATH_APP_SETTINGS) { - mCapabilityName = capabilityName; - mFileNameCurrent = filenameDefault; - mFileNameDefault = filenameDefault; - mSimulatorFeature = simFeatureName; + mCapabilityName = capability; + mFileNameCurrent = filename; + mFileNameDefault = filename; + mSimulatorFeature = sim_feature; mSyntaxIdCurrent = LLUUID(); } @@ -321,6 +321,9 @@ void LLSyntaxIdLSL::initialise() //----------------------------------------------------------------------------- // isSupportedVersion //----------------------------------------------------------------------------- +const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; +const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); + bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) { bool isValid = false; @@ -328,8 +331,6 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) * If the schema used to store LSL keywords and hints changes, this value is incremented * Note that it should _not_ be changed if the keywords and hints _content_ changes. */ - const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; - const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY)) { diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 1f7e893b38..75cfc45380 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -75,7 +75,7 @@ private: public: LLSyntaxIdLSL(); - LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName); + LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability); bool checkSyntaxIdChanged(); bool fetching(); @@ -104,9 +104,9 @@ protected: void loadDefaultKeywordsIntoLLSD(); void 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 setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; } + void setFileNameDefault(const std::string& name) { mFileNameDefault = name; } + void setFileNameNew(const std::string name) { mFileNameNew = name; } }; -- cgit v1.3 From 8501d6494bceeea962d7251d882ddc244a8daa7f Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 7 May 2014 19:58:56 -0600 Subject: Code policy --- indra/llui/llkeywords.cpp | 2 +- indra/llui/llkeywords.h | 2 +- .../newview/app_settings/keywords_lsl_default.xml | 2 +- indra/newview/llpreviewscript.cpp | 4 +-- indra/newview/llpreviewscript.h | 2 +- indra/newview/llscripteditor.cpp | 2 +- indra/newview/llsyntaxid.cpp | 38 ++++++++-------------- indra/newview/llsyntaxid.h | 24 ++++---------- 8 files changed, 27 insertions(+), 49 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index bae604e270..346b9a83bd 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -251,7 +251,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string& key_in) return LLUIColorTable::instance().getColor(color_group); } -void LLKeywords::initialise(LLSD SyntaxXML) +void LLKeywords::initialize(LLSD SyntaxXML) { mSyntax = SyntaxXML; mLoaded = true; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index b17e9dd942..eecb327fee 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -115,7 +115,7 @@ public: bool isLoaded() const { return mLoaded; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - void initialise(LLSD SyntaxXML); + void initialize(LLSD SyntaxXML); void processTokens(); // Add the token as described diff --git a/indra/newview/app_settings/keywords_lsl_default.xml b/indra/newview/app_settings/keywords_lsl_default.xml index 53a89f0f09..02823136ee 100755 --- a/indra/newview/app_settings/keywords_lsl_default.xml +++ b/indra/newview/app_settings/keywords_lsl_default.xml @@ -21,7 +21,7 @@ for tooltip - for loop\nfor (<initialiser>; <condition>; <post-iteration-statement>)\n{ ...\n} + for loop\nfor (<initializer>; <condition>; <post-iteration-statement>)\n{ ...\n} if diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index fae4aeb7bc..73dc19dd81 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -412,7 +412,7 @@ BOOL LLScriptEdCore::postBuild() LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL - LLSyntaxIdLSL::getInstance()->initialise(); + LLSyntaxIdLSL::getInstance()->initialize(); if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) { @@ -440,7 +440,7 @@ void LLScriptEdCore::updateKeywords() void LLScriptEdCore::processLoaded() { - LLSyntaxIdLSL::getInstance()->initialise(); + LLSyntaxIdLSL::getInstance()->initialize(); if (LLSyntaxIdLSL::getInstance()->isLoaded()) { processKeywords(); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 966c149d3d..69a72325fc 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -77,7 +77,7 @@ protected: public: ~LLScriptEdCore(); - void initialiseKeywords(); + void initializeKeywords(); void initMenu(); void processKeywords(); void processLoaded(); diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 5d87f7ba0c..869368e72c 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -46,7 +46,7 @@ LLScriptEditor::LLScriptEditor(const Params& p) void LLScriptEditor::initKeywords() { - mKeywords.initialise(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); + mKeywords.initialize(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); } static LLFastTimer::DeclareTimer FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 3f726fa8b5..3582ac024d 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -70,7 +70,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) << "Supported verson of syntax file." << LL_ENDL; LLSyntaxIdLSL::setKeywordsXml(content_ref); - LLSyntaxIdLSL::sInitialised = true; + LLSyntaxIdLSL::sInitialized = true; LLSyntaxIdLSL::sLoaded = true; LLSyntaxIdLSL::sLoadFailed = false; @@ -117,12 +117,12 @@ const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; -bool LLSyntaxIdLSL::sInitialised; +bool LLSyntaxIdLSL::sInitialized; LLSD LLSyntaxIdLSL::sKeywordsXml; bool LLSyntaxIdLSL::sLoaded; bool LLSyntaxIdLSL::sLoadFailed; bool LLSyntaxIdLSL::sVersionChanged; -LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; +LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor @@ -207,7 +207,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() } else { - if ( mSyntaxIdCurrent.isNull() && isInitialised()) + if ( mSyntaxIdCurrent.isNull() && isInitialized()) { LL_INFOS("SyntaxLSL") << "It does not have LSLSyntaxId capability, remaining with default keywords file!" @@ -255,9 +255,9 @@ void LLSyntaxIdLSL::fetchKeywordsFile() //----------------------------------------------------------------------------- -// initialise +// initialize //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::initialise() +void LLSyntaxIdLSL::initialize() { mFileNameNew = mFileNameCurrent; mSyntaxIdNew = mSyntaxIdCurrent; @@ -309,7 +309,7 @@ void LLSyntaxIdLSL::initialise() loadDefaultKeywordsIntoLLSD(); } } - else if (!isInitialised()) + else if (!isInitialized()) { loadDefaultKeywordsIntoLLSD(); } @@ -355,8 +355,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) //----------------------------------------------------------------------------- void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") - << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; + LL_INFOS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; mSyntaxIdNew = LLUUID(); buildFullFileSpec(); loadKeywordsIntoLLSD(); @@ -373,9 +372,7 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() */ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") - << "Trying to open cached or default keyword file ;-)" - << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Trying to open cached or default keyword file" << LL_ENDL; // Is this the right thing to do, or should we leave the old content // even if it isn't entirely accurate anymore? @@ -389,9 +386,7 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() sLoaded = (bool)LLSDSerialize::fromXML(content, file); if (!sLoaded) { - LL_WARNS("SyntaxLSL") - << "Unable to deserialise file: " - << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; } else { @@ -399,15 +394,13 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { sKeywordsXml = content; sLoaded = true; - sInitialised = true; - LL_INFOS("SyntaxLSL") - << "Deserialised file: " << mFullFileSpec << LL_ENDL; + sInitialized = true; + LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; } else { sLoaded = false; - LL_WARNS("SyntaxLSL") - << "Unknown or unsupported version of syntax file." << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } } @@ -422,8 +415,3 @@ boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fet { return sFileFetchedSignal.connect(cb); } - -void LLSyntaxIdLSL::removeFileFetchedCallback(boost::signals2::connection callback) -{ - sFileFetchedSignal.disconnect(callback); -} diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 75cfc45380..b68f3f4237 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -36,23 +36,18 @@ #include "llsingleton.h" #include "llviewerregion.h" - -/** - * @file llsyntaxid.h - * @brief Tracks the file needed to decorate the current sim's version of LSL. - */ -class LLSyntaxIdLSL: public LLSingleton +class LLSyntaxIdLSL : public LLSingleton { friend class fetchKeywordsFileResponder; public: typedef boost::signals2::signal file_fetched_signal_t; - static const std::string CAPABILITY_NAME; - static const std::string FILENAME_DEFAULT; - static const std::string SIMULATOR_FEATURE; + static const std::string CAPABILITY_NAME; + static const std::string FILENAME_DEFAULT; + static const std::string SIMULATOR_FEATURE; protected: - static bool sInitialised; + static bool sInitialized; static LLSD sKeywordsXml; static bool sLoaded; static bool sLoadFailed; @@ -85,16 +80,15 @@ public: LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } bool isDifferentVersion() const { return sVersionChanged; } - bool isInitialised() const { return sInitialised; } + bool isInitialized() const { return sInitialized; } - void initialise(); + void initialize(); bool isLoaded() { return sLoaded; } static bool isSupportedVersion(const LLSD& content); static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); - void removeFileFetchedCallback(boost::signals2::connection callback); protected: @@ -110,10 +104,6 @@ protected: }; -/** - * @file llsyntaxid.h - * @brief Handles responses for the LSLSyntax capability's get call. Is a friend of LLSyntaxIdLSL - */ class fetchKeywordsFileResponder : public LLHTTPClient::Responder { public: -- cgit v1.3 From 059a29e976a41c30ec9fb346ae53bbc51aa682fc Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 11 May 2014 23:17:31 -0600 Subject: Fix callback signal, Eliminate some unnecessary statics --- indra/newview/llpreviewscript.cpp | 5 +++-- indra/newview/llsyntaxid.cpp | 35 ++++++++++++++--------------------- indra/newview/llsyntaxid.h | 20 ++++++++------------ 3 files changed, 25 insertions(+), 35 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index befec98849..d83a2bc3a6 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -374,7 +374,6 @@ LLScriptEdCore::LLScriptEdCore( setXMLFilename("panel_script_ed.xml"); llassert_always(mContainer != NULL); - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); } LLScriptEdCore::~LLScriptEdCore() @@ -391,6 +390,7 @@ LLScriptEdCore::~LLScriptEdCore() delete mLiveFile; mRegionChangedCallback.disconnect(); + mFileFetchedCallback.disconnect(); } BOOL LLScriptEdCore::postBuild() @@ -409,7 +409,7 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + mFileFetchedCallback = LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL LLSyntaxIdLSL::getInstance()->initialize(); @@ -422,6 +422,7 @@ BOOL LLScriptEdCore::postBuild() { LL_DEBUGS("SyntaxLSL") << "Hashes are the same, no need to update highlighter." << LL_ENDL; } + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); return TRUE; } diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 3582ac024d..093caf3ecf 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -49,7 +49,7 @@ void fetchKeywordsFileResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content) { - LLSyntaxIdLSL::sLoadFailed = true; + LLSyntaxIdLSL::getInstance()->sLoadFailed = true; LL_WARNS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" << status << "]: " << content @@ -64,35 +64,35 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) LL_DEBUGS("SyntaxLSL") << "content_ref isMap so assuming valid XML." << LL_ENDL; - if (LLSyntaxIdLSL::isSupportedVersion(content_ref)) + if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref)) { LL_INFOS("SyntaxLSL") << "Supported verson of syntax file." << LL_ENDL; - LLSyntaxIdLSL::setKeywordsXml(content_ref); - LLSyntaxIdLSL::sInitialized = true; - LLSyntaxIdLSL::sLoaded = true; - LLSyntaxIdLSL::sLoadFailed = false; + LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref); + LLSyntaxIdLSL::getInstance()->sInitialized = true; + LLSyntaxIdLSL::getInstance()->sLoaded = true; + LLSyntaxIdLSL::getInstance()->sLoadFailed = false; cacheFile(content_ref); } else { - LLSyntaxIdLSL::sLoaded = false; - LLSyntaxIdLSL::sLoadFailed = true; + LLSyntaxIdLSL::getInstance()->sLoaded = false; + LLSyntaxIdLSL::getInstance()->sLoadFailed = true; LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } else { - LLSyntaxIdLSL::sLoaded = false; - LLSyntaxIdLSL::sLoadFailed = true; + LLSyntaxIdLSL::getInstance()->sLoaded = false; + LLSyntaxIdLSL::getInstance()->sLoadFailed = true; LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL; } - LLSyntaxIdLSL::sFileFetchedSignal(); + LLSyntaxIdLSL::getInstance()->sFileFetchedSignal(); } void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) @@ -113,16 +113,9 @@ void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- -const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; -const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; -const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; - -bool LLSyntaxIdLSL::sInitialized; -LLSD LLSyntaxIdLSL::sKeywordsXml; -bool LLSyntaxIdLSL::sLoaded; -bool LLSyntaxIdLSL::sLoadFailed; -bool LLSyntaxIdLSL::sVersionChanged; -LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; +const std::string CAPABILITY_NAME = "LSLSyntax"; +const std::string FILENAME_DEFAULT = "keywords_lsl_default.xml"; +const std::string SIMULATOR_FEATURE = "LSLSyntaxId"; /** * @brief LLSyntaxIdLSL constructor diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index b68f3f4237..179d622286 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -42,17 +42,13 @@ friend class fetchKeywordsFileResponder; public: typedef boost::signals2::signal file_fetched_signal_t; - static const std::string CAPABILITY_NAME; - static const std::string FILENAME_DEFAULT; - static const std::string SIMULATOR_FEATURE; - protected: - static bool sInitialized; - static LLSD sKeywordsXml; - static bool sLoaded; - static bool sLoadFailed; - static bool sVersionChanged; - static file_fetched_signal_t sFileFetchedSignal; + bool sInitialized; + LLSD sKeywordsXml; + bool sLoaded; + bool sLoadFailed; + bool sVersionChanged; + file_fetched_signal_t sFileFetchedSignal; private: std::string mCapabilityName; @@ -85,8 +81,8 @@ public: void initialize(); bool isLoaded() { return sLoaded; } - static bool isSupportedVersion(const LLSD& content); - static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } + bool isSupportedVersion(const LLSD& content); + void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); -- cgit v1.3 From 82cd99d6eb1fbe57e80f54ece6f740c520c7b78a Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 12 May 2014 07:49:18 -0600 Subject: Style - rename previously static members, fix scope, ease up on the exclamation points in debug messages --- indra/newview/llsyntaxid.cpp | 133 ++++++++++++++++--------------------------- indra/newview/llsyntaxid.h | 58 +++++++++---------- 2 files changed, 76 insertions(+), 115 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 093caf3ecf..9a0f53978e 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -40,20 +40,15 @@ fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec) { mFileSpec = filespec; - LL_INFOS("SyntaxLSL") - << "Instantiating with file saving to: '" << filespec << "'" - << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; } void fetchKeywordsFileResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content) { - LLSyntaxIdLSL::getInstance()->sLoadFailed = true; - LL_WARNS("SyntaxLSL") - << "fetchKeywordsFileResponder error [status:" - << status << "]: " << content - << LL_ENDL; + LLSyntaxIdLSL::getInstance()->mLoadFailed = true; + LL_WARNS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" << status << "]: " << content << LL_ENDL; } void fetchKeywordsFileResponder::result(const LLSD& content_ref) @@ -61,38 +56,34 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) // Continue only if a valid LLSD object was returned. if (content_ref.isMap()) { - LL_DEBUGS("SyntaxLSL") - << "content_ref isMap so assuming valid XML." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "content_ref isMap so assuming valid XML." << LL_ENDL; if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref)) { - LL_INFOS("SyntaxLSL") - << "Supported verson of syntax file." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Supported verson of syntax file." << LL_ENDL; LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref); - LLSyntaxIdLSL::getInstance()->sInitialized = true; - LLSyntaxIdLSL::getInstance()->sLoaded = true; - LLSyntaxIdLSL::getInstance()->sLoadFailed = false; + LLSyntaxIdLSL::getInstance()->mInitialized = true; + LLSyntaxIdLSL::getInstance()->mLoaded = true; + LLSyntaxIdLSL::getInstance()->mLoadFailed = false; cacheFile(content_ref); } else { - LLSyntaxIdLSL::getInstance()->sLoaded = false; - LLSyntaxIdLSL::getInstance()->sLoadFailed = true; - LL_WARNS("SyntaxLSL") - << "Unknown or unsupported version of syntax file." << LL_ENDL; + LLSyntaxIdLSL::getInstance()->mLoaded = false; + LLSyntaxIdLSL::getInstance()->mLoadFailed = true; + LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } else { - LLSyntaxIdLSL::getInstance()->sLoaded = false; - LLSyntaxIdLSL::getInstance()->sLoadFailed = true; - LL_WARNS("SyntaxLSL") - << "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL; + LLSyntaxIdLSL::getInstance()->mLoaded = false; + LLSyntaxIdLSL::getInstance()->mLoadFailed = true; + LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD." << LL_ENDL; } - LLSyntaxIdLSL::getInstance()->sFileFetchedSignal(); + LLSyntaxIdLSL::getInstance()->mFileFetchedSignal(); } void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) @@ -106,8 +97,7 @@ void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) file.write(xml.c_str(), str.str().size()); file.close(); - LL_INFOS("SyntaxLSL") - << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; } //----------------------------------------------------------------------------- @@ -159,18 +149,15 @@ std::string LLSyntaxIdLSL::buildFullFileSpec() //----------------------------------------------------------------------------- bool LLSyntaxIdLSL::checkSyntaxIdChanged() { - sVersionChanged = false; + mVersionChanged = false; LLViewerRegion* region = gAgent.getRegion(); if (region) { if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it may be needed. - sLoadFailed = true; - LL_WARNS("SyntaxLSL") - << "Region '" << region->getName() - << "' has not received capabilities yet! Cannot process SyntaxId." - << LL_ENDL; + mLoadFailed = true; + LL_INFOS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities yet. Cannot process SyntaxId." << LL_ENDL; } else { @@ -185,40 +172,32 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() mCapabilityURL = region->getCapability(mCapabilityName); if (mSyntaxIdCurrent != mSyntaxIdNew) { - LL_INFOS("SyntaxLSL") - << "It has LSLSyntaxId capability, and the new hash is '" - << mSyntaxIdNew.asString() << "'" << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Region has LSLSyntaxId capability, and the new hash is '" << mSyntaxIdNew.asString() << "'" << LL_ENDL; - sVersionChanged = true; + mVersionChanged = true; } else { - LL_INFOS("SyntaxLSL") - << "It has the same LSLSyntaxId! Leaving hash as '" - << mSyntaxIdCurrent.asString() << "'" << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Region has the same LSLSyntaxId! Leaving hash as '" << mSyntaxIdCurrent.asString() << "'" << LL_ENDL; } } else { if ( mSyntaxIdCurrent.isNull() && isInitialized()) { - LL_INFOS("SyntaxLSL") - << "It does not have LSLSyntaxId capability, remaining with default keywords file!" - << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Region does not have LSLSyntaxId capability, remaining with default keywords." << LL_ENDL; } else { // The hash is set to NULL_KEY to indicate use of default keywords file mSyntaxIdNew = LLUUID(); - LL_INFOS("SyntaxLSL") - << "It does not have LSLSyntaxId capability, using default keywords file!" - << LL_ENDL; - sVersionChanged = true; + LL_DEBUGS("SyntaxLSL") << "Region does not have LSLSyntaxId capability, using default keywords." << LL_ENDL; + mVersionChanged = true; } } } } - return sVersionChanged; + return mVersionChanged; } /** @@ -228,7 +207,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() */ bool LLSyntaxIdLSL::fetching() { - return !(sLoaded || sLoadFailed); + return !(mLoaded || mLoadFailed); } //----------------------------------------------------------------------------- @@ -240,10 +219,7 @@ void LLSyntaxIdLSL::fetchKeywordsFile() new fetchKeywordsFileResponder(mFullFileSpec), LLSD(), 30.f ); - LL_INFOS("SyntaxLSL") - << "LSLSyntaxId capability URL is: " << mCapabilityURL - << ". Filename to use is: '" << mFullFileSpec << "'." - << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << mFullFileSpec << "'." << LL_ENDL; } @@ -257,8 +233,8 @@ void LLSyntaxIdLSL::initialize() if (checkSyntaxIdChanged()) { - sKeywordsXml = LLSD(); - sLoaded = sLoadFailed = false; + mKeywordsXml = LLSD(); + mLoaded = mLoadFailed = false; if (mSyntaxIdNew.isNull()) { // Need to open the default @@ -266,9 +242,7 @@ void LLSyntaxIdLSL::initialize() } else if (!mCapabilityURL.empty() ) { - LL_INFOS("SyntaxLSL") - << "LSL version has changed, getting appropriate file." - << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "LSL version has changed, getting appropriate file." << LL_ENDL; // Need a full spec regardless of file source, so build it now. buildFullFileSpec(); @@ -276,16 +250,11 @@ void LLSyntaxIdLSL::initialize() { if ( !gDirUtilp->fileExists(mFullFileSpec) ) { // Does not exist, so fetch it from the capability - LL_INFOS("SyntaxLSL") - << "File is not cached, we will try to download it!" - << LL_ENDL; + LL_INFOS("SyntaxLSL") << "LSL syntax not cached, attempting download." << LL_ENDL; fetchKeywordsFile(); } else { - LL_INFOS("SyntaxLSL") - << "File is cached, no need to download!" - << LL_ENDL; loadKeywordsIntoLLSD(); } } @@ -296,9 +265,8 @@ void LLSyntaxIdLSL::initialize() } else { - sLoadFailed = true; - LL_WARNS("SyntaxLSL") - << "LSLSyntaxId capability URL is empty!!" << LL_ENDL; + mLoadFailed = true; + LL_WARNS("SyntaxLSL") << "LSLSyntaxId capability URL is empty." << LL_ENDL; loadDefaultKeywordsIntoLLSD(); } } @@ -327,8 +295,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY)) { - LL_INFOS("SyntaxLSL") - << "Syntax file version: " << content[LLSD_SYNTAX_LSL_VERSION_KEY].asString() << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "LSL syntax version: " << content[LLSD_SYNTAX_LSL_VERSION_KEY].asString() << LL_ENDL; if (content[LLSD_SYNTAX_LSL_VERSION_KEY].asInteger() == LLSD_SYNTAX_LSL_VERSION_EXPECTED) { @@ -337,7 +304,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) } else { - LL_WARNS("SyntaxLSL") << "No version key available!" << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "No LSL syntax version key." << LL_ENDL; } return isValid; @@ -348,7 +315,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) //----------------------------------------------------------------------------- void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file." << LL_ENDL; mSyntaxIdNew = LLUUID(); buildFullFileSpec(); loadKeywordsIntoLLSD(); @@ -365,46 +332,46 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() */ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") << "Trying to open cached or default keyword file" << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Trying to open cached or default keyword file" << 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(); + mKeywordsXml = LLSD().emptyMap(); LLSD content; llifstream file; file.open(mFullFileSpec); if (file.is_open()) { - sLoaded = (bool)LLSDSerialize::fromXML(content, file); - if (!sLoaded) + mLoaded = (bool)LLSDSerialize::fromXML(content, file); + if (!mLoaded) { - LL_WARNS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unable to deserialise: " << mFullFileSpec << LL_ENDL; } else { if (isSupportedVersion(content)) { - sKeywordsXml = content; - sLoaded = true; - sInitialized = true; - LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; + mKeywordsXml = content; + mLoaded = true; + mInitialized = true; + LL_DEBUGS("SyntaxLSL") << "Deserialised: " << mFullFileSpec << LL_ENDL; } else { - sLoaded = false; + mLoaded = false; LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } } else { - LL_WARNS("SyntaxLSL") << "Unable to open file: " << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unable to open: " << mFullFileSpec << LL_ENDL; } - sLoadFailed = !sLoaded; + mLoadFailed = !mLoaded; } boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb) { - return sFileFetchedSignal.connect(cb); + return mFileFetchedSignal.connect(cb); } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 179d622286..d803a09167 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -39,30 +39,6 @@ class LLSyntaxIdLSL : public LLSingleton { friend class fetchKeywordsFileResponder; -public: - typedef boost::signals2::signal file_fetched_signal_t; - -protected: - bool sInitialized; - LLSD sKeywordsXml; - bool sLoaded; - bool sLoadFailed; - bool sVersionChanged; - file_fetched_signal_t sFileFetchedSignal; - -private: - std::string mCapabilityName; - std::string mCapabilityURL; - std::string mFileNameCurrent; - std::string mFileNameDefault; - std::string mFileNameNew; - ELLPath mFilePath; - std::string mFullFileSpec; - std::string mSimulatorFeature; - LLUUID mSyntaxIdCurrent; - LLUUID mSyntaxIdNew; - - public: LLSyntaxIdLSL(); @@ -73,20 +49,19 @@ public: std::string getFileNameCurrent() const { return mFileNameCurrent; } ELLPath getFilePath() const { return mFilePath; } std::string getFileSpec() const { return mFullFileSpec; } - LLSD getKeywordsXML() const { return sKeywordsXml; } + LLSD getKeywordsXML() const { return mKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } - bool isDifferentVersion() const { return sVersionChanged; } - bool isInitialized() const { return sInitialized; } + bool isDifferentVersion() const { return mVersionChanged; } + bool isInitialized() const { return mInitialized; } void initialize(); - bool isLoaded() { return sLoaded; } - - bool isSupportedVersion(const LLSD& content); - void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } + bool isLoaded() { return mLoaded; } + bool isSupportedVersion(const LLSD& content); + void setKeywordsXml(const LLSD& content) { mKeywordsXml = content; } + typedef boost::signals2::signal file_fetched_signal_t; boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); - protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); @@ -97,6 +72,25 @@ protected: void setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; } void setFileNameDefault(const std::string& name) { mFileNameDefault = name; } void setFileNameNew(const std::string name) { mFileNameNew = name; } + +private: + bool mInitialized; + LLSD mKeywordsXml; + bool mLoaded; + bool mLoadFailed; + bool mVersionChanged; + file_fetched_signal_t mFileFetchedSignal; + + std::string mCapabilityName; + std::string mCapabilityURL; + std::string mFileNameCurrent; + std::string mFileNameDefault; + std::string mFileNameNew; + ELLPath mFilePath; + std::string mFullFileSpec; + std::string mSimulatorFeature; + LLUUID mSyntaxIdCurrent; + LLUUID mSyntaxIdNew; }; -- cgit v1.3 From 15d8f355072f2184f046a7aafb1b5c606fe97880 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 14 May 2014 16:43:13 -0400 Subject: clean up the constructor for LLSyntaxIdLSL --- indra/newview/llsyntaxid.cpp | 36 +++++++++++++++++------------------- indra/newview/llsyntaxid.h | 5 ++++- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 9a0f53978e..7551c1a442 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -103,31 +103,29 @@ void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- -const std::string CAPABILITY_NAME = "LSLSyntax"; -const std::string FILENAME_DEFAULT = "keywords_lsl_default.xml"; -const std::string SIMULATOR_FEATURE = "LSLSyntaxId"; +const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; +const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; +const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability) -: mFilePath(LL_PATH_APP_SETTINGS) -{ - mCapabilityName = capability; - mFileNameCurrent = filename; - mFileNameDefault = filename; - mSimulatorFeature = sim_feature; - mSyntaxIdCurrent = LLUUID(); -} - LLSyntaxIdLSL::LLSyntaxIdLSL() : - mFilePath(LL_PATH_APP_SETTINGS) + mInitialized(false), + mKeywordsXml(LLSD()), + mLoaded(false), + mLoadFailed(false), + mVersionChanged(false), + mCapabilityName(CAPABILITY_NAME), + mCapabilityURL(""), + mFileNameCurrent(FILENAME_DEFAULT), + mFileNameDefault(FILENAME_DEFAULT), + mFileNameNew(""), + mFilePath(LL_PATH_APP_SETTINGS), + mSimulatorFeature(SIMULATOR_FEATURE), + mSyntaxIdCurrent(LLUUID()), + mSyntaxIdNew(LLUUID()) { - mCapabilityName = CAPABILITY_NAME; - mFileNameCurrent = FILENAME_DEFAULT; - mFileNameDefault = FILENAME_DEFAULT; - mSimulatorFeature = SIMULATOR_FEATURE; - mSyntaxIdCurrent = LLUUID(); } std::string LLSyntaxIdLSL::buildFileNameNew() diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index d803a09167..aa69209ca9 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -42,7 +42,6 @@ friend class fetchKeywordsFileResponder; public: LLSyntaxIdLSL(); - LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability); bool checkSyntaxIdChanged(); bool fetching(); @@ -74,6 +73,10 @@ protected: void setFileNameNew(const std::string name) { mFileNameNew = name; } private: + static const std::string CAPABILITY_NAME; + static const std::string FILENAME_DEFAULT; + static const std::string SIMULATOR_FEATURE; + bool mInitialized; LLSD mKeywordsXml; bool mLoaded; -- cgit v1.3 From e6b20328c2e25223359dede17357682b5b4e7ea1 Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 4 Jun 2014 22:51:20 -0600 Subject: A little more cleanup in LLSyntaxIDLSL and LLKeywords --- indra/llui/llkeywords.cpp | 65 ++++++++++++++++++++++++-------------------- indra/llui/llkeywords.h | 24 ++++++++++++---- indra/newview/llsyntaxid.cpp | 15 +++------- indra/newview/llsyntaxid.h | 5 ++-- 4 files changed, 59 insertions(+), 50 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 9be15d8f1d..9c5a339b6d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -67,8 +67,8 @@ inline bool LLKeywordToken::isTail(const llwchar* s) const return res; } -LLKeywords::LLKeywords() : - mLoaded(false) +LLKeywords::LLKeywords() +: mLoaded(false) { } @@ -92,7 +92,7 @@ void LLKeywords::addToken(LLKeywordToken::ETokenType type, std::string tip_text = tool_tip_in; LLStringUtil::replaceString(tip_text, "\\n", "\n" ); LLStringUtil::replaceString(tip_text, "\t", " " ); - if (tip_text == "") + if (tip_text.empty()) { tip_text = "[no info]"; } @@ -161,7 +161,7 @@ std::string LLKeywords::getArguments(LLSD& arguments) { LL_WARNS("SyntaxLSL") << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; } - return argString == "" ? "" : argString; + return argString; } std::string LLKeywords::getAttribute(const std::string& key) @@ -299,14 +299,14 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group if (tokens.isMap()) { LLSD::map_const_iterator outer_itr = tokens.beginMap(); - for ( ; outer_itr != tokens.endMap(); ++outer_itr) + for ( ; outer_itr != tokens.endMap(); ++outer_itr ) { if (outer_itr->second.isMap()) { mAttributes.clear(); LLSD arguments = LLSD(); LLSD::map_const_iterator inner_itr = outer_itr->second.beginMap(); - for ( ; inner_itr != outer_itr->second.endMap(); ++inner_itr) + for ( ; inner_itr != outer_itr->second.endMap(); ++inner_itr ) { if (inner_itr->first == "arguments") { @@ -326,33 +326,34 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group } std::string tooltip = ""; - if (token_type == LLKeywordToken::TT_CONSTANT) + switch (token_type) { - color_group = getColorGroup(group + "-" + getAttribute("type")); - tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value"); - } - else if (token_type == LLKeywordToken::TT_EVENT) - { - tooltip = outer_itr->first + "(" + getArguments(arguments) + ")"; - } - else if (token_type == LLKeywordToken::TT_FUNCTION) - { - tooltip = getAttribute("return") + " " + outer_itr->first + "(" + getArguments(arguments) + ");"; - tooltip += "\nEnergy: "; - tooltip += getAttribute("energy") == "" ? "0.0" : getAttribute("energy"); - if (getAttribute("sleep") != "") - { - tooltip += ", Sleep: " + getAttribute("sleep"); - } + case LLKeywordToken::TT_CONSTANT: + color_group = getColorGroup(group + "-" + getAttribute("type")); + tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value"); + break; + case LLKeywordToken::TT_EVENT: + tooltip = outer_itr->first + "(" + getArguments(arguments) + ")"; + break; + case LLKeywordToken::TT_FUNCTION: + tooltip = getAttribute("return") + " " + outer_itr->first + "(" + getArguments(arguments) + ");"; + tooltip.append("\nEnergy: "); + tooltip.append(getAttribute("energy").empty() ? "0.0" : getAttribute("energy")); + if (!getAttribute("sleep").empty()) + { + tooltip += ", Sleep: " + getAttribute("sleep"); + } + default: + break; } - if (getAttribute("tooltip") != "") + if (!getAttribute("tooltip").empty()) { - if (tooltip != "") + if (!tooltip.empty()) { - tooltip += "\n"; + tooltip.append("\n"); } - tooltip += getAttribute("tooltip"); + tooltip.append(getAttribute("tooltip")); } color = getAttribute("deprecated") == "true" ? color_deprecated : color_group; @@ -399,15 +400,19 @@ LLKeywords::WStringMapIndex::WStringMapIndex(const LLWString& str) copyData(str.data(), str.size()); } -LLKeywords::WStringMapIndex::WStringMapIndex(const llwchar *start, size_t length): -mData(start), mLength(length), mOwner(false) +LLKeywords::WStringMapIndex::WStringMapIndex(const llwchar *start, size_t length) +: mData(start) +, mLength(length) +, mOwner(false) { } LLKeywords::WStringMapIndex::~WStringMapIndex() { - if(mOwner) + if (mOwner) + { delete[] mData; + } } void LLKeywords::WStringMapIndex::copyData(const llwchar *start, size_t length) diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 4e20b4459e..18e2ed06c5 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -113,7 +113,10 @@ public: LLColor4 getColorGroup(const std::string& key_in); bool isLoaded() const { return mLoaded; } - void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); + void findSegments(std::vector *seg_list, + const LLWString& text, + const LLColor4 &defaultColor, + class LLTextEditor& editor); void initialize(LLSD SyntaxXML); void processTokens(); @@ -167,8 +170,19 @@ public: protected: void processTokensGroup(const LLSD& Tokens, const std::string& Group); - void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); - void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); + void insertSegment(std::vector& seg_list, + LLTextSegmentPtr new_segment, + S32 text_len, + const LLColor4 &defaultColor, + class LLTextEditor& editor); + void insertSegments(const LLWString& wtext, + std::vector& seg_list, + LLKeywordToken* token, + S32 text_len, + S32 seg_start, + S32 seg_end, + const LLColor4 &defaultColor, + LLTextEditor& editor); bool mLoaded; LLSD mSyntax; @@ -182,9 +196,7 @@ protected: element_attributes_t mAttributes; std::string getAttribute(const std::string& key); - std::string getArguments(LLSD& args); - -private: + std::string getArguments(LLSD& arguments); }; #endif // LL_LLKEYWORDS_H diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 7551c1a442..0ef5993ac1 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -37,9 +37,9 @@ //----------------------------------------------------------------------------- // fetchKeywordsFileResponder //----------------------------------------------------------------------------- -fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec) +fetchKeywordsFileResponder::fetchKeywordsFileResponder(const std::string& filespec) +: mFileSpec(filespec) { - mFileSpec = filespec; LL_DEBUGS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; } @@ -128,18 +128,11 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() : { } -std::string LLSyntaxIdLSL::buildFileNameNew() -{ - mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + mSyntaxIdNew.asString() + ".llsd.xml"; - return mFileNameNew; -} - -std::string LLSyntaxIdLSL::buildFullFileSpec() +void LLSyntaxIdLSL::buildFullFileSpec() { ELLPath path = mSyntaxIdNew.isNull() ? LL_PATH_APP_SETTINGS : LL_PATH_CACHE; - buildFileNameNew(); + mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + mSyntaxIdNew.asString() + ".llsd.xml"; mFullFileSpec = gDirUtilp->getExpandedFilename(path, mFileNameNew); - return mFullFileSpec; } //----------------------------------------------------------------------------- diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index f14693d619..2288fb4ab8 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -62,8 +62,7 @@ public: boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); protected: - std::string buildFileNameNew(); - std::string buildFullFileSpec(); + void buildFullFileSpec(); void fetchKeywordsFile(); void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); @@ -105,7 +104,7 @@ public: * @brief fetchKeywordsFileResponder * @param filespec File path and name of where to save the returned data */ - fetchKeywordsFileResponder(std::string filespec); + fetchKeywordsFileResponder(const std::string& filespec); void errorWithContent(U32 status, const std::string& reason, -- cgit v1.3 From 41f6c5ce4899b3ae57aefa564ee22ff84fa698ce Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 9 Jun 2014 15:14:09 -0600 Subject: Greatly simplify LLSyntaxIdLSL: * Move file fetched callback to the singleton and handle all syntax id changes within the singleton * Remove a fair number of bool checks and method relying more on callbacks to drive syntax changes. * Don't pretty print the cache file to conserve space and to speed up xml to llsd parsing * Clean up includes --- indra/newview/llpreviewscript.cpp | 95 ++++-------- indra/newview/llpreviewscript.h | 3 +- indra/newview/llsyntaxid.cpp | 296 ++++++++++++++++---------------------- indra/newview/llsyntaxid.h | 111 ++++---------- 4 files changed, 182 insertions(+), 323 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 76cb1c1ebc..9ff0ece7d9 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -399,13 +399,9 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; - if (mRegionChangedCallback.connected()) + if (mSyntaxIDConnection.connected()) { - mRegionChangedCallback.disconnect(); - } - if (mFileFetchedCallback.connected()) - { - mFileFetchedCallback.disconnect(); + mSyntaxIDConnection.disconnect(); } } @@ -425,79 +421,48 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mFileFetchedCallback = LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + mSyntaxIDConnection = LLSyntaxIdLSL::getInstance()->addSyntaxIDCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL LLSyntaxIdLSL::getInstance()->initialize(); - - if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) - { - processLoaded(); - } - else - { - processKeywords(); - } - - if (mLive) - { - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::processLoaded, this)); - } + processKeywords(); return TRUE; } -void LLScriptEdCore::processLoaded() -{ - LLSyntaxIdLSL::getInstance()->initialize(); - if (LLSyntaxIdLSL::getInstance()->isLoaded()) - { - processKeywords(); - } - else - { - LL_DEBUGS("SyntaxLSL") << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; - } -} - void LLScriptEdCore::processKeywords() { - if (LLSyntaxIdLSL::getInstance()->isLoaded()) - { - LL_DEBUGS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; - - mEditor->clearSegments(); - - mEditor->initKeywords(); - mEditor->loadKeywords(); - - string_vec_t primary_keywords; - string_vec_t secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) - { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else - { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - } - for (string_vec_t::const_iterator iter = primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + LL_DEBUGS("SyntaxLSL") << "Processing keywords" << LL_ENDL; + mEditor->clearSegments(); + mEditor->initKeywords(); + mEditor->loadKeywords(); + + string_vec_t primary_keywords; + string_vec_t secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + { + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) { - mFunctions->add(*iter); + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } - for (string_vec_t::const_iterator iter = secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) + else { - mFunctions->add(*iter); + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } } + for (string_vec_t::const_iterator iter = primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } + for (string_vec_t::const_iterator iter = secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } void LLScriptEdCore::initMenu() diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 5aab3ed938..9ea191e928 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -159,8 +159,7 @@ private: LLScriptEdContainer* mContainer; // parent view public: - boost::signals2::connection mFileFetchedCallback; - boost::signals2::connection mRegionChangedCallback; + boost::signals2::connection mSyntaxIDConnection; }; diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 0ef5993ac1..5b5bab85d0 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -1,8 +1,8 @@ /** * @file LLSyntaxId - * @author Ima Mechanique * @brief Handles downloading, saving, and checking of LSL keyword/syntax files * for each region. + * @author Ima Mechanique, Cinder Roxley * * $LicenseInfo:firstyear=2013&license=viewerlgpl$ * Second Life Viewer Source Code @@ -28,189 +28,149 @@ #include "llviewerprecompiledheaders.h" +#include "llsyntaxid.h" #include "llagent.h" #include "llappviewer.h" #include "llhttpclient.h" #include "llsdserialize.h" -#include "llsyntaxid.h" +#include "llviewerregion.h" //----------------------------------------------------------------------------- // fetchKeywordsFileResponder //----------------------------------------------------------------------------- -fetchKeywordsFileResponder::fetchKeywordsFileResponder(const std::string& filespec) -: mFileSpec(filespec) +class fetchKeywordsFileResponder : public LLHTTPClient::Responder { - LL_DEBUGS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; -} +public: + fetchKeywordsFileResponder(const std::string& filespec) + : mFileSpec(filespec) + { + LL_DEBUGS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL; + } -void fetchKeywordsFileResponder::errorWithContent(U32 status, - const std::string& reason, - const LLSD& content) -{ - LLSyntaxIdLSL::getInstance()->mLoadFailed = true; - LL_WARNS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" << status << "]: " << content << LL_ENDL; -} + virtual void errorWithContent(U32 status, + const std::string& reason, + const LLSD& content) + { + LL_WARNS("SyntaxLSL") << "failed to fetch syntax file [status:" << status << "]: " << content << LL_ENDL; + } -void fetchKeywordsFileResponder::result(const LLSD& content_ref) -{ + virtual void result(const LLSD& content_ref) + { // Continue only if a valid LLSD object was returned. if (content_ref.isMap()) { - LL_DEBUGS("SyntaxLSL") << "content_ref isMap so assuming valid XML." << LL_ENDL; - if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref)) { - LL_DEBUGS("SyntaxLSL") << "Supported verson of syntax file." << LL_ENDL; - LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref); - LLSyntaxIdLSL::getInstance()->mInitialized = true; - LLSyntaxIdLSL::getInstance()->mLoaded = true; - LLSyntaxIdLSL::getInstance()->mLoadFailed = false; cacheFile(content_ref); + LLSyntaxIdLSL::getInstance()->handleFileFetched(mFileSpec); } else { - LLSyntaxIdLSL::getInstance()->mLoaded = false; - LLSyntaxIdLSL::getInstance()->mLoadFailed = true; LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } else { - LLSyntaxIdLSL::getInstance()->mLoaded = false; - LLSyntaxIdLSL::getInstance()->mLoadFailed = true; LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD." << LL_ENDL; } - - LLSyntaxIdLSL::getInstance()->mFileFetchedSignal(); } -void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) -{ - 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(); + void cacheFile(const LLSD& content_ref) + { + std::stringstream str; + LLSDSerialize::toXML(content_ref, str); + const std::string xml = str.str(); - LL_DEBUGS("SyntaxLSL") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; -} + // save the str to disk, usually to the cache. + llofstream file(mFileSpec, std::ios_base::out); + file.write(xml.c_str(), str.str().size()); + file.close(); + LL_DEBUGS("SyntaxLSL") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL; + } + +private: + std::string mFileSpec; +}; + //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- -const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; -const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; -const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; +const std::string SYNTAX_ID_CAPABILITY_NAME = "LSLSyntax"; +const std::string SYNTAX_ID_SIMULATOR_FEATURE = "LSLSyntaxId"; +const std::string FILENAME_DEFAULT = "keywords_lsl_default.xml"; /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL() : - mInitialized(false), - mKeywordsXml(LLSD()), - mLoaded(false), - mLoadFailed(false), - mVersionChanged(false), - mCapabilityName(CAPABILITY_NAME), - mCapabilityURL(""), - mFileNameCurrent(FILENAME_DEFAULT), - mFileNameDefault(FILENAME_DEFAULT), - mFileNameNew(""), - mFilePath(LL_PATH_APP_SETTINGS), - mSimulatorFeature(SIMULATOR_FEATURE), - mSyntaxIdCurrent(LLUUID()), - mSyntaxIdNew(LLUUID()) +LLSyntaxIdLSL::LLSyntaxIdLSL() +: mKeywordsXml(LLSD()) +, mCapabilityURL(std::string()) +, mFilePath(LL_PATH_APP_SETTINGS) +, mSyntaxId(LLUUID()) { + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLSyntaxIdLSL::handleRegionChanged, this)); + handleRegionChanged(); // Kick off an initial caps query and fetch } void LLSyntaxIdLSL::buildFullFileSpec() { - ELLPath path = mSyntaxIdNew.isNull() ? LL_PATH_APP_SETTINGS : LL_PATH_CACHE; - mFileNameNew = mSyntaxIdNew.isNull() ? mFileNameDefault : "keywords_lsl_" + mSyntaxIdNew.asString() + ".llsd.xml"; - mFullFileSpec = gDirUtilp->getExpandedFilename(path, mFileNameNew); + ELLPath path = mSyntaxId.isNull() ? LL_PATH_APP_SETTINGS : LL_PATH_CACHE; + const std::string filename = mSyntaxId.isNull() ? FILENAME_DEFAULT : "keywords_lsl_" + mSyntaxId.asString() + ".llsd.xml"; + mFullFileSpec = gDirUtilp->getExpandedFilename(path, filename); } //----------------------------------------------------------------------------- -// checkSyntaxIdChange() +// syntaxIdChange() //----------------------------------------------------------------------------- -bool LLSyntaxIdLSL::checkSyntaxIdChanged() +bool LLSyntaxIdLSL::syntaxIdChanged() { - mVersionChanged = false; + bool version_changed = false; LLViewerRegion* region = gAgent.getRegion(); if (region) { - if (!region->capabilitiesReceived()) - { // Shouldn't be possible, but experience shows that it may be needed. - mLoadFailed = true; - LL_INFOS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities yet. Cannot process SyntaxId." << LL_ENDL; - } - else + if (region->capabilitiesReceived()) { - LLSD simFeatures; - region->getSimulatorFeatures(simFeatures); + LLSD sim_features; + region->getSimulatorFeatures(sim_features); - // Does the sim have the required feature - if (simFeatures.has(mSimulatorFeature)) + if (sim_features.has(SYNTAX_ID_SIMULATOR_FEATURE)) { // get and check the hash - mSyntaxIdNew = simFeatures[mSimulatorFeature].asUUID(); - mCapabilityURL = region->getCapability(mCapabilityName); - if (mSyntaxIdCurrent != mSyntaxIdNew) - { - LL_DEBUGS("SyntaxLSL") << "Region has LSLSyntaxId capability, and the new hash is '" << mSyntaxIdNew.asString() << "'" << LL_ENDL; - - mVersionChanged = true; - } - else - { - LL_DEBUGS("SyntaxLSL") << "Region has the same LSLSyntaxId! Leaving hash as '" << mSyntaxIdCurrent.asString() << "'" << LL_ENDL; - } - } - else - { - if ( mSyntaxIdCurrent.isNull() && isInitialized()) + LLUUID new_syntax_id = sim_features[SYNTAX_ID_SIMULATOR_FEATURE].asUUID(); + mCapabilityURL = region->getCapability(SYNTAX_ID_CAPABILITY_NAME); + LL_DEBUGS("SyntaxLSL") << SYNTAX_ID_SIMULATOR_FEATURE << " capability URL: " << mCapabilityURL << LL_ENDL; + if (new_syntax_id != mSyntaxId) { - LL_DEBUGS("SyntaxLSL") << "Region does not have LSLSyntaxId capability, remaining with default keywords." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "New SyntaxID '" << new_syntax_id << "' found." << LL_ENDL; + mSyntaxId = new_syntax_id; + version_changed = true; } else - { - // The hash is set to NULL_KEY to indicate use of default keywords file - mSyntaxIdNew = LLUUID(); - LL_DEBUGS("SyntaxLSL") << "Region does not have LSLSyntaxId capability, using default keywords." << LL_ENDL; - mVersionChanged = true; - } + LL_DEBUGS("SyntaxLSL") << "SyntaxID matches what we have." << LL_ENDL; } } + else + { + LL_WARNS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities. Cannot process SyntaxId." << LL_ENDL; + } } - return mVersionChanged; -} - -/** - * @brief LLSyntaxIdLSL::fetching - * If the XML has not loaded yet and it hasn't failed, then we're still fetching it. - * @return bool Whether the file fetch is still in process. - */ -bool LLSyntaxIdLSL::fetching() -{ - return !(mLoaded || mLoadFailed); + return version_changed; } //----------------------------------------------------------------------------- // fetchKeywordsFile //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::fetchKeywordsFile() +void LLSyntaxIdLSL::fetchKeywordsFile(const std::string& filespec) { + mInflightFetches.push_back(filespec); LLHTTPClient::get(mCapabilityURL, - new fetchKeywordsFileResponder(mFullFileSpec), - LLSD(), 30.f - ); - LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << mFullFileSpec << "'." << LL_ENDL; + new fetchKeywordsFileResponder(filespec), + LLSD(), 30.f); + LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << filespec << "'." << LL_ENDL; } @@ -219,55 +179,40 @@ void LLSyntaxIdLSL::fetchKeywordsFile() //----------------------------------------------------------------------------- void LLSyntaxIdLSL::initialize() { - mFileNameNew = mFileNameCurrent; - mSyntaxIdNew = mSyntaxIdCurrent; - - if (checkSyntaxIdChanged()) + if (mSyntaxId.isNull()) { - mKeywordsXml = LLSD(); - mLoaded = mLoadFailed = false; + loadDefaultKeywordsIntoLLSD(); + } + else if (!mCapabilityURL.empty()) + { + LL_DEBUGS("SyntaxLSL") << "LSL version has changed, getting appropriate file." << LL_ENDL; - if (mSyntaxIdNew.isNull()) - { // Need to open the default - loadDefaultKeywordsIntoLLSD(); - } - else if (!mCapabilityURL.empty() ) + // Need a full spec regardless of file source, so build it now. + buildFullFileSpec(); + if (mSyntaxId.notNull()) { - LL_DEBUGS("SyntaxLSL") << "LSL version has changed, getting appropriate file." << LL_ENDL; - - // Need a full spec regardless of file source, so build it now. - buildFullFileSpec(); - if ( !mSyntaxIdNew.isNull()) - { - if ( !gDirUtilp->fileExists(mFullFileSpec) ) - { // Does not exist, so fetch it from the capability - LL_INFOS("SyntaxLSL") << "LSL syntax not cached, attempting download." << LL_ENDL; - fetchKeywordsFile(); - } - else - { - loadKeywordsIntoLLSD(); - } + if (!gDirUtilp->fileExists(mFullFileSpec)) + { // Does not exist, so fetch it from the capability + LL_DEBUGS("SyntaxLSL") << "LSL syntax not cached, attempting download." << LL_ENDL; + fetchKeywordsFile(mFullFileSpec); } else - { // Need to open the default - loadDefaultKeywordsIntoLLSD(); + { + LL_DEBUGS("SyntaxLSL") << "Found cached Syntax file: " << mFullFileSpec << " Loading keywords." << LL_ENDL; + loadKeywordsIntoLLSD(); } } else { - mLoadFailed = true; - LL_WARNS("SyntaxLSL") << "LSLSyntaxId capability URL is empty." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId is null. Loading default values" << LL_ENDL; loadDefaultKeywordsIntoLLSD(); } } - else if (!isInitialized()) + else { + LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is empty." << LL_ENDL; loadDefaultKeywordsIntoLLSD(); } - - mFileNameCurrent = mFileNameNew; - mSyntaxIdCurrent = mSyntaxIdNew; } //----------------------------------------------------------------------------- @@ -278,7 +223,7 @@ const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) { - bool isValid = false; + bool is_valid = false; /* * If the schema used to store LSL keywords and hints changes, this value is incremented * Note that it should _not_ be changed if the keywords and hints _content_ changes. @@ -290,15 +235,15 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) if (content[LLSD_SYNTAX_LSL_VERSION_KEY].asInteger() == LLSD_SYNTAX_LSL_VERSION_EXPECTED) { - isValid = true; + is_valid = true; } } else { - LL_DEBUGS("SyntaxLSL") << "No LSL syntax version key." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Missing LSL syntax version key." << LL_ENDL; } - return isValid; + return is_valid; } //----------------------------------------------------------------------------- @@ -306,8 +251,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) //----------------------------------------------------------------------------- void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() { - LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file." << LL_ENDL; - mSyntaxIdNew = LLUUID(); + mSyntaxId.setNull(); buildFullFileSpec(); loadKeywordsIntoLLSD(); } @@ -323,46 +267,52 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() */ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { - LL_DEBUGS("SyntaxLSL") << "Trying to open cached or default keyword file" << LL_ENDL; - - // Is this the right thing to do, or should we leave the old content - // even if it isn't entirely accurate anymore? - mKeywordsXml = LLSD().emptyMap(); - LLSD content; llifstream file; file.open(mFullFileSpec); if (file.is_open()) { - mLoaded = (bool)LLSDSerialize::fromXML(content, file); - if (!mLoaded) - { - LL_WARNS("SyntaxLSL") << "Unable to deserialise: " << mFullFileSpec << LL_ENDL; - } - else + if (LLSDSerialize::fromXML(content, file) != LLSDParser::PARSE_FAILURE) { if (isSupportedVersion(content)) { - mKeywordsXml = content; - mLoaded = true; - mInitialized = true; LL_DEBUGS("SyntaxLSL") << "Deserialised: " << mFullFileSpec << LL_ENDL; } else { - mLoaded = false; LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } } else { - LL_WARNS("SyntaxLSL") << "Unable to open: " << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Failed to open: " << mFullFileSpec << LL_ENDL; + } + mKeywordsXml = content; + mSyntaxIDChangedSignal(); +} + +bool LLSyntaxIdLSL::keywordFetchInProgress() +{ + return !mInflightFetches.empty(); +} + +void LLSyntaxIdLSL::handleRegionChanged() +{ + if (syntaxIdChanged()) + { + buildFullFileSpec(); + fetchKeywordsFile(mFullFileSpec); } - mLoadFailed = !mLoaded; } -boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb) +void LLSyntaxIdLSL::handleFileFetched(const std::string& filepath) +{ + mInflightFetches.remove(filepath); + loadKeywordsIntoLLSD(); +} + +boost::signals2::connection LLSyntaxIdLSL::addSyntaxIDCallback(const syntax_id_changed_signal_t::slot_type& cb) { - return mFileFetchedSignal.connect(cb); + return mSyntaxIDChangedSignal.connect(cb); } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 2288fb4ab8..70f6b28337 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -2,7 +2,7 @@ * @file llsyntaxid.h * @brief Contains methods to access the LSLSyntaxId feature and LSLSyntax capability * to use the appropriate syntax file for the current region's LSL version. - * @author Ima Mechanique + * @author Ima Mechanique, Cinder Roxley * * $LicenseInfo:firstyear=2013&license=viewerlgpl$ * Second Life Viewer Source Code @@ -30,98 +30,43 @@ #include "llviewerprecompiledheaders.h" -#include "llagent.h" -#include "llenvmanager.h" -#include "llhttpclient.h" #include "llsingleton.h" -#include "llviewerregion.h" + +class fetchKeywordsFileResponder; class LLSyntaxIdLSL : public LLSingleton { -friend class fetchKeywordsFileResponder; - -public: - LLSyntaxIdLSL(); - - bool checkSyntaxIdChanged(); - bool fetching(); - std::string getFileNameCurrent() const { return mFileNameCurrent; } - ELLPath getFilePath() const { return mFilePath; } - std::string getFileSpec() const { return mFullFileSpec; } - LLSD getKeywordsXML() const { return mKeywordsXml; } - LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } - bool isDifferentVersion() const { return mVersionChanged; } - bool isInitialized() const { return mInitialized; } - - void initialize(); - bool isLoaded() { return mLoaded; } - - bool isSupportedVersion(const LLSD& content); - void setKeywordsXml(const LLSD& content) { mKeywordsXml = content; } - typedef boost::signals2::signal file_fetched_signal_t; - boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); - -protected: - void buildFullFileSpec(); - void fetchKeywordsFile(); - void loadDefaultKeywordsIntoLLSD(); - void loadKeywordsIntoLLSD(); - void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } - void setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; } - void setFileNameNew(const std::string name) { mFileNameNew = name; } + friend class LLSingleton; + friend class fetchKeywordsFileResponder; private: - static const std::string CAPABILITY_NAME; - static const std::string FILENAME_DEFAULT; - static const std::string SIMULATOR_FEATURE; - - bool mInitialized; - LLSD mKeywordsXml; - bool mLoaded; - bool mLoadFailed; - bool mVersionChanged; - file_fetched_signal_t mFileFetchedSignal; + std::list mInflightFetches; + typedef boost::signals2::signal syntax_id_changed_signal_t; + syntax_id_changed_signal_t mSyntaxIDChangedSignal; + boost::signals2::connection mRegionChangedCallback; + + bool syntaxIdChanged(); + bool isSupportedVersion(const LLSD& content); + void handleRegionChanged(); + void handleFileFetched(const std::string& filepath); + void setKeywordsXml(const LLSD& content) { mKeywordsXml = content; }; + void buildFullFileSpec(); + void fetchKeywordsFile(const std::string& filespec); + void loadDefaultKeywordsIntoLLSD(); + void loadKeywordsIntoLLSD(); - std::string mCapabilityName; std::string mCapabilityURL; - std::string mFileNameCurrent; - std::string mFileNameDefault; - std::string mFileNameNew; - ELLPath mFilePath; std::string mFullFileSpec; - std::string mSimulatorFeature; - LLUUID mSyntaxIdCurrent; - LLUUID mSyntaxIdNew; -}; - - -class fetchKeywordsFileResponder : public LLHTTPClient::Responder -{ + ELLPath mFilePath; + LLUUID mSyntaxId; + LLSD mKeywordsXml; + public: - std::string mFileSpec; - - /** - * @brief fetchKeywordsFileResponder - * @param filespec File path and name of where to save the returned data - */ - fetchKeywordsFileResponder(const std::string& filespec); - - void errorWithContent(U32 status, - const std::string& reason, - const LLSD& content); - - /** - * @brief Checks the returned LLSD for version and stores it in the LLSyntaxIdLSL object. - * @param content_ref The returned LLSD. - */ - void result(const LLSD& content_ref); - - /** - * @brief Saves the returned file to the location provided at instantiation. - * Could be extended to manage cached entries. - * @param content_ref The LSL syntax file for the sim. - */ - void cacheFile(const LLSD& content_ref); + LLSyntaxIdLSL(); + void initialize(); + bool keywordFetchInProgress(); + LLSD getKeywordsXML() const { return mKeywordsXml; }; + boost::signals2::connection addSyntaxIDCallback(const syntax_id_changed_signal_t::slot_type& cb); }; #endif // LLSYNTAXID_H -- cgit v1.3 From 78be5c3aa5f7263698bec5bcbccb24c150f78d09 Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 9 Jun 2014 16:19:20 -0600 Subject: STORM-2026 - Use more unique syntax colors by default, also clean up some indentation --- indra/newview/llsyntaxid.cpp | 28 ++++++++++++++-------------- indra/newview/skins/default/colors.xml | 20 ++++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 5b5bab85d0..236ad784ec 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -51,31 +51,31 @@ public: const std::string& reason, const LLSD& content) { - LL_WARNS("SyntaxLSL") << "failed to fetch syntax file [status:" << status << "]: " << content << LL_ENDL; + LL_WARNS("SyntaxLSL") << "failed to fetch syntax file [status:" << status << "]: " << content << LL_ENDL; } virtual void result(const LLSD& content_ref) { - // Continue only if a valid LLSD object was returned. - if (content_ref.isMap()) - { - if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref)) + // Continue only if a valid LLSD object was returned. + if (content_ref.isMap()) { - LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref); + if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref)) + { + LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref); - cacheFile(content_ref); - LLSyntaxIdLSL::getInstance()->handleFileFetched(mFileSpec); + cacheFile(content_ref); + LLSyntaxIdLSL::getInstance()->handleFileFetched(mFileSpec); + } + else + { + LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; + } } else { - LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD." << LL_ENDL; } } - else - { - LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD." << LL_ENDL; - } -} void cacheFile(const LLSD& content_ref) { diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index 464e633297..bdc884885f 100755 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -917,32 +917,32 @@ reference="Black" /> + value="0 0.5 0 1" /> + value="0 0.6 0.6 1" /> + value="0.4 0 0.8 1" /> + value="0 0 0.8 1" /> + value="0.8 0.4 0 1" /> + value="0.9 0.0 0.66, 1" /> + value="0 0.3 0.5 1" /> + value="0.3 0 0.5 1" /> + value="0.7 .2 .35 1" /> + value="1 0.14 0 1" /> -- cgit v1.3 From d949bee053610fe8769055589984e721ae1ee3d1 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 20 Jun 2014 10:17:31 -0600 Subject: BUG-6425 - Init default keywords file during ctor so we have something to fallback on should caps or fetch fail --- indra/newview/llsyntaxid.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 236ad784ec..9b82710161 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -111,6 +111,7 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() , mFilePath(LL_PATH_APP_SETTINGS) , mSyntaxId(LLUUID()) { + loadDefaultKeywordsIntoLLSD(); mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLSyntaxIdLSL::handleRegionChanged, this)); handleRegionChanged(); // Kick off an initial caps query and fetch } -- cgit v1.3 From 984353d7ca6184d7252c716150d42139aae94e5c Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 20 Jun 2014 11:02:50 -0600 Subject: STORM-2036 - Fix trying to parse caps too early by adding a callback to check region caps when they haven't already been received --- doc/contributions.txt | 1 + indra/newview/llsyntaxid.cpp | 19 +++++++++++++++---- indra/newview/llsyntaxid.h | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') diff --git a/doc/contributions.txt b/doc/contributions.txt index a3ca5d5f58..3ba4ee8973 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -321,6 +321,7 @@ Cinder Roxley STORM-1958 STORM-1952 STORM-1951 + STORM-2036 Clara Young Coaldust Numbers VWR-1095 diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 9b82710161..b1194dcd1b 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -128,7 +128,6 @@ void LLSyntaxIdLSL::buildFullFileSpec() //----------------------------------------------------------------------------- bool LLSyntaxIdLSL::syntaxIdChanged() { - bool version_changed = false; LLViewerRegion* region = gAgent.getRegion(); if (region) @@ -148,7 +147,7 @@ bool LLSyntaxIdLSL::syntaxIdChanged() { LL_DEBUGS("SyntaxLSL") << "New SyntaxID '" << new_syntax_id << "' found." << LL_ENDL; mSyntaxId = new_syntax_id; - version_changed = true; + return true; } else LL_DEBUGS("SyntaxLSL") << "SyntaxID matches what we have." << LL_ENDL; @@ -156,10 +155,11 @@ bool LLSyntaxIdLSL::syntaxIdChanged() } else { - LL_WARNS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities. Cannot process SyntaxId." << LL_ENDL; + region->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::handleCapsReceived, this, _1)); + LL_DEBUGS("SyntaxLSL") << "Region has not received capabilities. Waiting for caps..." << LL_ENDL; } } - return version_changed; + return false; } //----------------------------------------------------------------------------- @@ -307,6 +307,17 @@ void LLSyntaxIdLSL::handleRegionChanged() } } +void LLSyntaxIdLSL::handleCapsReceived(const LLUUID& region_uuid) +{ + LLViewerRegion* current_region = gAgent.getRegion(); + + if (region_uuid.notNull() + && current_region->getRegionID() == region_uuid) + { + syntaxIdChanged(); + } +} + void LLSyntaxIdLSL::handleFileFetched(const std::string& filepath) { mInflightFetches.remove(filepath); diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 70f6b28337..504fb0997e 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -48,6 +48,7 @@ private: bool syntaxIdChanged(); bool isSupportedVersion(const LLSD& content); void handleRegionChanged(); + void handleCapsReceived(const LLUUID& region_uuid); void handleFileFetched(const std::string& filepath); void setKeywordsXml(const LLSD& content) { mKeywordsXml = content; }; void buildFullFileSpec(); -- cgit v1.3