Skip to content
Snippets Groups Projects
Commit 82cd99d6 authored by Cinder's avatar Cinder
Browse files

Style - rename previously static members, fix scope, ease up on the...

Style - rename previously static members, fix scope, ease up on the exclamation points in debug messages
parent 70aff215
No related branches found
No related tags found
No related merge requests found
...@@ -40,20 +40,15 @@ ...@@ -40,20 +40,15 @@
fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec) fetchKeywordsFileResponder::fetchKeywordsFileResponder(std::string filespec)
{ {
mFileSpec = filespec; mFileSpec = filespec;
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Instantiating with file saving to: '" << filespec << "'" << LL_ENDL;
<< "Instantiating with file saving to: '" << filespec << "'"
<< LL_ENDL;
} }
void fetchKeywordsFileResponder::errorWithContent(U32 status, void fetchKeywordsFileResponder::errorWithContent(U32 status,
const std::string& reason, const std::string& reason,
const LLSD& content) const LLSD& content)
{ {
LLSyntaxIdLSL::getInstance()->sLoadFailed = true; LLSyntaxIdLSL::getInstance()->mLoadFailed = true;
LL_WARNS("SyntaxLSL") LL_WARNS("SyntaxLSL") << "fetchKeywordsFileResponder error [status:" << status << "]: " << content << LL_ENDL;
<< "fetchKeywordsFileResponder error [status:"
<< status << "]: " << content
<< LL_ENDL;
} }
void fetchKeywordsFileResponder::result(const LLSD& content_ref) void fetchKeywordsFileResponder::result(const LLSD& content_ref)
...@@ -61,38 +56,34 @@ 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. // Continue only if a valid LLSD object was returned.
if (content_ref.isMap()) if (content_ref.isMap())
{ {
LL_DEBUGS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "content_ref isMap so assuming valid XML." << LL_ENDL;
<< "content_ref isMap so assuming valid XML." << LL_ENDL;
if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref)) if (LLSyntaxIdLSL::getInstance()->isSupportedVersion(content_ref))
{ {
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Supported verson of syntax file." << LL_ENDL;
<< "Supported verson of syntax file." << LL_ENDL;
LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref); LLSyntaxIdLSL::getInstance()->setKeywordsXml(content_ref);
LLSyntaxIdLSL::getInstance()->sInitialized = true; LLSyntaxIdLSL::getInstance()->mInitialized = true;
LLSyntaxIdLSL::getInstance()->sLoaded = true; LLSyntaxIdLSL::getInstance()->mLoaded = true;
LLSyntaxIdLSL::getInstance()->sLoadFailed = false; LLSyntaxIdLSL::getInstance()->mLoadFailed = false;
cacheFile(content_ref); cacheFile(content_ref);
} }
else else
{ {
LLSyntaxIdLSL::getInstance()->sLoaded = false; LLSyntaxIdLSL::getInstance()->mLoaded = false;
LLSyntaxIdLSL::getInstance()->sLoadFailed = true; LLSyntaxIdLSL::getInstance()->mLoadFailed = true;
LL_WARNS("SyntaxLSL") LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL;
<< "Unknown or unsupported version of syntax file." << LL_ENDL;
} }
} }
else else
{ {
LLSyntaxIdLSL::getInstance()->sLoaded = false; LLSyntaxIdLSL::getInstance()->mLoaded = false;
LLSyntaxIdLSL::getInstance()->sLoadFailed = true; LLSyntaxIdLSL::getInstance()->mLoadFailed = true;
LL_WARNS("SyntaxLSL") LL_WARNS("SyntaxLSL") << "Syntax file '" << mFileSpec << "' contains invalid LLSD." << LL_ENDL;
<< "Syntax file '" << mFileSpec << "' contains invalid LLSD!" << LL_ENDL;
} }
LLSyntaxIdLSL::getInstance()->sFileFetchedSignal(); LLSyntaxIdLSL::getInstance()->mFileFetchedSignal();
} }
void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref) void fetchKeywordsFileResponder::cacheFile(const LLSD& content_ref)
...@@ -106,8 +97,7 @@ 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.write(xml.c_str(), str.str().size());
file.close(); file.close();
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL;
<< "Syntax file received, saving as: '" << mFileSpec << "'" << LL_ENDL;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -159,18 +149,15 @@ std::string LLSyntaxIdLSL::buildFullFileSpec() ...@@ -159,18 +149,15 @@ std::string LLSyntaxIdLSL::buildFullFileSpec()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool LLSyntaxIdLSL::checkSyntaxIdChanged() bool LLSyntaxIdLSL::checkSyntaxIdChanged()
{ {
sVersionChanged = false; mVersionChanged = false;
LLViewerRegion* region = gAgent.getRegion(); LLViewerRegion* region = gAgent.getRegion();
if (region) if (region)
{ {
if (!region->capabilitiesReceived()) if (!region->capabilitiesReceived())
{ // Shouldn't be possible, but experience shows that it may be needed. { // Shouldn't be possible, but experience shows that it may be needed.
sLoadFailed = true; mLoadFailed = true;
LL_WARNS("SyntaxLSL") LL_INFOS("SyntaxLSL") << "Region '" << region->getName() << "' has not received capabilities yet. Cannot process SyntaxId." << LL_ENDL;
<< "Region '" << region->getName()
<< "' has not received capabilities yet! Cannot process SyntaxId."
<< LL_ENDL;
} }
else else
{ {
...@@ -185,40 +172,32 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() ...@@ -185,40 +172,32 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged()
mCapabilityURL = region->getCapability(mCapabilityName); mCapabilityURL = region->getCapability(mCapabilityName);
if (mSyntaxIdCurrent != mSyntaxIdNew) if (mSyntaxIdCurrent != mSyntaxIdNew)
{ {
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Region has LSLSyntaxId capability, and the new hash is '" << mSyntaxIdNew.asString() << "'" << LL_ENDL;
<< "It has LSLSyntaxId capability, and the new hash is '"
<< mSyntaxIdNew.asString() << "'" << LL_ENDL;
sVersionChanged = true; mVersionChanged = true;
} }
else else
{ {
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Region has the same LSLSyntaxId! Leaving hash as '" << mSyntaxIdCurrent.asString() << "'" << LL_ENDL;
<< "It has the same LSLSyntaxId! Leaving hash as '"
<< mSyntaxIdCurrent.asString() << "'" << LL_ENDL;
} }
} }
else else
{ {
if ( mSyntaxIdCurrent.isNull() && isInitialized()) if ( mSyntaxIdCurrent.isNull() && isInitialized())
{ {
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Region does not have LSLSyntaxId capability, remaining with default keywords." << LL_ENDL;
<< "It does not have LSLSyntaxId capability, remaining with default keywords file!"
<< LL_ENDL;
} }
else else
{ {
// The hash is set to NULL_KEY to indicate use of default keywords file // The hash is set to NULL_KEY to indicate use of default keywords file
mSyntaxIdNew = LLUUID(); mSyntaxIdNew = LLUUID();
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "Region does not have LSLSyntaxId capability, using default keywords." << LL_ENDL;
<< "It does not have LSLSyntaxId capability, using default keywords file!" mVersionChanged = true;
<< LL_ENDL;
sVersionChanged = true;
} }
} }
} }
} }
return sVersionChanged; return mVersionChanged;
} }
/** /**
...@@ -228,7 +207,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() ...@@ -228,7 +207,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged()
*/ */
bool LLSyntaxIdLSL::fetching() bool LLSyntaxIdLSL::fetching()
{ {
return !(sLoaded || sLoadFailed); return !(mLoaded || mLoadFailed);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -240,10 +219,7 @@ void LLSyntaxIdLSL::fetchKeywordsFile() ...@@ -240,10 +219,7 @@ void LLSyntaxIdLSL::fetchKeywordsFile()
new fetchKeywordsFileResponder(mFullFileSpec), new fetchKeywordsFileResponder(mFullFileSpec),
LLSD(), 30.f LLSD(), 30.f
); );
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "LSLSyntaxId capability URL is: " << mCapabilityURL << ". Filename to use is: '" << mFullFileSpec << "'." << LL_ENDL;
<< "LSLSyntaxId capability URL is: " << mCapabilityURL
<< ". Filename to use is: '" << mFullFileSpec << "'."
<< LL_ENDL;
} }
...@@ -257,8 +233,8 @@ void LLSyntaxIdLSL::initialize() ...@@ -257,8 +233,8 @@ void LLSyntaxIdLSL::initialize()
if (checkSyntaxIdChanged()) if (checkSyntaxIdChanged())
{ {
sKeywordsXml = LLSD(); mKeywordsXml = LLSD();
sLoaded = sLoadFailed = false; mLoaded = mLoadFailed = false;
if (mSyntaxIdNew.isNull()) if (mSyntaxIdNew.isNull())
{ // Need to open the default { // Need to open the default
...@@ -266,9 +242,7 @@ void LLSyntaxIdLSL::initialize() ...@@ -266,9 +242,7 @@ void LLSyntaxIdLSL::initialize()
} }
else if (!mCapabilityURL.empty() ) else if (!mCapabilityURL.empty() )
{ {
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "LSL version has changed, getting appropriate file." << LL_ENDL;
<< "LSL version has changed, getting appropriate file."
<< LL_ENDL;
// Need a full spec regardless of file source, so build it now. // Need a full spec regardless of file source, so build it now.
buildFullFileSpec(); buildFullFileSpec();
...@@ -276,16 +250,11 @@ void LLSyntaxIdLSL::initialize() ...@@ -276,16 +250,11 @@ void LLSyntaxIdLSL::initialize()
{ {
if ( !gDirUtilp->fileExists(mFullFileSpec) ) if ( !gDirUtilp->fileExists(mFullFileSpec) )
{ // Does not exist, so fetch it from the capability { // Does not exist, so fetch it from the capability
LL_INFOS("SyntaxLSL") LL_INFOS("SyntaxLSL") << "LSL syntax not cached, attempting download." << LL_ENDL;
<< "File is not cached, we will try to download it!"
<< LL_ENDL;
fetchKeywordsFile(); fetchKeywordsFile();
} }
else else
{ {
LL_INFOS("SyntaxLSL")
<< "File is cached, no need to download!"
<< LL_ENDL;
loadKeywordsIntoLLSD(); loadKeywordsIntoLLSD();
} }
} }
...@@ -296,9 +265,8 @@ void LLSyntaxIdLSL::initialize() ...@@ -296,9 +265,8 @@ void LLSyntaxIdLSL::initialize()
} }
else else
{ {
sLoadFailed = true; mLoadFailed = true;
LL_WARNS("SyntaxLSL") LL_WARNS("SyntaxLSL") << "LSLSyntaxId capability URL is empty." << LL_ENDL;
<< "LSLSyntaxId capability URL is empty!!" << LL_ENDL;
loadDefaultKeywordsIntoLLSD(); loadDefaultKeywordsIntoLLSD();
} }
} }
...@@ -327,8 +295,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) ...@@ -327,8 +295,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content)
if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY)) if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY))
{ {
LL_INFOS("SyntaxLSL") LL_DEBUGS("SyntaxLSL") << "LSL syntax version: " << content[LLSD_SYNTAX_LSL_VERSION_KEY].asString() << LL_ENDL;
<< "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) if (content[LLSD_SYNTAX_LSL_VERSION_KEY].asInteger() == LLSD_SYNTAX_LSL_VERSION_EXPECTED)
{ {
...@@ -337,7 +304,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) ...@@ -337,7 +304,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content)
} }
else else
{ {
LL_WARNS("SyntaxLSL") << "No version key available!" << LL_ENDL; LL_DEBUGS("SyntaxLSL") << "No LSL syntax version key." << LL_ENDL;
} }
return isValid; return isValid;
...@@ -348,7 +315,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) ...@@ -348,7 +315,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() 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(); mSyntaxIdNew = LLUUID();
buildFullFileSpec(); buildFullFileSpec();
loadKeywordsIntoLLSD(); loadKeywordsIntoLLSD();
...@@ -365,46 +332,46 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() ...@@ -365,46 +332,46 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD()
*/ */
void LLSyntaxIdLSL::loadKeywordsIntoLLSD() 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 // Is this the right thing to do, or should we leave the old content
// even if it isn't entirely accurate anymore? // even if it isn't entirely accurate anymore?
sKeywordsXml = LLSD().emptyMap(); mKeywordsXml = LLSD().emptyMap();
LLSD content; LLSD content;
llifstream file; llifstream file;
file.open(mFullFileSpec); file.open(mFullFileSpec);
if (file.is_open()) if (file.is_open())
{ {
sLoaded = (bool)LLSDSerialize::fromXML(content, file); mLoaded = (bool)LLSDSerialize::fromXML(content, file);
if (!sLoaded) if (!mLoaded)
{ {
LL_WARNS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; LL_WARNS("SyntaxLSL") << "Unable to deserialise: " << mFullFileSpec << LL_ENDL;
} }
else else
{ {
if (isSupportedVersion(content)) if (isSupportedVersion(content))
{ {
sKeywordsXml = content; mKeywordsXml = content;
sLoaded = true; mLoaded = true;
sInitialized = true; mInitialized = true;
LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; LL_DEBUGS("SyntaxLSL") << "Deserialised: " << mFullFileSpec << LL_ENDL;
} }
else else
{ {
sLoaded = false; mLoaded = 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;
} }
} }
} }
else 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) boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb)
{ {
return sFileFetchedSignal.connect(cb); return mFileFetchedSignal.connect(cb);
} }
...@@ -39,30 +39,6 @@ ...@@ -39,30 +39,6 @@
class LLSyntaxIdLSL : public LLSingleton<LLSyntaxIdLSL> class LLSyntaxIdLSL : public LLSingleton<LLSyntaxIdLSL>
{ {
friend class fetchKeywordsFileResponder; friend class fetchKeywordsFileResponder;
public:
typedef boost::signals2::signal<void()> file_fetched_signal_t;
protected:
bool sInitialized;
LLSD sKeywordsXml;
bool sLoaded;
bool sLoadFailed;
bool sVersionChanged;
file_fetched_signal_t sFileFetchedSignal;
private:
std::string mCapabilityName;
std::string mCapabilityURL;
std::string mFileNameCurrent;
std::string mFileNameDefault;
std::string mFileNameNew;
ELLPath mFilePath;
std::string mFullFileSpec;
std::string mSimulatorFeature;
LLUUID mSyntaxIdCurrent;
LLUUID mSyntaxIdNew;
public: public:
LLSyntaxIdLSL(); LLSyntaxIdLSL();
...@@ -73,20 +49,19 @@ friend class fetchKeywordsFileResponder; ...@@ -73,20 +49,19 @@ friend class fetchKeywordsFileResponder;
std::string getFileNameCurrent() const { return mFileNameCurrent; } std::string getFileNameCurrent() const { return mFileNameCurrent; }
ELLPath getFilePath() const { return mFilePath; } ELLPath getFilePath() const { return mFilePath; }
std::string getFileSpec() const { return mFullFileSpec; } std::string getFileSpec() const { return mFullFileSpec; }
LLSD getKeywordsXML() const { return sKeywordsXml; } LLSD getKeywordsXML() const { return mKeywordsXml; }
LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; }
bool isDifferentVersion() const { return sVersionChanged; } bool isDifferentVersion() const { return mVersionChanged; }
bool isInitialized() const { return sInitialized; } bool isInitialized() const { return mInitialized; }
void initialize(); void initialize();
bool isLoaded() { return sLoaded; } bool isLoaded() { return mLoaded; }
bool isSupportedVersion(const LLSD& content);
void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; }
bool isSupportedVersion(const LLSD& content);
void setKeywordsXml(const LLSD& content) { mKeywordsXml = content; }
typedef boost::signals2::signal<void()> file_fetched_signal_t;
boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb);
protected: protected:
std::string buildFileNameNew(); std::string buildFileNameNew();
std::string buildFullFileSpec(); std::string buildFullFileSpec();
...@@ -97,6 +72,25 @@ friend class fetchKeywordsFileResponder; ...@@ -97,6 +72,25 @@ friend class fetchKeywordsFileResponder;
void setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; } void setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; }
void setFileNameDefault(const std::string& name) { mFileNameDefault = name; } void setFileNameDefault(const std::string& name) { mFileNameDefault = name; }
void setFileNameNew(const std::string name) { mFileNameNew = name; } void setFileNameNew(const std::string name) { mFileNameNew = name; }
private:
bool mInitialized;
LLSD mKeywordsXml;
bool mLoaded;
bool mLoadFailed;
bool mVersionChanged;
file_fetched_signal_t mFileFetchedSignal;
std::string mCapabilityName;
std::string mCapabilityURL;
std::string mFileNameCurrent;
std::string mFileNameDefault;
std::string mFileNameNew;
ELLPath mFilePath;
std::string mFullFileSpec;
std::string mSimulatorFeature;
LLUUID mSyntaxIdCurrent;
LLUUID mSyntaxIdNew;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment