Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer into Cupcake

Conflicts:
	indra/newview/llappviewer.cpp
This commit is contained in:
Drake Arconis
2013-03-20 08:31:04 -04:00
14 changed files with 168 additions and 103 deletions

View File

@@ -315,11 +315,11 @@ LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_DEFAULT_RESPONSE)
{
setCheckBox(LLNotifications::instance().getGlobalString("skipnexttime"), ignore_label);
setCheckBox(LLNotificationTemplates::instance().getGlobalString("skipnexttime"), ignore_label);
}
else if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
{
setCheckBox(LLNotifications::instance().getGlobalString("alwayschoose"), ignore_label);
setCheckBox(LLNotificationTemplates::instance().getGlobalString("alwayschoose"), ignore_label);
}
}

View File

@@ -100,10 +100,10 @@ private:
for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
if (!LLNotifications::instance().templateExists((*it)->getName())) continue;
if (!LLNotificationTemplates::instance().templateExists((*it)->getName())) continue;
// only store notifications flagged as persisting
LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate((*it)->getName());
LLNotificationTemplatePtr templatep = LLNotificationTemplates::instance().getTemplate((*it)->getName());
if (!templatep->mPersist) continue;
data.append((*it)->asLLSD());
@@ -228,7 +228,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLXMLNodeP
LLXMLNodePtr child = xml_node->getFirstChild();
while(child)
{
child = LLNotifications::instance().checkForXMLTemplate(child);
child = LLNotificationTemplates::instance().checkForXMLTemplate(child);
LLSD item_entry;
std::string element_name = child->getName()->mString;
@@ -662,7 +662,7 @@ bool LLNotification::isEquivalentTo(LLNotificationPtr that) const
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
mTemplatep = LLNotifications::instance().getTemplate(template_name);
mTemplatep = LLNotificationTemplates::instance().getTemplate(template_name);
if (!mTemplatep) return;
const LLStringUtil::format_map_t& default_args = LLTrans::getDefaultArgs();
@@ -1098,12 +1098,19 @@ LLNotificationChannelPtr LLNotifications::getChannel(const std::string& channelN
return p->second;
}
// this function is called once at construction time, after the object is constructed.
void LLNotificationTemplates::initSingleton()
{
loadTemplates();
}
// this function is called once at construction time, after the object is constructed.
void LLNotifications::initSingleton()
{
loadTemplates();
createDefaultChannels();
loadNotifications();
// Cannot create default channels here, since that recursively accesses the singleton.
// Instead we call createDefaultChannels() from LLAppViewer::init().
//createDefaultChannels();
}
void LLNotifications::createDefaultChannels()
@@ -1142,7 +1149,7 @@ void LLNotifications::createDefaultChannels()
static std::string sStringSkipNextTime("Skip this dialog next time");
static std::string sStringAlwaysChoose("Always choose this option");
bool LLNotifications::addTemplate(const std::string &name,
bool LLNotificationTemplates::addTemplate(const std::string &name,
LLNotificationTemplatePtr theTemplate)
{
if (mTemplates.count(name))
@@ -1154,7 +1161,7 @@ bool LLNotifications::addTemplate(const std::string &name,
return true;
}
LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name)
LLNotificationTemplatePtr LLNotificationTemplates::getTemplate(const std::string& name)
{
if (mTemplates.count(name))
{
@@ -1166,12 +1173,12 @@ LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name)
}
}
bool LLNotifications::templateExists(const std::string& name)
bool LLNotificationTemplates::templateExists(const std::string& name)
{
return (mTemplates.count(name) != 0);
}
void LLNotifications::clearTemplates()
void LLNotificationTemplates::clearTemplates()
{
mTemplates.clear();
}
@@ -1192,7 +1199,7 @@ void LLNotifications::forceResponse(const LLNotification::Params& params, S32 op
temp_notify->respond(response);
}
LLNotifications::TemplateNames LLNotifications::getTemplateNames() const
LLNotificationTemplates::TemplateNames LLNotificationTemplates::getTemplateNames() const
{
TemplateNames names;
for (TemplateMap::const_iterator it = mTemplates.begin(); it != mTemplates.end(); ++it)
@@ -1242,7 +1249,7 @@ void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements)
// returns true if the template request was invalid and there's nothing else we
// can do with this node, false if you should keep processing (it may have
// replaced the contents of the node referred to)
LLXMLNodePtr LLNotifications::checkForXMLTemplate(LLXMLNodePtr item)
LLXMLNodePtr LLNotificationTemplates::checkForXMLTemplate(LLXMLNodePtr item)
{
if (item->hasName("usetemplate"))
{
@@ -1271,7 +1278,7 @@ LLXMLNodePtr LLNotifications::checkForXMLTemplate(LLXMLNodePtr item)
return item;
}
bool LLNotifications::loadTemplates()
bool LLNotificationTemplates::loadTemplates()
{
const std::string xml_filename = "notifications.xml";
LLXMLNodePtr root;
@@ -1289,11 +1296,6 @@ bool LLNotifications::loadTemplates()
for (LLXMLNodePtr item = root->getFirstChild();
item.notNull(); item = item->getNextSibling())
{
// we do this FIRST so that item can be changed if we
// encounter a usetemplate -- we just replace the
// current xml node and keep processing
item = checkForXMLTemplate(item);
if (item->hasName("global"))
{
std::string global_name;
@@ -1321,7 +1323,35 @@ bool LLNotifications::loadTemplates()
" found in " << xml_filename << llendl;
continue;
}
}
return true;
}
bool LLNotifications::loadNotifications()
{
const std::string xml_filename = "notifications.xml";
LLXMLNodePtr root;
BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
if (!success || root.isNull() || !root->hasName( "notifications" ))
{
llerrs << "Problem reading UI Notifications file: " << xml_filename << llendl;
return false;
}
for (LLXMLNodePtr item = root->getFirstChild();
item.notNull(); item = item->getNextSibling())
{
// we do this FIRST so that item can be changed if we
// encounter a usetemplate -- we just replace the
// current xml node and keep processing
item = LLNotificationTemplates::instance().checkForXMLTemplate(item);
if (!item->hasName("notification"))
continue;
// now we know we have a notification entry, so let's build it
LLNotificationTemplatePtr pTemplate(new LLNotificationTemplate());
@@ -1369,7 +1399,7 @@ bool LLNotifications::loadTemplates()
for (LLXMLNodePtr child = item->getFirstChild();
!child.isNull(); child = child->getNextSibling())
{
child = checkForXMLTemplate(child);
child = LLNotificationTemplates::instance().checkForXMLTemplate(child);
// <url>
if (child->hasName("url"))
@@ -1405,7 +1435,7 @@ bool LLNotifications::loadTemplates()
pTemplate->mForm = LLNotificationFormPtr(new LLNotificationForm(pTemplate->mName, child));
}
}
addTemplate(pTemplate->mName, pTemplate);
LLNotificationTemplates::instance().addTemplate(pTemplate->mName, pTemplate);
}
//std::ostringstream ostream;
@@ -1485,7 +1515,7 @@ void LLNotifications::update(const LLNotificationPtr pNotif)
}
LLNotificationPtr LLNotifications::find(LLUUID uuid)
LLNotificationPtr LLNotifications::find(LLUUID const& uuid)
{
LLNotificationPtr target = LLNotificationPtr(new LLNotification(uuid));
LLNotificationSet::iterator it=mItems.find(target);
@@ -1505,7 +1535,7 @@ void LLNotifications::forEachNotification(NotificationProcess process)
std::for_each(mItems.begin(), mItems.end(), process);
}
std::string LLNotifications::getGlobalString(const std::string& key) const
std::string LLNotificationTemplates::getGlobalString(const std::string& key) const
{
GlobalStringMap::const_iterator it = mGlobalStrings.find(key);
if (it != mGlobalStrings.end())

View File

@@ -679,45 +679,20 @@ private:
LLNotificationComparator mComparator;
};
class LLNotifications :
public LLSingleton<LLNotifications>,
public LLNotificationChannelBase
class LLNotificationTemplates :
public LLSingleton<LLNotificationTemplates>
{
LOG_CLASS(LLNotifications);
LOG_CLASS(LLNotificationTemplates);
friend class LLSingleton<LLNotificationTemplates>;
// This class may not use LLNotifications.
typedef char LLNotifications;
friend class LLSingleton<LLNotifications>;
public:
// load notification descriptions from file;
// OK to call more than once because it will reload
bool loadTemplates();
LLXMLNodePtr checkForXMLTemplate(LLXMLNodePtr item);
// we provide a collection of simple add notification functions so that it's reasonable to create notifications in one line
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions = LLSD(),
const LLSD& payload = LLSD());
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
const std::string& functor_name);
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
LLNotificationFunctorRegistry::ResponseFunctor functor);
LLNotificationPtr add(const LLNotification::Params& p);
void add(const LLNotificationPtr pNotif);
void cancel(LLNotificationPtr pNotif);
void update(const LLNotificationPtr pNotif);
LLNotificationPtr find(LLUUID uuid);
typedef boost::function<void (LLNotificationPtr)> NotificationProcess;
void forEachNotification(NotificationProcess process);
// This is all stuff for managing the templates
// take your template out
LLNotificationTemplatePtr getTemplate(const std::string& name);
@@ -736,17 +711,67 @@ public:
// useful if you're reloading the file
void clearTemplates(); // erase all templates
void forceResponse(const LLNotification::Params& params, S32 option);
// put your template in (should only be called from LLNotifications).
bool addTemplate(const std::string& name, LLNotificationTemplatePtr theTemplate);
std::string getGlobalString(const std::string& key) const;
private:
// we're a singleton, so we don't have a public constructor
LLNotificationTemplates() { }
/*virtual*/ void initSingleton();
TemplateMap mTemplates;
typedef std::map<std::string, LLXMLNodePtr> XMLTemplateMap;
XMLTemplateMap mXmlTemplates;
typedef std::map<std::string, std::string> GlobalStringMap;
GlobalStringMap mGlobalStrings;
};
class LLNotifications :
public LLSingleton<LLNotifications>,
public LLNotificationChannelBase
{
LOG_CLASS(LLNotifications);
friend class LLSingleton<LLNotifications>;
public:
// load notification descriptions from file;
// OK to call more than once because it will reload
bool loadNotifications();
void createDefaultChannels();
// we provide a collection of simple add notification functions so that it's reasonable to create notifications in one line
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions = LLSD(),
const LLSD& payload = LLSD());
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
const std::string& functor_name);
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
LLNotificationFunctorRegistry::ResponseFunctor functor);
LLNotificationPtr add(const LLNotification::Params& p);
void forceResponse(const LLNotification::Params& params, S32 option);
typedef std::map<std::string, LLNotificationChannelPtr> ChannelMap;
ChannelMap mChannels;
void addChannel(LLNotificationChannelPtr pChan);
LLNotificationChannelPtr getChannel(const std::string& channelName);
void add(const LLNotificationPtr pNotif);
void cancel(LLNotificationPtr pNotif);
void update(const LLNotificationPtr pNotif);
LLNotificationPtr find(LLUUID const& uuid);
std::string getGlobalString(const std::string& key) const;
typedef boost::function<void (LLNotificationPtr)> NotificationProcess;
void forEachNotification(NotificationProcess process);
private:
// we're a singleton, so we don't have a public constructor
@@ -760,22 +785,11 @@ private:
bool uniqueFilter(LLNotificationPtr pNotification);
bool uniqueHandler(const LLSD& payload);
bool failedUniquenessTest(const LLSD& payload);
LLNotificationChannelPtr pHistoryChannel;
LLNotificationChannelPtr pExpirationChannel;
// put your template in
bool addTemplate(const std::string& name, LLNotificationTemplatePtr theTemplate);
TemplateMap mTemplates;
std::string mFileName;
typedef std::map<std::string, LLXMLNodePtr> XMLTemplateMap;
XMLTemplateMap mXmlTemplates;
LLNotificationMap mUniqueNotifications;
typedef std::map<std::string, std::string> GlobalStringMap;
GlobalStringMap mGlobalStrings;
};