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")
master
PanteraPolnocy 2013-09-04 09:15:08 +02:00
parent b70db2f5f5
commit e1ac33104f
4 changed files with 65 additions and 16 deletions

View File

@ -4,6 +4,7 @@
#include "fskeywords.h"
#include "llui.h"
#include "llviewercontrol.h"
#include "growlmanager.h" // <FS:PP> FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground
#include <boost/regex.hpp>
//#include <boost/algorithm/string/find.hpp> //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;
}
// <FS:PP> 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<bool> 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");
}
// </FS:PP>

View File

@ -16,6 +16,7 @@ public:
void updateKeywords();
bool chatContainsKeyword(const LLChat& chat, bool is_local);
void static notify(const LLChat& chat); // <FS:PP> FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground
private:
std::vector<std::string> mWordList;

View File

@ -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<bool> sFSKeywordChangeColor(gSavedPerAccountSettings, "FSKeywordChangeColor");
if (sFSKeywordChangeColor)
{

View File

@ -154,6 +154,7 @@ const static boost::regex NEWLINES("\\n{1}");
#include "fscommon.h"
#include "fslightshare.h" // <FS:CR> FIRE-5118 - Lightshare support
#include "fsradar.h"
#include "fskeywords.h" // <FS:PP> 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;
// <FS:PP> 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);
}
// </FS:PP>
// 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);
// <FS:PP> 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);
}
// </FS:PP>
buffer = saved + message;
gIMMgr->addMessage(
@ -3380,6 +3398,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// [/SL:KB]
chat.mText = message;
// <FS:PP> 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);
}
// </FS:PP>
// Note: lie to Nearby Chat, pretending that this is NOT an IM, because
// IMs from obejcts don't open IM sessions.
// <FS:Ansariel> [FS communication UI]
@ -3473,6 +3498,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
}
else
{
// <FS:PP> 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);
}
// </FS:PP>
// 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;
// <FS:PP> 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);
}
// </FS:PP>
if (gSavedSettings.getBOOL("TranslateChat") && chat.mSourceType != CHAT_SOURCE_SYSTEM)
{
if (chat.mChatStyle == CHAT_STYLE_IRC)