summaryrefslogtreecommitdiff
path: root/indra/llmessage/llmessageconfig.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llmessageconfig.cpp')
-rw-r--r--indra/llmessage/llmessageconfig.cpp250
1 files changed, 125 insertions, 125 deletions
diff --git a/indra/llmessage/llmessageconfig.cpp b/indra/llmessage/llmessageconfig.cpp
index 64e79d6767..e611688155 100644
--- a/indra/llmessage/llmessageconfig.cpp
+++ b/indra/llmessage/llmessageconfig.cpp
@@ -1,25 +1,25 @@
-/**
+/**
* @file llmessageconfig.cpp
* @brief Live file handling for messaging
*
* $LicenseInfo:firstyear=2000&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, 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$
*/
@@ -47,107 +47,107 @@ static LLSD sMessages;
class LLMessageConfigFile : public LLLiveFile
{
public:
- LLMessageConfigFile() :
- LLLiveFile(filename(), messageConfigRefreshRate),
- mMaxQueuedEvents(0)
+ LLMessageConfigFile() :
+ LLLiveFile(filename(), messageConfigRefreshRate),
+ mMaxQueuedEvents(0)
{ }
- static std::string filename();
+ static std::string filename();
+
+ LLSD mMessages;
+ std::string mServerDefault;
- LLSD mMessages;
- std::string mServerDefault;
-
- static LLMessageConfigFile& instance();
- // return the singleton configuration file
+ static LLMessageConfigFile& instance();
+ // return the singleton configuration file
- /* virtual */ bool loadFile();
- void loadServerDefaults(const LLSD& data);
- void loadMaxQueuedEvents(const LLSD& data);
- void loadMessages(const LLSD& data);
- void loadCapBans(const LLSD& blacklist);
- void loadMessageBans(const LLSD& blacklist);
- bool isCapBanned(const std::string& cap_name) const;
+ /* virtual */ bool loadFile();
+ void loadServerDefaults(const LLSD& data);
+ void loadMaxQueuedEvents(const LLSD& data);
+ void loadMessages(const LLSD& data);
+ void loadCapBans(const LLSD& blacklist);
+ void loadMessageBans(const LLSD& blacklist);
+ bool isCapBanned(const std::string& cap_name) const;
public:
- LLSD mCapBans;
- S32 mMaxQueuedEvents;
+ LLSD mCapBans;
+ S32 mMaxQueuedEvents;
private:
- static const S32 DEFAULT_MAX_QUEUED_EVENTS = 100;
+ static const S32 DEFAULT_MAX_QUEUED_EVENTS = 100;
};
std::string LLMessageConfigFile::filename()
{
std::ostringstream ostr;
- ostr << sConfigDir//gAppSimp->getOption("configdir").asString()
- << "/" << messageConfigFileName;
- return ostr.str();
+ ostr << sConfigDir//gAppSimp->getOption("configdir").asString()
+ << "/" << messageConfigFileName;
+ return ostr.str();
}
LLMessageConfigFile& LLMessageConfigFile::instance()
{
- static LLMessageConfigFile the_file;
- the_file.checkAndReload();
- return the_file;
+ static LLMessageConfigFile the_file;
+ the_file.checkAndReload();
+ return the_file;
}
// virtual
bool LLMessageConfigFile::loadFile()
{
- LLSD data;
+ LLSD data;
{
llifstream file(filename().c_str());
-
+
if (file.is_open())
{
- LL_DEBUGS("AppInit") << "Loading message.xml file at " << filename() << LL_ENDL;
+ LL_DEBUGS("AppInit") << "Loading message.xml file at " << filename() << LL_ENDL;
LLSDSerialize::fromXML(data, file);
}
if (data.isUndefined())
{
LL_INFOS("AppInit") << "LLMessageConfigFile::loadFile: file missing,"
- " ill-formed, or simply undefined; not changing the"
- " file" << LL_ENDL;
+ " ill-formed, or simply undefined; not changing the"
+ " file" << LL_ENDL;
return false;
}
}
- loadServerDefaults(data);
- loadMaxQueuedEvents(data);
- loadMessages(data);
- loadCapBans(data);
- loadMessageBans(data);
- return true;
+ loadServerDefaults(data);
+ loadMaxQueuedEvents(data);
+ loadMessages(data);
+ loadCapBans(data);
+ loadMessageBans(data);
+ return true;
}
void LLMessageConfigFile::loadServerDefaults(const LLSD& data)
{
- mServerDefault = data["serverDefaults"][sServerName].asString();
+ mServerDefault = data["serverDefaults"][sServerName].asString();
}
void LLMessageConfigFile::loadMaxQueuedEvents(const LLSD& data)
{
- if (data.has("maxQueuedEvents"))
- {
- mMaxQueuedEvents = data["maxQueuedEvents"].asInteger();
- }
- else
- {
- mMaxQueuedEvents = DEFAULT_MAX_QUEUED_EVENTS;
- }
+ if (data.has("maxQueuedEvents"))
+ {
+ mMaxQueuedEvents = data["maxQueuedEvents"].asInteger();
+ }
+ else
+ {
+ mMaxQueuedEvents = DEFAULT_MAX_QUEUED_EVENTS;
+ }
}
void LLMessageConfigFile::loadMessages(const LLSD& data)
{
- mMessages = data["messages"];
+ mMessages = data["messages"];
#ifdef DEBUG
- std::ostringstream out;
- LLSDXMLFormatter *formatter = new LLSDXMLFormatter;
- formatter->format(mMessages, out);
- LL_INFOS() << "loading ... " << out.str()
- << " LLMessageConfigFile::loadMessages loaded "
- << mMessages.size() << " messages" << LL_ENDL;
+ std::ostringstream out;
+ LLSDXMLFormatter *formatter = new LLSDXMLFormatter;
+ formatter->format(mMessages, out);
+ LL_INFOS() << "loading ... " << out.str()
+ << " LLMessageConfigFile::loadMessages loaded "
+ << mMessages.size() << " messages" << LL_ENDL;
#endif
}
@@ -160,9 +160,9 @@ void LLMessageConfigFile::loadCapBans(const LLSD& data)
<< LL_ENDL;
return;
}
-
- mCapBans = bans;
-
+
+ mCapBans = bans;
+
LL_DEBUGS("AppInit") << "LLMessageConfigFile::loadCapBans: "
<< bans.size() << " ban tests" << LL_ENDL;
}
@@ -176,13 +176,13 @@ void LLMessageConfigFile::loadMessageBans(const LLSD& data)
<< LL_ENDL;
return;
}
-
- gMessageSystem->setMessageBans(bans["trusted"], bans["untrusted"]);
+
+ gMessageSystem->setMessageBans(bans["trusted"], bans["untrusted"]);
}
bool LLMessageConfigFile::isCapBanned(const std::string& cap_name) const
{
- LL_DEBUGS() << "mCapBans is " << LLSDNotationStreamer(mCapBans) << LL_ENDL;
+ LL_DEBUGS() << "mCapBans is " << LLSDNotationStreamer(mCapBans) << LL_ENDL;
return mCapBans[cap_name];
}
@@ -192,99 +192,99 @@ bool LLMessageConfigFile::isCapBanned(const std::string& cap_name) const
//static
void LLMessageConfig::initClass(const std::string& server_name,
- const std::string& config_dir)
+ const std::string& config_dir)
{
- sServerName = server_name;
- sConfigDir = config_dir;
- (void) LLMessageConfigFile::instance();
- LL_DEBUGS("AppInit") << "LLMessageConfig::initClass config file "
- << config_dir << "/" << messageConfigFileName << LL_ENDL;
+ sServerName = server_name;
+ sConfigDir = config_dir;
+ (void) LLMessageConfigFile::instance();
+ LL_DEBUGS("AppInit") << "LLMessageConfig::initClass config file "
+ << config_dir << "/" << messageConfigFileName << LL_ENDL;
}
//static
void LLMessageConfig::useConfig(const LLSD& config)
{
- LLMessageConfigFile &the_file = LLMessageConfigFile::instance();
- the_file.loadServerDefaults(config);
- the_file.loadMaxQueuedEvents(config);
- the_file.loadMessages(config);
- the_file.loadCapBans(config);
- the_file.loadMessageBans(config);
+ LLMessageConfigFile &the_file = LLMessageConfigFile::instance();
+ the_file.loadServerDefaults(config);
+ the_file.loadMaxQueuedEvents(config);
+ the_file.loadMessages(config);
+ the_file.loadCapBans(config);
+ the_file.loadMessageBans(config);
}
//static
LLMessageConfig::Flavor LLMessageConfig::getServerDefaultFlavor()
{
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- if (file.mServerDefault == "llsd")
- {
- return LLSD_FLAVOR;
- }
- if (file.mServerDefault == "template")
- {
- return TEMPLATE_FLAVOR;
- }
- return NO_FLAVOR;
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ if (file.mServerDefault == "llsd")
+ {
+ return LLSD_FLAVOR;
+ }
+ if (file.mServerDefault == "template")
+ {
+ return TEMPLATE_FLAVOR;
+ }
+ return NO_FLAVOR;
}
//static
S32 LLMessageConfig::getMaxQueuedEvents()
{
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- return file.mMaxQueuedEvents;
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ return file.mMaxQueuedEvents;
}
//static
LLMessageConfig::Flavor LLMessageConfig::getMessageFlavor(const std::string& msg_name)
{
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- LLSD config = file.mMessages[msg_name];
- if (config["flavor"].asString() == "llsd")
- {
- return LLSD_FLAVOR;
- }
- if (config["flavor"].asString() == "template")
- {
- return TEMPLATE_FLAVOR;
- }
- return NO_FLAVOR;
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ LLSD config = file.mMessages[msg_name];
+ if (config["flavor"].asString() == "llsd")
+ {
+ return LLSD_FLAVOR;
+ }
+ if (config["flavor"].asString() == "template")
+ {
+ return TEMPLATE_FLAVOR;
+ }
+ return NO_FLAVOR;
}
//static
LLMessageConfig::SenderTrust LLMessageConfig::getSenderTrustedness(
- const std::string& msg_name)
+ const std::string& msg_name)
{
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- LLSD config = file.mMessages[msg_name];
- if (config.has("trusted-sender"))
- {
- return config["trusted-sender"].asBoolean() ? TRUSTED : UNTRUSTED;
- }
- return NOT_SET;
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ LLSD config = file.mMessages[msg_name];
+ if (config.has("trusted-sender"))
+ {
+ return config["trusted-sender"].asBoolean() ? TRUSTED : UNTRUSTED;
+ }
+ return NOT_SET;
}
//static
bool LLMessageConfig::isValidMessage(const std::string& msg_name)
{
- if (sServerName.empty())
- {
- LL_ERRS() << "LLMessageConfig::initClass() not called" << LL_ENDL;
- }
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- return file.mMessages.has(msg_name);
+ if (sServerName.empty())
+ {
+ LL_ERRS() << "LLMessageConfig::initClass() not called" << LL_ENDL;
+ }
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ return file.mMessages.has(msg_name);
}
//static
bool LLMessageConfig::onlySendLatest(const std::string& msg_name)
{
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- LLSD config = file.mMessages[msg_name];
- return config["only-send-latest"].asBoolean();
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ LLSD config = file.mMessages[msg_name];
+ return config["only-send-latest"].asBoolean();
}
bool LLMessageConfig::isCapBanned(const std::string& cap_name)
{
- return LLMessageConfigFile::instance().isCapBanned(cap_name);
+ return LLMessageConfigFile::instance().isCapBanned(cap_name);
}
// return the web-service path to use for a given
@@ -292,13 +292,13 @@ bool LLMessageConfig::isCapBanned(const std::string& cap_name)
// in simulator.xml!
LLSD LLMessageConfig::getConfigForMessage(const std::string& msg_name)
{
- if (sServerName.empty())
- {
- LL_ERRS() << "LLMessageConfig::isMessageTrusted(name) before"
- << " LLMessageConfig::initClass()" << LL_ENDL;
- }
- LLMessageConfigFile& file = LLMessageConfigFile::instance();
- // LLSD for the CamelCase message name
- LLSD config = file.mMessages[msg_name];
- return config;
+ if (sServerName.empty())
+ {
+ LL_ERRS() << "LLMessageConfig::isMessageTrusted(name) before"
+ << " LLMessageConfig::initClass()" << LL_ENDL;
+ }
+ LLMessageConfigFile& file = LLMessageConfigFile::instance();
+ // LLSD for the CamelCase message name
+ LLSD config = file.mMessages[msg_name];
+ return config;
}