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.2.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 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 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(); } } -- cgit v1.2.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/llsyntaxid.cpp | 113 ++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 51 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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)); } //----------------------------------------------------------------------------- -- cgit v1.2.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.2.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.2.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 ++++++++++++++++++++++++++----------------- 1 file changed, 117 insertions(+), 74 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 } -- cgit v1.2.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.2.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/newview/llsyntaxid.cpp | 47 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 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; } -- cgit v1.2.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/newview/llsyntaxid.cpp | 47 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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 } -- cgit v1.2.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 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 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; } -- cgit v1.2.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. --- indra/newview/llsyntaxid.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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.2.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.2.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 +++--- 1 file changed, 3 insertions(+), 3 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 ;-)" -- cgit v1.2.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 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 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; -- cgit v1.2.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.2.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.2.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.2.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 +++++++++++++++++++++++----------------- 1 file changed, 23 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(); } //----------------------------------------------------------------------------- -- cgit v1.2.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.2.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.2.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 +++++++------ 1 file changed, 7 insertions(+), 6 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(); } //----------------------------------------------------------------------------- -- cgit v1.2.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 ++++++++++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 70 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; } -- cgit v1.2.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 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 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") -- cgit v1.2.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.2.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 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 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; } -- cgit v1.2.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.2.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.2.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 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (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); +} -- cgit v1.2.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/newview/llsyntaxid.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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.2.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.2.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/newview/llsyntaxid.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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)) { -- cgit v1.2.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/newview/llsyntaxid.cpp | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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); -} -- cgit v1.2.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/llsyntaxid.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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 -- cgit v1.2.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 ++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 83 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); } -- cgit v1.2.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 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 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() -- cgit v1.2.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/newview/llsyntaxid.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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; } //----------------------------------------------------------------------------- -- cgit v1.2.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/llsyntaxid.cpp | 296 ++++++++++++++++++------------------------- 1 file changed, 123 insertions(+), 173 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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); } -- cgit v1.2.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 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 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) { -- cgit v1.2.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.2.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 --- indra/newview/llsyntaxid.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsyntaxid.cpp') 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); -- cgit v1.2.3