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