PageRenderTime 37ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llvoicechannel.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 206 lines | 128 code | 41 blank | 37 comment | 0 complexity | e716e6d6acad28ad6687571eed443901 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvoicechannel.h
  3. * @brief Voice channel related classes
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_VOICECHANNEL_H
  27. #define LL_VOICECHANNEL_H
  28. #include "llhandle.h"
  29. #include "llvoiceclient.h"
  30. class LLPanel;
  31. class LLVoiceChannel : public LLVoiceClientStatusObserver
  32. {
  33. public:
  34. typedef enum e_voice_channel_state
  35. {
  36. STATE_NO_CHANNEL_INFO,
  37. STATE_ERROR,
  38. STATE_HUNG_UP,
  39. STATE_READY,
  40. STATE_CALL_STARTED,
  41. STATE_RINGING,
  42. STATE_CONNECTED
  43. } EState;
  44. typedef enum e_voice_channel_direction
  45. {
  46. INCOMING_CALL,
  47. OUTGOING_CALL
  48. } EDirection;
  49. typedef boost::signals2::signal<void(const EState& old_state, const EState& new_state, const EDirection& direction, bool ended_by_agent)> state_changed_signal_t;
  50. // on current channel changed signal
  51. typedef boost::function<void(const LLUUID& session_id)> channel_changed_callback_t;
  52. typedef boost::signals2::signal<void(const LLUUID& session_id)> channel_changed_signal_t;
  53. static channel_changed_signal_t sCurrentVoiceChannelChangedSignal;
  54. static boost::signals2::connection setCurrentVoiceChannelChangedCallback(channel_changed_callback_t cb, bool at_front = false);
  55. LLVoiceChannel(const LLUUID& session_id, const std::string& session_name);
  56. virtual ~LLVoiceChannel();
  57. /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
  58. virtual void handleStatusChange(EStatusType status);
  59. virtual void handleError(EStatusType status);
  60. virtual void deactivate();
  61. virtual void activate();
  62. virtual void setChannelInfo(
  63. const std::string& uri,
  64. const std::string& credentials);
  65. virtual void getChannelInfo();
  66. virtual BOOL isActive();
  67. virtual BOOL callStarted();
  68. // Session name is a UI label used for feedback about which person,
  69. // group, or phone number you are talking to
  70. const std::string& getSessionName() const { return mSessionName; }
  71. boost::signals2::connection setStateChangedCallback(const state_changed_signal_t::slot_type& callback)
  72. { return mStateChangedCallback.connect(callback); }
  73. const LLUUID getSessionID() { return mSessionID; }
  74. EState getState() { return mState; }
  75. void updateSessionID(const LLUUID& new_session_id);
  76. const LLSD& getNotifyArgs() { return mNotifyArgs; }
  77. void setCallDirection(EDirection direction) {mCallDirection = direction;}
  78. EDirection getCallDirection() {return mCallDirection;}
  79. static LLVoiceChannel* getChannelByID(const LLUUID& session_id);
  80. static LLVoiceChannel* getChannelByURI(std::string uri);
  81. static LLVoiceChannel* getCurrentVoiceChannel();
  82. static void initClass();
  83. static void suspend();
  84. static void resume();
  85. protected:
  86. virtual void setState(EState state);
  87. /**
  88. * Use this method if you want mStateChangedCallback to be executed while state is changed
  89. */
  90. void doSetState(const EState& state);
  91. void setURI(std::string uri);
  92. // there can be two directions INCOMING and OUTGOING
  93. EDirection mCallDirection;
  94. std::string mURI;
  95. std::string mCredentials;
  96. LLUUID mSessionID;
  97. EState mState;
  98. std::string mSessionName;
  99. LLSD mNotifyArgs;
  100. LLSD mCallDialogPayload;
  101. // true if call was ended by agent
  102. bool mCallEndedByAgent;
  103. BOOL mIgnoreNextSessionLeave;
  104. LLHandle<LLPanel> mLoginNotificationHandle;
  105. typedef std::map<LLUUID, LLVoiceChannel*> voice_channel_map_t;
  106. static voice_channel_map_t sVoiceChannelMap;
  107. typedef std::map<std::string, LLVoiceChannel*> voice_channel_map_uri_t;
  108. static voice_channel_map_uri_t sVoiceChannelURIMap;
  109. static LLVoiceChannel* sCurrentVoiceChannel;
  110. static LLVoiceChannel* sSuspendedVoiceChannel;
  111. static BOOL sSuspended;
  112. private:
  113. state_changed_signal_t mStateChangedCallback;
  114. };
  115. class LLVoiceChannelGroup : public LLVoiceChannel
  116. {
  117. public:
  118. LLVoiceChannelGroup(const LLUUID& session_id, const std::string& session_name);
  119. /*virtual*/ void handleStatusChange(EStatusType status);
  120. /*virtual*/ void handleError(EStatusType status);
  121. /*virtual*/ void activate();
  122. /*virtual*/ void deactivate();
  123. /*vritual*/ void setChannelInfo(
  124. const std::string& uri,
  125. const std::string& credentials);
  126. /*virtual*/ void getChannelInfo();
  127. protected:
  128. virtual void setState(EState state);
  129. private:
  130. U32 mRetries;
  131. BOOL mIsRetrying;
  132. };
  133. class LLVoiceChannelProximal : public LLVoiceChannel, public LLSingleton<LLVoiceChannelProximal>
  134. {
  135. public:
  136. LLVoiceChannelProximal();
  137. /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
  138. /*virtual*/ void handleStatusChange(EStatusType status);
  139. /*virtual*/ void handleError(EStatusType status);
  140. /*virtual*/ BOOL isActive();
  141. /*virtual*/ void activate();
  142. /*virtual*/ void deactivate();
  143. };
  144. class LLVoiceChannelP2P : public LLVoiceChannelGroup
  145. {
  146. public:
  147. LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id);
  148. /*virtual*/ void handleStatusChange(EStatusType status);
  149. /*virtual*/ void handleError(EStatusType status);
  150. /*virtual*/ void activate();
  151. /*virtual*/ void getChannelInfo();
  152. void setSessionHandle(const std::string& handle, const std::string &inURI);
  153. protected:
  154. virtual void setState(EState state);
  155. private:
  156. /**
  157. * Add the caller to the list of people with which we've recently interacted
  158. *
  159. **/
  160. void addToTheRecentPeopleList();
  161. std::string mSessionHandle;
  162. LLUUID mOtherUserID;
  163. BOOL mReceivedCall;
  164. };
  165. #endif // LL_VOICECHANNEL_H