perfsrv/piprofiler/engine/src/WriterPluginLoader.cpp
changeset 62 1c2bb2fc7c87
parent 51 98307c651589
equal deleted inserted replaced
56:aa2539c91954 62:1c2bb2fc7c87
    28 // CWriterPluginLoader::NewL
    28 // CWriterPluginLoader::NewL
    29 //
    29 //
    30 // EPOC two-phased constructor
    30 // EPOC two-phased constructor
    31 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    32 //
    32 //
    33 CWriterPluginLoader* CWriterPluginLoader::NewL()
    33 CWriterPluginLoader* CWriterPluginLoader::NewL(TBool aBootMode)
    34     {
    34     {
    35     CWriterPluginLoader* self = new( ELeave ) CWriterPluginLoader;
    35     CWriterPluginLoader* self = new( ELeave ) CWriterPluginLoader(aBootMode);
    36     CleanupStack::PushL( self );
    36     CleanupStack::PushL( self );
    37     self->ConstructL( );
    37     self->ConstructL( );
    38     CleanupStack::Pop( self );
    38     CleanupStack::Pop( self );
    39     return self;
    39     return self;
    40     }
    40     }
    45 //
    45 //
    46 // C++ default constructor can NOT contain any code, that
    46 // C++ default constructor can NOT contain any code, that
    47 // might leave.
    47 // might leave.
    48 // ----------------------------------------------------------------------------
    48 // ----------------------------------------------------------------------------
    49 //
    49 //
    50 CWriterPluginLoader::CWriterPluginLoader() : CActive( EPriorityStandard )
    50 CWriterPluginLoader::CWriterPluginLoader(TBool aBootMode) : 
       
    51         CActive( EPriorityStandard ),
       
    52         iBootMode(aBootMode)
    51     {
    53     {
    52     LOGTEXT(_L("CWriterPluginLoader()::CWriterPluginLoader()" ));
    54     LOGTEXT(_L("CWriterPluginLoader()::CWriterPluginLoader()" ));
    53     }
    55     }
    54 
    56 
    55 
    57 
   132         {
   134         {
   133         const CImplementationInformation* info = iImplInfoArray[ i ];
   135         const CImplementationInformation* info = iImplInfoArray[ i ];
   134         if  ( info->ImplementationUid() == aImplementationUid )
   136         if  ( info->ImplementationUid() == aImplementationUid )
   135             {
   137             {
   136             TRAPD(ret, plugin = &CreatePluginInstanceL( *info ); );
   138             TRAPD(ret, plugin = &CreatePluginInstanceL( *info ); );
   137             if( ret == KErrNone )
   139             if(plugin != NULL)
   138                 {
   140                 {
   139                 // Plugin ownership is transfered to iPluginArray
   141                 if( ret == KErrNone )
   140                 InsertPluginInOrderL( plugin, iPluginArray );
   142                     {
   141                 }
   143                     // Plugin ownership is transfered to iPluginArray
   142             else
   144                     InsertPluginInOrderL( plugin, iPluginArray );
   143                 {
   145                     }
   144                 // Error note is displayed even if plugin is not loaded
   146                 else
   145                 LOGSTRING2("CWriterPluginLoader::LoadSyncL() - plugin load failed, error %d", ret);
   147                     {
       
   148                     // Error note is displayed even if plugin is not loaded
       
   149                     LOGSTRING2("CWriterPluginLoader::LoadSyncL() - plugin load failed, error %d", ret);
       
   150                     }
   146                 }
   151                 }
   147             break;
   152             break;
   148             }
   153             }
   149         }
   154         }
   150 
   155 
   176 // ----------------------------------------------------------------------------
   181 // ----------------------------------------------------------------------------
   177 //
   182 //
   178 void CWriterPluginLoader::RunL()
   183 void CWriterPluginLoader::RunL()
   179     {
   184     {
   180     iRunLDebugCount++;
   185     iRunLDebugCount++;
   181     LoadNextPluginL();
   186     if (iBootMode)
   182 
   187         {
   183     // Check if there are still more plugins to be loaded:
   188         LOGTEXT(_L("CWriterPluginLoader() Rlibrary has been loaded." ));
   184     if ( iImplInfoArrayIterator < iImplInfoArray.Count() )
   189         NotifyFinished();
   185         {
       
   186         NotifyProgress();
       
   187         // Continue CActive asynchronous loop.
       
   188         CompleteOwnRequest();
       
   189         }
   190         }
   190     else
   191     else
   191         {
   192         {
   192         // All plugins loaded:
   193         LoadNextPluginL();
   193         LOGTEXT(_L("CWriterPluginLoader()::Loading plugins finished." ));
   194     
   194         NotifyFinished();
   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             }
   195         }
   208         }
   196     }
   209     }
   197 
   210 
   198 
   211 
   199 // ---------------------------------------------------------------------------
   212 // ---------------------------------------------------------------------------
   546         }
   559         }
   547     return comparison;
   560     return comparison;
   548     }
   561     }
   549 
   562 
   550 
   563 
       
   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 
   551 // ----------------------------------------------------------------------------
   644 // ----------------------------------------------------------------------------
   552 // CWriterPluginLoader::GetDocument
   645 // CWriterPluginLoader::GetDocument
   553 //
   646 //
   554 //
   647 //
   555 // ----------------------------------------------------------------------------
   648 // ----------------------------------------------------------------------------