From 6ffbf0d0498690ce9560ea8b649f5e3c00737c53 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 6 Mar 2015 17:11:21 +0100 Subject: [PATCH] More Growl/Keyword refactoring: * Remove the Growl keyword alert from LLViewerChat::getChatColor() again - this still might get called up to 3 times per message * Move the Growl keyword alert back into FSKeywords::notify() where it belongs * Explicitly wire up Growl keyword alerts in radar notifications in FSRadar::radarAlertMsg() If there are particular system messages that should be checked for keywords as well, wire them up in the correct place instead of using LLViewerChat::getChatColor() that will result in an incorrect behavior of * not playing the keyword alert sound * being checked only at the time somebody calls LLViewerChat::getChatColor (Console output, nearby chat floater becoming visible etc.) * getting called multiple times --- indra/newview/fskeywords.cpp | 23 +++++++++++++++++++++++ indra/newview/fsradar.cpp | 6 ++++++ indra/newview/growlmanager.h | 1 + indra/newview/llviewerchat.cpp | 19 +------------------ 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/indra/newview/fskeywords.cpp b/indra/newview/fskeywords.cpp index 836eda8f68..a61b8f2690 100644 --- a/indra/newview/fskeywords.cpp +++ b/indra/newview/fskeywords.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "fskeywords.h" +#include "growlmanager.h" #include "llagent.h" #include "llchat.h" #include "llinstantmessage.h" @@ -80,6 +81,12 @@ bool FSKeywords::chatContainsKeyword(const LLChat& chat, bool is_local) static LLCachedControl sFSKeywordCaseSensitive(gSavedPerAccountSettings, "FSKeywordCaseSensitive", false); static LLCachedControl sFSKeywordMatchWholeWords(gSavedPerAccountSettings, "FSKeywordMatchWholeWords", false); + // Don't check if message is from us - unless it's a radar notification + if (chat.mFromID == gAgentID && chat.mFromName != SYSTEM_FROM) + { + return false; + } + if (!sFSKeywordOn || (is_local && !sFSKeywordInChat) || (!is_local && !sFSKeywordInIM)) @@ -130,6 +137,22 @@ void FSKeywords::notify(const LLChat& chat) { LLUI::sAudioCallback(LLUUID(gSavedSettings.getString("UISndFSKeywordSound"))); } + + static LLCachedControl FSEnableGrowl(gSavedSettings, "FSEnableGrowl"); + if (FSEnableGrowl) + { + 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, GROWL_KEYWORD_ALERT_TYPE); + } } } } diff --git a/indra/newview/fsradar.cpp b/indra/newview/fsradar.cpp index 3a0f7c2075..d571301ef0 100644 --- a/indra/newview/fsradar.cpp +++ b/indra/newview/fsradar.cpp @@ -37,6 +37,7 @@ // newview #include "fscommon.h" +#include "fskeywords.h" #include "fslslbridge.h" #include "fslslbridgerequest.h" #include "fswsassetblacklist.h" @@ -164,6 +165,11 @@ void FSRadar::radarAlertMsg(const LLUUID& agent_id, const LLAvatarName& av_name, // FS:LO FIRE-1439 - Clickable avatar names on local chat radar crossing reports LLSD args; LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); + + if (FSKeywords::getInstance()->chatContainsKeyword(chat, true)) + { + FSKeywords::notify(chat); + } } // } diff --git a/indra/newview/growlmanager.h b/indra/newview/growlmanager.h index 726093b72c..76665bbb61 100644 --- a/indra/newview/growlmanager.h +++ b/indra/newview/growlmanager.h @@ -50,6 +50,7 @@ const U64 GROWL_THROTTLE_TIME = 1000000; // Maximum spam rate (in microseconds). const F32 GROWL_THROTTLE_CLEANUP_PERIOD = 300; // How often we clean up the list (in seconds). const int GROWL_MAX_BODY_LENGTH = 255; // Arbitrary. const std::string GROWL_IM_MESSAGE_TYPE = "Instant Message received"; +const std::string GROWL_KEYWORD_ALERT_TYPE = "Keyword Alert"; class GrowlManager : public LLEventTimer { diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp index 31cfe44583..a3df6eb28e 100755 --- a/indra/newview/llviewerchat.cpp +++ b/indra/newview/llviewerchat.cpp @@ -41,7 +41,6 @@ #include "rlvhandler.h" #include "lfsimfeaturehandler.h" // Opensim -#include "growlmanager.h" // Growl include // LLViewerChat @@ -120,24 +119,8 @@ 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)) + if (FSKeywords::getInstance()->chatContainsKeyword(chat, is_local)) { - static LLCachedControl FSEnableGrowl(gSavedSettings, "FSEnableGrowl"); - if (FSEnableGrowl) - { - 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) {