idlefw/plugins/mcsplugin/publisher/inc/mcspluginengine.h
changeset 0 79c6a41cd166
child 1 844b978f8d5e
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMCSPLUGINENGINE_H
       
    20 #define CMCSPLUGINENGINE_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <e32base.h>
       
    24 #include <mcsmenu.h>
       
    25 #include <mcsmenunotifier.h>
       
    26 #include <FavouritesDbObserver.h>   // For MFavouritesDbObserver
       
    27 #include <FavouritesDb.h>           // For RFavouritesDb
       
    28 #include <msvapi.h>                 // For MMsvSessionObserver
       
    29 
       
    30 #include "mcspluginwatcher.h"
       
    31 
       
    32 class CGulIcon;
       
    33 class CMCSPluginData;
       
    34 class TMCSData;
       
    35 class CMCSPlugin;
       
    36 class CActiveFavouritesDbNotifier;
       
    37 
       
    38 /**
       
    39  *  @ingroup group_mcsplugin
       
    40  *
       
    41  *  MCSPluginEngine class
       
    42  *
       
    43  *  @since S60 9.1
       
    44  */
       
    45 class CMCSPluginEngine : public CBase, public MMCSPluginWatcherObserver,
       
    46     public MFavouritesDbObserver, public MMsvSessionObserver
       
    47 {
       
    48 
       
    49 public:  // Constructors and destructor
       
    50 
       
    51     /**
       
    52      * Constructor to use in the object creation. Initializes the necessary 
       
    53      * data.
       
    54      *
       
    55      * @param aPlugin
       
    56      * @param aInstanceUid
       
    57      */
       
    58     CMCSPluginEngine( CMCSPlugin& aPlugin, const TDesC8& aInstanceUid );
       
    59 
       
    60     /**
       
    61     * Part of the two phased constuction
       
    62     *
       
    63     * @param aPlugin
       
    64     * @param aInstanceUid
       
    65     * @return Pointer to the created CMCSPluginEngine object
       
    66     */
       
    67     static CMCSPluginEngine* NewL( CMCSPlugin& aPlugin, 
       
    68         const TDesC8& aInstanceUid );
       
    69 
       
    70     /**
       
    71     * Destructor
       
    72     *
       
    73     * @param none
       
    74     * @return none
       
    75     */
       
    76     ~CMCSPluginEngine();
       
    77 
       
    78     /**
       
    79      * Gets the menu data.
       
    80      * 
       
    81      * @param aIndex
       
    82      * @return TMCSData&
       
    83      */
       
    84     TMCSData& MenuDataL( const TInt& aIndex );
       
    85 
       
    86     /** Gets the menu item count
       
    87      * 
       
    88      * @return TInt
       
    89      */
       
    90     TInt MenuItemCount();
       
    91 
       
    92     /**
       
    93      * Finds the menu item header for given filter.
       
    94      * 
       
    95      * @param aFilter
       
    96      * @return TMenuItem
       
    97      */
       
    98     TMenuItem FindMenuItemL( CMenuFilter& aFilter );
       
    99 
       
   100     /**
       
   101      * Retrieves the menu item object from MCS.
       
   102      * 
       
   103      * @param aMenuItem
       
   104      * @return CMenuItem*
       
   105      */
       
   106     CMenuItem* FetchMenuItemL( const TMenuItem& aMenuItem );
       
   107 
       
   108     /**
       
   109      * Returns icon for given menu item and given attribute
       
   110      * 
       
   111      * @param aMenuItem
       
   112      * @param aAttr
       
   113      * @return CGulIcon*
       
   114      */
       
   115     CGulIcon* ItemIconL( CMenuItem& aMenuItem, const TDesC& aAttr );
       
   116 
       
   117     /**
       
   118      * Returns text for given menu item and given attribute
       
   119      * 
       
   120      * @param aMenuItem
       
   121      * @param aAttr
       
   122      */
       
   123     TPtrC ItemTextL( CMenuItem& aMenuItem, const TDesC& aAttr );
       
   124 
       
   125     /** 
       
   126      * Launches menu item
       
   127      * 
       
   128      * @param aIndex
       
   129      */
       
   130     void LaunchItemL( const TInt& aIndex );
       
   131 
       
   132     /**
       
   133     * Resumes the engine
       
   134     *
       
   135     * @param void
       
   136     * @return void
       
   137     */
       
   138     void ResumeL();
       
   139 
       
   140     /**
       
   141     * Suspends the engine
       
   142     *
       
   143     * @param void
       
   144     * @return void
       
   145     */
       
   146     void Suspend();
       
   147 
       
   148     /**
       
   149      * ShowSettingsL
       
   150      */
       
   151     void ShowSettingsL();
       
   152 
       
   153     /**
       
   154      * From MMCSPluginWatcherObserver
       
   155      */
       
   156     void HandleNotifyL();
       
   157 
       
   158     // From MFavouritesDbObserver
       
   159     /**
       
   160      * Handles database event.
       
   161      * @param aEvent Database event.
       
   162      */
       
   163     void HandleFavouritesDbEventL( RDbNotifier::TEvent aEvent );
       
   164 
       
   165     // from base class MMsvSessionObserver
       
   166     /**
       
   167      * Handles an event from the message server.
       
   168      * Not used, but must be defined to be able to use the messaging server.
       
   169      *
       
   170      * @since S60 v3.2
       
   171      * @param aEvent Indicates the event type.
       
   172      * @param aArg1 Event type-specific argument value
       
   173      * @param aArg2 Event type-specific argument value
       
   174      * @param aArg3 Event type-specific argument value
       
   175      */
       
   176     void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1,
       
   177         TAny* aArg2, TAny* aArg3 );
       
   178 
       
   179     /**
       
   180     * Called during plugin desctruction
       
   181     * Decrements reference counters of all run-time generated items
       
   182     * and deletes those which have reference counter == 0
       
   183     */
       
   184     void CleanMCSItemsL();
       
   185 
       
   186 private:
       
   187     /*
       
   188      * Part of the two phased construction
       
   189      */
       
   190     void ConstructL();
       
   191 
       
   192     /**
       
   193      * InitL
       
   194      */
       
   195     void InitL();
       
   196 
       
   197     /**
       
   198      * Tells the settings container to start observing for changes in favorites
       
   199      * database and mailbox db.
       
   200      *
       
   201      */
       
   202     void StartObservingL();
       
   203 
       
   204     /**
       
   205      * Tells the settings container to stop observing for changes in favorites
       
   206      * database and mailbox db.
       
   207      *
       
   208      */
       
   209     void StopObserving();
       
   210 
       
   211     /**
       
   212      * ConstructMenuItemForIconL
       
   213      * 
       
   214      * @param aPath
       
   215      * @param aMenuItem
       
   216      * @return TBool
       
   217      */
       
   218     TBool ConstructMenuItemForIconL( const TDesC& aPath, CMenuItem& aMenuItem );
       
   219 
       
   220     /**
       
   221     * Helper method. Adds a given constant to a value of reference counter
       
   222     *
       
   223     * @param aItem A Menu Item to update
       
   224     * @param aValueToAdd A constant to add 
       
   225     * @return The actual value of updated reference count
       
   226     */
       
   227     TInt UpdateMenuItemsRefCountL( CMenuItem* aItem, const TInt aValueToAdd );
       
   228 
       
   229 protected:
       
   230 
       
   231 private:
       
   232 
       
   233     /* Plugin data
       
   234     * Own
       
   235     */
       
   236     CMCSPluginData* iPluginData;
       
   237 
       
   238     // MCS resource
       
   239     RMenu iMenu;
       
   240 
       
   241     // MCS change notifier
       
   242     RMenuNotifier iNotifier;
       
   243 
       
   244     // MCS asynchronous operation watcher
       
   245     CMCSPluginWatcher* iWatcher;
       
   246 
       
   247     // MCS change notifier watcher
       
   248     CMCSPluginWatcher* iNotifyWatcher;
       
   249 
       
   250     //
       
   251     CMCSPlugin& iPlugin;
       
   252 
       
   253     // Reference to plugin owned instanceUid
       
   254     const TDesC8& iInstanceUid;
       
   255     // Indicating that backup is in progress
       
   256     TBool iSuspend;
       
   257     //Offset of resource file.
       
   258     TInt iResourceOffset;
       
   259 
       
   260     /**
       
   261      * Bookmark database change observer.
       
   262      * Own.
       
   263      */
       
   264     CActiveFavouritesDbNotifier* iBookmarkDbObserver;
       
   265 
       
   266     /**
       
   267      * Bookmark database.
       
   268      */
       
   269     RFavouritesDb iBookmarkDb;
       
   270 
       
   271     /**
       
   272      * Bookmark database session.
       
   273      */
       
   274     RFavouritesSession iBookmarkSession;
       
   275 
       
   276     /**
       
   277      * Message server session
       
   278      * Own.
       
   279      */
       
   280     CMsvSession* iMsvSession;
       
   281 };
       
   282 
       
   283 #endif // CMCSPLUGINENGINE_H
       
   284 
       
   285