diff options
| author | Dave SIMmONs <simon@lindenlab.com> | 2011-03-15 16:06:38 -0700 | 
|---|---|---|
| committer | Dave SIMmONs <simon@lindenlab.com> | 2011-03-15 16:06:38 -0700 | 
| commit | b91ac7ae99c4034b31a07a8074f2e14d64790976 (patch) | |
| tree | 0413f7b71f1a229eb45963152061ff99cdcdaa4f | |
| parent | 57ac771b154d7722e4774b40a607a11f3286f472 (diff) | |
ER-614 : Add lleventhost API to send chat messages.  Reviewed by Kelly
| -rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | indra/newview/llbottomtray.cpp | 3 | ||||
| -rw-r--r-- | indra/newview/llbottomtray.h | 4 | ||||
| -rw-r--r-- | indra/newview/llnearbychatbarlistener.cpp | 87 | ||||
| -rw-r--r-- | indra/newview/llnearbychatbarlistener.h | 50 | 
5 files changed, 146 insertions, 0 deletions
| diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 11bebf04ef..c835891cbc 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -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 diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index d8ec4b605c..c55c72e2a4 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -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"); diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 04e5f5e9e0..83a33845bf 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -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 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);
 +}
 +
 diff --git a/indra/newview/llnearbychatbarlistener.h b/indra/newview/llnearbychatbarlistener.h new file mode 100644 index 0000000000..13e4e5990c --- /dev/null +++ b/indra/newview/llnearbychatbarlistener.h @@ -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
 +
 | 
