CHUI-685 Problem: The notifications .xml file was cleared upon exit because removeIMNotification was being called and deleting inventory offers becaus they did not have a session id. Resolution: Now check to make sure that removeIMNotification only removes IMs (IMToast).

master
Gilbert Gonzales 2013-01-17 13:52:51 -08:00
parent 41a53e8649
commit fdf774f51f
3 changed files with 40 additions and 41 deletions

View File

@ -43,15 +43,16 @@
#include "lluuid.h"
static const F32 DND_TIMER = 3.0;
const std::string toastName = "IMToast";
LLDoNotDisturbNotificationStorageTimer::LLDoNotDisturbNotificationStorageTimer() : LLEventTimer(DND_TIMER)
{
mEventTimer.start();
//mEventTimer.start();
}
LLDoNotDisturbNotificationStorageTimer::~LLDoNotDisturbNotificationStorageTimer()
{
mEventTimer.stop();
//mEventTimer.stop();
}
BOOL LLDoNotDisturbNotificationStorageTimer::tick()
@ -152,27 +153,27 @@ void LLDoNotDisturbNotificationStorage::loadNotifications()
std::string notificationName = notification_params["name"];
LLNotificationPtr notification = instance.find(notificationID);
if(notificationName == "IMToast")
if(notificationName == toastName)
{
imToastExists = true;
}
//New notification needs to be added
notification = (LLNotificationPtr) new LLNotification(notification_params.with("is_dnd", true));
LLNotificationResponderInterface* responder = createResponder(notification_params["responder_sd"]["responder_type"], notification_params["responder_sd"]);
if (responder == NULL)
{
LL_WARNS("LLDoNotDisturbNotificationStorage") << "cannot create responder for notification of type '"
<< notification->getType() << "'" << LL_ENDL;
}
else
{
LLNotificationResponderPtr responderPtr(responder);
notification->setResponseFunctor(responderPtr);
}
instance.add(notification);
notification = (LLNotificationPtr) new LLNotification(notification_params.with("is_dnd", true));
LLNotificationResponderInterface* responder = createResponder(notification_params["responder_sd"]["responder_type"], notification_params["responder_sd"]);
if (responder == NULL)
{
LL_WARNS("LLDoNotDisturbNotificationStorage") << "cannot create responder for notification of type '"
<< notification->getType() << "'" << LL_ENDL;
}
else
{
LLNotificationResponderPtr responderPtr(responder);
notification->setResponseFunctor(responderPtr);
}
instance.add(notification);
}
if(imToastExists)
{
@ -200,7 +201,7 @@ void LLDoNotDisturbNotificationStorage::updateNotifications()
LLNotificationPtr notification = it->second;
std::string notificationName = notification->getName();
if(notificationName == "IMToast")
if(notificationName == toastName)
{
imToastExists = true;
}
@ -221,9 +222,9 @@ void LLDoNotDisturbNotificationStorage::updateNotifications()
//When exit DND mode, write empty notifications file
if(commChannel->getHistorySize())
{
commChannel->clearHistory();
saveNotifications();
}
commChannel->clearHistory();
saveNotifications();
}
}
LLNotificationChannelPtr LLDoNotDisturbNotificationStorage::getCommunicationChannel() const
@ -241,6 +242,7 @@ void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& sessi
LLNotificationPtr notification;
LLSD substitutions;
LLUUID notificationSessionID;
std::string notificationName;
LLCommunicationChannel::history_list_t::iterator it;
std::vector<LLCommunicationChannel::history_list_t::iterator> itemsToRemove;
@ -252,8 +254,10 @@ void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& sessi
notification = it->second;
substitutions = notification->getSubstitutions();
notificationSessionID = substitutions["SESSION_ID"].asUUID();
notificationName = notification->getName();
if(session_id == notificationSessionID)
if(notificationName == toastName
&& session_id == notificationSessionID)
{
itemsToRemove.push_back(it);
}
@ -263,14 +267,14 @@ void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& sessi
//Remove the notifications
if(itemsToRemove.size())
{
while(itemsToRemove.size())
{
it = itemsToRemove.back();
notification = it->second;
while(itemsToRemove.size())
{
it = itemsToRemove.back();
notification = it->second;
commChannel->removeItemFromHistory(notification);
instance.cancel(notification);
itemsToRemove.pop_back();
}
instance.cancel(notification);
itemsToRemove.pop_back();
}
//Trigger saving of notifications to xml once all have been removed
saveNotifications();
}

View File

@ -42,9 +42,6 @@ public:
~LLDoNotDisturbNotificationStorageTimer();
public:
void startTimer();
void stopTimer();
bool isRunning();
BOOL tick();
};

View File

@ -1299,11 +1299,14 @@ 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);
}
}
//When in DND mode, remove stored IM notifications
//Nearby chat (Null) IMs are not stored while in DND mode, so can ignore removal
if(gAgent.isDoNotDisturb() && session_id.notNull())
{
LLDoNotDisturbNotificationStorage::getInstance()->removeIMNotification(session_id);
}
}
/* floater processing */
@ -1324,11 +1327,6 @@ 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