multimediacommsengine/tsrc/testdriver/siptester/src/CTcSIPProfileContainer.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 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:  See class definition below.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CTCSIPPROFILECONTAINER_H__
       
    19 #define __CTCSIPPROFILECONTAINER_H__
       
    20 
       
    21 // INCLUDES
       
    22 #include "CTcContextBase.h"
       
    23 #include "CTcIAPManager.h"
       
    24 #include <sipobserver.h>
       
    25 #include <sipprofileregistryobserver.h>
       
    26 #include <sipmanagedprofileregistry.h>
       
    27 #include <sipprofileregistry.h>
       
    28 
       
    29 #include <sipconnection.h>
       
    30 #include <sipconnectionobserver.h>
       
    31 #include <cdblen.h>
       
    32 
       
    33 #include "TTcSIPReceived.h"
       
    34 #include "TTcProfileReceived.h"
       
    35 
       
    36 #include "sipconnection.h"
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CTcSIPContext;
       
    40 
       
    41 // HELPER CLASSES
       
    42 class CTcSIPProfile : public CBase
       
    43 	    {
       
    44 	public:
       
    45 	
       
    46 	    /**
       
    47 	     * Create CTcSIPProfile item which is used for storing both
       
    48 	     * profile and its id
       
    49 	     *
       
    50 	     * @param aProfile, ownership is taken
       
    51 	     * @param aProfileId
       
    52 	     */
       
    53 	    CTcSIPProfile( CSIPProfile* aProfile, TInt aProfileId );
       
    54 	        
       
    55 	    /**
       
    56 	     * Destructor
       
    57          */
       
    58          ~CTcSIPProfile();
       
    59             
       
    60         /**
       
    61          * Returns pointer to owned profile
       
    62          *
       
    63          * @return reference to CSIPProfile
       
    64          */
       
    65         CSIPProfile& Profile();
       
    66         
       
    67         TInt ProfileId();
       
    68             
       
    69     private:
       
    70         
       
    71         CSIPProfile* iProfile;
       
    72         TInt iProfileId; 
       
    73 	    };
       
    74 	    
       
    75 class CTcSIPManagedProfile : public CBase
       
    76 	    {
       
    77 	public:
       
    78 	
       
    79 	    /**
       
    80 	     * Create CTcSIPProfile item which is used for storing both
       
    81 	     * profile and its id
       
    82 	     *
       
    83 	     * @param aManagedProfile, ownership is taken
       
    84 	     * @param aManagedProfileId
       
    85 	     */
       
    86 	    CTcSIPManagedProfile( CSIPManagedProfile* aManagedProfile, TInt aManagedProfileId );
       
    87 	        
       
    88 	    /**
       
    89 	     * Destructor
       
    90          */
       
    91          ~CTcSIPManagedProfile();
       
    92             
       
    93         /**
       
    94          * Returns pointer to owned profile
       
    95          *
       
    96          * @return reference to CSIPManagedProfile
       
    97          */
       
    98         CSIPManagedProfile& Profile();
       
    99             
       
   100         TInt ProfileId();
       
   101             
       
   102     private:
       
   103         
       
   104         CSIPManagedProfile* iManagedProfile;
       
   105         TInt iManagedProfileId; 
       
   106 	    };
       
   107 
       
   108 // CLASS DEFINITION
       
   109 /**
       
   110  * CTcSIPProfileContainer implements a container for multiple registry. 
       
   111  * Its task is also to observe and queue SIP notifications for
       
   112  * future use.
       
   113  */
       
   114 class CTcSIPProfileContainer
       
   115 	: public CBase,
       
   116       public MSIPProfileRegistryObserver
       
   117 	{
       
   118 	
       
   119 
       
   120 	
       
   121 	
       
   122 	public:	// Constructors and destructor
       
   123 
       
   124 		/**
       
   125 		 * Static constructor.
       
   126 		 *
       
   127 		 * @param aContext Reference to test context object.
       
   128 		 * @param aSip 
       
   129 		 * @return An initialized instance of this class.
       
   130 		 */
       
   131 		static CTcSIPProfileContainer* NewL( CTcSIPContext& aContext,
       
   132 											 CSIP& aSip );
       
   133 
       
   134 		/// Destructor
       
   135 		virtual ~CTcSIPProfileContainer();
       
   136 
       
   137 	private:
       
   138 
       
   139 		/**
       
   140 		 * Constructor.
       
   141 		 *
       
   142 		 * @param aContext Reference to test context object.
       
   143 		 * @param aIAPName Internet Access Point name to be used.
       
   144 		 */
       
   145 		CTcSIPProfileContainer( CTcSIPContext& aContext,
       
   146 								CSIP& aSip );
       
   147 
       
   148 		/// Default constructor. Not implementer.
       
   149 		CTcSIPProfileContainer();
       
   150 
       
   151 		/// 2nd phase constructor
       
   152 		void ConstructL();
       
   153 
       
   154 	public: // From MSIPProfileRegistryObserver
       
   155 	
       
   156         void ProfileRegistryEventOccurred(TUint32 aProfileId, TEvent aEvent);
       
   157         void ProfileRegistryErrorOccurred(TUint32 aProfileId, TInt aError);
       
   158 
       
   159     public : // new methods
       
   160         
       
   161          /**
       
   162 		 * Returns the first item off the receive queue (FIFO). If no
       
   163 		 * items are present, the function will wait for aTimeout seconds
       
   164 		 * and then try fetching again.
       
   165 		 *
       
   166 		 * @param aTimeOut Time in seconds waited for items to arrive.
       
   167 		 */
       
   168 		TTcProfileReceived ReceivedProfileItemL( TInt aTimeout );
       
   169 
       
   170 	    /**
       
   171 		 * Add the specified item to the received items queue.
       
   172 		 * The item is copied to the internal array.
       
   173 		 *
       
   174 		 * @param aItem Referece to a received object.
       
   175 		 */
       
   176 		void QueueProfileReceived( TTcProfileReceived& aItem );
       
   177 
       
   178 		/**
       
   179 		 * @return Reference to Profile Registry Admin interface.
       
   180 		 */
       
   181         inline CSIPManagedProfileRegistry& ManagedProfileRegistry()
       
   182 				{ return *iManagedProfileRegistry; };
       
   183 
       
   184 		/**
       
   185 		 * @return Reference to Profile Registry User interface.
       
   186 		 */
       
   187 		inline CSIPProfileRegistry& ProfileRegistry()
       
   188 				{ return *iProfileRegistry; };
       
   189 				
       
   190 				
       
   191 		/**
       
   192 		 * Store managed profile, cleanupstack is used internally so caller shouldn't use
       
   193 		 * Cleanupstack::PushL for aManagedProfile before calling the function
       
   194 		 *
       
   195 		 * @param aManagedProfile, ownership is taken
       
   196 		 */		
       
   197 	    void AddManagedProfileL( CSIPManagedProfile* aManagedProfile );
       
   198 	    
       
   199 		/**
       
   200 		 * Returns profile by its id from profiles array.
       
   201 		 * If profile doesnt's exist already in profiles array, new instance
       
   202 		 * will be created through profile registry and created profile will
       
   203 		 * be stored to profiles array
       
   204 		 *
       
   205 		 * @return reference to profile
       
   206          */
       
   207          CSIPProfile& GetProfileByIdL( TInt aProfileId );
       
   208          
       
   209         /**
       
   210 		 * Returns managed profile by its id from managed profiles array.
       
   211 		 * If managed profile doesnt's exist already in managed profiles array,
       
   212 		 * new instance will be created through managed profile registry and 
       
   213 		 * created managed profile will be stored to managed profiles array
       
   214 		 *
       
   215 		 * @return reference to managed profile
       
   216          */
       
   217          CSIPManagedProfile& GetManagedProfileByIdL( TInt aManagedProfileId );
       
   218          
       
   219         /**
       
   220 		 * Returns default profile as managed profile.
       
   221 		 *
       
   222 		 * @return reference to managed profile
       
   223          */
       
   224          CSIPManagedProfile& GetDefaultProfileL();
       
   225          
       
   226          /**
       
   227           * Deletes stored profile.
       
   228           *
       
   229           * @param aProfileId
       
   230           */
       
   231          void DeleteProfileById( TInt aProfileId );
       
   232          
       
   233          /**
       
   234           * Deletes stored managed profile.
       
   235           *
       
   236           * @param aManagedProfileId
       
   237           */
       
   238          void DeleteManagedProfileById( TInt aManagedProfileId );
       
   239          
       
   240 	private: // New methods
       
   241 
       
   242 		/**
       
   243 		 * CDeltaTimer callback. Called when the timer entry expires.
       
   244 		 *
       
   245 		 * @param aSelf Pointer to self
       
   246 		 * @return KErrNone
       
   247 		 */
       
   248 		static TInt ReceiveTimeout( TAny* aSelf );
       
   249 
       
   250 	private: // data
       
   251 
       
   252 		/// Active scheduler wrapper for async waiting. Owned.
       
   253 		CActiveSchedulerWait iActiveWait;
       
   254 
       
   255 		/// Reference to the test contextg. Not owned.
       
   256 		CTcSIPContext& iContext;
       
   257 
       
   258 		/// Timeout timer. Owned.
       
   259 		CDeltaTimer* iTimer;
       
   260 
       
   261 		/// Timeout entry. Owned.
       
   262 		TDeltaTimerEntry iReceiveTimeout;
       
   263 
       
   264 		/// SIP stack. Not Owned.
       
   265 		CSIP& iSip;
       
   266 
       
   267 		/// Admin interface to profile registry. Owned.
       
   268 		CSIPManagedProfileRegistry* iManagedProfileRegistry;
       
   269 
       
   270 		/// User interface to profile registry. Owned.
       
   271 		CSIPProfileRegistry* iProfileRegistry;
       
   272 
       
   273 		/// Array of received items. Owned.
       
   274 		CArrayFixSeg< TTcProfileReceived > iReceiveQueue;
       
   275 		
       
   276 		/// Array of profiles retrieved from ProfileRegistry
       
   277 		RPointerArray< CTcSIPProfile > iProfiles;
       
   278 		
       
   279 		/// Array of managed profiles retrieved profiles from ManagedProfileRegistry
       
   280 		RPointerArray< CTcSIPManagedProfile > iManagedProfiles;
       
   281 	    
       
   282 
       
   283 	};
       
   284 
       
   285 #endif // __CTCSIPPROFILECONTAINER_H__