realtimenetprots/sipfw/ProfileAgent/Server/Inc/SipProfileServerCore.h
changeset 0 307788aac0a8
child 4 dd3853b8dc3f
child 15 8248b03a2669
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2007-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        : SipProfileServerCore.h
       
    16 * Part of     : SIP Profile Server
       
    17 * Interface   : private
       
    18 * The class providing core functionality of profile server
       
    19 * Version     : 1.0
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 /**
       
    27  @internalComponent
       
    28 */
       
    29 
       
    30 #ifndef CSIPPROFILESERVERCORE_H
       
    31 #define CSIPPROFILESERVERCORE_H
       
    32 
       
    33 //  INCLUDES
       
    34 #include "sipconcreteprofile.h"
       
    35 #include "sipprofileagentobserver.h"
       
    36 #include "sipprofileerrorhandler.h"
       
    37 #include <sipsystemstateobserver.h>
       
    38 #include <e32base.h>
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CSIPProfileCSServer;
       
    42 class CSIPProfileStorage;
       
    43 class CSIPProfileStorageSecureBackup;
       
    44 class CSIPProfileCacheItem;
       
    45 class MSIPExtendedConcreteProfileObserver;
       
    46 class CSIPProfilePlugins;
       
    47 class CSIPPluginDirector;
       
    48 class CSIPProfileState;
       
    49 class CSIPProfileStateUnregistered;
       
    50 class CSIPProfileStateRegistered;
       
    51 class CSIPProfileStateUnregInProg;
       
    52 class CSIPProfileStateRegInProg;
       
    53 class CSIPProfileStateWaitForIAP;
       
    54 class CSIPProfileStateWaitForPermission;
       
    55 class CSIPProfileStateMigratingToNewIAP;
       
    56 class CSIPProfileStateUnregisteringOldIAP;
       
    57 class CImplementationInformation;
       
    58 class CSipAlrHandler;
       
    59 class CSipAlrMigrationController;
       
    60 class CSipSystemStateMonitor;
       
    61 
       
    62 // CLASS DECLARATION
       
    63 
       
    64 /**
       
    65  * The class providing core functionality of profile server.
       
    66  */
       
    67 class CSIPProfileServerCore : public CBase, 
       
    68                               public MSIPProfileAgentObserver,
       
    69                               public MSipProfileErrorHandler,
       
    70                               public MSipSystemStateObserver
       
    71 	{
       
    72 	public: // Constructors and destructor
       
    73     
       
    74 	    /**
       
    75         * Two-phased constructor.
       
    76         * @param aServer server of the session
       
    77 		* @return new instance
       
    78         */
       
    79 		static CSIPProfileServerCore* NewL();
       
    80 
       
    81 	    /**
       
    82         * Two-phased constructor.
       
    83         * @param aServer server of the session
       
    84 		* @return new instance
       
    85         */
       
    86 		static CSIPProfileServerCore* NewLC();
       
    87 
       
    88 	    /**
       
    89         * Destructor.
       
    90         */
       
    91 		~CSIPProfileServerCore();
       
    92 
       
    93 	public: // From MSIPProfileAgentObserver
       
    94 
       
    95 		void SIPProfileStatusEvent(
       
    96 		    CSIPConcreteProfile& aProfile,
       
    97 		    TUint32 aContextId);
       
    98 
       
    99 		void SIPProfileErrorEvent(
       
   100 		    CSIPConcreteProfile& aProfile,
       
   101 		    TInt aError);
       
   102 
       
   103 		TBool ProceedRegistration(CSIPConcreteProfile& aProfile, TInt aError);
       
   104 		
       
   105         void GetFailedProfilesL(
       
   106             const TSIPProfileTypeInfo& aType,
       
   107             RPointerArray<CSIPConcreteProfile>& aFailedProfiles ) const;
       
   108 
       
   109 	public: // MSipProfileErrorHandler
       
   110 
       
   111 		TBool HandleProfileError(CSIPProfileCacheItem& aItem, TInt aOwnError);
       
   112 
       
   113 	public: // MSipSystemStateObserver
       
   114 
       
   115         void SystemVariableUpdated( 
       
   116             CSipSystemStateMonitor::TSystemVariable aVariable,
       
   117     		TInt aObjectId,
       
   118     		TInt aValue );
       
   119 
       
   120     public: // New functions
       
   121 
       
   122 	    /**
       
   123         * Stores client observer for sending events
       
   124 		* @param aObserver observer to be stored
       
   125         */
       
   126 		void SessionRegisterL(
       
   127 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   128 
       
   129 	    /**
       
   130         * Removes client observer
       
   131 		* @param aObserver observer to be removed
       
   132         */
       
   133 		void SessionCleanup(
       
   134 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   135 
       
   136 	    /**
       
   137         * Gets profile plugins containing plugins type info
       
   138 		* @return profile plugins containing plugins type info
       
   139         */
       
   140 		const CSIPProfilePlugins& ProfilePluginsL();
       
   141 
       
   142 	    /**
       
   143         * Adds profile into permanent store, ownership is transferred
       
   144 		* @param aProfile a stored profile
       
   145 		* @param aObserver client observer of the profile
       
   146         */
       
   147 		void AddProfileL(CSIPConcreteProfile* aProfile,
       
   148 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   149 
       
   150 	    /**
       
   151         * Does the first phase of a profile update, by making update to
       
   152         * permanent store.
       
   153 		* @param aProfile Profile to store, ownership is transferred.
       
   154 		* @param aObserver client observer of the profile
       
   155 		* @return ETrue If can proceed to the next phase of the update
       
   156 		*		  EFalse Must queue the update
       
   157         */
       
   158 		TBool UpdateProfileToStoreL(CSIPConcreteProfile* aProfile,
       
   159 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   160 
       
   161 	    /**
       
   162         * Removes profile from permanent store
       
   163 		* @param aProfileId a removed profile id
       
   164         */
       
   165 		void RemoveProfileL(TUint32 aProfileId);
       
   166 
       
   167 	    /**
       
   168         * Updates profile registration if needed
       
   169 		* @param aProfileId a registered profile id
       
   170 		* @param aObserver client observer of the profile
       
   171         */
       
   172 		void UpdateRegistrationL(TUint32 aProfileId,
       
   173 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   174 
       
   175 	    /**
       
   176         * Enables profile for use
       
   177 		* @param aProfileId a enabled profile id
       
   178 		* @param aObserver client observer of the profile
       
   179 		* @return status of the profile
       
   180         */
       
   181 		CSIPConcreteProfile::TStatus EnableProfileL(
       
   182 			TUint32 aProfileId,
       
   183 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   184 
       
   185 	    /**
       
   186         * Disables profile from use
       
   187 		* @param aProfileId a enabled profile id
       
   188 		* @param aObserver client observer of the profile
       
   189 		* @return status of the profile
       
   190         */
       
   191 		CSIPConcreteProfile::TStatus DisableProfileL(
       
   192 			TUint32 aProfileId,
       
   193 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   194 
       
   195 		/**
       
   196 		* Force disables profile from use
       
   197 		* @param aProfileId a enabled profile id
       
   198 		* @param aObserver client observer of the profile
       
   199 		* @return status of the profile
       
   200 		*/
       
   201 		CSIPConcreteProfile::TStatus ForceDisableProfileL(
       
   202 			TUint32 aProfileId,
       
   203 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   204 		
       
   205 	    /**
       
   206         * Gets number of users of a profile
       
   207 		* @param aProfileId a enabled profile id
       
   208 		* @return number of users
       
   209         */
       
   210 		TInt ProfileUsageL(TUint32 aProfileId) const;
       
   211 
       
   212 	    /**
       
   213         * Gets profile.
       
   214 		* This method should only be used for calculating profile size.
       
   215 		* @param aProfileId a required profile id
       
   216 		* @return Found profile, or NULL if not found. Ownership is not
       
   217 		*		  transferred.
       
   218         */
       
   219 		const CSIPConcreteProfile* Profile(TUint32 aProfileId) const;
       
   220 
       
   221 	    /**
       
   222         * Gets default profile
       
   223 		* Ownership is not transferred.
       
   224 		* This method should only be used for calculating profile size
       
   225 		* @return profile
       
   226         */
       
   227 		const CSIPConcreteProfile* ProfileDefaultL();
       
   228 	
       
   229 	    /**
       
   230         * Gets profile.
       
   231 		* @param aProfileId a required profile id
       
   232 		* @param aObserver client observer of the profile
       
   233 		* @return Found profile
       
   234 		* @leave KErrNotFound if profile was not found
       
   235         */
       
   236 		CSIPConcreteProfile& ProfileL(
       
   237 			TUint32 aProfileId,
       
   238 			const MSIPExtendedConcreteProfileObserver& aObserver) const;
       
   239 	
       
   240 	    /**
       
   241         * Gets updated profile to refresh previously fetched data.
       
   242 		* @param aProfileId a required profile id
       
   243 		* @param aObserver client observer of the profile
       
   244 		* @return Profile
       
   245         */
       
   246 		CSIPConcreteProfile& ProfileRefreshL(
       
   247 			TUint32 aProfileId,
       
   248 			const MSIPExtendedConcreteProfileObserver& aObserver) const;
       
   249 
       
   250 		/**
       
   251 		* Creates new profile prefilled with default values.
       
   252 		* Ownership is transferred.
       
   253 		* @aParam aType type to match
       
   254 		* @return new instance of CSIPConcreteProfile
       
   255 		*/
       
   256 		CSIPConcreteProfile* CreateProfileL(const TSIPProfileTypeInfo& aType);
       
   257 
       
   258 	    /**
       
   259         * Gets array of all profiles
       
   260 		* @param aObserver client observer of the profiles
       
   261 		* @param aArray array to store profiles
       
   262         */
       
   263 		void ProfilesL(const MSIPExtendedConcreteProfileObserver* aObserver,
       
   264 			RPointerArray<CSIPConcreteProfile>& aArray) const;
       
   265 
       
   266 		/**
       
   267         * Gets array of profiles with matching AOR
       
   268 		* @param aAOR AOR to match
       
   269 		* @param aObserver client observer of the profiles
       
   270 		* @param aArray array to store profiles
       
   271         */
       
   272 		void ProfilesByAORL(const TDesC8& aAOR,
       
   273 			const MSIPExtendedConcreteProfileObserver* aObserver,
       
   274 			RPointerArray<CSIPConcreteProfile>& aArray) const;
       
   275 
       
   276 	    /**
       
   277         * Gets array of profiles with matching type
       
   278 		* @param aType type to match
       
   279 		* @param aObserver client observer of the profiles
       
   280 		* @param aArray array to store matching profiles
       
   281         */
       
   282 		void ProfilesByTypeL(const TSIPProfileTypeInfo& aType, 
       
   283 			const MSIPExtendedConcreteProfileObserver* aObserver,
       
   284 			RPointerArray<CSIPConcreteProfile>& aArray) const;
       
   285 
       
   286 	    /**
       
   287         * Clears client observer from profile
       
   288 		* @param aProfileId a required profile id
       
   289 		* @param aObserver client observer of the profile
       
   290         */
       
   291 		void DeleteProfileL(TUint32 aProfileId, 
       
   292 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   293 
       
   294 		/**
       
   295         * Checks if server can be stopped
       
   296 		* @return ETrue, if there are no clients using the profiles
       
   297 		*		  and there are not autoregistered profiles to be managed
       
   298         */
       
   299 		TBool CanServerStop() const;
       
   300 
       
   301 		/**
       
   302         * Checks if server is currently being backupped/restored
       
   303 		* @return ETrue, if server is currently being backupped/restored
       
   304 		*		  , EFalse otherwise
       
   305         */
       
   306 		TBool BackupInProgress() const;
       
   307 
       
   308 	    /**
       
   309         * Sends registration status event to observers of the profile
       
   310 		* @param aItem holds profile and observers
       
   311         */
       
   312 		void SendRegistrationStatusEventL(CSIPProfileCacheItem& aItem) const;
       
   313 
       
   314 	    /**
       
   315         * Sends unregistered status event to observers of the profile
       
   316 		* @param aItem holds profile and observers
       
   317         */
       
   318 		void SendUnregisteredStatusEventL(CSIPProfileCacheItem& aItem) const;
       
   319 
       
   320 	    /**
       
   321         * Sends error event to observers of the profile
       
   322 		* @param aItem holds profile and observers
       
   323 		* @param aStatus status indicating if error occurred
       
   324 		*		  during registering (ERegistrationInProgress)
       
   325 		*		  or deregistering (EUnregistrationInProgress)
       
   326 		* @param aError error code
       
   327 		* @return system wide error code on failure
       
   328         */
       
   329 		TInt SendErrorEvent(CSIPProfileCacheItem& aItem,
       
   330 							CSIPConcreteProfile::TStatus aStatus,
       
   331 							TInt aError) const;
       
   332 	
       
   333 	    /**
       
   334         * Sends profile added event to all clients
       
   335 		* @param aProfile added profile
       
   336         */
       
   337 		void SendProfileAddedEvent(const CSIPConcreteProfile& aProfile) const;
       
   338 	
       
   339 	    /**
       
   340         * Sends profile update event to observers of the profile
       
   341 		* @param aItem Holds the observers
       
   342 		* @param aProfile Profile that has been updated
       
   343         */
       
   344 		void SendProfileUpdatedEventL(const CSIPProfileCacheItem& aItem,
       
   345 			const CSIPConcreteProfile& aProfile) const;
       
   346 
       
   347 	    /**
       
   348         * Sends profile remove event to observers of the profile
       
   349 		* @param aItem holds profile and observers
       
   350         */
       
   351 		void SendProfileRemovedEventL(CSIPProfileCacheItem& aItem) const;		
       
   352 
       
   353 		/**
       
   354 		* Storage notifies that store file must be released. This
       
   355 		* occurs during backup/restore process
       
   356 		* aParam aRestoreOngoing ETrue if restore is ongoing,
       
   357 		*						 EFalse if backup is ongoing
       
   358 		*/
       
   359 		void ReleaseStorage(TBool aRestoreOngoing);
       
   360 
       
   361 		/**
       
   362 		* Storage notifies that store file can again be reserved. This
       
   363 		* occurs during backup/restore process
       
   364 		* aParam aRestoreOngoing ETrue if restore is ongoing,
       
   365 		*						 EFalse if backup is ongoing
       
   366 		*/
       
   367 		void ReserveStorage(TBool aRestoreOngoing);
       
   368 		
       
   369 		/**
       
   370 		* Allows the migration from the old
       
   371 		*  IAP to the new one.
       
   372 		* @param aProfileId the SIP profile id
       
   373 		* @param aIapId the new IAP id
       
   374 		* @param aObserver Observer
       
   375 		*/
       
   376 		void AllowMigrationL(TUint32 aProfileId,
       
   377 			TUint32 aIapId,
       
   378 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   379 		
       
   380 		/**
       
   381 		* Disallows the migration from the 
       
   382 		* old IAP to the new one.
       
   383 		* @param aProfileId the SIP profile id
       
   384 		* @param aIapId the new IAP id.
       
   385 		* @param aObserver Observer
       
   386 		*/
       
   387 		void DisallowMigrationL(TUint32 aProfileId,
       
   388 			TUint32 aIapId,
       
   389 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   390 
       
   391 		/**
       
   392         * Refreshes the list of available IAPs for a profile.
       
   393 		* @param aProfileId the SIP profile id
       
   394 		*/
       
   395 		void RefreshIapAvailabilityL(TUint32 aProfileId);
       
   396 
       
   397 		/**
       
   398         * Migrating to an IAP has been initiated.
       
   399 		* @param aItem Profile cache item
       
   400 		* @param aSnapId SNAP id
       
   401 		* @param aIapId IAP id
       
   402 		*/
       
   403 		void MigrationStartedL(const CSIPProfileCacheItem& aItem,
       
   404 							   TUint32 aSnapId,
       
   405 							   TUint32 aNewIapId) const;
       
   406 
       
   407 		/**
       
   408         * Migrating to an IAP has been completed successfully.
       
   409 		* @param aItem Profile cache item
       
   410 		* @param aSnapId SNAP id
       
   411 		* @param aIapId IAP id
       
   412 		*/
       
   413 		void MigrationCompletedL(const CSIPProfileCacheItem& aItem,
       
   414 							     TUint32 aSnapId,
       
   415 							     TUint32 aNewIapId) const;
       
   416 
       
   417 		/**
       
   418         * Forward an ALR related error to client. These errors include etc.
       
   419         * "migration failed".
       
   420 		* @param aItem Profile cache item
       
   421 		* @param aError Error code.
       
   422 		* @param aSnapId SNAP id
       
   423 		* @param aIapId IAP id
       
   424 		* @return system wide error code on failure
       
   425 		*/
       
   426 		TInt PassAlrErrorToClient(const CSIPProfileCacheItem& aItem,
       
   427 								  TInt aError,
       
   428 								  TUint32 aSnapId,
       
   429 								  TUint32 aIapId) const;
       
   430 
       
   431 		/**
       
   432         * Gets the migration controller of the given SNAP id. If a controller
       
   433         * does not exists, creates a new one.
       
   434 		* @param aSnapId SNAP id
       
   435 		* @return Migration controller, ownership is not transferred.
       
   436 		*/
       
   437 		CSipAlrMigrationController& MigrationControllerL(TUint32 aSnapId);
       
   438 
       
   439 		CSIPProfileState& UnregisteredState();
       
   440 
       
   441 		TUint32 GenerateProfileIdL();
       
   442 
       
   443 		/**
       
   444 		 * Sends forcibly disable profile added event to all clients
       
   445 		 * @param aProfileId: Id of the profile being disabled forcibly 
       
   446 		 */
       
   447 		void SendProfileForciblyDisabledEvent(const CSIPProfileCacheItem& aItem) const;
       
   448 		
       
   449       /**
       
   450         * Gets cached profile, leave if not found
       
   451         * ownership is not transfered
       
   452         * @param aProfileId id of profile. 
       
   453         * @return profile cache item 
       
   454         */
       
   455         CSIPProfileCacheItem* ProfileCacheItemL(TUint32 aProfileId) const;
       
   456 
       
   457 	private:
       
   458 
       
   459 		/**
       
   460 		* Default constructor
       
   461 		* @param aServer server of the session
       
   462 		*/
       
   463 		CSIPProfileServerCore();
       
   464 
       
   465 		/**
       
   466 		* Symbian 2nd phase constructor
       
   467 		*/
       
   468 		void ConstructL();
       
   469 
       
   470 		/**
       
   471         * Sends status event to observers of the profile
       
   472 		* @param aItem holds profile and observers
       
   473         */
       
   474 		void SendStatusEventL(CSIPProfileCacheItem& aItem, 
       
   475 							  CSIPConcreteProfile::TStatus aStatus) const;
       
   476 
       
   477 		/**
       
   478 		* Loads profiles from store to cache, register
       
   479 		* markes as autoregistration on.
       
   480 		* Runned after server is started and after
       
   481 		* store file is modified by external party
       
   482 		* like backup system.
       
   483 		*/
       
   484 		void LoadProfilesL(TBool aNotifyProfileCreation);
       
   485 
       
   486 		/**
       
   487 		* Terminates usage of profiles and cleans cache.
       
   488 		* Runned when external party has modified store.
       
   489 		*/
       
   490 		void TerminateProfilesL();
       
   491 
       
   492 		/**
       
   493 		* Gets cached profile, returns 0 if not found
       
   494 		* ownership is not transfered
       
   495 		* @param aProfileId id of profile. 
       
   496 		* @return profile cache item 
       
   497 		*/
       
   498 		CSIPProfileCacheItem* ProfileCacheItem(TUint32 aProfileId) const;
       
   499 
       
   500 		/**
       
   501 		* Gets cached profile, returns 0 if not found
       
   502 		* ownership is not transfered
       
   503 		* @param aIndex, index of item in array 
       
   504 		* @return profile cache item 
       
   505 		*/
       
   506 		CSIPProfileCacheItem* FindProfileCacheItem(TInt aIndex) const;
       
   507 
       
   508 		/**
       
   509 		* Checks if profile is cached
       
   510 		* @param aProfileId id of profile. 
       
   511 		* @return index of profile, KErrNotFound if not found 
       
   512 		*/
       
   513 		TInt ProfileCached(TUint32 aProfileId) const;
       
   514 
       
   515 		/**
       
   516 		* Searches the profile cache for an item with a mathing storage id.
       
   517 		* @param aStorageId Storage id
       
   518 		* @return Found item
       
   519 		* @leave KErrNotFound If matching item was not found
       
   520 		*/
       
   521 		CSIPProfileCacheItem&
       
   522 			ProfileCacheItemByStorageIdL(TUint32 aStorageId) const;
       
   523 
       
   524 		/**
       
   525 		* Searches the profile cache for an item with a mathing storage id.
       
   526 		* @param aStorageId Storage id
       
   527 		* @return Found item or NULL if not found. Ownership is not transferred.
       
   528 		*/
       
   529 		CSIPProfileCacheItem*
       
   530 			ProfileCacheItemByStorageId(TUint32 aStorageId) const;
       
   531 
       
   532 		/**
       
   533 		* Registers profiles marked as auto-register in startup
       
   534 		*/
       
   535 		void RegisterProfiles();
       
   536 		
       
   537 		/**
       
   538 		* Add a profile to array and check if the observer should be added to
       
   539 		* the profile.
       
   540 		* @param aObserver Observer
       
   541 		* @param aArray Array where the profile is added
       
   542 		* @param aItem Profile cache item containing the profile
       
   543 		*/
       
   544 		void HandleMatchingProfileL(
       
   545 			const MSIPExtendedConcreteProfileObserver* aObserver,
       
   546 			RPointerArray<CSIPConcreteProfile>& aArray,
       
   547 			CSIPProfileCacheItem& aItem) const;
       
   548 
       
   549 	    /**
       
   550         * Removes client observer, leaves on failure
       
   551 		* @param aObserver observer to be removed
       
   552         */
       
   553 		void SessionCleanupL(
       
   554 			const MSIPExtendedConcreteProfileObserver& aObserver);
       
   555 
       
   556 	    /**
       
   557         * Converts ECom plugin into profile type
       
   558 		* @param aEcomInfo ECom plugin info
       
   559 		* @param aInfo returned profile type info
       
   560         */
       
   561 		void ConvertTypeInfoL(const CImplementationInformation& aEcomInfo,
       
   562 							  TSIPProfileTypeInfo& aInfo) const;
       
   563 
       
   564 	    /**
       
   565         * Checks if the server can stop, informs CS-server
       
   566 		* if can be stopped;
       
   567         */
       
   568 		void CheckServerStatus() const;
       
   569 
       
   570 	    /**
       
   571         * Get status weather error occurred during registration
       
   572 		* or deregistartion
       
   573 		* @param aItem profile cache item to be validated
       
   574 		* @return in progress status of cached profile
       
   575         */
       
   576 		CSIPConcreteProfile::TStatus ValidateErrorStatus(
       
   577 			CSIPProfileCacheItem& aItem) const;
       
   578 
       
   579 		/**
       
   580 		* Registration status event occurred.
       
   581 		* @param aProfileId a profile id
       
   582 		* @param aContextId a registration context identifier
       
   583 		*/
       
   584 		void SIPProfileStatusEventL(
       
   585 			TUint32 aProfileId,
       
   586 			TUint32 aContextId);
       
   587 
       
   588 	    /**
       
   589         * Handles possible asynchronous errors from plugin manager
       
   590 		* @param aItem profile item to be handled
       
   591 		* @param aStatus status indicating if error occurred
       
   592 		*		  during registering (ERegistrationInProgress)
       
   593 		*		  or deregistering (EUnregistrationInProgress)
       
   594 		* @param aError Error code to be handled
       
   595         */
       
   596 		void HandleAsyncError(CSIPProfileCacheItem& aItem,
       
   597 							  CSIPConcreteProfile::TStatus aStatus,
       
   598 							  TInt aError);
       
   599 
       
   600 		/**
       
   601 		* Storage notifies that store file must be released. This
       
   602 		* occurs during backup/restore process
       
   603 		* aParam aRestoreOngoing ETrue if restore is ongoing,
       
   604 		*						 EFalse if backup is ongoing
       
   605 		*/
       
   606 		void ReleaseStorageL(TBool aRestoreOngoing);
       
   607 
       
   608 		/**
       
   609 		* Storage notifies that store file can again be reserved. This
       
   610 		* occurs during backup/restore process
       
   611 		* aParam aRestoreOngoing ETrue if restore is ongoing,
       
   612 		*						 EFalse if backup is ongoing
       
   613 		*/
       
   614 		void ReserveStorageL(TBool aRestoreOngoing);
       
   615 
       
   616 	    /**
       
   617         * Cleans up array in case of failure
       
   618         * ownership of aArray is transferred
       
   619 		* @param aArray array to be cleaned up
       
   620         */
       
   621 		static void ResetAndDestroy(TAny* aArray);
       
   622 
       
   623 	    /**
       
   624         * Cleans up array in case of failure
       
   625         * ownership of aArray is transferred
       
   626 		* @param aArray array to be cleaned up
       
   627         */
       
   628 		static void ResetAndDestroyInfo(TAny* aArray);
       
   629 
       
   630 	    /**
       
   631         * Reverts back cache in case of failure      
       
   632 		* @param aItem cache cleanup item
       
   633         */
       
   634 		static void CrashRevert(TAny* aItem);
       
   635 		
       
   636 		/**
       
   637         * Handles the errors occured during the profile restore     
       
   638 		* @param aErr
       
   639 		* @param fileStore specifies the kind of the file on which 
       
   640 		* the storage error has occured
       
   641         */
       
   642 		void HandleProfileStorageErrorL(TInt aErr, TBool fileStore=EFalse);
       
   643 
       
   644 		/**
       
   645         * Remove the cached profile entry identified by aProfileId.
       
   646 		* @param aProfileId Profile id
       
   647         */
       
   648 		void RemoveProfileItem(TUint32 aProfileId);
       
   649 
       
   650 		/**
       
   651         * Removes unused migration controllers, except if it uses the specified
       
   652         * SNAP id.
       
   653 		* @param aSnapId SNAP id
       
   654         */
       
   655 		void RemoveUnusedMigrationControllers(TUint32 aSnapId);
       
   656 
       
   657 		void LoadSystemStateMonitorL();
       
   658 
       
   659 		/**
       
   660 		* Gets the default profile
       
   661 		* @return Pointer to the default profile, or NULL if not found.
       
   662 		*/
       
   663 		CSIPConcreteProfile* FindDefaultProfile() const;
       
   664 
       
   665         TBool ShouldChangeIap(CSIPConcreteProfile& aProfile, TInt aError) const;
       
   666 
       
   667         /**
       
   668         * @return ETrue if any registered profile is using aIap
       
   669         */
       
   670         TBool AnyRegisteredProfileUsesIap(TUint aIap) const;
       
   671         
       
   672         /**
       
   673         * Add profiles in Profile Cache
       
   674         * @param aProfiles Array of the profiles to be added
       
   675         * @param aNotifyProfileCreation specifies whether the notification to be sent to the profile clients
       
   676         */
       
   677         void AddProfilesInCacheL(RPointerArray<CSIPConcreteProfile>& aProfiles,TBool aNotifyProfileCreation);
       
   678         
       
   679 	private: // Data
       
   680 	
       
   681 		RFs										iFs;
       
   682 		TBool									iBackupInProgress;
       
   683 
       
   684 		// Owned
       
   685 		CSIPProfileCSServer*					iServer;
       
   686 		// Owned
       
   687 		CSIPProfileStorage*						iProfileStorage;
       
   688 		// Owned
       
   689 		CSIPProfileStorageSecureBackup*			iNotify;
       
   690 
       
   691 		// Array items are owned
       
   692 		RPointerArray<CSIPProfileCacheItem>		iProfileCache;
       
   693 		// Array items are not owned
       
   694 		RPointerArray<MSIPExtendedConcreteProfileObserver>
       
   695 												iObservers;
       
   696 
       
   697 		// Owned
       
   698 		CSIPProfilePlugins*						iProfilePlugins;
       
   699 		// Owned
       
   700 		CSIPPluginDirector*						iPluginDirector;
       
   701 		// Owned
       
   702 		CSIPProfileCacheItem*					iFindEntry;
       
   703 
       
   704 		// Profile states. Owned.
       
   705 		CSIPProfileStateUnregistered* 			iUnregistered;
       
   706 		CSIPProfileStateRegistered* 			iRegistered;
       
   707 		CSIPProfileStateUnregInProg* 			iUnregInProg;
       
   708 		CSIPProfileStateRegInProg* 				iRegInProg;
       
   709 		CSIPProfileStateWaitForIAP* 			iWaitForIAP;
       
   710 		CSIPProfileStateWaitForPermission* 		iWaitForPermission;
       
   711 		CSIPProfileStateMigratingToNewIAP*		iMigratingToNewIAP;
       
   712     	CSIPProfileStateUnregisteringOldIAP*	iUnregisteringOldIAP;
       
   713 
       
   714 		// Owned
       
   715 		CSipAlrHandler* 						iAlrHandler;
       
   716 
       
   717 		// Migration controllers. Array items are owned.
       
   718 		RPointerArray<CSipAlrMigrationController> iMigrationControllers;
       
   719 
       
   720 		// Owned
       
   721 		CSipSystemStateMonitor*				iSystemStateMonitor;
       
   722 
       
   723 		TBool 								iOfflineEventReceived;
       
   724 
       
   725 	private: // For testing purposes
       
   726 #ifdef CPPUNIT_TEST
       
   727 		friend class CSIPProfileServerCoreTest;
       
   728 		friend class CSIPProfileCSSessionTest;
       
   729 		friend class CSIPProfileCSServerTest;
       
   730 		friend class CSIPProfileStateTest;
       
   731 		friend class CSIPProfileStateRegInProgTest;
       
   732 		friend class CSIPProfileStateRegisteredTest;
       
   733 		friend class CSIPProfileStateUnregInProgTest;
       
   734 		friend class CSIPProfileStateUnregisteredTest;
       
   735 		friend class CSIPProfileStateWaitForIAPTest;
       
   736 		friend class CSIPProfileStateWaitForPermissionTest;
       
   737 		friend class CSIPProfileStateMigratingToNewIAPTest;
       
   738 		friend class CSIPProfileStateUnregisteringOldIAPTest;
       
   739 		friend class CSipAlrHandlerTest;
       
   740 		friend class CSIPProfileAlrTest;
       
   741 		friend class CSIPProfileCacheItemTest;
       
   742 #endif
       
   743 	};
       
   744 
       
   745 #endif // CSIPPROFILESERVERCORE_H