From b91ac7ae99c4034b31a07a8074f2e14d64790976 Mon Sep 17 00:00:00 2001 From: Dave SIMmONs Date: Tue, 15 Mar 2011 16:06:38 -0700 Subject: ER-614 : Add lleventhost API to send chat messages. Reviewed by Kelly --- indra/newview/llnearbychatbarlistener.cpp | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 indra/newview/llnearbychatbarlistener.cpp (limited to 'indra/newview/llnearbychatbarlistener.cpp') diff --git a/indra/newview/llnearbychatbarlistener.cpp b/indra/newview/llnearbychatbarlistener.cpp new file mode 100644 index 0000000000..c30e89c35e --- /dev/null +++ b/indra/newview/llnearbychatbarlistener.cpp @@ -0,0 +1,87 @@ +/** + * @file llnearbychatbarlistener.cpp + * @author Dave Simmons + * @date 2011-03-15 + * @brief Implementation for LLNearbyChatBarListener. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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. + * + * 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. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llnearbychatbarlistener.h" + +#include "llagent.h" +#include "llchat.h" + + +// Ugly glue for llnearbychatbar.cpp utility function. Avoids pulling in a bunch of UI +// definitions. Also needs to get cleaned up from llchatbar.cpp +extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); + + +LLNearbyChatBarListener::LLNearbyChatBarListener(LLNearbyChatBar & chatbar) + : LLEventAPI("LLChatBar", + "LLChatBar listener to (e.g.) sendChat, etc."), + mChatbar(chatbar) +{ + add("sendChat", + "Send chat to the simulator:\n" + "[\"message\"] chat message text [required]\n" + "[\"channel\"] chat channel number [default = 0]\n" + "[\"type\"] chat type \"whisper\", \"normal\", \"shout\" [default = \"normal\"]", + &LLNearbyChatBarListener::sendChat); +} + + +// "sendChat" command +void LLNearbyChatBarListener::sendChat(LLSD const & chat_data) const +{ + // Extract the data + std::string chat_text = chat_data["message"].asString(); + + S32 channel = 0; + if (chat_data.has("channel")) + { + channel = chat_data["channel"].asInteger(); + if (channel < 0 || channel >= 2147483647) + { // Use 0 up to (but not including) DEBUG_CHANNEL (wtf isn't that defined??) + channel = 0; + } + } + + EChatType type_o_chat = CHAT_TYPE_NORMAL; + if (chat_data.has("type")) + { + std::string type_string = chat_data["type"].asString(); + if (type_string == "whisper") + { + type_o_chat = CHAT_TYPE_WHISPER; + } + else if (type_string == "shout") + { + type_o_chat = CHAT_TYPE_SHOUT; + } + } + send_chat_from_viewer(chat_text, type_o_chat, channel); +} + -- cgit v1.2.3 From acb763878543f2a25131b40646559feb7405c4fa Mon Sep 17 00:00:00 2001 From: Dave SIMmONs Date: Wed, 16 Mar 2011 13:20:18 -0700 Subject: ER-614: Add lleventhost API to send chat messages. Cleanup code a bit, now invoking proper routine to make viewer do chat animations. Commented out some un-used chat related code in llchatbar.cpp and llnotificationmanager.h. Also re-named a singleton class in llnearbychatbar.cpp so we don't have multiple LLChatHandler classes. Reviewed by Kelly --- indra/newview/llnearbychatbarlistener.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'indra/newview/llnearbychatbarlistener.cpp') diff --git a/indra/newview/llnearbychatbarlistener.cpp b/indra/newview/llnearbychatbarlistener.cpp index c30e89c35e..99286d972b 100644 --- a/indra/newview/llnearbychatbarlistener.cpp +++ b/indra/newview/llnearbychatbarlistener.cpp @@ -29,15 +29,12 @@ #include "llviewerprecompiledheaders.h" #include "llnearbychatbarlistener.h" +#include "llnearbychatbar.h" #include "llagent.h" #include "llchat.h" -// Ugly glue for llnearbychatbar.cpp utility function. Avoids pulling in a bunch of UI -// definitions. Also needs to get cleaned up from llchatbar.cpp -extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); - LLNearbyChatBarListener::LLNearbyChatBarListener(LLNearbyChatBar & chatbar) : LLEventAPI("LLChatBar", @@ -82,6 +79,22 @@ void LLNearbyChatBarListener::sendChat(LLSD const & chat_data) const type_o_chat = CHAT_TYPE_SHOUT; } } - send_chat_from_viewer(chat_text, type_o_chat, channel); + + // Have to prepend /42 style channel numbers + std::string chat_to_send; + if (channel == 0) + { + chat_to_send = chat_text; + } + else + { + chat_to_send += "/"; + chat_to_send += chat_data["channel"].asString(); + chat_to_send += " "; + chat_to_send += chat_text; + } + + // Send it as if it was typed in + mChatbar.sendChatFromViewer(chat_to_send, type_o_chat, (BOOL)(channel == 0)); } -- cgit v1.2.3 From e74e0c8da5ecdb107f89bd33de81397ac41f5a5b Mon Sep 17 00:00:00 2001 From: Dave SIMmONs Date: Tue, 5 Apr 2011 09:07:11 -0700 Subject: ER-671 : Add LLRegionSayTo() LSL function. Added new chat type for direct messages to match server code, use light orange for text. Reviewed by Kelly. --- indra/newview/llnearbychatbarlistener.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llnearbychatbarlistener.cpp') diff --git a/indra/newview/llnearbychatbarlistener.cpp b/indra/newview/llnearbychatbarlistener.cpp index 99286d972b..0d64eaed47 100644 --- a/indra/newview/llnearbychatbarlistener.cpp +++ b/indra/newview/llnearbychatbarlistener.cpp @@ -60,8 +60,8 @@ void LLNearbyChatBarListener::sendChat(LLSD const & chat_data) const if (chat_data.has("channel")) { channel = chat_data["channel"].asInteger(); - if (channel < 0 || channel >= 2147483647) - { // Use 0 up to (but not including) DEBUG_CHANNEL (wtf isn't that defined??) + if (channel < 0 || channel >= CHAT_CHANNEL_DEBUG) + { // Use 0 up to (but not including) CHAT_CHANNEL_DEBUG channel = 0; } } -- cgit v1.2.3