|
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 COMASUPLProtocolManager1; |
|
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,COMASUPLProtocolManager1& 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(); |
|
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); |
|
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 COMASuplConnRequestor(CSuplCommunicationManager& aCommMgr, |
|
189 COMASUPLProtocolManager1& aProtoMgr, |
|
190 TUint aPort, |
|
191 MOMASuplConnObserver& aObserver); |
|
192 /** |
|
193 * By default Symbian 2nd phase constructor is private. |
|
194 */ |
|
195 void ConstructL(); |
|
196 |
|
197 private : |
|
198 |
|
199 |
|
200 /** |
|
201 * InitilizeSetting Method,Initilize Supl Settings. |
|
202 * @since S60 3.1 |
|
203 * @param None |
|
204 * @return None |
|
205 */ |
|
206 void InitilizeSetting(); |
|
207 |
|
208 void SaveAccessPoint(const TDesC& aIapName); |
|
209 |
|
210 /** |
|
211 * Dialog Timeout Notifier Method. |
|
212 * @since Series 60 9.1 TB |
|
213 * @param None |
|
214 * @return None |
|
215 */ |
|
216 virtual void DialogTimerExpiredL(); |
|
217 protected : // Functions from CActive |
|
218 /** |
|
219 * From CActive |
|
220 * To handle request completion |
|
221 */ |
|
222 void RunL(); |
|
223 |
|
224 /** |
|
225 * From CActive |
|
226 * To cancel the asynchronous requests |
|
227 */ |
|
228 void DoCancel(); |
|
229 /** |
|
230 * From CActive |
|
231 * To handle errors in asynchronous requests |
|
232 */ |
|
233 TInt RunError(TInt aError); |
|
234 |
|
235 private : //Data |
|
236 |
|
237 //Connection State |
|
238 TConnState iState; |
|
239 |
|
240 // Communication Manager Reference |
|
241 CSuplCommunicationManager& iCommMgr; |
|
242 |
|
243 // Reference to protocol manager to invoke settings UI |
|
244 COMASUPLProtocolManager1& iProtocolManager; |
|
245 |
|
246 |
|
247 |
|
248 // Connection Object |
|
249 CSuplConnection *iConnection; |
|
250 |
|
251 // A String buffer holding the IP Address in String Format |
|
252 TBuf <KMaxHostAddressLen> iHostAddress; |
|
253 |
|
254 // An unsigned integer hodling the port with which |
|
255 // connection has to be made |
|
256 TUint iPort; |
|
257 |
|
258 // IAP ID |
|
259 TUint32 iIAPId; |
|
260 |
|
261 // TLS |
|
262 TBool iTls; |
|
263 |
|
264 // PSKTLS |
|
265 TBool iPskTls; |
|
266 |
|
267 // Active Object Observer |
|
268 MOMASuplConnObserver& iObserver; |
|
269 |
|
270 //For trying for once with newly generated HSLP. |
|
271 TBool iTLSAuthenticationFailed; |
|
272 |
|
273 //SUPLSettings |
|
274 CSuplSettingsInternal *iSuplSettings; |
|
275 |
|
276 //Trace Utility |
|
277 COMASuplTrace* iTrace; |
|
278 TBool iIsHSLPGenerated; |
|
279 TBool iHslpAddrFromImsiUsed; |
|
280 |
|
281 TInt iLastConnectionError; |
|
282 |
|
283 COMASuplFallBackHandler* iFallBackHandler; |
|
284 |
|
285 TBool iIsSettingInitilized; |
|
286 |
|
287 TInt64 iCurrentSLPId; |
|
288 |
|
289 COMASuplDialogTimer* iDialogTimer; |
|
290 |
|
291 TBool iIapDialogShown; |
|
292 |
|
293 TBool iIapDlgTimerExpired; |
|
294 |
|
295 TBool iIsTimeoutDialogTimerStarted; |
|
296 |
|
297 }; |
|
298 |
|
299 #endif //C_COMASUPLCONNREQUESTOR_H |