|
1 /* |
|
2 * Copyright (c) 2006 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 the License "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 to handle networking functions in vcxconnectionutility* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CVCX_CONUTILENGINE_H__ |
|
21 #define __CVCX_CONUTILENGINE_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <cmmanager.h> |
|
27 #include <es_sock.h> |
|
28 #include <connpref.h> |
|
29 #include <commdbconnpref.h> |
|
30 #include <comms-infras/cs_mobility_apiext.h> |
|
31 |
|
32 #include <cmdestinationext.h> |
|
33 #include <cmmanagerext.h> |
|
34 #include <rconnmon.h> |
|
35 #include "vcxconnectionutility.hrh" |
|
36 |
|
37 class CActiveCommsMobilityApiExt; |
|
38 class MConnUtilExtEngineObserver; |
|
39 |
|
40 |
|
41 // CLASS DECLARATION |
|
42 /** |
|
43 * Class defines functionality for handling networking functions in |
|
44 * vcxconnectionutility. |
|
45 * These are: |
|
46 * 1. connection creation and disconnecting |
|
47 * 2. handling and notifying of events from apllication level roaming (ALR) |
|
48 * 3. handling and notifying of other interesting events from the network: |
|
49 * - link layer closing and connection deletion |
|
50 * - iap list changing |
|
51 * |
|
52 * Class uses MConnUtilEngineObserver interface to inform CVcxConnUtilImpl |
|
53 * -class about the events. |
|
54 */ |
|
55 |
|
56 NONSHARABLE_CLASS ( CVcxConnUtilEngine ) : public CActive, |
|
57 public MMobilityProtocolResp, |
|
58 public MConnectionMonitorObserver |
|
59 { |
|
60 public: // construction / destruction |
|
61 |
|
62 /** |
|
63 * Construction. |
|
64 * |
|
65 * @param MConnUtilExtEngineObserver |
|
66 * @return The newly constructed CVcxConnUtilEngine |
|
67 */ |
|
68 static CVcxConnUtilEngine* NewL( MConnUtilExtEngineObserver* aObserver ); |
|
69 |
|
70 /** |
|
71 * Construction. Object left to cleanupstack |
|
72 * |
|
73 * @param MConnUtilExtEngineObserver |
|
74 * @return The newly constructed CVcxConnUtilEngine |
|
75 */ |
|
76 static CVcxConnUtilEngine* NewLC( MConnUtilExtEngineObserver* aObserver ); |
|
77 |
|
78 /** |
|
79 * destructor |
|
80 */ |
|
81 virtual ~CVcxConnUtilEngine(); |
|
82 |
|
83 private: |
|
84 |
|
85 /** |
|
86 * C++ constructor |
|
87 */ |
|
88 CVcxConnUtilEngine(); |
|
89 |
|
90 /** |
|
91 * Private 2nd phase construction. |
|
92 */ |
|
93 void ConstructL(); |
|
94 |
|
95 private: // From CActive |
|
96 |
|
97 /** |
|
98 * From CActive. Connection startup is done asynchronously after |
|
99 * connection cretaion ends, the status value of the connection is |
|
100 * updated whether connection succeed or not |
|
101 */ |
|
102 void RunL(); |
|
103 |
|
104 /** |
|
105 * From CActive. Cancels coonnection creation. |
|
106 */ |
|
107 void DoCancel(); |
|
108 |
|
109 private: // From MMobilityProtocolResp |
|
110 |
|
111 /** |
|
112 * From MMobilityProtocolResp. We have better carrier available for |
|
113 * the active connection. |
|
114 * |
|
115 * @param aOldAPInfo current IAP information |
|
116 * @param aNewAPInfo suggested new IAP information |
|
117 * @param aIsUpgrade ETrue indicates IAP is to be upgraded |
|
118 * @param aIsSeamless ETrue indicates that new connection is seamless |
|
119 * (new IAP requires dialog for connection) |
|
120 */ |
|
121 void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo, |
|
122 TAccessPointInfo aNewAPInfo, |
|
123 TBool aIsUpgrade, |
|
124 TBool aIsSeamless ); |
|
125 |
|
126 /** |
|
127 * From MMobilityProtocolResp. We have a new carrier available for |
|
128 * the active connection. |
|
129 * |
|
130 * @param aNewAPInfo IAP information from the new available connection |
|
131 * @param aIsSeamless ETrue indicates that new connection is seamless |
|
132 * (new IAP requires dialog for connection) |
|
133 */ |
|
134 void NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless ); |
|
135 |
|
136 /** |
|
137 * From MMobilityProtocolResp. |
|
138 * |
|
139 * @param aError |
|
140 */ |
|
141 void Error( TInt aError ); |
|
142 |
|
143 private: // from MConnectionMonitorObserver |
|
144 |
|
145 /** |
|
146 * @see MConnectionMonitorObserver |
|
147 */ |
|
148 void EventL( const CConnMonEventBase &aConnMonEvent ); |
|
149 |
|
150 public: // new methods |
|
151 |
|
152 typedef RArray<TUint32> RDestinationArray; |
|
153 |
|
154 /** |
|
155 * Starts a connection via SNAP |
|
156 * |
|
157 * @param aPref connection information to be used connection startup |
|
158 * @return KErrNone always is async connection and if sync connection |
|
159 * startup succeed or one of the system wide error codes |
|
160 */ |
|
161 TInt StartToConnect( TConnPref& aPref, TBool aConnAsync = ETrue ); |
|
162 |
|
163 /** |
|
164 * Disconnects active connection and closes RConnection |
|
165 */ |
|
166 void Disconnect(); |
|
167 |
|
168 /** |
|
169 * Method is used to get the name of the destination that matches |
|
170 * given id and to make sure, that destination really have connection |
|
171 * methods to use. |
|
172 * |
|
173 * @param aDestinationID destination (SNAP) if from where to fetch infromation |
|
174 * |
|
175 * @return TBool true, if connection is ok to start |
|
176 */ |
|
177 TBool PrepareConnectionDetailsL( TInt aDestinationID ); |
|
178 |
|
179 /** |
|
180 * Method reads platform's connection settings, and returns a destination id. |
|
181 * If aPurpose is setted as ESnapPurposeUnknown, default id is returned, |
|
182 * otherwise purpose is used to get correct id |
|
183 * |
|
184 * @param aPurpose if ESnapPurposeUnknown, get default, in all other cases |
|
185 * try to fetch id based on the purpose |
|
186 * |
|
187 * @return TUint32 destination id |
|
188 */ |
|
189 TUint32 GetCmmDestinationIdL( CMManager::TSnapPurpose aPurpose = |
|
190 CMManager::ESnapPurposeUnknown ); |
|
191 |
|
192 /** |
|
193 * Method checks if there is an active connection for |
|
194 * the given iap |
|
195 * |
|
196 * @param aIapId iap id to check |
|
197 * |
|
198 * @return TBool ETrue if connection exists |
|
199 * |
|
200 */ |
|
201 TBool IsIapConnected( TUint32 aIapId ); |
|
202 |
|
203 /** |
|
204 * Method fills started connection's information: IAP id (iIapId) and IAP name |
|
205 * This is needed in case of "always ask" to get the information client requires. |
|
206 * |
|
207 */ |
|
208 void FillActiveConnectionDetailsL(); |
|
209 |
|
210 /** |
|
211 * clears iapid, snapid and their names |
|
212 * |
|
213 */ |
|
214 void ResetConnectionInfo(); |
|
215 |
|
216 /** |
|
217 * Returns currently fetched iap id |
|
218 * |
|
219 * @return TUint32 |
|
220 */ |
|
221 TUint32 IapId() const; |
|
222 |
|
223 /** |
|
224 * Returns currently fetched iap id |
|
225 * |
|
226 * @return TInt |
|
227 */ |
|
228 TInt DestinationId() const; |
|
229 |
|
230 /** |
|
231 * Returns currently fetched snap name |
|
232 * |
|
233 * @return TUint32 |
|
234 */ |
|
235 TPtrC DestinationName() const; |
|
236 |
|
237 /** |
|
238 * Returns current connection status |
|
239 * |
|
240 * @return TPSVCConnectionStatus |
|
241 */ |
|
242 TVCxConnectionStatus ConnectionStatus() const; |
|
243 |
|
244 /** |
|
245 * Explicitly sets internal connection status. |
|
246 * |
|
247 * @param TPSVCConnectionStatus |
|
248 */ |
|
249 void SetConnectionStatus( TVCxConnectionStatus aStatus ); |
|
250 |
|
251 /** |
|
252 * Method can be called to create mobility object |
|
253 * for getting roaming events from the network. |
|
254 * |
|
255 * @return TInt KErrnone if object created or already exists. Otherwise a |
|
256 * system level error. |
|
257 */ |
|
258 TInt CreateMobility(); |
|
259 |
|
260 /** |
|
261 * Returns "query connection" status. |
|
262 */ |
|
263 TBool QueryConn(); |
|
264 |
|
265 /** |
|
266 * Set "query connection" status. |
|
267 * |
|
268 * @param aQueryConn Value for connection query flag. |
|
269 */ |
|
270 void SetQueryConn( TBool aQueryConn ); |
|
271 |
|
272 |
|
273 private: |
|
274 |
|
275 /** |
|
276 * Internal helper method trying to fetch destination |
|
277 * information for the current IAP. |
|
278 * |
|
279 */ |
|
280 void FillDestinationInfoL(); |
|
281 |
|
282 private: |
|
283 |
|
284 /** |
|
285 * Socket Server |
|
286 */ |
|
287 RSocketServ iSocketServer; |
|
288 |
|
289 /** |
|
290 * Connection |
|
291 */ |
|
292 RConnection iConnection; |
|
293 |
|
294 /** |
|
295 * Connection monitor |
|
296 */ |
|
297 RConnectionMonitor iConnectionMonitor; |
|
298 |
|
299 /** |
|
300 * Current connection state |
|
301 */ |
|
302 TVCxConnectionStatus iConnectionState; |
|
303 |
|
304 /** |
|
305 * Connection Manager Extensions |
|
306 */ |
|
307 RCmManagerExt iCmManagerExt; |
|
308 |
|
309 /** |
|
310 * Destination id. |
|
311 */ |
|
312 TInt iDestinationId; |
|
313 |
|
314 /** |
|
315 * IAP ID. |
|
316 */ |
|
317 TUint32 iIapId; |
|
318 |
|
319 /** |
|
320 * Destination (snap) Name. |
|
321 */ |
|
322 HBufC* iDestinationName; |
|
323 |
|
324 /** |
|
325 * current connection id |
|
326 */ |
|
327 TUint iCurrentConnectionId; |
|
328 |
|
329 /** |
|
330 * Mobility object to fetch carrier change events |
|
331 */ |
|
332 CActiveCommsMobilityApiExt* iMobility; |
|
333 |
|
334 /** |
|
335 * array of all available destination ids |
|
336 */ |
|
337 RDestinationArray iDestinationArray; |
|
338 |
|
339 /** |
|
340 * observer to notify about changes in the network |
|
341 */ |
|
342 MConnUtilExtEngineObserver* iObserver; |
|
343 |
|
344 /** |
|
345 * Value to pass connection result error code from the |
|
346 * async connection creation |
|
347 */ |
|
348 TInt iConnectingResult; |
|
349 |
|
350 /** |
|
351 * If is set to ETrue, connection selection dialog will be displayed. |
|
352 * Used when tried SNAP contained invalid IAP. |
|
353 */ |
|
354 TBool iQueryConn; |
|
355 |
|
356 }; |
|
357 |
|
358 #endif // __CVCX_CONUTILENGINE_H__ |