summaryrefslogtreecommitdiff
path: root/indra/newview/llimpanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llimpanel.cpp')
-rw-r--r--indra/newview/llimpanel.cpp316
1 files changed, 2 insertions, 314 deletions
diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index 0efe9b9849..de4faf72f5 100644
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -48,6 +48,7 @@
#include "llbutton.h"
#include "llbottomtray.h"
#include "llcallingcard.h"
+#include "llchannelmanager.h"
#include "llchat.h"
#include "llchiclet.h"
#include "llconsole.h"
@@ -81,6 +82,7 @@
#include "llhttpclient.h"
#include "llmutelist.h"
#include "llstylemap.h"
+#include "llappviewer.h"
//
// Constants
@@ -1986,318 +1988,4 @@ bool LLFloaterIMPanel::onConfirmForceCloseError(const LLSD& notification, const
}
return false;
}
-
-
-LLIMFloater::LLIMFloater(const LLUUID& session_id)
- : LLDockableFloater(NULL, session_id),
- mControlPanel(NULL),
- mSessionID(session_id),
- mLastMessageIndex(-1),
- mLastFromName(),
- mDialog(IM_NOTHING_SPECIAL),
- mHistoryEditor(NULL),
- mInputEditor(NULL),
- mPositioned(false)
-{
- LLIMModel::LLIMSession* session = get_if_there(LLIMModel::instance().sSessionsMap, mSessionID, (LLIMModel::LLIMSession*)NULL);
- if(session)
- {
- mDialog = session->mType;
- }
-
- if (mDialog == IM_NOTHING_SPECIAL)
- {
- mFactoryMap["panel_im_control_panel"] = LLCallbackMap(createPanelIMControl, this);
- }
- else
- {
- mFactoryMap["panel_im_control_panel"] = LLCallbackMap(createPanelGroupControl, this);
- }
-// LLUICtrlFactory::getInstance()->buildFloater(this, "floater_im_session.xml");
-}
-
-/* static */
-void LLIMFloater::newIMCallback(const LLSD& data){
-
- if (data["num_unread"].asInteger() > 0)
- {
- LLUUID session_id = data["session_id"].asUUID();
-
- LLIMFloater* floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
- if (floater == NULL)
- {
- llwarns << "new_im_callback for non-existent session_id " << session_id << llendl;
- return;
- }
-
- // update if visible, otherwise will be updated when opened
- if (floater->getVisible())
- {
- floater->updateMessages();
- }
- }
-}
-
-void LLIMFloater::onSendMsg( LLUICtrl* ctrl, void* userdata )
-{
- LLIMFloater* self = (LLIMFloater*) userdata;
- self->sendMsg();
-}
-
-void LLIMFloater::sendMsg()
-{
- if (!gAgent.isGodlike()
- && (mDialog == IM_NOTHING_SPECIAL)
- && mOtherParticipantUUID.isNull())
- {
- llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
- return;
- }
-
- if (mInputEditor)
- {
- LLWString text = mInputEditor->getConvertedText();
- if(!text.empty())
- {
- // Truncate and convert to UTF8 for transport
- std::string utf8_text = wstring_to_utf8str(text);
- utf8_text = utf8str_truncate(utf8_text, MAX_MSG_BUF_SIZE - 1);
-
- LLIMModel::sendMessage(utf8_text,
- mSessionID,
- mOtherParticipantUUID,
- mDialog);
-
- mInputEditor->setText(LLStringUtil::null);
-
- updateMessages();
- }
- }
-}
-
-
-
-LLIMFloater::~LLIMFloater()
-{
-}
-
-//virtual
-BOOL LLIMFloater::postBuild()
-{
- LLIMModel::LLIMSession* session = get_if_there(LLIMModel::instance().sSessionsMap, mSessionID, (LLIMModel::LLIMSession*)NULL);
- if(session)
- {
- mOtherParticipantUUID = session->mOtherParticipantID;
- mControlPanel->setID(session->mOtherParticipantID);
- }
-
- LLButton* slide_left = getChild<LLButton>("slide_left_btn");
- slide_left->setVisible(mControlPanel->getVisible());
- slide_left->setClickedCallback(boost::bind(&LLIMFloater::onSlide, this));
-
- LLButton* slide_right = getChild<LLButton>("slide_right_btn");
- slide_right->setVisible(!mControlPanel->getVisible());
- slide_right->setClickedCallback(boost::bind(&LLIMFloater::onSlide, this));
-
- mInputEditor = getChild<LLLineEditor>("chat_editor");
- mInputEditor->setMaxTextLength(1023);
- // enable line history support for instant message bar
- mInputEditor->setEnableLineHistory(TRUE);
-
- mInputEditor->setFocusReceivedCallback( onInputEditorFocusReceived, this );
- mInputEditor->setFocusLostCallback( onInputEditorFocusLost, this );
- mInputEditor->setKeystrokeCallback( onInputEditorKeystroke, this );
- mInputEditor->setCommitOnFocusLost( FALSE );
- mInputEditor->setRevertOnEsc( FALSE );
- mInputEditor->setReplaceNewlinesWithSpaces( FALSE );
-
- childSetCommitCallback("chat_editor", onSendMsg, this);
-
- mHistoryEditor = getChild<LLViewerTextEditor>("im_text");
- mHistoryEditor->setParseHTML(TRUE);
-
- setTitle(LLIMModel::instance().getName(mSessionID));
- setDocked(true);
-
- return LLDockableFloater::postBuild();
-}
-
-
-
-// static
-void* LLIMFloater::createPanelIMControl(void* userdata)
-{
- LLIMFloater *self = (LLIMFloater*)userdata;
- self->mControlPanel = new LLPanelIMControlPanel();
- self->mControlPanel->setXMLFilename("panel_im_control_panel.xml");
- return self->mControlPanel;
-}
-
-
-// static
-void* LLIMFloater::createPanelGroupControl(void* userdata)
-{
- LLIMFloater *self = (LLIMFloater*)userdata;
- self->mControlPanel = new LLPanelGroupControlPanel();
- self->mControlPanel->setXMLFilename("panel_group_control_panel.xml");
- return self->mControlPanel;
-}
-
-const U32 DOCK_ICON_HEIGHT = 6;
-
-//virtual
-void LLIMFloater::onFocusLost()
-{
- // spec says close if docked to bottom tray and user has clicked away
- // (hence we are no longer focused)
- if (isDocked())
- {
- LLIMFloater* floater = LLFloaterReg::getTypedInstance<LLIMFloater>("impanel", mSessionID);
- if (floater)
- {
- floater->setVisible(false);
- }
- }
-}
-
-void LLIMFloater::onSlide()
-{
- LLPanel* im_control_panel = getChild<LLPanel>("panel_im_control_panel");
- im_control_panel->setVisible(!im_control_panel->getVisible());
-
- getChild<LLButton>("slide_left_btn")->setVisible(im_control_panel->getVisible());
- getChild<LLButton>("slide_right_btn")->setVisible(!im_control_panel->getVisible());
-}
-
-//static
-LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
-{
- //hide all
- LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel");
- for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin();
- iter != inst_list.end(); ++iter)
- {
- LLIMFloater* floater = dynamic_cast<LLIMFloater*>(*iter);
- if (floater && floater->isDocked())
- {
- floater->setVisible(false);
- }
- }
-
- LLIMFloater* floater = LLFloaterReg::showTypedInstance<LLIMFloater>("impanel", session_id);
-
- floater->updateMessages();
- floater->mInputEditor->setFocus(TRUE);
-
- if (floater->getDockControl() == NULL)
- {
- LLView* chiclet =
- LLBottomTray::getInstance()->getChicletPanel()->findChiclet<LLView>(
- session_id);
- if (chiclet == NULL)
- {
- llerror("Dock chiclet for LLIMFloater doesn't exists", 0);
- }
- floater->setDockControl(new LLDockControl(chiclet, floater, floater->getDockTongue(),
- LLDockControl::TOP, floater->isDocked()));
- }
-
- return floater;
-}
-
-//static
-bool LLIMFloater::toggle(const LLUUID& session_id)
-{
- LLIMFloater* floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
- if (floater && floater->getVisible())
- {
- // clicking on chiclet to close floater just hides it to maintain existing
- // scroll/text entry state
- floater->setVisible(false);
- return false;
- }
- else
- {
- // ensure the list of messages is updated when floater is made visible
- show(session_id);
- // update number of unread notifications in the SysWell
- LLBottomTray::getInstance()->getSysWell()->updateUreadIMNotifications();
- return true;
- }
-}
-
-void LLIMFloater::updateMessages()
-{
- std::list<LLSD> messages = LLIMModel::instance().getMessages(mSessionID, mLastMessageIndex+1);
-
- if (messages.size())
- {
- LLUIColor divider_color = LLUIColorTable::instance().getColor("LtGray_50");
- LLUIColor chat_color = LLUIColorTable::instance().getColor("IMChatColor");
-
- std::ostringstream message;
- std::list<LLSD>::const_reverse_iterator iter = messages.rbegin();
- std::list<LLSD>::const_reverse_iterator iter_end = messages.rend();
- for (; iter != iter_end; ++iter)
- {
- LLSD msg = *iter;
-
- const bool prepend_newline = true;
- std::string from = msg["from"].asString();
- if (mLastFromName != from)
- {
- message << from << " ----- " << msg["time"].asString();
- mHistoryEditor->appendColoredText(message.str(), false,
- prepend_newline, divider_color);
- message.str("");
- mLastFromName = from;
- }
-
- message << msg["message"].asString();
- mHistoryEditor->appendColoredText(message.str(), false,
- prepend_newline, chat_color);
- message.str("");
-
- mLastMessageIndex = msg["index"].asInteger();
- }
-
- mHistoryEditor->setCursorAndScrollToEnd();
- }
-}
-
-// static
-void LLIMFloater::onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata )
-{
- LLIMFloater* self= (LLIMFloater*) userdata;
- self->mHistoryEditor->setCursorAndScrollToEnd();
-}
-
-// static
-void LLIMFloater::onInputEditorFocusLost(LLFocusableElement* caller, void* userdata)
-{
- LLIMFloater* self = (LLIMFloater*) userdata;
- self->setTyping(FALSE);
-}
-
-// static
-void LLIMFloater::onInputEditorKeystroke(LLLineEditor* caller, void* userdata)
-{
- LLIMFloater* self = (LLIMFloater*)userdata;
- std::string text = self->mInputEditor->getText();
- if (!text.empty())
- {
- self->setTyping(TRUE);
- }
- else
- {
- // Deleting all text counts as stopping typing.
- self->setTyping(FALSE);
- }
-}
-
-
-//just a stub for now
-void LLIMFloater::setTyping(BOOL typing)
-{
-}