idlehomescreen/examples/carouselwidgetexample/publisher/inc/carouselpluginengine.h
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
child 103 966d119a7e67
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
     1 /*
       
     2 * Copyright (c) 2009 - 2010 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 #ifndef CMCSPLUGINENGINE_H
       
    20 #define CMCSPLUGINENGINE_H
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 #include <mcsmenu.h>
       
    25 #include <mcsmenuitem.h>
       
    26 #include <mcsmenunotifier.h>
       
    27 #include <msvapi.h>
       
    28 
       
    29 // User includes
       
    30 #include "carouselpluginwatcher.h"
       
    31 
       
    32 // Forward declarations
       
    33 class CGulIcon;
       
    34 class CCarouselPluginData;
       
    35 class CCarouselData;
       
    36 class CCarouselPlugin;
       
    37 
       
    38 
       
    39 /**
       
    40  * @ingroup group_mcsplugin
       
    41  *
       
    42  * MCSPluginEngine class
       
    43  *
       
    44  * @since S60 5.2
       
    45  */
       
    46 NONSHARABLE_CLASS( CCarouselPluginEngine ) : public CBase, 
       
    47     public MCarouselPluginWatcherObserver,
       
    48     public MMsvSessionObserver
       
    49     {
       
    50 public:  
       
    51     // constructor and destructor
       
    52 
       
    53     /**
       
    54     * Part of the two phased constuction
       
    55     *
       
    56     * @param aPlugin
       
    57     * @param aInstanceUid
       
    58     * @return Pointer to the created CMCSPluginEngine object
       
    59     */
       
    60     static CCarouselPluginEngine* NewL( CCarouselPlugin& aPlugin, 
       
    61         const TDesC8& aInstanceUid );
       
    62 
       
    63     /**
       
    64     * Destructor
       
    65     *
       
    66     * @param none
       
    67     * @return none
       
    68     */
       
    69     ~CCarouselPluginEngine();
       
    70 
       
    71 private:
       
    72     // constructors
       
    73     
       
    74     /**
       
    75      * C++ default constructor 
       
    76      */
       
    77     CCarouselPluginEngine( CCarouselPlugin& aPlugin, const TDesC8& aInstanceUid );
       
    78 
       
    79     /*
       
    80      * 2nd phase constructor
       
    81      */
       
    82     void ConstructL();
       
    83     
       
    84 public:
       
    85     // new functions
       
    86     
       
    87     /**
       
    88      * Gets the menu data.
       
    89      * 
       
    90      * @param aIndex
       
    91      * @return TMCSData&
       
    92      */
       
    93     CCarouselData& MenuDataL( const TInt& aIndex );
       
    94 
       
    95     /** Gets the menu item count
       
    96      * 
       
    97      * @return TInt
       
    98      */
       
    99     TInt MenuItemCount();
       
   100 
       
   101     /**
       
   102      * Finds the menu item header for given filter.
       
   103      * 
       
   104      * @param aFilter
       
   105      * @return TMenuItem
       
   106      */
       
   107     TMenuItem FindMenuItemL( CMenuFilter& aFilter );
       
   108 
       
   109     /**
       
   110      * Retrieves the menu item object from MCS.
       
   111      * 
       
   112      * @param aMenuItem
       
   113      * @return CMenuItem*
       
   114      */
       
   115     CMenuItem* FetchMenuItemL( CCarouselData& aData);
       
   116     
       
   117     /**
       
   118      * Returns icon for given menu item and given attribute
       
   119      * 
       
   120      * @param aMenuItem
       
   121      * @param aAttr
       
   122      * @return CGulIcon*
       
   123      */
       
   124     CGulIcon* ItemIconL( CMenuItem* aMenuItem, const TDesC& aAttr );
       
   125 
       
   126     /**
       
   127      * Returns text for given menu item and given attribute
       
   128      * 
       
   129      * @param aMenuItem
       
   130      * @param aAttr
       
   131      */
       
   132     TPtrC ItemTextL( CMenuItem* aMenuItem, const TDesC& aAttr );
       
   133 
       
   134     /** 
       
   135      * Launches menu item
       
   136      * 
       
   137      * @param aIndex
       
   138      */
       
   139     void LaunchItemL( const TInt& aIndex );
       
   140 
       
   141     /**
       
   142     * Set backup/restore state
       
   143     *
       
   144     * @param aBackupRestore ETrue if backup/restore is ongoing 
       
   145     * @return void
       
   146     */
       
   147     void SetBackupRestore( TBool aBackupRestore );
       
   148 
       
   149     /**
       
   150      * ShowSettingsL
       
   151      */
       
   152     void ShowSettingsL();
       
   153 
       
   154 private:
       
   155     // from MMCSPluginWatcherObserver
       
   156     
       
   157     /**
       
   158      * @see MMCSPluginWatcherObserver 
       
   159      */
       
   160     void HandleNotifyL();
       
   161 
       
   162 private:    
       
   163     // from MMsvSessionObserver
       
   164 
       
   165     /**
       
   166      * @see MMsvSessionObserver
       
   167      */    
       
   168     void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1,
       
   169         TAny* aArg2, TAny* aArg3 );
       
   170 
       
   171 private:
       
   172     // new functions
       
   173 
       
   174     /**
       
   175      * InitL
       
   176      */
       
   177     void InitL();
       
   178     
       
   179     /**
       
   180      * Tells the settings container to start observing 
       
   181      * for changes in mailbox db and changes in MCS.
       
   182      */
       
   183     void StartObservingL();
       
   184 
       
   185     /**
       
   186      * Tells the settings container to stop observing 
       
   187      * for changes in mailbox db.     
       
   188      */
       
   189     void StopObserving();
       
   190 
       
   191     /**
       
   192      * ConstructMenuItemForIconL
       
   193      * 
       
   194      * @param aPath
       
   195      * @param aMenuItem
       
   196      * @return TBool
       
   197      */
       
   198     TBool ConstructMenuItemForIconL( 
       
   199         const TDesC& aPath, CMenuItem& aMenuItem );
       
   200 
       
   201     /**
       
   202      * Creates bookmark specific MCS menu item.
       
   203      */
       
   204     CMenuItem* CreateBkmItemL( CCarouselData& aData );
       
   205     
       
   206     /**
       
   207      * Creates mailbox specific MCS menu item.
       
   208      */
       
   209     CMenuItem* CreateMailboxItemL( CCarouselData& aData );
       
   210     
       
   211     void LaunchFolderItemL( CCarouselData& aData );
       
   212     
       
   213     void LaunchBookmarkItemL( CCarouselData& aData );
       
   214     
       
   215     void LaunchMailboxItemL( CCarouselData& aData );
       
   216     
       
   217     void LaunchMCSItemL( CCarouselData& aData );
       
   218 
       
   219 private:
       
   220     // data
       
   221     
       
   222     /** Plugin data, owned */
       
   223     CCarouselPluginData* iPluginData;
       
   224     /** MCS resource handle, owned */
       
   225     RMenu iMenu;
       
   226     /** MCS change notifier handle, owned */
       
   227     RMenuNotifier iNotifier;
       
   228     /** MCS asynchronous operation watcher, owned */
       
   229     CCarouselPluginWatcher* iWatcher;
       
   230     /** MCS change notifier watcher, owned */
       
   231     CCarouselPluginWatcher* iNotifyWatcher;
       
   232     /** MCS plugin, not owned */
       
   233     CCarouselPlugin& iPlugin;
       
   234     /** Reference to plugin owned instanceUid */
       
   235     const TDesC8& iInstanceUid;
       
   236     /** Flag Indicating that backup/restore is in progress */
       
   237     TBool iBackupRestore;
       
   238     /** Offset of resource file */
       
   239     TInt iResourceOffset;
       
   240     /** Message server session, owned */
       
   241     CMsvSession* iMsvSession;        
       
   242     /** "Undefined" menu item, owned */
       
   243     CMenuItem* iUndefinedItem;
       
   244     /** "Undefined" menu item header */
       
   245     TMenuItem iUndefinedItemHeader;    
       
   246     };
       
   247 
       
   248 #endif // CMCSPLUGINENGINE_H
       
   249 
       
   250 // End of file