|
1 /* |
|
2 * Copyright (c) 2004 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <sipregistrationbinding.h> |
|
19 #include <siprefresh.h> |
|
20 #include <sipsubscribedialogassoc.h> |
|
21 |
|
22 #include "TCmdGetRefreshState.h" |
|
23 #include "SIPConstants.h" |
|
24 |
|
25 // State enumeration names |
|
26 _LIT8( KInactive, "inactive" ); |
|
27 _LIT8( KActive, "active" ); |
|
28 _LIT8( KTerminated, "terminated" ); |
|
29 |
|
30 /** |
|
31 * INPUT: |
|
32 * Headers: - |
|
33 * Parameters: - |
|
34 * IDs: RefreshId*, RegistrationId*, SubscribeDialogId* |
|
35 * |
|
36 * OUTPUT: |
|
37 * Parameters: - |
|
38 * IDs: RefreshState |
|
39 */ |
|
40 void TCmdGetRefreshState::ExecuteL() |
|
41 { |
|
42 // -- Setup --------------------------------------------------------------- |
|
43 |
|
44 // Get SIP objects from registry |
|
45 CSIPRefresh* refresh = GetRefreshL( EFalse ); |
|
46 CSIPRegistrationBinding* registration = GetRegistrationL( EFalse ); |
|
47 CSIPSubscribeDialogAssoc* dialogAssoc = GetSubscribeDialogAssocL( EFalse ); |
|
48 |
|
49 // Get the refresh object from a registration or from a dialog association |
|
50 // if it's not defined as such. |
|
51 if( !refresh ) |
|
52 { |
|
53 if( registration ) |
|
54 { |
|
55 refresh = const_cast< CSIPRefresh* >( registration->SIPRefresh() ); |
|
56 } |
|
57 else if( dialogAssoc ) |
|
58 { |
|
59 refresh = const_cast< CSIPRefresh* >( dialogAssoc->SIPRefresh() ); |
|
60 } |
|
61 else |
|
62 { |
|
63 User::Leave( KTcErrMandatoryIdNotFound ); |
|
64 } |
|
65 } |
|
66 |
|
67 // -- Execution ----------------------------------------------------------- |
|
68 |
|
69 // Report and terminate if no refresh was found |
|
70 if( !refresh ) |
|
71 { |
|
72 User::Leave( KErrNotFound ); |
|
73 } |
|
74 |
|
75 // Fetch refresh state |
|
76 CSIPRefresh::TState state = refresh->State(); |
|
77 |
|
78 // -- Response creation --------------------------------------------------- |
|
79 |
|
80 // Map enumeration to text |
|
81 TPtrC8 stateName; |
|
82 switch( state ) |
|
83 { |
|
84 case CSIPRefresh::EActive: |
|
85 { |
|
86 stateName.Set( KActive ); |
|
87 break; |
|
88 } |
|
89 case CSIPRefresh::ETerminated: |
|
90 { |
|
91 stateName.Set( KTerminated ); |
|
92 break; |
|
93 } |
|
94 case CSIPRefresh::EInactive: |
|
95 default: |
|
96 { |
|
97 stateName.Set( KInactive ); |
|
98 break; |
|
99 } |
|
100 } |
|
101 |
|
102 AddTextResponseL( KParamRefreshState, stateName ); |
|
103 } |
|
104 |
|
105 TBool TCmdGetRefreshState::Match( const TTcIdentifier& aId ) |
|
106 { |
|
107 return TTcSIPCommandBase::Match( aId, _L8("GetRefreshState") ); |
|
108 } |
|
109 |
|
110 TTcCommandBase* TCmdGetRefreshState::CreateL( MTcTestContext& aContext ) |
|
111 { |
|
112 return new( ELeave ) TCmdGetRefreshState( aContext ); |
|
113 } |
|
114 |