realtimenetprots/sipfw/SIP/ConnectionMgr/inc/CSipConnectionMgr.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-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          : CSipConnectionMgr.h
       
    16 * Part of       : ConnectionMgr
       
    17 * Version       : SIP/4.0 
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef __CSIPCONNECTIONMGR_H__
       
    29 #define __CSIPCONNECTIONMGR_H__
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32base.h>
       
    33 #include <in_sock.h>
       
    34 #include "MUriResolver.h"
       
    35 #include "SipStackServerDefs.h"
       
    36 #include "MConnectionStateObserver.h"
       
    37 #include "MSipConnectionMgr.h"
       
    38 #include "sipclient.h"
       
    39 #include "MSigComp.h"
       
    40 #include "MLocalName.h"
       
    41 #include "MSipConnectionOwner.h"
       
    42 #include "MSIPTransportMgr.h"
       
    43 #include <sipsystemstateobserver.h>
       
    44 #include "MSipCellularDataUsageObserver.h"
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 class CSipConnectionMgrStateBase;
       
    48 class MTransactionFinder;
       
    49 class MSIPResolvingResult;
       
    50 class MTimerManager;
       
    51 class CSipConnection;
       
    52 class CSIPResponse;
       
    53 class CSIPRequest;
       
    54 class MSigCompController;
       
    55 class CNetworkManager;
       
    56 class MSIPServerResolverObserver;
       
    57 class TSIPTransportParams;
       
    58 class CNetworkInfo;
       
    59 class MServerTaFactory;
       
    60 class CSIPNATTraversalController;
       
    61 class CSipSystemStateMonitor;
       
    62 class CSipCellularDataUsageMonitor;
       
    63 
       
    64 
       
    65 class CSipConnectionMgr : public CBase,
       
    66 	                      public MSipConnectionMgr,
       
    67 	                      public MSipUriResolver,
       
    68 	                      public MSigComp, 
       
    69 	                      public MLocalName,
       
    70 	                      public MSipConnectionOwner,
       
    71 	                      public MSIPTransportMgr,
       
    72 	                      public MSipSystemStateObserver,
       
    73 	                      public MSipCellularDataUsageObserver
       
    74 	                      
       
    75 	{
       
    76 public:
       
    77 
       
    78 		enum TICMPError
       
    79 			{
       
    80 			EHostUnreachable = 850,
       
    81 			ENetUnreachable,
       
    82 			EPortUnreachable,
       
    83 			EProtocolUnreachable
       
    84 			};
       
    85 
       
    86 public:
       
    87 
       
    88 	static CSipConnectionMgr* NewL(MTransactionFinder& aFinder, 
       
    89 		MServerTaFactory& aTaFactory, MTimerManager& aTimer, TUint aTOne, 
       
    90 		MConnectionStateObserver& aNetworkObserver);
       
    91 
       
    92 	static CSipConnectionMgr* NewLC(MTransactionFinder& aFinder, 
       
    93 		MServerTaFactory& aTaFactory, MTimerManager& aTimer, TUint aTOne, 
       
    94 		MConnectionStateObserver& aNetworkObserver);
       
    95 
       
    96 	~CSipConnectionMgr();
       
    97 
       
    98 	void RefreshConnectionL(TUint32 aIapId);
       
    99 	
       
   100 	TInt ConnectionErrorL(TUint32 aIapId);
       
   101 
       
   102 
       
   103 public: // From MSipConnectionMgr
       
   104 
       
   105     CSIPConnection::TState OpenL( const TSIPTransportParams& aParams );
       
   106 
       
   107     TBool IsOpen( const TSIPTransportParams& aParams );
       
   108 
       
   109 	void Close( const TSIPTransportParams& aParams );
       
   110 	
       
   111     void SetOptL( const TSIPTransportParams& aParams,
       
   112                   TUint aOptionName,
       
   113 	              TUint aOptionLevel,
       
   114 	              const TDesC8& aOption );
       
   115 	         	                         
       
   116     void SetOptL( const TSIPTransportParams& aParams,
       
   117                   TUint aOptionName,
       
   118 	              TUint aOptionLevel,
       
   119 	              TInt aOption); 	
       
   120 
       
   121 	void SendL( const TSIPTransportParams& aParams,
       
   122 	            CSIPRequest& aRequest,
       
   123 	            TBool aForceUDP,
       
   124 	            const CUri8* aOutboundProxy,
       
   125 			    const TInetAddr& aRemoteAddr, 
       
   126 			    TRequestStatus& aStatus );
       
   127 
       
   128     void SendL( const TSIPTransportParams& aParams,
       
   129 	            CSIPResponse& aResponse,
       
   130                 TTransactionId aId,
       
   131 			    TRequestStatus& aStatus );
       
   132 
       
   133     TInt CancelSend( TRequestStatus &aStatus );
       
   134 
       
   135 	TInt CancelResponseSend( TTransactionId aId, TBool aCancelAlso2xxResponses );
       
   136 
       
   137     void TcpDisconnect( const TSIPTransportParams& aParams,
       
   138 	                    const TInetAddr& aRemoteAddress );
       
   139 	                    
       
   140     void FreeResources( MSIPNATBindingObserver& aSIPNATBindingObserver );
       
   141 
       
   142 
       
   143 public: // From MSipUriResolver
       
   144 
       
   145     void GetByURIL( const CURIContainer& aURI,
       
   146                     RPointerArray<MSIPResolvingResult>& aResult,
       
   147 					const TSIPTransportParams& aParams,
       
   148 		            MSIPServerResolverObserver* aObserver );
       
   149 
       
   150 	void CancelGetByUri( MSIPServerResolverObserver* aObserver );
       
   151 
       
   152 
       
   153 public: // From MSigComp
       
   154 
       
   155 	TBool IsSupported () const;
       
   156 
       
   157 	TUint32 CreateCompartmentL( TUint32 aIapId );
       
   158 
       
   159     void RemoveCompartment( TUint32 aCompartmentId );
       
   160 
       
   161 	TInt CompartmentCount();
       
   162 
       
   163 	void SendFailedL( TUint32 aCompartmentId );
       
   164 
       
   165 
       
   166 public: // From MLocalName
       
   167 
       
   168 	TBool Match( const TDesC8& aAddress );
       
   169 	
       
   170 	
       
   171 public: // From MSipConnectionOwner
       
   172 
       
   173     TBool IsSystemStarted() const;
       
   174 
       
   175 	void Destroy( TUint32 aIapId );
       
   176 
       
   177 	TBool IsCellularDataUsageAllowed() const;
       
   178 
       
   179 public: // From MSIPTransportMgr
       
   180 
       
   181     void ReserveTransportL( TSIPTransportParams& aTransportParams,
       
   182                             TUint aLocalSendPort,
       
   183 						    TUint aLocalReceivePort,
       
   184 			                const TInetAddr& aRemoteAddr,
       
   185 			                TUint aRemoteSendPort );
       
   186     
       
   187     void CreateTLSTransportL( TSIPTransportParams& aTransportParams );
       
   188     
       
   189     void RemoveTransport( TUint32 aTransportId );
       
   190     	                
       
   191 	TInt RemoveTransport( TUint32 aTransportId,
       
   192 	                      MSIPTransportRemovalObserver* aRemovalObserver );
       
   193 	
       
   194 	TInt GetLocalAddress( TUint32 aIapId, TInetAddr& aAddr );
       
   195 
       
   196 public: // From MSipSystemStateObserver
       
   197 
       
   198     void SystemVariableUpdated( 
       
   199         CSipSystemStateMonitor::TSystemVariable aVariable,
       
   200 		TInt aObjectId,
       
   201 		TInt aValue );
       
   202 
       
   203 public: //MSipCellularDataUsageObserver
       
   204 void CellularDataUsageChangedL(MSipCellularDataUsageObserver::TCellularDataUsageStatus aStatus);
       
   205 
       
   206 
       
   207 
       
   208 private: // New functions
       
   209 
       
   210 	CSipConnection* CreateNewConnectionL( const TSIPTransportParams& aParams );
       
   211 	TBool ConnectionExists( TUint32 aIapId );
       
   212 	CSipConnection* Connection( TUint32 aIapId );
       
   213 	void RemoveConnection( TUint32 aIapId );
       
   214 	void RemoveAllConnections();
       
   215 	TUint32 CreateTransportId();
       
   216 	void LoadSigCompL();
       
   217 	void LoadNATTraversalL();
       
   218 	void LoadSystemStateMonitorL();
       
   219 
       
   220 private: // Constructors
       
   221 
       
   222 	CSipConnectionMgr( MTransactionFinder& aFinder, 
       
   223 		MServerTaFactory& aTaFactory, MTimerManager& aTimer, TUint aTOne, 
       
   224 		MConnectionStateObserver& aNetworkObserver );
       
   225 	void ConstructL();
       
   226 
       
   227 
       
   228 private: // Data
       
   229 	
       
   230 	CNetworkManager* iNetworkManager;
       
   231 
       
   232 	MSigCompController* iSigCompController;
       
   233 	MConnectionStateObserver* iTUNetStatusObserver;
       
   234 	MTransactionFinder* iFinder; 
       
   235 	MServerTaFactory* iTaFactory;
       
   236 	MTimerManager* iTimer;	
       
   237 	RSocketServ iSocketServ;
       
   238 	TUint iTOne;
       
   239 	TSglQue<CSipConnection> iConnectionList;
       
   240 	TSglQueIter<CSipConnection> iConnectionListIter;
       
   241 	TUint32 iTransportIdCounter;
       
   242 	
       
   243 	CNetworkInfo* iNetworkInfo; //owned
       
   244 	
       
   245 	CSIPNATTraversalController* iNATTraversal;
       
   246 	
       
   247 	CSipSystemStateMonitor* iSystemStateMonitor;
       
   248 	
       
   249 	CSipSystemStateMonitor::TSystemState iSystemState;
       
   250 
       
   251 	CSipCellularDataUsageMonitor * iCellularDataUsageMonitor;
       
   252 
       
   253 private: //For testing purposes
       
   254 #ifdef CPPUNIT_TEST
       
   255 	friend class CSipConnectionMgrTest;
       
   256 #endif
       
   257     };
       
   258     
       
   259 #endif // end of __CSIPCONNECTIONMGR_H__
       
   260 
       
   261 // End of File