diff options
author | Alexei Arabadji <aarabadji@productengine.com> | 2010-04-01 15:24:36 +0300 |
---|---|---|
committer | Alexei Arabadji <aarabadji@productengine.com> | 2010-04-01 15:24:36 +0300 |
commit | 4992eaf27dd113df805f347811882e72df6d7a86 (patch) | |
tree | 0b9dc91a785e4727be7f43b2ea20f2b38f24c4f2 | |
parent | 91b28e42cb9ac68cb199eb8b39de90ab2249de24 (diff) |
fixed EXT-2801 Record "object return" notification into IM history, not chat history,
* added class for LLPostponedNotification to rpovide possibility postpone adding notification to notifications system till sender avatar name will be received from cache name;
* rolled back changes related to fix of EXT-4779;
* avoided passing avatar id when logging 'Object Return' notification to nearby chat;
eviewed by Vadim Savchuk at https://jira.secondlife.com/browse/EXT-6373
--HG--
branch : product-engine
-rw-r--r-- | indra/llui/llnotifications.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 57 | ||||
-rw-r--r-- | indra/newview/llnotificationhandlerutil.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llviewermessage.cpp | 23 |
4 files changed, 86 insertions, 11 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index d7424cf05a..65ef53443b 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1552,3 +1552,11 @@ std::ostream& operator<<(std::ostream& s, const LLNotification& notification) return s; } +void LLPostponedNotification::onCachedNameReceived(const LLUUID& id, const std::string& first, + const std::string& last, bool is_group) +{ + gCacheName->getFullName(id, mName); + modifyNotificationParams(); + LLNotifications::instance().add(mParams); + cleanup(); +} diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 400491a154..707a84bdfe 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -104,6 +104,7 @@ #include "llinitparam.h" #include "llnotificationslistener.h" #include "llnotificationptr.h" +#include "llcachename.h" typedef enum e_notification_priority @@ -949,6 +950,62 @@ private: boost::scoped_ptr<LLNotificationsListener> mListener; }; +/** + * Abstract class for postponed notifications. + * Provides possibility to add notification after specified by id avatar or group will be + * received from cache name. The object of this type automatically well be deleted + * by cleanup method after respond will be received from cache name. + * + * To add custom postponed notification to the notification system client should: + * 1 create class derived from LLPostponedNotification; + * 2 call LLPostponedNotification::add method; + */ +class LLPostponedNotification +{ +public: + /** + * Performs hooking cache name callback which will add notification to notifications system. + * Type of added notification should be specified by template parameter T + * and non-private derived from LLPostponedNotification class, + * otherwise compilation error will occur. + */ + template<class T> + static void add(const LLNotification::Params& params, + const LLUUID& id, bool is_group) + { + // upcast T to the base type to restrict T derivation from LLPostponedNotification + LLPostponedNotification* thiz = new T(); + + thiz->mParams = params; + + gCacheName->get(id, is_group, boost::bind( + &LLPostponedNotification::onCachedNameReceived, thiz, _1, _2, + _3, _4)); + } + +private: + void onCachedNameReceived(const LLUUID& id, const std::string& first, + const std::string& last, bool is_group); + + void cleanup() + { + delete this; + } + +protected: + LLPostponedNotification() {} + ~LLPostponedNotification() {} + + /** + * Abstract method provides possibility to modify notification parameters and + * will be called after cache name retrieve information about avatar or group + * and before notification will be added to the notification system. + */ + virtual void modifyNotificationParams() = 0; + + LLNotification::Params mParams; + std::string mName; +}; #endif//LL_LLNOTIFICATIONS_H diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 6aafa04a17..3f551f6b32 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -323,7 +323,7 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification, bool to_fi { const std::string name = LLHandlerUtil::getSubstitutionName(notification); - std::string session_name = notification->getPayload().has( + const std::string& session_name = notification->getPayload().has( "SESSION_NAME") ? notification->getPayload()["SESSION_NAME"].asString() : name; // don't create IM p2p session with objects, it's necessary condition to log @@ -332,12 +332,6 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification, bool to_fi { LLUUID from_id = notification->getPayload()["from_id"]; - //*HACK for ServerObjectMessage the sesson name is really weird, see EXT-4779 - if (SERVER_OBJECT_MESSAGE == notification->getName()) - { - session_name = "chat"; - } - //there still appears a log history file with weird name " .txt" if (" " == session_name || "{waiting}" == session_name || "{nobody}" == session_name) { @@ -392,6 +386,7 @@ void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChat LLChat chat_msg(notification->getMessage()); chat_msg.mSourceType = type; chat_msg.mFromName = SYSTEM_FROM; + chat_msg.mFromID = LLUUID::null; nearby_chat->addMessage(chat_msg); } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 3a5d701bc1..1426c0b9e2 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1685,6 +1685,18 @@ bool inspect_remote_object_callback(const LLSD& notification, const LLSD& respon } static LLNotificationFunctorRegistration inspect_remote_object_callback_reg("ServerObjectMessage", inspect_remote_object_callback); +class LLPostponedServerObjectNotification: public LLPostponedNotification +{ +protected: + /* virtual */ + void modifyNotificationParams() + { + LLSD payload = mParams.payload; + payload["SESSION_NAME"] = mName; + mParams.payload = payload; + } +}; + void process_improved_im(LLMessageSystem *msg, void **user_data) { if (gNoRender) @@ -2220,7 +2232,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if(SYSTEM_FROM == name) { // System's UUID is NULL (fixes EXT-4766) - chat.mFromID = from_id = LLUUID::null; + chat.mFromID = LLUUID::null; } LLSD query_string; @@ -2266,13 +2278,16 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) payload["slurl"] = location; payload["name"] = name; std::string session_name; - gCacheName->getFullName(from_id, session_name); - payload["SESSION_NAME"] = session_name; if (from_group) { payload["group_owned"] = "true"; } - LLNotificationsUtil::add("ServerObjectMessage", substitutions, payload); + + LLNotification::Params params("ServerObjectMessage"); + params.substitutions = substitutions; + params.payload = payload; + + LLPostponedNotification::add<LLPostponedServerObjectNotification>(params, from_id, false); } break; case IM_FROM_TASK_AS_ALERT: |