|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMCESESSION_H |
|
20 #define CMCESESSION_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <mcedefs.h> |
|
24 #include <e32base.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CDesC8Array; |
|
28 class TMceIds; |
|
29 class CMceMediaStream; |
|
30 class CMceManager; |
|
31 class TMceFactory; |
|
32 class RReadStream; |
|
33 class RWriteStream; |
|
34 class CMceItcSender; |
|
35 class CMceSessionReceiver; |
|
36 class MMceFcMsgObserver; |
|
37 class CMceComSession; |
|
38 class CMceMsgBase; |
|
39 class TMceEvent; |
|
40 class CMceInSession; |
|
41 class MDesC8Array; |
|
42 class CMceStreamBundle; |
|
43 |
|
44 |
|
45 // CLASS DECLARATION |
|
46 |
|
47 /** |
|
48 * Base class for MCE sessions, inherited by both CMceInSession and CMceOutSession. |
|
49 * |
|
50 * CMceSession represents peer-to-peer connection made with remote terminal. |
|
51 * This connection is also known as dialog and it is set up using SIP INVITE |
|
52 * method. |
|
53 * |
|
54 * The characteristics of the session are defined by user of this class by attaching |
|
55 * media streams into the session. |
|
56 * |
|
57 * After the session has been succesfylly established, it can be later updated and |
|
58 * must be finally terminated. |
|
59 * |
|
60 * If for any reason instance of this class is deleted while in established state, |
|
61 * session is automatically terminated by MCE server. |
|
62 * |
|
63 * @lib mceclient.lib |
|
64 */ |
|
65 class CMceSession : public CBase |
|
66 { |
|
67 public: // Session states |
|
68 |
|
69 enum TState |
|
70 { |
|
71 EIdle, // Idle |
|
72 EOffering, // Outgoing session, or session update establishment in progress, |
|
73 EIncoming, // Session received incoming call |
|
74 EReserving, // UpdateL called to incoming session during session establishment |
|
75 EAnswering, // Answering an incoming call |
|
76 EProceeding, // Session media negotiations proceeding |
|
77 EEstablished, // Session established |
|
78 ECancelling, // Cancelling outgoing session establishment |
|
79 ETerminating, // Terminating session |
|
80 ETerminated, // Session terminated |
|
81 }; |
|
82 |
|
83 public: // Session termination reasons |
|
84 |
|
85 enum TReason |
|
86 { |
|
87 EDeclined, |
|
88 EBusy, |
|
89 ECancelled, |
|
90 EDisconnected |
|
91 }; |
|
92 |
|
93 public: |
|
94 |
|
95 /** |
|
96 * Destructor. |
|
97 */ |
|
98 virtual ~CMceSession(); |
|
99 |
|
100 public: // Functions |
|
101 |
|
102 /** |
|
103 * Returns the state of the session. |
|
104 * @return The current state of the session |
|
105 */ |
|
106 IMPORT_C TState State() const; |
|
107 |
|
108 /** |
|
109 * Returns the state of network connection of the session. |
|
110 * @return ETrue if connection active, EFalse if connection inactive. |
|
111 */ |
|
112 IMPORT_C TBool ConnectionActive() const; |
|
113 |
|
114 |
|
115 /** |
|
116 * Removes media stream from session. |
|
117 * @pre State() == CMceSession::EIdle || |
|
118 * State() == CMceSession::EIncoming || |
|
119 * State() == CMceSession::EEstablished |
|
120 * @post aMediaStream cannot be used anymore and contents of |
|
121 * previously returned stream array (CMceSession::Streams()) |
|
122 * are not anymore valid |
|
123 * @param aMediaStream media stream to be removed |
|
124 */ |
|
125 IMPORT_C void RemoveStreamL( CMceMediaStream& aMediaStream ); |
|
126 |
|
127 /** |
|
128 * Adds media stream into session. |
|
129 * @pre State() == CMceSession::EIdle || |
|
130 * State() == CMceSession::EIncoming || |
|
131 * State() == CMceSession::EEstablished |
|
132 * @pre aMediaStream != 0 |
|
133 * @param aMediaStream, media stream to be added. |
|
134 * ownership is transferred. |
|
135 */ |
|
136 virtual void AddStreamL( CMceMediaStream* aMediaStream ); |
|
137 |
|
138 /** |
|
139 * Updates offered session parameters during session |
|
140 * establishement phase for first answer. |
|
141 * Updates established session using re-invite. |
|
142 * In state EIncoming the timeout value must be smaller or equal to |
|
143 * offered value obtained by SessionTimer(). |
|
144 * @pre State() == CMceSession::EIncoming || |
|
145 * State() == CMceSession::EEstablished |
|
146 * @post State() == CMceSession::EReserving for incoming session || |
|
147 * State() == CMceSession::EOffering for established session |
|
148 * @param aTimeout, the session timer value in seconds |
|
149 * @param aHeaders, SIP headers to be added. Ownership is |
|
150 * transferred. |
|
151 * @param aContentType, content type of the body. |
|
152 * Ownership is transferred. |
|
153 * @param aContent, content to be added in body. Ownership is |
|
154 * transferred. |
|
155 * @param aContentHeaders, content headers to be added. Ownership is |
|
156 * transferred. |
|
157 */ |
|
158 IMPORT_C void UpdateL( |
|
159 TUint32 aTimeout = 0, |
|
160 CDesC8Array* aHeaders = 0, |
|
161 HBufC8* aContentType = 0, |
|
162 HBufC8* aContent = 0, |
|
163 CDesC8Array* aContentHeaders = 0 ); |
|
164 |
|
165 /** |
|
166 * Terminates established session. |
|
167 * @pre State() == CMceSession::EEstablished |
|
168 * @post State() == CMceSession::ETerminating |
|
169 * @param aHeaders, SIP headers to be added. Ownership is |
|
170 * transferred. |
|
171 * @param aContentType, content type of the body. |
|
172 * Ownership is transferred. |
|
173 * @param aContent, content to be added in body. Ownership is |
|
174 * transferred. |
|
175 */ |
|
176 IMPORT_C void TerminateL( CDesC8Array* aHeaders = 0, |
|
177 HBufC8* aContentType = 0, |
|
178 HBufC8* aContent = 0 ); |
|
179 |
|
180 /** |
|
181 * Returns the streams belonging to the session. |
|
182 * @return streams of the session. |
|
183 */ |
|
184 IMPORT_C const RPointerArray<CMceMediaStream>& Streams() const; |
|
185 |
|
186 /** |
|
187 * Returns the recipient of the session. |
|
188 * @pre State() == CMceSession::EIncoming || |
|
189 * State() == CMceSession::EEstablished |
|
190 * @return The recipients address. |
|
191 */ |
|
192 IMPORT_C const TDesC8& Recipient() const; |
|
193 |
|
194 /** |
|
195 * Returns the originator of the session. |
|
196 * @pre State() == CMceSession::EIdle || |
|
197 * State() == CMceSession::EIncoming || |
|
198 * State() == CMceSession::EEstablished |
|
199 * @return the originators address. |
|
200 */ |
|
201 IMPORT_C const TDesC8& Originator() const; |
|
202 |
|
203 /** |
|
204 * Configures session by updating SDP session lines. |
|
205 * In order to get complete update, whole session must be |
|
206 * updated causing sending of re-invite. |
|
207 * @pre State() == CMceSession::EIdle || |
|
208 * State() == CMceSession::EIncoming || |
|
209 * State() == CMceSession::EEstablished |
|
210 * @pre aSessionSDPLines != 0 |
|
211 * @param aSessionSDPLines, application specific SDP lines for session. |
|
212 * Ownership is transferred. |
|
213 */ |
|
214 IMPORT_C void SetSessionSDPLinesL( CDesC8Array* aSessionSDPLines ); |
|
215 |
|
216 /** |
|
217 * Gets SDP lines of the session. |
|
218 * @return array of session SDP lines, owneship is transferred. |
|
219 */ |
|
220 IMPORT_C MDesC8Array* SessionSDPLinesL(); |
|
221 |
|
222 /** |
|
223 * Returns the session timer value of the session. |
|
224 * @return the session timer value. |
|
225 */ |
|
226 IMPORT_C TUint32 SessionTimer() const; |
|
227 |
|
228 /** |
|
229 * Adds grouped media streams to the session. Changes SDP |
|
230 * of the session. In order to get complete update, whole |
|
231 * session must be updated causing sending of re-invite. |
|
232 * @pre State() == CMceSession::EIdle || |
|
233 * State() == CMceSession::EIncoming || |
|
234 * State() == CMceSession::EEstablished |
|
235 * @pre aBundle != 0 |
|
236 * @param aBundle group of media streams; |
|
237 * ownership of the bundle is transferred |
|
238 */ |
|
239 IMPORT_C void AddBundleL( CMceStreamBundle* aBundle ); |
|
240 |
|
241 /** |
|
242 * Removes grouped media stream from session. Changes SDP |
|
243 * of the session. In order to get complete update, whole |
|
244 * session must be updated causing sending of re-invite. |
|
245 * @pre State() == CMceSession::EIdle || |
|
246 * State() == CMceSession::EIncoming || |
|
247 * State() == CMceSession::EEstablished |
|
248 * @post aBundle cannot be used anymore and contents of |
|
249 * previously returned bundle array (CMceSession::Bundles()) |
|
250 * are not anymore valid |
|
251 * @param aBundle bundle to be removed |
|
252 */ |
|
253 IMPORT_C void RemoveBundleL( CMceStreamBundle& aBundle ); |
|
254 |
|
255 /** |
|
256 * Gets the grouped media streams of the session. |
|
257 * @return bundles of the session |
|
258 */ |
|
259 IMPORT_C const RPointerArray< CMceStreamBundle >& Bundles() const; |
|
260 |
|
261 /** |
|
262 * Gets session modifier of type TUint. |
|
263 * @param aModifier is a modifier to be retrieved |
|
264 * @param aValue on return will contain modifier value |
|
265 * @leave KErrNotFound if modifier is not found |
|
266 */ |
|
267 IMPORT_C void GetModifierL( TMceSessionModifier aModifier, |
|
268 TUint& aValue ) const; |
|
269 |
|
270 /** |
|
271 * Sets session modifier of type TUint. |
|
272 * @param aModifier is a modifier to be set |
|
273 * @param aValue is a new value of a modifier |
|
274 * @leave KErrNotFound if modifier is not found |
|
275 */ |
|
276 IMPORT_C void SetModifierL( TMceSessionModifier aModifier, |
|
277 TUint aValue ); |
|
278 |
|
279 /** |
|
280 * Returns the identifier of profile used by the sesison. |
|
281 * @return TUint32 Identifier of the used profile. 0, |
|
282 * if session is setup without profile. |
|
283 */ |
|
284 IMPORT_C TUint32 Profile() const; |
|
285 |
|
286 public: |
|
287 |
|
288 CMceManager& Manager() const; |
|
289 |
|
290 protected: |
|
291 |
|
292 /** |
|
293 * C++ default constructor. |
|
294 * @param aManager, reference to session manager. |
|
295 * @param aProfileId, id of the sip profile used for the session. |
|
296 */ |
|
297 CMceSession( CMceManager* aManager, TUint32 aProfileId ); |
|
298 |
|
299 /** |
|
300 * second-phase constructor |
|
301 */ |
|
302 void ConstructL(); |
|
303 |
|
304 /** |
|
305 * Initializes |
|
306 */ |
|
307 void InitializeL(); |
|
308 |
|
309 |
|
310 protected: // Not owned data |
|
311 |
|
312 /** |
|
313 * profile id |
|
314 */ |
|
315 TUint32 iProfileId; |
|
316 |
|
317 private: // Owned data |
|
318 |
|
319 /** |
|
320 * media streams |
|
321 */ |
|
322 RPointerArray<CMceMediaStream> iMediaStreams; |
|
323 |
|
324 /** |
|
325 * bundles |
|
326 */ |
|
327 RPointerArray<CMceStreamBundle> iBundles; |
|
328 |
|
329 //for testing |
|
330 |
|
331 //friend class CMceManager; |
|
332 |
|
333 public: // stub data |
|
334 |
|
335 CMceManager* iManager; |
|
336 |
|
337 CMceSession::TState iState; |
|
338 |
|
339 TBool iIsConnectionActive; |
|
340 |
|
341 HBufC8* iOriginator; |
|
342 |
|
343 HBufC8* iRecipient; |
|
344 |
|
345 TUint32 iTimeout; |
|
346 |
|
347 CDesC8Array* iSessionSDPLines; |
|
348 |
|
349 CDesC8Array* iHeaders; |
|
350 |
|
351 TBool iForceInternetSignaling; |
|
352 |
|
353 TUint i100RelUsage; |
|
354 |
|
355 // If this code is != KErrNone, next operation that can fail will fail |
|
356 // (leave or return a value) with this code. Variable is reseted before |
|
357 // failing. |
|
358 // Obs! Check that wanted failing is really implemented in this stub |
|
359 TInt iFailWithCode; |
|
360 |
|
361 TBuf8<200> iReasonPhrase; |
|
362 |
|
363 TInt iReasonCode; |
|
364 }; |
|
365 |
|
366 #endif |