summaryrefslogtreecommitdiff
path: root/indra/newview/llchatbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchatbar.cpp')
-rw-r--r--indra/newview/llchatbar.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index 239d974bc3..73c00c1d82 100644
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -45,6 +45,7 @@
#include "llagent.h"
#include "llbutton.h"
#include "llcombobox.h"
+#include "llcommandhandler.h" // secondlife:///app/chat/ support
#include "llviewercontrol.h"
#include "llfloaterchat.h"
#include "llgesturemgr.h"
@@ -76,6 +77,7 @@ LLChatBar *gChatBar = NULL;
// legacy calllback glue
void toggleChatHistory(void* user_data);
+void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
class LLChatBarGestureObserver : public LLGestureManagerObserver
@@ -570,8 +572,6 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type,
void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate)
{
- LLMessageSystem* msg = gMessageSystem;
-
// Look for "/20 foo" channel chats.
S32 channel = 0;
LLWString out_text = stripChannelNumber(wtext, &channel);
@@ -616,6 +616,12 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
}
}
+ send_chat_from_viewer(utf8_out_text, type, channel);
+}
+
+void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel)
+{
+ LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ChatFromViewer);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
@@ -670,3 +676,24 @@ void toggleChatHistory(void* user_data)
{
LLFloaterChat::toggleInstance(LLSD());
}
+
+
+class LLChatHandler : public LLCommandHandler
+{
+public:
+ // not allowed from outside the app
+ LLChatHandler() : LLCommandHandler("chat", false) { }
+
+ // Your code here
+ bool handle(const LLSD& tokens, const LLSD& queryMap)
+ {
+ if (tokens.size() < 2) return false;
+ S32 channel = tokens[0].asInteger();
+ std::string mesg = tokens[1].asString();
+ send_chat_from_viewer(mesg, CHAT_TYPE_NORMAL, channel);
+ return true;
+ }
+};
+
+// Creating the object registers with the dispatcher.
+LLChatHandler gChatHandler;