|
1 /* |
|
2 * Copyright (c) 2009 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: casrvmanager.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL |
|
19 #include "casrvplugin.h" |
|
20 #include "casrvmanager.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CCaSrvManager::CCaSrvManager() |
|
27 { |
|
28 } |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CCaSrvManager::~CCaSrvManager() |
|
35 { |
|
36 THashMapIter<TInt32, CCaSrvPlugin*> iter( iPluginMap ); |
|
37 for( CCaSrvPlugin* const * ptr = |
|
38 (CCaSrvPlugin* const * ) iter.NextValue(); ptr; ptr |
|
39 = (CCaSrvPlugin* const * ) iter.NextValue() ) |
|
40 { |
|
41 delete (CCaSrvPlugin* ) ( *ptr ); |
|
42 } |
|
43 iPluginMap.Close(); |
|
44 |
|
45 delete iPluginParams; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CCaSrvManager* CCaSrvManager::NewLC( CCaStorageProxy& aCaStorageProxy, |
|
53 CCaSrvEngUtils* aUtils ) |
|
54 { |
|
55 CCaSrvManager* self = new ( ELeave ) CCaSrvManager(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL( aCaStorageProxy, aUtils ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CCaSrvManager* CCaSrvManager::NewL( |
|
66 CCaStorageProxy& aCaStorageProxy, CCaSrvEngUtils* aUtils ) |
|
67 { |
|
68 CCaSrvManager* self = CCaSrvManager::NewLC( aCaStorageProxy, aUtils ); |
|
69 CleanupStack::Pop(); // self; |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CCaSrvManager::ConstructL( CCaStorageProxy& aCaStorageProxy, |
|
78 CCaSrvEngUtils* aUtils ) |
|
79 { |
|
80 iPluginParams = new TPluginParams(); |
|
81 iPluginParams->storageProxy = &aCaStorageProxy; |
|
82 iPluginParams->engUtils = aUtils; |
|
83 |
|
84 LoadPluginsL(); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CASpaPluginManager::LoadPluginsL |
|
89 // Load plugins implementations |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CCaSrvManager::LoadPluginsL() |
|
93 { |
|
94 // Read info about all implementations into infoArray |
|
95 RImplInfoPtrArray infoArray; |
|
96 |
|
97 // Note that a special cleanup function is required to reset and destroy |
|
98 // all items in the array, and then close it. |
|
99 CleanupResetAndDestroyPushL( infoArray ); |
|
100 CCaSrvPlugin::ListAllImplementationsL( infoArray ); |
|
101 |
|
102 // Loop through each info for each implementation |
|
103 // and create and use each in turn |
|
104 CCaSrvPlugin* plug; |
|
105 for( TInt i = 0; i < infoArray.Count(); i++ ) |
|
106 { |
|
107 // Slice off first sub-section in the data section |
|
108 TUid current_plugin = infoArray[i]->ImplementationUid(); |
|
109 plug = CCaSrvPlugin::NewL( current_plugin, iPluginParams ); |
|
110 CleanupStack::PushL( plug ); |
|
111 TInt32 key = current_plugin.iUid; |
|
112 iPluginMap.InsertL( key, plug ); |
|
113 CleanupStack::Pop( plug ); |
|
114 plug = NULL; |
|
115 } |
|
116 CleanupStack::PopAndDestroy( &infoArray ); |
|
117 } |
|
118 |
|
119 // End of file |