diff options
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r-- | indra/newview/llimview.cpp | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index b50d4674f7..ea3b57a358 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -153,7 +153,7 @@ LLIMModel::LLIMModel() addNewMsgCallback(toast_callback); } -LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, const std::vector<LLUUID>& ids) +LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, const std::vector<LLUUID>& ids, bool voice) : mSessionID(session_id), mName(name), mType(type), @@ -167,7 +167,8 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& mCallBackEnabled(true), mTextIMPossible(true), mOtherParticipantIsAvatar(true), - mStartCallOnInitialize(false) + mStartCallOnInitialize(false), + mStartedAsIMCall(voice) { // set P2P type by default mSessionType = P2P_SESSION; @@ -250,10 +251,10 @@ void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::ES switch(new_state) { case LLVoiceChannel::STATE_CALL_STARTED : - LLIMModel::getInstance()->addMessage(mSessionID, other_avatar_name, mOtherParticipantID, "Started a voice call"); + LLIMModel::getInstance()->addMessageSilently(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"); + LLIMModel::getInstance()->addMessageSilently(mSessionID, "You", gAgent.getID(), "Joined the voice call"); default: break; } @@ -263,10 +264,10 @@ void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::ES switch(new_state) { case LLVoiceChannel::STATE_CALL_STARTED : - LLIMModel::getInstance()->addMessage(mSessionID, "You", gAgent.getID(), "Started a voice call"); + LLIMModel::getInstance()->addMessageSilently(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"); + LLIMModel::getInstance()->addMessageSilently(mSessionID, other_avatar_name, mOtherParticipantID, "Joined the voice call"); default: break; } @@ -452,7 +453,7 @@ void LLIMModel::testMessages() //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) + const LLUUID& other_participant_id, const std::vector<LLUUID>& ids, bool voice) { if (name.empty()) { @@ -466,7 +467,7 @@ bool LLIMModel::newSession(const LLUUID& session_id, const std::string& name, co return false; } - LLIMSession* session = new LLIMSession(session_id, name, type, other_participant_id, ids); + LLIMSession* session = new LLIMSession(session_id, name, type, other_participant_id, ids, voice); mId2SessionMap[session_id] = session; LLIMMgr::getInstance()->notifyObserverSessionAdded(session_id, name, other_participant_id); @@ -475,6 +476,12 @@ bool LLIMModel::newSession(const LLUUID& session_id, const std::string& name, co } +bool LLIMModel::newSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, bool voice) +{ + std::vector<LLUUID> no_ids; + return newSession(session_id, name, type, other_participant_id, no_ids, voice); +} + bool LLIMModel::clearSession(const LLUUID& session_id) { if (mId2SessionMap.find(session_id) == mId2SessionMap.end()) return false; @@ -574,12 +581,33 @@ bool LLIMModel::proccessOnlineOfflineNotification( bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text, bool log2file /* = true */) { + + LLIMSession* session = addMessageSilently(session_id, from, from_id, utf8_text, log2file); + if (!session) return false; + + // 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; + arg["time"] = LLLogChat::timestamp(false); + mNewMsgSignal(arg); + + return true; +} + +LLIMModel::LLIMSession* LLIMModel::addMessageSilently(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, + const std::string& utf8_text, bool log2file /* = true */) +{ LLIMSession* session = findIMSession(session_id); if (!session) { llwarns << "session " << session_id << "does not exist " << llendl; - return false; + return NULL; } addToHistory(session_id, from, from_id, utf8_text); @@ -593,19 +621,7 @@ bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, co ++(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; - arg["time"] = LLLogChat::timestamp(false); - mNewMsgSignal(arg); - - return true; + return session; } @@ -1056,8 +1072,8 @@ public: || mInvitiationType == LLIMMgr::INVITATION_TYPE_IMMEDIATE) && LLIMModel::getInstance()->findIMSession(mSessionID)) { - // always open IM window when connecting to voice - LLIMFloater::show(mSessionID); + // TODO remove in 2010, for voice calls we do not open an IM window + //LLIMFloater::show(mSessionID); } gIMMgr->clearPendingAgentListUpdates(mSessionID); @@ -1582,11 +1598,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response) if (voice) { - if (gIMMgr->startCall(session_id, LLVoiceChannel::INCOMING_CALL)) - { - // always open IM window when connecting to voice - LLIMFloater::show(session_id); - } + gIMMgr->startCall(session_id, LLVoiceChannel::INCOMING_CALL); } gIMMgr->clearPendingAgentListUpdates(session_id); @@ -1625,11 +1637,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response) } } - LLUUID new_session_id = gIMMgr->addSession(correct_session_name, type, session_id); - if (new_session_id != LLUUID::null) - { - LLIMFloater::show(new_session_id); - } + LLUUID new_session_id = gIMMgr->addSession(correct_session_name, type, session_id, true); std::string url = gAgent.getRegion()->getCapability( "ChatSessionRequest"); @@ -1705,11 +1713,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) payload["session_handle"].asString(), payload["session_uri"].asString()); - if (gIMMgr->startCall(session_id)) - { - // always open IM window when connecting to voice - LLIMFloater::show(session_id); - } + gIMMgr->startCall(session_id); gIMMgr->clearPendingAgentListUpdates(session_id); gIMMgr->clearPendingInvitation(session_id); @@ -1719,11 +1723,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) LLUUID new_session_id = gIMMgr->addSession( payload["session_name"].asString(), type, - session_id); - if (new_session_id != LLUUID::null) - { - LLIMFloater::show(new_session_id); - } + session_id, true); std::string url = gAgent.getRegion()->getCapability( "ChatSessionRequest"); @@ -2018,11 +2018,7 @@ LLUUID LLIMMgr::addP2PSession(const std::string& name, const std::string& voice_session_handle, const std::string& caller_uri) { - LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id); - if (session_id != LLUUID::null) - { - LLIMFloater::show(session_id); - } + LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id, true); LLIMSpeakerMgr* speaker_mgr = LLIMModel::getInstance()->getSpeakerManager(session_id); if (speaker_mgr) @@ -2043,11 +2039,11 @@ LLUUID LLIMMgr::addP2PSession(const std::string& name, LLUUID LLIMMgr::addSession( const std::string& name, EInstantMessage dialog, - const LLUUID& other_participant_id) + const LLUUID& other_participant_id, bool voice) { LLDynamicArray<LLUUID> ids; ids.put(other_participant_id); - return addSession(name, dialog, other_participant_id, ids); + return addSession(name, dialog, other_participant_id, ids, voice); } // Adds a session using the given session_id. If the session already exists @@ -2056,7 +2052,7 @@ LLUUID LLIMMgr::addSession( const std::string& name, EInstantMessage dialog, const LLUUID& other_participant_id, - const LLDynamicArray<LLUUID>& ids) + const LLDynamicArray<LLUUID>& ids, bool voice) { if (0 == ids.getLength()) { @@ -2075,7 +2071,7 @@ LLUUID LLIMMgr::addSession( if (new_session) { - LLIMModel::getInstance()->newSession(session_id, name, dialog, other_participant_id, ids); + LLIMModel::getInstance()->newSession(session_id, name, dialog, other_participant_id, ids, voice); } @@ -2454,6 +2450,14 @@ bool LLIMMgr::endCall(const LLUUID& session_id) return true; } +bool LLIMMgr::isVoiceCall(const LLUUID& session_id) +{ + LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(session_id); + if (!im_session) return false; + + return im_session->mStartedAsIMCall; +} + // create a floater and update internal representation for // consistency. Returns the pointer, caller (the class instance since // it is a private method) is not responsible for deleting the |