realtimenetprots/sipfw/ProfileAgent/Server/Inc/SipProfileState.h
changeset 0 307788aac0a8
child 2 1e1cc61f56c3
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2008-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 * Name        : sipprofilestate.h
       
    16 * Part of     : Sip Profile Server
       
    17 * Interface   : private
       
    18 * Base class for profile states
       
    19 * Version     : 1.0
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 /**
       
    27  @internalComponent
       
    28 */
       
    29 
       
    30 #ifndef CSIPPROFILESTATE_H
       
    31 #define CSIPPROFILESTATE_H
       
    32 
       
    33 // INCLUDES
       
    34 #include "sipconcreteprofile.h"
       
    35 #include <e32base.h>
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CSIPProfileCacheItem;
       
    39 class CSIPPluginDirector;
       
    40 class MSIPExtendedConcreteProfileObserver;
       
    41 class CSIPProfileServerCore;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46 *  Base class for profile state classes
       
    47 *  @lib 
       
    48 */
       
    49 class CSIPProfileState: public CBase
       
    50 	{
       
    51 	public:  // Enums
       
    52 
       
    53 		// State ids used for logging.
       
    54 		// The actual values of these enums must be different from the values
       
    55 		// of CSIPConcreteProfile::TStatus.
       
    56         enum TStatus
       
    57             {
       
    58             /** Wait for IAP */
       
    59             EWaitForIAP = 10,
       
    60             /** Wait for IAP migration permission */
       
    61             EWaitForPermission,
       
    62             /** Migrating to new IAP */
       
    63             EMigratingToNewIAP,
       
    64             /** Unregistering old IAP */
       
    65             EUnregisteringOldIAP
       
    66             };
       
    67 
       
    68    public:  // Constructors and destructor
       
    69         
       
    70         /**
       
    71         * Destructor.
       
    72         */
       
    73         virtual ~CSIPProfileState();
       
    74 
       
    75     public: // New functions
       
    76         
       
    77         /**
       
    78         * Gets CSIPConcreteProfile status of the state
       
    79         * @return CSIPConcreteProfile status of the state
       
    80         */      
       
    81 		virtual CSIPConcreteProfile::TStatus Name() const = 0;
       
    82 
       
    83         /**
       
    84         * Called when entering a new state.
       
    85         * @param aItem Profile cache item
       
    86         * @param aMaySendRegStatusEvent ETrue if registration status event can
       
    87         *		 be sent to client. EFalse if it must not be sent.
       
    88         * @param aServerCore Server core where status event is sent to
       
    89         */
       
    90 		virtual void EnterL(CSIPProfileCacheItem& aItem,
       
    91 							TBool aMaySendRegStatusEvent,
       
    92 							CSIPProfileServerCore& aServerCore);
       
    93 
       
    94         /**
       
    95         * Registers profile, leaves because not allowed
       
    96         * @param aItem profile cache item
       
    97         */
       
    98 		virtual void RegisterL(CSIPProfileCacheItem& aItem);
       
    99 
       
   100 		/**
       
   101         * Updates profile registration
       
   102         * @param aItem profile cache item
       
   103         * @param aObserver client updating the profile
       
   104         */
       
   105 		virtual void UpdateRegistrationL(
       
   106 			CSIPProfileCacheItem& aItem,
       
   107 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   108 
       
   109 		/**
       
   110         * Enables profile
       
   111         * @param aItem profile cache item
       
   112         * @param aObserver client enabling the profile
       
   113         */      
       
   114 		virtual void EnableL(
       
   115 			CSIPProfileCacheItem& aItem,
       
   116 			const MSIPExtendedConcreteProfileObserver& aObserver) = 0;
       
   117 
       
   118 		/**
       
   119         * Enables profile
       
   120         * @param aItem profile cache item
       
   121         * @param aObserver client enabling the profile
       
   122         * @param aSnapId SNAP id
       
   123         */      
       
   124 		virtual void EnableSnapInUseL(
       
   125 			CSIPProfileCacheItem& aItem,
       
   126 			const MSIPExtendedConcreteProfileObserver& aObserver,
       
   127 			TUint32 aSnapId) = 0;
       
   128 
       
   129         /**
       
   130         * Disables profile.
       
   131         * @param aItem profile cache item
       
   132         * @param aObserver client disabling the profile
       
   133         */
       
   134 		virtual void DisableL(
       
   135 			CSIPProfileCacheItem& aItem,
       
   136 			const MSIPExtendedConcreteProfileObserver& aObserver) = 0;
       
   137 
       
   138         /**
       
   139         * Profile Removed, proper actions done in order.
       
   140 		* to unregister if not unregistered
       
   141         * @param aItem profile cache item
       
   142         */
       
   143 		virtual void RemoveL(CSIPProfileCacheItem& aItem);
       
   144 
       
   145         /**
       
   146         * Checks if profile can be permanently removed
       
   147         * @param aItem profile cache item
       
   148 		* @return ETrue, if unregistered and can be removed
       
   149         */
       
   150 		virtual TBool CanBePermanentlyRemoved(
       
   151 			const CSIPProfileCacheItem& aItem) const;
       
   152 
       
   153         /**
       
   154         * Updates registration status.
       
   155         * @param aItem profile cache item
       
   156         * @param aStatus new registration status
       
   157         */
       
   158 		virtual void RegistrationStatusEventL(
       
   159 			CSIPProfileCacheItem& aItem,
       
   160 			CSIPConcreteProfile::TStatus aStatus);
       
   161 
       
   162         /**
       
   163         * Resets registration status to unregistered befause of an error.
       
   164         * @param aItem profile cache item
       
   165         * @param aError occurred error code
       
   166         * @return ETrue Work normally
       
   167         *         EFalse Don't send error or registration state events to client
       
   168         */
       
   169 		virtual TBool ErrorOccurred(CSIPProfileCacheItem& aItem,
       
   170 								    TInt aError) = 0;
       
   171 
       
   172 		/**
       
   173 		* A new IAP became available.
       
   174 		* This event is only received by a profile that has a SNAP configured.
       
   175 		* @param aItem Profile cache item
       
   176 		* @param aSnapId a SNAP id.
       
   177 		* @param aNewIapId an IAP id. 
       
   178 		*/
       
   179 		virtual void IapAvailableL(CSIPProfileCacheItem& aItem,
       
   180 								   TUint32 aSnapId,
       
   181 								   TUint32 aNewIapId);
       
   182 
       
   183 		/**
       
   184         * Migration to new IAP is allowed by a client.
       
   185         * @param aItem Profile cache item
       
   186 		* @param aIapId IAP id
       
   187 		* @param aObserver Observer
       
   188         */
       
   189 		virtual void ClientAllowsMigrationL(CSIPProfileCacheItem& aItem,
       
   190 			TUint32 aIapId,
       
   191 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   192 
       
   193 		/**
       
   194         * Migration to new IAP is not allowed by a client.
       
   195         * @param aItem Profile cache item
       
   196 		* @param aIapId IAP id
       
   197 		* @param aObserver Observer
       
   198         */
       
   199 		virtual void ClientDisallowsMigrationL(CSIPProfileCacheItem& aItem,
       
   200 			TUint32 aIapId,
       
   201 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   202 
       
   203 		/**
       
   204         * Overall result of all clients of all profiles using the same SNAP, is
       
   205         * that migration is allowed.
       
   206         * @param aItem Profile cache item
       
   207 		* @param aIapId IAP id
       
   208         */
       
   209 		virtual void MigrationIsAllowedL(CSIPProfileCacheItem& aItem,
       
   210 										 TUint32 aIapId);
       
   211 
       
   212 		/**
       
   213         * Overall result of all clients of all profiles using the same SNAP, is
       
   214         * that migration is not allowed.
       
   215         * @param aItem Profile cache item
       
   216 		* @param aIapId IAP id
       
   217         */
       
   218 		virtual void MigrationIsDisallowedL(CSIPProfileCacheItem& aItem,
       
   219 										 	TUint32 aIapId);
       
   220 
       
   221 		virtual TBool ShouldRefreshIAPs(CSIPProfileCacheItem& aItem) const;
       
   222 
       
   223 		/**
       
   224         * Determines if the state is an ALR-related state, or not.
       
   225 		* @return ETrue If the state is one of the ALR-related ones
       
   226 		*		  EFalse Otherwise
       
   227         */
       
   228 		virtual TBool IsAlrState() const;
       
   229 
       
   230 		/**
       
   231         * System is about to be shut down.
       
   232         * @param aItem Profile cache item
       
   233         */
       
   234 		virtual void ShutdownInitiated(CSIPProfileCacheItem& aItem);
       
   235 		
       
   236 		/**
       
   237         * No unused IAP available in SNAP
       
   238         * @param aItem Profile cache item
       
   239         */
       
   240 		virtual void NoNewIapAvailable(CSIPProfileCacheItem& aItem);
       
   241 
       
   242 		/**
       
   243         * Determines if profile can be updated in current state, or if it must
       
   244         * be queued and updated later.
       
   245         * @param aItem Profile cache item
       
   246 		* @return ETrue Can update now
       
   247 		*		  EFalse Must queue
       
   248         */
       
   249 		TBool CanProfileBeUpdated(CSIPProfileCacheItem& aItem) const;
       
   250 
       
   251 		/**
       
   252         * Checks if an initial registration has been done.
       
   253         * @param aItem Profile cache item
       
   254         * @return ETrue Initial registration has been done
       
   255         *		  EFalse Otherwise
       
   256         */
       
   257 		TBool IsInitialRegisterDone(CSIPProfileCacheItem& aItem) const;
       
   258 
       
   259 		/**
       
   260         * Register profile using the IAP id.
       
   261         * @param aItem Profile cache item
       
   262         * @param aIapId IAP id to register with
       
   263         * @param aRegInProg "Register in progress" state
       
   264         */
       
   265 		void RegisterWithIapL(CSIPProfileCacheItem& aItem,
       
   266 							  TUint32 aIapId,
       
   267 							  CSIPProfileState& aRegInProg) const;
       
   268 
       
   269 		/**
       
   270         * De-register the used profile
       
   271         * @param aItem profile cache item
       
   272         * @param aUnregInProg "Unregister in progress" state
       
   273         */
       
   274 		void StartDeregisterL(CSIPProfileCacheItem& aItem,
       
   275 							  CSIPProfileState& aUnregInProg) const;
       
   276 
       
   277 		/**
       
   278         * Update profile.
       
   279         * @param aProfile Profile with updated data
       
   280         * @param aOldProfile Existing profile
       
   281         * @return ETrue  if de-register started for the existing profile
       
   282         *		  EFalse if the update is so minor that e.g. sending an UPDATE
       
   283         *				 is enough, and there is no need for de-register
       
   284         */
       
   285 		TBool DoUpdateL(CSIPConcreteProfile& aProfile,
       
   286 						CSIPConcreteProfile& aOldProfile) const;
       
   287 
       
   288 		/**
       
   289         * Refreshing IAPs has failed. Terminate the handling of this profile.
       
   290         * @param aItem profile cache item
       
   291         */
       
   292 		void RefreshIAPsFailed(CSIPProfileCacheItem& aItem) const;
       
   293 
       
   294     protected:
       
   295 
       
   296         /**
       
   297         * Constructor.
       
   298 		* @param aPluginDirector plugin mgr
       
   299         */
       
   300         CSIPProfileState(CSIPPluginDirector& aPluginDirector);
       
   301 
       
   302         /**
       
   303         * Enables profile, leaves because not allowed
       
   304         * @param aItem profile cache item
       
   305         * @param aObserver client enabling the profile
       
   306         */      
       
   307 		void DoCommonEnableL(
       
   308 			CSIPProfileCacheItem& aItem,
       
   309 			const MSIPExtendedConcreteProfileObserver& aObserver) const;
       
   310 
       
   311         /**
       
   312         * Disables profile
       
   313 		* @param aCore server core
       
   314         * @param aItem profile cache item
       
   315         */
       
   316 		void DoCommonDisable(
       
   317 			CSIPProfileCacheItem& aItem,
       
   318 			const MSIPExtendedConcreteProfileObserver& aObserver) const;
       
   319 
       
   320         /**
       
   321         * Resets registartion status of underlying layers 
       
   322 		* to unregistred befause of error
       
   323         * @param aItem profile cache item
       
   324         */
       
   325 		void DoCommonErrorOccurred(CSIPProfileCacheItem& aItem) const;
       
   326 
       
   327 		void DisableWhileWaitingIAPL(CSIPProfileCacheItem& aItem,
       
   328 			const MSIPExtendedConcreteProfileObserver& aObserver,
       
   329 			CSIPProfileState& aUnregInProg,
       
   330 			CSIPProfileState& aUnregistered) const;
       
   331 
       
   332 		void DisableWhileInProgressL(CSIPProfileCacheItem& aItem,
       
   333 			CSIPProfileState& aUnregInProg,
       
   334 			CSIPProfileState& aUnregistered) const;
       
   335 
       
   336 	protected: // Data
       
   337 
       
   338 		CSIPPluginDirector& iPluginDirector;
       
   339 
       
   340 	private: // For testing purposes
       
   341 #ifdef CPPUNIT_TEST
       
   342 		friend class CSIPProfileStateTest;
       
   343 #endif
       
   344 	};
       
   345 
       
   346 #endif