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.cpp405
1 files changed, 209 insertions, 196 deletions
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index 73c00c1d82..6e58be8174 100644
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -2,30 +2,25 @@
* @file llchatbar.cpp
* @brief LLChatBar class implementation
*
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -47,7 +42,6 @@
#include "llcombobox.h"
#include "llcommandhandler.h" // secondlife:///app/chat/ support
#include "llviewercontrol.h"
-#include "llfloaterchat.h"
#include "llgesturemgr.h"
#include "llkeyboard.h"
#include "lllineeditor.h"
@@ -65,8 +59,8 @@
#include "llmultigesture.h"
#include "llui.h"
#include "llviewermenu.h"
-#include "llvieweruictrlfactory.h"
-
+#include "lluictrlfactory.h"
+#include "llbottomtray.h"
//
// Globals
@@ -75,11 +69,6 @@ const F32 AGENT_TYPING_TIMEOUT = 5.f; // seconds
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
{
public:
@@ -91,12 +80,14 @@ private:
};
+extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
+
//
// Functions
//
LLChatBar::LLChatBar()
-: LLPanel("", LLRect(), BORDER_NO),
+: LLPanel(),
mInputEditor(NULL),
mGestureLabelTimer(),
mLastSpecialChatChannel(0),
@@ -105,15 +96,12 @@ LLChatBar::LLChatBar()
mObserver(NULL)
{
setIsChrome(TRUE);
-
- #if !LL_RELEASE_FOR_DOWNLOAD
- childDisplayNotFound();
-#endif
}
LLChatBar::~LLChatBar()
{
+ LLGestureMgr::instance().removeObserver(mObserver);
delete mObserver;
mObserver = NULL;
// LLView destructor cleans up children
@@ -121,33 +109,25 @@ LLChatBar::~LLChatBar()
BOOL LLChatBar::postBuild()
{
- childSetAction("History", toggleChatHistory, this);
- childSetCommitCallback("Say", onClickSay, this);
+ getChild<LLUICtrl>("Say")->setCommitCallback(boost::bind(&LLChatBar::onClickSay, this, _1));
+ // * NOTE: mantipov: getChild with default parameters returns dummy widget.
+ // Seems this class will be completle removed
// attempt to bind to an existing combo box named gesture
- setGestureCombo(LLUICtrlFactory::getComboBoxByName(this, "Gesture"));
+ setGestureCombo(findChild<LLComboBox>( "Gesture"));
- LLButton * sayp = getChild<LLButton>("Say");
- if(sayp)
- {
- setDefaultBtn(sayp);
- }
+ mInputEditor = getChild<LLLineEditor>("Chat Editor");
+ mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke, this);
+ mInputEditor->setFocusLostCallback(boost::bind(&LLChatBar::onInputEditorFocusLost));
+ mInputEditor->setFocusReceivedCallback(boost::bind(&LLChatBar::onInputEditorGainFocus));
+ mInputEditor->setCommitOnFocusLost( FALSE );
+ mInputEditor->setRevertOnEsc( FALSE );
+ mInputEditor->setIgnoreTab(TRUE);
+ mInputEditor->setPassDelete(TRUE);
+ mInputEditor->setReplaceNewlinesWithSpaces(FALSE);
- mInputEditor = LLUICtrlFactory::getLineEditorByName(this, "Chat Editor");
- if (mInputEditor)
- {
- mInputEditor->setCallbackUserData(this);
- mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke);
- mInputEditor->setFocusLostCallback(&onInputEditorFocusLost, this);
- mInputEditor->setFocusReceivedCallback( &onInputEditorGainFocus, this );
- mInputEditor->setCommitOnFocusLost( FALSE );
- mInputEditor->setRevertOnEsc( FALSE );
- mInputEditor->setIgnoreTab(TRUE);
- mInputEditor->setPassDelete(TRUE);
-
- mInputEditor->setMaxTextLength(1023);
- mInputEditor->setEnableLineHistory(TRUE);
- }
+ mInputEditor->setMaxTextLength(DB_CHAT_MSG_STR_LEN);
+ mInputEditor->setEnableLineHistory(TRUE);
mIsBuilt = TRUE;
@@ -159,36 +139,33 @@ BOOL LLChatBar::postBuild()
//-----------------------------------------------------------------------
// virtual
-BOOL LLChatBar::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() && !called_from_parent)
+ if( KEY_RETURN == key )
{
- // ALT-RETURN is reserved for windowed/fullscreen toggle
- if( KEY_RETURN == key )
+ if (mask == MASK_CONTROL)
{
- if (mask == MASK_CONTROL)
- {
- // shout
- sendChat(CHAT_TYPE_SHOUT);
- handled = TRUE;
- }
- else if (mask == MASK_NONE)
- {
- // say
- sendChat( CHAT_TYPE_NORMAL );
- handled = TRUE;
- }
+ // shout
+ sendChat(CHAT_TYPE_SHOUT);
+ handled = TRUE;
}
- // only do this in main chatbar
- else if ( KEY_ESCAPE == key && gChatBar == this)
+ else if (mask == MASK_NONE)
{
- stopChat();
-
+ // say
+ sendChat( CHAT_TYPE_NORMAL );
handled = TRUE;
}
}
+ // only do this in main chatbar
+ else if ( KEY_ESCAPE == key && gChatBar == this)
+ {
+ stopChat();
+
+ handled = TRUE;
+ }
+
return handled;
}
@@ -208,29 +185,26 @@ void LLChatBar::refresh()
gAgent.stopTyping();
}
- childSetValue("History", LLFloaterChat::instanceVisible(LLSD()));
-
- childSetEnabled("Say", mInputEditor->getText().size() > 0);
- childSetEnabled("Shout", mInputEditor->getText().size() > 0);
+ getChildView("Say")->setEnabled(mInputEditor->getText().size() > 0);
}
void LLChatBar::refreshGestures()
{
- LLCtrlListInterface* gestures = mGestureCombo ? mGestureCombo->getListInterface() : NULL;
- if (mGestureCombo && gestures)
+ if (mGestureCombo)
{
//store current selection so we can maintain it
- LLString cur_gesture = mGestureCombo->getValue().asString();
- gestures->selectFirstItem();
- LLString label = mGestureCombo->getValue().asString();;
+ std::string cur_gesture = mGestureCombo->getValue().asString();
+ mGestureCombo->selectFirstItem();
+ std::string label = mGestureCombo->getValue().asString();;
// clear
- gestures->clearRows();
+ mGestureCombo->clearRows();
// collect list of unique gestures
std::map <std::string, BOOL> unique;
- LLGestureManager::item_map_t::iterator it;
- for (it = gGestureManager.mActive.begin(); it != gGestureManager.mActive.end(); ++it)
+ LLGestureMgr::item_map_t::const_iterator it;
+ const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures();
+ for (it = active_gestures.begin(); it != active_gestures.end(); ++it)
{
LLMultiGesture* gesture = (*it).second;
if (gesture)
@@ -242,24 +216,25 @@ void LLChatBar::refreshGestures()
}
}
- // ad unique gestures
+ // add unique gestures
std::map <std::string, BOOL>::iterator it2;
for (it2 = unique.begin(); it2 != unique.end(); ++it2)
{
- gestures->addSimpleElement((*it2).first);
+ mGestureCombo->addSimpleElement((*it2).first);
}
- gestures->sortByColumn(0, TRUE);
- // Insert label after sorting
- gestures->addSimpleElement(label, ADD_TOP);
+ mGestureCombo->sortByName();
+ // Insert label after sorting, at top, with separator below it
+ mGestureCombo->addSeparator(ADD_TOP);
+ mGestureCombo->addSimpleElement(getString("gesture_label"), ADD_TOP);
if (!cur_gesture.empty())
- {
- gestures->selectByValue(LLSD(cur_gesture));
+ {
+ mGestureCombo->selectByValue(LLSD(cur_gesture));
}
else
{
- gestures->selectFirstItem();
+ mGestureCombo->selectFirstItem();
}
}
}
@@ -300,9 +275,9 @@ BOOL LLChatBar::inputEditorHasFocus()
return mInputEditor && mInputEditor->hasFocus();
}
-LLString LLChatBar::getCurrentChat()
+std::string LLChatBar::getCurrentChat()
{
- return mInputEditor ? mInputEditor->getText() : LLString::null;
+ return mInputEditor ? mInputEditor->getText() : LLStringUtil::null;
}
void LLChatBar::setGestureCombo(LLComboBox* combo)
@@ -310,12 +285,11 @@ void LLChatBar::setGestureCombo(LLComboBox* combo)
mGestureCombo = combo;
if (mGestureCombo)
{
- mGestureCombo->setCommitCallback(onCommitGesture);
- mGestureCombo->setCallbackUserData(this);
+ mGestureCombo->setCommitCallback(boost::bind(&LLChatBar::onCommitGesture, this, _1));
// now register observer since we have a place to put the results
mObserver = new LLChatBarGestureObserver(this);
- gGestureManager.addObserver(mObserver);
+ LLGestureMgr::instance().addObserver(mObserver);
// refresh list from current active gestures
refreshGestures();
@@ -345,12 +319,12 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel)
S32 pos = 0;
// Copy the channel number into a string
- llwchar channel_string[64];
+ LLWString channel_string;
llwchar c;
do
{
c = mesg[pos+1];
- channel_string[pos] = c;
+ channel_string.push_back(c);
pos++;
}
while(c && pos < 64 && LLStringOps::isDigit(c));
@@ -363,7 +337,6 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel)
c = mesg[pos+1];
pos++;
}
-
mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10);
*channel = mLastSpecialChatChannel;
@@ -380,40 +353,41 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel)
void LLChatBar::sendChat( EChatType type )
{
- LLWString text;
- if (mInputEditor) text = mInputEditor->getWText();
- LLWString::trim(text);
-
- if (!text.empty())
+ if (mInputEditor)
{
- // store sent line in history, duplicates will get filtered
- if (mInputEditor) mInputEditor->updateHistory();
- // Check if this is destined for another channel
- S32 channel = 0;
- stripChannelNumber(text, &channel);
-
- std::string utf8text = wstring_to_utf8str(text);
- // Try to trigger a gesture, if not chat to a script.
- std::string utf8_revised_text;
- if (0 == channel)
- {
- // discard returned "found" boolean
- gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text);
- }
- else
+ LLWString text = mInputEditor->getConvertedText();
+ if (!text.empty())
{
- utf8_revised_text = utf8text;
- }
+ // store sent line in history, duplicates will get filtered
+ if (mInputEditor) mInputEditor->updateHistory();
+ // Check if this is destined for another channel
+ S32 channel = 0;
+ stripChannelNumber(text, &channel);
+
+ std::string utf8text = wstring_to_utf8str(text);
+ // Try to trigger a gesture, if not chat to a script.
+ std::string utf8_revised_text;
+ if (0 == channel)
+ {
+ // discard returned "found" boolean
+ LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
+ }
+ else
+ {
+ utf8_revised_text = utf8text;
+ }
- utf8_revised_text = utf8str_trim(utf8_revised_text);
+ utf8_revised_text = utf8str_trim(utf8_revised_text);
- if (!utf8_revised_text.empty())
- {
- // Chat with animation
- sendChatFromViewer(utf8_revised_text, type, TRUE);
+ if (!utf8_revised_text.empty())
+ {
+ // Chat with animation
+ sendChatFromViewer(utf8_revised_text, type, TRUE);
+ }
}
}
- childSetValue("Chat Editor", LLString::null);
+
+ getChild<LLUICtrl>("Chat Editor")->setValue(LLStringUtil::null);
gAgent.stopTyping();
@@ -433,17 +407,26 @@ void LLChatBar::sendChat( EChatType type )
// static
void LLChatBar::startChat(const char* line)
{
- gChatBar->setVisible(TRUE);
- gChatBar->setKeyboardFocus(TRUE);
- gSavedSettings.setBOOL("ChatVisible", TRUE);
-
- if (line && gChatBar->mInputEditor)
- {
- std::string line_string(line);
- gChatBar->mInputEditor->setText(line_string);
- }
- // always move cursor to end so users don't obliterate chat when accidentally hitting WASD
- gChatBar->mInputEditor->setCursorToEnd();
+ //TODO* remove DUMMY chat
+ //if(gBottomTray && gBottomTray->getChatBox())
+ //{
+ // gBottomTray->setVisible(TRUE);
+ // gBottomTray->getChatBox()->setFocus(TRUE);
+ //}
+
+ // *TODO Vadim: Why was this code commented out?
+
+// gChatBar->setVisible(TRUE);
+// gChatBar->setKeyboardFocus(TRUE);
+// gSavedSettings.setBOOL("ChatVisible", TRUE);
+//
+// if (line && gChatBar->mInputEditor)
+// {
+// std::string line_string(line);
+// gChatBar->mInputEditor->setText(line_string);
+// }
+// // always move cursor to end so users don't obliterate chat when accidentally hitting WASD
+// gChatBar->mInputEditor->setCursorToEnd();
}
@@ -451,21 +434,29 @@ void LLChatBar::startChat(const char* line)
// static
void LLChatBar::stopChat()
{
- // In simple UI mode, we never release focus from the chat bar
- gChatBar->setKeyboardFocus(FALSE);
-
- // If we typed a movement key and pressed return during the
- // same frame, the keyboard handlers will see the key as having
- // gone down this frame and try to move the avatar.
- gKeyboard->resetKeys();
- gKeyboard->resetMaskKeys();
-
- // stop typing animation
- gAgent.stopTyping();
-
- // hide chat bar so it doesn't grab focus back
- gChatBar->setVisible(FALSE);
- gSavedSettings.setBOOL("ChatVisible", FALSE);
+ //TODO* remove DUMMY chat
+ //if(gBottomTray && gBottomTray->getChatBox())
+ ///{
+ // gBottomTray->getChatBox()->setFocus(FALSE);
+ //}
+
+ // *TODO Vadim: Why was this code commented out?
+
+// // In simple UI mode, we never release focus from the chat bar
+// gChatBar->setKeyboardFocus(FALSE);
+//
+// // If we typed a movement key and pressed return during the
+// // same frame, the keyboard handlers will see the key as having
+// // gone down this frame and try to move the avatar.
+// gKeyboard->resetKeys();
+// gKeyboard->resetMaskKeys();
+//
+// // stop typing animation
+// gAgent.stopTyping();
+//
+// // hide chat bar so it doesn't grab focus back
+// gChatBar->setVisible(FALSE);
+// gSavedSettings.setBOOL("ChatVisible", FALSE);
}
// static
@@ -478,7 +469,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
// Can't trim the end, because that will cause autocompletion
// to eat trailing spaces that might be part of a gesture.
- LLWString::trimHead(raw_text);
+ LLWStringUtil::trimHead(raw_text);
S32 length = raw_text.length();
@@ -499,7 +490,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
{
// the selection will already be deleted, but we need to trim
// off the character before
- LLString new_text = raw_text.substr(0, length-1);
+ std::string new_text = raw_text.substr(0, length-1);
self->mInputEditor->setText( new_text );
self->mInputEditor->setCursorToEnd();
length = length - 1;
@@ -518,11 +509,12 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
std::string utf8_trigger = wstring_to_utf8str(raw_text);
std::string utf8_out_str(utf8_trigger);
- if (gGestureManager.matchPrefix(utf8_trigger, &utf8_out_str))
+ if (LLGestureMgr::instance().matchPrefix(utf8_trigger, &utf8_out_str))
{
if (self->mInputEditor)
{
- self->mInputEditor->setText(utf8_out_str);
+ std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size());
+ self->mInputEditor->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
S32 outlength = self->mInputEditor->getLength(); // in characters
// Select to end of line, starting from the character
@@ -539,30 +531,31 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
}
// static
-void LLChatBar::onInputEditorFocusLost( LLFocusableElement* caller, void* userdata)
+void LLChatBar::onInputEditorFocusLost()
{
// stop typing animation
gAgent.stopTyping();
}
// static
-void LLChatBar::onInputEditorGainFocus( LLFocusableElement* caller, void* userdata )
+void LLChatBar::onInputEditorGainFocus()
{
- LLFloaterChat::setHistoryCursorAndScrollToEnd();
+ //LLFloaterChat::setHistoryCursorAndScrollToEnd();
}
-// static
-void LLChatBar::onClickSay( LLUICtrl* ctrl, void* userdata )
+void LLChatBar::onClickSay( LLUICtrl* ctrl )
{
- LLChatBar* self = (LLChatBar*) userdata;
- if (ctrl->getValue().asString() == "shout")
+ std::string cmd = ctrl->getValue().asString();
+ e_chat_type chat_type = CHAT_TYPE_NORMAL;
+ if (cmd == "shout")
{
- self->sendChat( CHAT_TYPE_SHOUT );
+ chat_type = CHAT_TYPE_SHOUT;
}
- else
+ else if (cmd == "whisper")
{
- self->sendChat( CHAT_TYPE_NORMAL );
+ chat_type = CHAT_TYPE_WHISPER;
}
+ sendChat(chat_type);
}
void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate)
@@ -572,12 +565,20 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type,
void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate)
{
+ // as soon as we say something, we no longer care about teaching the user
+ // how to chat
+ gWarningSettings.setBOOL("FirstOtherChatBeforeUser", FALSE);
+
// Look for "/20 foo" channel chats.
S32 channel = 0;
LLWString out_text = stripChannelNumber(wtext, &channel);
std::string utf8_out_text = wstring_to_utf8str(out_text);
- std::string utf8_text = wstring_to_utf8str(wtext);
+ if (!utf8_out_text.empty())
+ {
+ utf8_out_text = utf8str_truncate(utf8_out_text, MAX_MSG_STR_LEN);
+ }
+ std::string utf8_text = wstring_to_utf8str(wtext);
utf8_text = utf8str_trim(utf8_text);
if (!utf8_text.empty())
{
@@ -618,7 +619,7 @@ 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;
@@ -633,15 +634,13 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32
gAgent.sendReliableMessage();
- gViewerStats->incStat(LLViewerStats::ST_CHAT_COUNT);
+ LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
}
+*/
-
-// static
-void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data)
+void LLChatBar::onCommitGesture(LLUICtrl* ctrl)
{
- LLChatBar* self = (LLChatBar*)data;
- LLCtrlListInterface* gestures = self->mGestureCombo ? self->mGestureCombo->getListInterface() : NULL;
+ LLCtrlListInterface* gestures = mGestureCombo ? mGestureCombo->getListInterface() : NULL;
if (gestures)
{
S32 index = gestures->getFirstSelectedIndex();
@@ -655,45 +654,59 @@ void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data)
// substitution and logging.
std::string text(trigger);
std::string revised_text;
- gGestureManager.triggerAndReviseString(text, &revised_text);
+ LLGestureMgr::instance().triggerAndReviseString(text, &revised_text);
revised_text = utf8str_trim(revised_text);
if (!revised_text.empty())
{
// Don't play nodding animation
- self->sendChatFromViewer(revised_text, CHAT_TYPE_NORMAL, FALSE);
+ sendChatFromViewer(revised_text, CHAT_TYPE_NORMAL, FALSE);
}
}
- self->mGestureLabelTimer.start();
- if (self->mGestureCombo != NULL)
+ mGestureLabelTimer.start();
+ if (mGestureCombo != NULL)
{
// free focus back to chat bar
- self->mGestureCombo->setFocus(FALSE);
+ mGestureCombo->setFocus(FALSE);
}
}
-void toggleChatHistory(void* user_data)
-{
- LLFloaterChat::toggleInstance(LLSD());
-}
-
-
class LLChatHandler : public LLCommandHandler
{
public:
// not allowed from outside the app
- LLChatHandler() : LLCommandHandler("chat", false) { }
+ LLChatHandler() : LLCommandHandler("chat", UNTRUSTED_BLOCK) { }
// Your code here
- bool handle(const LLSD& tokens, const LLSD& queryMap)
+ bool handle(const LLSD& tokens, const LLSD& query_map,
+ LLMediaCtrl* web)
{
- if (tokens.size() < 2) return false;
+ bool retval = false;
+ // Need at least 2 tokens to have a valid message.
+ if (tokens.size() < 2)
+ {
+ retval = false;
+ }
+ else
+ {
S32 channel = tokens[0].asInteger();
+ // VWR-19499 Restrict function to chat channels greater than 0.
+ if ((channel > 0) && (channel < 2147483647))
+ {
+ retval = true;
+ // Say mesg on channel
std::string mesg = tokens[1].asString();
send_chat_from_viewer(mesg, CHAT_TYPE_NORMAL, channel);
- return true;
+ }
+ else
+ {
+ retval = false;
+ // Tell us this is an unsupported SLurl.
+ }
+ }
+ return retval;
}
};
// Creating the object registers with the dispatcher.
-LLChatHandler gChatHandler;
+//LLChatHandler gChatHandler;