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