realtimenetprots/sipfw/ProfileAgent/profile_fsm/inc/sipprofilequeuehandling.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2006-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        : sipprofilequeuehandling.h
       
    16 * Part of     : sip profile fsm
       
    17 * Interface   : Internal IF
       
    18 * Version     : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @internalComponent
       
    27 */
       
    28 
       
    29 #ifndef CSIPPRROFILEQUEUEHANDLING_H
       
    30 #define CSIPPRROFILEQUEUEHANDLING_H
       
    31 
       
    32 //INCLUDES 
       
    33 #include "sipprofilequeueitem.h"
       
    34 #include <e32base.h>
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class  MSIPProfileFSMUser;
       
    38 class CSIPConcreteProfile;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 *  A class for maintaining the queue handling for profiles which 
       
    43 *  are pending for registration or deregistration.
       
    44 *  Class stores the arrays of profiles.
       
    45 *
       
    46 *  @lib sipprofilefsm.lib
       
    47 */
       
    48 class CSIPProfileQueueHandling : public CBase
       
    49 	{
       
    50 	public:
       
    51 
       
    52 		/**
       
    53         * Two-phased constructor.
       
    54 		* @param aUser user for the state machine
       
    55         */
       
    56 		IMPORT_C static CSIPProfileQueueHandling* NewL(
       
    57 		    MSIPProfileFSMUser& aUser );
       
    58 
       
    59    		/**
       
    60         * Two-phased constructor.
       
    61         * @param aUser user for the state machine
       
    62         */
       
    63 		IMPORT_C static CSIPProfileQueueHandling* NewLC(
       
    64 		    MSIPProfileFSMUser& aUser );
       
    65 
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69 		IMPORT_C ~CSIPProfileQueueHandling();
       
    70 		
       
    71 
       
    72 	public: // New functions
       
    73 	
       
    74 		IMPORT_C TBool AddRegisterToQueueL( 
       
    75 		    CSIPConcreteProfile& aSIPConcreteProfile,
       
    76 		    TBool aRetryRegistration );	
       
    77 	
       
    78 		IMPORT_C TBool AddDeregisterToQueueL( 
       
    79 		    CSIPConcreteProfile& aSIPConcreteProfile );
       
    80 
       
    81 		/**
       
    82 		* After final response is received, queue of profiles
       
    83 		* which are waiting deregistration is checked.
       
    84 		* If there is found profile with the same registrar as 
       
    85 		* input profile aSIPConcreteprofile has, that profile is removed 
       
    86 		* from queue and registration is continued with that profile.
       
    87 		*/
       
    88 		IMPORT_C void RegisterFromQueueL( 
       
    89 		    CSIPConcreteProfile& aSIPConcreteProfile );
       
    90 
       
    91 		/**
       
    92 		* Check if queue has profile which has 
       
    93 		* SecurityNegotiationEnabled and does not has HttpDigestSettings
       
    94 		* configured.
       
    95 		* return ETrue in that case.
       
    96 		*/
       
    97 		IMPORT_C TBool FoundIPSecProfileCandidate();
       
    98 
       
    99 		/**
       
   100 		* Check if queue has profile which has 
       
   101 		* SecurityNegotiationEnabled and does not has HttpDigestSettings
       
   102 		* configured.If profile found, it will be removed from queue
       
   103 		* and will be returned.Input value aRegistering get value EFalse if profile 
       
   104 		* found from deregistering queue, otherwise value is ETrue;
       
   105 		* Return NULL and ETrue, if no profile found.
       
   106 		* return .
       
   107 		*/
       
   108 		IMPORT_C CSIPConcreteProfile* IPSecProfileCandidate(TBool& aRegistering);
       
   109 		
       
   110 
       
   111         /**
       
   112 		* Check if queue has profile which is waiting for allowed network. 
       
   113 		* A profile may be configured so that it can be used only in home network
       
   114 		* or used in roaming state only if user has explicitly enabled it.
       
   115 		* @param aOnHomeNetwork ETrue if phone is currently on home nw, EFalse
       
   116 		*        if phone is roaming
       
   117 		* @return profile to be registered or NULL
       
   118 		*/
       
   119         IMPORT_C CSIPConcreteProfile* WaitingForAllowedNetworkProfile( 
       
   120             TBool aOnHomeNetwork );
       
   121         
       
   122         IMPORT_C CSIPConcreteProfile* RemoveProfileFromRegQueueL(
       
   123             CSIPConcreteProfile& aSIPConcreteProfile);                
       
   124                             
       
   125         /**
       
   126 		* Check if both (registration and deregistration) queues are empty.
       
   127 		* @return ETrue if both queues are empty
       
   128 		*/
       
   129         IMPORT_C TBool IsEmpty() const;
       
   130 
       
   131         /*
       
   132         * Cleanup of queue, profiles which have been changed from auto 
       
   133         * registration mode to when needed or which don't have any users
       
   134         * are removed.
       
   135         */
       
   136         IMPORT_C void Cleanup( CSIPConcreteProfile& aOldProfile,
       
   137                                CSIPConcreteProfile* aNewProfile );
       
   138         
       
   139         /**
       
   140 		* Check if profile is in queue 
       
   141 		* Return ETrue, if profile found.
       
   142 		*/     
       
   143         IMPORT_C TBool IsInQueue(
       
   144             CSIPConcreteProfile& aSIPConcreteProfile);                
       
   145 
       
   146 		/**
       
   147 		* Checks whether registration is allowed in current network 
       
   148 		* for the given profile
       
   149 		* @param aSIPConcreteProfile the profile to be checked
       
   150 		* @param aOnHomeNetwork ETrue if the phone is currently on home network, 
       
   151 		*        EFalse if the phone is roaming
       
   152 		* @return ETrue if registration is allowed
       
   153 		*/
       
   154 		IMPORT_C TBool IsRegistrationAllowed(
       
   155 		    CSIPConcreteProfile& aSIPConcreteProfile,
       
   156 		    TBool aOnHomeNetwork);
       
   157 
       
   158     public: // New functions
       
   159     
       
   160 		/**
       
   161 		* Checks if registration/deregistration should be put
       
   162 		* in que to wait, because there is registration/deregistration
       
   163 		* with same registrar address pending.
       
   164 		* @return ETrue if should be put into que to wait.
       
   165 		*/
       
   166 		TBool AddIntoQueue( CSIPConcreteProfile& aSIPConcreteProfile );
       
   167 
       
   168 		/**
       
   169 		* aSIPConcreteProfile is added into queue ,
       
   170 		* until there is no more registration/deregistration
       
   171 		* with same registration address pending final response.
       
   172 		* @return ETrue if profile was added
       
   173 		*/
       
   174 		TBool AddIntoDeregisterQueueL( 
       
   175 		    CSIPConcreteProfile& aSIPConcreteProfile );
       
   176 
       
   177 		/**
       
   178 		* aSIPConcreteProfile is added into queue ,
       
   179 		* until there is no more registration/deregistration
       
   180 		* with same registration address pending final response.
       
   181 		* @return ETrue if profile was added
       
   182 		*/
       
   183 		TBool AddIntoRegisterQueueL( 
       
   184 		    CSIPConcreteProfile& aSIPConcreteProfile,
       
   185 		    TBool aRetryRegistration );
       
   186     
       
   187 		/**
       
   188 		* After final response is received, queue of profiles
       
   189 		* which are waiting deregistration is checked.
       
   190 		* If there is found profile with the same registrar as 
       
   191 		* input profile aSIPConcreteprofile has, that profile is removed 
       
   192 		* from queue and deregistration is continued with that profile.
       
   193 		*/
       
   194 		TBool CheckDeregisterQueueL( 
       
   195 		    CSIPConcreteProfile& aSIPConcreteProfile );
       
   196 
       
   197 		/**
       
   198 		* After final response is received, queue of profiles
       
   199 		* which are waiting registration is checked.
       
   200 		* If there is found profile with the same registrar as 
       
   201 		* input profile aSIPConcreteprofile has, that profile is removed 
       
   202 		* from queue and registration is continued with that profile.
       
   203 		*/
       
   204 		TBool CheckRegisterQueueL( 
       
   205 		    CSIPConcreteProfile& aSIPConcreteProfile );
       
   206 		
       
   207 		/**
       
   208 		* If from aProfileArray is found a profile with the same 
       
   209 		* registrar as input profile aSIPConcreteprofile has, 
       
   210 		* that profile is removed from queue and returned.
       
   211 		*/
       
   212 		TInt FindIndex(
       
   213             CSIPConcreteProfile& aSIPConcreteProfile,
       
   214             RArray<TSIPProfileQueueItem>& aProfileArray );
       
   215 
       
   216     private: // New functions
       
   217     
       
   218         TBool AddToQueueNoDuplicatesL( 
       
   219             RArray<TSIPProfileQueueItem>& aProfileArray,
       
   220             TSIPProfileQueueItem& aProfileItem );
       
   221     
       
   222         void QueueCleanup( RArray<TSIPProfileQueueItem>& aProfileArray,
       
   223                            CSIPConcreteProfile& aOldProfile,
       
   224                            CSIPConcreteProfile* aNewProfile );
       
   225 
       
   226 		/**
       
   227 		* Constructor
       
   228 		*/
       
   229 	    CSIPProfileQueueHandling( MSIPProfileFSMUser& aUser );
       
   230 	    
       
   231 	    void ConstructL();
       
   232 
       
   233 	private: //data
       
   234 	
       
   235 	    MSIPProfileFSMUser& iUser;
       
   236 		RArray<TSIPProfileQueueItem> iRegisteringQueue;
       
   237 		RArray<TSIPProfileQueueItem> iDeregisteringQueue;
       
   238 		
       
   239 	private: // For testing purposes
       
   240 	
       
   241         #ifdef CPPUNIT_TEST	
       
   242 	    	friend class CSIPProfileQueueHandlingTest;
       
   243         #endif
       
   244 	};
       
   245 
       
   246 #endif // CSIPPRROFILEQUEUEHANDLING_H