1 /* |
|
2 * Copyright (c) 2006 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: Transfer state context class for state machine logic |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SVPTRANSFERSTATECONTEXT_H |
|
20 #define SVPTRANSFERSTATECONTEXT_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <badesca.h> // CDesC8ArrayFlat |
|
24 #include "svputdefs.h" |
|
25 |
|
26 class CSVPController; |
|
27 class CSVPSessionBase; |
|
28 class CSVPTransferStateBase; // iCurrentState |
|
29 class MSVPTransferObserver; // iTransferObserver |
|
30 class CMceSession; |
|
31 class TMceTransactionDataContainer; // iContainer |
|
32 class CMceRefer; // iMceRefer |
|
33 class CMceEvent; // iMceEvent |
|
34 |
|
35 typedef TInt TSVPTransferStateIndex; |
|
36 |
|
37 const TInt KSVPTransferStateArraySize = 5; |
|
38 const TInt KSVPHeaderArrayGranularity = 2; |
|
39 |
|
40 // State indices. |
|
41 const TSVPTransferStateIndex KSVPTransferIdleStateIndex = 0; |
|
42 const TSVPTransferStateIndex KSVPTransferPendingStateIndex = 1; |
|
43 const TSVPTransferStateIndex KSVPTransferAcceptedStateIndex = 2; |
|
44 const TSVPTransferStateIndex KSVPTransferTerminatingStateIndex = 3; |
|
45 const TSVPTransferStateIndex KSVPTransferTerminatedStateIndex = 4; |
|
46 |
|
47 // Error codes |
|
48 const TInt KSVPErrTransferErrorBase = -2300; |
|
49 const TInt KSVPErrTransferStateError = KSVPErrTransferErrorBase - 1; |
|
50 const TInt KSVPErrTransferInProgress = KSVPErrTransferErrorBase - 2; |
|
51 const TInt KSVPErrTransferReferCreate = KSVPErrTransferErrorBase - 3; |
|
52 const TInt KSVPErrTransferApplyState = KSVPErrTransferErrorBase - 4; |
|
53 const TInt KSVPErrTransferReferStatusCodeNotHandled = |
|
54 KSVPErrTransferErrorBase - 5; |
|
55 const TInt KSVPErrTransferParamRefer = KSVPErrTransferErrorBase - 6; |
|
56 const TInt KSVPErrTransferReferTo = KSVPErrTransferErrorBase - 7; |
|
57 |
|
58 |
|
59 |
|
60 /** |
|
61 * Transfer state contexts. |
|
62 * |
|
63 * |
|
64 * @lib svp.dll |
|
65 * @since S60 3.2 |
|
66 */ |
|
67 class CSVPTransferStateContext : public CBase |
|
68 { |
|
69 |
|
70 public: |
|
71 |
|
72 /** |
|
73 * Two-phased constructor. |
|
74 */ |
|
75 static CSVPTransferStateContext* NewL( |
|
76 CMceSession* aMceSession, |
|
77 CSVPSessionBase* aSVPSession, |
|
78 TMceTransactionDataContainer& aContainer, |
|
79 MSVPTransferObserver& aObserver ); |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 virtual ~CSVPTransferStateContext(); |
|
85 |
|
86 /** |
|
87 * Sets the current state for the context. |
|
88 * @since S60 3.2 |
|
89 * @param aNewState New current state |
|
90 * @return Leaves with Error code if state transition is not |
|
91 * acceptable. |
|
92 */ |
|
93 void SetCurrentStateL( TSVPTransferStateIndex aNewState ); |
|
94 |
|
95 /** |
|
96 * Returns the current state of the context |
|
97 * @since S60 3.2 |
|
98 * @return TSVPTransferStateIndex Index to the current state. |
|
99 */ |
|
100 TSVPTransferStateIndex CurrentState() const; |
|
101 |
|
102 /** |
|
103 * Applies the current state of the contex. This causes a |
|
104 * state transition to next state of the state machine. The |
|
105 * current state sets the next state. Leaves on error |
|
106 * @since S60 3.2 |
|
107 */ |
|
108 void ApplyCurrentStateL(); |
|
109 |
|
110 /** |
|
111 * Returns reference to the transfer observer. |
|
112 * @since S60 3.2 |
|
113 * @return Reference to the transfer observer |
|
114 */ |
|
115 MSVPTransferObserver& TransferObserver(); |
|
116 |
|
117 /** |
|
118 * Sets the reference to the sip (mce) session object |
|
119 * @param aSession The session object |
|
120 * @return None |
|
121 */ |
|
122 void SetMceSessionObject( CMceSession* aSession ); |
|
123 |
|
124 /** |
|
125 * Returns the sip (mce) session object. |
|
126 * @since S60 3.2 |
|
127 * @return The sip (mce) session object |
|
128 */ |
|
129 CMceSession* MceSessionObject(); |
|
130 |
|
131 /** |
|
132 * Sets the MCE refer object. |
|
133 * @since Series 60 3.2 |
|
134 * @param aRefer New received refer |
|
135 */ |
|
136 void SetMceRefer( CMceRefer* aRefer ); |
|
137 |
|
138 /** |
|
139 * Returns pointer to the MCE refer object. |
|
140 * @since S60 3.2 |
|
141 * @return Pointer to the MCE refer object |
|
142 */ |
|
143 CMceRefer* MceRefer(); |
|
144 |
|
145 /** |
|
146 * Check if attended or unattended transfer. |
|
147 * @since S60 3.2 |
|
148 * @return Boolean true (=attended) or false |
|
149 */ |
|
150 TBool IsAttended(); |
|
151 |
|
152 /** |
|
153 * Check if session is on remote hold. If yes, this is Snom or EyeBeam |
|
154 * as unattended transferer case and we send OK notify |
|
155 * to proceed unattended transfer. |
|
156 * @since S60 3.2 |
|
157 * @return TBool true if session is remote hold |
|
158 */ |
|
159 TBool CheckIsSessionRemoteHold(); |
|
160 |
|
161 /** |
|
162 * Set transfer data. Add Replaces and Referred-By headers. |
|
163 * Update transfer target url to sips: if secure status 1 or 2, |
|
164 * otherwise url updated to sip: |
|
165 * @since S60 3.2 |
|
166 * @param aUserAgentHeaders On completion contains collected transfer headers. |
|
167 * @param aSecureStatus secure status |
|
168 */ |
|
169 void SetTransferDataL( CDesC8Array* aUserAgentHeaders, TInt aSecureStatus ); |
|
170 |
|
171 /** |
|
172 * Set attended/unattended. |
|
173 * @since S60 3.2 |
|
174 * @param aAttended boolean true (=attended) or false |
|
175 */ |
|
176 void SetAttended( const TBool aAttended ); |
|
177 |
|
178 /** |
|
179 * Check if incoming transfer. |
|
180 * @since S60 3.2 |
|
181 * @return Boolean true (=incoming) or false |
|
182 */ |
|
183 TBool IsIncoming(); |
|
184 |
|
185 /** |
|
186 * Set incoming "refer to" -string. |
|
187 * @since S60 3.2 |
|
188 * @param aReferTo Reference to the string |
|
189 */ |
|
190 void SetIncomingReferToL( const TDesC8& aReferTo ); |
|
191 |
|
192 /** |
|
193 * Sets the Referred-By data |
|
194 * @since S60 3.2 |
|
195 * @param aReferredBy reference to the Referred-By data to store |
|
196 */ |
|
197 void SetIncomingReferredByL( const TDesC8& aReferredBy ); |
|
198 |
|
199 /** |
|
200 * Return incoming "Referred By" -string. |
|
201 * @since S60 3.2 |
|
202 * @return Reference to the string |
|
203 */ |
|
204 const TDesC& IncomingReferredBy(); |
|
205 |
|
206 /** |
|
207 * Return incoming "refer to" -string. |
|
208 * @since S60 3.2 |
|
209 * @return Reference to the string |
|
210 */ |
|
211 const TDesC& IncomingReferTo(); |
|
212 |
|
213 /** |
|
214 * Reset/clear incoming "refer to" -string. |
|
215 * @since S60 3.2 |
|
216 */ |
|
217 void ResetIncomingReferTo(); |
|
218 |
|
219 /** |
|
220 * Reset/clear incoming "Referred-By" -string. |
|
221 * @since S60 3.2 |
|
222 */ |
|
223 void ResetIncomingReferredBy(); |
|
224 |
|
225 /** |
|
226 * Set incoming "Replaces" -string. |
|
227 * @since S60 3.2 |
|
228 * @param aString Reference to the string |
|
229 */ |
|
230 void SetIncomingReplacesL( const TDesC8& aString ); |
|
231 |
|
232 /** |
|
233 * Return incoming "Replaces" -string. |
|
234 * @since S60 3.2 |
|
235 * @return Reference to the string |
|
236 */ |
|
237 const TDesC& IncomingReplaces(); |
|
238 |
|
239 /** |
|
240 * Reset/clear incoming "Replaces" -string. |
|
241 * @since S60 3.2 |
|
242 */ |
|
243 void ResetIncomingReplaces(); |
|
244 |
|
245 /** |
|
246 * Store the parameters for the mce out refer. |
|
247 * @since S60 3.2 |
|
248 * @param aTargetSession target receiver of the transferred call, |
|
249 * null if address is given. |
|
250 * @param aTarget transfer target address, KNullDesC if call is given. |
|
251 * @param aAttendedTransfer boolean true if attended transfer. |
|
252 */ |
|
253 void SetTransferParmsL( CSVPSessionBase* aTargetSession, |
|
254 const TDesC& aTarget, |
|
255 const TBool aAttendedTransfer ); |
|
256 |
|
257 /** |
|
258 * Execute the refer, creates mce out event. |
|
259 * @since S60 3.2 |
|
260 * @return KErrNone if ok, SVP transfer error on failure |
|
261 */ |
|
262 void ExecuteReferL(); |
|
263 |
|
264 /** |
|
265 * Sets the MCE event object. |
|
266 * @since Series 60 3.2 |
|
267 * @param aEvent New received event |
|
268 */ |
|
269 void SetMceEvent( CMceEvent* aEvent ); |
|
270 |
|
271 /** |
|
272 * Returns pointer to the MCE event object. |
|
273 * @since S60 3.2 |
|
274 * @return Pointer to the MCE event object |
|
275 */ |
|
276 CMceEvent* MceEvent(); |
|
277 |
|
278 /** |
|
279 * Stop the refer timer. |
|
280 * @since Series 60 3.2 |
|
281 */ |
|
282 void StopReferTimer(); |
|
283 |
|
284 |
|
285 protected: // New functions |
|
286 |
|
287 /** |
|
288 * Creates the states belonging to this context |
|
289 * @since S60 3.2 |
|
290 */ |
|
291 void InitializeStateArrayL(); |
|
292 |
|
293 /** |
|
294 * Check if state transition to a new state is acceptable. |
|
295 * @since S60 3.2 |
|
296 * @param aStateIndex New state to enter |
|
297 * @return Boolean value, is the transition valid. |
|
298 */ |
|
299 TBool IsStateTransitionAccepted( |
|
300 const TSVPTransferStateIndex aStateIndex ); |
|
301 |
|
302 /** |
|
303 * C++ default constructor. |
|
304 */ |
|
305 CSVPTransferStateContext( CMceSession* aMceSession, |
|
306 CSVPSessionBase* aSVPSession, |
|
307 TMceTransactionDataContainer& aContainer, |
|
308 MSVPTransferObserver& aObserver ); |
|
309 |
|
310 /** |
|
311 * By default Symbian 2nd phase constructor is private. |
|
312 * Now it is protected. |
|
313 */ |
|
314 void ConstructL(); |
|
315 |
|
316 |
|
317 private: // New Functions |
|
318 |
|
319 /** |
|
320 * Set up headers for refer call. |
|
321 * @since S60 3.2 |
|
322 * @return Pointer to the new created headers data |
|
323 */ |
|
324 CDesC8Array* SetupHeadersL(); |
|
325 |
|
326 /** |
|
327 * Create mce out refer using target address. |
|
328 * @since S60 3.2 |
|
329 * @param aTarget Address of the target. |
|
330 */ |
|
331 void CreateMceOutReferL( const TDesC& aTarget ); |
|
332 |
|
333 /** |
|
334 * Create mce out refer using session. |
|
335 * @since S60 3.2 |
|
336 * @param aTargetSession Pointer to the target session. |
|
337 */ |
|
338 void CreateMceOutReferL( CSVPSessionBase* aTargetSession ); |
|
339 |
|
340 /** |
|
341 * Method for completing referTo |
|
342 * @since Series 60 3.2 |
|
343 * @param aReferTo referto |
|
344 * @return HBufC8* constructed aReferTo |
|
345 */ |
|
346 HBufC8* CompleteReferToL( const TDesC8& aReferTo ); |
|
347 |
|
348 /** |
|
349 * Method for completing referred by |
|
350 * @since Series 60 3.2 |
|
351 * @param aReferredBy Referred By |
|
352 * @return HBufC8* constructed aReferredBy |
|
353 */ |
|
354 HBufC8* CompleteReferredByL( const TDesC8& aReferredBy ); |
|
355 |
|
356 /** |
|
357 * Method for completing Replaces |
|
358 * @since Series 60 3.2 |
|
359 * @param aString Replaces string |
|
360 * @return HBufC8* constructed Replaces string |
|
361 */ |
|
362 HBufC8* CompleteReplacesL( const TDesC8& aString ); |
|
363 |
|
364 /** |
|
365 * Checks, if the URI given as parameter has |
|
366 * the "<" character. |
|
367 * @since S60 3.2 |
|
368 * @param aUri The URI to be checked, non-modifiable descriptor. |
|
369 * @return TInt, position of the character, |
|
370 * KErrNotFound, if not found. |
|
371 */ |
|
372 TInt CheckLeftBracket( const TDesC8& aUri ) const; |
|
373 |
|
374 /** |
|
375 * Removes the "<" character and all characters |
|
376 * before the position from the URI given as parameter. |
|
377 * @since S60 3.2 |
|
378 * @param aUri The URI to be altered, modifiable descriptor. |
|
379 * @param aPosition, position of string. |
|
380 * @return None |
|
381 */ |
|
382 void RemoveLeftBracket( HBufC8*& aUri, TInt aPosition ) const; |
|
383 |
|
384 /** |
|
385 * Checks, if the URI given as parameter has |
|
386 * the ">" character. |
|
387 * @since S60 3.2 |
|
388 * @param aUri The URI to be checked, non-modifiable descriptor. |
|
389 * @return TInt, position of the character, |
|
390 * KErrNotFound, if not found. |
|
391 */ |
|
392 TInt CheckRightBracket( const TDesC8& aUri ) const; |
|
393 |
|
394 /** |
|
395 * Removes the all characters from the URI after the position. |
|
396 * @since S60 3.2 |
|
397 * @param aUri, the URI to be altered, modifiable descriptor. |
|
398 * @param aPosition, position where removing starts. |
|
399 * @return None |
|
400 */ |
|
401 void CutStringFromPosition( HBufC8*& aUri, TInt aPosition ) const; |
|
402 |
|
403 /** |
|
404 * Checks, if the URI given as parameter has |
|
405 * the "?X-Sipx-Authidentity=" string. |
|
406 * Some server might add that to Refer-To header. |
|
407 * @since S60 3.2 |
|
408 * @param aUri The URI to be checked, non-modifiable descriptor. |
|
409 * @return TInt, position of the character, |
|
410 * KErrNotFound, if not found. |
|
411 */ |
|
412 TInt CheckAuthidentity( const TDesC8& aUri ) const; |
|
413 |
|
414 /** |
|
415 * Checks, if the URI given as parameter has the "?Replaces=" text. |
|
416 * @since S60 3.2 |
|
417 * @param aUri The URI to be checked, non-modifiable descriptor. |
|
418 * @return TInt, position of the chareacter, |
|
419 * KErrNotFound, if not found. |
|
420 */ |
|
421 TInt CheckReplacesTxt( const TDesC8& aUri ) const; |
|
422 |
|
423 /** |
|
424 * Checks, if the URI given as parameter has the "Referred-By:" text. |
|
425 * @since S60 3.2 |
|
426 * @param aReferredBy The URI to be checked, non-modifiable descriptor. |
|
427 * @return TInt, position of the chareacter, |
|
428 * KErrNotFound, if not found. |
|
429 */ |
|
430 TInt CheckReferredByTxt( const TDesC8& aReferredBy ) const; |
|
431 |
|
432 /** |
|
433 * Removes the "Referred-By:" text |
|
434 * @since S60 3.2 |
|
435 * @param aReferredBy The text to be altered, modifiable descriptor. |
|
436 * @param aPosition, position of string. |
|
437 * @return None |
|
438 */ |
|
439 void RemoveReferredByTxt( HBufC8*& aReferredBy, TInt aPosition ) const; |
|
440 |
|
441 /** |
|
442 * Take the "?Replaces=" text and text after it. |
|
443 * @since S60 3.2 |
|
444 * @param aUri The URI to be altered, modifiable descriptor. |
|
445 * @param aPosition, position of string. |
|
446 * @return None |
|
447 */ |
|
448 void TakeReplacesTxt( HBufC8*& aString, TInt aPosition ) const; |
|
449 |
|
450 /** |
|
451 * Checks, if the URI given as parameter has |
|
452 * the ";user=phone" text. |
|
453 * @since S60 3.2 |
|
454 * @param aUri The URI to be checked, non-modifiable descriptor. |
|
455 * @return TInt, position of the chareacter, |
|
456 * KErrNotFound, if not found. |
|
457 */ |
|
458 TInt CheckUserEqualsPhone( const TDesC8& aUri ) const; |
|
459 |
|
460 /** |
|
461 * Removes the ";user=phone" text and text after it. |
|
462 * @since S60 3.2 |
|
463 * @param aUri The URI to be altered, modifiable descriptor. |
|
464 * @param aPosition, position of string. |
|
465 * @return None |
|
466 */ |
|
467 void RemoveUserEqualsPhone( HBufC8*& aUri, TInt aPosition ) const; |
|
468 |
|
469 /** |
|
470 * Removes all extra parameters from given address |
|
471 * @since S60 3.2 |
|
472 * @param aUri The URI to be altered, modifiable descriptor. |
|
473 * @return None |
|
474 */ |
|
475 void RemoveExtraParameters( HBufC8*& aUri ) const; |
|
476 |
|
477 /** |
|
478 * Update transfer target url to sips: if secure status 1 or 2. |
|
479 * Otherwise url updated to sip: |
|
480 * @since S60 3.2 |
|
481 * @param aSecureStatus secure status |
|
482 */ |
|
483 void UpdateTransferTargetL( TInt aSecureStatus ); |
|
484 |
|
485 private: // data |
|
486 |
|
487 /** |
|
488 * Pointer to the mce session object. |
|
489 * Not own. |
|
490 */ |
|
491 CMceSession* iMceSession; |
|
492 |
|
493 /** |
|
494 * Pointer to the SVP session object. |
|
495 * Not own. |
|
496 */ |
|
497 CSVPSessionBase* iSVPSession; |
|
498 |
|
499 /** |
|
500 * Pointer to the target of attended transfer. |
|
501 * Not own. |
|
502 */ |
|
503 CSVPSessionBase* iTargetSession; |
|
504 |
|
505 /** |
|
506 * Data container for mce session. |
|
507 */ |
|
508 TMceTransactionDataContainer& iContainer; |
|
509 |
|
510 /** |
|
511 * Reference to the transfer observer. |
|
512 */ |
|
513 MSVPTransferObserver& iTransferObserver; |
|
514 |
|
515 /** |
|
516 * Transfer state array. |
|
517 * Own. |
|
518 */ |
|
519 RPointerArray< CSVPTransferStateBase >* iStates; |
|
520 |
|
521 /** |
|
522 * State object pointer to indicate current state. |
|
523 */ |
|
524 CSVPTransferStateBase* iCurrentState; |
|
525 |
|
526 /** |
|
527 * Mce refer, either in (MT) or out (MO) type. |
|
528 * Own. |
|
529 */ |
|
530 CMceRefer* iMceRefer; |
|
531 |
|
532 /** |
|
533 * Mce event, either in (MT) or out (MO) type. |
|
534 * Own. |
|
535 */ |
|
536 CMceEvent* iMceEvent; |
|
537 |
|
538 /** |
|
539 * Attended (consultative) / unattended (blind) transfer. |
|
540 */ |
|
541 TBool iAttended; |
|
542 |
|
543 /** |
|
544 * Incoming "refer to" parameter string |
|
545 * Indicates also the incoming refer handling. |
|
546 */ |
|
547 HBufC* iIncomingReferTo; |
|
548 |
|
549 /** |
|
550 * Incoming "Referred By" parameter string |
|
551 */ |
|
552 HBufC* iIncomingReferredBy; |
|
553 |
|
554 /** |
|
555 * Incoming "Replaces" parameter string |
|
556 */ |
|
557 HBufC* iIncomingReplaces; |
|
558 |
|
559 private: |
|
560 |
|
561 // For testing |
|
562 SVP_UT_DEFS |
|
563 |
|
564 }; |
|
565 |
|
566 #endif // SVPTRANSFERSTATECONTEXT_H |
|