diff options
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r-- | indra/newview/llimview.cpp | 149 |
1 files changed, 121 insertions, 28 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 6c4af0522f..4d2ba16a4c 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -88,6 +88,9 @@ 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; @@ -116,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"]; @@ -154,11 +164,11 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& mInitialTargetIDs(ids), mVoiceChannel(NULL), mSpeakers(NULL), - mCallDialogManager(NULL), mSessionInitialized(false), mCallBackEnabled(true), mTextIMPossible(true), - mOtherParticipantIsAvatar(true) + mOtherParticipantIsAvatar(true), + mStartCallOnInitialize(false) { if (IM_NOTHING_SPECIAL == type || IM_SESSION_P2P_INVITE == type) { @@ -287,9 +297,6 @@ void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::ES LLIMModel::LLIMSession::~LLIMSession() { - delete mCallDialogManager; - mCallDialogManager = NULL; - delete mSpeakers; mSpeakers = NULL; @@ -413,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 @@ -448,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; @@ -608,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; @@ -995,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 // @@ -1079,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); } } @@ -1268,6 +1275,7 @@ void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EStat { LLSD mCallDialogPayload; LLOutgoingCallDialog* ocd; + bool is_incoming; mCallDialogPayload["session_id"] = sSession->mSessionID; mCallDialogPayload["session_name"] = sSession->mName; @@ -1277,8 +1285,10 @@ void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EStat switch(new_state) { case LLVoiceChannel::STATE_CALL_STARTED : - // do not show "Calling to..." if it is incoming P2P call - if(sSession->mSessionType == LLIMModel::LLIMSession::P2P_SESSION && static_cast<LLVoiceChannelP2P*>(sSession->mVoiceChannel)->isIncomingCall()) + // 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; } @@ -1290,6 +1300,7 @@ void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EStat 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; @@ -1301,10 +1312,12 @@ void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EStat 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) { @@ -1312,6 +1325,7 @@ void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EStat 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; @@ -1363,6 +1377,33 @@ LLCallDialog(payload) instance->onCancel(instance); } } +void LLOutgoingCallDialog::draw() +{ + if (lifetimeHasExpired()) + { + onLifetimeExpired(); + } + LLDockableFloater::draw(); +} + +bool LLOutgoingCallDialog::lifetimeHasExpired() +{ + 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) { @@ -1391,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(); + } } @@ -1514,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; @@ -1530,8 +1580,8 @@ void LLIncomingCallDialog::processCallResponse(S32 response) { // create a normal IM session session_id = gIMMgr->addP2PSession( - mPayload["session_name"].asString(), - mPayload["caller_id"].asUUID(), + session_name, + caller_id, mPayload["session_handle"].asString(), mPayload["session_uri"].asString()); @@ -1549,10 +1599,38 @@ void LLIncomingCallDialog::processCallResponse(S32 response) } else { - LLUUID new_session_id = gIMMgr->addSession( - mPayload["session_name"].asString(), - type, - session_id); + //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(new_session_id); @@ -1929,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, @@ -1979,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); |