idlehomescreen/widgetmanager/inc/wmwidgetloaderao.h
branchRCL_3
changeset 83 5456b4e8b3a8
equal deleted inserted replaced
82:5f0182e07bfb 83:5456b4e8b3a8
       
     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 * Active object to load widgets into list
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef WMWIDGETLOADERAO_H_
       
    20 #define WMWIDGETLOADERAO_H_
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CWmPlugin;
       
    27 class CWmListBox;
       
    28 class CHsContentInfo;
       
    29 class CWmWidgetData;
       
    30 class CWmPersistentWidgetOrder;
       
    31 class RWidgetRegistryClientSession;
       
    32 
       
    33 // CLASS DECLARATIONS
       
    34 
       
    35 class MWmWidgetloaderObserver
       
    36     {
       
    37 public:
       
    38     /**
       
    39      * Notifies client when widget list is succesfully loaded
       
    40      *
       
    41      * @param aWidgetListChanged true if widget list changed
       
    42      */
       
    43     virtual void LoadDoneL( TBool aWidgetListChanged ) = 0;
       
    44     };
       
    45     
       
    46 /**
       
    47  * Active object to load widgets into list
       
    48  */
       
    49 NONSHARABLE_CLASS( CWmWidgetLoaderAo ) : public CActive
       
    50     {
       
    51     
       
    52 public:
       
    53     /**
       
    54      * Static constructor
       
    55      */
       
    56     static CWmWidgetLoaderAo* NewL(
       
    57             CWmPlugin& aWmPlugin,
       
    58             CWmListBox& aTargetList );
       
    59     
       
    60     /**
       
    61      * Destructor.
       
    62      */
       
    63     ~CWmWidgetLoaderAo();
       
    64 
       
    65     /**
       
    66      * Starts the load process by activating the AO
       
    67      */
       
    68     void StartLoading();
       
    69     
       
    70     /**
       
    71      * Is loading ongoing.
       
    72      */
       
    73     TBool IsLoading();
       
    74 
       
    75     /**
       
    76      * Set MWmWidgetloaderObserver observer
       
    77       */
       
    78     void SetObserver( MWmWidgetloaderObserver* aObserver );
       
    79 private:
       
    80     
       
    81     /**
       
    82      * Constructor
       
    83      */
       
    84     CWmWidgetLoaderAo(
       
    85             CWmPlugin& aWmPlugin,
       
    86             CWmListBox& aTargetList );
       
    87     
       
    88     /**
       
    89      * 2nd phase constructor
       
    90      */
       
    91     void ConstructL();
       
    92 
       
    93 protected: // from CActive
       
    94     
       
    95     /**
       
    96     * Handles an active object's request completion event.
       
    97     * 
       
    98     * @see CActive::RunL
       
    99     */
       
   100     void RunL();
       
   101 
       
   102     /**
       
   103      * RunError
       
   104      * 
       
   105      * @see CActive::RunError
       
   106      */
       
   107     TInt RunError( TInt aError );
       
   108     
       
   109     /**
       
   110      * Implements cancellation of an outstanding request.
       
   111      * 
       
   112      * @see CActive::DoCancel
       
   113      */
       
   114     void DoCancel();
       
   115 
       
   116 private:
       
   117 
       
   118     /**
       
   119      * connects to wrt registry
       
   120      */
       
   121     void OpenSessionL();
       
   122 
       
   123     /**
       
   124      * disconnects from wrt registry
       
   125      */
       
   126     void CloseSession();
       
   127     
       
   128     /**
       
   129      * loads widgets into the listbox
       
   130      */
       
   131     void DoLoadWidgetsL();
       
   132 
       
   133     /**
       
   134      * finds a widget data entry from iWidgetsList that matches
       
   135      * given content info. returns a pointer to the data found,
       
   136      * or NULL if not found
       
   137      */
       
   138     CWmWidgetData* FindWidgetData( CHsContentInfo& aContentInfo );
       
   139     
       
   140     /**
       
   141      * adds a widget data entry to iWidgetsList
       
   142      * takes ownership of aContentInfo
       
   143      */
       
   144     void AddWidgetDataL( CHsContentInfo* aContentInfo, TInt& aCount );
       
   145     
       
   146     /**
       
   147      * cleanup resources allocated runing one single run
       
   148      */
       
   149     void Cleanup();
       
   150     
       
   151     /** Converts uid to TUid from TDesC8 */
       
   152     TUid UidFromString( const TDesC8& aUidString ) const;
       
   153     
       
   154 private: // data
       
   155 
       
   156     /** reference to the widget manager root */
       
   157     CWmPlugin& iWmPlugin;
       
   158 
       
   159     /** target where widgets are to be loaded */
       
   160     CWmListBox& iWidgetsList;
       
   161     
       
   162     /** widget registry */
       
   163     RWidgetRegistryClientSession* iWidgetRegistry;
       
   164     
       
   165     /** persistent widget order */
       
   166     CWmPersistentWidgetOrder* iWidgetOrder;
       
   167     
       
   168     /** uid of currently unistalled widget */
       
   169     TUid iUninstallUid;
       
   170     
       
   171     /** switch for loading operation */
       
   172     TBool iLoading;
       
   173     
       
   174     /** Notifies client when widget list is fully loaded */
       
   175     MWmWidgetloaderObserver* iObserver;
       
   176     
       
   177     /** tells if widgetlist has changed */
       
   178     TBool iWidgetListChanged;
       
   179     };
       
   180 
       
   181 #endif // WMWIDGETLOADERAO_H_