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