realtimenetprots/sipfw/ProfileAgent/Server/Src/sipalrmigrationcontroller.h
changeset 0 307788aac0a8
child 37 0295359a7673
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          : sipalrmigrationcontroller.h
       
    16 * Part of       : SIP / SIP Profile Server
       
    17 * Version       : SIP/6.0 
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef CSIPALRMIGRATIONCONTROLLER_H
       
    29 #define CSIPALRMIGRATIONCONTROLLER_H
       
    30 
       
    31 // INCLUDES
       
    32 #include "sipalrobserver.h"
       
    33 #include <e32base.h>
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CSipAlrMonitor;
       
    37 class MSipAlrMigrationObserver;
       
    38 class TSipAlrMigrationObserverInfo;
       
    39 
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43 * Combines the migration permissions of all profiles using the same SNAP id.
       
    44 *
       
    45 * @lib sipsrofilesrv.exe
       
    46 */
       
    47 class CSipAlrMigrationController :
       
    48 	public CBase,
       
    49 	public MSipAlrObserver
       
    50 	{
       
    51 	public: // Enumerations
       
    52 
       
    53         enum TIapId
       
    54             {
       
    55             // The most recent IAP id offered to MSipAlrMigrationObserver
       
    56             EMostRecentIap = 0
       
    57             };
       
    58 
       
    59 	public:
       
    60     	static CSipAlrMigrationController* NewLC(CSipAlrMonitor& aAlrMonitor,
       
    61     											 TUint32 aSnapId);
       
    62 
       
    63     	~CSipAlrMigrationController();
       
    64 
       
    65 	public: // From MSipAlrObserver
       
    66 
       
    67 		void AlrEvent(MSipAlrObserver::TEvent aEvent,
       
    68 					  TUint32 aSnapId,
       
    69 					  TUint32 aIapId);
       
    70 
       
    71     public: // New functions
       
    72 
       
    73 		TUint32 SnapId() const;
       
    74 
       
    75 		/**
       
    76         * Check if any profile is using this instance.
       
    77         * @return ETrue At least one profile is using this migration controller
       
    78         *		  EFalse otherwise
       
    79         */
       
    80 		TBool IsUsed() const;
       
    81 
       
    82 		/**
       
    83         * A profile starts to listen for IAP notifications of the SNAP.
       
    84         * @param aObserver Observer to attach
       
    85         * @return Initial IAP id to use, or zero of no IAP is available yet
       
    86         */
       
    87         TUint32 AttachProfileL(MSipAlrMigrationObserver& aObserver);
       
    88 
       
    89 		/**
       
    90         * A profile quits listening IAP notifications of the SNAP.
       
    91         * @param aObserver Observer to detach
       
    92         */
       
    93 		void DetachProfile(MSipAlrMigrationObserver& aObserver);
       
    94 
       
    95 		/**
       
    96         * A new IAP became available.
       
    97         * @param aSnapId SNAP id
       
    98         * @param aNewIap IAP id
       
    99         */
       
   100 		void IapAvailable(TUint32 aSnapId, TUint32 aNewIapId);
       
   101 
       
   102 		/**
       
   103         * Profile cache item has formed its decision regarding the migration.
       
   104         * @param aObserver Observer who is now giving its answer
       
   105         * @param aAllow ETrue if this observer allows migration,
       
   106         *				EFalse otherwise
       
   107         * @param aIapId IAP id
       
   108         */
       
   109 		void SetMigrationPermission(MSipAlrMigrationObserver& aObserver,
       
   110 									TBool aAllow,
       
   111 									TUint32 aIapId = EMostRecentIap);
       
   112 
       
   113 		void RefreshIapAvailabilityL(TUint32 aSnapId);
       
   114 
       
   115 		TInt SetIapAcceptance(MSipAlrMigrationObserver& aObserver,
       
   116 							  TBool aIapWorks);
       
   117 							  
       
   118 		void ResetFlags();
       
   119 
       
   120 	private: // Constructors
       
   121 
       
   122 	    CSipAlrMigrationController(CSipAlrMonitor& aAlrMonitor,
       
   123 	    						   TUint32 aSnapId);
       
   124 
       
   125     private: // New functions
       
   126 
       
   127 		void SendMigrationResult(TUint32 aIapId, TBool aAllowed);
       
   128 
       
   129 		TInt FindIndex(MSipAlrMigrationObserver& aObserver) const;
       
   130 
       
   131 		TBool ObserversWaitingPermission() const;
       
   132 
       
   133 		TBool ObserversWaitingAcceptance() const;
       
   134 		
       
   135 		void NoNewIapAvailable() const;
       
   136 		
       
   137 		void OfferedIapRejected() const;
       
   138 
       
   139     private: // Data
       
   140 
       
   141 		// Not owned
       
   142     	CSipAlrMonitor& iAlrMonitor;
       
   143 
       
   144 		RArray<TSipAlrMigrationObserverInfo> iObservers;
       
   145 
       
   146 		// SNAP id that is monitored. Does not change.
       
   147 		const TUint32 iSnapId;
       
   148 
       
   149 		// The IAP id, that was most recently offered to observers with
       
   150 		// MSipAlrMigrationObserver::IapAvailableL.
       
   151 		TUint32 iOfferedIapId;
       
   152 
       
   153 		// Most recent IAP id, where the migration was allowed.
       
   154 		TUint32 iAllowedIapId;
       
   155 
       
   156 		// Is the migration to iOfferedIapId disallowed.
       
   157 		TBool iMigrationDisallowed;
       
   158 
       
   159 		// Used to prevent refreshing the IAP availability when it has already
       
   160 		// been done.
       
   161 		// ETrue if CSipAlrMonitor has been requested to refresh the IAP
       
   162 		// availability.
       
   163 		// Will be set to EFalse, when ALR monitor notifies about IAP, using
       
   164 		// MSipAlrObserver::IapAvailable.
       
   165 		TBool iRefreshIssued;
       
   166 
       
   167     private: // For testing purposes		
       
   168 #ifdef CPPUNIT_TEST
       
   169 		friend class CSipAlrMigrationControllerTest;    
       
   170         friend class CSIPProfileAlrTest;
       
   171         friend class CSIPProfileStateWaitForPermissionTest;
       
   172         friend class CSIPProfileCacheItemTest;
       
   173 #endif
       
   174     };
       
   175 
       
   176 #endif // CSIPALRMIGRATIONCONTROLLER_H