devicediagnosticsfw/diagframework/inc/diagpluginpoolimpl.h
branchRCL_3
changeset 26 19bba8228ff0
parent 0 b497e44ab2fc
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Manages Diagnostics Plug-in
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DIAGPLUGINPOOLIMPL_H
       
    20 #define DIAGPLUGINPOOLIMPL_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>                    // CActive
       
    24 #include <implementationinformation.h>  // RImplInfoPtrArray
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MDiagPlugin;
       
    28 class MDiagPluginPoolObserver;
       
    29 class CDiagPluginConstructionParam;
       
    30 class MDiagSuitePlugin;   
       
    31 
       
    32 /**
       
    33 *  Diagnostics Framework Plugin Pool Implementation Class
       
    34 *
       
    35 *  This class is used to load Diagnostics ECom plug-ins. It works with both
       
    36 *  Suite Plug-in and Test Plug-in. Once loaded, it will manage the life
       
    37 *  cycle of the plug-ins.
       
    38 *
       
    39 *  All loaded plug-ins will be destroyed when pool is deleted.
       
    40 *
       
    41 *  @since S60 v5.0
       
    42 */
       
    43 NONSHARABLE_CLASS( CDiagPluginPoolImpl ) : public CActive
       
    44     {
       
    45 public:
       
    46 
       
    47     /**
       
    48     * Two-phased constructors
       
    49     *
       
    50     * @param aObserver     Plug-in Pool observer.
       
    51     * @return New instance of CDiagPluginPool
       
    52     */
       
    53     static CDiagPluginPoolImpl* NewL( MDiagPluginPoolObserver& aObserver );
       
    54     static CDiagPluginPoolImpl* NewLC( MDiagPluginPoolObserver& aObserver );
       
    55 
       
    56     /**
       
    57     * Destructor
       
    58     *
       
    59     */
       
    60     virtual ~CDiagPluginPoolImpl();
       
    61 
       
    62 public:     // new API
       
    63 
       
    64     /**
       
    65     * Loads all plug-ins. Progress is notified via MDiagPluginPoolObserver.
       
    66     * Leave codes:     KErrNone        - Success.
       
    67     *                  KErrNotFound    - No plugins
       
    68     *                  KErrAlreadyExists    - Plug-ins have already been loaded.
       
    69     */
       
    70     void LoadAsyncL();
       
    71     
       
    72     /**
       
    73     * Create an instance of a plug-in. It can be a test plug-in or suite plug-in.
       
    74     * If this is a suite, it will not have its children associated with it since
       
    75     * will require children to be loaded as well.
       
    76     *
       
    77     * Plug-ins created using this method is not part of plug-in pool. Therefore
       
    78     * client must manage the life cycle of the plug-in.
       
    79     * 
       
    80     * @param aUid - Implementation Uid of plug-in. 
       
    81     * @return Newly instantiated plug-in. Ownership is transferred to caller.
       
    82     */
       
    83     static MDiagPlugin* CreatePluginL( const TUid aUid );
       
    84 
       
    85     /**
       
    86     * Find Plug-in that matches given Uid.
       
    87     *
       
    88     * @param aUid      Uid of plug-in to search.
       
    89     * @param aPlugin   Reference to Plugin found. Engine owns this plug-in.
       
    90     *                  Client must not deallocate plug-in.
       
    91     * @return TInt     KErrNone        - Success.
       
    92     *                  KErrNotFound    - Not found.
       
    93     *                  KErrNotReady    - Plug-ins are not yet loaded.
       
    94     */
       
    95     TInt FindPlugin( TUid aUid, MDiagPlugin*& aPlugin ) const;
       
    96 
       
    97     /**
       
    98     * Find Plug-in that matches given service name.
       
    99     *
       
   100     * @param aServiceName  Service name of the plug-in. Name must match exactly.
       
   101     * @param aPlugin       Reference to Plugin found. Engine owns this plug-in.
       
   102     *                      Client must not deallocate plug-in.
       
   103     * @return TInt         KErrNone        - Success.
       
   104     *                      KErrNotFound    - Not found.
       
   105     *                      KErrNotReady    - Plug-ins are not yet loaded.
       
   106     */
       
   107     TInt FindPlugin( const TDesC& aServiceName, 
       
   108                              MDiagPlugin*& aPlugin ) const;      
       
   109 
       
   110 
       
   111 private:    // internal types                                   
       
   112     typedef RPointerArray<CDiagPluginConstructionParam> RConstructionParamArray;        
       
   113                              
       
   114 private:    // private constructors
       
   115     
       
   116     /**
       
   117     * Construct a CDiagPluginPoolImpl object
       
   118     *
       
   119     * @param aObserver  The observer which listens to plug-in pool events
       
   120     */
       
   121     CDiagPluginPoolImpl( MDiagPluginPoolObserver& aObserver );
       
   122     
       
   123     /**
       
   124     * 2nd phase constructor
       
   125     *
       
   126     */    
       
   127     void ConstructL();  
       
   128 
       
   129 
       
   130 private: // internal API
       
   131 
       
   132     /**
       
   133     * Obtain the list construction paramaters to construct a plug-in
       
   134     *    
       
   135     * @return Pointer to construction paramaters pointer array
       
   136     */    
       
   137     static RConstructionParamArray* GeneratePluginListL();
       
   138     
       
   139     /**
       
   140     * Generate parmaters to construct a plug-in given the ECOM implementation
       
   141     * info structure
       
   142     *
       
   143     * @param aInfo  Pointer to the implementation info structure
       
   144     * @return Pointer to newly generated construction params
       
   145     */
       
   146     
       
   147     static CDiagPluginConstructionParam* GenerateConstructionParamsLC(
       
   148             const CImplementationInformation* aInfo );
       
   149             
       
   150     /**
       
   151     * Create a plug-in from given construction data
       
   152     *
       
   153     * @param aInfo  Pointer to the implementation info structure
       
   154     * @return Pointer to the newly created plug-in
       
   155     */
       
   156     static MDiagPlugin* CreatePluginFromConstructionParamsL(
       
   157             const CDiagPluginConstructionParam* aParams );                       
       
   158 
       
   159     /**
       
   160     * Setup active object for next iteration of plug-in loading
       
   161     *    
       
   162     */
       
   163     void SetNextIteration();
       
   164     
       
   165     /**
       
   166     * Load the next plug-in in the list per built in iterator
       
   167     *    
       
   168     */
       
   169     void LoadNextPluginL();
       
   170     
       
   171     /**
       
   172     * Add plug-in to plug-in pool by inserting into the plug-in tree.
       
   173     * Plug-in ownership is transferred to the Plug-in Pool if it is
       
   174     * supported.  If the plug-in is not supported, it is deleted.
       
   175     *
       
   176     * @param aPlugin pointer to the new plug-in to be added
       
   177     * @return TUid UID of the plug-in to report back to the application.
       
   178     * Set to TUid::Null() if the plug-in was not added to the pool.
       
   179     */
       
   180     TUid AddPluginToPoolLD( MDiagPlugin* aPlugin );
       
   181     
       
   182     /**
       
   183     * Destroy implementation info regarding ECOM plug-ins
       
   184     *    
       
   185     */
       
   186     void DestroyConstructionParams();            
       
   187 
       
   188     /**
       
   189     * Call when a plug-in is loaded to add a newly loaded plug-in to a currently 
       
   190     * loaded suite (if available)
       
   191     * no ownership transfer
       
   192     *
       
   193     * @param aPluginSuite pointer to the new plug-in to be added
       
   194     */
       
   195     void AddNewPluginToSuiteL(MDiagPlugin* aPlugin);
       
   196     
       
   197     /**
       
   198     * Call when a suite is loaded to add any existing parentless plug-ins with
       
   199     * matching parent UID to suite
       
   200     * no ownership transfer
       
   201     *
       
   202     * @param aPluginSuite pointer to the new suite to be added
       
   203     */
       
   204     void AddPluginsToNewSuiteL(MDiagSuitePlugin* aPluginSuite);
       
   205     
       
   206     /**
       
   207     * Resets all member data and notifies observer that load is copmlete
       
   208     *
       
   209     * @param aErrorCode Plug-In load error
       
   210     * @return LoadCompletedL error, if any
       
   211     */
       
   212     TInt ResetAndNotify(TInt aErrorCode);
       
   213 
       
   214 
       
   215 private: // From CActive
       
   216 
       
   217     /**
       
   218     * @see CActive::RunL
       
   219     */
       
   220     virtual void RunL();
       
   221 
       
   222     /**
       
   223     * @see CActive::DoCancel
       
   224     */
       
   225     virtual void DoCancel();
       
   226 
       
   227     /**
       
   228     * @see CActive::RunError
       
   229     */
       
   230     virtual TInt RunError( TInt aError );
       
   231 
       
   232 private:    //  member data
       
   233 
       
   234     MDiagPluginPoolObserver& iObserver;
       
   235             
       
   236     // List of plug-ins that have been loaded
       
   237     RPointerArray<MDiagPlugin> iPlugins;        
       
   238     
       
   239     // Array of plug-in construction params        
       
   240     // owned
       
   241     RConstructionParamArray* iConstructionParamArray;
       
   242     
       
   243     // Indicates that all plug-ins have been loaded
       
   244     TBool iPluginsLoaded;
       
   245     
       
   246     // Indicates that plug-ins are currently loading
       
   247     TBool iPluginsLoading;
       
   248             
       
   249     // Index of current plug-in for plug-in load iteration
       
   250     TInt iCurrentPluginIndex;            
       
   251     
       
   252     // Holds error code for first error found in loading process
       
   253     TInt iErrorCode;
       
   254     
       
   255     // Total number of plug-ins found
       
   256     TInt iTotalPluginsFound;
       
   257     };
       
   258     
       
   259 #endif // DIAGPLUGINPOOLIMPL_H
       
   260 
       
   261 // End of File
       
   262