|
1 /* |
|
2 * Copyright (c) 2002 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 wireless village settings in provisioning. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CWPPecAdapter.h" // own header |
|
22 #include <e32base.h> |
|
23 #include <CWPCharacteristic.h> |
|
24 #include <CWPParameter.h> |
|
25 #include <wpwvadapterresource.rsg> |
|
26 |
|
27 #include <ApDataHandler.h> |
|
28 #include <ApAccessPointItem.h> |
|
29 #include <ApUtils.h> |
|
30 #include <commdb.h> |
|
31 #include "WPAdapterUtil.h" |
|
32 #include "CWPIMSAPItem.h" |
|
33 #include "ProvisioningDebug.h" |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CWPPecAdapter::CWPPecAdapter |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CWPPecAdapter::CWPPecAdapter() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CWPPecAdapter::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CWPPecAdapter::ConstructL() |
|
53 { |
|
54 FLOG( _L( "[Provisioning] CWPPecAdapter::ConstructL:" ) ); |
|
55 |
|
56 TFileName fileName; |
|
57 Dll::FileName( fileName ); |
|
58 iWVTitle = WPAdapterUtil::ReadHBufCL( fileName, |
|
59 KWVAdapterName, |
|
60 R_QTN_OP_HEAD_IMSETTINGS ); |
|
61 |
|
62 iSAPIdForDefault = KNotSet; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CWPPecAdapter::NewL |
|
67 // Two-phased constructor. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CWPPecAdapter* CWPPecAdapter::NewL() |
|
71 { |
|
72 CWPPecAdapter* self = new(ELeave) CWPPecAdapter; |
|
73 CleanupStack::PushL(self); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop(self); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Destructor |
|
81 // ----------------------------------------------------------------------------- |
|
82 CWPPecAdapter::~CWPPecAdapter() |
|
83 { |
|
84 delete iCurrentData; |
|
85 delete iWVTitle; |
|
86 for ( TInt i = 0; i < iDatas.Count(); i++ ) |
|
87 { |
|
88 delete iDatas[i]; |
|
89 } |
|
90 iDatas.Close(); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CWPPecAdapter::DetailsL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CWPPecAdapter::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor */ ) |
|
98 { |
|
99 return KErrNotSupported; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CWPPecAdapter::SummaryCount |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 TInt CWPPecAdapter::ItemCount() const |
|
107 { |
|
108 TInt count(0); |
|
109 for(TInt i=0;i<iDatas.Count();i++) |
|
110 { |
|
111 if(iDatas[i]->iProvLocation == EIMPSPECAccessGroup) |
|
112 { |
|
113 count++; |
|
114 } |
|
115 } |
|
116 return count; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CWPPecAdapter::SummaryTitle |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 const TDesC16& CWPPecAdapter::SummaryTitle(TInt /*aIndex*/) const |
|
124 { |
|
125 return *iWVTitle; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CWPPecAdapter::SummaryText |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 const TDesC16& CWPPecAdapter::SummaryText(TInt aIndex) const |
|
133 { |
|
134 return iDatas[aIndex]->iName; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CWPPecAdapter::SaveL |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CWPPecAdapter::SaveL( TInt aIndex ) |
|
142 { |
|
143 FLOG( _L( "[Provisioning] CWPPecAdapter::SaveL" ) ); |
|
144 |
|
145 |
|
146 for(TInt i=0;i<iDatas.Count();i++) |
|
147 { |
|
148 if(iDatas[i]->iProvLocation != EIMPSPECAccessGroup) |
|
149 { |
|
150 delete iDatas[i]; |
|
151 iDatas.Remove(i); |
|
152 i--; |
|
153 } |
|
154 } |
|
155 |
|
156 if ( ( iDatas.Count() == 0 ) || ( aIndex > iDatas.Count() - 1 ) ) |
|
157 { |
|
158 FLOG( _L( "[Provisioning] CWPPecAdapter::SaveL No data" ) ); |
|
159 return; |
|
160 } |
|
161 |
|
162 if ( iDatas[aIndex]->iProvLocation == EIMPSPECAccessGroup ) |
|
163 { |
|
164 //data item at given index |
|
165 TData* data = iDatas[aIndex]; |
|
166 // create save item |
|
167 CWPIMSAPItem* sapItem = CWPIMSAPItem::NewLC( EIMPSPECAccessGroup ); |
|
168 |
|
169 // set data to save item |
|
170 sapItem->SetUserIDL( data->iUserID ); |
|
171 sapItem->SetPasswordL( data->iPassword ); |
|
172 sapItem->SetSAPURIL( data->iURL ); |
|
173 sapItem->SetSettingsNameL( data->iName ); |
|
174 |
|
175 // Find a proper GPRS access point |
|
176 CApAccessPointItem* item = WPIMUtil::FindGPRSL( data->iLinks ); |
|
177 CleanupStack::PushL( item ); |
|
178 |
|
179 // get the WAP id |
|
180 CCommsDatabase* commDb = CCommsDatabase::NewL(); |
|
181 CleanupStack::PushL(commDb); |
|
182 TUint32 uid( item->WapUid() ); |
|
183 |
|
184 // Convert WAP uid to IAP uid |
|
185 CApUtils* apUtils = CApUtils::NewLC( *commDb ); |
|
186 TUint32 iapId = apUtils->IapIdFromWapIdL( uid ); |
|
187 |
|
188 // set the IAP id as part of save item. |
|
189 sapItem->SetIAPIdL( iapId ); |
|
190 |
|
191 CleanupStack::PopAndDestroy( 3 ); // apUtils, commDb, item |
|
192 // store SAP item |
|
193 TUint32 SAPuid = sapItem->StoreL(); |
|
194 data->iSAPId = SAPuid; |
|
195 |
|
196 // if there is no id for default Service Access Point, set it. |
|
197 if (iSAPIdForDefault == KNotSet) |
|
198 { |
|
199 iSAPIdForDefault = SAPuid; |
|
200 } |
|
201 |
|
202 CleanupStack::PopAndDestroy( sapItem ); |
|
203 FLOG( _L( "[Provisioning] CWPPecAdapter::SaveL Done" ) ); |
|
204 } |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CWPPecAdapter::CanSetAsDefault |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TBool CWPPecAdapter::CanSetAsDefault( TInt aIndex ) const |
|
212 { |
|
213 // the first one is set as default if exists. |
|
214 return ( iSAPIdForDefault && ( aIndex == 0 ) ); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CWPPecAdapter::SetAsDefaultL |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CWPPecAdapter::SetAsDefaultL( TInt aIndex ) |
|
222 { |
|
223 if ( aIndex == 0 && iSAPIdForDefault != KNotSet ) |
|
224 { |
|
225 // set the first item saved as a default |
|
226 CWPIMSAPItem::SetAsDefaultL( iSAPIdForDefault, EIMPSPECAccessGroup ); |
|
227 } |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CWPPecAdapter::VisitL |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CWPPecAdapter::VisitL( CWPCharacteristic& aCharacteristic ) |
|
235 { |
|
236 switch( aCharacteristic.Type() ) |
|
237 { |
|
238 case KWPApplication: |
|
239 { |
|
240 iCurrentData = new(ELeave) TData; |
|
241 |
|
242 aCharacteristic.AcceptL( *this ); |
|
243 |
|
244 if( (iAppID == KIMAppID1 || |
|
245 iAppID == KIMAppID2 ) && |
|
246 WPIMUtil::IsValid( iCurrentData ) ) |
|
247 { |
|
248 FLOG( _L( "[Provisioning] CWPPecAdapter::VisitL App id match" ) ); |
|
249 User::LeaveIfError( iDatas.Append( iCurrentData ) ); |
|
250 } |
|
251 else |
|
252 { |
|
253 delete iCurrentData; |
|
254 } |
|
255 iCurrentData = NULL; |
|
256 } |
|
257 break; |
|
258 |
|
259 case KWPAppAddr: // fallthrough |
|
260 case KWPAppAuth: |
|
261 { |
|
262 if( iCurrentData ) |
|
263 { |
|
264 aCharacteristic.AcceptL( *this ); |
|
265 } |
|
266 } |
|
267 break; |
|
268 |
|
269 default: |
|
270 break; |
|
271 } |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CWPPecAdapter::VisitL |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CWPPecAdapter::VisitL( CWPParameter& aParameter ) |
|
279 { |
|
280 |
|
281 switch( aParameter.ID() ) |
|
282 { |
|
283 case EWPParameterAppID: |
|
284 iAppID.Set( aParameter.Value() ); |
|
285 break; |
|
286 |
|
287 case EWPParameterName: |
|
288 if (iCurrentData->iName == KNullDesC) |
|
289 { |
|
290 iCurrentData->iName.Set( aParameter.Value() ); |
|
291 } |
|
292 break; |
|
293 |
|
294 case EWPParameterAddr: |
|
295 if (iCurrentData->iURL == KNullDesC) |
|
296 { |
|
297 iCurrentData->iURL.Set( aParameter.Value() ); |
|
298 } |
|
299 break; |
|
300 |
|
301 case EWPParameterAAuthName: |
|
302 if (iCurrentData->iUserID == KNullDesC) |
|
303 { |
|
304 iCurrentData->iUserID.Set( aParameter.Value() ); |
|
305 } |
|
306 break; |
|
307 |
|
308 case EWPParameterAAuthSecret: |
|
309 if (iCurrentData->iPassword == KNullDesC) |
|
310 { |
|
311 iCurrentData->iPassword.Set( aParameter.Value() ); |
|
312 } |
|
313 break; |
|
314 // Here case 0 are handled the IM and Presence parameters that are extensions |
|
315 // to OMA Client Provisioning parameter set. |
|
316 case 0: |
|
317 { |
|
318 FLOG( _L( "[Provisioning] CWPPecAdapter::VisitL Case 0" ) ); |
|
319 TInt val = aParameter.Name().Match( KServicesName ); |
|
320 if ( val >= 0 ) |
|
321 { |
|
322 FLOG( _L( "[Provisioning] CWPPecAdapter::VisitL Services" ) ); |
|
323 val = aParameter.Value().Match( KPresenceName ); |
|
324 if ( val >= 0 ) |
|
325 { |
|
326 FLOG( _L( "[Provisioning] CWPPecAdapter::VisitL Pec" ) ); |
|
327 iCurrentData->iProvLocation = EIMPSPECAccessGroup; |
|
328 } |
|
329 else |
|
330 { |
|
331 FLOG( _L( "[Provisioning] CWPPecAdapter::VisitL NO Pec" ) ); |
|
332 // settings not for this adapter |
|
333 iCurrentData->iProvLocation = EIMPSNoAccessGroup; |
|
334 } |
|
335 } |
|
336 break; |
|
337 } |
|
338 default: |
|
339 break; |
|
340 } |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CWPPecAdapter::VisitLinkL |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CWPPecAdapter::VisitLinkL( CWPCharacteristic& aLink ) |
|
348 { |
|
349 switch( aLink.Type() ) |
|
350 { |
|
351 case KWPNapDef: // fallthrough |
|
352 case KWPPxLogical: |
|
353 { |
|
354 User::LeaveIfError( iCurrentData->iLinks.Append( &aLink ) ); |
|
355 break; |
|
356 } |
|
357 default: |
|
358 break; |
|
359 } |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CWPPecAdapter::ContextExtension |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 TInt CWPPecAdapter::ContextExtension( MWPContextExtension*& aExtension ) |
|
367 { |
|
368 aExtension = this; |
|
369 return KErrNone; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CWPPecAdapter::SaveDataL |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 const TDesC8& CWPPecAdapter::SaveDataL( TInt aIndex ) const |
|
377 { |
|
378 return iDatas[aIndex]->iSAPId; |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CWPPecAdapter::DeleteL |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void CWPPecAdapter::DeleteL( const TDesC8& aSaveData ) |
|
386 { |
|
387 TPckgBuf<TUint32> pckg; |
|
388 pckg.Copy( aSaveData ); |
|
389 |
|
390 CWPIMSAPItem* sapItem = CWPIMSAPItem::NewLC( EIMPSPECAccessGroup ); |
|
391 sapItem->DeleteL( pckg() ); |
|
392 CleanupStack::PopAndDestroy( sapItem ); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CWPPecAdapter::Uid |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 TUint32 CWPPecAdapter::Uid() const |
|
400 { |
|
401 return iDtor_ID_Key.iUid; |
|
402 } |
|
403 |
|
404 // End of File |