|
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: Engine class for Provisioning. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CWPEngine.h" |
|
21 #include <badesca.h> |
|
22 #include "CWPWbxmlParser.h" |
|
23 #include "CWPEngine.pan" |
|
24 #include "CWPRoot.h" |
|
25 #include "CWPValidator.h" |
|
26 #include "CWPAdapterManager.h" |
|
27 #include "MWPContextManager.h" |
|
28 #include "WPContextManagerFactory.h" |
|
29 #include "WPEngineDebug.h" |
|
30 #include "CWPPushMessage.h" |
|
31 #include "ProvisioningDebug.h" |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KStreamVersion = 1; |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CWPEngine::CWPEngine |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CWPEngine::CWPEngine():iAccessDenied(EFalse) |
|
45 { |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CWPEngine::ConstructL |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CWPEngine::ConstructL() |
|
54 { |
|
55 FLOG( _L( "[ProvisioningEngine] CWPEngine::ConstructL" ) ); |
|
56 |
|
57 iRoot = CWPRoot::NewL(); |
|
58 // Create a context manager |
|
59 iManager = WPContextManagerFactory::CreateL(); |
|
60 FLOG( _L( "[ProvisioningEngine] CWPEngine::ConstructL done" ) ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CWPEngine::NewL |
|
65 // Two-phased constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CWPEngine* CWPEngine::NewL() |
|
69 { |
|
70 CWPEngine* self = NewLC(); |
|
71 CleanupStack::Pop(); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CWPEngine::NewLC |
|
78 // Two-phased constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C CWPEngine* CWPEngine::NewLC() |
|
82 { |
|
83 CWPEngine* self = new( ELeave ) CWPEngine; |
|
84 |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL(); |
|
87 |
|
88 return self; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // Destructor |
|
93 // ----------------------------------------------------------------------------- |
|
94 CWPEngine::~CWPEngine() |
|
95 { |
|
96 FLOG( _L( "[ProvisioningEngine] CWPEngine::~CWPEngine" ) ); |
|
97 delete iManager; |
|
98 delete iAdapters; |
|
99 delete iRoot; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CWPEngine::RestoreL |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C void CWPEngine::RestoreL( CStreamStore& aStore, TStreamId aId ) |
|
107 { |
|
108 FLOG( _L( "[ProvisioningEngine] CWPEngine::RestoreL" ) ); |
|
109 |
|
110 RStoreReadStream instream; |
|
111 instream.OpenLC(aStore,aId); |
|
112 InternalizeL(instream); |
|
113 CleanupStack::PopAndDestroy(); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CWPEngine::StoreL |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C TStreamId CWPEngine::StoreL( CStreamStore& aStore ) const |
|
121 { |
|
122 FLOG( _L( "[ProvisioningEngine] CWPEngine::StoreL" ) ); |
|
123 |
|
124 RStoreWriteStream stream; |
|
125 TStreamId id=stream.CreateLC(aStore); |
|
126 ExternalizeL(stream); |
|
127 stream.CommitL(); |
|
128 CleanupStack::PopAndDestroy(); |
|
129 return id; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CWPEngine::InternalizeL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 EXPORT_C void CWPEngine::InternalizeL( RReadStream& aStream ) |
|
137 { |
|
138 if( aStream.ReadInt32L() != KStreamVersion ) |
|
139 { |
|
140 User::Leave( KErrNotSupported ); |
|
141 } |
|
142 |
|
143 iRoot->InternalizeL( aStream ); |
|
144 CreateLinksL(); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CWPEngine::ExternalizeL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void CWPEngine::ExternalizeL( RWriteStream& aStream ) const |
|
152 { |
|
153 aStream.WriteInt32L( KStreamVersion ); |
|
154 iRoot->ExternalizeL( aStream ); |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CWPEngine::AcceptL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C void CWPEngine::AcceptL( MWPVisitor& aVisitor ) |
|
163 { |
|
164 iRoot->AcceptL( aVisitor ); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CWPEngine::ImportDocumentL |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C void CWPEngine::ImportDocumentL( const TDesC8& aDocument ) |
|
172 { |
|
173 FLOG( _L( "[ProvisioningEngine] CWPEngine::ImportDocumentL begin" ) ); |
|
174 |
|
175 #ifdef _DEBUG |
|
176 FHex(aDocument); |
|
177 #endif |
|
178 |
|
179 CWPWbxmlParser* parser = CWPWbxmlParser::NewL(); |
|
180 CleanupStack::PushL( parser ); |
|
181 parser->ParseL( aDocument, *iRoot ); |
|
182 CleanupStack::PopAndDestroy(); // parser |
|
183 |
|
184 CWPValidator* validator = CWPValidator::NewLC(); |
|
185 iRoot->AcceptL( *validator ); |
|
186 CleanupStack::PopAndDestroy(); |
|
187 |
|
188 CreateLinksL(); |
|
189 FLOG( _L( "[ProvisioningEngine] CWPEngine::ImportDocumentL end" ) ); |
|
190 |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CWPEngine::PopulateL |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C void CWPEngine::PopulateL() |
|
198 { |
|
199 FLOG( _L( "[ProvisioningEngine] CWPEngine::PopulateL" ) ); |
|
200 |
|
201 // First remove the old adapters |
|
202 delete iAdapters; |
|
203 iAdapters = NULL; |
|
204 |
|
205 // Create the adapters |
|
206 AdapterManagerL().PopulateL( *iRoot ); |
|
207 |
|
208 FLOG( _L( "[ProvisioningEngine] CWPEngine::PopulateL done" ) ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CWPEngine::ItemCount |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 EXPORT_C TInt CWPEngine::ItemCount() const |
|
216 { |
|
217 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::ItemCount: (%d)"), iAdapters->ItemCount())); |
|
218 |
|
219 return iAdapters->ItemCount(); |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CWPEngine::SummaryTitle |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 EXPORT_C const TDesC16& CWPEngine::SummaryTitle( TInt aIndex ) const |
|
227 { |
|
228 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::SummaryTitle: (%d)"), aIndex)); |
|
229 |
|
230 return iAdapters->SummaryTitle(aIndex); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CWPEngine::SummaryText |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C const TDesC16& CWPEngine::SummaryText( TInt aIndex ) const |
|
238 { |
|
239 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::SummaryText: (%d)"), aIndex)); |
|
240 |
|
241 return iAdapters->SummaryText(aIndex); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CWPEngine::DetailsL |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 EXPORT_C TInt CWPEngine::DetailsL( TInt aIndex, MWPPairVisitor& aVisitor ) |
|
249 { |
|
250 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::DetailsL: (%d)"), aIndex)); |
|
251 |
|
252 return AdapterManagerL().DetailsL(aIndex, aVisitor); |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CWPEngine::SaveL |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 EXPORT_C void CWPEngine::SaveL( TInt aIndex ) |
|
260 { |
|
261 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::SaveL: (%d)"), aIndex)); |
|
262 |
|
263 AdapterManagerL().SaveL( *iManager, aIndex ); |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CWPEngine::CanSetAsDefault |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 EXPORT_C TBool CWPEngine::CanSetAsDefault( TInt aIndex ) const |
|
271 { |
|
272 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::CanSetAsDefault: (%d)"), aIndex)); |
|
273 |
|
274 return iAdapters->CanSetAsDefault(aIndex); |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CWPEngine::SetAsDefaultL |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 EXPORT_C void CWPEngine::SetAsDefaultL( TInt aIndex ) |
|
282 { |
|
283 FTRACE(RDebug::Print(_L("[Provisioning] CWPEngine::SetAsDefault: (%d)"), aIndex)); |
|
284 |
|
285 AdapterManagerL().SetAsDefaultL(aIndex); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CWPEngine::CreateLinksL |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 EXPORT_C void CWPEngine::CreateLinksL() |
|
293 { |
|
294 iRoot->CreateLinksL(); |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CWPEngine::Builder |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 EXPORT_C MWPBuilder& CWPEngine::Builder() const |
|
302 { |
|
303 return *iRoot; |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // CWPEngine::ContextManager |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 MWPContextManager& CWPEngine::ContextManager() const |
|
311 { |
|
312 FLOG( _L( "[ProvisioningEngine] CWPEngine::ContextManager" ) ); |
|
313 return *iManager; |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CWPEngine::AdapterManager |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 CWPAdapterManager& CWPEngine::AdapterManagerL() |
|
321 { |
|
322 if( !iAdapters ) |
|
323 { |
|
324 iAdapters = CWPAdapterManager::NewL(); |
|
325 } |
|
326 |
|
327 return *iAdapters; |
|
328 } |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // CWPEngine::CreateContextL |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 EXPORT_C TUint32 CWPEngine::CreateContextL( const TDesC& aName, |
|
335 const TDesC& aTPS, |
|
336 const MDesC16Array& aProxies ) |
|
337 { |
|
338 return iManager->CreateContextL( aName, aTPS, aProxies ); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CWPEngine::DeleteContextL |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 EXPORT_C void CWPEngine::DeleteContextL( TUint32 aUid ) |
|
346 { |
|
347 iManager->DeleteContextL( AdapterManagerL(), aUid ); |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CWPEngine::DeleteContextDataL |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 EXPORT_C TBool CWPEngine::DeleteContextDataL( TUint32 aUid ) |
|
355 { |
|
356 return iManager->DeleteContextDataL( AdapterManagerL(), aUid ); |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CWPEngine::ContextDataCountL |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 EXPORT_C TInt CWPEngine::ContextDataCountL( TUint32 aUid ) |
|
364 { |
|
365 return iManager->ContextDataCountL( aUid ); |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CWPEngine::ContextUidsL |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 EXPORT_C CArrayFix<TUint32>* CWPEngine::ContextUidsL() |
|
373 { |
|
374 return iManager->ContextUidsL(); |
|
375 } |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // CWPEngine::ContextNameL |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 EXPORT_C HBufC* CWPEngine::ContextNameL( TUint32 aUid ) |
|
382 { |
|
383 return iManager->ContextNameL( aUid ); |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CWPEngine::ContextTPSL |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 EXPORT_C HBufC* CWPEngine::ContextTPSL( TUint32 aUid ) |
|
391 { |
|
392 return iManager->ContextTPSL( aUid ); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CWPEngine::ContextProxiesL |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 EXPORT_C CDesCArray* CWPEngine::ContextProxiesL( TUint32 aUid ) |
|
400 { |
|
401 return iManager->ContextProxiesL( aUid ); |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CWPEngine::ContextExistsL |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 EXPORT_C TBool CWPEngine::ContextExistsL( TUint32 aUid ) |
|
409 { |
|
410 return iManager->ContextExistsL( aUid ); |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CWPEngine::ContextExistsL |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 EXPORT_C TBool CWPEngine::ContextExistsL( const TDesC& aTPS ) |
|
418 { |
|
419 return iManager->ContextExistsL( aTPS ); |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CWPEngine::ContextL |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 EXPORT_C TUint32 CWPEngine::ContextL( const TDesC& aTPS ) |
|
427 { |
|
428 return iManager->ContextL( aTPS ); |
|
429 } |
|
430 |
|
431 // ----------------------------------------------------------------------------- |
|
432 // CWPEngine::CurrentContextL |
|
433 // ----------------------------------------------------------------------------- |
|
434 // |
|
435 EXPORT_C TUint32 CWPEngine::CurrentContextL() |
|
436 { |
|
437 return iManager->CurrentContextL(); |
|
438 } |
|
439 |
|
440 // ----------------------------------------------------------------------------- |
|
441 // CWPEngine::SetCurrentContextL |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 EXPORT_C void CWPEngine::SetCurrentContextL( TUint32 aUid ) |
|
445 { |
|
446 iManager->SetCurrentContextL( aUid ); |
|
447 } |
|
448 |
|
449 // ----------------------------------------------------------------------------- |
|
450 // CWPEngine::RegisterContextObserverL |
|
451 // ----------------------------------------------------------------------------- |
|
452 // |
|
453 EXPORT_C void CWPEngine::RegisterContextObserverL( |
|
454 MWPContextObserver* aObserver ) |
|
455 { |
|
456 iManager->RegisterContextObserverL( aObserver ); |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // CWPEngine::SetCurrentContextL |
|
461 // ----------------------------------------------------------------------------- |
|
462 // |
|
463 EXPORT_C TInt CWPEngine::UnregisterContextObserver( |
|
464 MWPContextObserver* aObserver ) |
|
465 { |
|
466 return iManager->UnregisterContextObserver( aObserver ); |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CWPEngine::SetAccessDenied |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 EXPORT_C void CWPEngine::SetAccessDenied(TBool aStatus) |
|
474 { |
|
475 iAccessDenied = aStatus; |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CWPEngine::GetAccessDenied |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 EXPORT_C TInt CWPEngine::GetAccessDenied() |
|
483 { |
|
484 return iAccessDenied; |
|
485 } |
|
486 |
|
487 // End of File |