idlehomescreen/widgetmanager/inc/wmwidgetloaderao.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 09:29:04 +0300
branchRCL_3
changeset 26 1b758917cafc
parent 12 9674c1a575e9
child 28 d721605b30d0
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies)..
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
* Active object to load widgets into list
*
*/

#ifndef WMWIDGETLOADERAO_H_
#define WMWIDGETLOADERAO_H_

// INCLUDES
#include <e32base.h>

// FORWARD DECLARATIONS
class CWmPlugin;
class CWmListBox;
class CHsContentInfo;
class CWmWidgetData;
class CWmPersistentWidgetOrder;
class RWidgetRegistryClientSession;

// CLASS DECLARATIONS

/**
 * Active object to load widgets into list
 */
NONSHARABLE_CLASS( CWmWidgetLoaderAo ) : public CActive
    {
    
public:
	/**
     * Static constructor
     */
	static CWmWidgetLoaderAo* NewL(
	        CWmPlugin& aWmPlugin,
	        CWmListBox& aTargetList );
	
    /**
     * Destructor.
     */
	~CWmWidgetLoaderAo();

    /**
     * Starts the load process by activating the AO
     */
    void StartLoading();
    
    /**
     * Is loading ongoing.
     */
    TBool IsLoading();

private:
    
    /**
     * Constructor
     */
    CWmWidgetLoaderAo(
            CWmPlugin& aWmPlugin,
            CWmListBox& aTargetList );
    
    /**
     * 2nd phase constructor
     */
    void ConstructL();

protected: // from CActive
    
    /**
    * Handles an active object's request completion event.
    * 
    * @see CActive::RunL
    */
    void RunL();

    /**
     * RunError
     * 
     * @see CActive::RunError
     */
    TInt RunError( TInt aError );
    
    /**
     * Implements cancellation of an outstanding request.
     * 
     * @see CActive::DoCancel
     */
    void DoCancel();

private:

    /**
     * connects to wrt registry
     */
    void OpenSessionL();

    /**
     * disconnects from wrt registry
     */
    void CloseSession();
    
    /**
     * loads widgets into the listbox
     */
    void DoLoadWidgetsL();

    /**
     * finds a widget data entry from iWidgetsList that matches
     * given content info. returns a pointer to the data found,
     * or NULL if not found
     */
    CWmWidgetData* FindWidgetData( CHsContentInfo& aContentInfo );
    
    /**
     * adds a widget data entry to iWidgetsList
     * takes ownership of aContentInfo
     */
    void AddWidgetDataL( CHsContentInfo* aContentInfo, TInt& aCount );
    
    /**
     * cleanup resources allocated runing one single run
     */
    void Cleanup();
    
    /** Converts uid to TUid from TDesC8 */
    TUid UidFromString( const TDesC8& aUidString ) const;
    
private: // data

    /** reference to the widget manager root */
    CWmPlugin& iWmPlugin;

    /** target where widgets are to be loaded */
    CWmListBox& iWidgetsList;
    
    /** widget registry */
    RWidgetRegistryClientSession* iWidgetRegistry;
    
    /** persistent widget order */
    CWmPersistentWidgetOrder* iWidgetOrder;
    
	/** uid of currently unistalled widget */
    TUid iUninstallUid;
    
    /** switch for loading operation */
    TBool iLoading;
    };

#endif // WMWIDGETLOADERAO_H_