From e1ac33104f08025580d30d1456a1081d4bdd4888 Mon Sep 17 00:00:00 2001 From: PanteraPolnocy Date: Wed, 4 Sep 2013 09:15:08 +0200 Subject: [PATCH] FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground, original patch provided by Manami Hokkigai "Moved alert handling out of the window drawing, and into the message receipt function" Most probably is also fixing FIRE-6144 ("keyword alerts are triggered by chat history reloading") --- indra/newview/fskeywords.cpp | 26 +++++++++++++++++--- indra/newview/fskeywords.h | 1 + indra/newview/llviewerchat.cpp | 13 ---------- indra/newview/llviewermessage.cpp | 41 +++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/indra/newview/fskeywords.cpp b/indra/newview/fskeywords.cpp index 0fd226de76..1716c5a237 100644 --- a/indra/newview/fskeywords.cpp +++ b/indra/newview/fskeywords.cpp @@ -4,6 +4,7 @@ #include "fskeywords.h" #include "llui.h" #include "llviewercontrol.h" +#include "growlmanager.h" // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground #include //#include //for boost::ifind_first @@ -49,11 +50,30 @@ bool FSKeywords::chatContainsKeyword(const LLChat& chat, bool is_local) { if(source.find(mWordList[i]) != std::string::npos) { - if(gSavedSettings.getBOOL("PlayModeUISndFSKeywordSound")) - LLUI::sAudioCallback(LLUUID(gSavedSettings.getString("UISndFSKeywordSound"))); - return true; } } return false; } + +// FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground +void FSKeywords::notify(const LLChat& chat) +{ + static LLCachedControl PlayModeUISndFSKeywordSound(gSavedSettings, "PlayModeUISndFSKeywordSound"); + if(PlayModeUISndFSKeywordSound) + LLUI::sAudioCallback(LLUUID(gSavedSettings.getString("UISndFSKeywordSound"))); + + std::string msg = chat.mFromName; + std::string prefix = chat.mText.substr(0, 4); + if(prefix == "/me " || prefix == "/me'" || prefix == "/ME " || prefix == "/ME'") + { + msg = msg + chat.mText.substr(3); + } + else + { + msg = msg + ": " + chat.mText; + } + + gGrowlManager->notify("Keyword Alert", msg, "Keyword Alert"); +} +// diff --git a/indra/newview/fskeywords.h b/indra/newview/fskeywords.h index ae0d8db843..4c6e3eaf51 100644 --- a/indra/newview/fskeywords.h +++ b/indra/newview/fskeywords.h @@ -16,6 +16,7 @@ public: void updateKeywords(); bool chatContainsKeyword(const LLChat& chat, bool is_local); + void static notify(const LLChat& chat); // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground private: std::vector mWordList; diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp index 354cb980c6..5e40dbbec2 100755 --- a/indra/newview/llviewerchat.cpp +++ b/indra/newview/llviewerchat.cpp @@ -132,19 +132,6 @@ void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color, bool is_l //Keyword alerts -KC if ((gAgentID != chat.mFromID || chat.mFromName == SYSTEM_FROM) && FSKeywords::getInstance()->chatContainsKeyword(chat, is_local)) { - std::string msg = chat.mFromName; - std::string prefix = chat.mText.substr(0, 4); - if(prefix == "/me " || prefix == "/me'") - { - msg = msg + chat.mText.substr(3); - } - else - { - msg = msg + ": " + chat.mText; - } - - gGrowlManager->notify("Keyword Alert", msg, "Keyword Alert"); - static LLCachedControl sFSKeywordChangeColor(gSavedPerAccountSettings, "FSKeywordChangeColor"); if (sFSKeywordChangeColor) { diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 95d2f51ad2..f2656f960d 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -154,6 +154,7 @@ const static boost::regex NEWLINES("\\n{1}"); #include "fscommon.h" #include "fslightshare.h" // FIRE-5118 - Lightshare support #include "fsradar.h" +#include "fskeywords.h" // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground #if LL_MSVC // disable boost::lexical_cast warning @@ -2828,6 +2829,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL; + // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground (notification on receipt of IM) + chat.mText = buffer; + if ((chat.mFromID != gAgent.getID() || chat.mFromName == SYSTEM_FROM) && FSKeywords::getInstance()->chatContainsKeyword(chat, false)) + { + FSKeywords::notify(chat); + } + // + // add to IM panel, but do not bother the user gIMMgr->addMessage( session_id, @@ -2937,6 +2946,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { // checkfor and process reqinfo message = FSData::getInstance()->processRequestForInfo(from_id,message,name,session_id); + + // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground (notification on receipt of IM) + chat.mText = message; + if ((chat.mFromID != gAgent.getID() || chat.mFromName == SYSTEM_FROM) && FSKeywords::getInstance()->chatContainsKeyword(chat, false)) + { + FSKeywords::notify(chat); + } + // + buffer = saved + message; gIMMgr->addMessage( @@ -3380,6 +3398,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // [/SL:KB] chat.mText = message; + // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground (notification on receipt of Task IM) + if ((chat.mFromID != gAgent.getID() || chat.mFromName == SYSTEM_FROM) && FSKeywords::getInstance()->chatContainsKeyword(chat, true)) + { + FSKeywords::notify(chat); + } + // + // Note: lie to Nearby Chat, pretending that this is NOT an IM, because // IMs from obejcts don't open IM sessions. // [FS communication UI] @@ -3473,6 +3498,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } else { + + // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground (notification on receipt of IM) + chat.mText = message; + if ((chat.mFromID != gAgent.getID() || chat.mFromName == SYSTEM_FROM) && FSKeywords::getInstance()->chatContainsKeyword(chat, false)) + { + FSKeywords::notify(chat); + } + // + // standard message, not from system std::string saved; if(offline == IM_OFFLINE) @@ -4532,6 +4566,13 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) LLSD args; chat.mOwnerID = owner_id; + // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground (notification on receipt of local chat) + if ((chat.mFromID != gAgent.getID() || chat.mFromName == SYSTEM_FROM) && FSKeywords::getInstance()->chatContainsKeyword(chat, true)) + { + FSKeywords::notify(chat); + } + // + if (gSavedSettings.getBOOL("TranslateChat") && chat.mSourceType != CHAT_SOURCE_SYSTEM) { if (chat.mChatStyle == CHAT_STYLE_IRC)