|
1 /* |
|
2 * Copyright (c) 2005-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: ECOM interface default implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MUSSIPPROFILEUTILS_INL |
|
20 #define MUSSIPPROFILEUTILS_INL |
|
21 |
|
22 #include "musavasettings.h" |
|
23 #include "muslogger.h" |
|
24 |
|
25 #include <badesca.h> |
|
26 #include <sipmanagedprofileregistry.h> |
|
27 #include <sipmanagedprofile.h> |
|
28 #include <utf.h> |
|
29 |
|
30 _LIT8( KVsTag, "+g.3gpp.cs-voice" ); |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 inline TInt MusSipProfileUtils::VsTagIndex( const MDesC8Array& aArray ) |
|
37 { |
|
38 MUS_LOG( "mus: [MUSSET] -> MusSipProfileUtils::VsTagIndex( )" ) |
|
39 |
|
40 for( TInt i(0); i<aArray.MdcaCount(); i++ ) |
|
41 { |
|
42 if( aArray.MdcaPoint( i ).Find( KVsTag ) == 0 ) |
|
43 { |
|
44 MUS_LOG1( "mus: [MUSSET] <- MusSipProfileUtils::VsTagIndex( %d )", |
|
45 i ) |
|
46 |
|
47 return i; |
|
48 } |
|
49 } |
|
50 MUS_LOG( "mus: [MUSSET] <- MusSipProfileUtils::VsTagIndex( KErrNotFound )" ) |
|
51 return KErrNotFound; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 inline CDesC8ArrayFlat* MusSipProfileUtils::AddVsTagLC( const MDesC8Array& aArray ) |
|
59 { |
|
60 CDesC8ArrayFlat* array |
|
61 = new( ELeave ) CDesC8ArrayFlat( aArray.MdcaCount() + 1 ); |
|
62 CleanupStack::PushL( array ); |
|
63 |
|
64 for( TInt i(0); i<aArray.MdcaCount(); i++ ) |
|
65 { |
|
66 array->AppendL( aArray.MdcaPoint( i ) ); |
|
67 } |
|
68 array->AppendL( KVsTag() ); |
|
69 |
|
70 return array; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 inline CDesC8ArrayFlat* MusSipProfileUtils::RemoveVsTagLC( |
|
78 const MDesC8Array& aArray, |
|
79 TInt aIndex ) |
|
80 { |
|
81 CDesC8ArrayFlat* array |
|
82 = new( ELeave ) CDesC8ArrayFlat( aArray.MdcaCount() + 1 ); |
|
83 CleanupStack::PushL( array ); |
|
84 |
|
85 for( TInt i(0); i<aArray.MdcaCount(); i++ ) |
|
86 { |
|
87 if( aIndex != i ) |
|
88 { |
|
89 array->AppendL( aArray.MdcaPoint( i ) ); |
|
90 } |
|
91 } |
|
92 return array; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 |
|
100 inline void MusSipProfileUtils::RemoveFeatureTagL( CSIPManagedProfile& aProfile ) |
|
101 { |
|
102 //MDesC8Array* params; |
|
103 const MDesC8Array* params; |
|
104 |
|
105 aProfile.GetParameter( KSIPContactHeaderParams, params ); |
|
106 |
|
107 MUS_LOG( "mus: [MUSSET] Handling contact header params" ) |
|
108 |
|
109 TInt index( KErrNotFound ); |
|
110 if( params ) |
|
111 { |
|
112 index = MusSipProfileUtils::VsTagIndex( *params ); |
|
113 |
|
114 if( index != KErrNotFound ) |
|
115 { |
|
116 MUS_LOG( "mus: [MUSSET] No VS-specific contact header param set yet, setting it..." ) |
|
117 const CDesC8ArrayFlat* newParams |
|
118 = RemoveVsTagLC( *params, index ); |
|
119 aProfile.SetParameter( KSIPContactHeaderParams, |
|
120 *newParams ); |
|
121 CleanupStack::PopAndDestroy(); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 inline void MusSipProfileUtils::AddFeatureTagL( CSIPManagedProfile& aProfile ) |
|
131 { |
|
132 const MDesC8Array* params; |
|
133 |
|
134 aProfile.GetParameter( KSIPContactHeaderParams, params ); |
|
135 |
|
136 MUS_LOG( "mus: [MUSSET] Handling contact header params" ) |
|
137 |
|
138 TInt index( KErrNotFound ); |
|
139 if( params ) |
|
140 { |
|
141 index = MusSipProfileUtils::VsTagIndex( *params ); |
|
142 |
|
143 if( index == KErrNotFound ) |
|
144 { |
|
145 MUS_LOG( "mus: [MUSSET] No VS-specific contact header param set yet, setting it..." ) |
|
146 const CDesC8ArrayFlat* newParams |
|
147 = AddVsTagLC( *params ); |
|
148 aProfile.SetParameter( KSIPContactHeaderParams, |
|
149 *newParams ); |
|
150 CleanupStack::PopAndDestroy(); |
|
151 } |
|
152 } |
|
153 |
|
154 if( !params ) |
|
155 { |
|
156 MUS_LOG( "mus: [MUSSET] No VS-specific contact header param set yet, setting it..." ) |
|
157 CDesC8ArrayFlat* newParams |
|
158 = new( ELeave ) CDesC8ArrayFlat( 1 ); |
|
159 CleanupStack::PushL( newParams ); |
|
160 newParams->AppendL( KVsTag() ); |
|
161 aProfile.SetParameter( KSIPContactHeaderParams, |
|
162 *newParams ); |
|
163 CleanupStack::PopAndDestroy(); |
|
164 } |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 inline void MusSipProfileUtils::InsertContactHeaderL( TInt aSipProfileId ) |
|
172 { |
|
173 MUS_LOG1( "mus: [MUSSET] -> MusSipProfileUtils::InsertContactHeaderL( %d )", |
|
174 aSipProfileId ) |
|
175 MusSipProfileUtils* utils = new( ELeave ) MusSipProfileUtils(); |
|
176 |
|
177 CleanupStack::PushL( utils ); |
|
178 |
|
179 MUS_LOG( "mus: [MUSSET] Opening SIP profile registry" ) |
|
180 |
|
181 CSIPManagedProfileRegistry* registry |
|
182 = CSIPManagedProfileRegistry::NewLC( *utils ); |
|
183 |
|
184 MUS_LOG1( "mus: [MUSSET] Looking for profile for id %d", |
|
185 aSipProfileId ) |
|
186 |
|
187 CSIPManagedProfile* profile = NULL; |
|
188 |
|
189 TRAPD( err, profile = static_cast< CSIPManagedProfile* >( |
|
190 registry->ProfileL( aSipProfileId ) ) ); |
|
191 if ( err == KErrNone ) |
|
192 { |
|
193 CleanupStack::PushL( profile ); |
|
194 MUS_LOG( "mus: [MUSSET] Corresponding profile found" ) |
|
195 AddFeatureTagL( *profile ); |
|
196 registry->SaveL( *profile ); |
|
197 CleanupStack::PopAndDestroy( profile ); |
|
198 } |
|
199 CleanupStack::PopAndDestroy( registry ); |
|
200 CleanupStack::PopAndDestroy( utils ); |
|
201 |
|
202 MUS_LOG( "mus: [MUSSET] <- MusSipProfileUtils::InsertContactHeaderL()" ) |
|
203 } |
|
204 |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 inline void MusSipProfileUtils::RemoveContactHeaderL( TInt aSipProfileId ) |
|
211 { |
|
212 MUS_LOG1( "mus: [MUSSET] -> MusSipProfileUtils::RemoveContactHeaderL( %d )", |
|
213 aSipProfileId ) |
|
214 MusSipProfileUtils* utils = new( ELeave ) MusSipProfileUtils(); |
|
215 |
|
216 CleanupStack::PushL( utils ); |
|
217 |
|
218 CSIPManagedProfileRegistry* registry = |
|
219 CSIPManagedProfileRegistry::NewLC( *utils ); |
|
220 |
|
221 CSIPManagedProfile* profile = NULL; |
|
222 |
|
223 TRAPD( err, profile = static_cast< CSIPManagedProfile* > |
|
224 ( registry->ProfileL( aSipProfileId ) ) ); |
|
225 if ( err == KErrNone ) |
|
226 { |
|
227 CleanupStack::PushL( profile ); |
|
228 MUS_LOG( "mus: [MUSSET] Corresponding profile found" ) |
|
229 RemoveFeatureTagL( *profile ); |
|
230 registry->SaveL( *profile ); |
|
231 CleanupStack::PopAndDestroy( profile ); |
|
232 } |
|
233 |
|
234 CleanupStack::PopAndDestroy( registry ); |
|
235 CleanupStack::PopAndDestroy( utils ); |
|
236 MUS_LOG( "mus: [MUSSET] <- MusSipProfileUtils::RemoveContactHeaderL()" ) |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 inline MusSipProfileUtils::MusSipProfileUtils() |
|
244 { |
|
245 |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 inline MusSipProfileUtils::~MusSipProfileUtils() |
|
253 { |
|
254 |
|
255 } |
|
256 |
|
257 #endif // MUSSIPPROFILEUTILS_INL |