diff options
Diffstat (limited to 'indra/newview/lldonotdisturbnotificationstorage.cpp')
-rw-r--r-- | indra/newview/lldonotdisturbnotificationstorage.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp index ac41a3804f..12ff308a77 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.cpp +++ b/indra/newview/lldonotdisturbnotificationstorage.cpp @@ -33,6 +33,7 @@ #include "lldir.h" #include "llerror.h" #include "llfasttimer_class.h" +#include "llfloaterreg.h" #include "llnotifications.h" #include "llnotificationhandler.h" #include "llnotificationstorage.h" @@ -103,6 +104,7 @@ void LLDoNotDisturbNotificationStorage::loadNotifications() } LLNotifications& instance = LLNotifications::instance(); + bool imToastExists = false; for (LLSD::array_const_iterator notification_it = data.beginArray(); notification_it != data.endArray(); @@ -110,8 +112,14 @@ void LLDoNotDisturbNotificationStorage::loadNotifications() { LLSD notification_params = *notification_it; const LLUUID& notificationID = notification_params["id"]; + std::string notificationName = notification_params["name"]; 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 +146,11 @@ void LLDoNotDisturbNotificationStorage::loadNotifications() } } + if(imToastExists) + { + LLFloaterReg::showInstance("im_container"); + } + // 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 +167,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) { |