85
|
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 |
// ---------------------------------------------------------------------------
|
94
|
88 |
//
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
EXPORT_C TInt CCaSrvManager::LoadOperationErrorCodeL()
|
|
92 |
{
|
|
93 |
return iErrorCode;
|
|
94 |
}
|
|
95 |
|
|
96 |
// ---------------------------------------------------------------------------
|
85
|
97 |
// CASpaPluginManager::LoadPluginsL
|
|
98 |
// Load plugins implementations
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CCaSrvManager::LoadPluginsL()
|
|
102 |
{
|
|
103 |
// Read info about all implementations into infoArray
|
|
104 |
RImplInfoPtrArray infoArray;
|
|
105 |
|
|
106 |
// Note that a special cleanup function is required to reset and destroy
|
|
107 |
// all items in the array, and then close it.
|
|
108 |
CleanupResetAndDestroyPushL( infoArray );
|
|
109 |
CCaSrvPlugin::ListAllImplementationsL( infoArray );
|
|
110 |
|
|
111 |
// Loop through each info for each implementation
|
|
112 |
// and create and use each in turn
|
|
113 |
CCaSrvPlugin* plug;
|
|
114 |
for( TInt i = 0; i < infoArray.Count(); i++ )
|
|
115 |
{
|
|
116 |
// Slice off first sub-section in the data section
|
|
117 |
TUid current_plugin = infoArray[i]->ImplementationUid();
|
94
|
118 |
TRAPD(err, plug = CCaSrvPlugin::NewL( current_plugin, iPluginParams ));
|
|
119 |
if( KErrNone==iErrorCode )
|
|
120 |
{
|
|
121 |
// remember error code only if it wasn't set yet
|
|
122 |
iErrorCode = err;
|
|
123 |
}
|
85
|
124 |
CleanupStack::PushL( plug );
|
|
125 |
TInt32 key = current_plugin.iUid;
|
|
126 |
iPluginMap.InsertL( key, plug );
|
|
127 |
CleanupStack::Pop( plug );
|
|
128 |
plug = NULL;
|
|
129 |
}
|
|
130 |
CleanupStack::PopAndDestroy( &infoArray );
|
|
131 |
}
|
|
132 |
|
94
|
133 |
|
85
|
134 |
// End of file
|