|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Header file for CIptvNetworkSelection.h class* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #ifndef __CIPTVNETWORKSELECTION_H__ |
|
20 #define __CIPTVNETWORKSELECTION_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 //#include <cdbcols.h> |
|
24 #include <wlanmgmtclient.h> |
|
25 #include <wlanscaninfo.h> |
|
26 #include "TIptvIap.h" |
|
27 #include "MIptvTimerObserver.h" |
|
28 #include <rconnmon.h> |
|
29 #include <MProfileChangeObserver.h> //profile change notifier |
|
30 #include "IptvDebug.h" |
|
31 #include "TIptvGetUsedIapReq.h" |
|
32 #include "MIptvNetworkSelectionObserver.h" |
|
33 |
|
34 //#define ISIAIMATCH_USED |
|
35 #define ICISIMATCH_USED |
|
36 |
|
37 class CIptvServer; |
|
38 class CIptvIapList; |
|
39 class CIptvService; |
|
40 class CIptvTimer; |
|
41 class CProfileChangeNotifyHandler; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * CIptvServer owned class. This class is used to find out correct IAP for accessing |
|
47 * a Video Center service. This class also keeps track of connection permissions to |
|
48 * different type networks. |
|
49 */ |
|
50 class CIptvNetworkSelection : public CActive, |
|
51 public MIptvTimerObserver, |
|
52 public MProfileChangeObserver |
|
53 |
|
54 { |
|
55 |
|
56 public: // Enumerations |
|
57 |
|
58 /** |
|
59 * Response statuses. |
|
60 */ |
|
61 enum TRespStatus |
|
62 { |
|
63 EProcessing, |
|
64 ESucceeded, |
|
65 EGeneralError, |
|
66 /** |
|
67 * Service IAP list didn't contain any IAP which could be used for |
|
68 * connecting at the moment and no currect IAP set. |
|
69 */ |
|
70 ENoSuitableIapFound, |
|
71 |
|
72 /** |
|
73 * Couldn't get IAP without WLAN scan, |
|
74 * calls TIptvGetUsedIapReq->iNsObserver->GetUsedIapResp() |
|
75 * when WLAN scan has finished. |
|
76 */ |
|
77 EDoingWlanScan, |
|
78 EServiceNotFound, |
|
79 ECancelled, |
|
80 EFailedAlwaysAskSelected |
|
81 }; |
|
82 |
|
83 enum TConnectionPermission |
|
84 { |
|
85 EAllowed, |
|
86 ENotAllowed, |
|
87 EMustAskConfirmation |
|
88 }; |
|
89 |
|
90 public: |
|
91 /** |
|
92 * Constructor. |
|
93 */ |
|
94 static CIptvNetworkSelection* NewL(CIptvServer& aServer); |
|
95 |
|
96 /** |
|
97 * Destructor. |
|
98 */ |
|
99 virtual ~CIptvNetworkSelection(); |
|
100 |
|
101 private: |
|
102 CIptvNetworkSelection(CIptvServer& aServer); |
|
103 |
|
104 public: |
|
105 |
|
106 /* Network selection API */ |
|
107 |
|
108 /** |
|
109 * Sets IAP aIapId to be used as a default untill server is shutdown |
|
110 * or value is changed. |
|
111 * I.e this setting is valid for the server lifetime. |
|
112 * @param aIapId |
|
113 * @param aServiceId. |
|
114 * @param aSetToDefaultForService if True, the IAP is set to all services |
|
115 * to service db (current implementation ignores aServiceId). |
|
116 * @param aRespStatus |
|
117 */ |
|
118 void SetUsedIapL(TUint32 aIapId, |
|
119 TUint32 aServiceId, |
|
120 TBool aSetToDefaultForService, |
|
121 TRespStatus& aRespStatus); |
|
122 /** |
|
123 * Gets IAP which is used for connecting to aGetUsedIapReq->iServiceId. |
|
124 * Function is synchronous if IAP can be retrieved without wlan scan. |
|
125 * If wlan scan is needed aGetUsedIapReq->iRespStatus will contain EDoingWlanScan |
|
126 * value, in that case GetUsedIapResp() is called from aGetUsedIapReq->iNsObserver |
|
127 * when operation is completed. |
|
128 * Caller must inherit MIptvNetworkSelectionObserver class and implement callback |
|
129 * functions from there. |
|
130 * Caller keeps ownership to aGetUsedIapReq. |
|
131 * @param aGetUsedIapReq->iNsObserver pointer to object which issued the request. |
|
132 * @param aGetUsedIapReq->iServiceId |
|
133 * @param aGetUsedIapReq->iIapId will contain IAP ID. |
|
134 * @param aGetUsedIapReq->iIapName will contain IAP name. |
|
135 * @param aGetUsedIapReq->iConnectionPermission will contain connection permission. |
|
136 * @param aGetUsedIapReq->iRespStatus will contain resp status. |
|
137 */ |
|
138 void GetUsedIapReqL(TIptvGetUsedIapReq* aGetUsedIapReq); |
|
139 |
|
140 /** |
|
141 * Cancels all GetUsedIapReqs for aObserver. |
|
142 * WLAN scan is not cancelled (it is not possible). On WINSCW the WLAN simulation timer is cancelled. |
|
143 * @param aObserver |
|
144 */ |
|
145 TInt CancelGetUsedIapReq(MIptvNetworkSelectionObserver* aObserver); |
|
146 |
|
147 /** |
|
148 * Sets connection allowed for connection type aIapId represents. |
|
149 * See TConnectionType for possible types. |
|
150 * @param aConnectionAllowed |
|
151 * @param aIapId |
|
152 * @param aRespStatus |
|
153 */ |
|
154 void SetConnectionAllowedL(TBool aConnectionAllowed, |
|
155 TUint32 aIapId, |
|
156 TRespStatus& aRespStatus); |
|
157 |
|
158 /** |
|
159 * @param aIapId Iap ID which connection permission is queryed. |
|
160 * @return Connection permission |
|
161 */ |
|
162 TConnectionPermission IsConnectionAllowedL(TUint32 aIapId); |
|
163 |
|
164 /** |
|
165 * From MIptvTimerObserver. |
|
166 * @param aTimer pointer to timer which expired. |
|
167 */ |
|
168 void TimerExpired(CIptvTimer* aTimer); |
|
169 |
|
170 /** |
|
171 * ClearUsedIap. |
|
172 */ |
|
173 void ClearUsedIap(); |
|
174 |
|
175 private: |
|
176 void ConstructL(); |
|
177 |
|
178 /** |
|
179 * Gets used IAP for aServiceId. This is called after wlan scan. |
|
180 * @param aGetUsedIapReq request message from the client. |
|
181 */ |
|
182 void GetUsedIapAfterWlanScanL(TIptvGetUsedIapReq& aGetUsedIapReq); |
|
183 |
|
184 /** |
|
185 * GetActiveIapsL. |
|
186 * Gets currently active IAPS in the system. |
|
187 * Used by UpdateActiveIapsL method. |
|
188 */ |
|
189 CIptvIapList* GetActiveIapsL(); |
|
190 |
|
191 /** |
|
192 * UpdateActiveIapsL. |
|
193 * Updates iActiveIaps member variable. |
|
194 */ |
|
195 void UpdateActiveIapsL(); |
|
196 |
|
197 /** |
|
198 * UpdateWlanScannedIapsL. |
|
199 * Performs Wlan scan and updates iWlanScannedIaps member variable. |
|
200 */ |
|
201 void UpdateWlanScannedIapsL(); |
|
202 |
|
203 /** |
|
204 * FindCommonIapFromLists. |
|
205 * Picks the highest priority IAP from aServiceIaps list which is also |
|
206 * on aCompare list. |
|
207 * @param aServiceIaps |
|
208 * @param aCompareIaps |
|
209 * @param aIap The found iap is written here. |
|
210 * @return System-wide error code. aIap will contain valid value only |
|
211 * if this is KErrNone. |
|
212 */ |
|
213 TInt FindCommonIapFromListsL(CIptvIapList& aServiceIaps, |
|
214 CIptvIapList& aCompareIaps, |
|
215 TIptvIap& aIap); |
|
216 |
|
217 /** |
|
218 * CreateFilteredIapListL |
|
219 * Picks IAPs from aIapList which have matching connection type |
|
220 * with aConnectionTypeMask. |
|
221 * @param aIapList list to be filtered |
|
222 * @param aConnectionTypeMask |
|
223 * @return filtered IAP list, ownership moves to caller. |
|
224 */ |
|
225 CIptvIapList* CreateFilteredIapListL(CIptvIapList& aIapList, |
|
226 TUint32 aConnectionTypeMask); |
|
227 |
|
228 #ifdef ISIAIMATCH_USED |
|
229 /** |
|
230 * Updates iSiAiMatch member variable. |
|
231 */ |
|
232 void UpdateSiAiMatchL(); |
|
233 #endif |
|
234 |
|
235 /** |
|
236 * Updates iSiSwiMatch member variable. |
|
237 */ |
|
238 void UpdateSiSwiMatchL(); |
|
239 |
|
240 #ifdef ICISIMATCH_USED |
|
241 /** |
|
242 * Updates iCiSiMatch member variable. |
|
243 */ |
|
244 void UpdateCiSiMatch(); |
|
245 #endif |
|
246 |
|
247 /** |
|
248 * Updates iCiAiMatch member variable. |
|
249 */ |
|
250 void UpdateCiAiMatch(); |
|
251 |
|
252 /** |
|
253 * Updates iCiSwiMatch member variable. |
|
254 */ |
|
255 void UpdateCiSwiMatchL(); |
|
256 |
|
257 /** |
|
258 * Handles all pending GetUsedIapRequests from clients. |
|
259 * This is called after WLAN scan. |
|
260 */ |
|
261 void HandleGetUsedIapRequests(); |
|
262 |
|
263 /** |
|
264 * |
|
265 */ |
|
266 void GetWlanIapFromAiL(TIptvIap& aIap); |
|
267 |
|
268 /** |
|
269 * Gets IAP name, if empty, tries to find SSID. Leaves with KErrNotFound |
|
270 * if not found. |
|
271 * @param aIapId IAP to get |
|
272 * @param aIapName IAP name or SSID is written here. |
|
273 */ |
|
274 void GetIapNameL(TUint32 aIapId, TDes& aIapName); |
|
275 |
|
276 /** |
|
277 * Gets the first IAP ID with matching IAP name from commsdb. |
|
278 * @param aIapId The found IAP ID. |
|
279 * @param aIapName The IAP name used in comparasion. |
|
280 * @return KErrNone if IAP was found, KErrNotFound if no matching IAP name was found. |
|
281 */ |
|
282 TInt GetIapIdL(TUint32& aIapId, const TDesC& aIapName); |
|
283 |
|
284 /** |
|
285 * Gets SSID from commsdb using wlan service id. |
|
286 * @param aWlanServiceId |
|
287 * @param aSsid |
|
288 */ |
|
289 TInt GetSsidL(TUint32 aWlanServiceId, TDes& aSsid); |
|
290 |
|
291 /** |
|
292 * Current IAP selected, fills aGetUsedIapReq accordingly. |
|
293 * @param aGetUsedIapReq |
|
294 */ |
|
295 void SelectCiL(TIptvGetUsedIapReq& aGetUsedIapReq); |
|
296 |
|
297 /** |
|
298 * aIapId selected, fills aGetUsedIapReq accordingly. |
|
299 * @param aGetUsedIapReq |
|
300 * @param aIapId |
|
301 */ |
|
302 void SelectL(TIptvGetUsedIapReq& aGetUsedIapReq, TUint32 aIapId); |
|
303 |
|
304 /** |
|
305 * Updates all IAP lists except iCiSwiMatch which requires wlan scan. |
|
306 */ |
|
307 void UpdateAllButWlanListsL(TIptvGetUsedIapReq& aGetUsedIapReq); |
|
308 |
|
309 /** |
|
310 * Updates iService by getting new value from Service Manager. If service has IAP name field set, |
|
311 * it is tried to convert into an IAP ID. Conversion is stored to Service Manager. |
|
312 */ |
|
313 void UpdateServiceL(TUint32 aServiceId); |
|
314 |
|
315 #if IPTV_LOGGING_METHOD != 0 |
|
316 void PrintIapList(CIptvIapList& aIapList); |
|
317 #endif |
|
318 |
|
319 /** |
|
320 * Adds all hidden WLAN IAPs from iService to iScannedWlanIaps. |
|
321 */ |
|
322 void AddHiddenWlanSiIapsToSwiL(); |
|
323 |
|
324 /** |
|
325 * Clears iCurrent IAP if it is EGPRS or ECSD type. |
|
326 * Clears all EGPRS and ECSD type IAPs from iService IAPs. |
|
327 * This function is used in offline mode to ignore GPRS and CSD |
|
328 * type IAPs. |
|
329 */ |
|
330 void ClearGprsAndCsdIapsL(); |
|
331 |
|
332 public: //From MProfileChangeObserver |
|
333 |
|
334 /** |
|
335 * Callback function which is called when an active profile event |
|
336 * completes. |
|
337 * @param aProfileEvent Profile event |
|
338 * @param aProfileId Active profile id |
|
339 */ |
|
340 void HandleActiveProfileEventL( TProfileEvent aProfileEvent, TInt aProfileId ); |
|
341 |
|
342 private: |
|
343 |
|
344 #if IPTV_LOGGING_METHOD != 0 |
|
345 const TDesC& ConnectionTypeDes( CIptvUtil::TConnectionType aConnectionType ); |
|
346 #endif |
|
347 |
|
348 protected: // Functions from base classes |
|
349 |
|
350 /** |
|
351 * From CActive, RunL. |
|
352 * Callback function. |
|
353 * Invoked to handle responses from the server. |
|
354 */ |
|
355 void RunL(); |
|
356 |
|
357 /** |
|
358 * From CActive, DoCancel. |
|
359 * Cancels any outstanding operation. |
|
360 */ |
|
361 void DoCancel(); |
|
362 |
|
363 /** |
|
364 * From CActive, RunError. |
|
365 * Handles possible leaves during RunL. |
|
366 */ |
|
367 TInt RunError( TInt aError ); |
|
368 |
|
369 private: |
|
370 |
|
371 /** |
|
372 * System has these IAPs active at the moment |
|
373 */ |
|
374 CIptvIapList* iActiveIaps; |
|
375 |
|
376 /** |
|
377 * These IAPs have been scanned from the neighborhood. |
|
378 */ |
|
379 CIptvIapList* iScannedWlanIaps; |
|
380 |
|
381 /** |
|
382 * Working iaplist, used when calculating IAP to select |
|
383 */ |
|
384 CIptvIapList* iAvailableIaps; |
|
385 |
|
386 /** |
|
387 * Currently used IAP, set with SetUsedIap() method. |
|
388 */ |
|
389 TIptvIap iCurrentIap; |
|
390 |
|
391 #ifdef ISIAIMATCH_USED |
|
392 /** |
|
393 * Contains the highest priority IAP from iService IAPs which is also |
|
394 * in iActiveIaps. |
|
395 */ |
|
396 TIptvIap iSiAiMatch; |
|
397 #endif |
|
398 |
|
399 /** |
|
400 * The highest priority service IAP which is also found from scanned WLAN IAPs. |
|
401 */ |
|
402 TIptvIap iSiSwiMatch; |
|
403 |
|
404 #ifdef ICISIMATCH_USED |
|
405 /** |
|
406 * Contains iCurrentIap if it is found from iService IAP list. |
|
407 */ |
|
408 TIptvIap iCiSiMatch; |
|
409 #endif |
|
410 |
|
411 /** |
|
412 * Contains current IAP if it is found from active IAPs. |
|
413 */ |
|
414 TIptvIap iCiAiMatch; |
|
415 |
|
416 /** |
|
417 * Contains current IAP if it is found from scanned WLAN IAPs. |
|
418 */ |
|
419 TIptvIap iCiSwiMatch; |
|
420 |
|
421 /** |
|
422 * Service object, IAP list is fetched from it. |
|
423 */ |
|
424 CIptvService* iService; |
|
425 |
|
426 /** |
|
427 * A mask defining which connection types are allowed for connection. |
|
428 * Bit values from TConnectionType are used. |
|
429 */ |
|
430 TUint32 iConnectionAllowedMask; |
|
431 |
|
432 /** |
|
433 * The owner of this class |
|
434 */ |
|
435 CIptvServer& iServer; |
|
436 |
|
437 /** |
|
438 * All GetUsedIap requests are stored here and a single |
|
439 * WLAN scan is performed for them all. |
|
440 */ |
|
441 RArray<TIptvGetUsedIapReq*> iGetUsedIapReqs; |
|
442 |
|
443 #ifdef __WINSCW__ |
|
444 CIptvTimer* iWlanScanSimulationTimer; |
|
445 #endif |
|
446 |
|
447 /** |
|
448 * Used to perform WLAN scan. |
|
449 */ |
|
450 RConnectionMonitor iConnMon; |
|
451 |
|
452 /** |
|
453 * Contains WLAN scan result. |
|
454 */ |
|
455 TConnMonIapInfoBuf iIapInfoBuf; |
|
456 |
|
457 /** |
|
458 * Used to scan offline state, iOffline is updated accordingly. |
|
459 */ |
|
460 CProfileChangeNotifyHandler* iProfChangeHandler; |
|
461 |
|
462 /** |
|
463 * ETrue if phone is in offline mode, if phone is in offline mode |
|
464 * then GPRS IAPS are not used. |
|
465 */ |
|
466 TBool iOffline; |
|
467 |
|
468 /** |
|
469 * Used to store iCurrentIap feasiblity status in GetUsedIap procedure. |
|
470 */ |
|
471 TBool iCurrentIapIsFeasible; |
|
472 |
|
473 /** |
|
474 * Used to store if WLAN iap available in other snap when GPRS iap selected. |
|
475 */ |
|
476 TBool iWlanWhenGPRS; |
|
477 |
|
478 }; |
|
479 |
|
480 #endif // __CIPTVNETWORKSELECTION_H__ |
|
481 |