summaryrefslogtreecommitdiff
path: root/indra/newview/lldonotdisturbnotificationstorage.cpp
diff options
context:
space:
mode:
authorGilbert Gonzales <gilbert@lindenlab.com>2013-01-11 18:20:29 -0800
committerGilbert Gonzales <gilbert@lindenlab.com>2013-01-11 18:20:29 -0800
commit69497e645bbefe85d83e85bb353e5fb719263877 (patch)
tree8ea5f431bd5142d222dbc2ae3204f86d91ad6b95 /indra/newview/lldonotdisturbnotificationstorage.cpp
parent16082462a4d355509338ed28e396c8c81a20712a (diff)
CHUI-668: Not fully complete but as of this commit, have functionality to use the user's most intrusive chat notification upon exiting from DND mode with IM's. Also if in DND mode, clicking on a conversation line item or floater, will flush the DND notifications system of storing that conversation. This way upon existing DND mode already responded conversations won't be notified to the user.
Diffstat (limited to 'indra/newview/lldonotdisturbnotificationstorage.cpp')
-rw-r--r--indra/newview/lldonotdisturbnotificationstorage.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp
index ac41a3804f..764da25b08 100644
--- a/indra/newview/lldonotdisturbnotificationstorage.cpp
+++ b/indra/newview/lldonotdisturbnotificationstorage.cpp
@@ -41,6 +41,8 @@
#include "llsingleton.h"
#include "lluuid.h"
+extern void useMostItrusiveIMNotification();
+
LLDoNotDisturbNotificationStorage::LLDoNotDisturbNotificationStorage()
: LLSingleton<LLDoNotDisturbNotificationStorage>()
, LLNotificationStorage(gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "dnd_notifications.xml"))
@@ -103,15 +105,22 @@ void LLDoNotDisturbNotificationStorage::loadNotifications()
}
LLNotifications& instance = LLNotifications::instance();
+ bool imToastExists = false;
for (LLSD::array_const_iterator notification_it = data.beginArray();
notification_it != data.endArray();
++notification_it)
{
LLSD notification_params = *notification_it;
+ const std::string notificationName = notification_params["name"].asString();
const LLUUID& notificationID = notification_params["id"];
LLNotificationPtr notification = instance.find(notificationID);
+ if(notificationName == "IMToast")
+ {
+ imToastExists = true;
+ }
+
//Notification already exists in notification pipeline (same instance of app running)
if (notification)
{
@@ -138,6 +147,11 @@ void LLDoNotDisturbNotificationStorage::loadNotifications()
}
}
+ if(imToastExists)
+ {
+ useMostItrusiveIMNotification();
+ }
+
// Clear the communication channel history and rewrite the save file to empty it as well
LLNotificationChannelPtr channelPtr = getCommunicationChannel();
LLCommunicationChannel *commChannel = dynamic_cast<LLCommunicationChannel*>(channelPtr.get());
@@ -154,6 +168,45 @@ LLNotificationChannelPtr LLDoNotDisturbNotificationStorage::getCommunicationChan
return channelPtr;
}
+void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& session_id)
+{
+ LLNotifications& instance = LLNotifications::instance();
+ LLNotificationChannelPtr channelPtr = getCommunicationChannel();
+ LLCommunicationChannel *commChannel = dynamic_cast<LLCommunicationChannel*>(channelPtr.get());
+ LLNotificationPtr notification;
+ LLSD substitutions;
+ LLUUID notificationSessionID;
+ LLCommunicationChannel::history_list_t::const_iterator it;
+ std::vector<LLCommunicationChannel::history_list_t::const_iterator> itemsToRemove;
+
+ //Find notification with the matching session id
+ for (it = commChannel->beginHistory();
+ it != commChannel->endHistory();
+ ++it)
+ {
+ notification = it->second;
+ substitutions = notification->getSubstitutions();
+ notificationSessionID = substitutions["SESSION_ID"].asUUID();
+
+ if(session_id == notificationSessionID)
+ {
+ itemsToRemove.push_back(it);
+ }
+ }
+
+ //Remove the notification
+ while(itemsToRemove.size())
+ {
+ it = itemsToRemove.back();
+ notification = it->second;
+ commChannel->removeItem(it);
+ //instance.cancel triggers onChannelChanged to be called within LLNotificationChannelBase::updateItem (which save changes to the .xml file)
+ //but this means that saveNotifications write a file each time as well, BAD! Will find a way to prevent this.
+ instance.cancel(notification);
+ itemsToRemove.pop_back();
+ }
+}
+
bool LLDoNotDisturbNotificationStorage::onChannelChanged(const LLSD& pPayload)
{