|
1 /* |
|
2 * Copyright (c) 2006-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: Handles Always-On settings in OMA provisioning. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <f32file.h> |
|
21 #include <CWPCharacteristic.h> |
|
22 #include <CWPParameter.h> |
|
23 #include <pdpcontextmanagerinternalcrkeys.h> |
|
24 #include <centralrepository.h> |
|
25 |
|
26 #include "WPAdapterUtil.h" |
|
27 #include "alwaysonadapter.h" |
|
28 #include "ProvisioningDebug.h" |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KAlwaysOnAwonPdpcStr, "AWON-PDPC" ); |
|
32 _LIT( KAlwaysOnTRetryStr, "T-RETRY" ); |
|
33 |
|
34 // AlwaysON PDP context status |
|
35 // Parameters shall be binary encoded using the in-line string. |
|
36 // Max length for each item is 2bytes. |
|
37 // Values are XY, where X is related to 3G flag and Y is related to 2G flag. |
|
38 // Possible values are: |
|
39 // * "00", AlwaysOn is OFF for both 3G and 2G |
|
40 // * "10", AlwaysOn is ON for 3G, OFF for 2G |
|
41 // * "01", AlwaysOn is OFF for 3G, ON for 2G |
|
42 // * "11", AlwaysOn is ON for 3G, ON for 2G |
|
43 const TInt KAwonPdpc_Off3G_Off2G = 00; |
|
44 const TInt KAwonPdpc_Off3G_On2G = 01; |
|
45 const TInt KAwonPdpc_On3G_Off2G = 10; |
|
46 const TInt KAwonPdpc_On3G_On2G = 11; |
|
47 |
|
48 // ======== LOCAL FUNCTIONS ======== |
|
49 |
|
50 // ======== MEMBER FUNCTIONS ======== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CAlwaysOnAdapter::CAlwaysOnAdapter |
|
54 // C++ default constructor can NOT contain any code, that |
|
55 // might leave. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CAlwaysOnAdapter::CAlwaysOnAdapter() |
|
59 { |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CAlwaysOnAdapter::ConstructL |
|
64 // Symbian 2nd phase constructor can leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CAlwaysOnAdapter::ConstructL() |
|
68 { |
|
69 iPdpCenrep = CRepository::NewL( KCRUidPDPContextManager ); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CAlwaysOnAdapter::NewL |
|
74 // Two-phased constructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CAlwaysOnAdapter* CAlwaysOnAdapter::NewL() |
|
78 { |
|
79 CAlwaysOnAdapter* self = new( ELeave ) CAlwaysOnAdapter; |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CAlwaysOnAdapter::~CAlwaysOnAdapter |
|
89 // Destructor |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CAlwaysOnAdapter::~CAlwaysOnAdapter() |
|
93 { |
|
94 delete iVConfigData; |
|
95 delete iTempVConfigData; |
|
96 delete iPdpCenrep; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CAlwaysOnAdapter::ItemCount |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CAlwaysOnAdapter::ItemCount() const |
|
104 { |
|
105 // SummaryTitle(), SummaryText(), SaveL(), SetAsDefaultL() and |
|
106 // CanSetAsDefault() are called ItemCount() times |
|
107 return iVConfigData ? 1 : 0; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CAlwaysOnAdapter::SummaryTitle |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 const TDesC16& CAlwaysOnAdapter::SummaryTitle( TInt /*aIndex*/ ) const |
|
115 { |
|
116 return KNullDesC(); |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CAlwaysOnAdapter::SummaryText |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 const TDesC16& CAlwaysOnAdapter::SummaryText( TInt /*aIndex*/ ) const |
|
124 { |
|
125 return KNullDesC(); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CAlwaysOnAdapter::DetailsL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CAlwaysOnAdapter::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/ ) |
|
133 { |
|
134 // Detail view is a feature for later release. |
|
135 return KErrNotSupported; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CAlwaysOnAdapter::SaveL |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CAlwaysOnAdapter::SaveL( TInt /*aItem*/ ) |
|
143 { |
|
144 FLOG( _L( "[Provisioning] CAlwaysOnAdapter::SaveL:" ) ); |
|
145 __ASSERT_DEBUG( iVConfigData, User::Leave( KErrCorrupt ) ); |
|
146 |
|
147 User::LeaveIfError( iPdpCenrep->Set( KPDPContextManagerEnableWhenHome, |
|
148 TInt( iVConfigData->iAwonPdpcHPLMN ) ) ); |
|
149 User::LeaveIfError( iPdpCenrep->Set( KPDPContextManagerEnableWhenRoaming, |
|
150 TInt( iVConfigData->iAwonPdpcVPLMN ) ) ); |
|
151 User::LeaveIfError( iPdpCenrep->Set( KPDPContextManagerRetryTimer, |
|
152 iVConfigData->iTRetry ) ); |
|
153 |
|
154 FLOG( _L( "[Provisioning] CStreamingAdapter::SaveL: Done" ) ); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CAlwaysOnAdapter::CanSetAsDefault |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 TBool CAlwaysOnAdapter::CanSetAsDefault( TInt /*aItem*/ ) const |
|
162 { |
|
163 return EFalse; |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CAlwaysOnAdapter::SetAsDefault |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CAlwaysOnAdapter::SetAsDefaultL( TInt /*aItem*/ ) |
|
171 { |
|
172 // This shouldn't be called because CanSetAsDefault |
|
173 // always returns EFalse. |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CAlwaysOnAdapter::VisitL |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CAlwaysOnAdapter::VisitL( CWPCharacteristic& aCharacteristic ) |
|
181 { |
|
182 switch( aCharacteristic.Type() ) |
|
183 { |
|
184 case KWPVendorConfig: |
|
185 { |
|
186 // Init settings temporary storage |
|
187 InitTempVConfigL(); |
|
188 |
|
189 // Accept characteristic |
|
190 aCharacteristic.AcceptL( *this ); |
|
191 |
|
192 // Validate data |
|
193 if( IsVConfigValid() ) |
|
194 { |
|
195 // data is valid -> assign it to member variable |
|
196 delete iVConfigData; |
|
197 iVConfigData = iTempVConfigData; |
|
198 iTempVConfigData = NULL; |
|
199 } |
|
200 else |
|
201 { |
|
202 // data is invalid |
|
203 delete iTempVConfigData; |
|
204 iTempVConfigData = NULL; |
|
205 } |
|
206 break; |
|
207 } |
|
208 default: |
|
209 break; |
|
210 } |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CAlwaysOnAdapter::VisitL |
|
215 // |
|
216 // Used to parse, the following always-on related provisioning settings |
|
217 // |
|
218 // <characteristic type="VENDORCONFIG"> |
|
219 // <parm name="NAME" value="MRBLOBBY"/> |
|
220 // <parm name="AWON-PDPC" value="11"/> |
|
221 // <parm name="T-RETRY" value="100"/> |
|
222 // </characteristic> |
|
223 // </characteristic> |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CAlwaysOnAdapter::VisitL( CWPParameter& aParameter ) |
|
227 { |
|
228 switch( aParameter.ID() ) |
|
229 { |
|
230 case EWPParameterName: |
|
231 iTempVConfigData->iName.Set( aParameter.Value() ); |
|
232 break; |
|
233 case EWPNamedParameter: |
|
234 { |
|
235 if( aParameter.Name().Compare( KAlwaysOnAwonPdpcStr ) == 0 ) |
|
236 { |
|
237 TInt awonPdpcTemp( KErrNotFound ); |
|
238 ParseIntegerL( aParameter.Value(), awonPdpcTemp ); |
|
239 ParseAwonPdpcValuesL( awonPdpcTemp ); |
|
240 } |
|
241 else if( aParameter.Name().Compare( KAlwaysOnTRetryStr ) == 0 ) |
|
242 { |
|
243 ParseIntegerL( aParameter.Value(), iTempVConfigData->iTRetry ); |
|
244 } |
|
245 break; |
|
246 } |
|
247 default: |
|
248 break; |
|
249 } |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CAlwaysOnAdapter::VisitLinkL |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CAlwaysOnAdapter::VisitLinkL( CWPCharacteristic& /*aCharacteristic*/ ) |
|
257 { |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CAlwaysOnAdapter::IsVConfigValid |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TBool CAlwaysOnAdapter::IsVConfigValid() |
|
265 { |
|
266 TBool validity( ETrue ); |
|
267 |
|
268 // Validity check: |
|
269 // |
|
270 // T-Retry must be >= 0 |
|
271 // ** 0 means infinity |
|
272 // ** > 0 is retry timer value in seconds |
|
273 if( iTempVConfigData->iTRetry < 0 ) |
|
274 { |
|
275 validity = EFalse; |
|
276 } |
|
277 |
|
278 // AWON-PDPC |
|
279 // ** Allowed awon-pdpc values are speficied in the beginning of file |
|
280 // There is no need to validate AWON-PDPC because if parsing has succeeded |
|
281 // the values are inside correct range. |
|
282 |
|
283 return validity; |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CAlwaysOnAdapter::InitTempVConfigL |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 void CAlwaysOnAdapter::InitTempVConfigL() |
|
291 { |
|
292 delete iTempVConfigData; |
|
293 iTempVConfigData = NULL; |
|
294 iTempVConfigData = new ( ELeave ) TAlwaysOnVConfigAdapterData; |
|
295 |
|
296 // Initialize iTempVConfigData's members |
|
297 iTempVConfigData->iName.Set( KNullDesC ); |
|
298 TInt temp( 0 ); |
|
299 User::LeaveIfError( |
|
300 iPdpCenrep->Get( KPDPContextManagerEnableWhenHome, temp ) ); |
|
301 iTempVConfigData->iAwonPdpcHPLMN = TBool( temp ); |
|
302 User::LeaveIfError( |
|
303 iPdpCenrep->Get( KPDPContextManagerEnableWhenRoaming, temp ) ); |
|
304 iTempVConfigData->iAwonPdpcVPLMN = TBool( temp ); |
|
305 User::LeaveIfError( iPdpCenrep->Get( KPDPContextManagerRetryTimer, |
|
306 iTempVConfigData->iTRetry ) ); |
|
307 |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // CAlwaysOnAdapter::ParseIntegerL |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CAlwaysOnAdapter::ParseIntegerL( const TDesC& aPtr, TInt& aInt ) |
|
315 { |
|
316 TLex lex( aPtr ); |
|
317 User::LeaveIfError( lex.Val( aInt ) ); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CAlwaysOnAdapter::ParseAwonPdpcValuesL |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CAlwaysOnAdapter::ParseAwonPdpcValuesL( TInt aInt ) |
|
325 { |
|
326 switch( aInt ) |
|
327 { |
|
328 case KAwonPdpc_Off3G_Off2G: |
|
329 iTempVConfigData->iAwonPdpcHPLMN = EFalse; |
|
330 iTempVConfigData->iAwonPdpcVPLMN = EFalse; |
|
331 break; |
|
332 case KAwonPdpc_Off3G_On2G: |
|
333 iTempVConfigData->iAwonPdpcHPLMN = EFalse; |
|
334 iTempVConfigData->iAwonPdpcVPLMN = ETrue; |
|
335 break; |
|
336 case KAwonPdpc_On3G_Off2G: |
|
337 iTempVConfigData->iAwonPdpcHPLMN = ETrue; |
|
338 iTempVConfigData->iAwonPdpcVPLMN = EFalse; |
|
339 break; |
|
340 case KAwonPdpc_On3G_On2G: |
|
341 iTempVConfigData->iAwonPdpcHPLMN = ETrue; |
|
342 iTempVConfigData->iAwonPdpcVPLMN = ETrue; |
|
343 break; |
|
344 default: |
|
345 User::Leave( KErrNotSupported ); |
|
346 break; |
|
347 } |
|
348 } |
|
349 |
|
350 // End of File |