diff options
author | Oz Linden <oz@lindenlab.com> | 2011-04-05 07:23:43 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-04-05 07:23:43 -0400 |
commit | b5c834c6fdcee7d7238bebfc561ecee3ecca3589 (patch) | |
tree | 327ccb1a74e828db62e8d19768ff953192d86f72 /indra/llui/llnotifications.cpp | |
parent | fa4359e571fb67aca651efc3403274cdf0bb2616 (diff) | |
parent | 2787be7d3558c3ca1ed15863e875612b1b27ec78 (diff) |
merge changes for STORM-1051
Diffstat (limited to 'indra/llui/llnotifications.cpp')
-rw-r--r-- | indra/llui/llnotifications.cpp | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index cc9edfcdea..bdac125eb0 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1195,16 +1195,18 @@ bool LLNotifications::uniqueFilter(LLNotificationPtr pNotif) bool LLNotifications::uniqueHandler(const LLSD& payload) { + std::string cmd = payload["sigtype"]; + LLNotificationPtr pNotif = LLNotifications::instance().find(payload["id"].asUUID()); if (pNotif && pNotif->hasUniquenessConstraints()) { - if (payload["sigtype"].asString() == "add") + if (cmd == "add") { // not a duplicate according to uniqueness criteria, so we keep it // and store it for future uniqueness checks mUniqueNotifications.insert(std::make_pair(pNotif->getName(), pNotif)); } - else if (payload["sigtype"].asString() == "delete") + else if (cmd == "delete") { mUniqueNotifications.erase(pNotif->getName()); } @@ -1217,12 +1219,16 @@ bool LLNotifications::failedUniquenessTest(const LLSD& payload) { LLNotificationPtr pNotif = LLNotifications::instance().find(payload["id"].asUUID()); - if (!pNotif || !pNotif->hasUniquenessConstraints()) + std::string cmd = payload["sigtype"]; + + if (!pNotif || cmd != "add") { return false; } - // checks against existing unique notifications + // Update the existing unique notification with the data from this particular instance... + // This guarantees that duplicate notifications will be collapsed to the one + // most recently triggered for (LLNotificationMap::iterator existing_it = mUniqueNotifications.find(pNotif->getName()); existing_it != mUniqueNotifications.end(); ++existing_it) @@ -1235,7 +1241,7 @@ bool LLNotifications::failedUniquenessTest(const LLSD& payload) // of this unique notification and update it existing_notification->updateFrom(pNotif); // then delete the new one - pNotif->cancel(); + cancel(pNotif); } } @@ -1300,26 +1306,14 @@ void LLNotifications::createDefaultChannels() // usage LLStopWhenHandled combiner in LLStandardSignal LLNotifications::instance().getChannel("Unique")-> connectAtFrontChanged(boost::bind(&LLNotifications::uniqueHandler, this, _1)); -// failedUniquenessTest slot isn't necessary -// LLNotifications::instance().getChannel("Unique")-> -// connectFailedFilter(boost::bind(&LLNotifications::failedUniquenessTest, this, _1)); + LLNotifications::instance().getChannel("Unique")-> + connectFailedFilter(boost::bind(&LLNotifications::failedUniquenessTest, this, _1)); LLNotifications::instance().getChannel("Ignore")-> connectFailedFilter(&handleIgnoredNotification); LLNotifications::instance().getChannel("VisibilityRules")-> connectFailedFilter(&visibilityRuleMached); } -bool LLNotifications::addTemplate(const std::string &name, - LLNotificationTemplatePtr theTemplate) -{ - if (mTemplates.count(name)) - { - llwarns << "LLNotifications -- attempted to add template '" << name << "' twice." << llendl; - return false; - } - mTemplates[name] = theTemplate; - return true; -} LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) { @@ -1416,27 +1410,45 @@ void replaceFormText(LLNotificationForm::Params& form, const std::string& patter } } +void addPathIfExists(const std::string& new_path, std::vector<std::string>& paths) +{ + if (gDirUtilp->fileExists(new_path)) + { + paths.push_back(new_path); + } +} + bool LLNotifications::loadTemplates() { - const std::string xml_filename = "notifications.xml"; - std::string full_filename = gDirUtilp->findSkinnedFilename(LLUI::getXUIPaths().front(), xml_filename); + std::vector<std::string> search_paths; + + std::string skin_relative_path = gDirUtilp->getDirDelimiter() + LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + "notifications.xml"; + std::string localized_skin_relative_path = gDirUtilp->getDirDelimiter() + LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + "notifications.xml"; + + addPathIfExists(gDirUtilp->getDefaultSkinDir() + skin_relative_path, search_paths); + addPathIfExists(gDirUtilp->getDefaultSkinDir() + localized_skin_relative_path, search_paths); + addPathIfExists(gDirUtilp->getSkinDir() + skin_relative_path, search_paths); + addPathIfExists(gDirUtilp->getSkinDir() + localized_skin_relative_path, search_paths); + addPathIfExists(gDirUtilp->getUserSkinDir() + skin_relative_path, search_paths); + addPathIfExists(gDirUtilp->getUserSkinDir() + localized_skin_relative_path, search_paths); + std::string base_filename = search_paths.front(); LLXMLNodePtr root; - BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); + BOOL success = LLXMLNode::getLayeredXMLNode(root, search_paths); if (!success || root.isNull() || !root->hasName( "notifications" )) { - llerrs << "Problem reading UI Notifications file: " << full_filename << llendl; + llerrs << "Problem reading UI Notifications file: " << base_filename << llendl; return false; } LLNotificationTemplate::Notifications params; LLXUIParser parser; - parser.readXUI(root, params, full_filename); + parser.readXUI(root, params, base_filename); if(!params.validateBlock()) { - llerrs << "Problem reading UI Notifications file: " << full_filename << llendl; + llerrs << "Problem reading UI Notifications file: " << base_filename << llendl; return false; } @@ -1483,7 +1495,7 @@ bool LLNotifications::loadTemplates() replaceFormText(it->form_ref.form, "$ignoretext", it->form_ref.form_template.ignore_text); } } - addTemplate(it->name, LLNotificationTemplatePtr(new LLNotificationTemplate(*it))); + mTemplates[it->name] = LLNotificationTemplatePtr(new LLNotificationTemplate(*it)); } return true; @@ -1578,7 +1590,7 @@ void LLNotifications::add(const LLNotificationPtr pNotif) void LLNotifications::cancel(LLNotificationPtr pNotif) { - if (pNotif == NULL) return; + if (pNotif == NULL || pNotif->isCancelled()) return; LLNotificationSet::iterator it=mItems.find(pNotif); if (it == mItems.end()) @@ -1680,7 +1692,6 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) for(it = mVisibilityRules.begin(); it != mVisibilityRules.end(); it++) { // An empty type/tag/name string will match any notification, so only do the comparison when the string is non-empty in the rule. - lldebugs << "notification \"" << n->getName() << "\" " << "testing against " << ((*it)->mVisible?"show":"hide") << " rule, " @@ -1728,7 +1739,7 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) // Response property is empty. Cancel this notification. lldebugs << "cancelling notification " << n->getName() << llendl; - n->cancel(); + cancel(n); } else { |