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 |
// INCLUDE FILES
|
|
20 |
#include "WriterPluginLoader.h"
|
|
21 |
//#include <piprofiler/EngineUIDs.h>
|
|
22 |
#include <utf.h> // CnvUtfConverter
|
|
23 |
#include <basched.h>
|
|
24 |
|
|
25 |
// constants
|
|
26 |
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
// CWriterPluginLoader::NewL
|
|
29 |
//
|
|
30 |
// EPOC two-phased constructor
|
|
31 |
// ----------------------------------------------------------------------------
|
|
32 |
//
|
62
|
33 |
CWriterPluginLoader* CWriterPluginLoader::NewL(TBool aBootMode)
|
51
|
34 |
{
|
62
|
35 |
CWriterPluginLoader* self = new( ELeave ) CWriterPluginLoader(aBootMode);
|
51
|
36 |
CleanupStack::PushL( self );
|
|
37 |
self->ConstructL( );
|
|
38 |
CleanupStack::Pop( self );
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
// ----------------------------------------------------------------------------
|
|
44 |
// CWriterPluginLoader::CWriterPluginLoader
|
|
45 |
//
|
|
46 |
// C++ default constructor can NOT contain any code, that
|
|
47 |
// might leave.
|
|
48 |
// ----------------------------------------------------------------------------
|
|
49 |
//
|
62
|
50 |
CWriterPluginLoader::CWriterPluginLoader(TBool aBootMode) :
|
|
51 |
CActive( EPriorityStandard ),
|
|
52 |
iBootMode(aBootMode)
|
51
|
53 |
{
|
|
54 |
LOGTEXT(_L("CWriterPluginLoader()::CWriterPluginLoader()" ));
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
// ----------------------------------------------------------------------------
|
|
59 |
// CWriterPluginLoader::ConstructL
|
|
60 |
//
|
|
61 |
// EPOC default constructor can leave.
|
|
62 |
// ----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
void CWriterPluginLoader::ConstructL( )
|
|
65 |
{
|
|
66 |
LOGTEXT(_L("CWriterPluginLoader()::ConstructL()" ));
|
|
67 |
|
|
68 |
// get list of implementations
|
|
69 |
CWriterPluginInterface::ListAllImplementationsL( iImplInfoArray );
|
|
70 |
|
|
71 |
CActiveScheduler::Add( this );
|
|
72 |
}
|
|
73 |
|
|
74 |
// ----------------------------------------------------------------------------
|
|
75 |
// CWriterPluginLoader::~CWriterPluginLoader
|
|
76 |
//
|
|
77 |
// Destructor
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CWriterPluginLoader::~CWriterPluginLoader()
|
|
81 |
{
|
|
82 |
LOGTEXT(_L("CWriterPluginLoader()::~CWriterPluginLoader()") );
|
|
83 |
|
|
84 |
AbortAsyncLoad();
|
|
85 |
|
|
86 |
Cancel();
|
|
87 |
|
|
88 |
// reset ECOM implementation info array
|
|
89 |
iImplInfoArray.ResetAndDestroy(); // This is needed
|
|
90 |
iImplInfoArray.Close();
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
// CWriterPluginLoader::LoadAsync
|
|
96 |
//
|
|
97 |
//
|
|
98 |
// ----------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
void CWriterPluginLoader::LoadAsyncL( CArrayPtrFlat<CWriterPluginInterface>* aPluginArray )
|
|
101 |
{
|
|
102 |
iPluginArray = aPluginArray;
|
|
103 |
|
|
104 |
// Reset iterator:
|
|
105 |
iImplInfoArrayIterator = 0;
|
|
106 |
|
|
107 |
LOGSTRING2( "CWriterPluginLoader()::Implementation info count: %d",
|
|
108 |
iImplInfoArray.Count() );
|
|
109 |
|
|
110 |
NotifyProgress();
|
|
111 |
|
|
112 |
//Begin CActive asynchronous loop.
|
|
113 |
CompleteOwnRequest();
|
|
114 |
}
|
|
115 |
|
|
116 |
|
|
117 |
// ----------------------------------------------------------------------------
|
|
118 |
// CWriterPluginLoader::LoadSyncL
|
|
119 |
//
|
|
120 |
//
|
|
121 |
// ----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
CWriterPluginInterface& CWriterPluginLoader::LoadSyncL( TUid aImplementationUid )
|
|
124 |
{
|
|
125 |
Cancel();
|
|
126 |
CWriterPluginInterface* plugin = NULL;
|
|
127 |
|
|
128 |
// Get a list of all implementations, even though we only want one specific
|
|
129 |
// one. There appears to be no way to otherwise extract a specific implementation
|
|
130 |
// info object :(
|
|
131 |
// Search for the implementation that matches aImplementationUid
|
|
132 |
const TInt impCount = iImplInfoArray.Count();
|
|
133 |
for( TInt i=0; i<impCount; i++ )
|
|
134 |
{
|
|
135 |
const CImplementationInformation* info = iImplInfoArray[ i ];
|
|
136 |
if ( info->ImplementationUid() == aImplementationUid )
|
|
137 |
{
|
|
138 |
TRAPD(ret, plugin = &CreatePluginInstanceL( *info ); );
|
62
|
139 |
if(plugin != NULL)
|
51
|
140 |
{
|
62
|
141 |
if( ret == KErrNone )
|
|
142 |
{
|
|
143 |
// Plugin ownership is transfered to iPluginArray
|
|
144 |
InsertPluginInOrderL( plugin, iPluginArray );
|
|
145 |
}
|
|
146 |
else
|
|
147 |
{
|
|
148 |
// Error note is displayed even if plugin is not loaded
|
|
149 |
LOGSTRING2("CWriterPluginLoader::LoadSyncL() - plugin load failed, error %d", ret);
|
|
150 |
}
|
51
|
151 |
}
|
|
152 |
break;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
if ( plugin == NULL )
|
|
157 |
{
|
|
158 |
User::Leave( KErrNotFound );
|
|
159 |
}
|
|
160 |
return *plugin;
|
|
161 |
}
|
|
162 |
|
|
163 |
|
|
164 |
// ----------------------------------------------------------------------------
|
|
165 |
// CWriterPluginLoader::AbortAsyncLoad
|
|
166 |
//
|
|
167 |
//
|
|
168 |
// ----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
void CWriterPluginLoader::AbortAsyncLoad()
|
|
171 |
{
|
|
172 |
LOGTEXT(_L("CWriterPluginLoader()::AbortAsyncLoad()" ));
|
|
173 |
Cancel();
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
// ----------------------------------------------------------------------------
|
|
178 |
// CWriterPluginLoader::RunL
|
|
179 |
//
|
|
180 |
//
|
|
181 |
// ----------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
void CWriterPluginLoader::RunL()
|
|
184 |
{
|
|
185 |
iRunLDebugCount++;
|
62
|
186 |
if (iBootMode)
|
51
|
187 |
{
|
62
|
188 |
LOGTEXT(_L("CWriterPluginLoader() Rlibrary has been loaded." ));
|
|
189 |
NotifyFinished();
|
51
|
190 |
}
|
|
191 |
else
|
|
192 |
{
|
62
|
193 |
LoadNextPluginL();
|
|
194 |
|
|
195 |
// Check if there are still more plugins to be loaded:
|
|
196 |
if ( iImplInfoArrayIterator < iImplInfoArray.Count() )
|
|
197 |
{
|
|
198 |
NotifyProgress();
|
|
199 |
// Continue CActive asynchronous loop.
|
|
200 |
CompleteOwnRequest();
|
|
201 |
}
|
|
202 |
else
|
|
203 |
{
|
|
204 |
// All plugins loaded:
|
|
205 |
LOGTEXT(_L("CWriterPluginLoader()::Loading plugins finished." ));
|
|
206 |
NotifyFinished();
|
|
207 |
}
|
51
|
208 |
}
|
|
209 |
}
|
|
210 |
|
|
211 |
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
// CScGenreItemConstructionConductor::CompleteOwnRequest
|
|
214 |
//
|
|
215 |
// Issue request complete notification.
|
|
216 |
// ---------------------------------------------------------------------------
|
|
217 |
void CWriterPluginLoader::CompleteOwnRequest()
|
|
218 |
{
|
|
219 |
TRequestStatus* status = &iStatus;
|
|
220 |
User::RequestComplete( status, KErrNone );
|
|
221 |
SetActive();
|
|
222 |
}
|
|
223 |
|
|
224 |
|
|
225 |
// ----------------------------------------------------------------------------
|
|
226 |
// CWriterPluginLoader::RunError
|
|
227 |
//
|
|
228 |
//
|
|
229 |
// ----------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
TInt CWriterPluginLoader::RunError( TInt aError )
|
|
232 |
{
|
|
233 |
// This method is called when a plugin loading fails.
|
|
234 |
// Always "fake" the return value so that ActiveSchedule
|
|
235 |
// keeps running and later plugins are continued to be loaded.
|
|
236 |
// Check if still plugins to be loaded:
|
|
237 |
if( iImplInfoArrayIterator < iImplInfoArray.Count() )
|
|
238 |
{
|
|
239 |
NotifyProgress();
|
|
240 |
|
|
241 |
//Continue CActive asynchronous loop.
|
|
242 |
CompleteOwnRequest();
|
|
243 |
}
|
|
244 |
else // All plugins loaded:
|
|
245 |
{
|
|
246 |
NotifyFinished();
|
|
247 |
}
|
|
248 |
|
|
249 |
if ( aError == KLeaveExit )
|
|
250 |
{
|
|
251 |
return KLeaveExit;
|
|
252 |
}
|
|
253 |
|
|
254 |
return KErrNone;
|
|
255 |
}
|
|
256 |
|
|
257 |
|
|
258 |
// ----------------------------------------------------------------------------
|
|
259 |
// CWriterPluginLoader::DoCancel
|
|
260 |
//
|
|
261 |
//
|
|
262 |
// ----------------------------------------------------------------------------
|
|
263 |
//
|
|
264 |
void CWriterPluginLoader::DoCancel()
|
|
265 |
{
|
|
266 |
|
|
267 |
}
|
|
268 |
|
|
269 |
|
|
270 |
// ----------------------------------------------------------------------------
|
|
271 |
// CWriterPluginLoader::NotifyProgress
|
|
272 |
//
|
|
273 |
//
|
|
274 |
// ----------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
void CWriterPluginLoader::NotifyProgress()
|
|
277 |
{
|
|
278 |
if( iObserver )
|
|
279 |
{
|
|
280 |
iObserver->HandlePluginLoaded( MWriterPluginLoadObserver::EWriterSuccess);
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
|
|
285 |
// ----------------------------------------------------------------------------
|
|
286 |
// CWriterPluginLoader::NotifyFinished
|
|
287 |
//
|
|
288 |
//
|
|
289 |
// ----------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
void CWriterPluginLoader::NotifyFinished()
|
|
292 |
{
|
|
293 |
if( iObserver )
|
|
294 |
{
|
|
295 |
iObserver->HandlePluginLoaded( MWriterPluginLoadObserver::EWriterFinished );
|
|
296 |
}
|
|
297 |
}
|
|
298 |
|
|
299 |
|
|
300 |
// ----------------------------------------------------------------------------
|
|
301 |
// CWriterPluginLoader::SetObserver
|
|
302 |
//
|
|
303 |
//
|
|
304 |
// ----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
void CWriterPluginLoader::SetObserver(MWriterPluginLoadObserver* aObserver)
|
|
307 |
{
|
|
308 |
LOGSTRING2("CWriterPluginLoader()::Observer set:0x%X", aObserver);
|
|
309 |
iObserver = aObserver;
|
|
310 |
}
|
|
311 |
|
|
312 |
|
|
313 |
// ----------------------------------------------------------------------------
|
|
314 |
// CWriterPluginLoader::ParseToUid
|
|
315 |
// Parses a UID from descriptor of form '0xNNNNNNNN' where N is hexadecimal.
|
|
316 |
//
|
|
317 |
// ----------------------------------------------------------------------------
|
|
318 |
//
|
|
319 |
TInt CWriterPluginLoader::ParseToUid( const TDesC8& aSource, TUid& aTarget )
|
|
320 |
{
|
|
321 |
// Remove "0x" from the descriptor if it exists
|
|
322 |
_LIT8(KHexPrefix, "0x");
|
|
323 |
|
|
324 |
TPtrC8 pSource( aSource );
|
|
325 |
const TInt prefixPosition = pSource.Find( KHexPrefix );
|
|
326 |
if ( prefixPosition != KErrNotFound )
|
|
327 |
{
|
|
328 |
pSource.Set( aSource.Mid( prefixPosition + KHexPrefix().Length() ) );
|
|
329 |
}
|
|
330 |
|
|
331 |
// Parse to integer
|
|
332 |
TLex8 lex( pSource );
|
|
333 |
TUint integer = 0;
|
|
334 |
|
|
335 |
// Parse using TRadix::EHex as radix:
|
|
336 |
const TInt err = lex.Val( integer, EHex );
|
|
337 |
aTarget.iUid = integer;
|
|
338 |
|
|
339 |
if( err != KErrNone )
|
|
340 |
{
|
|
341 |
// If parsing parent UID failed, do not load plugin:
|
|
342 |
LOGSTRING2(
|
|
343 |
"CWriterPluginLoader()::Parsing parent UID failed. Error code:%d",
|
|
344 |
err );
|
|
345 |
}
|
|
346 |
return err;
|
|
347 |
}
|
|
348 |
|
|
349 |
|
|
350 |
// ----------------------------------------------------------------------------
|
|
351 |
// CWriterPluginLoader::ParseOrderNumber
|
|
352 |
//
|
|
353 |
//
|
|
354 |
// ----------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
TInt CWriterPluginLoader::ParseOrderNumber( const TDesC8& aSource, TInt& aOrderNumber )
|
|
357 |
{
|
|
358 |
// Parse plugin's order number from opaque_data:
|
|
359 |
TLex8 lex( aSource );
|
|
360 |
const TInt orderErr = lex.Val( aOrderNumber );
|
|
361 |
return orderErr;
|
|
362 |
}
|
|
363 |
|
|
364 |
// ----------------------------------------------------------------------------
|
|
365 |
// CWriterPluginLoader::LoadNextPluginL
|
|
366 |
// Iterate through iImplInfoArray. Load the plugin if it is eligible for
|
|
367 |
// loading. Loaded plugin is added to iPluginArray. Each time a plugin is
|
|
368 |
// loaded, iObserver is notified.
|
|
369 |
//
|
|
370 |
// ----------------------------------------------------------------------------
|
|
371 |
//
|
|
372 |
void CWriterPluginLoader::LoadNextPluginL()
|
|
373 |
{
|
|
374 |
// Iterate through iImplInfoArray. This loop continues between function
|
|
375 |
// calls. Therefore member variable iImplInfoArrayIterator is used as a
|
|
376 |
// counter. Loop will break when match is found and continues on next RunL.
|
|
377 |
for( ; iImplInfoArrayIterator < iImplInfoArray.Count(); )
|
|
378 |
{
|
|
379 |
const CImplementationInformation* info =
|
|
380 |
iImplInfoArray[ iImplInfoArrayIterator ];
|
|
381 |
|
|
382 |
iImplInfoArrayIterator++;
|
|
383 |
|
|
384 |
// If this plugin is OK -> load it:
|
|
385 |
LOGSTRING2( "CWriterPluginLoader() %S eligible for parent",
|
|
386 |
&info->DisplayName() );
|
|
387 |
CWriterPluginInterface* plugin = NULL;
|
|
388 |
TInt error(KErrNone);
|
|
389 |
// Create plugin. Trap leave for debugging purposes.
|
|
390 |
TRAP( error, plugin = &CreatePluginInstanceL( *info ); );
|
|
391 |
if( error == KErrNone )
|
|
392 |
{
|
|
393 |
// Plugin ownership is transfered to iPluginArray
|
|
394 |
InsertPluginInOrderL( plugin, iPluginArray );
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
LOGSTRING2("CWriterPluginLoader::LoadNextPluginL() - plugin load failed, error %d", error);
|
|
399 |
}
|
|
400 |
// Wait for next round
|
|
401 |
break;
|
|
402 |
}
|
|
403 |
}
|
|
404 |
|
|
405 |
// ----------------------------------------------------------------------------
|
|
406 |
// CWriterPluginLoader::CreatePluginInstanceL
|
|
407 |
//
|
|
408 |
//
|
|
409 |
// ----------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
|
|
412 |
CWriterPluginInterface& CWriterPluginLoader::CreatePluginInstanceL(
|
|
413 |
const CImplementationInformation& aImpInfo )
|
|
414 |
{
|
|
415 |
// Now we can load the plugin
|
|
416 |
const TUid implUid = aImpInfo.ImplementationUid();
|
|
417 |
|
|
418 |
CWriterPluginInterface* plugin = CWriterPluginInterface::NewL( implUid , (TAny*)&aImpInfo.DisplayName() );
|
|
419 |
CleanupStack::PushL ( plugin );
|
|
420 |
|
|
421 |
TInt orderNumber(0);
|
|
422 |
const TInt orderErr = ParseOrderNumber( aImpInfo.OpaqueData(), orderNumber );
|
|
423 |
|
|
424 |
if ( orderErr == KErrNone && orderNumber >= 0 )
|
|
425 |
{
|
|
426 |
plugin->iOrder = orderNumber;
|
|
427 |
}
|
|
428 |
|
|
429 |
CleanupStack::Pop( plugin ); // CWriterController is now responsible for this memory.
|
|
430 |
|
|
431 |
return *plugin;
|
|
432 |
}
|
|
433 |
|
|
434 |
// ----------------------------------------------------------------------------
|
|
435 |
// CWriterPluginLoader::SortPluginsL
|
|
436 |
//
|
|
437 |
// ----------------------------------------------------------------------------
|
|
438 |
//
|
|
439 |
void CWriterPluginLoader::SortPluginsL(
|
|
440 |
CArrayPtrFlat<CWriterPluginInterface>* aPlugins )
|
|
441 |
{
|
|
442 |
RPointerArray<CWriterPluginInterface> plugins;
|
|
443 |
TLinearOrder<CWriterPluginInterface> order( CWriterPluginLoader::Compare );
|
|
444 |
|
|
445 |
// Insertion will also order
|
|
446 |
for( TInt i = 0; i < aPlugins->Count(); i++ )
|
|
447 |
{
|
|
448 |
plugins.InsertInOrderL( (*aPlugins)[i], order );
|
|
449 |
}
|
|
450 |
|
|
451 |
// Replace original array content with sorted items
|
|
452 |
aPlugins->Reset();
|
|
453 |
for( TInt i = 0; i < plugins.Count(); i++ )
|
|
454 |
{
|
|
455 |
aPlugins->AppendL( plugins[i] );
|
|
456 |
}
|
|
457 |
}
|
|
458 |
|
|
459 |
|
|
460 |
// ----------------------------------------------------------------------------
|
|
461 |
// CWriterPluginLoader::Compare
|
|
462 |
//
|
|
463 |
// Compare two plugins.
|
|
464 |
// Precedence:
|
|
465 |
// [1. plugin provider category]
|
|
466 |
// 2. plugin order number
|
|
467 |
// 3. plugin caption
|
|
468 |
// Plugin provider gategory is currently disabled (not supported yet).
|
|
469 |
// ----------------------------------------------------------------------------
|
|
470 |
//
|
|
471 |
TInt CWriterPluginLoader::Compare( const CWriterPluginInterface& aFirst,
|
|
472 |
const CWriterPluginInterface& aSecond )
|
|
473 |
{
|
|
474 |
return CompareIndex( aFirst, aSecond );
|
|
475 |
}
|
|
476 |
|
|
477 |
|
|
478 |
// ----------------------------------------------------------------------------
|
|
479 |
// CWriterPluginLoader::InsertPluginInOrderL
|
|
480 |
//
|
|
481 |
// ----------------------------------------------------------------------------
|
|
482 |
//
|
|
483 |
void CWriterPluginLoader::InsertPluginInOrderL(
|
|
484 |
CWriterPluginInterface* aPlugin,
|
|
485 |
CArrayPtrFlat<CWriterPluginInterface>* aPlugins )
|
|
486 |
{
|
|
487 |
CWriterPluginInterface* comparedPlugin;
|
|
488 |
TInt comparison = 0;
|
|
489 |
TBool inserted = EFalse;
|
|
490 |
|
|
491 |
for( TInt i = 0; i < aPlugins->Count(); i++ )
|
|
492 |
{
|
|
493 |
comparedPlugin = (*aPlugins)[i];
|
|
494 |
// Optimization: do not call time consuming Compare() multiple times!
|
|
495 |
comparison = Compare( *aPlugin, *comparedPlugin );
|
|
496 |
if( comparison < 0 )
|
|
497 |
{
|
|
498 |
aPlugins->InsertL( i, aPlugin );
|
|
499 |
inserted = ETrue;
|
|
500 |
break;
|
|
501 |
}
|
|
502 |
else if( comparison == 0 )
|
|
503 |
{
|
|
504 |
aPlugins->InsertL( i+1, aPlugin );
|
|
505 |
inserted = ETrue;
|
|
506 |
break;
|
|
507 |
}
|
|
508 |
}
|
|
509 |
// Plugin was not before any other plugin - make sure it's appended
|
|
510 |
if( !inserted )
|
|
511 |
{
|
|
512 |
aPlugins->AppendL( aPlugin );
|
|
513 |
}
|
|
514 |
|
|
515 |
#ifdef _GS_PLUGINLOADER_SORTING_TRACES
|
|
516 |
PrintOrderTraces( aPlugins );
|
|
517 |
#endif // _GS_PLUGINLOADER_SORTING_TRACES
|
|
518 |
|
|
519 |
}
|
|
520 |
|
|
521 |
// ----------------------------------------------------------------------------
|
|
522 |
// CWriterPluginLoader::CompareIndex
|
|
523 |
//
|
|
524 |
//
|
|
525 |
// ----------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
|
|
528 |
TInt CWriterPluginLoader::CompareIndex( const CWriterPluginInterface& aFirst,
|
|
529 |
const CWriterPluginInterface& aSecond )
|
|
530 |
{
|
|
531 |
TInt comparison = KWriterComparisonEqual;
|
|
532 |
// The plugin having index is before the one not having one
|
|
533 |
|
|
534 |
if( aFirst.iOrder == KWriterPluginNotIndexed &&
|
|
535 |
aSecond.iOrder == KWriterPluginNotIndexed )
|
|
536 |
{
|
|
537 |
// Neither have index -> equal
|
|
538 |
comparison = KWriterComparisonEqual;
|
|
539 |
}
|
|
540 |
else if( aFirst.iOrder == KWriterPluginNotIndexed )
|
|
541 |
{
|
|
542 |
// The plugin having index is before the one not having one
|
|
543 |
comparison = KWriterComparisonAfter;
|
|
544 |
}
|
|
545 |
else if( aSecond.iOrder == KWriterPluginNotIndexed )
|
|
546 |
{
|
|
547 |
// The plugin having index is before the one not having one
|
|
548 |
comparison = KWriterComparisonBefore;
|
|
549 |
}
|
|
550 |
else if( aFirst.iOrder < aSecond.iOrder )
|
|
551 |
{
|
|
552 |
// Compare actual index values
|
|
553 |
comparison = KWriterComparisonBefore;
|
|
554 |
}
|
|
555 |
else if( aFirst.iOrder > aSecond.iOrder )
|
|
556 |
{
|
|
557 |
// Compare actual index values
|
|
558 |
comparison = KWriterComparisonAfter;
|
|
559 |
}
|
|
560 |
return comparison;
|
|
561 |
}
|
|
562 |
|
|
563 |
|
62
|
564 |
void CWriterPluginLoader::LoadRlibraryL(CArrayPtrFlat<CWriterPluginInterface>* aPluginArray )
|
|
565 |
{
|
|
566 |
LOGTEXT(_L("CWriterPluginLoader::InitialiseWriterListL BOOT" ));
|
|
567 |
iPluginArray = aPluginArray;
|
|
568 |
|
|
569 |
// Reset iterator:
|
|
570 |
iImplInfoArrayIterator = 0;
|
|
571 |
|
|
572 |
LOGSTRING("CWriterPluginLoader rlibrary loading");
|
|
573 |
// Load dll
|
|
574 |
RLibrary aLib;
|
|
575 |
|
|
576 |
// need to know wether to load diskwriter or debugwriter plugin.
|
|
577 |
// for now, lets just load both.
|
|
578 |
TInt ret = aLib.Load(_L("PIProfilerDiskWriter.dll"),_L("c:\\sys\\bin"));
|
|
579 |
LOGSTRING2("RLibrary diskwriter load returns %d", ret);
|
|
580 |
if(ret != KErrNone)
|
|
581 |
{
|
|
582 |
User::LeaveIfError(ret);
|
|
583 |
}
|
|
584 |
const TInt KNewLOrdinal = 2;
|
|
585 |
TLibraryFunction NewL =aLib.Lookup(KNewLOrdinal);
|
|
586 |
|
|
587 |
if(!NewL)
|
|
588 |
{
|
|
589 |
RDebug::Printf("library.lookup returns null");
|
|
590 |
}
|
|
591 |
else
|
|
592 |
{
|
|
593 |
LOGSTRING2("library.lookup returns 0x%x", NewL);
|
|
594 |
//CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL();
|
|
595 |
CWriterPluginInterface* mydll=(CWriterPluginInterface*)NewL();
|
|
596 |
if (mydll != NULL)
|
|
597 |
{
|
|
598 |
//Generals plugin loaded, samplers enabled.
|
|
599 |
CleanupStack::PushL( mydll );
|
|
600 |
InsertPluginInOrderL( mydll, aPluginArray);
|
|
601 |
CleanupStack::Pop(mydll);
|
|
602 |
}
|
|
603 |
else
|
|
604 |
{
|
|
605 |
RDebug::Printf("mydll was null");
|
|
606 |
}
|
|
607 |
}
|
|
608 |
|
|
609 |
ret = aLib.Load(_L("PIProfilerDebugWriter.dll"),_L("c:\\sys\\bin"));
|
|
610 |
if (ret != KErrNone)
|
|
611 |
{
|
|
612 |
RDebug::Printf("RLibrary debugwriter load returns %d", ret);
|
|
613 |
User::LeaveIfError(ret);
|
|
614 |
}
|
|
615 |
TLibraryFunction DbgNewL =aLib.Lookup(KNewLOrdinal);
|
|
616 |
if(!DbgNewL)
|
|
617 |
{
|
|
618 |
RDebug::Printf("library.lookup returns null");
|
|
619 |
}
|
|
620 |
else
|
|
621 |
{
|
|
622 |
LOGSTRING2("library.lookup returns 0x%x", DbgNewL);
|
|
623 |
//CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL();
|
|
624 |
CWriterPluginInterface* dbgdll=(CWriterPluginInterface*)DbgNewL();
|
|
625 |
if (dbgdll != NULL)
|
|
626 |
{
|
|
627 |
//Generals plugin loaded, samplers enabled.
|
|
628 |
CleanupStack::PushL( dbgdll );
|
|
629 |
InsertPluginInOrderL( dbgdll , aPluginArray);
|
|
630 |
CleanupStack::Pop(dbgdll );
|
|
631 |
}
|
|
632 |
else
|
|
633 |
{
|
|
634 |
RDebug::Printf("dbgdll was NULL");
|
|
635 |
}
|
|
636 |
}
|
|
637 |
|
|
638 |
NotifyProgress();
|
|
639 |
|
|
640 |
//Begin CActive asynchronous loop.
|
|
641 |
CompleteOwnRequest();
|
|
642 |
}
|
|
643 |
|
51
|
644 |
// ----------------------------------------------------------------------------
|
|
645 |
// CWriterPluginLoader::GetDocument
|
|
646 |
//
|
|
647 |
//
|
|
648 |
// ----------------------------------------------------------------------------
|
|
649 |
//
|
|
650 |
/*
|
|
651 |
CWriterBaseDocument* CWriterPluginLoader::GetDocument()
|
|
652 |
{
|
|
653 |
CWriterBaseDocument* document = static_cast<CWriterBaseDocument*>( iAppUi->Document() );
|
|
654 |
return document;
|
|
655 |
}
|
|
656 |
*/
|
|
657 |
|
|
658 |
// End of File
|