locationtriggering/ltserver/ltserverlogic/inc/lbtappchangehandler.h
changeset 56 4e949f03ecc5
equal deleted inserted replaced
-1:000000000000 56:4e949f03ecc5
       
     1 /*
       
     2 * Copyright (c) 2006 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 header file describes the class reposnible for handling
       
    15 *              : removal of applications
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_LBTAPPCHANGEHANDLER_H
       
    21 #define C_LBTAPPCHANGEHANDLER_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <apgnotif.h>
       
    25 #include "lbttriggerchangeobserver.h"
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 class TApaAppInfo;
       
    29 class RApaLsSession;
       
    30 class CApaAppListNotifier;
       
    31 class CLbtContainer;
       
    32 class CLbtContainerTriggerEntry;
       
    33 class CLbtCleanupHandler;
       
    34 class MLbtServerLogicTriggerChangeObserver;
       
    35 struct TLbtAppInfo;
       
    36 
       
    37 /**
       
    38  *
       
    39  */
       
    40 class CLbtAppChangeHandler : public CActive,
       
    41 							 public MApaAppListServObserver,
       
    42 							 public MLbtContainerChangeEventObserver
       
    43 							 
       
    44 	{	
       
    45 	public:
       
    46 		/**
       
    47 	     * Constructs a new instance of App Change handler.
       
    48 	     *
       
    49 	     * @return The new instance of App Change handler object.
       
    50 	     */
       
    51 		static CLbtAppChangeHandler* NewL(CLbtContainer& aContainer, CLbtCleanupHandler& iCleanupHandler,
       
    52 		                                  MLbtServerLogicTriggerChangeObserver& aTriggerChangeObserver);		
       
    53 		
       
    54 		/**
       
    55 	     * Destructor.
       
    56 	     */
       
    57 		~CLbtAppChangeHandler();
       
    58 		
       
    59 		/**
       
    60 		 * Start listening to application un-installation events
       
    61 		 *
       
    62 		 */
       
    63 		void StartListeningL();
       
    64 		
       
    65 		/**
       
    66 		 * Stops listening to application un-installation events
       
    67 		 *
       
    68 		 */
       
    69 		void StopListening();
       
    70 		
       
    71 	private: // New functions
       
    72 		/**
       
    73 	     * C++ constructor
       
    74 	     */
       
    75 		CLbtAppChangeHandler(CLbtContainer& aContainer, CLbtCleanupHandler& iCleanupHandler,
       
    76 		                     MLbtServerLogicTriggerChangeObserver& aTriggerChangeObserver);
       
    77 		
       
    78 		/**
       
    79 	     * Symbian 2nd phase of construction
       
    80 	     */
       
    81 		void ConstructL();
       
    82 		
       
    83 		/**
       
    84 		 * Handles removal of an application that resided on the MMC. The function 
       
    85 		 * checks if same MMC card is still inserted. If it still inserted it implies
       
    86 		 * that the application has been un-installed and hence takes appropriate action.
       
    87 		 * If the MMC is not present in its slot then it means that the MMC card is 
       
    88 		 * removed for the time being and may be inserted again, based on which it takes
       
    89 		 * appropriate action
       
    90 		 *
       
    91 		 * @param aAppInfo information of the application removed
       
    92 		 */
       
    93 		void HandleMMCApplicationRemovalL();
       
    94 		
       
    95 		/**
       
    96 		 * Handles un-installation of an application.
       
    97 		 *
       
    98 		 * @param aAppInfo information of the application un-installed
       
    99 		 */
       
   100 		void HandleApplicationUninstallationL();
       
   101 		
       
   102 		
       
   103 		/**
       
   104 		 * Checks if MMC is present in its slot
       
   105 		 * 
       
   106 		 * @return ETrue if MMC is present EFlase otherwise
       
   107 		 */
       
   108 		TBool IsMemoryCardPresent();
       
   109 		
       
   110 		/**
       
   111          * Get Memory card character
       
   112          */
       
   113         void MemoryCardChar();        
       
   114 		
       
   115 		/**
       
   116 		 * Finds the a particular element in the array. The search is based on the 
       
   117 		 * UID in the application info. If the application is not present then the
       
   118 		 * function return KErrNotFound
       
   119 		 *
       
   120 		 * @param aArray the array in which the element needs to be searched
       
   121 		 * @param aElement the element which needs to be searched for
       
   122 		 */ 
       
   123 		TInt FindElementInArray(RArray<TLbtAppInfo>& aArray, TLbtAppInfo& aElement);
       
   124 		
       
   125 		/**
       
   126 		 * Handles list notification event when notification is for addition of an
       
   127 		 * application
       
   128 		 */
       
   129 		void HandleAppListAdditionEvent(RArray<TLbtAppInfo>& aNewAppList);
       
   130 		
       
   131 		/**
       
   132 		 * Handles list notification event when notification is for removal of an
       
   133 		 * application		 
       
   134 		 */
       
   135 		void HandleAppListRemovalEvent(RArray<TLbtAppInfo>& aNewAppList);
       
   136 		
       
   137 		
       
   138 		/**
       
   139 		 * Validates the triggers of the applications present in iAppList
       
   140 		 */
       
   141 		void SetValidTriggersOfApplicationsL();
       
   142 		
       
   143 		
       
   144 		
       
   145 	public: // from MLbtContainerChangeEventObserver
       
   146 	    void TriggerStoreChanged( RArray<TLbtTriggerId>& aTriggerIds,
       
   147                                   TLbtTriggerEventMask aEventMask,
       
   148                                   TLbtContainerChangedAreaType aAreaType,
       
   149                                   RArray<TUid>& aManagerUids );
       
   150 
       
   151 	private: // From CActive
       
   152 		
       
   153 		void DoCancel();
       
   154 		
       
   155 		void RunL();
       
   156 		
       
   157 		TInt RunError(TInt aError);
       
   158 		
       
   159 	
       
   160 	private: /// from MApaAppListServObserver
       
   161 		/**
       
   162 	     * Handles notification from app list observer when ever an application is 
       
   163 	     * installed or uninstalled
       
   164 	     *
       
   165 	     */
       
   166 		void HandleAppListEvent(TInt aEvent);
       
   167 		
       
   168 		/**
       
   169 		 * Lists triggers for which apps iAppList in are the 
       
   170 		 * startup process
       
   171 		 */
       
   172 		void ListTriggersOfStartupProcessL();
       
   173 		
       
   174 		/**
       
   175 		 * Deletes triggers for which apps iAppList in are the 
       
   176 		 * startup process
       
   177 		 */
       
   178 		void DeleteTriggersOfStartupProcessL();
       
   179 
       
   180 	private: // data members
       
   181 	
       
   182 		
       
   183 		// Reference to the container
       
   184 		CLbtContainer& iContainer;
       
   185 		
       
   186 		// Reference to cleanup handler
       
   187         CLbtCleanupHandler& iCleanupHandler;
       
   188 		        
       
   189 		// Reference to MLbtServerLogicTriggerChangeObserver
       
   190 		MLbtServerLogicTriggerChangeObserver& iTriggerChangeObserver;
       
   191 		
       
   192 		// Session with the application architecture framework
       
   193         RApaLsSession iAppArcSession;
       
   194         
       
   195         // Pointer to application scanner
       
   196         CApaAppListNotifier* iAppListNotifier;
       
   197 		        
       
   198 		// Array to hold the currently installed applications on the system
       
   199         RArray<TLbtAppInfo> iCurrentInstalledApps;
       
   200 		        
       
   201 		// The async operation in progress.
       
   202 		TInt iOperation;
       
   203 		
       
   204 		// Array of pointers to container trigger entries
       
   205 		RPointerArray<CLbtContainerTriggerEntry> iTriggerEntries;
       
   206 		
       
   207 		// Array to store the list of app removed
       
   208 		RArray<TLbtAppInfo> iAppList;
       
   209 	
       
   210 		// Operation id for calls to container. Needed for any cancellation
       
   211 		TInt iOpId;
       
   212 		
       
   213 		// External Memory card drive character
       
   214 		TBuf<2> iMMCDriveChar; // drive and colon
       
   215 	};
       
   216 
       
   217 #endif // C_LBTAPPREMOVALHANDLER_H