1 /* |
|
2 * Copyright (c) 2002-2010 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: Handles LaunchBrowser command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <MSatShellController.h> |
|
21 #include <cmmanager.h> |
|
22 #include <cmconnectionmethod.h> |
|
23 #include <cmconnectionmethoddef.h> |
|
24 #include <cmpluginpacketdatadef.h> |
|
25 #include <cmdestination.h> |
|
26 |
|
27 #include "MSatApi.h" |
|
28 #include "MSatUtils.h" |
|
29 #include "MSatUiSession.h" |
|
30 #include "SatSOpcodes.h" |
|
31 #include "MSatSUiClientHandler.h" |
|
32 #include "CLaunchBrowserHandler.h" |
|
33 #include "SatLog.h" |
|
34 #include "MSatSystemState.h" |
|
35 |
|
36 // The pause constant for checking if BrowserApp has exited. |
|
37 // This value may be adjusted to ensure the time sequence |
|
38 const TInt KSatSShortLoopTimeout = 800000; //0.8 sec |
|
39 |
|
40 // How many times the browser status is checked, when waiting for |
|
41 // browser shutdown. Total time |
|
42 // used to check the exiting of browser app is |
|
43 // KSatSWaitCount * KSatSShortLoopTimeout. |
|
44 const TInt KSatSWaitCount = 10; |
|
45 |
|
46 // Invalid PDP type |
|
47 const TInt KSatInvalidPdpType = -1; |
|
48 |
|
49 #ifdef _DEBUG |
|
50 // Class name for error information. |
|
51 //lint -e752 Accessed in __ASSERT_DEBUG, but lint will not notice it. |
|
52 _LIT( KLaunchBrowserHandlerName, "CLaunchBrowserHandler" ); |
|
53 #endif |
|
54 |
|
55 const TInt KSatMaxIPv4AddressLength( 15 ); |
|
56 const TInt KSatMaxIPv6AddressLength( 39 ); |
|
57 const TInt KSatMinIPv4AddressLength( 7 ); |
|
58 const TInt KSatMinIPv6AddressLength( 7 ); |
|
59 const TInt KSatMaxIPv4SegmentCounter( 3 ); |
|
60 const TInt KSatMaxIPv4SegmentLength( 3 ); |
|
61 const TInt KSatIPv4Broadcast( 255 ); |
|
62 const TInt KSatIPv4Network( 0 ); |
|
63 const TInt KSatMaxIPv6SegmentCounter( 7 ); |
|
64 const TInt KSatMaxIPv6SegmentLength( 4 ); |
|
65 const TUint32 KSatLaunchBrowserProxyPortNumber( 80 ); |
|
66 const TUint32 KSatMaxProxyPortNumber( 9999 ); |
|
67 const TUint32 KSatMinProxyPortNumber( 0 ); |
|
68 // Granularity for getting connection methods from CM session |
|
69 const TUint32 KSatCMGranularity( 5 ); |
|
70 |
|
71 _LIT( KSatAccessPointName, "SAT Launch Browser" ); |
|
72 _LIT( KSatGprsAccessPointName, "internet" ); |
|
73 _LIT( KSatIPv4Delimiter, "." ); |
|
74 _LIT( KSatIPv6Delimiter, ":" ); |
|
75 |
|
76 // ======== MEMBER FUNCTIONS ======== |
|
77 // ----------------------------------------------------------------------------- |
|
78 // Two-phased constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CLaunchBrowserHandler* CLaunchBrowserHandler::NewL( MSatUtils* aUtils ) |
|
82 { |
|
83 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::NewL calling" ) |
|
84 |
|
85 CLaunchBrowserHandler* self = new( ELeave ) CLaunchBrowserHandler; |
|
86 |
|
87 CleanupStack::PushL( self ); |
|
88 self->BaseConstructL( aUtils ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 |
|
92 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::NewL exiting" ) |
|
93 return self; |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // Destructor. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CLaunchBrowserHandler::~CLaunchBrowserHandler() |
|
102 { |
|
103 LOG( SIMPLE, |
|
104 "LAUNCHBROWSER: CLaunchBrowserHandler::~CSatSLaunchBrowserHandler \ |
|
105 calling" ) |
|
106 |
|
107 if ( iAfterWait.IsStarted() ) |
|
108 { |
|
109 iAfterWait.AsyncStop(); |
|
110 } |
|
111 |
|
112 if ( iAfterTimer ) |
|
113 { |
|
114 iAfterTimer->Cancel(); |
|
115 delete iAfterTimer; |
|
116 iAfterTimer = NULL; |
|
117 } |
|
118 |
|
119 iWsSession.Close(); |
|
120 |
|
121 Cancel(); |
|
122 |
|
123 LOG( SIMPLE, |
|
124 "LAUNCHBROWSER: CLaunchBrowserHandler::~CSatSLaunchBrowserHandler \ |
|
125 exiting" ) |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // From class MSatCommand. |
|
130 // Response from the client. |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CLaunchBrowserHandler::ClientResponse() |
|
134 { |
|
135 LOG( SIMPLE, |
|
136 "LAUNCHBROWSER: CLaunchBrowserHandler::ClientResponse calling" ) |
|
137 |
|
138 // TPCmdResult |
|
139 iLaunchBrowserRsp.iGeneralResult = RSat::KLaunchBrowserError; |
|
140 |
|
141 // TAdditionalInfoType |
|
142 iLaunchBrowserRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
143 iLaunchBrowserRsp.iAdditionalInfo.Zero(); |
|
144 iLaunchBrowserRsp.SetPCmdNumber( iLaunchBrowserData.PCmdNumber() ); |
|
145 |
|
146 // Perform the action that we just queried the user for. |
|
147 if ( iQueryRsp.iAccepted ) |
|
148 { |
|
149 // Launch the Browser. |
|
150 TRAPD( err, LaunchBrowserL() ); |
|
151 if ( KErrNone != err ) |
|
152 { |
|
153 iLaunchBrowserRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
154 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
155 CLaunchBrowserHandler::ClientResponse error: %i", err ) |
|
156 } |
|
157 else |
|
158 { |
|
159 LOG( SIMPLE, |
|
160 "LAUNCHBROWSER: CLBH::CR ESetUpMenuRequested registered" ) |
|
161 TRAP_IGNORE( iUtils->RegisterL( |
|
162 this, MSatUtils::ESetUpMenuRequested ) ) |
|
163 } |
|
164 } |
|
165 else // User denied this action |
|
166 { |
|
167 iLaunchBrowserRsp.iGeneralResult = RSat::KPCmdNotAcceptedByUser; |
|
168 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
169 CLaunchBrowserHandler::ClientResponse not accepted" ) |
|
170 if ( iQueryRsp.iSessionTerminatedByUser ) |
|
171 { |
|
172 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
173 CLaunchBrowserHandler::ClientResponse close ui session" ) |
|
174 // Next SimSession end will close the ui session |
|
175 iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser ); |
|
176 } |
|
177 } |
|
178 |
|
179 // If command had icon data and was done succesfully, report that icon |
|
180 // was not shown |
|
181 // To be removed when icons are allowed in this command |
|
182 if ( ( RSat::KSuccess == iLaunchBrowserRsp.iGeneralResult ) && |
|
183 iIconCommand ) |
|
184 { |
|
185 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
186 CLaunchBrowserHandler::ClientResponse icon not display" ) |
|
187 iLaunchBrowserRsp.iGeneralResult = |
|
188 RSat::KSuccessRequestedIconNotDisplayed; |
|
189 } |
|
190 |
|
191 TerminalRsp( RSat::ELaunchBrowser, iLaunchBrowserRspPckg ); |
|
192 |
|
193 LOG( SIMPLE, |
|
194 "LAUNCHBROWSER: CLaunchBrowserHandler::ClientResponse exiting" ) |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // From class CSatCommandHandler. |
|
199 // Event notification |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CLaunchBrowserHandler::Event( TInt aEvent ) |
|
203 { |
|
204 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::Event calling" ) |
|
205 |
|
206 switch ( aEvent ) |
|
207 { |
|
208 // SetUpMenu is listening by SAT Client. |
|
209 case MSatUtils::ESetUpMenuRequested: |
|
210 { |
|
211 LOG( NORMAL, |
|
212 "LAUNCHBROWSER::Event ESetUpMenuRequested catched and unreg" ) |
|
213 iUtils->UnregisterEvent( this, MSatUtils::ESetUpMenuRequested ); |
|
214 // Browser is brought to the top after short period of time. |
|
215 //iUtils->SatUiHandler().ShellController(). |
|
216 // BringBrowserToForegroundAfterPeriod(); |
|
217 break; |
|
218 } |
|
219 |
|
220 default: |
|
221 { |
|
222 LOG2( NORMAL, "LAUNCHBROWSER: Unexpected event: %i", aEvent ) |
|
223 CSatCommandHandler::Event( aEvent ); |
|
224 } |
|
225 } |
|
226 |
|
227 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::Event exiting" ) |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // From class CActive. |
|
232 // Cancels the sat request. |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 void CLaunchBrowserHandler::DoCancel() |
|
236 { |
|
237 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::DoCancel calling" ) |
|
238 |
|
239 iUtils->USatAPI().NotifyLaunchBrowserCancel(); |
|
240 |
|
241 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::DoCancel exiting" ) |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // From class CSatCommandHandler. |
|
246 // Requests the command notification. |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 void CLaunchBrowserHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
250 { |
|
251 LOG( SIMPLE, |
|
252 "LAUNCHBROWSER: CLaunchBrowserHandler::IssueUSATRequest calling" ) |
|
253 |
|
254 // Clear the IPC package. |
|
255 new (&iLaunchBrowserData) RSat::TLaunchBrowserV2(); |
|
256 iQueryRsp.iAccepted = EFalse; // default |
|
257 |
|
258 iUtils->USatAPI().NotifyLaunchBrowser( aStatus, iLaunchBrowserPckg ); |
|
259 |
|
260 LOG( SIMPLE, |
|
261 "LAUNCHBROWSER: CLaunchBrowserHandler::IssueUSATRequest exiting" ) |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // From class CSatCommandHandler. |
|
266 // Precheck before executing the command. |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 TBool CLaunchBrowserHandler::CommandAllowed() |
|
270 { |
|
271 LOG( SIMPLE, |
|
272 "LAUNCHBROWSER: CLaunchBrowserHandler::CommandAllowed calling" ) |
|
273 |
|
274 iLaunchBrowserRsp.iGeneralResult = RSat::KLaunchBrowserError; |
|
275 iLaunchBrowserRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
276 iLaunchBrowserRsp.iAdditionalInfo.Zero(); |
|
277 |
|
278 RMobilePhone::TMobilePhoneRegistrationStatus registrationStatus( |
|
279 iUtils->SystemState().GetNetworkRegistrationStatus() ); |
|
280 |
|
281 TBool commandAllowed( ETrue ); |
|
282 |
|
283 if ( RSat::EBrowserIdNotSpecified == iLaunchBrowserData.iBrowserId ) |
|
284 { |
|
285 // When get unknown browser id, such as RFU value, return |
|
286 // terminal response of command not understood. |
|
287 iLaunchBrowserRsp.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
288 commandAllowed = EFalse; |
|
289 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
290 CLaunchBrowserHandler::CommandAllowed unknown browser id" ) |
|
291 } |
|
292 else if ( ( RSat::EAlphaIdProvided != |
|
293 iLaunchBrowserData.iAlphaId.iStatus ) && |
|
294 ( RSat::ESelfExplanatory == |
|
295 iLaunchBrowserData.iIconId.iQualifier || |
|
296 RSat::ENotSelfExplanatory == |
|
297 iLaunchBrowserData.iIconId.iQualifier ) ) |
|
298 { |
|
299 iLaunchBrowserRsp.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
300 commandAllowed = EFalse; |
|
301 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
302 CLaunchBrowserHandler::CommandAllowed icon without alpha id" ) |
|
303 } |
|
304 else if ( |
|
305 ( RMobilePhone::ERegisteredOnHomeNetwork != registrationStatus ) && |
|
306 ( RMobilePhone::ERegisteredRoaming != registrationStatus ) ) |
|
307 { |
|
308 iLaunchBrowserRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
309 iLaunchBrowserRsp.iInfoType = RSat::KMeProblem; |
|
310 iLaunchBrowserRsp.iAdditionalInfo.SetLength( 1 ); |
|
311 iLaunchBrowserRsp.iAdditionalInfo[0] = RSat::KNoService; |
|
312 commandAllowed = EFalse; |
|
313 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::CommandAllowed\ |
|
314 MS is out of service (Net. Reg. status wrong)" ) |
|
315 } |
|
316 else if ( RSat::EBrowserSelectionNotSet == iLaunchBrowserData.iBrowserSel ) |
|
317 { |
|
318 iLaunchBrowserRsp.iGeneralResult = RSat::KCmdTypeNotUnderstood; |
|
319 commandAllowed = EFalse; |
|
320 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
321 CLaunchBrowserHandler::CommandAllowed selection not set" ) |
|
322 } |
|
323 else if ( RSat::ELaunchBrowserIfNotAlreadyLaunched == |
|
324 iLaunchBrowserData.iBrowserSel ) |
|
325 { |
|
326 if ( BrowserExists() ) |
|
327 { |
|
328 iLaunchBrowserRsp.iInfoType = RSat::KMeProblem; |
|
329 iLaunchBrowserRsp.iAdditionalInfo.Append( |
|
330 RSat::KBrowserUnavailable ); |
|
331 commandAllowed = EFalse; |
|
332 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
333 CLaunchBrowserHandler::CommandAllowed not launched" ) |
|
334 } |
|
335 } |
|
336 else |
|
337 { |
|
338 LOG( SIMPLE, |
|
339 "LAUNCHBROWSER: CLaunchBrowserHandler::CommandAllowed ok" ) |
|
340 } |
|
341 |
|
342 if ( !commandAllowed ) |
|
343 { |
|
344 LOG( SIMPLE, |
|
345 "CLaunchBrowserHandler::CommandAllowed commandAllowed false" ) |
|
346 iLaunchBrowserRsp.SetPCmdNumber( iLaunchBrowserData.PCmdNumber() ); |
|
347 TerminalRsp( RSat::ELaunchBrowser, iLaunchBrowserRspPckg ); |
|
348 } |
|
349 // Set icon command flag whether icon data was received and set qualifier |
|
350 // to no icon id |
|
351 // To be removed when icons are allowed in this command |
|
352 else if ( ( RSat::ESelfExplanatory == |
|
353 iLaunchBrowserData.iIconId.iQualifier ) || |
|
354 ( RSat::ENotSelfExplanatory == |
|
355 iLaunchBrowserData.iIconId.iQualifier ) ) |
|
356 { |
|
357 LOG( SIMPLE, |
|
358 "CLaunchBrowserHandler::CommandAllowed commandAllowed ENoIconId" ) |
|
359 iIconCommand = ETrue; |
|
360 iLaunchBrowserData.iIconId.iQualifier = RSat::ENoIconId; |
|
361 } |
|
362 else |
|
363 { |
|
364 iIconCommand = EFalse; |
|
365 } |
|
366 |
|
367 LOG2( SIMPLE, |
|
368 "LAUNCHBROWSER: CLaunchBrowserHandler::CommandAllowed exiting, \ |
|
369 commandAllowed: %d", commandAllowed ) |
|
370 return commandAllowed; |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // From class CSatCommandHandler. |
|
375 // Answers for need of UI session. |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 TBool CLaunchBrowserHandler::NeedUiSession() |
|
379 { |
|
380 LOG( SIMPLE, |
|
381 "LAUNCHBROWSER: CLaunchBrowserHandler::NeedUiSession calling" ) |
|
382 |
|
383 const RSat::TAlphaId alphaId( iLaunchBrowserData.iAlphaId ); |
|
384 |
|
385 iNeedUiSession = ETrue; |
|
386 |
|
387 if ( ( ( alphaId.iStatus == RSat::EAlphaIdProvided && |
|
388 alphaId.iAlphaId.Length() == 0 ) || |
|
389 alphaId.iStatus == RSat::EAlphaIdNull ) && |
|
390 ( !iUtils->SystemState().IsConfirmSatOperationsOn() ) ) |
|
391 { |
|
392 iNeedUiSession = EFalse; |
|
393 LOG( NORMAL, |
|
394 "LAUNCHBROWSER: CLaunchBrowserHandler::NeedUiSession no \ |
|
395 Ui session needed" ) |
|
396 } |
|
397 |
|
398 if ( iUtils->CoverUiSupported() && iNeedUiSession ) |
|
399 { |
|
400 LOG( NORMAL, |
|
401 "LAUNCHBROWSER: CLaunchBrowserHandler::NeedUiSession Ui session \ |
|
402 needed" ) |
|
403 TSatCommandData medEventData; |
|
404 medEventData.iPCmdNumber = RSat::ELaunchBrowser; |
|
405 medEventData.iAlphaId = iLaunchBrowserData.iAlphaId; |
|
406 |
|
407 if ( iUtils->SystemState().IsConfirmSatOperationsOn() ) |
|
408 { |
|
409 LOG( NORMAL, |
|
410 "LAUNCHBROWSER: CLaunchBrowserHandler::NeedUiSession \ |
|
411 KSatLongDuration" ) |
|
412 medEventData.iDuration.iNumOfUnits = KSatLongDuration; |
|
413 } |
|
414 else |
|
415 { |
|
416 medEventData.iDuration.iNumOfUnits = KSatDefaultDuration; |
|
417 } |
|
418 |
|
419 medEventData.iDuration.iTimeUnit = RSat::ESeconds; |
|
420 medEventData.iIconID = iLaunchBrowserData.iIconId; |
|
421 TSatCommandPckg tPckg( medEventData ); |
|
422 iUtils->RaiseSatEvent( tPckg ); |
|
423 } |
|
424 |
|
425 LOG2( SIMPLE, |
|
426 "LAUNCHBROWSER: CLaunchBrowserHandler::NeedUiSession exiting, \ |
|
427 iNeedUiSession: %d", iNeedUiSession ) |
|
428 return iNeedUiSession; |
|
429 } |
|
430 |
|
431 // ----------------------------------------------------------------------------- |
|
432 // From class CSatCommandHandler. |
|
433 // Called when USAT API notifies that command. |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 void CLaunchBrowserHandler::HandleCommand() |
|
437 { |
|
438 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::HandleCommand calling" ) |
|
439 |
|
440 // Register service request handler for LaunchBrowser command, |
|
441 // If there is already service request for query, registering |
|
442 // updates command handler, so client responses comes to this |
|
443 // command handler |
|
444 TRAPD( err, iUtils->RegisterServiceRequestL( |
|
445 ESatSProactiveQuery, |
|
446 ESatSProactiveQueryResponse, |
|
447 this ) ); |
|
448 |
|
449 if ( KErrNone != err ) |
|
450 { |
|
451 iLaunchBrowserRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
452 iLaunchBrowserRsp.iInfoType = RSat::KMeProblem; |
|
453 iLaunchBrowserRsp.iAdditionalInfo.SetLength( 1 ); |
|
454 iLaunchBrowserRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
455 iLaunchBrowserRsp.SetPCmdNumber( iLaunchBrowserData.PCmdNumber() ); |
|
456 TerminalRsp( RSat::ELaunchBrowser, iLaunchBrowserRspPckg ); |
|
457 |
|
458 LOG2( SIMPLE, |
|
459 "LAUNCHBROWSER: CLaunchBrowserHandler::HandleCommand error: %i", err ) |
|
460 } |
|
461 else if ( iNeedUiSession ) |
|
462 { |
|
463 iQueryData.iCommand = ESatSLaunchBrowserQuery; |
|
464 iQueryData.iQueryText = iLaunchBrowserData.iAlphaId.iAlphaId; |
|
465 iQueryData.iIconId.iIdentifier = |
|
466 iLaunchBrowserData.iIconId.iIdentifier; |
|
467 LOG2( SIMPLE, "CLaunchBrowserHandler::HandleCommand \ |
|
468 iLaunchBrowserData.iIconId.iQualifier: %i", |
|
469 iLaunchBrowserData.iIconId.iQualifier ) |
|
470 switch ( iLaunchBrowserData.iIconId.iQualifier ) |
|
471 { |
|
472 case RSat::ESelfExplanatory: |
|
473 { |
|
474 // Icon qualifier is self explanatory (to display instead |
|
475 // of the alpha id or text string). |
|
476 iQueryData.iIconId.iIconQualifier = ESatSelfExplanatory; |
|
477 break; |
|
478 } |
|
479 |
|
480 case RSat::ENotSelfExplanatory: |
|
481 { |
|
482 // Icon qualifier is not self explanatory. |
|
483 iQueryData.iIconId.iIconQualifier = ESatNotSelfExplanatory; |
|
484 break; |
|
485 } |
|
486 |
|
487 default: |
|
488 { |
|
489 // Icon qualifier not present |
|
490 iQueryData.iIconId.iIconQualifier = ESatENoIconId; |
|
491 break; |
|
492 } |
|
493 } |
|
494 |
|
495 if ( RSat::EAlphaIdNotPresent == iLaunchBrowserData.iAlphaId.iStatus ) |
|
496 { |
|
497 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::HandleCommand \ |
|
498 EAlphaIdNotPresent" ) |
|
499 iQueryData.iAlphaIdStatus = ESatAlphaIdNotProvided; |
|
500 } |
|
501 else if ( RSat::EAlphaIdProvided == |
|
502 iLaunchBrowserData.iAlphaId.iStatus ) |
|
503 { |
|
504 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::HandleCommand \ |
|
505 EAlphaIdProvided" ) |
|
506 iQueryData.iAlphaIdStatus = ESatAlphaIdNotNull; |
|
507 } |
|
508 else |
|
509 { |
|
510 iQueryData.iAlphaIdStatus = ESatAlphaIdNull; |
|
511 } |
|
512 |
|
513 iQueryData.iSimApplicationName = iUtils->SatAppName(); |
|
514 |
|
515 // Ask the user permission to launch browser. Reply will come |
|
516 // to ClientResponse() method. |
|
517 iUtils->SatUiHandler().UiSession()->SendCommand( |
|
518 &iQueryPckg, |
|
519 &iQueryRspPckg, |
|
520 ESatSProactiveQuery ); |
|
521 } |
|
522 else // transparent launch |
|
523 { |
|
524 // Launch the Browser. |
|
525 TRAP( err, LaunchBrowserL() ); |
|
526 |
|
527 if ( KErrNone != err ) |
|
528 { |
|
529 iLaunchBrowserRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
530 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
531 CLaunchBrowserHandler::HandleCommand error: %i", err ) |
|
532 } |
|
533 else |
|
534 { |
|
535 LOG( SIMPLE, |
|
536 "LAUNCHBROWSER: CLBH::CR ESetUpMenuRequested registered" ) |
|
537 TRAP_IGNORE( iUtils->RegisterL( |
|
538 this, MSatUtils::ESetUpMenuRequested ) ) |
|
539 } |
|
540 |
|
541 TerminalRsp( RSat::ELaunchBrowser, iLaunchBrowserRspPckg ); |
|
542 } |
|
543 |
|
544 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::HandleCommand exiting" ) |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // From class CSatCommandHandler. |
|
549 // Indicates the failure of launching ui client. |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CLaunchBrowserHandler::UiLaunchFailed() |
|
553 { |
|
554 LOG( SIMPLE, |
|
555 "LAUNCHBROWSER: CLaunchBrowserHandler::UiLaunchFailed calling" ) |
|
556 |
|
557 iLaunchBrowserRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
558 iLaunchBrowserRsp.iInfoType = RSat::KMeProblem; |
|
559 iLaunchBrowserRsp.iAdditionalInfo.SetLength( 1 ); |
|
560 iLaunchBrowserRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
561 iLaunchBrowserRsp.SetPCmdNumber( iLaunchBrowserData.PCmdNumber() ); |
|
562 TerminalRsp( RSat::ELaunchBrowser, iLaunchBrowserRspPckg ); |
|
563 |
|
564 LOG( SIMPLE, |
|
565 "LAUNCHBROWSER: CLaunchBrowserHandler::UiLaunchFailed exiting" ) |
|
566 } |
|
567 |
|
568 // ----------------------------------------------------------------------------- |
|
569 // C++ default constructor can NOT contain any code, that |
|
570 // might leave. |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 //lint -e{1403, 1769} Can not be initialized, harmless. |
|
574 CLaunchBrowserHandler::CLaunchBrowserHandler() : |
|
575 CSatCommandHandler(), |
|
576 iLaunchBrowserData(), |
|
577 iLaunchBrowserPckg( iLaunchBrowserData ), |
|
578 iLaunchBrowserRsp(), |
|
579 iLaunchBrowserRspPckg( iLaunchBrowserRsp ), |
|
580 iQueryData(), |
|
581 iQueryPckg( iQueryData ), |
|
582 iQueryRsp(), |
|
583 iQueryRspPckg( iQueryRsp ), |
|
584 iUidWmlBrowser( TUid::Uid( KWmlcHandler ) ), |
|
585 iAfterTimer( NULL ), |
|
586 // To be removed when icons are allowed in this command |
|
587 iIconCommand( EFalse ) |
|
588 { |
|
589 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::CLaunchBrowserHandler \ |
|
590 calling - exiting" ) |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // Symbian 2nd phase constructor can leave. |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 void CLaunchBrowserHandler::ConstructL() |
|
598 { |
|
599 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::ConstructL calling" ) |
|
600 |
|
601 // Open the Window server session. |
|
602 User::LeaveIfError( iWsSession.Connect() ); |
|
603 |
|
604 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::ConstructL exiting" ) |
|
605 } |
|
606 |
|
607 |
|
608 // ----------------------------------------------------------------------------- |
|
609 // Checks if Browser application is launched. |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 TBool CLaunchBrowserHandler::BrowserExists() |
|
613 { |
|
614 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::BrowserExists calling" ) |
|
615 TBool browserExists( EFalse ); |
|
616 |
|
617 TApaTaskList taskList( iWsSession ); |
|
618 TApaTask task = taskList.FindApp( iUidWmlBrowser ); |
|
619 browserExists = task.Exists(); |
|
620 |
|
621 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::BrowserExists exiting" ) |
|
622 return browserExists; |
|
623 } |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // The Launch Browser handler. |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 void CLaunchBrowserHandler::LaunchBrowserL() |
|
630 { |
|
631 LOG( SIMPLE, |
|
632 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL calling" ) |
|
633 |
|
634 // Check the URL length. |
|
635 const TInt urlLen( iLaunchBrowserData.iUrl.Length() ); |
|
636 |
|
637 // ID of the accesspoint in the communications database. |
|
638 TUid accesspointID( TUid::Uid( KErrNotFound ) ); |
|
639 |
|
640 // If apId is given by SIM card, then we use that, otherwise, |
|
641 // get default apId from default connection method. |
|
642 TUint32 apId( 0 ); |
|
643 // GCF is supported since S60 5.0 |
|
644 apId = GetAccessPointByGatewayAddressL(); |
|
645 if ( apId ) |
|
646 { |
|
647 LOG2( SIMPLE, |
|
648 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL, \ |
|
649 Get gcf AP id = %d", apId ) |
|
650 accesspointID.iUid = static_cast<TInt32>( apId ); |
|
651 } |
|
652 |
|
653 // Get default AP if GCF ap not found |
|
654 if ( KErrNotFound == accesspointID.iUid ) |
|
655 { |
|
656 LOG( SIMPLE, |
|
657 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL, \ |
|
658 no gcf AP id" ) |
|
659 apId = GetAccessPointByDefaultL(); |
|
660 if ( apId ) |
|
661 { |
|
662 LOG2( SIMPLE, |
|
663 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL, \ |
|
664 default AP id = %d", apId ) |
|
665 accesspointID.iUid = static_cast<TInt32>( apId ); |
|
666 } |
|
667 } |
|
668 |
|
669 LOG2( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL, \ |
|
670 accesspointID.iUid=%d", accesspointID.iUid ) |
|
671 |
|
672 HBufC* param = NULL; |
|
673 // If the URL is given by SIM, then we use that |
|
674 if ( urlLen ) |
|
675 { |
|
676 // Url is given by SIM, and we use that. |
|
677 param = HBufC::NewLC( urlLen ); |
|
678 param->Des().Copy( iLaunchBrowserData.iUrl ); |
|
679 LOG3( SIMPLE, |
|
680 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL,\ |
|
681 url is given by SIM, url=%s, length=%d", |
|
682 param, param->Des().Length() ) |
|
683 } |
|
684 // If no url from SIM, get default URL by selected access point. |
|
685 else if ( !param && accesspointID.iUid > 0 ) |
|
686 { |
|
687 param = GetDefaultUrlByAccessPointLC( |
|
688 static_cast<TUint32>( accesspointID.iUid) ); |
|
689 LOG3( SIMPLE, |
|
690 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL,\ |
|
691 url is given by IAP, url=%s, length=%d", |
|
692 param, param->Des().Length() ) |
|
693 } |
|
694 else |
|
695 { |
|
696 param = KNullDesC().AllocLC(); |
|
697 LOG( SIMPLE, |
|
698 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL no url" ) |
|
699 } |
|
700 |
|
701 switch ( iLaunchBrowserData.iBrowserSel ) |
|
702 { |
|
703 case RSat::ECloseExistingLaunchNewBrowserSession: |
|
704 { |
|
705 LOG( NORMAL, "LAUNCHBROWSER: CLaunchBrowserHandler:: \ |
|
706 LaunchBrowserL, ECloseExistingLaunchNewBrowserSession" ) |
|
707 CloseBrowser(); // Close Browser Session if it exists. |
|
708 LaunchWithUrlL( param->Des(), accesspointID ); |
|
709 break; |
|
710 } |
|
711 |
|
712 case RSat::ELaunchBrowserIfNotAlreadyLaunched: |
|
713 { |
|
714 LOG( NORMAL, "LAUNCHBROWSER: CLaunchBrowserHandler:: \ |
|
715 LaunchBrowserL, ELaunchBrowserIfNotAlreadyLaunched" ) |
|
716 if ( BrowserExists() ) |
|
717 { |
|
718 LOG( SIMPLE,"CLaunchBrowserHandler::LaunchBrowserL \ |
|
719 BrowserExists" ) |
|
720 // Browser exists, error response returned. |
|
721 iLaunchBrowserRsp.iGeneralResult = RSat::KLaunchBrowserError; |
|
722 iLaunchBrowserRsp.iInfoType = RSat::KMeProblem; |
|
723 iLaunchBrowserRsp.iAdditionalInfo.Append( |
|
724 RSat::KBrowserUnavailable ); |
|
725 } |
|
726 else |
|
727 { |
|
728 LaunchWithUrlL( param->Des(), accesspointID ); |
|
729 } |
|
730 break; |
|
731 } |
|
732 |
|
733 case RSat::EUseExistingBrowser: |
|
734 { |
|
735 // SAT Shell Controller looks if browser already exists. |
|
736 LOG( NORMAL, "LAUNCHBROWSER: CLaunchBrowserHandler:: \ |
|
737 LaunchBrowserL,EUseExistingBrowser" ) |
|
738 LaunchWithUrlL( param->Des(), accesspointID ); |
|
739 break; |
|
740 } |
|
741 |
|
742 case RSat::EBrowserSelectionNotSet: |
|
743 default: |
|
744 __ASSERT_DEBUG( EFalse, |
|
745 Panic( KLaunchBrowserHandlerName, KErrBadName ) ); |
|
746 break; |
|
747 } |
|
748 |
|
749 CleanupStack::PopAndDestroy( param ); |
|
750 |
|
751 LOG( SIMPLE, |
|
752 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchBrowserL exiting" ) |
|
753 } |
|
754 |
|
755 // -------------------------------------------------------------------------- |
|
756 // Closes the Browser application if it is active and waits until |
|
757 // closing is complete. |
|
758 // -------------------------------------------------------------------------- |
|
759 // |
|
760 void CLaunchBrowserHandler::CloseBrowser() |
|
761 { |
|
762 LOG( SIMPLE, |
|
763 "LAUNCHBROWSER: CLaunchBrowserHandler::CloseBrowser calling" ) |
|
764 TApaTaskList taskList( iWsSession ); |
|
765 TApaTask task = taskList.FindApp( iUidWmlBrowser ); |
|
766 |
|
767 if ( task.Exists() ) |
|
768 { |
|
769 task.SendSystemEvent( EApaSystemEventShutdown ); |
|
770 |
|
771 TBool browserExists( ETrue ); |
|
772 TInt waitCount( 0 ); |
|
773 LOG2( SIMPLE, |
|
774 "CLaunchBrowserHandler::CloseBrowser browserExists: %d", |
|
775 browserExists ) |
|
776 // Make sure that closing is completed. |
|
777 while ( browserExists ) |
|
778 { |
|
779 After( KSatSShortLoopTimeout ); |
|
780 ++waitCount; |
|
781 |
|
782 TApaTask newTask = taskList.FindApp( iUidWmlBrowser ); |
|
783 browserExists = newTask.Exists(); |
|
784 |
|
785 if ( KSatSWaitCount <= waitCount ) |
|
786 { |
|
787 newTask.KillTask(); |
|
788 browserExists = EFalse; |
|
789 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler:: \ |
|
790 CloseBrowser force kill task" ) |
|
791 } |
|
792 } |
|
793 } |
|
794 |
|
795 LOG( SIMPLE, |
|
796 "LAUNCHBROWSER: CLaunchBrowserHandler::CloseBrowser exiting" ) |
|
797 } |
|
798 |
|
799 // -------------------------------------------------------------------------- |
|
800 // Launches The Browser with URL. |
|
801 // -------------------------------------------------------------------------- |
|
802 // |
|
803 void CLaunchBrowserHandler::LaunchWithUrlL( const TDesC& aParam, |
|
804 const TUid& aAccessPointUid ) |
|
805 { |
|
806 LOG( SIMPLE, |
|
807 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchWithUrlL calling" ) |
|
808 LOG3( SIMPLE, |
|
809 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchWithUrlL\ |
|
810 url=%s, IAP=%d", &aParam, aAccessPointUid.iUid ) |
|
811 |
|
812 // Browser launching called. |
|
813 //TInt err = iUtils->SatUiHandler().ShellController().LaunchBrowserL( |
|
814 // aParam, aAccessPointUid ); |
|
815 TInt err = KErrNone; |
|
816 |
|
817 if ( KErrNone == err ) |
|
818 { |
|
819 if ( !iQueryRsp.iRequestedIconDisplayed && |
|
820 ( ( RSat::ESelfExplanatory == |
|
821 iLaunchBrowserData.iIconId.iQualifier ) || |
|
822 ( RSat::ENotSelfExplanatory == |
|
823 iLaunchBrowserData.iIconId.iQualifier ) ) ) |
|
824 { |
|
825 iLaunchBrowserRsp.iGeneralResult = |
|
826 RSat::KSuccessRequestedIconNotDisplayed; |
|
827 LOG( SIMPLE, |
|
828 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchWithUrlL \ |
|
829 no icon shown" ) |
|
830 } |
|
831 else |
|
832 { |
|
833 iLaunchBrowserRsp.iGeneralResult = RSat::KSuccess; |
|
834 LOG( SIMPLE, |
|
835 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchWithUrlL \ |
|
836 command ok" ) |
|
837 } |
|
838 } |
|
839 else |
|
840 { |
|
841 iLaunchBrowserRsp.iGeneralResult = RSat::KLaunchBrowserError; |
|
842 iLaunchBrowserRsp.iInfoType = RSat::KMeProblem; |
|
843 iLaunchBrowserRsp.iAdditionalInfo.Append( |
|
844 RSat::KBrowserUnavailable ); |
|
845 LOG2( SIMPLE, |
|
846 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchWithUrlL error: %i", |
|
847 err ) |
|
848 } |
|
849 |
|
850 LOG( SIMPLE, |
|
851 "LAUNCHBROWSER: CLaunchBrowserHandler::LaunchWithUrlL exiting" ) |
|
852 } |
|
853 |
|
854 // -------------------------------------------------------------------------- |
|
855 // Starts timer. Function returns as the given time has elapsed or |
|
856 // timer is cancelled. |
|
857 // -------------------------------------------------------------------------- |
|
858 void CLaunchBrowserHandler::After( |
|
859 const TTimeIntervalMicroSeconds32& aDelay, |
|
860 const TTimeIntervalMicroSeconds32& aInterval ) |
|
861 { |
|
862 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::After calling" ) |
|
863 |
|
864 if ( !iAfterWait.IsStarted() ) |
|
865 { |
|
866 TRAPD( err, iAfterTimer = CPeriodic::NewL( EPriorityStandard ) ) |
|
867 LOG2( SIMPLE, |
|
868 "LAUNCHBROWSER: CLaunchBrowserHandler::After err: %i", err ) |
|
869 if ( ( KErrNone == err ) && iAfterTimer ) |
|
870 { |
|
871 iAfterTimer->Start( |
|
872 aDelay, aInterval, TCallBack( DelayCallBack, this ) ); |
|
873 iAfterWait.Start(); |
|
874 |
|
875 delete iAfterTimer; |
|
876 iAfterTimer = NULL; |
|
877 } |
|
878 } |
|
879 |
|
880 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::After exiting" ) |
|
881 } |
|
882 |
|
883 // -------------------------------------------------------------------------- |
|
884 // Timer call back function |
|
885 // -------------------------------------------------------------------------- |
|
886 TInt CLaunchBrowserHandler::DelayCallBack( TAny* aPtr ) |
|
887 { |
|
888 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::DelayCallBack \ |
|
889 calling" ) |
|
890 CLaunchBrowserHandler* ptrThis = |
|
891 static_cast<CLaunchBrowserHandler*>( aPtr ); |
|
892 |
|
893 if ( ptrThis && ( ptrThis->iAfterWait.IsStarted() ) ) |
|
894 { |
|
895 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::DelayCallBack \ |
|
896 stop iAfterWait" ) |
|
897 ptrThis->iAfterWait.AsyncStop(); |
|
898 } |
|
899 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::DelayCallBack \ |
|
900 exiting" ) |
|
901 return ( EFalse ); |
|
902 } |
|
903 |
|
904 // -------------------------------------------------------------------------- |
|
905 // Create a new access point using the Access Point Engine. |
|
906 // -------------------------------------------------------------------------- |
|
907 // |
|
908 TUint32 CLaunchBrowserHandler::CreateAccessPointL( |
|
909 const TDesC16& aApName, |
|
910 const TDesC16& aProxyServerAddr, |
|
911 const TUint32 aProxyPortNumber, |
|
912 const RPacketContext::TProtocolType& aIPvType ) |
|
913 { |
|
914 LOG( SIMPLE, |
|
915 "LAUNCHBROWSER: CLaunchBrowserHandler::CreateAccessPointL calling" ) |
|
916 |
|
917 // Connection method interface. |
|
918 RCmConnectionMethod cm; |
|
919 // Connection method manager interface. |
|
920 RCmManager cmManager; |
|
921 // Used to exit connection methods go through loop |
|
922 TBool exitConnectionMethodsLoop( EFalse ); |
|
923 |
|
924 cmManager.OpenLC(); |
|
925 |
|
926 // Find if the access point with the same name is already exist. |
|
927 // If such access point exists, delete it and then create a new one. |
|
928 |
|
929 // Get the Connection Methods does not belogns to any destination |
|
930 RArray<TUint32> array = RArray<TUint32>( KSatCMGranularity ); |
|
931 CleanupClosePushL( array ); |
|
932 |
|
933 cmManager.ConnectionMethodL( array ); |
|
934 |
|
935 // Go through the Connection Method list to find if there is matched one |
|
936 |
|
937 for( TInt i = 0; |
|
938 ( i < array.Count() ) && !exitConnectionMethodsLoop; ++i) |
|
939 { |
|
940 cm = cmManager.ConnectionMethodL( array[i] ); |
|
941 CleanupClosePushL( cm ); |
|
942 |
|
943 // query the access point name |
|
944 HBufC * pa = NULL; |
|
945 pa = cm.GetStringAttributeL( CMManager::ECmName ); |
|
946 CleanupStack::PushL(pa); |
|
947 |
|
948 if ( *pa == aApName ) |
|
949 { |
|
950 // Find the matched connection method |
|
951 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
952 CreateAccessPointL, find the existing ap" ) |
|
953 cm.DeleteL(); |
|
954 exitConnectionMethodsLoop = ETrue; |
|
955 } |
|
956 CleanupStack::PopAndDestroy( pa ); |
|
957 CleanupStack::PopAndDestroy( &cm ); |
|
958 } |
|
959 CleanupStack::PopAndDestroy( &array ); |
|
960 |
|
961 // Create a connection method without destination. |
|
962 cm = cmManager.CreateConnectionMethodL( KUidPacketDataBearerType ); |
|
963 CleanupClosePushL( cm ); |
|
964 |
|
965 // Fulfill connection method params with default setting from OCC. |
|
966 // We use trap to continue following operations even if leaving from |
|
967 // FulfillConnnectionMethodL. |
|
968 TRAPD( errCode, FulfillConnnectionMethodL( cmManager, cm ) ); |
|
969 LOG3( SIMPLE, "SATENGINE: CLaunchBrowserHandler::CreateAccessPointL \ |
|
970 errCode=%d ad line %d", errCode, __LINE__ ) |
|
971 // Set attributes of the connection method. |
|
972 cm.SetStringAttributeL( CMManager::ECmName, aApName ); |
|
973 cm.SetIntAttributeL( CMManager::EPacketDataPDPType, aIPvType ); |
|
974 cm.SetStringAttributeL( CMManager::ECmWapIPGatewayAddress, |
|
975 TPtrC( aProxyServerAddr ) ); |
|
976 cm.SetStringAttributeL( CMManager::ECmProxyServerName, |
|
977 TPtrC( aProxyServerAddr ) ); |
|
978 cm.SetIntAttributeL( CMManager::ECmProxyPortNumber, aProxyPortNumber ); |
|
979 |
|
980 // Update the access point ID for use later. |
|
981 cm.UpdateL(); |
|
982 |
|
983 TUint32 apId = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
984 LOG2( SIMPLE, |
|
985 "LAUNCHBROWSER: CLaunchBrowserHandler::CreateAccessPointL apId=%d", |
|
986 apId ) |
|
987 |
|
988 CleanupStack::PopAndDestroy( &cm ); |
|
989 CleanupStack::PopAndDestroy( &cmManager ); |
|
990 |
|
991 LOG( SIMPLE, |
|
992 "LAUNCHBROWSER: CLaunchBrowserHandler::CreateAccessPointL exiting" ) |
|
993 |
|
994 return apId; |
|
995 } |
|
996 |
|
997 // -------------------------------------------------------------------------- |
|
998 // Get a AP from the Connection Method Manager. |
|
999 // -------------------------------------------------------------------------- |
|
1000 TUint32 CLaunchBrowserHandler::GetAccessPointByGatewayAddressL() |
|
1001 { |
|
1002 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1003 CLaunchBrowserHandler::GetAccessPointByGatewayAddressL calling" ) |
|
1004 // Access Point ID. |
|
1005 TUint32 apId( 0 ); |
|
1006 // Unknown IP address type. |
|
1007 TInt ipvType( 0 ); |
|
1008 // Get the gateway address. |
|
1009 TPtrC gatewayAddrPtr( iLaunchBrowserData.iText ); |
|
1010 // Get the bearer list. |
|
1011 TPtrC8 bearerListPtr( iLaunchBrowserData.iBearerList ); |
|
1012 |
|
1013 // Proxy address. |
|
1014 HBufC* proxyAddress = NULL; |
|
1015 // Proxy port number. |
|
1016 TUint32 proxyPortNumber( 0 ); |
|
1017 HBufC* pa = NULL; |
|
1018 TUint32 pn( 0 ); |
|
1019 |
|
1020 // Used to exit the connection method go through loop |
|
1021 TBool exitConnectionMethodsLoop( EFalse ); |
|
1022 |
|
1023 // SAT access point name. |
|
1024 TPtrC satAPN( KNullDesC ); |
|
1025 |
|
1026 // Use SAT application name as SAT APN. |
|
1027 satAPN.Set( iUtils->SatAppName() ); |
|
1028 // Use default SAT APN if SAT application name is not available. |
|
1029 if ( satAPN == KNullDesC ) |
|
1030 { |
|
1031 LOG( SIMPLE, |
|
1032 "CLaunchBrowserHandler::GetAccessPointByGatewayAddressL\ |
|
1033 satAPN == KNullDesC" ) |
|
1034 satAPN.Set( KSatAccessPointName ); |
|
1035 } |
|
1036 |
|
1037 // Get the proxy address and port number |
|
1038 proxyAddress = HBufC::NewLC( gatewayAddrPtr.Length() ); |
|
1039 TPtr proxyAddrPtr( proxyAddress->Des() ); |
|
1040 SeparatePortNumberFromAddress( gatewayAddrPtr, proxyAddrPtr, |
|
1041 proxyPortNumber ); |
|
1042 proxyAddrPtr.TrimAll(); |
|
1043 |
|
1044 // Check the launch browser package for gateway setting. |
|
1045 ipvType = ValidateGatewayAddress( proxyAddrPtr ); |
|
1046 |
|
1047 if ( RPacketContext::EPdpTypeIPv4 == ipvType || \ |
|
1048 RPacketContext::EPdpTypeIPv6 == ipvType ) |
|
1049 { |
|
1050 LOG2( SIMPLE, |
|
1051 "CLaunchBrowserHandler::GetAccessPointByGatewayAddressL \ |
|
1052 gatewayAddrPtr.Length(): %d", gatewayAddrPtr.Length() ) |
|
1053 // Check the launch browser package for bearer setting if the gateway |
|
1054 // address is valid. |
|
1055 LOG2( SIMPLE, |
|
1056 "LAUNCHBROWSER: CLaunchBrowserHandler:: \ |
|
1057 GetAccessPointByGatewayAddressL, IPvType is %d", |
|
1058 ipvType) |
|
1059 if ( gatewayAddrPtr.Length() ) |
|
1060 { |
|
1061 // The bearer is GPRS. |
|
1062 if ( bearerListPtr != KNullDesC8 && bearerListPtr.Length() > 0 |
|
1063 && RSat::KGprsBearer == bearerListPtr[0] ) |
|
1064 { |
|
1065 |
|
1066 // Go through the candidate connection methods to find |
|
1067 // the one matched the gateway address. If a matched one |
|
1068 // is found,using it as the access point for SIM service, |
|
1069 // else a new one is created. |
|
1070 RCmManager cmManager; |
|
1071 cmManager.OpenLC(); |
|
1072 |
|
1073 // Get the Connection Methods does not belongs to |
|
1074 // any destination |
|
1075 RArray<TUint32> array = RArray<TUint32>( |
|
1076 KSatCMGranularity ); |
|
1077 CleanupClosePushL( array ); |
|
1078 |
|
1079 cmManager.ConnectionMethodL( array ); |
|
1080 |
|
1081 // Go through the Connection Method list to find |
|
1082 // if there is matched one |
|
1083 |
|
1084 for( TInt i = 0; |
|
1085 ( i < array.Count() ) && !exitConnectionMethodsLoop; |
|
1086 ++i ) |
|
1087 { |
|
1088 RCmConnectionMethod cm = cmManager.ConnectionMethodL( |
|
1089 array[i] ); |
|
1090 CleanupClosePushL( cm ); |
|
1091 |
|
1092 // query the Gateway proxy address |
|
1093 // of the Connection Method |
|
1094 pa = cm.GetStringAttributeL( |
|
1095 CMManager::ECmWapIPGatewayAddress ); |
|
1096 CleanupStack::PushL(pa); |
|
1097 |
|
1098 // query the Gateway proxy port number of the Connection |
|
1099 // Method |
|
1100 pn = cm.GetIntAttributeL( |
|
1101 CMManager::ECmProxyPortNumber ); |
|
1102 |
|
1103 if (( pn == proxyPortNumber ) && |
|
1104 ( *pa == *proxyAddress )) |
|
1105 { |
|
1106 // Find the matched connection method |
|
1107 apId = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
1108 LOG2( SIMPLE, |
|
1109 "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1110 GetAccessPointByGatewayAddressL, apId=%d", |
|
1111 apId ) |
|
1112 exitConnectionMethodsLoop = ETrue; |
|
1113 } |
|
1114 |
|
1115 CleanupStack::PopAndDestroy( pa ); |
|
1116 CleanupStack::PopAndDestroy( &cm ); |
|
1117 } |
|
1118 |
|
1119 CleanupStack::PopAndDestroy( &array ); |
|
1120 CleanupStack::PopAndDestroy( &cmManager ); |
|
1121 |
|
1122 LOG2( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler:: \ |
|
1123 GetAccessPointByGatewayAddressL apId=%d", apId ) |
|
1124 |
|
1125 if ( !apId ) |
|
1126 { |
|
1127 // Create a new AP if there is not a matched one. |
|
1128 apId = CreateAccessPointL( |
|
1129 satAPN, |
|
1130 proxyAddrPtr, |
|
1131 proxyPortNumber, |
|
1132 static_cast<RPacketContext::TProtocolType>( |
|
1133 ipvType ) ); |
|
1134 } |
|
1135 } |
|
1136 } |
|
1137 } |
|
1138 CleanupStack::PopAndDestroy( proxyAddress ); |
|
1139 |
|
1140 LOG2( SIMPLE, |
|
1141 "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1142 GetAccessPointByGatewayAddressL exiting, apId=%d", apId ) |
|
1143 |
|
1144 // return the AP. |
|
1145 return apId; |
|
1146 } |
|
1147 |
|
1148 // -------------------------------------------------------------------------- |
|
1149 // Get an Access Point by default. |
|
1150 // -------------------------------------------------------------------------- |
|
1151 TUint32 CLaunchBrowserHandler::GetAccessPointByDefaultL() |
|
1152 { |
|
1153 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1154 GetAccessPointByDefaultL calling" ) |
|
1155 |
|
1156 TUint32 apId ( KErrNone ); |
|
1157 RCmManager cmManager; |
|
1158 cmManager.OpenLC(); |
|
1159 RCmConnectionMethod cm; |
|
1160 CleanupClosePushL( cm ); |
|
1161 |
|
1162 // Get a default connection method |
|
1163 TInt ret( KErrNotFound ); |
|
1164 GetDefConnMethodL( cmManager, cm, ret ); |
|
1165 if ( !ret ) |
|
1166 { |
|
1167 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1168 GetAccessPointByDefaultL default connection found" ) |
|
1169 apId = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
1170 } |
|
1171 |
|
1172 CleanupStack::PopAndDestroy( &cm ); |
|
1173 CleanupStack::PopAndDestroy( &cmManager ); |
|
1174 |
|
1175 LOG2( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1176 GetAccessPointByDefaultL exiting, apId=%d", apId ) |
|
1177 |
|
1178 return apId; |
|
1179 } |
|
1180 |
|
1181 // -------------------------------------------------------------------------- |
|
1182 // Get default URL by access point |
|
1183 // -------------------------------------------------------------------------- |
|
1184 HBufC* CLaunchBrowserHandler::GetDefaultUrlByAccessPointLC( TUint32 aApId ) |
|
1185 { |
|
1186 LOG2( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1187 GetDefaultUrlByAccessPointLC calling, aApId=%d", aApId ) |
|
1188 |
|
1189 HBufC* url = NULL; |
|
1190 if ( aApId > 0 ) |
|
1191 { |
|
1192 // Create CMManager session |
|
1193 RCmManager cmManager; |
|
1194 cmManager.OpenLC(); |
|
1195 |
|
1196 // get the connection method by apId |
|
1197 RCmConnectionMethod cm = cmManager.ConnectionMethodL( aApId ); |
|
1198 CleanupClosePushL( cm ); |
|
1199 |
|
1200 // Get the default URL from default accesspoint |
|
1201 // If the access point doesn't include the default URL, |
|
1202 // the empty string is returned. |
|
1203 url = cm.GetStringAttributeL( CMManager::ECmStartPage ); |
|
1204 |
|
1205 CleanupStack::PopAndDestroy( &cm ); |
|
1206 CleanupStack::PopAndDestroy( &cmManager ); |
|
1207 |
|
1208 CleanupStack::PushL( url ); |
|
1209 } |
|
1210 |
|
1211 if ( !url ) |
|
1212 { |
|
1213 url = KNullDesC().AllocLC(); |
|
1214 } |
|
1215 |
|
1216 LOG2( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1217 GetDefaultUrlByAccessPointLC exiting, url=%s", url ) |
|
1218 return url; |
|
1219 } |
|
1220 |
|
1221 // -------------------------------------------------------------------------- |
|
1222 // Convert a descriptor into a integer. |
|
1223 // -------------------------------------------------------------------------- |
|
1224 TInt CLaunchBrowserHandler::ConvertDesToInt( const TDesC16& aDes ) |
|
1225 { |
|
1226 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1227 CLaunchBrowserHandler::ConvertDesToInt calling,length of aDes:%d", |
|
1228 aDes.Length() ) |
|
1229 |
|
1230 TLex converter; |
|
1231 TInt intValue( KErrNotFound ); |
|
1232 TBool digital( ETrue ); |
|
1233 |
|
1234 if ( aDes != KNullDesC && aDes.Length() > 0 ) |
|
1235 { |
|
1236 // The literal value of every element in the descriptor |
|
1237 // should be numerical. |
|
1238 for ( TInt i = 0; i < aDes.Length() && digital; i++ ) |
|
1239 { |
|
1240 TChar ch( aDes[i] ); |
|
1241 |
|
1242 if ( !ch.IsDigit() ) |
|
1243 { |
|
1244 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1245 CLaunchBrowserHandler::ConvertDesToInt not digit" ) |
|
1246 digital = EFalse; |
|
1247 } |
|
1248 } |
|
1249 |
|
1250 if ( digital ) |
|
1251 { |
|
1252 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1253 CLaunchBrowserHandler::ConvertDesToInt digit" ) |
|
1254 // Converting. |
|
1255 converter.Assign( aDes ); |
|
1256 converter.Val( intValue ); |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1261 CLaunchBrowserHandler::ConvertDesToInt exiting,intValue:%d", |
|
1262 intValue ) |
|
1263 |
|
1264 return intValue; |
|
1265 } |
|
1266 |
|
1267 // -------------------------------------------------------------------------- |
|
1268 // Check the validity of a descriptor in hex. |
|
1269 // -------------------------------------------------------------------------- |
|
1270 TBool CLaunchBrowserHandler::ValidateHexadecimal( const TDesC16& aHex ) |
|
1271 { |
|
1272 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1273 CLaunchBrowserHandler::ValidateHexadecimal calling" ) |
|
1274 |
|
1275 // The hexadecimal descriptor can be null. |
|
1276 TInt length( aHex.Length() ); |
|
1277 TBool retVal( ETrue ); |
|
1278 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1279 CLaunchBrowserHandler::ValidateHexadecimal length:%d", length ) |
|
1280 |
|
1281 // Validate characters one by one. |
|
1282 for ( TInt i = 0; i < length && retVal; i++ ) |
|
1283 { |
|
1284 TChar ch( aHex[i] ); |
|
1285 |
|
1286 if ( !ch.IsHexDigit() ) |
|
1287 { |
|
1288 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1289 CLaunchBrowserHandler::ValidateHexadecimal hex digit,i: %d", |
|
1290 i ) |
|
1291 retVal = EFalse; |
|
1292 } |
|
1293 } |
|
1294 |
|
1295 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1296 CLaunchBrowserHandler::ValidateHexadecimal exiting, retVal:%d", |
|
1297 retVal ) |
|
1298 |
|
1299 return retVal; |
|
1300 } |
|
1301 |
|
1302 // -------------------------------------------------------------------------- |
|
1303 // Check the validity of a IPv4 address. For example, 210.13.246.172. |
|
1304 // -------------------------------------------------------------------------- |
|
1305 TBool CLaunchBrowserHandler::ValidateIPv4Address( |
|
1306 const TDesC16& aAddress ) |
|
1307 { |
|
1308 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1309 CLaunchBrowserHandler::ValidateIPv4Address calling,aAddress: %s", |
|
1310 &aAddress ) |
|
1311 |
|
1312 // Separate the address to be three segments using dot and validate |
|
1313 // each segment. |
|
1314 TPtrC segPtr( aAddress ); |
|
1315 TBuf<KSatMaxIPv4SegmentLength> segment; |
|
1316 TInt posInDes( KErrNone ); |
|
1317 TInt posInPtr( KErrNone ); |
|
1318 TInt segCounter( KErrNone ); |
|
1319 TBool first( ETrue ); |
|
1320 TBool retVal( ETrue ); |
|
1321 // Segment value in integer. |
|
1322 TInt intValue( KErrNone ); |
|
1323 |
|
1324 // Convert each segment into integer. |
|
1325 while ( KErrNotFound != ( posInPtr = segPtr.Find( KSatIPv4Delimiter ) ) |
|
1326 && retVal ) |
|
1327 { |
|
1328 |
|
1329 if ( KSatMaxIPv4SegmentLength >= posInPtr && 0 < posInPtr ) |
|
1330 { |
|
1331 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1332 CLaunchBrowserHandler::ValidateIPv4Address posInPtr valid" ) |
|
1333 segCounter++; |
|
1334 posInDes += posInPtr; |
|
1335 segment = segPtr.Mid( 0, posInPtr ); |
|
1336 |
|
1337 // The first integer should be > 0 and < 255, others should be |
|
1338 // >=0 and < 255. |
|
1339 intValue = ConvertDesToInt( segment ); |
|
1340 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1341 CLaunchBrowserHandler::ValidateIPv4Address first:%d",first ) |
|
1342 if ( first ) |
|
1343 { |
|
1344 first = EFalse; |
|
1345 |
|
1346 if ( !( KSatIPv4Network < intValue && |
|
1347 KSatIPv4Broadcast > intValue ) ) |
|
1348 { |
|
1349 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1350 ValidateIPv4Address intValue valid" ) |
|
1351 retVal = EFalse; |
|
1352 } |
|
1353 } |
|
1354 else |
|
1355 { |
|
1356 |
|
1357 if ( !( KSatIPv4Network <= intValue && |
|
1358 KSatIPv4Broadcast > intValue ) ) |
|
1359 { |
|
1360 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1361 ValidateIPv4Address intValue range" ) |
|
1362 retVal = EFalse; |
|
1363 } |
|
1364 } |
|
1365 // Skip dot. |
|
1366 posInDes++; |
|
1367 segPtr.Set( aAddress.Mid( posInDes, |
|
1368 aAddress.Length() - posInDes ) ); |
|
1369 } |
|
1370 else |
|
1371 { |
|
1372 retVal = EFalse; |
|
1373 } |
|
1374 } |
|
1375 |
|
1376 // IPv4 address is consist of 4 segment |
|
1377 if ( KSatMaxIPv4SegmentCounter == segCounter && retVal ) |
|
1378 { |
|
1379 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1380 CLaunchBrowserHandler::ValidateIPv4Address valid address" ) |
|
1381 // Validate the last segment. |
|
1382 segment = segPtr; |
|
1383 |
|
1384 if ( KSatMaxIPv4SegmentLength < segment.Length() ) |
|
1385 { |
|
1386 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1387 CLaunchBrowserHandler::ValidateIPv4Address address invalid" ) |
|
1388 retVal = EFalse; |
|
1389 } |
|
1390 |
|
1391 intValue = ConvertDesToInt( segment ); |
|
1392 |
|
1393 if ( !( KSatIPv4Network < intValue && |
|
1394 KSatIPv4Broadcast > intValue ) ) |
|
1395 { |
|
1396 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1397 CLaunchBrowserHandler::ValidateIPv4Address intValue range" ) |
|
1398 retVal = EFalse; |
|
1399 } |
|
1400 } |
|
1401 else |
|
1402 { |
|
1403 retVal = EFalse; |
|
1404 } |
|
1405 |
|
1406 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1407 CLaunchBrowserHandler::ValidateIPv4Address exiting,retVal:%d", |
|
1408 retVal ) |
|
1409 |
|
1410 return retVal; |
|
1411 } |
|
1412 |
|
1413 // -------------------------------------------------------------------------- |
|
1414 // Check the validity of a IPv6 address. For example, |
|
1415 // 3ffe:ffff:101::230:6eff:fe04:d9ff. |
|
1416 // -------------------------------------------------------------------------- |
|
1417 TBool CLaunchBrowserHandler::ValidateIPv6Address( |
|
1418 const TDesC16& aAddress ) |
|
1419 { |
|
1420 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1421 CLaunchBrowserHandler::ValidateIPv6Address calling,aAddress: %s", |
|
1422 &aAddress ) |
|
1423 |
|
1424 // Separate the address to be eight segments using colon and validate |
|
1425 // each segment. |
|
1426 TPtrC segPtr( aAddress ); |
|
1427 TBuf<KSatMaxIPv6SegmentLength> segment; |
|
1428 TInt posInDes( KErrNone ); |
|
1429 TInt posInPtr( KErrNone ); |
|
1430 TInt segCounter( KErrNone ); |
|
1431 TBool first( ETrue ); |
|
1432 TBool retVal( ETrue ); |
|
1433 |
|
1434 while ( KErrNotFound != ( posInPtr = segPtr.Find( KSatIPv6Delimiter ) ) |
|
1435 && retVal ) |
|
1436 { |
|
1437 |
|
1438 if ( KSatMaxIPv6SegmentLength >= posInPtr && 0 <= posInPtr ) |
|
1439 { |
|
1440 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1441 CLaunchBrowserHandler::ValidateIPv6Address posInPtr valid" ) |
|
1442 segCounter++; |
|
1443 posInDes += posInPtr; |
|
1444 segment = segPtr.Mid( 0, posInPtr ); |
|
1445 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1446 CLaunchBrowserHandler::ValidateIPv6Address first:%d",first ) |
|
1447 if ( first ) |
|
1448 { |
|
1449 first = EFalse; |
|
1450 |
|
1451 if ( 0 >= segment.Length() ) |
|
1452 { |
|
1453 retVal = EFalse; |
|
1454 } |
|
1455 } |
|
1456 |
|
1457 if ( KSatMaxIPv6SegmentLength < segment.Length() ) |
|
1458 { |
|
1459 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1460 CLaunchBrowserHandler::ValidateIPv6Address address invalid" ) |
|
1461 retVal = EFalse; |
|
1462 } |
|
1463 |
|
1464 if ( !ValidateHexadecimal( segment ) ) |
|
1465 { |
|
1466 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1467 ValidateIPv6Address address invalid hex" ) |
|
1468 retVal = EFalse; |
|
1469 } |
|
1470 |
|
1471 // Skip colon. |
|
1472 posInDes++; |
|
1473 segPtr.Set( aAddress.Mid( posInDes, |
|
1474 aAddress.Length() - posInDes ) ); |
|
1475 } |
|
1476 else |
|
1477 { |
|
1478 retVal = EFalse; |
|
1479 } |
|
1480 } |
|
1481 |
|
1482 // IPv6 address is consist of 8 segment |
|
1483 if ( KSatMaxIPv6SegmentCounter == segCounter && retVal ) |
|
1484 { |
|
1485 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1486 CLaunchBrowserHandler::ValidateIPv6Address valid address" ) |
|
1487 // Validate the last segment. |
|
1488 segment = segPtr; |
|
1489 |
|
1490 if ( KSatMaxIPv6SegmentLength < segment.Length() ) |
|
1491 { |
|
1492 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1493 CLaunchBrowserHandler::ValidateIPv6Address address invalid" ) |
|
1494 retVal = EFalse; |
|
1495 } |
|
1496 |
|
1497 if ( !ValidateHexadecimal( segment ) ) |
|
1498 { |
|
1499 LOG( SIMPLE, "LAUNCHBROWSER: CLaunchBrowserHandler::\ |
|
1500 ValidateIPv6Address address invalid hex" ) |
|
1501 retVal = EFalse; |
|
1502 } |
|
1503 } |
|
1504 else |
|
1505 { |
|
1506 retVal = EFalse; |
|
1507 } |
|
1508 |
|
1509 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1510 CLaunchBrowserHandler::ValidateIPv6Address exiting,retVal:%d", |
|
1511 retVal ) |
|
1512 |
|
1513 return retVal; |
|
1514 } |
|
1515 |
|
1516 // -------------------------------------------------------------------------- |
|
1517 // Check the validity of a gateway IP address. Either it is IPv4 or IPv6. |
|
1518 // For example, 210.13.246.172 or 3ffe:ffff:101::230:6eff:fe04:d9ff. |
|
1519 // -------------------------------------------------------------------------- |
|
1520 TInt CLaunchBrowserHandler::ValidateGatewayAddress( |
|
1521 const TDesC16& aAddress ) |
|
1522 { |
|
1523 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1524 CLaunchBrowserHandler::ValidateGatewayAddress calling,length of \ |
|
1525 aAddress: %d", aAddress.Length() ) |
|
1526 |
|
1527 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1528 CLaunchBrowserHandler::ValidateGatewayAddress aAddress: %s", &aAddress ) |
|
1529 TInt ipvType( KSatInvalidPdpType ); |
|
1530 TInt length( aAddress.Length() ); |
|
1531 |
|
1532 if ( length ) |
|
1533 { |
|
1534 // The maximum length of a IP address is less than 39. |
|
1535 if ( KSatMaxIPv4AddressLength >= length && |
|
1536 KSatMinIPv4AddressLength <= length ) |
|
1537 { |
|
1538 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1539 CLaunchBrowserHandler::ValidateGatewayAddress IPV4 address" ) |
|
1540 // aAddress is a IPv4 address. |
|
1541 if ( ValidateIPv4Address( aAddress ) ) |
|
1542 { |
|
1543 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1544 CLaunchBrowserHandler::ValidateGatewayAddress valid IPV4 \ |
|
1545 address" ) |
|
1546 ipvType = RPacketContext::EPdpTypeIPv4; |
|
1547 } |
|
1548 } |
|
1549 else if ( KSatMaxIPv6AddressLength >= length && |
|
1550 KSatMinIPv6AddressLength <= length ) |
|
1551 { |
|
1552 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1553 CLaunchBrowserHandler::ValidateGatewayAddress IPV6 address" ) |
|
1554 // aAddress is a IPv6 address. |
|
1555 if ( ValidateIPv6Address( aAddress ) ) |
|
1556 { |
|
1557 LOG( SIMPLE, "LAUNCHBROWSER: \ |
|
1558 CLaunchBrowserHandler::ValidateGatewayAddress valid IPV6 \ |
|
1559 address" ) |
|
1560 ipvType = RPacketContext::EPdpTypeIPv6; |
|
1561 } |
|
1562 } |
|
1563 } |
|
1564 |
|
1565 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1566 CLaunchBrowserHandler::ValidateGatewayAddress exiting,ipvType:%d", |
|
1567 ipvType ) |
|
1568 |
|
1569 // Returned IP address. |
|
1570 return ipvType; |
|
1571 } |
|
1572 |
|
1573 // -------------------------------------------------------------------------- |
|
1574 // Separate the port number from a address if it is existing. For example, |
|
1575 // 210.13.246.172:8080. |
|
1576 // -------------------------------------------------------------------------- |
|
1577 void CLaunchBrowserHandler::SeparatePortNumberFromAddress( |
|
1578 const TDesC16& aAddress, |
|
1579 TDes16& aPureAddr, |
|
1580 TUint32& aPortNumber ) |
|
1581 { |
|
1582 LOG2( SIMPLE, "LAUNCHBROWSER: \ |
|
1583 CLaunchBrowserHandler::SeparatePortNumberFromAddress calling,\ |
|
1584 aAddress: %s", &aAddress ) |
|
1585 |
|
1586 // The following three variables are used to locate the port number. |
|
1587 TBool isSeparator( EFalse ); |
|
1588 TBool portNumberBegin( EFalse ); |
|
1589 TBool portNumberEnd( EFalse ); |
|
1590 TBool pureAddrEnd( EFalse ); |
|
1591 // Count delimiters in the address. |
|
1592 TInt delimiterCounter( 0 ); |
|
1593 // Count symbols in a segment of the address. |
|
1594 TInt symbolCounter( 0 ); |
|
1595 // Currsent position of the address descriptor. |
|
1596 TInt curPos( 0 ); |
|
1597 TInt posOffset( 0 ); |
|
1598 // The position of the last valid character. |
|
1599 TInt rightBound( 0 ); |
|
1600 // Digital port number. |
|
1601 TUint32 portNumber( KSatLaunchBrowserProxyPortNumber ); |
|
1602 // The descriptor pointer for the address. |
|
1603 TPtrC addrPtr; |
|
1604 // The length of the address. |
|
1605 TInt addrLen( 0 ); |
|
1606 |
|
1607 // The address is a valid descriptor. |
|
1608 if ( NULL != &aAddress && |
|
1609 KSatMinIPv4AddressLength <= aAddress.Length() ) |
|
1610 { |
|
1611 addrPtr.Set( aAddress ); |
|
1612 addrLen = aAddress.Length(); |
|
1613 curPos = addrPtr.Find( KSatIPv4Delimiter ); |
|
1614 |
|
1615 LOG2( SIMPLE, "CLaunchBrowserHandler::\ |
|
1616 SeparatePortNumberFromAddress curPos: %i", curPos ) |
|
1617 if ( KErrNotFound != curPos ) |
|
1618 { |
|
1619 // Skip three delimiters in the IPv4 address. |
|
1620 delimiterCounter++; |
|
1621 |
|
1622 while ( KSatMaxIPv4SegmentCounter > delimiterCounter |
|
1623 && curPos < addrLen ) |
|
1624 { |
|
1625 curPos++; |
|
1626 posOffset = addrPtr.Right( addrLen - curPos ).Find( |
|
1627 KSatIPv4Delimiter ); |
|
1628 LOG2( SIMPLE, "CLaunchBrowserHandler::\ |
|
1629 SeparatePortNumberFromAddress posOffset: %i", posOffset ) |
|
1630 if ( KErrNotFound != posOffset ) |
|
1631 { |
|
1632 delimiterCounter++; |
|
1633 curPos += posOffset; |
|
1634 } |
|
1635 else |
|
1636 { |
|
1637 delimiterCounter = KSatMaxIPv4SegmentCounter; |
|
1638 } |
|
1639 } |
|
1640 |
|
1641 // Locate the separator between the pure address and |
|
1642 // the port number. |
|
1643 curPos++; |
|
1644 |
|
1645 while ( curPos < addrLen |
|
1646 && KSatMaxIPv4SegmentLength > symbolCounter |
|
1647 && !isSeparator ) |
|
1648 { |
|
1649 TChar ch( addrPtr[curPos] ); |
|
1650 |
|
1651 if ( ch.IsAlphaDigit() ) |
|
1652 { |
|
1653 LOG( SIMPLE, "CLaunchBrowserHandler::\ |
|
1654 SeparatePortNumberFromAddress AlphaDigit" ) |
|
1655 symbolCounter++; |
|
1656 } |
|
1657 else |
|
1658 { |
|
1659 isSeparator = ETrue; |
|
1660 } |
|
1661 |
|
1662 curPos++; |
|
1663 } |
|
1664 } |
|
1665 else |
|
1666 { |
|
1667 curPos = addrPtr.Find( KSatIPv6Delimiter ); |
|
1668 LOG2( SIMPLE, "CLaunchBrowserHandler::\ |
|
1669 SeparatePortNumberFromAddress curPos: %i", curPos ) |
|
1670 if ( KErrNotFound != curPos ) |
|
1671 { |
|
1672 // Skip seven delimiters in the IPv6 address. |
|
1673 delimiterCounter++; |
|
1674 |
|
1675 while ( KSatMaxIPv6SegmentCounter > delimiterCounter |
|
1676 && curPos < addrLen ) |
|
1677 { |
|
1678 curPos++; |
|
1679 posOffset = addrPtr.Right( addrLen - curPos ).Find( |
|
1680 KSatIPv6Delimiter ); |
|
1681 LOG2( SIMPLE, "CLaunchBrowserHandler::\ |
|
1682 SeparatePortNumberFromAddress posOffset: %i", posOffset ) |
|
1683 if ( KErrNotFound != posOffset ) |
|
1684 { |
|
1685 delimiterCounter++; |
|
1686 curPos += posOffset; |
|
1687 } |
|
1688 } |
|
1689 |
|
1690 // Locate the separator between the pure address and |
|
1691 // the port number. |
|
1692 curPos++; |
|
1693 |
|
1694 while ( curPos < addrLen && |
|
1695 KSatMaxIPv6SegmentLength > symbolCounter && |
|
1696 !isSeparator ) |
|
1697 { |
|
1698 TChar ch( addrPtr[curPos] ); |
|
1699 |
|
1700 if ( ch.IsAlphaDigit() ) |
|
1701 { |
|
1702 LOG( SIMPLE, "CLaunchBrowserHandler::\ |
|
1703 SeparatePortNumberFromAddress AlphaDigit" ) |
|
1704 symbolCounter++; |
|
1705 } |
|
1706 else |
|
1707 { |
|
1708 isSeparator = ETrue; |
|
1709 } |
|
1710 |
|
1711 curPos++; |
|
1712 } |
|
1713 } |
|
1714 } |
|
1715 |
|
1716 // Extract the pure address. |
|
1717 while ( curPos < addrLen && KSatMinIPv4AddressLength < curPos |
|
1718 && !pureAddrEnd ) |
|
1719 { |
|
1720 TChar ch( addrPtr[curPos] ); |
|
1721 |
|
1722 if ( !ch.IsAlphaDigit() ) |
|
1723 { |
|
1724 LOG( SIMPLE, "CLaunchBrowserHandler::\ |
|
1725 SeparatePortNumberFromAddress not AlphaDigit" ) |
|
1726 curPos--; |
|
1727 } |
|
1728 else |
|
1729 { |
|
1730 pureAddrEnd = ETrue; |
|
1731 } |
|
1732 } |
|
1733 |
|
1734 if ( curPos <= addrLen ) |
|
1735 { |
|
1736 aPureAddr.Copy( addrPtr.Left( curPos + 1 ) ); |
|
1737 } |
|
1738 |
|
1739 // Extract the port number. |
|
1740 // Locate the beginning of the port number. |
|
1741 curPos++; |
|
1742 |
|
1743 while ( curPos < addrLen && !portNumberBegin) |
|
1744 { |
|
1745 TChar ch( addrPtr[curPos] ); |
|
1746 |
|
1747 if ( ch.IsDigit() ) |
|
1748 { |
|
1749 LOG( SIMPLE, "CLaunchBrowserHandler::\ |
|
1750 SeparatePortNumberFromAddress Digit" ) |
|
1751 portNumberBegin = ETrue; |
|
1752 } |
|
1753 else |
|
1754 { |
|
1755 curPos++; |
|
1756 } |
|
1757 } |
|
1758 |
|
1759 // Locate the end of the port number. |
|
1760 rightBound = addrLen; |
|
1761 rightBound--; |
|
1762 |
|
1763 while ( rightBound > curPos && !portNumberEnd ) |
|
1764 { |
|
1765 TChar ch( addrPtr[rightBound] ); |
|
1766 |
|
1767 if ( ch.IsDigit() ) |
|
1768 { |
|
1769 LOG( SIMPLE, "CLaunchBrowserHandler::\ |
|
1770 SeparatePortNumberFromAddress Digit" ) |
|
1771 portNumberEnd = ETrue; |
|
1772 } |
|
1773 else |
|
1774 { |
|
1775 rightBound--; |
|
1776 } |
|
1777 } |
|
1778 |
|
1779 // Convert the port number and validate it. |
|
1780 // Set the port number to default port number |
|
1781 aPortNumber = portNumber; |
|
1782 if ( curPos < rightBound && rightBound < addrLen ) |
|
1783 { |
|
1784 portNumber = ConvertDesToInt( |
|
1785 addrPtr.Mid( curPos, rightBound - curPos + 1 ) ); |
|
1786 |
|
1787 if ( KSatMaxProxyPortNumber > portNumber && |
|
1788 KSatMinProxyPortNumber < portNumber ) |
|
1789 { |
|
1790 LOG( SIMPLE, "CLaunchBrowserHandler::\ |
|
1791 SeparatePortNumberFromAddress valid portNumber" ) |
|
1792 aPortNumber = portNumber; |
|
1793 } |
|
1794 } |
|
1795 } |
|
1796 |
|
1797 LOG( SIMPLE, |
|
1798 "LAUNCHBROWSER: CLaunchBrowserHandler::SeparatePortNumberFromAddress \ |
|
1799 exiting" ) |
|
1800 } |
|
1801 |
|
1802 // -------------------------------------------------------------------------- |
|
1803 // Fulfill connecion method params with default params. |
|
1804 // -------------------------------------------------------------------------- |
|
1805 void CLaunchBrowserHandler::FulfillConnnectionMethodL( |
|
1806 RCmManager& aCmManager, |
|
1807 RCmConnectionMethod& aCm ) |
|
1808 { |
|
1809 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1810 FulfillConnnectionMethodL calling" ) |
|
1811 |
|
1812 // The following 3 lines are used to preset the default parameters |
|
1813 // to avoid doing nothing for them if leaving. |
|
1814 aCm.SetStringAttributeL( CMManager::EPacketDataAPName, |
|
1815 KSatGprsAccessPointName ); |
|
1816 aCm.SetBoolAttributeL( CMManager::ECmIFPromptForAuth, EFalse ); |
|
1817 aCm.SetBoolAttributeL( CMManager::ECmDisablePlainTextAuth, EFalse ); |
|
1818 |
|
1819 // Get default access point ID. |
|
1820 RCmConnectionMethod defCm; |
|
1821 CleanupClosePushL( defCm ); |
|
1822 |
|
1823 TInt ret ( KErrNotFound ); |
|
1824 GetDefConnMethodL( aCmManager, defCm, ret ); |
|
1825 |
|
1826 if ( !ret ) |
|
1827 { |
|
1828 // Default AP found! Copy parameters from |
|
1829 // default AP to new created AP. |
|
1830 |
|
1831 // Copy AP name. |
|
1832 HBufC* strValue = defCm.GetStringAttributeL( |
|
1833 CMManager::EPacketDataAPName ); |
|
1834 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1835 FulfillConnnectionMethodL AP Name is %s", strValue ) |
|
1836 CleanupStack::PushL( strValue ); |
|
1837 aCm.SetStringAttributeL( CMManager::EPacketDataAPName, *strValue ); |
|
1838 CleanupStack::PopAndDestroy( strValue ); |
|
1839 |
|
1840 // Copy authentic name |
|
1841 strValue = defCm.GetStringAttributeL( CMManager::ECmIFAuthName ); |
|
1842 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1843 FulfillConnnectionMethodL Auch name is %s", strValue ) |
|
1844 CleanupStack::PushL( strValue ); |
|
1845 aCm.SetStringAttributeL( CMManager::ECmIFAuthName, *strValue ); |
|
1846 CleanupStack::PopAndDestroy( strValue ); |
|
1847 |
|
1848 // Copy authentic pass |
|
1849 strValue = defCm.GetStringAttributeL( CMManager::ECmIFAuthPass ); |
|
1850 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1851 FulfillConnnectionMethodL Auch pass is %s", strValue ) |
|
1852 CleanupStack::PushL( strValue ); |
|
1853 aCm.SetStringAttributeL( CMManager::ECmIFAuthPass, *strValue ); |
|
1854 CleanupStack::PopAndDestroy( strValue ); |
|
1855 |
|
1856 // Copy default URL |
|
1857 strValue = defCm.GetStringAttributeL( CMManager::ECmStartPage ); |
|
1858 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1859 FulfillConnnectionMethodL Start page pass is %s", strValue ) |
|
1860 CleanupStack::PushL( strValue ); |
|
1861 aCm.SetStringAttributeL( CMManager::ECmStartPage, *strValue ); |
|
1862 CleanupStack::PopAndDestroy( strValue ); |
|
1863 |
|
1864 // Copy status if prompt for auth |
|
1865 TBool bValue = defCm.GetBoolAttributeL( |
|
1866 CMManager::ECmIFPromptForAuth ); |
|
1867 aCm.SetBoolAttributeL( CMManager::ECmIFPromptForAuth, bValue ); |
|
1868 |
|
1869 // Copy security status. |
|
1870 bValue = defCm.GetBoolAttributeL( |
|
1871 CMManager::ECmDisablePlainTextAuth ); |
|
1872 aCm.SetBoolAttributeL( CMManager::ECmIFPromptForAuth, bValue ); |
|
1873 } |
|
1874 |
|
1875 CleanupStack::PopAndDestroy( &defCm ); |
|
1876 |
|
1877 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1878 FulfillConnnectionMethodL exiting" ) |
|
1879 } |
|
1880 |
|
1881 // -------------------------------------------------------------------------- |
|
1882 // Check the validity of offered bearer type |
|
1883 // -------------------------------------------------------------------------- |
|
1884 void CLaunchBrowserHandler::ValidateBearerTypeL( RCmConnectionMethod& aCm, |
|
1885 TInt& aIsValid ) |
|
1886 { |
|
1887 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1888 ValidateBearerTypeL calling" ) |
|
1889 |
|
1890 TUint32 bearerType = aCm.GetIntAttributeL( |
|
1891 CMManager::ECmBearerType ); |
|
1892 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1893 ValidateBearerTypeL bearerType=0x%x", bearerType ) |
|
1894 |
|
1895 if ( KUidPacketDataBearerType == bearerType ) |
|
1896 { |
|
1897 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1898 ValidateBearerTypeL bearer type is GPRS" ) |
|
1899 aIsValid = KErrNone; |
|
1900 } |
|
1901 |
|
1902 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1903 ValidateBearerTypeL exiting, aIsValid=%d", aIsValid ) |
|
1904 } |
|
1905 |
|
1906 // -------------------------------------------------------------------------- |
|
1907 // Get default connection method |
|
1908 // -------------------------------------------------------------------------- |
|
1909 void CLaunchBrowserHandler::GetDefConnMethodL( RCmManager& aCmManager, |
|
1910 RCmConnectionMethod& aDefCm, |
|
1911 TInt& aIsValid ) |
|
1912 { |
|
1913 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1914 GetDefConnMethodL calling" ) |
|
1915 |
|
1916 // Go through the default connection methods to find |
|
1917 // the one valid connection method. |
|
1918 TCmDefConnValue defConn; |
|
1919 aCmManager.ReadDefConnL( defConn ); |
|
1920 |
|
1921 LOG3( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1922 GetDefConnMethodL DefConn type=%d, id=%d", |
|
1923 defConn.iType, defConn.iId ) |
|
1924 |
|
1925 // Mark aIsFound as KErrNone if there is one valid |
|
1926 // connection method, otherwise KErrNotFound. |
|
1927 aIsValid = KErrNotFound; |
|
1928 |
|
1929 // Default setting is a connection method |
|
1930 if ( ECmDefConnConnectionMethod == defConn.iType ) |
|
1931 { |
|
1932 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1933 GetDefConnMethodL ECmDefConnConnectionMethod" ) |
|
1934 aDefCm = aCmManager.ConnectionMethodL( defConn.iId ); |
|
1935 // Check bearer type, leave if not GPRS |
|
1936 ValidateBearerTypeL( aDefCm, aIsValid ); |
|
1937 } |
|
1938 |
|
1939 // Default setting is a destination |
|
1940 else if ( ECmDefConnDestination == defConn.iType ) |
|
1941 { |
|
1942 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1943 GetDefConnMethodL ECmDefConnDestination" ) |
|
1944 RCmDestination defDes = aCmManager.DestinationL( defConn.iId ); |
|
1945 |
|
1946 TInt desCount = defDes.ConnectionMethodCount(); |
|
1947 |
|
1948 LOG2( SIMPLE, "SATENGINE: CLaunchBrowserHandler::\ |
|
1949 GetDefConnMethodL ECmDefConnDestination count=%d", |
|
1950 desCount ) |
|
1951 |
|
1952 for ( TInt i = 0; |
|
1953 desCount > 0 && aIsValid != KErrNone && i < desCount; i++ ) |
|
1954 { |
|
1955 // Go through all the connection methods, |
|
1956 // until find a valid one. |
|
1957 aDefCm = defDes.ConnectionMethodL( i ); |
|
1958 ValidateBearerTypeL( aDefCm, aIsValid ); |
|
1959 } |
|
1960 } |
|
1961 else |
|
1962 { |
|
1963 aIsValid = KErrNotFound; |
|
1964 } |
|
1965 LOG( SIMPLE, "SATENGINE: CLaunchBrowserHandler::GetDefConnMethodL exit" ) |
|
1966 } |
|
1967 // End Of File |
|