From 6b9ead91459d702727b54ab7e51614c2d5959f5f Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 18 Dec 2012 23:07:27 -0800 Subject: CHUI-499: Refactoring the LLPersistentNotificationStorage implementation for shared usage with the new LLDoNotDisturbNotificationStorage class. --- indra/newview/llnotificationstorage.cpp | 69 +++++++++++++++++++++++ indra/newview/llnotificationstorage.h | 3 + indra/newview/llpersistentnotificationstorage.cpp | 67 +--------------------- 3 files changed, 73 insertions(+), 66 deletions(-) diff --git a/indra/newview/llnotificationstorage.cpp b/indra/newview/llnotificationstorage.cpp index d25a212059..4746e4bbd4 100644 --- a/indra/newview/llnotificationstorage.cpp +++ b/indra/newview/llnotificationstorage.cpp @@ -29,14 +29,39 @@ #include "llnotificationstorage.h" #include +#include #include "llerror.h" #include "llfile.h" +#include "llnotifications.h" #include "llpointer.h" #include "llsd.h" #include "llsdserialize.h" +#include "llsingleton.h" +#include "llviewermessage.h" +class LLResponderRegistry : public LLSingleton +{ +public: + LLResponderRegistry(); + ~LLResponderRegistry(); + + LLNotificationResponderInterface* createResponder(const std::string& pNotificationName, const LLSD& pParams); + +protected: + +private: + template static LLNotificationResponderInterface* create(const LLSD& pParams); + + typedef boost::function responder_constructor_t; + + void add(const std::string& pNotificationName, const responder_constructor_t& pConstructor); + + typedef std::map build_map_t; + build_map_t mBuildMap; +}; + LLNotificationStorage::LLNotificationStorage(std::string pFileName) : mFileName(pFileName) { @@ -90,3 +115,47 @@ bool LLNotificationStorage::readNotifications(LLSD& pNotificationData) const return didFileRead; } + +LLNotificationResponderInterface* LLNotificationStorage::createResponder(const std::string& pNotificationName, const LLSD& pParams) const +{ + return LLResponderRegistry::getInstance()->createResponder(pNotificationName, pParams); +} + +LLResponderRegistry::LLResponderRegistry() + : LLSingleton() + , mBuildMap() +{ + add("ObjectGiveItem", &create); + add("UserGiveItem", &create); +} + +LLResponderRegistry::~LLResponderRegistry() +{ +} + +LLNotificationResponderInterface* LLResponderRegistry::createResponder(const std::string& pNotificationName, const LLSD& pParams) +{ + build_map_t::const_iterator it = mBuildMap.find(pNotificationName); + if(mBuildMap.end() == it) + { + return NULL; + } + responder_constructor_t ctr = it->second; + return ctr(pParams); +} + +template LLNotificationResponderInterface* LLResponderRegistry::create(const LLSD& pParams) +{ + RESPONDER_TYPE* responder = new RESPONDER_TYPE(); + responder->fromLLSD(pParams); + return responder; +} + +void LLResponderRegistry::add(const std::string& pNotificationName, const responder_constructor_t& pConstructor) +{ + if (mBuildMap.find(pNotificationName) != mBuildMap.end()) + { + LL_ERRS("LLResponderRegistry") << "Responder is already registered : " << pNotificationName << LL_ENDL; + } + mBuildMap.insert(std::make_pair(pNotificationName, pConstructor)); +} diff --git a/indra/newview/llnotificationstorage.h b/indra/newview/llnotificationstorage.h index ab4da4e73f..7aabf7d09e 100644 --- a/indra/newview/llnotificationstorage.h +++ b/indra/newview/llnotificationstorage.h @@ -31,6 +31,7 @@ #include "llerror.h" +class LLNotificationResponderInterface; class LLSD; class LLNotificationStorage @@ -44,6 +45,8 @@ protected: bool writeNotifications(const LLSD& pNotificationData) const; bool readNotifications(LLSD& pNotificationData) const; + LLNotificationResponderInterface* createResponder(const std::string& pNotificationName, const LLSD& pParams) const; + private: std::string mFileName; }; diff --git a/indra/newview/llpersistentnotificationstorage.cpp b/indra/newview/llpersistentnotificationstorage.cpp index 7aaad64fd7..224aaa2146 100644 --- a/indra/newview/llpersistentnotificationstorage.cpp +++ b/indra/newview/llpersistentnotificationstorage.cpp @@ -36,34 +36,6 @@ #include "llscriptfloater.h" #include "llviewermessage.h" -class LLResponderRegistry -{ -public: - - static void registerResponders(); - - static LLNotificationResponderInterface* createResponder(const std::string& notification_name, const LLSD& params); - -protected: - -private: - template - static LLNotificationResponderInterface* create(const LLSD& params) - { - RESPONDER_TYPE* responder = new RESPONDER_TYPE(); - responder->fromLLSD(params); - return responder; - } - - typedef boost::function responder_constructor_t; - - static void add(const std::string& notification_name, const responder_constructor_t& ctr); - - typedef std::map build_map_t; - - static build_map_t sBuildMap; -}; - LLPersistentNotificationStorage::LLPersistentNotificationStorage() : LLSingleton() , LLNotificationStorage(gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "open_notifications.xml")) @@ -114,7 +86,6 @@ static LLFastTimer::DeclareTimer FTM_LOAD_NOTIFICATIONS("Load Notifications"); void LLPersistentNotificationStorage::loadNotifications() { LLFastTimer _(FTM_LOAD_NOTIFICATIONS); - LLResponderRegistry::registerResponders(); LLNotifications::instance().getChannel("Persistent")-> connectChanged(boost::bind(&LLPersistentNotificationStorage::onPersistentChannelChanged, this, _1)); @@ -144,8 +115,7 @@ void LLPersistentNotificationStorage::loadNotifications() LLSD notification_params = *notification_it; LLNotificationPtr notification(new LLNotification(notification_params)); - LLNotificationResponderPtr responder(LLResponderRegistry:: - createResponder(notification_params["name"], notification_params["responder"])); + LLNotificationResponderPtr responder(createResponder(notification_params["name"], notification_params["responder"])); notification->setResponseFunctor(responder); instance.add(notification); @@ -172,39 +142,4 @@ bool LLPersistentNotificationStorage::onPersistentChannelChanged(const LLSD& pay return false; } -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -LLResponderRegistry::build_map_t LLResponderRegistry::sBuildMap; - -void LLResponderRegistry::registerResponders() -{ - sBuildMap.clear(); - - add("ObjectGiveItem", &create); - add("UserGiveItem", &create); -} - -LLNotificationResponderInterface* LLResponderRegistry::createResponder(const std::string& notification_name, const LLSD& params) -{ - build_map_t::const_iterator it = sBuildMap.find(notification_name); - if(sBuildMap.end() == it) - { - return NULL; - } - responder_constructor_t ctr = it->second; - return ctr(params); -} - -void LLResponderRegistry::add(const std::string& notification_name, const responder_constructor_t& ctr) -{ - if(sBuildMap.find(notification_name) != sBuildMap.end()) - { - llwarns << "Responder is already registered : " << notification_name << llendl; - llassert(!"Responder already registered"); - } - sBuildMap[notification_name] = ctr; -} - // EOF -- cgit v1.2.3 From bd6d34d312c3e3322ab62f3a60253fb88fcbc9e3 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Wed, 19 Dec 2012 01:48:37 -0800 Subject: CHUI-499: Loading the DND notifications upon exit from DND mode and after login. --- indra/newview/llagent.cpp | 14 ++-- indra/newview/llchannelmanager.cpp | 2 + indra/newview/llcommunicationchannel.cpp | 6 ++ indra/newview/llcommunicationchannel.h | 2 + .../newview/lldonotdisturbnotificationstorage.cpp | 76 ++++++++++++++++++++++ 5 files changed, 96 insertions(+), 4 deletions(-) diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 49c570c30b..fc3be9ca21 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -41,6 +41,7 @@ #include "llchannelmanager.h" #include "llchicletbar.h" #include "llconsole.h" +#include "lldonotdisturbnotificationstorage.h" #include "llenvmanager.h" #include "llfirstuse.h" #include "llfloatercamera.h" @@ -1389,11 +1390,16 @@ BOOL LLAgent::getAFK() const //----------------------------------------------------------------------------- // setDoNotDisturb() //----------------------------------------------------------------------------- -void LLAgent::setDoNotDisturb(bool pIsDotNotDisturb) +void LLAgent::setDoNotDisturb(bool pIsDoNotDisturb) { - mIsDoNotDisturb = pIsDotNotDisturb; - sendAnimationRequest(ANIM_AGENT_DO_NOT_DISTURB, (pIsDotNotDisturb ? ANIM_REQUEST_START : ANIM_REQUEST_STOP)); - LLNotificationsUI::LLChannelManager::getInstance()->muteAllChannels(pIsDotNotDisturb); + bool isDoNotDisturbSwitchedOff = (mIsDoNotDisturb && !pIsDoNotDisturb); + mIsDoNotDisturb = pIsDoNotDisturb; + sendAnimationRequest(ANIM_AGENT_DO_NOT_DISTURB, (pIsDoNotDisturb ? ANIM_REQUEST_START : ANIM_REQUEST_STOP)); + LLNotificationsUI::LLChannelManager::getInstance()->muteAllChannels(pIsDoNotDisturb); + if (isDoNotDisturbSwitchedOff) + { + LLDoNotDisturbNotificationStorage::getInstance()->loadNotifications(); + } } //----------------------------------------------------------------------------- diff --git a/indra/newview/llchannelmanager.cpp b/indra/newview/llchannelmanager.cpp index dd2bcc742b..43757d0174 100644 --- a/indra/newview/llchannelmanager.cpp +++ b/indra/newview/llchannelmanager.cpp @@ -139,7 +139,9 @@ void LLChannelManager::onLoginCompleted() } LLPersistentNotificationStorage::getInstance()->loadNotifications(); + LLDoNotDisturbNotificationStorage::getInstance()->initialize(); + LLDoNotDisturbNotificationStorage::getInstance()->loadNotifications(); } //-------------------------------------------------------------------------- diff --git a/indra/newview/llcommunicationchannel.cpp b/indra/newview/llcommunicationchannel.cpp index 353447e4b6..4b0a70ffd8 100644 --- a/indra/newview/llcommunicationchannel.cpp +++ b/indra/newview/llcommunicationchannel.cpp @@ -39,6 +39,7 @@ LLCommunicationChannel::LLCommunicationChannel(const std::string& pName, const std::string& pParentName) : LLNotificationChannel(pName, pParentName, filterByDoNotDisturbStatus) + , mHistory() { } @@ -61,6 +62,11 @@ LLCommunicationChannel::history_list_t::const_iterator LLCommunicationChannel::e return mHistory.end(); } +void LLCommunicationChannel::clearHistory() +{ + mHistory.clear(); +} + void LLCommunicationChannel::onFilterFail(LLNotificationPtr pNotificationPtr) { std::string notificationType = pNotificationPtr->getType(); diff --git a/indra/newview/llcommunicationchannel.h b/indra/newview/llcommunicationchannel.h index a4756b8993..0e15e1cd15 100644 --- a/indra/newview/llcommunicationchannel.h +++ b/indra/newview/llcommunicationchannel.h @@ -46,6 +46,8 @@ public: typedef std::multimap history_list_t; history_list_t::const_iterator beginHistory() const; history_list_t::const_iterator endHistory() const; + + void clearHistory(); protected: virtual void onFilterFail(LLNotificationPtr pNotificationPtr); diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp index 472a0dd9ee..43fd7705aa 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.cpp +++ b/indra/newview/lldonotdisturbnotificationstorage.cpp @@ -29,14 +29,25 @@ #include "lldonotdisturbnotificationstorage.h" +#define XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT 0 + +#if XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT +#include "llchannelmanager.h" +#endif // XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT #include "llcommunicationchannel.h" #include "lldir.h" #include "llerror.h" #include "llfasttimer_class.h" #include "llnotifications.h" +#include "llnotificationhandler.h" #include "llnotificationstorage.h" +#if XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT +#include "llscreenchannel.h" +#endif // XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT +#include "llscriptfloater.h" #include "llsd.h" #include "llsingleton.h" +#include "lluuid.h" LLDoNotDisturbNotificationStorage::LLDoNotDisturbNotificationStorage() : LLSingleton() @@ -85,6 +96,71 @@ static LLFastTimer::DeclareTimer FTM_LOAD_DND_NOTIFICATIONS("Load DND Notificati void LLDoNotDisturbNotificationStorage::loadNotifications() { + LLFastTimer _(FTM_LOAD_DND_NOTIFICATIONS); + + LL_INFOS("stinsonDebug") << "STINSON DEBUG: loading notifiations" << LL_ENDL; + + LLSD input; + if (!readNotifications(input) ||input.isUndefined()) + { + return; + } + + LLSD& data = input["data"]; + if (data.isUndefined()) + { + return; + } + +#if XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT + LLNotificationsUI::LLScreenChannel* notification_channel = + dynamic_cast(LLNotificationsUI::LLChannelManager::getInstance()-> + findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID")))); +#endif // XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT + + LLNotifications& instance = LLNotifications::instance(); + + for (LLSD::array_const_iterator notification_it = data.beginArray(); + notification_it != data.endArray(); + ++notification_it) + { + LLSD notification_params = *notification_it; + LLNotificationPtr notification(new LLNotification(notification_params)); + + LL_INFOS("stinsonDebug") << "STINSON DEBUG: loading notification of type '" << notification->getType() << "'" << LL_ENDL; + + const LLUUID& notificationID = notification->id(); + if (instance.find(notificationID)) + { + instance.update(notification); + } + else + { + LLNotificationResponderPtr responder(createResponder(notification_params["name"], notification_params["responder"])); + notification->setResponseFunctor(responder); + + instance.add(notification); + } + +#if XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT + // hide script floaters so they don't confuse the user and don't overlap startup toast + LLScriptFloaterManager::getInstance()->setFloaterVisible(notification->getID(), false); + + if(notification_channel) + { + // hide saved toasts so they don't confuse the user + notification_channel->hideToast(notification->getID()); + } +#endif // XXX_STINSON_HIDE_NOTIFICATIONS_ON_DND_EXIT + } + + // Clear the communication channel history and rewrite the save file to empty it as well + LLNotificationChannelPtr channelPtr = getCommunicationChannel(); + LLCommunicationChannel *commChannel = dynamic_cast(channelPtr.get()); + llassert(commChannel != NULL); + commChannel->clearHistory(); + + saveNotifications(); } LLNotificationChannelPtr LLDoNotDisturbNotificationStorage::getCommunicationChannel() const -- cgit v1.2.3 From ca4c5d3bcb18afefc181bdc164d1c338abef7488 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Wed, 19 Dec 2012 11:28:38 -0800 Subject: Switching some notification types from "offer" to be "notify" as the notifications were not offers. --- indra/newview/skins/default/xui/en/notifications.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 35ce787847..05798da8e2 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -6583,7 +6583,7 @@ However, this region contains content accessible to adults only. log_to_im="true" log_to_chat="false" show_toast="false" - type="offer"> + type="notify"> Teleport offer sent to [TO_NAME] @@ -6636,7 +6636,7 @@ However, this region contains content accessible to adults only. name="FriendshipOffered" log_to_im="true" show_toast="false" - type="offer"> + type="notify"> friendship You have offered friendship to [TO_NAME] @@ -6666,7 +6666,7 @@ However, this region contains content accessible to adults only. icon="notify.tga" name="FriendshipAccepted" log_to_im="true" - type="offer"> + type="notify"> friendship <nolink>[NAME]</nolink> accepted your friendship offer. @@ -6686,7 +6686,7 @@ However, this region contains content accessible to adults only. name="FriendshipAcceptedByMe" log_to_im="true" show_toast="false" - type="offer"> + type="notify"> friendship Friendship offer accepted. @@ -6696,7 +6696,7 @@ Friendship offer accepted. name="FriendshipDeclinedByMe" log_to_im="true" show_toast="false" - type="offer"> + type="notify"> friendship Friendship offer declined. -- cgit v1.2.3 From ef6121cba1c72549cca10763645254ae3aaf2887 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Wed, 19 Dec 2012 15:37:12 -0800 Subject: CHUI-499: Code clean-up and adding some more types badly defined. --- indra/newview/lldonotdisturbnotificationstorage.cpp | 17 +++++++++++------ indra/newview/llnotificationstorage.cpp | 6 ++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp index 43fd7705aa..bf3dcae1f3 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.cpp +++ b/indra/newview/lldonotdisturbnotificationstorage.cpp @@ -98,8 +98,6 @@ void LLDoNotDisturbNotificationStorage::loadNotifications() { LLFastTimer _(FTM_LOAD_DND_NOTIFICATIONS); - LL_INFOS("stinsonDebug") << "STINSON DEBUG: loading notifiations" << LL_ENDL; - LLSD input; if (!readNotifications(input) ||input.isUndefined()) { @@ -127,8 +125,6 @@ void LLDoNotDisturbNotificationStorage::loadNotifications() LLSD notification_params = *notification_it; LLNotificationPtr notification(new LLNotification(notification_params)); - LL_INFOS("stinsonDebug") << "STINSON DEBUG: loading notification of type '" << notification->getType() << "'" << LL_ENDL; - const LLUUID& notificationID = notification->id(); if (instance.find(notificationID)) { @@ -136,8 +132,17 @@ void LLDoNotDisturbNotificationStorage::loadNotifications() } else { - LLNotificationResponderPtr responder(createResponder(notification_params["name"], notification_params["responder"])); - notification->setResponseFunctor(responder); + LLNotificationResponderInterface* responder = createResponder(notification_params["name"], notification_params["responder"]); + 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); } diff --git a/indra/newview/llnotificationstorage.cpp b/indra/newview/llnotificationstorage.cpp index 4746e4bbd4..b797775369 100644 --- a/indra/newview/llnotificationstorage.cpp +++ b/indra/newview/llnotificationstorage.cpp @@ -126,7 +126,13 @@ LLResponderRegistry::LLResponderRegistry() , mBuildMap() { add("ObjectGiveItem", &create); + add("OwnObjectGiveItem", &create); add("UserGiveItem", &create); + + add("TeleportOffered", &create); + add("TeleportOffered_MaturityExceeded", &create); + + add("OfferFriendship", &create); } LLResponderRegistry::~LLResponderRegistry() -- cgit v1.2.3 From b15ba74485e24db9a996a2f6a9438ac48224ea7a Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Wed, 19 Dec 2012 17:19:48 -0800 Subject: CHUI-607: Due to a problem in design we have two checkboxes that determine whether a conversation transcript should be saved. By defaut commiting a change that makes both checkboxes checked by default. This makes it so that a new user can see their transcript/chat history. --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 24fa0a0cd4..ebc915ec5a 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4676,7 +4676,7 @@ Type Boolean Value - 0 + 1 LandBrushSize -- cgit v1.2.3