supl/locationomasuplprotocolhandler/protocolhandlerver2/inc/epos_comasuplconnrequestor.h
changeset 0 667063e416a2
child 12 5944cae565c9
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-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:   Class for doing asynchronous service.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_COMASUPLCONNREQUESTOR_H
       
    21 #define C_COMASUPLCONNREQUESTOR_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "epos_csuplconnection.h"
       
    26 #include "epos_comasupluicompletionobserver.h" 
       
    27 #include "epos_momasupldialogtimeoutnotifier.h"
       
    28 
       
    29 class CSuplCommunicationManager;
       
    30 class MOMASuplConnObserver;
       
    31 class CSuplSettings;
       
    32 class COMASuplTrace;
       
    33 class COMASuplFallBackHandler;
       
    34 class COMASUPLProtocolManager2;
       
    35 class COMASuplDialogTimer;
       
    36 /**
       
    37  *  Class for doing asynchronous service  i.e. used for Sending Packet to Socket.	
       
    38  *
       
    39  *  @lib eposomasuplprotocolhandler.lib
       
    40  *  @since S60 v3.1
       
    41  */
       
    42  
       
    43 class COMASuplConnRequestor : public CActive, 
       
    44                               public MOMASuplUICompletionObserver,  
       
    45                               public MOMASuplDialogTimeOutNotifier
       
    46 {
       
    47 
       
    48 	enum TConnState
       
    49 	    {
       
    50 		  EConnecting,
       
    51 		  EConnectionDone,
       
    52 	      ESending,
       
    53 	      EInitilizeSetting
       
    54 		};
       
    55 
       
    56 	public :  // Constructor 
       
    57 	
       
    58 		/**
       
    59 		* NewL Method.
       
    60 		* @since Series 60 3.1
       
    61 		* @param MEventCompletionObserver
       
    62 		* @return Instance of COMASuplAOOperation
       
    63 		*/ 
       
    64 		
       
    65 		/*
       
    66 		static COMASuplConnRequestor* NewL(CSuplCommunicationManager& aCommMgr, const TDesC8& aHostAddr,
       
    67 										   TInt aIAPId, TUint aPort, MOMASuplConnObserver& aObserver);
       
    68 		*/										   
       
    69 		static COMASuplConnRequestor* NewL(CSuplCommunicationManager& aCommMgr,COMASUPLProtocolManager2& aProtoMgr,TUint aPort,MOMASuplConnObserver& aObserver);										   
       
    70 		
       
    71 		/**
       
    72 		* Destructor.
       
    73 		*/
       
    74 		~COMASuplConnRequestor();
       
    75 		
       
    76 	public :		
       
    77 	
       
    78 		/**
       
    79 		* CreateConnection Method. Creates the Socket required to
       
    80 		* communicate with the SLP
       
    81 		* @since Series 60 3.1
       
    82 		* @param None
       
    83 		* @return None
       
    84 		*/ 
       
    85 		void CreateConnectionL(TBool aTriggerSession);
       
    86 		
       
    87 		/**
       
    88 		 * CreateConnection Method Overload. Creates the Socket required to
       
    89 		 * communicate with the SLP. Called in case of NI case.
       
    90 		 * @since 
       
    91 		 * @param None
       
    92 		 * @return None
       
    93 		 */ 
       
    94 		void CreateConnectionL(TInt aDialogTimeOutDelay, TBool aTriggerSession);
       
    95 		
       
    96 		/**
       
    97 		* SendPacket Method.
       
    98 		* @since Series 60 3.1
       
    99 		* @param aConnection, for sending Packet
       
   100 		* @param aPacket, Packet
       
   101 		* @return None
       
   102 		*/ 
       
   103 		void SendPacket(const TDesC8& aPacket);
       
   104 
       
   105 		/**
       
   106 		* OpenConnection Method.,It Connects to SLP
       
   107 		* @since Series 60 3.1
       
   108 		* @param None
       
   109 		* @return None
       
   110 		*/ 
       
   111 		void OpenConnection();
       
   112 		
       
   113 		/**
       
   114 		* ListenToMessages Method.Start listening to Messages
       
   115 		* @since Series 60 3.1
       
   116 		* @param None
       
   117 		* @return None
       
   118 		*/ 
       
   119 		void ListenToMessages();
       
   120 		
       
   121 		/**
       
   122 		* CloseConnection Method.Destroys the socket to SLP
       
   123 		* @since Series 60 3.1
       
   124 		* @param None
       
   125 		* @return None
       
   126 		*/ 
       
   127 		void CloseConnection();
       
   128 		
       
   129 		/**
       
   130 		* GetLocalIPAddress Method.
       
   131 		* @since Series 60 3.1
       
   132 		* @param aAddress, TInetAddr 
       
   133 		* @return None
       
   134 		*/ 
       
   135 		TInt GetLocalIPAddress(TInetAddr& aAddress);
       
   136 		
       
   137 		/**
       
   138 		* GetLocalIPAddress Method.
       
   139 		* @since Series 60 3.1
       
   140 		* @param aAddress, TInetAddr 
       
   141 		* @return None
       
   142 		*/ 
       
   143 		void CancelReadOperation();
       
   144 		
       
   145 		/**
       
   146 		* SetIAPID Method.
       
   147 		* @since Series 60 3.1
       
   148 		* @param aIAPID, 
       
   149 		* @return None
       
   150 		*/ 
       
   151 		void SetIAPID(TInt aIAPID);
       
   152 
       
   153 	/**
       
   154 		* IsHslpGenerated Method,checks if Hslp address is NULL. 
       
   155 		* @since S60 3.1
       
   156 		* @param None
       
   157 		* @return None
       
   158 		*/ 
       
   159 	
       
   160 		void IsHslpGenerated(TBool aIsGenerated);
       
   161 
       
   162        /**
       
   163 		* IsHslpAddrFromImsiUsed Method,checks if Hslp address is used for connection is from IMSI. 
       
   164 		* @since S60 3.2
       
   165 		* @param None
       
   166 		* @return None
       
   167 		*/ 
       
   168         TBool IsHslpAddrFromImsiUsed();
       
   169         
       
   170         void SetDefaultParametersL(const TDesC& aClientProvidedHSLPAddress,TBool aFallBackAllowed);	
       
   171         
       
   172         void GetUsedServerAddress(TDes& aHSLPAddressUsed);
       
   173         
       
   174         void SettingsUICompletedL(TInt aError);
       
   175         void SettingsUsageUICompletedL(TInt /*aError*/) {}
       
   176         void SettingsTimeOutUICompletedL(TInt /*aError*/) {}
       
   177         TBool ConvertIAPNameToIdL(const TDesC& aIAPName, TUint32& aIAPId);
       
   178         void UpdateNetInfo(const TTime& aLastTimeUsed,TInt& aMcc,TInt& aMnc,
       
   179 							              TInt& aCid,TInt& aLac,TInt& aType,TInt& aErrorCode);
       
   180 				
       
   181 				void UseDefaultServerL();	            
       
   182 				void UseServerL(const TDesC& aClientProvidedHSLPAddress);  
       
   183 				void UpdateSLPListForHomeUsage(TBool aHomeNetwork);
       
   184 
       
   185         TUint GetPortNumber();
       
   186 	private : 
       
   187 		//Constuctor
       
   188 		/*
       
   189 		COMASuplConnRequestor(CSuplCommunicationManager& aCommMgr, 
       
   190 							  TInt aIAPId, TUint aPort, MOMASuplConnObserver& aObserver);
       
   191 		*/							  
       
   192 											 
       
   193 		COMASuplConnRequestor(CSuplCommunicationManager& aCommMgr,
       
   194 							   COMASUPLProtocolManager2& aProtoMgr,
       
   195 					  			TUint aPort,
       
   196 					  		   MOMASuplConnObserver& aObserver);
       
   197 		/**
       
   198 		* By default Symbian 2nd phase constructor is private.
       
   199 		*/
       
   200 		//void ConstructL(const TDesC8& aHostAddr);
       
   201 		void ConstructL();
       
   202 		
       
   203 	private :		
       
   204 	
       
   205 		
       
   206 		/**
       
   207 		* InitilizeSetting Method,Initilize Supl Settings. 
       
   208 		* @since S60 3.1
       
   209 		* @param None
       
   210 		* @return None
       
   211 		*/ 
       
   212 		void InitilizeSetting();
       
   213 		
       
   214 		void SaveAccessPoint(const TDesC& aIapName);
       
   215 
       
   216 		/**
       
   217 		 * Dialog Timeout Notifier Method.
       
   218 		 * @since Series 60 9.1 TB
       
   219 		 * @param None
       
   220 		 * @return None
       
   221 		 */
       
   222 		virtual void DialogTimerExpiredL();	
       
   223   	protected :  // Functions from CActive
       
   224       /**
       
   225       * From CActive 
       
   226       * To handle request completion
       
   227       */
       
   228       void RunL();
       
   229       
       
   230       /**
       
   231       * From CActive 
       
   232       * To cancel the asynchronous requests
       
   233       */
       
   234    		void DoCancel();  
       
   235       /**
       
   236       * From CActive 
       
   237       * To handle errors in asynchronous requests
       
   238       */
       
   239    		TInt RunError(TInt aError);
       
   240      
       
   241 	private : //Data
       
   242 	
       
   243 			//Connection State
       
   244 			TConnState iState;
       
   245 			
       
   246 			// Communication Manager Reference
       
   247 			CSuplCommunicationManager& iCommMgr;
       
   248 			
       
   249            // Reference to protocol manager to invoke settings UI
       
   250             COMASUPLProtocolManager2& iProtocolManager;
       
   251 
       
   252 
       
   253 			
       
   254 			// Connection Object
       
   255 			CSuplConnection *iConnection;
       
   256 
       
   257 			// A String buffer holding the IP Address in String Format
       
   258 			TBuf <KMaxHostAddressLen> iHostAddress;
       
   259 			
       
   260 			// An unsigned integer hodling the port with which 
       
   261 			// connection has to be made
       
   262 			TUint iPort;
       
   263 			
       
   264 			// IAP ID
       
   265 			TUint32 iIAPId;
       
   266 			
       
   267 			// TLS
       
   268 			TBool iTls;
       
   269 			
       
   270 			// PSKTLS
       
   271 			TBool iPskTls;
       
   272 			
       
   273 			// Active Object Observer
       
   274 			MOMASuplConnObserver& iObserver;      
       
   275 			
       
   276 			//For trying for once with newly generated HSLP.
       
   277 			TBool iTLSAuthenticationFailed;
       
   278 			
       
   279 			//SUPLSettings
       
   280 			CSuplSettingsInternal *iSuplSettings;
       
   281 			
       
   282 			//Trace Utility
       
   283 			COMASuplTrace* iTrace;
       
   284 			TBool iIsHSLPGenerated;
       
   285             TBool iHslpAddrFromImsiUsed;
       
   286             
       
   287             TInt iLastConnectionError;
       
   288             
       
   289             COMASuplFallBackHandler* iFallBackHandler;
       
   290             
       
   291             TBool iIsSettingInitilized;
       
   292             
       
   293             TInt64 iCurrentSLPId;
       
   294             
       
   295             COMASuplDialogTimer* iDialogTimer;
       
   296             
       
   297             TBool iIapDialogShown;
       
   298             
       
   299             TBool iIapDlgTimerExpired;
       
   300             
       
   301             TBool iIsTimeoutDialogTimerStarted;
       
   302 
       
   303 };
       
   304 
       
   305 #endif //C_COMASUPLCONNREQUESTOR_H