From 9b4d09471cca6922257a27ba9cb70498ab81fd94 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Thu, 10 Dec 2009 14:05:17 +0000 Subject: DEV-41317 DEV-42311: Improved auto-call implementation. Improved the implementation for auto-connecting an adhoc call. This involved having the controller (LLIMMgr) set a flag in the model (LLIMModel) to autoconnect on initialize. Now all of the view code (LLPanelChatControlPanel) and the signal/callback infrastructure that I added earlier can be removed as it violated MVP separation. Ah! Much nicer. Thanks to PE folk for the suggestion. --- indra/newview/llavataractions.cpp | 18 ++---------------- indra/newview/llavataractions.h | 1 - indra/newview/llimview.cpp | 30 +++++++++++++++++------------- indra/newview/llimview.h | 7 ++++--- indra/newview/llpanelimcontrolpanel.cpp | 8 -------- indra/newview/llpanelimcontrolpanel.h | 4 +--- 6 files changed, 24 insertions(+), 44 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 5af023f565..5f90a7627f 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -62,9 +62,6 @@ #include "llimfloater.h" #include "lltrans.h" -// callback connection to auto-call when the IM floater initializes -boost::signals2::connection gAdhocAutoCall; - // static void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name) { @@ -250,8 +247,8 @@ void LLAvatarActions::startAdhocCall(const std::vector& ids) // always open IM window when connecting to voice LLIMFloater::show(session_id); - // start the call once the floater has fully initialized - gAdhocAutoCall = LLIMModel::getInstance()->addSessionInitializedCallback(callbackAutoStartCall); + // start the call once the session has fully initialized + gIMMgr->autoStartCallOnStartup(session_id); make_ui_sound("UISndStartIM"); } @@ -466,17 +463,6 @@ bool LLAvatarActions::callbackAddFriend(const LLSD& notification, const LLSD& re return false; } -// static -void LLAvatarActions::callbackAutoStartCall(const LLSD& data) -{ - // start the adhoc voice call now the IM panel has initialized - LLUUID session_id = data["session_id"].asUUID(); - gIMMgr->startCall(session_id); - - // and deschedule this callback as its work is done now - gAdhocAutoCall.disconnect(); -} - // static void LLAvatarActions::requestFriendship(const LLUUID& target_id, const std::string& target_name, const std::string& message) { diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h index 4c9851a48d..2dd2a4c4b1 100644 --- a/indra/newview/llavataractions.h +++ b/indra/newview/llavataractions.h @@ -139,7 +139,6 @@ private: static bool handleRemove(const LLSD& notification, const LLSD& response); static bool handlePay(const LLSD& notification, const LLSD& response, LLUUID avatar_id); static void callback_invite_to_group(LLUUID group_id, LLUUID id); - static void callbackAutoStartCall(const LLSD& data); // Just request friendship, no dialog. static void requestFriendship(const LLUUID& target_id, const std::string& target_name, const std::string& message); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 6c4af0522f..4780b51c55 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -158,7 +158,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) { @@ -413,6 +414,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 @@ -995,18 +1002,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 // @@ -1929,6 +1924,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, diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index c002434a18..c2288a719a 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -105,6 +105,7 @@ public: bool mTextIMPossible; bool mOtherParticipantIsAvatar; + bool mStartCallOnInitialize; }; @@ -124,7 +125,6 @@ public: typedef boost::function session_callback_t; session_signal_t mNewMsgSignal; session_signal_t mNoUnreadMsgsSignal; - session_signal_t mSessionInitializedSignal; /** * Find an IM Session corresponding to session_id @@ -139,7 +139,6 @@ public: boost::signals2::connection addNewMsgCallback( session_callback_t cb ) { return mNewMsgSignal.connect(cb); } boost::signals2::connection addNoUnreadMsgsCallback( session_callback_t cb ) { return mNoUnreadMsgsSignal.connect(cb); } - boost::signals2::connection addSessionInitializedCallback(session_callback_t cb ) { return mSessionInitializedSignal.connect(cb); } /** * Create new session object in a model @@ -213,7 +212,6 @@ public: static bool sendStartSession(const LLUUID& temp_session_id, const LLUUID& other_participant_id, const std::vector& ids, EInstantMessage dialog); static void sendTypingState(LLUUID session_id, LLUUID other_participant_id, BOOL typing); - static void sendSessionInitialized(const LLUUID &session_id); static void sendMessage(const std::string& utf8_text, const LLUUID& im_session_id, const LLUUID& other_participant_id, EInstantMessage dialog); @@ -330,6 +328,9 @@ public: void notifyNewIM(); void clearNewIMNotification(); + // automatically start a call once the session has initialized + void autoStartCallOnStartup(const LLUUID& session_id); + // IM received that you haven't seen yet BOOL getIMReceived() const; diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp index 8c19865550..4f76d32ad5 100644 --- a/indra/newview/llpanelimcontrolpanel.cpp +++ b/indra/newview/llpanelimcontrolpanel.cpp @@ -101,14 +101,6 @@ void LLPanelChatControlPanel::draw() && callback_enabled; childSetEnabled("call_btn", enable_connect); - // send a signal when the floater is fully initialized - // this lets LLAvatarActions::startAdhocCall() start the call - if (enable_connect && !mInitialized) - { - LLIMModel::sendSessionInitialized(mSessionId); - mInitialized = true; - } - LLPanel::draw(); } diff --git a/indra/newview/llpanelimcontrolpanel.h b/indra/newview/llpanelimcontrolpanel.h index 871779b273..711340efc7 100644 --- a/indra/newview/llpanelimcontrolpanel.h +++ b/indra/newview/llpanelimcontrolpanel.h @@ -45,8 +45,7 @@ class LLPanelChatControlPanel : public LLPanel { public: LLPanelChatControlPanel() : - mSessionId(LLUUID()), - mInitialized(false) {}; + mSessionId(LLUUID()) {}; ~LLPanelChatControlPanel(); virtual BOOL postBuild(); @@ -63,7 +62,6 @@ public: private: LLUUID mSessionId; - bool mInitialized; // connection to voice channel state change signal boost::signals2::connection mVoiceChannelStateChangeConnection; -- cgit v1.2.3