realtimenetprots/sipfw/ProfileAgent/Server/Inc/SipProfileServerCore.h
branchRCL_3
changeset 9 1e1cc61f56c3
parent 4 dd3853b8dc3f
child 16 43c4dec3cb1f
equal deleted inserted replaced
4:dd3853b8dc3f 9:1e1cc61f56c3
    33 //  INCLUDES
    33 //  INCLUDES
    34 #include "sipconcreteprofile.h"
    34 #include "sipconcreteprofile.h"
    35 #include "sipprofileagentobserver.h"
    35 #include "sipprofileagentobserver.h"
    36 #include "sipprofileerrorhandler.h"
    36 #include "sipprofileerrorhandler.h"
    37 #include <sipsystemstateobserver.h>
    37 #include <sipsystemstateobserver.h>
       
    38 #include "sipapnmanager.h"
    38 #include <e32base.h>
    39 #include <e32base.h>
    39 
    40 
    40 // FORWARD DECLARATIONS
    41 // FORWARD DECLARATIONS
    41 class CSIPProfileCSServer;
    42 class CSIPProfileCSServer;
    42 class CSIPProfileStorage;
    43 class CSIPProfileStorage;
    65  * The class providing core functionality of profile server.
    66  * The class providing core functionality of profile server.
    66  */
    67  */
    67 class CSIPProfileServerCore : public CBase, 
    68 class CSIPProfileServerCore : public CBase, 
    68                               public MSIPProfileAgentObserver,
    69                               public MSIPProfileAgentObserver,
    69                               public MSipProfileErrorHandler,
    70                               public MSipProfileErrorHandler,
    70                               public MSipSystemStateObserver
    71                               public MSipSystemStateObserver,
       
    72                               public MSIPApnChangeObserver
    71 	{
    73 	{
       
    74     
       
    75     public:
       
    76     /*
       
    77      * struct to store ApnSwitchEnabled profiles in the event 
       
    78      * when IAPSettings are not same as required.
       
    79      */
       
    80     struct TStoreSwitchEnabledProfile
       
    81         {
       
    82     public:
       
    83         enum TOperation
       
    84             {
       
    85             Update =1,
       
    86             Enable,
       
    87             Register
       
    88             };
       
    89         CSIPConcreteProfile*                          iProfile;
       
    90         const MSIPExtendedConcreteProfileObserver*    iObserver;
       
    91         TOperation                                    operation;
       
    92         };
       
    93     
    72 	public: // Constructors and destructor
    94 	public: // Constructors and destructor
    73     
    95     
    74 	    /**
    96 	    /**
    75         * Two-phased constructor.
    97         * Two-phased constructor.
    76         * @param aServer server of the session
    98         * @param aServer server of the session
   114 
   136 
   115         void SystemVariableUpdated( 
   137         void SystemVariableUpdated( 
   116             CSipSystemStateMonitor::TSystemVariable aVariable,
   138             CSipSystemStateMonitor::TSystemVariable aVariable,
   117     		TInt aObjectId,
   139     		TInt aObjectId,
   118     		TInt aValue );
   140     		TInt aValue );
       
   141         
       
   142 	public: // MSIPApnChangeObserver
       
   143 	    
       
   144         void ApnChanged( const TDesC8& aApn, TUint32 aIapId, TInt aError );
   119 
   145 
   120     public: // New functions
   146     public: // New functions
   121 
   147 
   122 	    /**
   148 	    /**
   123         * Stores client observer for sending events
   149         * Stores client observer for sending events
   439 		CSIPProfileState& UnregisteredState();
   465 		CSIPProfileState& UnregisteredState();
   440 
   466 
   441 		TUint32 GenerateProfileIdL();
   467 		TUint32 GenerateProfileIdL();
   442 
   468 
   443 		/**
   469 		/**
   444 		 * Sends forcibly disable profile added event to all clients
   470 		* Sends forcibly disable profile added event to all clients
   445 		 * @param aProfileId: Id of the profile being disabled forcibly 
   471 		* @param aProfileId: Id of the profile being disabled forcibly 
   446 		 */
   472 		*/
   447 		void SendProfileForciblyDisabledEvent(const CSIPProfileCacheItem& aItem) const;
   473 		void SendProfileForciblyDisabledEvent(const CSIPProfileCacheItem& aItem) const;
   448 		
   474 		
   449       /**
   475     /**
   450         * Gets cached profile, leave if not found
   476     * Gets cached profile, leave if not found
   451         * ownership is not transfered
   477     * ownership is not transfered
   452         * @param aProfileId id of profile. 
   478     * @param aProfileId id of profile. 
   453         * @return profile cache item 
   479     * @return profile cache item 
   454         */
   480     */
   455         CSIPProfileCacheItem* ProfileCacheItemL(TUint32 aProfileId) const;
   481     CSIPProfileCacheItem* ProfileCacheItemL(TUint32 aProfileId) const;
       
   482 
       
   483 		/**
       
   484 		*Starts timer of type CDeltaTimer, 
       
   485 		*which callback is ConnectionCloseTimerExpired function
       
   486 		*/
       
   487 		void StartConnectionCloseTimer();
       
   488 		
       
   489 		/**
       
   490 		* A callback for CDeltaTimer
       
   491 		*/
       
   492 		static TInt ConnectionCloseTimerExpired(TAny* aPtr);
       
   493 		
       
   494 		/**
       
   495 		* Notify system state monitor about event processing completion
       
   496 		*/
       
   497 		void ConfirmSystemstateMonitor(
       
   498 			CSipSystemStateMonitor::TSystemVariable aVariable);
       
   499 			
       
   500 		/*
       
   501          * Checks whether the Update can be performed when the profile
       
   502          * has IAP as modem bearer.
       
   503          */
       
   504         TBool IsUpdateAllowed( CSIPConcreteProfile *aProfile );
   456 
   505 
   457 	private:
   506 	private:
   458 
   507 
   459 		/**
   508 		/**
   460 		* Default constructor
   509 		* Default constructor
   466 		* Symbian 2nd phase constructor
   515 		* Symbian 2nd phase constructor
   467 		*/
   516 		*/
   468 		void ConstructL();
   517 		void ConstructL();
   469 
   518 
   470 		/**
   519 		/**
   471         * Sends status event to observers of the profile
   520     * Sends status event to observers of the profile
   472 		* @param aItem holds profile and observers
   521 		* @param aItem holds profile and observers
   473         */
   522     */
   474 		void SendStatusEventL(CSIPProfileCacheItem& aItem, 
   523 		void SendStatusEventL(CSIPProfileCacheItem& aItem, 
   475 							  CSIPConcreteProfile::TStatus aStatus) const;
   524 							  CSIPConcreteProfile::TStatus aStatus) const;
   476 
   525 
   477 		/**
   526 		/**
   478 		* Loads profiles from store to cache, register
   527 		* Loads profiles from store to cache, register
   611 		* aParam aRestoreOngoing ETrue if restore is ongoing,
   660 		* aParam aRestoreOngoing ETrue if restore is ongoing,
   612 		*						 EFalse if backup is ongoing
   661 		*						 EFalse if backup is ongoing
   613 		*/
   662 		*/
   614 		void ReserveStorageL(TBool aRestoreOngoing);
   663 		void ReserveStorageL(TBool aRestoreOngoing);
   615 
   664 
   616 	    /**
   665 	  /**
   617         * Cleans up array in case of failure
   666     * Cleans up array in case of failure
   618         * ownership of aArray is transferred
   667     * ownership of aArray is transferred
   619 		* @param aArray array to be cleaned up
   668 		* @param aArray array to be cleaned up
   620         */
   669     */
   621 		static void ResetAndDestroy(TAny* aArray);
   670 		static void ResetAndDestroy(TAny* aArray);
   622 
   671 
   623 	    /**
   672 	  /**
   624         * Cleans up array in case of failure
   673     * Cleans up array in case of failure
   625         * ownership of aArray is transferred
   674     * ownership of aArray is transferred
   626 		* @param aArray array to be cleaned up
   675 		* @param aArray array to be cleaned up
   627         */
   676     */
   628 		static void ResetAndDestroyInfo(TAny* aArray);
   677 		static void ResetAndDestroyInfo(TAny* aArray);
   629 
   678 
   630 	    /**
   679 	  /**
   631         * Reverts back cache in case of failure      
   680     * Reverts back cache in case of failure      
   632 		* @param aItem cache cleanup item
   681 		* @param aItem cache cleanup item
   633         */
   682     */
   634 		static void CrashRevert(TAny* aItem);
   683 		static void CrashRevert(TAny* aItem);
   635 		
   684 		
   636 		/**
   685 		/**
   637         * Handles the errors occured during the profile restore     
   686     * Handles the errors occured during the profile restore     
   638 		* @param aErr
   687 		* @param aErr
   639 		* @param fileStore specifies the kind of the file on which 
   688 		* @param fileStore specifies the kind of the file on which 
   640 		* the storage error has occured
   689 		* the storage error has occured
   641         */
   690     */
   642 		void HandleProfileStorageErrorL(TInt aErr, TBool fileStore=EFalse);
   691 		void HandleProfileStorageErrorL(TInt aErr, TBool fileStore=EFalse);
   643 
   692 
   644 		/**
   693 		/**
   645         * Remove the cached profile entry identified by aProfileId.
   694         * Remove the cached profile entry identified by aProfileId.
   646 		* @param aProfileId Profile id
   695 		* @param aProfileId Profile id
   647         */
   696         */
   648 		void RemoveProfileItem(TUint32 aProfileId);
   697 		void RemoveProfileItem(TUint32 aProfileId);
   649 
   698 
   650 		/**
   699 		/**
   651         * Removes unused migration controllers, except if it uses the specified
   700     * Removes unused migration controllers, except if it uses the specified
   652         * SNAP id.
   701     * SNAP id.
   653 		* @param aSnapId SNAP id
   702 		* @param aSnapId SNAP id
   654         */
   703     */
   655 		void RemoveUnusedMigrationControllers(TUint32 aSnapId);
   704 		void RemoveUnusedMigrationControllers(TUint32 aSnapId);
   656 
   705 
   657 		void LoadSystemStateMonitorL();
   706 		void LoadSystemStateMonitorL();
   658 
   707 
   659 		/**
   708 		/**
   660 		* Gets the default profile
   709 		* Gets the default profile
   661 		* @return Pointer to the default profile, or NULL if not found.
   710 		* @return Pointer to the default profile, or NULL if not found.
   662 		*/
   711 		*/
   663 		CSIPConcreteProfile* FindDefaultProfile() const;
   712 		CSIPConcreteProfile* FindDefaultProfile() const;
   664 
   713 
   665         TBool ShouldChangeIap(CSIPConcreteProfile& aProfile, TInt aError) const;
   714     TBool ShouldChangeIap(CSIPConcreteProfile& aProfile, TInt aError) const;
   666 
   715 
   667         /**
   716     /**
   668         * @return ETrue if any registered profile is using aIap
   717     * @return ETrue if any registered profile is using aIap
   669         */
   718     */
   670         TBool AnyRegisteredProfileUsesIap(TUint aIap) const;
   719     TBool AnyRegisteredProfileUsesIap(TUint aIap) const;
       
   720         
       
   721     /**
       
   722     * Add profiles in Profile Cache
       
   723     * @param aProfiles Array of the profiles to be added
       
   724     * @param aNotifyProfileCreation specifies whether the notification
       
   725     * to be sent to the profile clients
       
   726     */
       
   727     void AddProfilesInCacheL(RPointerArray<CSIPConcreteProfile>& aProfiles,
       
   728     	TBool aNotifyProfileCreation);
       
   729         
       
   730 		/**
       
   731 		* Gets the IAP Count in the Snap
       
   732     * @return number of aIaps in the Snap
       
   733     */
       
   734     TInt IAPCountL(TUint32 aSnapId) const;
       
   735 	
       
   736 	 /*
       
   737          * Checks whether the current seetings are same as 
       
   738          * required seetings for Registeration.
       
   739          * @ returns ETrue when the seetings are correct
       
   740          *      EFalse otherwise
       
   741          */
       
   742         
       
   743         TBool IsRegistrationAllowedWithCurrentApnSettings( TUint32 aIapId );
   671         
   744         
   672         /**
   745         /**
   673         * Add profiles in Profile Cache
   746          ** Selecting Initial Apn for the profile
   674         * @param aProfiles Array of the profiles to be added
   747          **/
   675         * @param aNotifyProfileCreation specifies whether the notification to be sent to the profile clients
   748         void SelectInitialApnL( const CSIPConcreteProfile& aProfile );
   676         */
       
   677         void AddProfilesInCacheL(RPointerArray<CSIPConcreteProfile>& aProfiles,TBool aNotifyProfileCreation);
       
   678         
   749         
   679 		/**
   750         /**
   680 		* Gets the IAP Count in the Snap
   751          * Checks whether the profile's IAP is switch enabled 
   681         * @return number of aIaps in the Snap
   752          * @ returns ETrue when the profile is APN switch enabled
   682         */
   753          *      EFalse otherwise
   683         TInt IAPCountL(TUint32 aSnapId) const;
   754          */
       
   755         TBool CheckApnSwitchEnabledL( const CSIPConcreteProfile& aProfile );
       
   756                
       
   757         /**
       
   758          * Checks the IAP settings 
       
   759          * @ returns ETrue when all the settings are correct
       
   760          *      EFalse otherwise 
       
   761          */
       
   762         TBool CheckIapSettings(TUint32 aProfileId);
       
   763         
       
   764         void UsePrimaryApn(TUint32 aIapId);
       
   765 
       
   766         void UseBackupApn( TUint32 aIapId, TBool aFatalFailure = ETrue );
       
   767 		
   684         
   768         
   685 	private: // Data
   769 	private: // Data
   686 	
   770 	
   687 		RFs										iFs;
   771 		RFs										iFs;
   688 		TBool									iBackupInProgress;
   772 		TBool									iBackupInProgress;
   723 		// Migration controllers. Array items are owned.
   807 		// Migration controllers. Array items are owned.
   724 		RPointerArray<CSipAlrMigrationController> iMigrationControllers;
   808 		RPointerArray<CSipAlrMigrationController> iMigrationControllers;
   725 
   809 
   726 		// Owned
   810 		// Owned
   727 		CSipSystemStateMonitor*				iSystemStateMonitor;
   811 		CSipSystemStateMonitor*				iSystemStateMonitor;
       
   812 		//ApnManager
       
   813 		CSIPApnManager*                     iApnManager; // iBackupApnSettings;
       
   814 		RArray<TStoreSwitchEnabledProfile>                iWaitForApnSettings;
   728 
   815 
   729 		TBool 								iOfflineEventReceived;
   816 		TBool 								iOfflineEventReceived;
       
   817 		
       
   818 		TBool									iFeatMgrInitialized;
       
   819 		
       
   820 		CDeltaTimer* 						iDeltaTimer;
       
   821 		TCallBack 							iDeltaTimerCallBack;
       
   822 		TDeltaTimerEntry 					iDeltaTimerEntry;
   730 
   823 
   731 	private: // For testing purposes
   824 	private: // For testing purposes
   732 #ifdef CPPUNIT_TEST
   825 #ifdef CPPUNIT_TEST
   733 		friend class CSIPProfileServerCoreTest;
   826 		friend class CSIPProfileServerCoreTest;
   734 		friend class CSIPProfileCSSessionTest;
   827 		friend class CSIPProfileCSSessionTest;