diff --git a/indra/newview/fsfloaterim.cpp b/indra/newview/fsfloaterim.cpp index d63c509230..e0d34575f2 100644 --- a/indra/newview/fsfloaterim.cpp +++ b/indra/newview/fsfloaterim.cpp @@ -37,6 +37,7 @@ #include "fsdata.h" #include "fsfloaterimcontainer.h" // to replace separate IM Floaters with multifloater container #include "fsfloaternearbychat.h" +#include "fsnearbychathub.h" // FIRE-24133 - Redirect chat channel messages #include "fspanelimcontrolpanel.h" #include "llagent.h" #include "llappviewer.h" @@ -77,6 +78,8 @@ #include "rlvactions.h" #include "rlvhandler.h" +#include // FIRE-24133 - Redirect chat channel messages + const F32 ME_TYPING_TIMEOUT = 4.0f; const F32 OTHER_TYPING_TIMEOUT = 9.0f; const F32 NAME_REFRESH_TIMEOUT = 300.0f; @@ -352,6 +355,32 @@ void FSFloaterIM::onVisibilityChange(BOOL new_visibility) } } +// FIRE-24133 - Redirect chat channel messages +void FSFloaterIM::onChatChannelTextSend(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option == 2) // Discard message + { + return; + } + + LLSD payload = notification["payload"]; + std::string text = payload["MESSAGE"]; + + if (option == 0) // Send to Channel + { + // always send the chat as CHAT_TYPE_NORMAL since we don't have any other information + FSNearbyChat::instance().sendChatFromViewer(text, CHAT_TYPE_NORMAL, false); + } + else if (option == 1) // Send to IM + { + // pass the message on to the IM unaltered + sendMsg(text); + } +} +// FIRE-24133 - Redirect chat channel messages + + void FSFloaterIM::sendMsgFromInputEditor(EChatType type) { if (gAgent.isGodlike() @@ -381,7 +410,36 @@ void FSFloaterIM::sendMsgFromInputEditor(EChatType type) // Truncate and convert to UTF8 for transport std::string utf8_text = wstring_to_utf8str(text); - + + // FIRE-24133 - Redirect chat channel messages + if (boost::regex_match(utf8_text.c_str(), boost::regex("/-{0,1}[0-9].*"))) + { + // message starts with a / and a valid channel number, so ask the user if they really want + // to send this to an IM instead of a chat channel + std::string sample_text = utf8_text; + if (sample_text.size() > 30) + { + // shorten the sample text for the dialog + sample_text.resize(26); + sample_text += " ..."; + } + + LLSD args; + args["MESSAGE"] = sample_text; + + LLSD payload; + payload["MESSAGE"] = utf8_text; + + LLNotificationsUtil::add("SendToChannelInIM", args, payload, boost::bind(&FSFloaterIM::onChatChannelTextSend, this, _1, _2)); + + // clean out the text box and typing indicator, which we wouldn't reach otherwise + mInputEditor->setText(LLStringUtil::null); + setTyping(false); + + return; + } + // FIRE-24133 - Redirect chat channel messages + // Convert OOC and MU* style poses utf8_text = FSCommon::applyAutoCloseOoc(utf8_text); utf8_text = FSCommon::applyMuPose(utf8_text); diff --git a/indra/newview/fsfloaterim.h b/indra/newview/fsfloaterim.h index d70bac8155..27d34c16c5 100644 --- a/indra/newview/fsfloaterim.h +++ b/indra/newview/fsfloaterim.h @@ -172,6 +172,7 @@ protected: LLButton* mSysinfoButton; // support sysinfo button -Zi + void onChatChannelTextSend(const LLSD& notification, const LLSD& response); // FIRE-24133 - Redirect chat channel messages BOOL enableViewerVersionCallback(const LLSD& notification,const LLSD& response); // Viewer version popup void reshapeFloater(bool collapse); void reshapeChatLayoutPanel(); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index be51a1d4f4..90723ea680 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -13624,4 +13624,34 @@ Firestorm Animation Overrider: [AO_MESSAGE] name="notifyignore"/> + + +It looks like you want to send a command to a chat channel instead of an instant message: + +[MESSAGE] + +Please choose one of the options below to proceed: +
+