menucontentsrv/srvinc/mcsrunningappshandler.h
changeset 0 79c6a41cd166
child 22 1b207dd38b72
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 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:  This class maintains a list of the running apps, and listen 
       
    15 *  for changes in the running apps. It calls the observer if there is such a 
       
    16 *  change.
       
    17 *
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef __MCSRUNNINGAPPSHANDLER_H__
       
    23 #define __MCSRUNNINGAPPSHANDLER_H__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <e32property.h>
       
    27 #include <w32std.h>
       
    28 
       
    29 #include "menuengoperation.h"
       
    30 #include "menusrvengutils.h"
       
    31 
       
    32 //Forward declatations
       
    33 class CMenuEng;
       
    34 class CMcsCacheHandler;
       
    35 class CMcsRunningAppsWgMonitor;
       
    36 class CMcsRunningAppsFswMonitor;
       
    37 class CMcsRunningAppsHiddenAttrScanner;
       
    38 class CMcsRunningAppsAddRemoveHandler;
       
    39 
       
    40 /**
       
    41  * Interface for updating RunningApps list stored in CMcsRunningAppsHandler class
       
    42  *
       
    43  * @since S60 v3.2
       
    44  */
       
    45 class MMcsRunningAppsHandler
       
    46     {
       
    47 public:
       
    48 	enum TArrayDataType
       
    49     	{
       
    50     	ERunningApps,
       
    51     	EFswHiddenApps,
       
    52     	EHiddenApps
       
    53     	};
       
    54     /*
       
    55 	 * Called by HiddenAttr scanner, FSW monitor or WindowsGroup 
       
    56 	 * Monitor.
       
    57      * @param aArray an array containing UIDs of running, hidden or
       
    58      * 	fsw apps  
       
    59      * @param aType type of data stored in aArray   
       
    60 	 */
       
    61     virtual void HandleListUpdateL(const RArray<TUid>& aArray, 
       
    62     		TArrayDataType aType ) = 0;
       
    63     
       
    64 	/*
       
    65 	 * Called by AddRemoveHandler
       
    66 	 * @param aFolder id of folder for which the method was invoked
       
    67 	 */
       
    68     virtual void HandleAddRemoveRunningAppL( TInt aFolder ) = 0;
       
    69     
       
    70     };
       
    71 
       
    72 /*
       
    73  *  RunningApps Handler.
       
    74  *  @lib mcsmenu.lib
       
    75  *  @since S60 v5.0
       
    76  */
       
    77 NONSHARABLE_CLASS( CMcsRunningAppsHandler ): public CBase, MMcsRunningAppsHandler
       
    78     {
       
    79     public:
       
    80 
       
    81 	/**
       
    82 	*   Factory method.
       
    83 	*/
       
    84     static CMcsRunningAppsHandler* NewL( 
       
    85 		CMenuEng& aEng,
       
    86     	CMcsCacheHandler& aCacheHandler );
       
    87 
       
    88     /**
       
    89     *   Destructor.
       
    90     */
       
    91     ~CMcsRunningAppsHandler();
       
    92     
       
    93     /**
       
    94      * Called by EngineEvents method
       
    95      * @param aFolder folder id
       
    96      * @param aEvents events
       
    97      */
       
    98     void EngineEventsL( TInt aFolder, TInt aEvents );
       
    99 
       
   100     /**
       
   101      * Called by CMenuSrvEng class object
       
   102      * @param aFolder folder id
       
   103      * @param aEvents events
       
   104      */
       
   105     void EngineEvents( TInt aFolder, TInt aEvents );
       
   106     
       
   107     /**
       
   108      * Fills aArray with UIDs of running apps
       
   109      * @param aArray array to be filled with UIDs of running apps
       
   110      */
       
   111     void GetRunningAppsL( RArray<TUid>& aArray );
       
   112 
       
   113     /**
       
   114      * Returns running status of an item
       
   115      * @param aItemId id of the item
       
   116      * @return running status of an item
       
   117      */    
       
   118     TBool GetRunningStatusL( TInt aItemId );
       
   119 
       
   120     
       
   121 // from MMcsRunningAppsHandler
       
   122     
       
   123     /*
       
   124 	 * Called by HiddenAttr scanner, FSW monitor or WindowsGroup 
       
   125 	 * Monitor.
       
   126      * @param aArray an array containing UIDs of running, hidden or
       
   127      * 	fsw apps  
       
   128      * @param aType type of data stored in aArray   
       
   129 	 */
       
   130     void HandleListUpdateL(const RArray<TUid>& aArray, TArrayDataType aType );
       
   131 
       
   132 	/*
       
   133 	 * Called by AddRemoveHandler
       
   134 	 * @param id of folder for which the method was invoked
       
   135 	 */
       
   136 	void HandleAddRemoveRunningAppL( TInt aFolder );    
       
   137 
       
   138 private:
       
   139 	/**
       
   140 	*   Constructor.
       
   141 	*/
       
   142 	CMcsRunningAppsHandler( 
       
   143 		CMenuEng& aEng, 
       
   144 	    CMcsCacheHandler& aCacheHandler );
       
   145 
       
   146 	/**
       
   147 	 * 2nd phase constructor
       
   148 	 */
       
   149 	void ConstructL();
       
   150 
       
   151     /**
       
   152     * Called by HandleListUpdateL
       
   153     * @param aArray array with UIDs of running apps
       
   154     */
       
   155 	void HandleRunningAppsChangedL( const RArray<TUid>& aArray );
       
   156 
       
   157     /**
       
   158     * Called by HandleListUpdateL
       
   159     * @param aArray array with UIDs of FSW hidden apps
       
   160     */
       
   161 	void HandleFswHiddenAppsChangedL( const RArray<TUid>& aArray );
       
   162 
       
   163     /**
       
   164     * Called by HandleListUpdateL
       
   165     * @param aArray array with UIDs of hidden apps
       
   166     */
       
   167 	void HandleHiddenAppsChangedL(const RArray<TUid>& aArray );
       
   168 	
       
   169 	/**
       
   170 	 * Sends AttributeChange notification for item and parents of the item
       
   171 	 * it it is necessary, it is also responsible for removing data from cache
       
   172 	 * if attribute value cahnged
       
   173 	 * @param aId id of item with changed running status attribute
       
   174 	 */
       
   175 	void HandleNotificationL( TInt aId );
       
   176 
       
   177 	/**
       
   178 	 * Sends AttributeChange notification for items and parents of items with
       
   179 	 * given uid, it is also responsible for removing data from cache
       
   180 	 * if attribute value has changed
       
   181 	 * @param aAppUid uid of items with changed running status attribute
       
   182 	 */
       
   183 	void HandleNotificationL( TUid aAppUid );
       
   184 	
       
   185 	/**
       
   186 	 * Gets list of items with secified uid
       
   187 	 * @param aAppUid items uid
       
   188 	 * @return KErrNotFound if no item was found KErrNone if succesfull
       
   189 	 */
       
   190 	TInt GetItemsListL( TUid aAppUid, RArray<TMenuItem>& aItemArray );
       
   191 
       
   192 	/*
       
   193 	 * Updates array containing folders with running status
       
   194 	 * @param aFolderId id of a folder
       
   195 	 * @param aNewRunningStatus current running status
       
   196 	 */
       
   197 	void UpdateFolderRunningStatusL( TInt aFolderId, TBool aNewRunningStatus );
       
   198 
       
   199 	
       
   200 	/**
       
   201 	 * Updates array containing folders with running status.
       
   202 	 * It is called at startup and it scans all folders
       
   203 	 */
       
   204 	void UpdateFoldersRunningStatusL( );
       
   205 	
       
   206 	/**
       
   207 	 * Gets running status for CMenuEngObject
       
   208 	 * @param aEngObj object to be checked
       
   209 	 * @return running status of an object
       
   210 	 */
       
   211 	TBool GetRunningStatusL( const CMenuEngObject& aEngObj );
       
   212 
       
   213 	/**
       
   214 	 * Gets previous Folder running status
       
   215 	 * @param aId id of the folder
       
   216 	 * @return previous running status of a folder (stored in 
       
   217 	 * 	iRunningFolderStatus array )
       
   218 	 */
       
   219 	TBool GetFolderPreviousRunningStatusL( TInt aId );
       
   220 
       
   221 	
       
   222 	/**
       
   223 	 * Gets current folder running status
       
   224 	 * @param aId id of the folder
       
   225 	 * @return running status of a folder
       
   226 	 */
       
   227 	TBool GetFolderRunningStatusL( TInt aId );
       
   228 	
       
   229 	/**
       
   230 	 * Gets current application running status
       
   231 	 * @param aUid UID of an application
       
   232 	 * @return running status of an application
       
   233 	 */
       
   234 	TBool GetAppRunningStatusL( TUid aUid );
       
   235 
       
   236 private:    
       
   237 
       
   238     CMenuEng& iEng ; ///< Engine. not own
       
   239 
       
   240     /** not own
       
   241     */
       
   242     CMcsCacheHandler& iCacheHandler;
       
   243     
       
   244     /*
       
   245     * own
       
   246     */
       
   247     CMcsRunningAppsWgMonitor* iWindowGroupMonitor;
       
   248 
       
   249     /*
       
   250     * own
       
   251     */
       
   252     CMcsRunningAppsFswMonitor* iFswMonitor;
       
   253     
       
   254     /*
       
   255      * own
       
   256      */
       
   257     CMcsRunningAppsHiddenAttrScanner* iHiddenAttrScanner;    
       
   258     
       
   259     /*
       
   260      * own 
       
   261      */
       
   262     CMcsRunningAppsAddRemoveHandler* iAddRemoveHandler;
       
   263     
       
   264     /*
       
   265     * own
       
   266     */
       
   267     RArray<TRunningAppsAttr> iRunningApps;
       
   268     
       
   269     /*
       
   270     * own
       
   271     */
       
   272     RArray<TInt> iRunningFolderStatus;
       
   273     };
       
   274 	
       
   275 #endif // __MCSRUNNINGAPPSHANDLER_H__