diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llcommunicationchannel.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llcommunicationchannel.h | 1 | ||||
-rw-r--r-- | indra/newview/lldonotdisturbnotificationstorage.cpp | 54 | ||||
-rw-r--r-- | indra/newview/lldonotdisturbnotificationstorage.h | 1 | ||||
-rw-r--r-- | indra/newview/llfloaterimcontainer.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llimview.cpp | 42 |
6 files changed, 97 insertions, 19 deletions
diff --git a/indra/newview/llcommunicationchannel.cpp b/indra/newview/llcommunicationchannel.cpp index 4b0a70ffd8..a99047c163 100644 --- a/indra/newview/llcommunicationchannel.cpp +++ b/indra/newview/llcommunicationchannel.cpp @@ -67,12 +67,18 @@ void LLCommunicationChannel::clearHistory() mHistory.clear(); } +void LLCommunicationChannel::removeItem(history_list_t::const_iterator itemToRemove) +{ + mHistory.erase(itemToRemove); +} + void LLCommunicationChannel::onFilterFail(LLNotificationPtr pNotificationPtr) { std::string notificationType = pNotificationPtr->getType(); if ((notificationType == "groupnotify") || (notificationType == "offer") - || (notificationType == "notifytoast")) + || (notificationType == "notifytoast") + && !pNotificationPtr->isCancelled()) { mHistory.insert(std::make_pair<LLDate, LLNotificationPtr>(pNotificationPtr->getDate(), pNotificationPtr)); } diff --git a/indra/newview/llcommunicationchannel.h b/indra/newview/llcommunicationchannel.h index 0e15e1cd15..c07933118d 100644 --- a/indra/newview/llcommunicationchannel.h +++ b/indra/newview/llcommunicationchannel.h @@ -48,6 +48,7 @@ public: history_list_t::const_iterator endHistory() const; void clearHistory(); + void removeItem(history_list_t::const_iterator itemToRemove); protected: virtual void onFilterFail(LLNotificationPtr pNotificationPtr); 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) { diff --git a/indra/newview/lldonotdisturbnotificationstorage.h b/indra/newview/lldonotdisturbnotificationstorage.h index 60bcd89ec3..8edb8569b4 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.h +++ b/indra/newview/lldonotdisturbnotificationstorage.h @@ -45,6 +45,7 @@ public: void saveNotifications(); void loadNotifications(); + void removeIMNotification(const LLUUID& session_id); protected: diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index f825e253d4..dd7e28dc71 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -39,6 +39,7 @@ #include "llavatariconctrl.h" #include "llavatarnamecache.h" #include "llcallbacklist.h" +#include "lldonotdisturbnotificationstorage.h" #include "llgroupactions.h" #include "llgroupiconctrl.h" #include "llflashtimer.h" @@ -1292,6 +1293,10 @@ BOOL LLFloaterIMContainer::selectConversationPair(const LLUUID& session_id, bool if (widget && widget->getParentFolder()) { widget->getParentFolder()->setSelection(widget, FALSE, FALSE); + if(gAgent.isDoNotDisturb()) + { + LLDoNotDisturbNotificationStorage::getInstance()->removeIMNotification(session_id); + } } } @@ -1313,6 +1318,11 @@ BOOL LLFloaterIMContainer::selectConversationPair(const LLUUID& session_id, bool // Switch to the conversation floater that is being selected selectFloater(session_floater); } + + if(gAgent.isDoNotDisturb()) + { + LLDoNotDisturbNotificationStorage::getInstance()->removeIMNotification(session_id); + } } // Set the focus on the selected floater diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index da811535e5..ff171fc0f8 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -128,18 +128,11 @@ void process_dnd_im(const LLSD& notification) false, false); //will need slight refactor to retrieve whether offline message or not (assume online for now) } - - // open conversation floater - LLFloaterIMContainer* container_floater = - LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container"); - if (container_floater && !(container_floater->isFrontmost())) - { - container_floater->openFloater(); - container_floater->setFrontmost(TRUE); - } } + + static void on_avatar_name_cache_toast(const LLUUID& agent_id, const LLAvatarName& av_name, LLSD msg) @@ -254,13 +247,22 @@ void on_new_message(const LLSD& msg) { if (conversation_floater_not_focused) { - if(session_floater_not_focused) + if(session_floater_not_focused && !gAgent.isDoNotDisturb()) { //User is not focused on conversation containing the message gToolBarView->flashCommand(LLCommandId("chat"), true); } im_box->flashConversationItemWidget(session_id, true); + + //If a DND message, allow notification to be stored so upon DND exit + //useMostItrusiveIMNotification will be called to notify user a message exists + if(session_id.notNull() + && participant_id.notNull() + && gAgent.isDoNotDisturb()) + { + LLAvatarNameCache::get(participant_id, boost::bind(&on_avatar_name_cache_toast, _1, _2, msg)); + } } } @@ -272,9 +274,21 @@ void on_new_message(const LLSD& msg) //Flash line item im_box->flashConversationItemWidget(session_id, true); + if(!gAgent.isDoNotDisturb()) + { //Surface conversations floater LLFloaterReg::showInstance("im_container"); } + + //If in DND mode, allow notification to be stored so upon DND exit + //useMostItrusiveIMNotification will be called to notify user a message exists + if(session_id.notNull() + && participant_id.notNull() + && gAgent.isDoNotDisturb()) + { + LLAvatarNameCache::get(participant_id, boost::bind(&on_avatar_name_cache_toast, _1, _2, msg)); + } +} } } @@ -2605,13 +2619,7 @@ void LLIMMgr::addMessage( // Open conversation floater if offline messages are present if (is_offline_msg) { - LLFloaterIMContainer* container_floater = - LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container"); - if (container_floater && !(container_floater->isFrontmost())) - { - container_floater->openFloater(); - container_floater->setFrontmost(TRUE); - } + LLFloaterReg::showInstance("im_container"); } } |