locationtriggering/ltserver/ltserverlogic/inc/lbtserverlogic.h
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2006,2007 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:  LBT Server Logic implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_LBTSERVERLOGIC_H
       
    20 #define C_LBTSERVERLOGIC_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "lbtserverlogicbase.h" // interface 
       
    24 #include "lbtaoobserver.h"
       
    25 #include "lbttriggeringsupervisionobserver.h" // stratergy observer
       
    26 #include "lbtbackuprestoreobserver.h" // For Backup and Restore observer
       
    27 #include "lbtstrategytriggeringsystemstatus.h"
       
    28 #include "lbtdeletesessiontriggers.h"
       
    29 #include "lbtdeletesessiontriggerobserver.h"
       
    30 #include "lbttriggerchangeobserver.h"
       
    31 #include <lbttriggeringsystemmanagementsettings.h>
       
    32 #include <lbttriggerchangeevent.h>
       
    33 #include "lbtserverlogictriggerchangeobserver.h"
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CLbtAOOperationBase;
       
    37 class CLbtStratergyContainer;
       
    38 class CLbtBackupRestoreListener;
       
    39 class CLbtContainer;
       
    40 class CLbtSettingsManager;
       
    41 class CLbtNotificationMap;
       
    42 class CLbtTriggerFireHandler;
       
    43 class CLbtAppChangeHandler;
       
    44 class CLbtCleanupHandler;
       
    45 class CLbtSimChangeHandler;
       
    46 
       
    47 /**
       
    48  * Class declaration for server logic implementation
       
    49  * 
       
    50  * @since S60 v4.0
       
    51  */
       
    52 class CLbtServerLogic : public CLbtServerLogicBase, 
       
    53 						public MLbtAOObserver,	// AOO operation observer
       
    54 						public MLbtTriggeringSupervisionObserver,	// Stratergy observer
       
    55 						public MLbtBackupRestoreObserver, // Backup and Restore observer
       
    56 						public MLbtDeleteSessionTriggerObserver, // Delete session trigger observer
       
    57 						public MLbtServerLogicTriggerChangeObserver
       
    58 	{
       
    59 	public:	
       
    60 		/**
       
    61 	     * Instantiates a new object of 
       
    62 	     * CLbtServerLogic
       
    63 	     *
       
    64 	     * @return a pointer to an instance of 
       
    65 	     * CLbtServerLogic
       
    66 	     */
       
    67 	    static CLbtServerLogic* NewL();
       
    68 	    
       
    69 	    /**
       
    70 	     * Destructor
       
    71 	     *
       
    72 	     */
       
    73 	    ~CLbtServerLogic();
       
    74 	
       
    75 	public: // new functions
       
    76 		
       
    77 		/**
       
    78 	     * Handles the servicing of a client request that 
       
    79 	     * has been passed from server core session
       
    80 	     *
       
    81 	     * @aMessage The message containing the details of 
       
    82 	     * the client request. The resposibility of completing
       
    83 	     * the message is upto this object
       
    84 	     *
       
    85 	     */	     
       
    86 	    void ServiceL(const RMessage2 &aMessage, TSubSessionType aType);
       
    87 	    
       
    88 	    /**
       
    89 	     * Loads stratergy plugin if not already loaded
       
    90 	     * After loading it starts the supervision process.
       
    91 	     * In case strategy is already loaded and there are no
       
    92 	     * valid and enabled triggers in the system then strategy
       
    93 	     * plugin is un-loaded.	     
       
    94 	     */
       
    95 	    void LoadOrUnloadStrategyPluginL();
       
    96 	    
       
    97 	    /**
       
    98 	     * Method is invoked when a session with a particular session
       
    99 	     * id is being closed. One closure of this session all the 
       
   100 	     * data pertaining to that session like session triggers,
       
   101 	     * IPC messages has to be deleted
       
   102 	     *
       
   103 	     * @param aSessionId the id of the session which is being closed
       
   104 	     */
       
   105 	    void HandleSubSessionClosure(const TInt aSessionId, const CSession2* aSession);
       
   106 	    
       
   107 	    /**
       
   108 	     * Informs server logic implementation that all the sessions of
       
   109 	     * client with a particular secure id has been closed. 
       
   110 	     * 
       
   111 	     * @param aSecureId the secure id of the client whose sessions
       
   112 	     * are being closed
       
   113 	     */
       
   114 	    void HandleSessionClosureL(const TSecureId aSecureId);
       
   115 	
       
   116 	public: // from MLbtAOObserver
       
   117 	    void HandleDeleteSessionTriggersClosureL(CLbtDeleteSessionTriggers*
       
   118 	    												 aDeleteSessionTriggers);
       
   119 	
       
   120 	public: // from MLbtAOObserver
       
   121 		void HandleOperationClosureL(CLbtAOOperationBase* aOperation, TInt aStatus);
       
   122 	
       
   123 	public: // from MLbtTriggeringSupervisionObserver
       
   124 		void TriggerFiredL( CLbtGeoAreaBase::TGeoAreaType aAreaType,TLbtTriggerId aId, 
       
   125         					const TPositionInfo& aPosInfo );
       
   126         					
       
   127 		void SetTriggeringSupervisionDynamicInfo( 
       
   128    							const TLbtStrategySupervisionDynamicInfo& aStatus );
       
   129    			
       
   130    		void GetTriggeringSupervisionSettings( 
       
   131  							TLbtStrategyTriggeringSupervisionSettings& aSettings );
       
   132 	
       
   133 	public: // from MLbtBackupRestoreObserver
       
   134 		void HandleBackupRestoreOperationL(TBRState aState);
       
   135 
       
   136 	public: // from	MLbtServerLogicTriggerChangeObserver
       
   137 	    void HandleTriggersChange( RArray<TLbtTriggerId>& aTriggerIds,
       
   138                                    RArray<TUid>& aManagerUids,
       
   139                                    TLbtTriggerEventMask aEventMask  );
       
   140 	private:
       
   141 	
       
   142 		/**
       
   143 	     * Default C++ Constructor
       
   144 	     *
       
   145 	     */
       
   146 	    CLbtServerLogic();
       
   147 	    
       
   148 		/**
       
   149 	     * 2nd phase constuctor for instantiating member variables
       
   150 	     *
       
   151 	     */
       
   152 		void ConstructL();
       
   153 		
       
   154 	    /**
       
   155 	     * Cancels all outstanding operation objects and destroys it
       
   156 	     *
       
   157 	     */
       
   158 	    void CancelAllOperations();
       
   159 	    
       
   160 	    /**
       
   161 	     * Removes the meesage which matches the notification cancellation
       
   162 	     * message received. The message in the notification map which matches 
       
   163 	     * the session id and the service id of the received message is removed.
       
   164 	     *
       
   165 	     * @param aMessage the message to be removed from the message notification map
       
   166 	     * @param aServiceId the service id for the cancellation of which this
       
   167 	     *        message has been received
       
   168 	     */
       
   169 	    TInt RemoveFromNotificationMap( const RMessage2& aMessage, TInt aServiceId );
       
   170 	    
       
   171 	    /**
       
   172 	     * Checks if the received message is not a duplicate. If it is a duplicate
       
   173 	     * request then the client message is completed with ELbtDuplicateRequest
       
   174 	     *
       
   175 	     * @param aMessage message to be inserted into the message notification map
       
   176 	     * 
       
   177 	     */
       
   178 	    void InsertIntoNotificationMapL(const RMessage2& aMessage, TSubSessionType aType);
       
   179 	    
       
   180 	    /**
       
   181 	     * Makes capability checks and other Notify change related
       
   182 	     * sanity checks on the message. Returns appropriate error
       
   183 	     * code.
       
   184 	     *
       
   185 	     * @return KErrNone if trigger can be created and any one of the error 
       
   186 	     * codes otherwise
       
   187 	     */
       
   188 	     TInt ValidateChangeNotification(const RMessage2& aMessage);
       
   189 	     
       
   190 	     /**
       
   191 	     * Makes capability checks for general LBT operation
       
   192 	     * on the message. Returns appropriate error
       
   193 	     * code.
       
   194 	     *
       
   195 	     * @return KErrNone if trigger can be created and any one of the error 
       
   196 	     * codes otherwise
       
   197 	     */
       
   198 	     TInt ValidateGeneralOperation(const RMessage2& aMessage);
       
   199 	     
       
   200 	    /**
       
   201 	     * Makes capability checks and other create trigger related
       
   202 	     * sanity checks on the message. Returns appropriate error
       
   203 	     * code.
       
   204 	     *
       
   205 	     * @return KErrNone if trigger can be created and any one of the error 
       
   206 	     * codes otherwise
       
   207 	     */
       
   208 		TInt ValidateCreateTriggerMessage(const RMessage2& aMessage);
       
   209 		/**
       
   210 	     * Makes capability checks and other get triggering setting related
       
   211 	     * sanity checks on the message. Returns appropriate error
       
   212 	     * code.
       
   213 	     *
       
   214 	     * @return KErrNone if trigger can be created and any one of the error 
       
   215 	     * codes otherwise
       
   216 	     */
       
   217 		TInt ValidateGetTriggeringSysSetting(const RMessage2& aMessage);
       
   218 		
       
   219 		/**
       
   220 	     * Makes capability checks and other set triggering setting related
       
   221 	     * sanity checks on the message. Returns appropriate error
       
   222 	     * code.
       
   223 	     *
       
   224 	     * @return KErrNone if trigger can be created and any one of the error 
       
   225 	     * codes otherwise
       
   226 	     */
       
   227 		TInt ValidateSetTriggeringSetting(const RMessage2& aMessage);
       
   228 		
       
   229 		/**
       
   230 	     * Makes capability checks and other Get triggering status related
       
   231 	     * sanity checks on the message. Returns appropriate error
       
   232 	     * code.
       
   233 	     *
       
   234 	     * @return KErrNone if trigger can be created and any one of the error 
       
   235 	     * codes otherwise
       
   236 	     */
       
   237 		TInt ValidateGetTriggeringSysStatus(const RMessage2& aMessage);
       
   238 		
       
   239 		/**
       
   240 		 * Checks if the provided service id is for a asynchronous
       
   241 		 * notification request
       
   242 		 * 
       
   243 		 * @param[in] aServiceId the provided service id 
       
   244 		 * @return ETrue if the provided service id is for a 
       
   245 		 * asynchronous service request. EFalse otherwise		 
       
   246 		 */
       
   247 		TBool IsNotificationRequest(TInt aServiceId);
       
   248 		
       
   249 		/**
       
   250 		 * Handles all asynchronous notifications except system settings 
       
   251 		 * change notification. System settings change notification is valid
       
   252 		 * only when management library changes the settings. Hence that 
       
   253 		 * notification will be taken care by the active object handling 
       
   254 		 * all management library requests
       
   255 		 *
       
   256 		 * @param aMessage the message to be removed from the message notification map
       
   257 		 */
       
   258 		void HandleNotificationOperationsL(CLbtAOOperationBase* aOperation, TInt aServiceId);
       
   259 	    
       
   260 		/**
       
   261 		 * Change the Settings used by the triggering engine.
       
   262 		 * These settings values tweak the behaviour of triggering engine
       
   263 		 * Only when management library changes the settings. 
       
   264 		 *
       
   265 		 * @param aSettings the new settings values for the triggering engine.
       
   266 		 */
       
   267         void SetTriggeringSystemSettings( 
       
   268             TLbtTriggeringSystemManagementSettings& aSettings,
       
   269             TLbtManagementSettingsMask aSettingsMask );
       
   270 
       
   271         TInt GetTriggeringSystemSettings( const RMessage2& aMessage, TSubSessionType aClientType );
       
   272         
       
   273         void GetTriggeringSysStatus( TLbtTriggeringSystemStatus& aSystemStatus );
       
   274         
       
   275         void HandleSingleNotificationOperationsL(
       
   276             CLbtAOOperationBase* aOperation, 
       
   277             TInt aServiceId);
       
   278 
       
   279         void HandleMultipleNotificationOperationsL(
       
   280             CLbtAOOperationBase* aOperation, 
       
   281             TInt aServiceId);
       
   282 
       
   283         void SetNotificationEventType( 
       
   284             CLbtAOOperationBase* aOperation, 
       
   285             TLbtTriggerChangeEvent& aEvent );
       
   286        void NotifyTriggeringSystemSettingChange(TLbtManagementSettingsMask aSettingsMask );    
       
   287        
       
   288        void NotifyTriggeringSystemStatusChange();
       
   289 	private: // Data
       
   290 	    // Handle to RProperty server
       
   291 	    RProperty    iProperty;
       
   292 	
       
   293 		// Array to maintain the list of ao operation running in server logic
       
   294 		RPointerArray<CLbtAOOperationBase> iAOOArray;
       
   295 		
       
   296 		// Pointer to stratergy container
       
   297 		CLbtStratergyContainer* iStratergyContainer;
       
   298 		
       
   299 		// Pointer to backup and restore event listener
       
   300 		CLbtBackupRestoreListener* iBackupRestoreListener;
       
   301 		
       
   302 		// Pointer to location triggering container
       
   303 		CLbtContainer* iContainer;
       
   304 		
       
   305 		// Pointer to the triggering settings manager
       
   306 		CLbtSettingsManager* iSettingsManager;
       
   307 		
       
   308 		// Notification map to store all notification messages
       
   309 		CLbtNotificationMap* iNotificationMap;
       
   310 		
       
   311 		// Trigger fire handler
       
   312 		CLbtTriggerFireHandler* iFireHandler;
       
   313 		
       
   314 		// Array that maintains delete session triggers AO.
       
   315 		RPointerArray<CLbtDeleteSessionTriggers> iDeleteSessionTriggersArray;
       
   316 		// Strategy dynamic info structure.
       
   317 		TLbtStrategySupervisionDynamicInfo iStrategyDynamicInfo;
       
   318 		
       
   319 		// Pointer to application change handler
       
   320 		CLbtAppChangeHandler* iAppChangeHandler;
       
   321 		// Pointer to sim change handler
       
   322 		CLbtSimChangeHandler* iSimChangeHandler;
       
   323 		
       
   324 		// Pointer to cleanup handler
       
   325 		CLbtCleanupHandler* iCleanupHandler;
       
   326 	};
       
   327 
       
   328 #endif // C_LBTSERVERLOGIC_H