diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llimview.cpp | 217 | ||||
-rw-r--r-- | indra/newview/llimview.h | 52 | ||||
-rw-r--r-- | indra/newview/llvoicechannel.cpp | 59 |
3 files changed, 213 insertions, 115 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index d3058e67af..f1efc11b07 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -88,6 +88,10 @@ const static std::string IM_TEXT("message"); const static std::string IM_FROM("from"); const static std::string IM_FROM_ID("from_id"); +std::string LLCallDialogManager::sPreviousSessionlName = ""; +std::string LLCallDialogManager::sCurrentSessionlName = ""; +LLIMModel::LLIMSession* LLCallDialogManager::sSession = NULL; + // // Globals // @@ -149,6 +153,7 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& mInitialTargetIDs(ids), mVoiceChannel(NULL), mSpeakers(NULL), + mCallDialogManager(NULL), mSessionInitialized(false), mCallBackEnabled(true), mTextIMPossible(true), @@ -167,6 +172,9 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& { 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. @@ -199,8 +207,35 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& } } +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; @@ -251,6 +286,9 @@ void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::ES LLIMModel::LLIMSession::~LLIMSession() { + delete mCallDialogManager; + mCallDialogManager = NULL; + delete mSpeakers; mSpeakers = NULL; @@ -1184,21 +1222,141 @@ LLIMMgr::onConfirmForceCloseError( //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLOutgoingCallDialog +// Class LLCallDialogManager //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LLOutgoingCallDialog::LLOutgoingCallDialog(const LLSD& payload) : - LLDockableFloater(NULL, false, payload), - mPayload(payload) + +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 LLOutgoingCallDialog::getAllowedRect(LLRect& rect) +void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state) +{ + LLSD mCallDialogPayload; + LLOutgoingCallDialog* ocd; + + 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 P2P call + if(sSession->mSessionType == LLIMModel::LLIMSession::P2P_SESSION && static_cast<LLVoiceChannelP2P*>(sSession->mVoiceChannel)->isIncomingCall()) + { + 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); + } + 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); + } + return; + + case LLVoiceChannel::STATE_ERROR : + 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); + } + 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) : +LLCallDialog(payload) +{ + LLOutgoingCallDialog* instance = LLFloaterReg::findTypedInstance<LLOutgoingCallDialog>("outgoing_call", payload); + if(instance && instance->getVisible()) + { + instance->onCancel(instance); + } +} + 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()) { @@ -1246,22 +1404,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()->getChild<LLPanel>("speak_panel"), - 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) { } @@ -1305,13 +1456,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()) @@ -1322,11 +1471,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()->getChild<LLPanel>("speak_panel"), - this, getDockTongue(), LLDockControl::TOP, - boost::bind(&LLIncomingCallDialog::getAllowedRect, this, _1))); } //static @@ -1966,18 +2110,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; - - LLNotificationsUtil::add(notify_box_type, args, payload, &inviteUserResponse); - } + LLFloaterReg::showInstance("incoming_call", payload, TRUE); } mPendingInvitations[session_id.asString()] = LLSD(); } @@ -1990,21 +2123,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(); - - LLNotificationsUtil::add( - payload["notify_box_type"].asString(), - args, - payload, - &inviteUserResponse); - } + LLFloaterReg::showInstance("incoming_call", payload, TRUE); } void LLIMMgr::disconnectAllSessions() diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index 8a0f57deb0..4561d760d4 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -48,6 +48,7 @@ class LLFloaterChatterBox; class LLUUID; class LLFloaterIMPanel; class LLFriendObserver; +class LLCallDialogManager; class LLIMModel : public LLSingleton<LLIMModel> { @@ -55,12 +56,20 @@ public: struct LLIMSession { + typedef enum e_session_type + { // for now we have 4 predefined types for a session + P2P_SESSION, + GROUP_SESSION, + ADHOC_SESSION, + AVALINE_SESSION, + } SType; + LLIMSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, const std::vector<LLUUID>& ids); virtual ~LLIMSession(); void sessionInitReplyReceived(const LLUUID& new_session_id); - + void setSessionType(); //define what type of session was opened void addMessagesFromHistory(const std::list<LLSD>& history); void addMessage(const std::string& from, const LLUUID& from_id, const std::string& utf8_text, const std::string& time); void onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state); @@ -69,8 +78,10 @@ public: LLUUID mSessionID; std::string mName; EInstantMessage mType; + SType mSessionType; LLUUID mOtherParticipantID; std::vector<LLUUID> mInitialTargetIDs; + LLCallDialogManager* mCallDialogManager; // connection to voice channel state change signal boost::signals2::connection mVoiceChannelStateChangeConnection; @@ -419,7 +430,36 @@ private: LLSD mPendingAgentListUpdates; }; -class LLIncomingCallDialog : public LLDockableFloater +class LLCallDialogManager : public LLInitClass<LLCallDialogManager> +{ +public: + LLCallDialogManager(); + ~LLCallDialogManager(); + + static void initClass(); + static void onVoiceChannelChanged(const LLUUID &session_id); + static void onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state); + +protected: + static std::string sPreviousSessionlName; + static std::string sCurrentSessionlName; + static LLIMModel::LLIMSession* sSession; +}; + +class LLCallDialog : public LLDockableFloater +{ +public: + LLCallDialog(const LLSD& payload); + ~LLCallDialog() {} + + virtual void onOpen(const LLSD& key); + +protected: + virtual void getAllowedRect(LLRect& rect); + LLSD mPayload; +}; + +class LLIncomingCallDialog : public LLCallDialog { public: LLIncomingCallDialog(const LLSD& payload); @@ -433,12 +473,9 @@ public: private: void processCallResponse(S32 response); - void getAllowedRect(LLRect& rect); - - LLSD mPayload; }; -class LLOutgoingCallDialog : public LLDockableFloater +class LLOutgoingCallDialog : public LLCallDialog { public: LLOutgoingCallDialog(const LLSD& payload); @@ -449,9 +486,6 @@ public: static void onCancel(void* user_data); private: - void getAllowedRect(LLRect& rect); - - LLSD mPayload; }; // Globals diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 608060174a..175b6f1d10 100644 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -316,6 +316,8 @@ void LLVoiceChannel::activate() } } + sCurrentVoiceChannelChangedSignal(this->mSessionID); + if (mState == STATE_NO_CHANNEL_INFO) { // responsible for setting status to active @@ -325,8 +327,6 @@ void LLVoiceChannel::activate() { setState(STATE_CALL_STARTED); } - - sCurrentVoiceChannelChangedSignal(this->mSessionID); } void LLVoiceChannel::getChannelInfo() @@ -874,61 +874,6 @@ void LLVoiceChannelP2P::setState(EState state) return; } } - else // outgoing call - { - mCallDialogPayload["session_id"] = mSessionID; - mCallDialogPayload["session_name"] = mSessionName; - mCallDialogPayload["other_user_id"] = mOtherUserID; - if (state == STATE_RINGING || - state == STATE_CALL_STARTED) - { - // *HACK: open outgoing call floater if needed, might be better done elsewhere. - // *TODO: should move this squirrelly ui-fudging crap into LLOutgoingCallDialog itself - if (!mSessionName.empty()) - { - LLOutgoingCallDialog *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); - } - } - } - /*else if (state == STATE_CONNECTED) - { - LLOutgoingCallDialog *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(true); - ocd->getChild<LLTextBox>("noanswer")->setVisible(false); - } - }*/ - else if (state == STATE_ERROR) - { - LLOutgoingCallDialog *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); - } - } - else if (state == STATE_HUNG_UP || - state == STATE_CONNECTED) - { - // hide popup - LLOutgoingCallDialog *ocd = dynamic_cast<LLOutgoingCallDialog*>(LLFloaterReg::showInstance("outgoing_call", mCallDialogPayload, TRUE)); - if (ocd) - { - ocd->closeFloater(); - } - } - } LLVoiceChannel::setState(state); } |