PageRenderTime 385ms CodeModel.GetById 242ms app.highlight 16ms RepoModel.GetById 125ms 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
  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
 27#ifndef LL_VOICECHANNEL_H
 28#define LL_VOICECHANNEL_H
 29
 30#include "llhandle.h"
 31#include "llvoiceclient.h"
 32
 33class LLPanel;
 34
 35class LLVoiceChannel : public LLVoiceClientStatusObserver
 36{
 37public:
 38	typedef enum e_voice_channel_state
 39	{
 40		STATE_NO_CHANNEL_INFO,
 41		STATE_ERROR,
 42		STATE_HUNG_UP,
 43		STATE_READY,
 44		STATE_CALL_STARTED,
 45		STATE_RINGING,
 46		STATE_CONNECTED
 47	} EState;
 48
 49	typedef enum e_voice_channel_direction
 50	{
 51		INCOMING_CALL,
 52		OUTGOING_CALL
 53	} EDirection;
 54
 55	typedef boost::signals2::signal<void(const EState& old_state, const EState& new_state, const EDirection& direction, bool ended_by_agent)> state_changed_signal_t;
 56
 57	// on current channel changed signal
 58	typedef boost::function<void(const LLUUID& session_id)> channel_changed_callback_t;
 59	typedef boost::signals2::signal<void(const LLUUID& session_id)> channel_changed_signal_t;
 60	static channel_changed_signal_t sCurrentVoiceChannelChangedSignal;
 61	static boost::signals2::connection setCurrentVoiceChannelChangedCallback(channel_changed_callback_t cb, bool at_front = false);
 62
 63
 64	LLVoiceChannel(const LLUUID& session_id, const std::string& session_name);
 65	virtual ~LLVoiceChannel();
 66
 67	/*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
 68
 69	virtual void handleStatusChange(EStatusType status);
 70	virtual void handleError(EStatusType status);
 71	virtual void deactivate();
 72	virtual void activate();
 73	virtual void setChannelInfo(
 74		const std::string& uri,
 75		const std::string& credentials);
 76	virtual void getChannelInfo();
 77	virtual BOOL isActive();
 78	virtual BOOL callStarted();
 79
 80	// Session name is a UI label used for feedback about which person,
 81	// group, or phone number you are talking to
 82	const std::string& getSessionName() const { return mSessionName; }
 83
 84	boost::signals2::connection setStateChangedCallback(const state_changed_signal_t::slot_type& callback)
 85	{ return mStateChangedCallback.connect(callback); }
 86
 87	const LLUUID getSessionID() { return mSessionID; }
 88	EState getState() { return mState; }
 89
 90	void updateSessionID(const LLUUID& new_session_id);
 91	const LLSD& getNotifyArgs() { return mNotifyArgs; }
 92
 93	void setCallDirection(EDirection direction) {mCallDirection = direction;}
 94	EDirection getCallDirection() {return mCallDirection;}
 95
 96	static LLVoiceChannel* getChannelByID(const LLUUID& session_id);
 97	static LLVoiceChannel* getChannelByURI(std::string uri);
 98	static LLVoiceChannel* getCurrentVoiceChannel();
 99	
100	static void initClass();
101	
102	static void suspend();
103	static void resume();
104
105protected:
106	virtual void setState(EState state);
107	/**
108	 * Use this method if you want mStateChangedCallback to be executed while state is changed
109	 */
110	void doSetState(const EState& state);
111	void setURI(std::string uri);
112
113	// there can be two directions INCOMING and OUTGOING
114	EDirection mCallDirection;
115
116	std::string	mURI;
117	std::string	mCredentials;
118	LLUUID		mSessionID;
119	EState		mState;
120	std::string	mSessionName;
121	LLSD mNotifyArgs;
122	LLSD mCallDialogPayload;
123	// true if call was ended by agent
124	bool mCallEndedByAgent;
125	BOOL		mIgnoreNextSessionLeave;
126	LLHandle<LLPanel> mLoginNotificationHandle;
127
128	typedef std::map<LLUUID, LLVoiceChannel*> voice_channel_map_t;
129	static voice_channel_map_t sVoiceChannelMap;
130
131	typedef std::map<std::string, LLVoiceChannel*> voice_channel_map_uri_t;
132	static voice_channel_map_uri_t sVoiceChannelURIMap;
133
134	static LLVoiceChannel* sCurrentVoiceChannel;
135	static LLVoiceChannel* sSuspendedVoiceChannel;
136	static BOOL sSuspended;
137
138private:
139	state_changed_signal_t mStateChangedCallback;
140};
141
142class LLVoiceChannelGroup : public LLVoiceChannel
143{
144public:
145	LLVoiceChannelGroup(const LLUUID& session_id, const std::string& session_name);
146
147	/*virtual*/ void handleStatusChange(EStatusType status);
148	/*virtual*/ void handleError(EStatusType status);
149	/*virtual*/ void activate();
150	/*virtual*/ void deactivate();
151	/*vritual*/ void setChannelInfo(
152		const std::string& uri,
153		const std::string& credentials);
154	/*virtual*/ void getChannelInfo();
155
156protected:
157	virtual void setState(EState state);
158
159private:
160	U32 mRetries;
161	BOOL mIsRetrying;
162};
163
164class LLVoiceChannelProximal : public LLVoiceChannel, public LLSingleton<LLVoiceChannelProximal>
165{
166public:
167	LLVoiceChannelProximal();
168
169	/*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
170	/*virtual*/ void handleStatusChange(EStatusType status);
171	/*virtual*/ void handleError(EStatusType status);
172	/*virtual*/ BOOL isActive();
173	/*virtual*/ void activate();
174	/*virtual*/ void deactivate();
175
176};
177
178class LLVoiceChannelP2P : public LLVoiceChannelGroup
179{
180public:
181	LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id);
182
183	/*virtual*/ void handleStatusChange(EStatusType status);
184	/*virtual*/ void handleError(EStatusType status);
185    /*virtual*/ void activate();
186	/*virtual*/ void getChannelInfo();
187
188	void setSessionHandle(const std::string& handle, const std::string &inURI);
189
190protected:
191	virtual void setState(EState state);
192
193private:
194
195	/**
196	* Add the caller to the list of people with which we've recently interacted
197	*
198	**/
199	void addToTheRecentPeopleList();
200
201	std::string	mSessionHandle;
202	LLUUID		mOtherUserID;
203	BOOL		mReceivedCall;
204};
205
206#endif  // LL_VOICECHANNEL_H