diff options
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r-- | indra/newview/llimview.cpp | 520 |
1 files changed, 428 insertions, 92 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index ffa943092f..4d2ba16a4c 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -70,6 +70,8 @@ #include "lltoolbar.h" #include "llviewermessage.h" #include "llviewerwindow.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llnotify.h" #include "llnearbychat.h" #include "llviewerregion.h" @@ -81,19 +83,23 @@ #include "llfirstuse.h" #include "llagentui.h" +const static std::string IM_TIME("time"); +const static std::string IM_TEXT("message"); +const static std::string IM_FROM("from"); +const static std::string IM_FROM_ID("from_id"); + +const static std::string NO_SESSION("(IM Session Doesn't Exist)"); +const static std::string ADHOC_NAME_SUFFIX(" Conference"); + +std::string LLCallDialogManager::sPreviousSessionlName = ""; +std::string LLCallDialogManager::sCurrentSessionlName = ""; +LLIMModel::LLIMSession* LLCallDialogManager::sSession = NULL; + // // Globals // LLIMMgr* gIMMgr = NULL; -// -// Statics -// -// *FIXME: make these all either UIStrings or Strings - -const static std::string IM_SEPARATOR(": "); - - void toast_callback(const LLSD& msg){ // do not show toast in busy mode or it goes from agent if (gAgent.getBusy() || gAgent.getID() == msg["from_id"]) @@ -113,6 +119,13 @@ void toast_callback(const LLSD& msg){ return; } + // Skip toasting if we have open window of IM with this session id + LLIMFloater* open_im_floater = LLIMFloater::findInstance(msg["session_id"]); + if (open_im_floater && open_im_floater->getVisible()) + { + return; + } + LLSD args; args["MESSAGE"] = msg["message"]; args["TIME"] = msg["time"]; @@ -120,7 +133,7 @@ void toast_callback(const LLSD& msg){ args["FROM_ID"] = msg["from_id"]; args["SESSION_ID"] = msg["session_id"]; - LLNotifications::instance().add("IMToast", args, LLSD(), boost::bind(&LLIMFloater::show, msg["session_id"].asUUID())); + LLNotificationsUtil::add("IMToast", args, LLSD(), boost::bind(&LLIMFloater::show, msg["session_id"].asUUID())); } void LLIMModel::setActiveSessionID(const LLUUID& session_id) @@ -145,6 +158,7 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& : mSessionID(session_id), mName(name), mType(type), + mParticipantUnreadMessageCount(0), mNumUnread(0), mOtherParticipantID(other_participant_id), mInitialTargetIDs(ids), @@ -153,7 +167,8 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& mSessionInitialized(false), mCallBackEnabled(true), mTextIMPossible(true), - mOtherParticipantIsAvatar(true) + mOtherParticipantIsAvatar(true), + mStartCallOnInitialize(false) { if (IM_NOTHING_SPECIAL == type || IM_SESSION_P2P_INVITE == type) { @@ -163,6 +178,14 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& { mVoiceChannel = new LLVoiceChannelGroup(session_id, name); } + + if(mVoiceChannel) + { + mVoiceChannelStateChangeConnection = mVoiceChannel->setStateChangedCallback(boost::bind(&LLIMSession::onVoiceChannelStateChanged, this, _1, _2)); + } + // define what type of session was opened + setSessionType(); + mSpeakers = new LLIMSpeakerMgr(mVoiceChannel); // All participants will be added to the list of people we've recently interacted with. @@ -186,7 +209,90 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& } if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) - LLLogChat::loadHistory(mName, &chatFromLogFile, (void *)this); + { + std::list<LLSD> chat_history; + + //involves parsing of a chat history + LLLogChat::loadAllHistory(mName, chat_history); + addMessagesFromHistory(chat_history); + } +} + +void LLIMModel::LLIMSession::setSessionType() +{ + // set P2P type by default + mSessionType = P2P_SESSION; + + if (dynamic_cast<LLVoiceChannelP2P*>(mVoiceChannel) && !mOtherParticipantIsAvatar) // P2P AVALINE channel was opened + { + mSessionType = AVALINE_SESSION; + return; + } + else if(dynamic_cast<LLVoiceChannelGroup*>(mVoiceChannel)) // GROUP channel was opened + { + if (mType == IM_SESSION_CONFERENCE_START) + { + mSessionType = ADHOC_SESSION; + return; + } + else if(mType == IM_SESSION_GROUP_START) + { + mSessionType = GROUP_SESSION; + return; + } + } +} + +void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state) +{ + // *TODO: remove hardcoded string!!!!!!!!!!! + + bool is_p2p_session = dynamic_cast<LLVoiceChannelP2P*>(mVoiceChannel); + bool is_incoming_call = false; + std::string other_avatar_name; + + if(is_p2p_session) + { + is_incoming_call = static_cast<LLVoiceChannelP2P*>(mVoiceChannel)->isIncomingCall(); + gCacheName->getFullName(mOtherParticipantID, other_avatar_name); + + if(is_incoming_call) + { + switch(new_state) + { + case LLVoiceChannel::STATE_CALL_STARTED : + LLIMModel::getInstance()->addMessage(mSessionID, other_avatar_name, mOtherParticipantID, "Started a voice call"); + break; + case LLVoiceChannel::STATE_CONNECTED : + LLIMModel::getInstance()->addMessage(mSessionID, "You", gAgent.getID(), "Joined the voice call"); + default: + break; + } + } + else // outgoing call + { + switch(new_state) + { + case LLVoiceChannel::STATE_CALL_STARTED : + LLIMModel::getInstance()->addMessage(mSessionID, "You", gAgent.getID(), "Started a voice call"); + break; + case LLVoiceChannel::STATE_CONNECTED : + LLIMModel::getInstance()->addMessage(mSessionID, other_avatar_name, mOtherParticipantID, "Joined the voice call"); + default: + break; + } + } + + // Update speakers list when connected + if (LLVoiceChannel::STATE_CONNECTED == new_state) + { + mSpeakers->update(true); + } + } + else // group || ad-hoc calls + { + + } } LLIMModel::LLIMSession::~LLIMSession() @@ -210,9 +316,11 @@ LLIMModel::LLIMSession::~LLIMSession() } } + mVoiceChannelStateChangeConnection.disconnect(); + // HAVE to do this here -- if it happens in the LLVoiceChannel destructor it will call the wrong version (since the object's partially deconstructed at that point). mVoiceChannel->deactivate(); - + delete mVoiceChannel; mVoiceChannel = NULL; } @@ -246,6 +354,30 @@ void LLIMModel::LLIMSession::addMessage(const std::string& from, const LLUUID& f } } +void LLIMModel::LLIMSession::addMessagesFromHistory(const std::list<LLSD>& history) +{ + std::list<LLSD>::const_iterator it = history.begin(); + while (it != history.end()) + { + const LLSD& msg = *it; + + std::string from = msg[IM_FROM]; + LLUUID from_id = LLUUID::null; + if (msg[IM_FROM_ID].isUndefined()) + { + gCacheName->getUUID(from, from_id); + } + + + std::string timestamp = msg[IM_TIME]; + std::string text = msg[IM_TEXT]; + + addMessage(from, from_id, text, timestamp); + + it++; + } +} + void LLIMModel::LLIMSession::chatFromLogFile(LLLogChat::ELogLineType type, const LLSD& msg, void* userdata) { if (!userdata) return; @@ -288,6 +420,12 @@ void LLIMModel::processSessionInitializedReply(const LLUUID& old_session_id, con { im_floater->sessionInitReplyReceived(new_session_id); } + + // auto-start the call on session initialization? + if (session->mStartCallOnInitialize) + { + gIMMgr->startCall(new_session_id); + } } //*TODO remove this "floater" stuff when Communicate Floater is gone @@ -323,10 +461,16 @@ void LLIMModel::testMessages() addMessage(bot2_session_id, from, bot2_id, "Test Message: OMGWTFBBQ."); } - +//session name should not be empty bool LLIMModel::newSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, const std::vector<LLUUID>& ids) { + if (name.empty()) + { + llwarns << "Attempt to create a new session with empty name; id = " << session_id << llendl; + return false; + } + if (findIMSession(session_id)) { llwarns << "IM Session " << session_id << " already exists" << llendl; @@ -372,10 +516,12 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages, } session->mNumUnread = 0; + session->mParticipantUnreadMessageCount = 0; LLSD arg; arg["session_id"] = session_id; arg["num_unread"] = 0; + arg["participant_unread"] = session->mParticipantUnreadMessageCount; mNoUnreadMsgsSignal(arg); } @@ -394,6 +540,19 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, return true; } +bool LLIMModel::logToFile(const std::string& session_name, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) +{ + if (gSavedPerAccountSettings.getBOOL("LogInstantMessages")) + { + LLLogChat::saveHistory(session_name, from, from_id, utf8_text); + return true; + } + else + { + return false; + } +} + bool LLIMModel::logToFile(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) { if (gSavedPerAccountSettings.getBOOL("LogInstantMessages")) @@ -428,7 +587,7 @@ bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, co const std::string& utf8_text, bool log2file /* = true */) { LLIMSession* session = findIMSession(session_id); - if (!session) + if (!session) { llwarns << "session " << session_id << "does not exist " << llendl; return false; @@ -439,10 +598,18 @@ bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, co session->mNumUnread++; + //update count of unread messages from real participant + if (!(from_id.isNull() || from_id == gAgentID || SYSTEM_FROM == from)) + { + ++(session->mParticipantUnreadMessageCount); + } + + // notify listeners LLSD arg; arg["session_id"] = session_id; arg["num_unread"] = session->mNumUnread; + arg["participant_unread"] = session->mParticipantUnreadMessageCount; arg["message"] = utf8_text; arg["from"] = from; arg["from_id"] = from_id; @@ -460,7 +627,7 @@ const std::string& LLIMModel::getName(const LLUUID& session_id) const if (!session) { llwarns << "session " << session_id << "does not exist " << llendl; - return LLStringUtil::null; + return NO_SESSION; } return session->mName; @@ -847,18 +1014,6 @@ bool LLIMModel::sendStartSession( return false; } -// static -void LLIMModel::sendSessionInitialized(const LLUUID &session_id) -{ - LLIMSession* session = getInstance()->findIMSession(session_id); - if (session) - { - LLSD arg; - arg["session_id"] = session_id; - getInstance()->mSessionInitializedSignal(arg); - } -} - // // Helper Functions // @@ -931,7 +1086,7 @@ public: if ( 404 == statusNum ) { std::string error_string; - error_string = "does not exist"; + error_string = "session_does_not_exist_error"; gIMMgr->showSessionStartError(error_string, mSessionID); } } @@ -1015,7 +1170,7 @@ LLIMMgr::showSessionStartError( LLSD payload; payload["session_id"] = session_id; - LLNotifications::instance().add( + LLNotificationsUtil::add( "ChatterBoxSessionStartError", args, payload, @@ -1038,7 +1193,7 @@ LLIMMgr::showSessionEventError( LLTrans::getString(event_string); args["RECIPIENT"] = floater->getTitle(); - LLNotifications::instance().add( + LLNotificationsUtil::add( "ChatterBoxSessionEventError", args); } @@ -1059,7 +1214,7 @@ LLIMMgr::showSessionForceClose( LLSD payload; payload["session_id"] = session_id; - LLNotifications::instance().add( + LLNotificationsUtil::add( "ForceCloseChatterBoxSession", args, payload, @@ -1085,21 +1240,175 @@ LLIMMgr::onConfirmForceCloseError( //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLCallDialogManager +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +LLCallDialogManager::LLCallDialogManager() +{ +} + +LLCallDialogManager::~LLCallDialogManager() +{ +} + +void LLCallDialogManager::initClass() +{ + LLVoiceChannel::setCurrentVoiceChannelChangedCallback(LLCallDialogManager::onVoiceChannelChanged); +} + +void LLCallDialogManager::onVoiceChannelChanged(const LLUUID &session_id) +{ + LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(session_id); + if(!session) + { + sPreviousSessionlName = sCurrentSessionlName; + sCurrentSessionlName = ""; // Empty string results in "Nearby Voice Chat" after substitution + return; + } + sSession = session; + sSession->mVoiceChannel->setStateChangedCallback(LLCallDialogManager::onVoiceChannelStateChanged); + sPreviousSessionlName = sCurrentSessionlName; + sCurrentSessionlName = session->mName; +} + +void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state) +{ + LLSD mCallDialogPayload; + LLOutgoingCallDialog* ocd; + bool is_incoming; + + mCallDialogPayload["session_id"] = sSession->mSessionID; + mCallDialogPayload["session_name"] = sSession->mName; + mCallDialogPayload["other_user_id"] = sSession->mOtherParticipantID; + mCallDialogPayload["old_channel_name"] = sPreviousSessionlName; + + switch(new_state) + { + case LLVoiceChannel::STATE_CALL_STARTED : + // do not show "Calling to..." if it is incoming call + is_incoming = LLVoiceClient::getInstance()->isSessionIncoming(sSession->mSessionID); + // *TODO: implement for AdHoc and Group voice chats + if(is_incoming) + { + return; + } + + ocd = dynamic_cast<LLOutgoingCallDialog*>(LLFloaterReg::showInstance("outgoing_call", mCallDialogPayload, TRUE)); + if (ocd) + { + ocd->getChild<LLTextBox>("calling")->setVisible(true); + ocd->getChild<LLTextBox>("leaving")->setVisible(true); + ocd->getChild<LLTextBox>("connecting")->setVisible(false); + ocd->getChild<LLTextBox>("noanswer")->setVisible(false); + ocd->getChild<LLButton>("Cancel")->setVisible(true); + } + return; + + case LLVoiceChannel::STATE_RINGING : + ocd = dynamic_cast<LLOutgoingCallDialog*>(LLFloaterReg::showInstance("outgoing_call", mCallDialogPayload, TRUE)); + if (ocd) + { + ocd->getChild<LLTextBox>("calling")->setVisible(false); + ocd->getChild<LLTextBox>("leaving")->setVisible(true); + ocd->getChild<LLTextBox>("connecting")->setVisible(true); + ocd->getChild<LLTextBox>("noanswer")->setVisible(false); + ocd->getChild<LLButton>("Cancel")->setVisible(true); + } + return; + + case LLVoiceChannel::STATE_ERROR : + mCallDialogPayload["start_timer"] = true; + ocd = dynamic_cast<LLOutgoingCallDialog*>(LLFloaterReg::showInstance("outgoing_call", mCallDialogPayload, TRUE)); + if (ocd) + { + ocd->getChild<LLTextBox>("calling")->setVisible(false); + ocd->getChild<LLTextBox>("leaving")->setVisible(false); + ocd->getChild<LLTextBox>("connecting")->setVisible(false); + ocd->getChild<LLTextBox>("noanswer")->setVisible(true); + ocd->getChild<LLButton>("Cancel")->setVisible(false); + } + return; + + case LLVoiceChannel::STATE_CONNECTED : + case LLVoiceChannel::STATE_HUNG_UP : + ocd = dynamic_cast<LLOutgoingCallDialog*>(LLFloaterReg::showInstance("outgoing_call", mCallDialogPayload, TRUE)); + if (ocd) + { + ocd->closeFloater(); + } + return; + + default: + break; + } + +} + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLCallDialog +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LLCallDialog::LLCallDialog(const LLSD& payload) : +LLDockableFloater(NULL, false, payload), +mPayload(payload) +{ +} + +void LLCallDialog::getAllowedRect(LLRect& rect) +{ + rect = gViewerWindow->getWorldViewRectScaled(); +} + +void LLCallDialog::onOpen(const LLSD& key) +{ + // dock the dialog to the Speak Button, where other sys messages appear + setDockControl(new LLDockControl(LLBottomTray::getInstance()->getChild<LLPanel>("speak_panel"), + this, getDockTongue(), LLDockControl::TOP, boost::bind(&LLCallDialog::getAllowedRect, this, _1))); +} + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLOutgoingCallDialog //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LLOutgoingCallDialog::LLOutgoingCallDialog(const LLSD& payload) : - LLDockableFloater(NULL, false, payload), - mPayload(payload) +LLCallDialog(payload) +{ + LLOutgoingCallDialog* instance = LLFloaterReg::findTypedInstance<LLOutgoingCallDialog>("outgoing_call", payload); + if(instance && instance->getVisible()) + { + instance->onCancel(instance); + } +} +void LLOutgoingCallDialog::draw() { + if (lifetimeHasExpired()) + { + onLifetimeExpired(); + } + LLDockableFloater::draw(); } -void LLOutgoingCallDialog::getAllowedRect(LLRect& rect) +bool LLOutgoingCallDialog::lifetimeHasExpired() { - rect = gViewerWindow->getWorldViewRectScaled(); + if (mLifetimeTimer.getStarted()) + { + F32 elapsed_time = mLifetimeTimer.getElapsedTimeF32(); + if (elapsed_time > LIFETIME) + { + return true; + } + } + return false; +} + +void LLOutgoingCallDialog::onLifetimeExpired() +{ + mLifetimeTimer.stop(); + closeFloater(); } void LLOutgoingCallDialog::onOpen(const LLSD& key) { + LLCallDialog::onOpen(key); + // tell the user which voice channel they are leaving if (!mPayload["old_channel_name"].asString().empty()) { @@ -1123,6 +1432,13 @@ void LLOutgoingCallDialog::onOpen(const LLSD& key) childSetTextArg("connecting", "[CALLEE_NAME]", callee_name); LLAvatarIconCtrl* icon = getChild<LLAvatarIconCtrl>("avatar_icon"); icon->setValue(callee_id); + + // stop timer by default + mLifetimeTimer.stop(); + if(mPayload.has("start_timer")) + { + mLifetimeTimer.reset(); + } } @@ -1147,22 +1463,15 @@ BOOL LLOutgoingCallDialog::postBuild() childSetAction("Cancel", onCancel, this); - // dock the dialog to the sys well, where other sys messages appear - setDockControl(new LLDockControl(LLBottomTray::getInstance()->getSysWell(), - this, getDockTongue(), LLDockControl::TOP, - boost::bind(&LLOutgoingCallDialog::getAllowedRect, this, _1))); - return success; } - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLIncomingCallDialog //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LLIncomingCallDialog::LLIncomingCallDialog(const LLSD& payload) : - LLDockableFloater(NULL, false, payload), - mPayload(payload) +LLCallDialog(payload) { } @@ -1206,13 +1515,11 @@ BOOL LLIncomingCallDialog::postBuild() return TRUE; } -void LLIncomingCallDialog::getAllowedRect(LLRect& rect) -{ - rect = gViewerWindow->getWorldViewRectScaled(); -} void LLIncomingCallDialog::onOpen(const LLSD& key) { + LLCallDialog::onOpen(key); + // tell the user which voice channel they would be leaving LLVoiceChannel *voice = LLVoiceChannel::getCurrentVoiceChannel(); if (voice && !voice->getSessionName().empty()) @@ -1223,11 +1530,6 @@ void LLIncomingCallDialog::onOpen(const LLSD& key) { childSetTextArg("question", "[CURRENT_CHAT]", getString("localchat")); } - - // dock the dialog to the sys well, where other sys messages appear - setDockControl(new LLDockControl(LLBottomTray::getInstance()->getSysWell(), - this, getDockTongue(), LLDockControl::TOP, - boost::bind(&LLIncomingCallDialog::getAllowedRect, this, _1))); } //static @@ -1260,6 +1562,8 @@ void LLIncomingCallDialog::processCallResponse(S32 response) return; LLUUID session_id = mPayload["session_id"].asUUID(); + LLUUID caller_id = mPayload["caller_id"].asUUID(); + std::string session_name = mPayload["session_name"].asString(); EInstantMessage type = (EInstantMessage)mPayload["type"].asInteger(); LLIMMgr::EInvitationType inv_type = (LLIMMgr::EInvitationType)mPayload["inv_type"].asInteger(); bool voice = true; @@ -1276,9 +1580,10 @@ void LLIncomingCallDialog::processCallResponse(S32 response) { // create a normal IM session session_id = gIMMgr->addP2PSession( - mPayload["session_name"].asString(), - mPayload["caller_id"].asUUID(), - mPayload["session_handle"].asString()); + session_name, + caller_id, + mPayload["session_handle"].asString(), + mPayload["session_uri"].asString()); if (voice) { @@ -1294,13 +1599,41 @@ void LLIncomingCallDialog::processCallResponse(S32 response) } else { - LLUUID session_id = gIMMgr->addSession( - mPayload["session_name"].asString(), - type, - session_id); - if (session_id != LLUUID::null) + //session name should not be empty, but it can contain spaces so we don't trim + std::string correct_session_name = session_name; + if (session_name.empty()) + { + llwarns << "Received an empty session name from a server" << llendl; + + switch(type){ + case IM_SESSION_CONFERENCE_START: + case IM_SESSION_GROUP_START: + case IM_SESSION_INVITE: + if (gAgent.isInGroup(session_id)) + { + LLGroupData data; + if (!gAgent.getGroupData(session_id, data)) break; + correct_session_name = data.mName; + } + else + { + if (gCacheName->getFullName(caller_id, correct_session_name)) + { + correct_session_name.append(ADHOC_NAME_SUFFIX); + } + } + llinfos << "Corrected session name is " << correct_session_name << llendl; + break; + default: + llwarning("Received an empty session name from a server and failed to generate a new proper session name", 0); + break; + } + } + + LLUUID new_session_id = gIMMgr->addSession(correct_session_name, type, session_id); + if (new_session_id != LLUUID::null) { - LLIMFloater::show(session_id); + LLIMFloater::show(new_session_id); } std::string url = gAgent.getRegion()->getCapability( @@ -1363,7 +1696,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) LLUUID session_id = payload["session_id"].asUUID(); EInstantMessage type = (EInstantMessage)payload["type"].asInteger(); LLIMMgr::EInvitationType inv_type = (LLIMMgr::EInvitationType)payload["inv_type"].asInteger(); - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch(option) { case 0: // accept @@ -1388,13 +1721,13 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) } else { - LLUUID session_id = gIMMgr->addSession( + LLUUID new_session_id = gIMMgr->addSession( payload["session_name"].asString(), type, session_id); - if (session_id != LLUUID::null) + if (new_session_id != LLUUID::null) { - LLIMFloater::show(session_id); + LLIMFloater::show(new_session_id); } std::string url = gAgent.getRegion()->getCapability( @@ -1651,6 +1984,19 @@ S32 LLIMMgr::getNumberOfUnreadIM() return num; } +S32 LLIMMgr::getNumberOfUnreadParticipantMessages() +{ + std::map<LLUUID, LLIMModel::LLIMSession*>::iterator it; + + S32 num = 0; + for(it = LLIMModel::getInstance()->mId2SessionMap.begin(); it != LLIMModel::getInstance()->mId2SessionMap.end(); ++it) + { + num += (*it).second->mParticipantUnreadMessageCount; + } + + return num; +} + void LLIMMgr::clearNewIMNotification() { mIMReceived = FALSE; @@ -1661,6 +2007,15 @@ BOOL LLIMMgr::getIMReceived() const return mIMReceived; } +void LLIMMgr::autoStartCallOnStartup(const LLUUID& session_id) +{ + LLIMModel::LLIMSession *session = LLIMModel::getInstance()->findIMSession(session_id); + if (session) + { + session->mStartCallOnInitialize = true; + } +} + LLUUID LLIMMgr::addP2PSession(const std::string& name, const LLUUID& other_participant_id, const std::string& voice_session_handle, @@ -1711,6 +2066,12 @@ LLUUID LLIMMgr::addSession( return LLUUID::null; } + if (name.empty()) + { + llwarning("Session name cannot be null!", 0); + return LLUUID::null; + } + LLUUID session_id = computeSessionID(dialog,other_participant_id); bool new_session = !LLIMModel::getInstance()->findIMSession(session_id); @@ -1866,18 +2227,7 @@ void LLIMMgr::inviteToSession( } else { - if (notify_box_type == "VoiceInviteP2P" || notify_box_type == "VoiceInviteAdHoc") - { - LLFloaterReg::showInstance("incoming_call", payload, TRUE); - } - else - { - LLSD args; - args["NAME"] = caller_name; - args["GROUP"] = session_name; - - LLNotifications::instance().add(notify_box_type, args, payload, &inviteUserResponse); - } + LLFloaterReg::showInstance("incoming_call", payload, TRUE); } mPendingInvitations[session_id.asString()] = LLSD(); } @@ -1890,21 +2240,7 @@ void LLIMMgr::onInviteNameLookup(LLSD payload, const LLUUID& id, const std::stri std::string notify_box_type = payload["notify_box_type"].asString(); - if (notify_box_type == "VoiceInviteP2P" || notify_box_type == "VoiceInviteAdHoc") - { - LLFloaterReg::showInstance("incoming_call", payload, TRUE); - } - else - { - LLSD args; - args["NAME"] = payload["caller_name"].asString(); - - LLNotifications::instance().add( - payload["notify_box_type"].asString(), - args, - payload, - &inviteUserResponse); - } + LLFloaterReg::showInstance("incoming_call", payload, TRUE); } void LLIMMgr::disconnectAllSessions() |