51
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef SAMPLERPLUGINLOADER_H
|
|
20 |
#define SAMPLERPLUGINLOADER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <ecom/implementationinformation.h>
|
|
25 |
#include <piprofiler/ProfilerConfig.h>
|
|
26 |
#include <piprofiler/SamplerPluginInterface.h>
|
|
27 |
|
|
28 |
// CONSTANTS
|
|
29 |
// Value for a to b comparison result when logically a == b.
|
|
30 |
const TInt KSamplerComparisonEqual = 0;
|
|
31 |
|
|
32 |
// Value for a to b comparison result when logically a < b.
|
|
33 |
const TInt KSamplerComparisonBefore = -1;
|
|
34 |
|
|
35 |
// Value for a to b comparison result when logically a > b.
|
|
36 |
const TInt KSamplerComparisonAfter = 1;
|
|
37 |
|
|
38 |
// CLASS DEFINITIONS
|
|
39 |
class CSamplerPluginInterface;
|
|
40 |
class MSamplerPluginLoadObserver;
|
|
41 |
class REComSession;
|
|
42 |
|
|
43 |
/**
|
|
44 |
* CSamplerPluginLoader. Mechanism used to load plugins asynchronously. Uses
|
|
45 |
* MSamplerPluginLoadObserver as a callback.
|
|
46 |
*
|
|
47 |
* @lib ProfilerEngine.exe/.lib???????????
|
|
48 |
* @since Series60_30.1
|
|
49 |
*/
|
|
50 |
class CSamplerPluginLoader : public CActive
|
|
51 |
{
|
|
52 |
public: // Constructor and destructor
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Two-phased constructor.
|
|
56 |
*
|
|
57 |
* @param aAppUi Pointer to application UI. Does not take ownership.
|
|
58 |
*/
|
62
|
59 |
static CSamplerPluginLoader* NewL(TBool aBootMode);
|
51
|
60 |
|
|
61 |
/**
|
|
62 |
* Destructor
|
|
63 |
*/
|
|
64 |
~CSamplerPluginLoader();
|
|
65 |
|
|
66 |
private: // Internal construction
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Default C++ contructor
|
|
70 |
*/
|
62
|
71 |
CSamplerPluginLoader(TBool aBootMode);
|
51
|
72 |
|
|
73 |
/**
|
|
74 |
* Symbian OS default constructor
|
|
75 |
* @return void
|
|
76 |
*/
|
|
77 |
void ConstructL();
|
|
78 |
|
|
79 |
public: // API
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Starts loading GS plug-ins asynchronously. Will call
|
|
83 |
* MSamplerPluginLoadObserver::HandlePluginLoaded() each time a plug-in is
|
|
84 |
* loaded and when all plugins are loaded.
|
|
85 |
*
|
|
86 |
* CSamplerPluginLoader transfers the ownership of each loaded plugin view to
|
|
87 |
* CAknViewAppUi. It is client's responsibility to remove the views from
|
|
88 |
* CAknViewAppUi and delete the plugins if necessary.
|
|
89 |
*
|
|
90 |
* @param aInterfaceUid Uid ofthe interfaces to be loaded.
|
|
91 |
* @param aParentUid Uid of the parent. Only children of this parent
|
|
92 |
* will be loaded.
|
|
93 |
* @param aPluginArray An array for the loaded GS plug-ins.
|
|
94 |
* CSamplerPluginLoader does not take the ownership of this array.
|
|
95 |
*/
|
|
96 |
void LoadAsyncL( CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray );
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Load a specific plugin instance synchronously.
|
|
100 |
*
|
|
101 |
* @param aInterfaceUid Uid ofthe interfaces to be loaded.
|
|
102 |
* @param aImplementationUid Uid of the implementation to load
|
|
103 |
*/
|
|
104 |
void LoadSyncL( CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray );
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Sets observer for this loader. Only one observer per loader in one
|
|
108 |
* time is possible.
|
|
109 |
*/
|
|
110 |
void SetObserver(MSamplerPluginLoadObserver* aObserver);
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Aborts asynchronous loading of the GS plug-ins.
|
|
114 |
*/
|
|
115 |
void AbortAsyncLoad();
|
|
116 |
|
62
|
117 |
void LoadRlibraryL(CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray);
|
|
118 |
|
51
|
119 |
/**
|
|
120 |
* Sorts the plugin array.
|
|
121 |
*
|
|
122 |
* Sorting criterias:
|
|
123 |
*
|
|
124 |
* 1. Order number if provider category is Internal.
|
|
125 |
* 2. Provider category. Precedence as follows:
|
|
126 |
* 1. KGSPluginProviderInternal
|
|
127 |
* 2. EGSPluginProviderOEM
|
|
128 |
* 3. EGSPluginProviderOperator
|
|
129 |
* 4. EGSPluginProvider3rdParty
|
|
130 |
* 3. Alphabetical
|
|
131 |
*
|
|
132 |
* @param aPlugins The array which will be sorted.
|
|
133 |
*/
|
|
134 |
void SortPluginsL( CArrayPtrFlat<CSamplerPluginInterface>* aPlugins );
|
|
135 |
|
|
136 |
private: // Internal methods
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Starts loading next plugin.
|
|
140 |
*/
|
|
141 |
void LoadNextPluginL();
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Creates a plugin instance from given UID. Ownership is transferred.
|
|
145 |
*/
|
|
146 |
CSamplerPluginInterface& CreatePluginInstanceL(
|
|
147 |
const CImplementationInformation& aImpInfo );
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Notifies MPluginLoadObserver.
|
|
151 |
*/
|
|
152 |
void NotifyProgress();
|
|
153 |
|
|
154 |
/**
|
|
155 |
* Notifies MPluginLoadObserver.
|
|
156 |
*/
|
|
157 |
void NotifyFinished();
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Wait for the next round of CActive execution.
|
|
161 |
*/
|
|
162 |
void CompleteOwnRequest();
|
|
163 |
|
|
164 |
// Insertion function used by sorting:
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Inserts plugin in the correct position in the array using sorting
|
|
168 |
* criterias. Assumes aPlugins is ordered.
|
|
169 |
*
|
|
170 |
* @param aPlugin The plugin to be inserted.
|
|
171 |
* @param aPlugins Array in which the plugin is inserted into the
|
|
172 |
* corresponding location.
|
|
173 |
*/
|
|
174 |
void InsertPluginInOrderL(
|
|
175 |
CSamplerPluginInterface* aPlugin,
|
|
176 |
CArrayPtrFlat<CSamplerPluginInterface>* aPlugins );
|
|
177 |
|
|
178 |
// Comparison functions:
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Compares plugins according to comparison criterias.
|
|
182 |
*
|
|
183 |
* Note: GS internal comparison constants such as KGSComparisonEqual are
|
|
184 |
* different from the ones outputted by this function. This is because
|
|
185 |
* this function is also usable by RArray sort -functionality but BC
|
|
186 |
* cannot be broken in GS.
|
|
187 |
*
|
|
188 |
* @return Negative value: If aFirst before aSecond.
|
|
189 |
* 0: If equal.
|
|
190 |
* Positive value: If aSecond before aFirst.
|
|
191 |
*/
|
|
192 |
static TInt Compare( const CSamplerPluginInterface& aFirst,
|
|
193 |
const CSamplerPluginInterface& aSecond );
|
|
194 |
|
|
195 |
/**
|
|
196 |
*
|
|
197 |
* @return KGSComparisonEqual = equal indexes
|
|
198 |
* KGSComparisonBefore = aFirst is before aSecond
|
|
199 |
* KGSComparisonAfter = aFirst is after aSecond
|
|
200 |
*/
|
|
201 |
|
|
202 |
static TInt CompareIndex(
|
|
203 |
const CSamplerPluginInterface& aFirst,
|
|
204 |
const CSamplerPluginInterface& aSecond );
|
|
205 |
|
|
206 |
private: // Utility methods
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Parses descriptor to UID.
|
|
210 |
*/
|
|
211 |
static TInt ParseToUid( const TDesC8& aSource, TUid& aTarget );
|
|
212 |
|
|
213 |
/**
|
|
214 |
* Parsers plugin's order number
|
|
215 |
*/
|
|
216 |
static TInt ParseOrderNumber( const TDesC8& aSource, TInt& aOrderNumber );
|
|
217 |
|
|
218 |
private: // From CActive
|
|
219 |
|
|
220 |
/**
|
|
221 |
* See base class.
|
|
222 |
*/
|
|
223 |
void RunL();
|
|
224 |
|
|
225 |
/**
|
|
226 |
* See base class.
|
|
227 |
*/
|
|
228 |
TInt RunError( TInt aError );
|
|
229 |
|
|
230 |
/**
|
|
231 |
* See base class.
|
|
232 |
*/
|
|
233 |
void DoCancel();
|
|
234 |
|
|
235 |
private: // Data
|
|
236 |
// Pluginloader goes through this array and loads the plugins into
|
|
237 |
// iPluginArray if they fulfill the criterias.
|
|
238 |
RImplInfoPtrArray iImplInfoArray;
|
|
239 |
|
|
240 |
// Used as an iterator to maintain location in iImplInfoArray.
|
|
241 |
TInt iImplInfoArrayIterator;
|
|
242 |
|
|
243 |
// Array of loaded plugins.Plugins are owned by iAppUi. Only the array
|
|
244 |
// pointers are owned by this class and therefore only reset array.
|
|
245 |
CArrayPtrFlat<CSamplerPluginInterface>* iPluginArray;
|
|
246 |
|
|
247 |
// Pointer to observer. Not owned.
|
|
248 |
MSamplerPluginLoadObserver* iObserver;
|
|
249 |
|
|
250 |
// Number of RunL calls.
|
|
251 |
TInt iRunLDebugCount;
|
62
|
252 |
TBool iBootMode;
|
51
|
253 |
|
|
254 |
};
|
|
255 |
|
|
256 |
|
|
257 |
/**
|
|
258 |
* Interface for SamplerPluginLoader observer. MSamplerPluginLoadObserver gets
|
|
259 |
* notifications when plugins are loaded.
|
|
260 |
*
|
|
261 |
* @lib ProfilerEngine.exe/.lib???????????
|
|
262 |
* @since Series60_30.1
|
|
263 |
*/
|
|
264 |
|
|
265 |
class MSamplerPluginLoadObserver
|
|
266 |
{
|
|
267 |
public: // Enums
|
|
268 |
enum KSamplerPluginLoaderStatus
|
|
269 |
{
|
|
270 |
// One plugin loaded successfully, continue to next.
|
|
271 |
ESamplerSuccess,
|
|
272 |
// Loading one plugin failed, contiue to next.
|
|
273 |
ESamplerFail,
|
|
274 |
// Client called AbortAsyncLoad(), finished loading.
|
|
275 |
ESamplerAborted,
|
|
276 |
// All plugins loaded successfully, finished loading.
|
|
277 |
ESamplerFinished,
|
|
278 |
// Severe error with loader, finished loading.
|
|
279 |
ESamplerError
|
|
280 |
};
|
|
281 |
|
|
282 |
public: // New
|
|
283 |
|
|
284 |
//CSamplerPluginLoader calls this function when each plug-in is loaded or
|
|
285 |
//loading is finished..
|
|
286 |
|
|
287 |
IMPORT_C virtual void HandlePluginLoaded(
|
|
288 |
KSamplerPluginLoaderStatus aStatus ) = 0;
|
|
289 |
};
|
|
290 |
|
|
291 |
|
|
292 |
#endif // SAMPLERPLUGINLOADER_H
|
|
293 |
// End of File
|