25
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2006 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CPLUGINVALIDATOR_H
|
|
20 |
#define CPLUGINVALIDATOR_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <e32hashtab.h>
|
|
25 |
#include <ecom/implementationinformation.h>
|
|
26 |
|
|
27 |
// FORWARD DECLARATIONS
|
|
28 |
class REComSession;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Class containing information regarding a plugin
|
|
32 |
*
|
|
33 |
*
|
|
34 |
* @lib cpclient.dll
|
|
35 |
* @since S60 v 5.0
|
|
36 |
*/
|
|
37 |
NONSHARABLE_CLASS( TPluginInfo )
|
|
38 |
{
|
|
39 |
public:
|
|
40 |
TAny* iPlugin; // not own
|
|
41 |
TUid iImplementationUid;
|
|
42 |
TInt iVersion;
|
|
43 |
TUid iDtor_ID_Key;
|
|
44 |
};
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Class used to maintain required ECOM plugins implementations
|
|
48 |
*
|
|
49 |
*
|
|
50 |
* @lib cpclient.dll
|
|
51 |
* @since S60 v 5.0
|
|
52 |
*/
|
|
53 |
NONSHARABLE_CLASS( CPluginValidator ): public CActive
|
|
54 |
{
|
|
55 |
public:
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Two-phased constructor.
|
|
59 |
*
|
|
60 |
*/
|
|
61 |
IMPORT_C static CPluginValidator* NewL( TUid aUid,
|
|
62 |
TAny *aParameter = NULL );
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Two-phased constructor.
|
|
66 |
*
|
|
67 |
*/
|
|
68 |
IMPORT_C static CPluginValidator* NewLC( TUid aUid,
|
|
69 |
TAny *aParameter = NULL );
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Gets plugin with provided UID
|
|
73 |
*
|
|
74 |
* @param aUid required plugin
|
|
75 |
* @return pointer to plugin implementation
|
|
76 |
*/
|
|
77 |
IMPORT_C TAny* GetImplementation( TUid aUid );
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Gets plugin with provided index
|
|
81 |
*
|
|
82 |
* @param aIndex index of plugin
|
|
83 |
* @return pointer to plugin implementation
|
|
84 |
*/
|
|
85 |
IMPORT_C TAny* GetImplementation( TInt aIndex );
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Gets number of plugins
|
|
89 |
*
|
|
90 |
* @return number of plugins
|
|
91 |
*/
|
|
92 |
IMPORT_C TInt GetCount();
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Desctructor.
|
|
96 |
*/
|
|
97 |
virtual ~CPluginValidator();
|
|
98 |
|
|
99 |
protected:
|
|
100 |
|
|
101 |
/**
|
|
102 |
* From CActive, RunL.
|
|
103 |
* Handles the active object’s request completion event
|
|
104 |
*/
|
|
105 |
void RunL();
|
|
106 |
|
|
107 |
/**
|
|
108 |
* From CActive, DoCancel.
|
|
109 |
* Implements cancellation of an outstanding request.
|
|
110 |
*/
|
|
111 |
void DoCancel();
|
|
112 |
|
|
113 |
/**
|
|
114 |
* From CActive, RunError.
|
|
115 |
* Method called when leave occured in RunL
|
|
116 |
*/
|
|
117 |
TInt RunError( TInt aError );
|
|
118 |
|
|
119 |
protected:
|
|
120 |
|
|
121 |
/**
|
|
122 |
* C++ default constructor.
|
|
123 |
*/
|
|
124 |
CPluginValidator( TUid aUid, TAny *aParameter );
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Perform the second phase construction of a CPluginValidator object.
|
|
128 |
*/
|
|
129 |
void ConstructL();
|
|
130 |
|
|
131 |
/*
|
|
132 |
* Checks if plugin is present in an array
|
|
133 |
*/
|
|
134 |
TBool PresentInArrayL( TPluginInfo aPluginInfo,
|
|
135 |
const RImplInfoPtrArray& aInfoArray );
|
|
136 |
|
|
137 |
/*
|
|
138 |
*
|
|
139 |
*/
|
|
140 |
void DestroyPlugin( TInt aIndex );
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Cleans plugins table;
|
|
144 |
*/
|
|
145 |
void CleanPluginsTable();
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Loads or destroys plugins
|
|
149 |
*/
|
|
150 |
virtual void ManagePluginsL();
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Loads ECOM plugins
|
|
154 |
*/
|
|
155 |
virtual void LoadPluginL( TPluginInfo& aPluginInfo );
|
|
156 |
|
|
157 |
protected:
|
|
158 |
|
|
159 |
/**
|
|
160 |
* ECOM handler
|
|
161 |
* Own.
|
|
162 |
*/
|
|
163 |
REComSession* iSession;
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Array containing plugins
|
|
167 |
* Own.
|
|
168 |
*/
|
|
169 |
RArray<TPluginInfo> iPluginArray;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* UID of the interface
|
|
173 |
*/
|
|
174 |
const TUid iUid;
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Parameter to pass to the object creation method.
|
|
178 |
*/
|
|
179 |
TAny* iParameter;
|
|
180 |
};
|
|
181 |
|
|
182 |
// ==================== LOCAL FUNCTIONS ====================
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Identity function to search in an array of TPluginInfo.
|
|
186 |
* @param aLeft Search term.
|
|
187 |
* @param aRight Array item.
|
|
188 |
* @return ETrue if ID-s match.
|
|
189 |
*/
|
|
190 |
LOCAL_C TBool UidMatch( const TPluginInfo& aLeft, const TPluginInfo& aRight )
|
|
191 |
{
|
|
192 |
return aLeft.iImplementationUid == aRight.iImplementationUid;
|
|
193 |
}
|
|
194 |
|
|
195 |
#endif // CPLUGINVALIDATOR_H
|