|
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 "CTcSIPContext.h" |
|
19 #include "SIPConstants.h" |
|
20 #include "TCmdGetProfiles.h" |
|
21 #include "Cleanupresetanddestroy.h" |
|
22 #include "CTcSIPProfileContainer.h" |
|
23 |
|
24 #include <sipmanagedprofile.h> |
|
25 #include <sipmanagedprofileregistry.h> |
|
26 #include <sipprofile.h> |
|
27 #include <sipprofiletypeinfo.h> |
|
28 #include "tclog.h" |
|
29 |
|
30 /** |
|
31 * INPUT: |
|
32 * Headers: - |
|
33 * Parameters: ProfileType*, ProfileAOR* |
|
34 * IDs: RegistryId |
|
35 * |
|
36 * OUTPUT: |
|
37 * Parameters: - |
|
38 * IDs: ProfileIdList |
|
39 */ |
|
40 void TCmdGetProfiles::ExecuteL() |
|
41 { |
|
42 // -- Setup --------------------------------------------------------------- |
|
43 |
|
44 // Get selected registry |
|
45 CTcSIPProfileContainer& container = SelectProfileL(); |
|
46 |
|
47 // Type |
|
48 TcLog::WriteFormat( _L8("-- Get optional structure \"ProfileType\"") ); |
|
49 CTcStructure* structure = FindStructureL( KParamProfileType, EFalse ); |
|
50 TSIPProfileTypeInfo typeInfo; |
|
51 if( structure ) |
|
52 { |
|
53 TcLog::Write( KLogOk ); |
|
54 TcLog::WriteFormat( _L8("-- Get mandatory structure item \"ProfileName\"") ); |
|
55 typeInfo.iSIPProfileName = structure->ItemL( KParamProfileName )->Value(); |
|
56 TcLog::Write( KLogOk ); |
|
57 TcLog::WriteFormat( _L8("-- Get mandatory structure item \"Class\"") ); |
|
58 typeInfo.iSIPProfileClass = ProfileTypeClassL( structure ); |
|
59 TcLog::Write( KLogOk ); |
|
60 } |
|
61 else |
|
62 { |
|
63 TcLog::Write( KLogNotFound ); |
|
64 } |
|
65 |
|
66 // Get profile AOR, or KNullDesC8 |
|
67 TPtrC8 aor = ExtractTextL( KParamProfileAOR, EFalse ); |
|
68 |
|
69 // -- Execution ----------------------------------------------------------- |
|
70 |
|
71 RPointerArray< CSIPProfile > profileArray; |
|
72 CleanupResetAndDestroyPushL( profileArray ); |
|
73 |
|
74 // See if Type was given |
|
75 if( structure ) |
|
76 { |
|
77 container.ManagedProfileRegistry().ProfilesL( typeInfo, profileArray ); |
|
78 } |
|
79 else if( aor != KNullDesC8 ) |
|
80 { |
|
81 container.ManagedProfileRegistry().ProfilesL( aor, profileArray ); |
|
82 } |
|
83 else |
|
84 { |
|
85 User::Leave( KTcErrMandatoryParameterNotFound ); |
|
86 } |
|
87 |
|
88 // -- Response creation --------------------------------------------------- |
|
89 |
|
90 // Crete response only if some profiles exist |
|
91 TInt count = profileArray.Count(); |
|
92 if ( count > 0 ) |
|
93 { |
|
94 CDesC8ArrayFlat* array = new ( ELeave ) CDesC8ArrayFlat( count ); |
|
95 CleanupStack::PushL( array ); |
|
96 |
|
97 for( TInt i = 0; i < count; i++ ) |
|
98 { |
|
99 // Register object |
|
100 CSIPProfile* profile = profileArray[ i ]; |
|
101 // Create a name out of the profile id |
|
102 TBuf8< KTcMaxIntConversion > idName; |
|
103 |
|
104 TUint32 profileId( 0 ); |
|
105 User::LeaveIfError( |
|
106 profile->GetParameter( KSIPProfileId, profileId ) ); |
|
107 idName.AppendNum( (TInt)profileId ); |
|
108 // ..and add it to the ProfileIdList array |
|
109 array->AppendL( idName ); |
|
110 } |
|
111 |
|
112 AddArrayResponseL( KParamProfileProfileIdist, *array ); |
|
113 |
|
114 CleanupStack::PopAndDestroy(); // array |
|
115 } |
|
116 CleanupStack::PopAndDestroy(); // profileArray |
|
117 } |
|
118 |
|
119 |
|
120 TBool TCmdGetProfiles::Match( const TTcIdentifier& aId ) |
|
121 { |
|
122 return TTcSIPCommandBase::Match( aId, _L8("GetProfiles") ); |
|
123 } |
|
124 |
|
125 TTcCommandBase* TCmdGetProfiles::CreateL( MTcTestContext& aContext ) |
|
126 { |
|
127 return new( ELeave ) TCmdGetProfiles( aContext ); |
|
128 } |