ER-614 : Add lleventhost API to send chat messages. Reviewed by Kelly
parent
57ac771b15
commit
b91ac7ae99
|
|
@ -307,6 +307,7 @@ set(viewer_SOURCE_FILES
|
|||
llnearbychat.cpp
|
||||
llnearbychatbar.cpp
|
||||
llnearbychathandler.cpp
|
||||
llnearbychatbarlistener.cpp
|
||||
llnetmap.cpp
|
||||
llnotificationalerthandler.cpp
|
||||
llnotificationgrouphandler.cpp
|
||||
|
|
@ -848,6 +849,7 @@ set(viewer_HEADER_FILES
|
|||
llnearbychat.h
|
||||
llnearbychatbar.h
|
||||
llnearbychathandler.h
|
||||
llnearbychatbarlistener.h
|
||||
llnetmap.h
|
||||
llnotificationhandler.h
|
||||
llnotificationmanager.h
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "llhints.h"
|
||||
#include "llimfloater.h" // for LLIMFloater
|
||||
#include "llnearbychatbar.h"
|
||||
#include "llnearbychatbarlistener.h"
|
||||
#include "llspeakbutton.h"
|
||||
#include "llsplitbutton.h"
|
||||
#include "llsyswellwindow.h"
|
||||
|
|
@ -551,6 +552,8 @@ BOOL LLBottomTray::postBuild()
|
|||
mNearbyChatBar = findChild<LLNearbyChatBar>("chat_bar");
|
||||
LLHints::registerHintTarget("chat_bar", mNearbyChatBar->LLView::getHandle());
|
||||
|
||||
mListener.reset(new LLNearbyChatBarListener(*mNearbyChatBar));
|
||||
|
||||
mChatBarContainer = getChild<LLLayoutPanel>("chat_bar_layout_panel");
|
||||
mNearbyCharResizeHandlePanel = getChild<LLPanel>("chat_bar_resize_handle_panel");
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class LLIMChiclet;
|
|||
class LLBottomTrayLite;
|
||||
class LLLayoutPanel;
|
||||
class LLMenuGL;
|
||||
class LLNearbyChatBarListener;
|
||||
|
||||
// Build time optimization, generate once in .cpp file
|
||||
#ifndef LLBOTTOMTRAY_CPP
|
||||
|
|
@ -508,6 +509,9 @@ protected:
|
|||
* Image used to show position where dragged button will be dropped.
|
||||
*/
|
||||
LLUIImage* mImageDragIndication;
|
||||
|
||||
// We want only one LLNearbyChatBarListener object, so it's tied to this singleton
|
||||
boost::shared_ptr<LLNearbyChatBarListener> mListener;
|
||||
};
|
||||
|
||||
#endif // LL_LLBOTTOMPANEL_H
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* @file llnearbychatbarlistener.h
|
||||
* @author Dave Simmons
|
||||
* @date 2011-03-15
|
||||
* @brief Class definition 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$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LL_LLNEARBYCHATBARLISTENER_H
|
||||
#define LL_LLNEARBYCHATBARLISTENER_H
|
||||
|
||||
#include "lleventapi.h"
|
||||
|
||||
class LLSD;
|
||||
class LLNearbyChatBar;
|
||||
|
||||
class LLNearbyChatBarListener : public LLEventAPI
|
||||
{
|
||||
public:
|
||||
LLNearbyChatBarListener(LLNearbyChatBar & chatbar);
|
||||
|
||||
private:
|
||||
void sendChat(LLSD const & chat_data) const;
|
||||
|
||||
LLNearbyChatBar & mChatbar;
|
||||
};
|
||||
|
||||
#endif // LL_LLNEARBYCHATBARLISTENER_H
|
||||
|
||||
Loading…
Reference in New Issue