CHUI-499: Adding ability to serialize the communication notifications to local disk per user.

master
William Todd Stinson 2012-12-18 18:48:15 -08:00
parent e7467e8c01
commit c73947ac1f
11 changed files with 311 additions and 5 deletions

View File

@ -992,10 +992,12 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt
bool abortProcessing = false;
if (passesFilter)
{
onFilterPass(pNotification);
abortProcessing = mPassedFilter(payload);
}
else
{
onFilterFail(pNotification);
abortProcessing = mFailedFilter(payload);
}

View File

@ -774,6 +774,9 @@ protected:
virtual void onDelete(LLNotificationPtr p) {}
virtual void onChange(LLNotificationPtr p) {}
virtual void onFilterPass(LLNotificationPtr p) {}
virtual void onFilterFail(LLNotificationPtr p) {}
bool updateItem(const LLSD& payload, LLNotificationPtr pNotification);
LLNotificationFilter mFilter;
};

View File

@ -137,6 +137,7 @@ set(viewer_SOURCE_FILES
llcommanddispatcherlistener.cpp
llcommandhandler.cpp
llcommandlineparser.cpp
llcommunicationchannel.cpp
llcompilequeue.cpp
llconfirmationmanager.cpp
llconversationlog.cpp
@ -152,6 +153,7 @@ set(viewer_SOURCE_FILES
lldebugview.cpp
lldelayedgestureerror.cpp
lldirpicker.cpp
lldonotdisturbnotificationstorage.cpp
lldndbutton.cpp
lldrawable.cpp
lldrawpool.cpp
@ -723,6 +725,7 @@ set(viewer_HEADER_FILES
llcommanddispatcherlistener.h
llcommandhandler.h
llcommandlineparser.h
llcommunicationchannel.h
llcompilequeue.h
llconfirmationmanager.h
llconversationlog.h
@ -738,6 +741,7 @@ set(viewer_HEADER_FILES
lldebugview.h
lldelayedgestureerror.h
lldirpicker.h
lldonotdisturbnotificationstorage.h
lldndbutton.h
lldrawable.h
lldrawpool.h

View File

@ -29,6 +29,7 @@
#include "llchannelmanager.h"
#include "llappviewer.h"
#include "lldonotdisturbnotificationstorage.h"
#include "llpersistentnotificationstorage.h"
#include "llviewercontrol.h"
#include "llviewerwindow.h"
@ -138,6 +139,7 @@ void LLChannelManager::onLoginCompleted()
}
LLPersistentNotificationStorage::getInstance()->loadNotifications();
LLDoNotDisturbNotificationStorage::getInstance()->initialize();
}
//--------------------------------------------------------------------------

View File

@ -0,0 +1,73 @@
/**
* @file llcommunicationchannel.cpp
* @brief Implementation of llcommunicationchannel
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h" // must be first include
#include "llcommunicationchannel.h"
#include <string>
#include <map>
#include "llagent.h"
#include "lldate.h"
#include "llnotifications.h"
LLCommunicationChannel::LLCommunicationChannel(const std::string& pName, const std::string& pParentName)
: LLNotificationChannel(pName, pParentName, filterByDoNotDisturbStatus)
{
}
LLCommunicationChannel::~LLCommunicationChannel()
{
}
bool LLCommunicationChannel::filterByDoNotDisturbStatus(LLNotificationPtr)
{
return !gAgent.isDoNotDisturb();
}
LLCommunicationChannel::history_list_t::const_iterator LLCommunicationChannel::beginHistory() const
{
return mHistory.begin();
}
LLCommunicationChannel::history_list_t::const_iterator LLCommunicationChannel::endHistory() const
{
return mHistory.end();
}
void LLCommunicationChannel::onFilterFail(LLNotificationPtr pNotificationPtr)
{
std::string notificationType = pNotificationPtr->getType();
if ((notificationType == "groupnotify")
|| (notificationType == "offer")
|| (notificationType == "notifytoast"))
{
mHistory.insert(std::make_pair<LLDate, LLNotificationPtr>(pNotificationPtr->getDate(), pNotificationPtr));
}
}

View File

@ -0,0 +1,59 @@
/**
* @file llcommunicationchannel.h
* @brief Header file for llcommunicationchannel
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLCOMMUNICATIONCHANNEL_H
#define LL_LLCOMMUNICATIONCHANNEL_H
#include <string>
#include <map>
#include "lldate.h"
#include "llerror.h"
#include "llnotifications.h"
class LLCommunicationChannel : public LLNotificationChannel
{
LOG_CLASS(LLCommunicationChannel);
public:
LLCommunicationChannel(const std::string& pName, const std::string& pParentName);
virtual ~LLCommunicationChannel();
static bool filterByDoNotDisturbStatus(LLNotificationPtr);
typedef std::multimap<LLDate, LLNotificationPtr> history_list_t;
history_list_t::const_iterator beginHistory() const;
history_list_t::const_iterator endHistory() const;
protected:
virtual void onFilterFail(LLNotificationPtr pNotificationPtr);
private:
history_list_t mHistory;
};
#endif // LL_LLCOMMUNICATIONCHANNEL_H

View File

@ -0,0 +1,106 @@
/**
* @file lldonotdisturbnotificationstorage.cpp
* @brief Implementation of lldonotdisturbnotificationstorage
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "lldonotdisturbnotificationstorage.h"
#include "llcommunicationchannel.h"
#include "lldir.h"
#include "llerror.h"
#include "llfasttimer_class.h"
#include "llnotifications.h"
#include "llnotificationstorage.h"
#include "llsd.h"
#include "llsingleton.h"
LLDoNotDisturbNotificationStorage::LLDoNotDisturbNotificationStorage()
: LLSingleton<LLDoNotDisturbNotificationStorage>()
, LLNotificationStorage(gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "dnd_notifications.xml"))
{
}
LLDoNotDisturbNotificationStorage::~LLDoNotDisturbNotificationStorage()
{
}
void LLDoNotDisturbNotificationStorage::initialize()
{
getCommunicationChannel()->connectFailedFilter(boost::bind(&LLDoNotDisturbNotificationStorage::onChannelChanged, this, _1));
}
static LLFastTimer::DeclareTimer FTM_SAVE_DND_NOTIFICATIONS("Save DND Notifications");
void LLDoNotDisturbNotificationStorage::saveNotifications()
{
LLFastTimer _(FTM_SAVE_DND_NOTIFICATIONS);
LLNotificationChannelPtr channelPtr = getCommunicationChannel();
const LLCommunicationChannel *commChannel = dynamic_cast<LLCommunicationChannel*>(channelPtr.get());
llassert(commChannel != NULL);
LLSD output = LLSD::emptyMap();
LLSD& data = output["data"];
data = LLSD::emptyArray();
for (LLCommunicationChannel::history_list_t::const_iterator historyIter = commChannel->beginHistory();
historyIter != commChannel->endHistory(); ++historyIter)
{
LLNotificationPtr notificationPtr = historyIter->second;
if (!notificationPtr->isRespondedTo() && !notificationPtr->isCancelled() && !notificationPtr->isExpired())
{
data.append(notificationPtr->asLLSD());
}
}
writeNotifications(output);
}
static LLFastTimer::DeclareTimer FTM_LOAD_DND_NOTIFICATIONS("Load DND Notifications");
void LLDoNotDisturbNotificationStorage::loadNotifications()
{
}
LLNotificationChannelPtr LLDoNotDisturbNotificationStorage::getCommunicationChannel() const
{
LLNotificationChannelPtr channelPtr = LLNotifications::getInstance()->getChannel("Communication");
llassert(channelPtr);
return channelPtr;
}
bool LLDoNotDisturbNotificationStorage::onChannelChanged(const LLSD& pPayload)
{
if (pPayload["sigtype"].asString() != "load")
{
saveNotifications();
}
return false;
}

View File

@ -0,0 +1,57 @@
/**
* @file lldonotdisturbnotificationstorage.h
* @brief Header file for lldonotdisturbnotificationstorage
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLDONOTDISTURBNOTIFICATIONSTORAGE_H
#define LL_LLDONOTDISTURBNOTIFICATIONSTORAGE_H
#include "llerror.h"
#include "llnotifications.h"
#include "llnotificationstorage.h"
#include "llsingleton.h"
class LLSD;
class LLDoNotDisturbNotificationStorage : public LLSingleton<LLDoNotDisturbNotificationStorage>, public LLNotificationStorage
{
LOG_CLASS(LLDoNotDisturbNotificationStorage);
public:
LLDoNotDisturbNotificationStorage();
~LLDoNotDisturbNotificationStorage();
void initialize();
void saveNotifications();
void loadNotifications();
protected:
private:
LLNotificationChannelPtr getCommunicationChannel() const;
bool onChannelChanged(const LLSD& pPayload);
};
#endif // LL_LLDONOTDISTURBNOTIFICATIONSTORAGE_H

View File

@ -149,7 +149,7 @@ void on_new_message(const LLSD& msg)
}
// do not show notification in "do not disturb" mode or it goes from agent
if (gAgent.isDoNotDisturb() || gAgent.getID() == participant_id)
if (gAgent.getID() == participant_id)
{
return;
}
@ -2500,7 +2500,7 @@ void LLIMMgr::addMessage(
}
bool new_session = !hasSession(new_session_id);
if (new_session && !gAgent.isDoNotDisturb())
if (new_session)
{
LLAvatarName av_name;
if (LLAvatarNameCache::get(other_participant_id, &av_name) && !name_is_setted)
@ -2543,7 +2543,7 @@ void LLIMMgr::addMessage(
}
//Play sound for new conversations
if(gSavedSettings.getBOOL("PlaySoundNewConversation") == TRUE)
if (!gAgent.isDoNotDisturb() && (gSavedSettings.getBOOL("PlaySoundNewConversation") == TRUE))
{
make_ui_sound("UISndNewIncomingIMSession");
}

View File

@ -119,7 +119,6 @@ public:
/**
* Handler for chat message notifications.
*/
// XXX stinson 12/06/2012 : can I just remove the LLChatHandler class?
class LLChatHandler : public LLEventHandler
{
public:

View File

@ -37,6 +37,7 @@
#include "llagent.h"
#include "llagentcamera.h"
#include "llcommunicationchannel.h"
#include "llfloaterreg.h"
#include "llmeshrepository.h"
#include "llnotificationhandler.h"
@ -1557,7 +1558,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
mViewerWindowListener.reset(new LLViewerWindowListener(this));
mSystemChannel.reset(new LLNotificationChannel("System", "Visible", LLNotificationFilters::includeEverything));
mCommunicationChannel.reset(new LLNotificationChannel("Communication", "Visible", !boost::bind(&LLAgent::isDoNotDisturb, &gAgent)));
mCommunicationChannel.reset(new LLCommunicationChannel("Communication", "Visible"));
mAlertsChannel.reset(new LLNotificationsUI::LLViewerAlertHandler("VW_alerts", "alert"));
mModalAlertsChannel.reset(new LLNotificationsUI::LLViewerAlertHandler("VW_alertmodal", "alertmodal"));