From f0426b924f543c62268ac5098c0c2c6a44e68084 Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Sat, 28 Nov 2009 17:43:21 +0200 Subject: implemented EXT-2889 "Incoming "grant modify rights" message should trigger notify toast and adding record to IM history"; fixed avatar icon in IM-floater when message added to IM-session; avoided popup of IM-tast when message added to IM-session; --HG-- branch : product-engine --- indra/newview/llnotificationhandlerutil.cpp | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 indra/newview/llnotificationhandlerutil.cpp (limited to 'indra/newview/llnotificationhandlerutil.cpp') diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp new file mode 100644 index 0000000000..e1236b935e --- /dev/null +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -0,0 +1,88 @@ +/** + * @file llnotificationofferhandler.cpp + * @brief Provides set of utility methods for notifications processing. + * + * $LicenseInfo:firstyear=2000&license=viewergpl$ + * + * Copyright (c) 2000-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + + +#include "llviewerprecompiledheaders.h" // must be first include + +#include "llnotificationhandler.h" +#include "llnotifications.h" +#include "llimview.h" + +using namespace LLNotificationsUI; + +const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"), + REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), OBJECT_GIVE_ITEM( + "ObjectGiveItem"), OBJECT_GIVE_ITEM_UNKNOWN_USER( + "ObjectGiveItemUnknownUser"); + +// static +bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification) +{ + return GRANTED_MODIFY_RIGHTS == notification->getName() + || REVOKED_MODIFY_RIGHTS == notification->getName(); +} + +// static +void LLHandlerUtil::logToIM(const LLNotificationPtr& notification) +{ + // add message to IM + const std::string + name = + notification->getSubstitutions().has("NAME") ? notification->getSubstitutions()["NAME"] + : notification->getSubstitutions()["[NAME]"]; + + // don't create IM session with objects, it's necessary condition to log + if (notification->getName() != OBJECT_GIVE_ITEM && notification->getName() + != OBJECT_GIVE_ITEM_UNKNOWN_USER) + { + LLUUID from_id = notification->getPayload()["from_id"]; + LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, + from_id); + + LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); + if (session == NULL) + { + session_id = LLIMMgr::instance().addSession(name, + IM_NOTHING_SPECIAL, from_id); + session = LLIMModel::instance().findIMSession(session_id); + } + + if (session == NULL) + { + llerrs << "session " << session_id << "does not exist " << llendl; + return; + } + + LLIMModel::instance().addMessageSilently(*session, name, from_id, + notification->getMessage()); + } +} -- cgit v1.2.3 From 0c828289c04a9783eab72d2e9f77903f96f2bc62 Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Mon, 30 Nov 2009 18:15:09 +0200 Subject: renamed LLHandlerUtil::logToIM to LLHandlerUtil::logToIMP2P; avoided IM-toast popup when adding message to session; --HG-- branch : product-engine --- indra/newview/llnotificationhandlerutil.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/newview/llnotificationhandlerutil.cpp') diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index e1236b935e..112d829563 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -52,7 +52,7 @@ bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification) } // static -void LLHandlerUtil::logToIM(const LLNotificationPtr& notification) +void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification) { // add message to IM const std::string @@ -82,7 +82,18 @@ void LLHandlerUtil::logToIM(const LLNotificationPtr& notification) return; } - LLIMModel::instance().addMessageSilently(*session, name, from_id, + + // store active session id + const LLUUID & active_session_id = + LLIMModel::instance().getActiveSessionID(); + + // set created session as active to avoid IM toast popup + LLIMModel::instance().setActiveSessionID(session->mSessionID); + + LLIMModel::instance().addMessage(session->mSessionID, name, from_id, notification->getMessage()); + + // restore active session id + LLIMModel::instance().setActiveSessionID(active_session_id); } } -- cgit v1.2.3 From 5ed4c7015641b0739291c7fc75b67aa5b0ed36fc Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Mon, 30 Nov 2009 19:59:44 +0200 Subject: =?UTF-8?q?implemented=20EXT-2962=20=E2=80=9CImplement=20adding=20?= =?UTF-8?q?messages=20into=20IM=20history=20w/o=20spawning=20chiclet?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : product-engine --- indra/newview/llnotificationhandlerutil.cpp | 32 ++++++++++++----------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'indra/newview/llnotificationhandlerutil.cpp') diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 112d829563..a30f896fa2 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -71,29 +71,23 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification) LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); if (session == NULL) { - session_id = LLIMMgr::instance().addSession(name, - IM_NOTHING_SPECIAL, from_id); - session = LLIMModel::instance().findIMSession(session_id); + LLIMModel::instance().logToFile(session_id, name, from_id, + notification->getMessage()); } - - if (session == NULL) + else { - llerrs << "session " << session_id << "does not exist " << llendl; - return; - } + // store active session id + const LLUUID & active_session_id = + LLIMModel::instance().getActiveSessionID(); + // set searched session as active to avoid IM toast popup + LLIMModel::instance().setActiveSessionID(session->mSessionID); - // store active session id - const LLUUID & active_session_id = - LLIMModel::instance().getActiveSessionID(); + LLIMModel::instance().addMessage(session->mSessionID, name, from_id, + notification->getMessage()); - // set created session as active to avoid IM toast popup - LLIMModel::instance().setActiveSessionID(session->mSessionID); - - LLIMModel::instance().addMessage(session->mSessionID, name, from_id, - notification->getMessage()); - - // restore active session id - LLIMModel::instance().setActiveSessionID(active_session_id); + // restore active session id + LLIMModel::instance().setActiveSessionID(active_session_id); + } } } -- cgit v1.2.3 From 7c0eac93e7444bc1896f8ed0ee26888ff54a33bf Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Mon, 30 Nov 2009 21:41:17 +0200 Subject: =?UTF-8?q?mplemented=20EXT-2891=20=E2=80=9CGroup=20notices=20shou?= =?UTF-8?q?ld=20be=20recorded=20into=20group=20IM=20history=E2=80=9D;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : product-engine --- indra/newview/llnotificationhandlerutil.cpp | 88 ++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 26 deletions(-) (limited to 'indra/newview/llnotificationhandlerutil.cpp') diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index a30f896fa2..05da338513 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -36,6 +36,7 @@ #include "llnotificationhandler.h" #include "llnotifications.h" #include "llimview.h" +#include "llagent.h" using namespace LLNotificationsUI; @@ -51,43 +52,78 @@ bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification) || REVOKED_MODIFY_RIGHTS == notification->getName(); } +// static +void LLHandlerUtil::logToIM(const EInstantMessage& session_type, + const std::string& session_name, const std::string& from_name, + const std::string& message, const LLUUID& session_owner_id, + const LLUUID& from_id) +{ + LLUUID session_id = LLIMMgr::computeSessionID(session_type, + session_owner_id); + LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession( + session_id); + if (session == NULL) + { + LLIMModel::instance().logToFile(session_name, from_name, from_id, message); + } + else + { + // store active session id + const LLUUID & active_session_id = + LLIMModel::instance().getActiveSessionID(); + + // set searched session as active to avoid IM toast popup + LLIMModel::instance().setActiveSessionID(session_id); + + LLIMModel::instance().addMessage(session_id, from_name, from_id, + message); + + // restore active session id + LLIMModel::instance().setActiveSessionID(active_session_id); + } +} + // static void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification) { - // add message to IM const std::string name = notification->getSubstitutions().has("NAME") ? notification->getSubstitutions()["NAME"] : notification->getSubstitutions()["[NAME]"]; - // don't create IM session with objects, it's necessary condition to log + // don't create IM p2p session with objects, it's necessary condition to log if (notification->getName() != OBJECT_GIVE_ITEM && notification->getName() != OBJECT_GIVE_ITEM_UNKNOWN_USER) { LLUUID from_id = notification->getPayload()["from_id"]; - LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, - from_id); - - LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); - if (session == NULL) - { - LLIMModel::instance().logToFile(session_id, name, from_id, - notification->getMessage()); - } - else - { - // store active session id - const LLUUID & active_session_id = - LLIMModel::instance().getActiveSessionID(); - - // set searched session as active to avoid IM toast popup - LLIMModel::instance().setActiveSessionID(session->mSessionID); - - LLIMModel::instance().addMessage(session->mSessionID, name, from_id, - notification->getMessage()); - - // restore active session id - LLIMModel::instance().setActiveSessionID(active_session_id); - } + + logToIM(IM_NOTHING_SPECIAL, name, name, notification->getMessage(), + from_id, from_id); } } + +// static +void LLHandlerUtil::logGroupNoticeToIMGroup( + const LLNotificationPtr& notification) +{ + + const LLSD& payload = notification->getPayload(); + LLGroupData groupData; + if (!gAgent.getGroupData(payload["group_id"].asUUID(), groupData)) + { + llwarns + << "Group notice for unkown group: " + << payload["group_id"].asUUID() << llendl; + } + + const std::string group_name = groupData.mName; + const std::string sender_name = payload["sender_name"].asString(); + + // we can't retrieve sender id from group notice system message, so try to lookup it from cache + LLUUID sender_id; + gCacheName->getUUID(sender_name, sender_id); + + logToIM(IM_SESSION_GROUP_START, group_name, sender_name, payload["message"], + payload["group_id"], sender_id); +} + -- cgit v1.2.3 From ab5e6c93c927935943b7135a8e70dd50256e3c2e Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Tue, 1 Dec 2009 15:16:12 +0200 Subject: =?UTF-8?q?implemented=20EXT-2799=20=E2=80=9CRecord=20to=20IM=20hi?= =?UTF-8?q?story=20notification=20about=20L$=20payments=20by=20other=20ava?= =?UTF-8?q?tar=E2=80=9D;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : product-engine --- indra/newview/llnotificationhandlerutil.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llnotificationhandlerutil.cpp') diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 05da338513..857b7e9796 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -43,13 +43,14 @@ using namespace LLNotificationsUI; const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"), REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), OBJECT_GIVE_ITEM( "ObjectGiveItem"), OBJECT_GIVE_ITEM_UNKNOWN_USER( - "ObjectGiveItemUnknownUser"); + "ObjectGiveItemUnknownUser"), PAYMENT_RECIVED("PaymentRecived"); // static bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification) { return GRANTED_MODIFY_RIGHTS == notification->getName() - || REVOKED_MODIFY_RIGHTS == notification->getName(); + || REVOKED_MODIFY_RIGHTS == notification->getName() + || PAYMENT_RECIVED == notification->getName(); } // static -- cgit v1.2.3