|
1 /* |
|
2 * Copyright (c) 2007-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 "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: Implementation of CWsfAppLauncher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // EXTERNAL INCLUDES |
|
22 #include <apgtask.h> |
|
23 #include <apgcli.h> |
|
24 #include <centralrepository.h> |
|
25 #include <BrowserUiSDKCRKeys.h> |
|
26 #include <bldvariant.hrh> |
|
27 #include <featmgr.h> |
|
28 #include <cmmanager.h> |
|
29 #include <cmmanagerext.h> |
|
30 #include <cmconnectionmethod.h> |
|
31 #include <cmconnectionmethodext.h> |
|
32 |
|
33 // CLASS HEADER |
|
34 #include "wsfapplauncher.h" |
|
35 |
|
36 // INTERNAL INCLUDES |
|
37 #include "wsfbrowserlaunchobserver.h" |
|
38 #include "wsflogger.h" |
|
39 #include "wsfactivewaiter.h" |
|
40 |
|
41 |
|
42 // LOCAL DEFINITIONS |
|
43 /** |
|
44 * Delay that we wait for the browser to start or terminate |
|
45 */ |
|
46 static const TInt KTimerTickInterval = 2 * 1000 * 1000; |
|
47 |
|
48 /** |
|
49 * Repository key ID for the browser's homepage URL |
|
50 */ |
|
51 static const TUint32 KBrowserNGHomepageURL = 0x00000030; |
|
52 |
|
53 |
|
54 #ifdef _DEBUG |
|
55 _LIT( KBrowserLauncherPanic, "CWsfAppLauncher" ); |
|
56 #define _ASSERTD( cond ) __ASSERT_DEBUG( (cond), User::Panic( KBrowserLauncherPanic, __LINE__) ) |
|
57 #else |
|
58 #define _ASSERTD( cond ) {} |
|
59 #endif //_DEBUG |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CWsfAppLauncher::NewL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CWsfAppLauncher* CWsfAppLauncher::NewL() |
|
67 { |
|
68 CWsfAppLauncher* self = CWsfAppLauncher::NewLC(); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CWsfAppLauncher::NewLC |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CWsfAppLauncher* CWsfAppLauncher::NewLC() |
|
79 { |
|
80 CWsfAppLauncher* self = new( ELeave ) CWsfAppLauncher(); |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 return self; |
|
84 } |
|
85 |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CWsfAppLauncher::~CWsfAppLauncher |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CWsfAppLauncher::~CWsfAppLauncher() |
|
92 { |
|
93 Cancel(); |
|
94 delete iURL; |
|
95 delete iRepository; |
|
96 iTimer.Close(); |
|
97 iWsSession.Close(); |
|
98 } |
|
99 |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CWsfAppLauncher::CWsfAppLauncher |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CWsfAppLauncher::CWsfAppLauncher(): |
|
106 CActive( CActive::EPriorityLow ), |
|
107 iIapId( 0 ), |
|
108 iWapId( 0 ), |
|
109 iLaunchState( EIdle ), |
|
110 iRestoreSelectionMode( EFalse ), |
|
111 iRestoreAccessPoint( EFalse ), |
|
112 iLaunchBookMarks( EFalse ) |
|
113 { |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CWsfAppLauncher::ConstructL |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CWsfAppLauncher::ConstructL() |
|
122 { |
|
123 LOG_ENTERFN( "CWsfAppLauncher::ConstructL" ); |
|
124 iBrowserUid = KCRUidBrowser; |
|
125 iHomepageKey = KBrowserNGHomepageURL; |
|
126 iBrowserStartingPageKey = KBrowserNGHomepageType; |
|
127 |
|
128 // Common settings for both browsers |
|
129 iRepository = CRepository::NewL( KCRUidBrowser ); |
|
130 |
|
131 User::LeaveIfError( iWsSession.Connect() ); |
|
132 User::LeaveIfError( iTimer.CreateLocal() ); |
|
133 |
|
134 iURL = KNullDesC().AllocL(); |
|
135 CActiveScheduler::Add( this ); |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CWsfAppLauncher::LaunchBrowserL |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CWsfAppLauncher::LaunchBrowserL( MWsfBrowserLaunchObserver& aObserver, |
|
144 TUint aIapId, |
|
145 TUint aWapId, |
|
146 const TDesC& aURL ) |
|
147 { |
|
148 LOG_ENTERFN( "CWsfAppLauncher::LaunchBrowserL_3" ); |
|
149 Cancel(); |
|
150 SetAccessPoint( aWapId ); |
|
151 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_3 -->> afer cancel" ); |
|
152 iObserver = &aObserver; |
|
153 iIapId = aIapId; |
|
154 iWapId = aWapId; |
|
155 HBufC* url = aURL.AllocL(); |
|
156 delete iURL; |
|
157 iURL = url; |
|
158 |
|
159 iLaunchState = EIdle; |
|
160 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_3 -->> before set active" ); |
|
161 SetActive(); |
|
162 TRequestStatus* status = &iStatus; |
|
163 User::RequestComplete( status, KErrNone ); |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CWsfAppLauncher::LaunchBrowserL |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CWsfAppLauncher::LaunchBrowserL( MWsfBrowserLaunchObserver& aObserver, |
|
172 TUint aIapId ) |
|
173 { |
|
174 LOG_ENTERFN( "CWsfAppLauncher::LaunchBrowserL_2" ); |
|
175 LOG_WRITEF( "CWsfAppLauncher::LaunchBrowserL_2 -->> iIapid %d", aIapId ); |
|
176 HBufC* url = HBufC::NewLC( |
|
177 NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
178 TPtr urlPtr( url->Des() ); |
|
179 |
|
180 iLaunchBookMarks = EFalse; |
|
181 |
|
182 RCmManager cmManager; |
|
183 |
|
184 cmManager.OpenL(); |
|
185 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> cmmanager opened" ); |
|
186 CleanupClosePushL( cmManager ); |
|
187 |
|
188 RCmConnectionMethod plugin; |
|
189 CleanupClosePushL( plugin ); |
|
190 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> cm before open" ); |
|
191 LOG_WRITEF( "CWsfAppLauncher::LaunchBrowserL_2 -->> iIapid %d", aIapId ); |
|
192 plugin = cmManager.ConnectionMethodL( aIapId ); |
|
193 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> cm after open" ); |
|
194 |
|
195 // Browser uses WAP id instead of IAP id so |
|
196 // we need to pass wap id to browser |
|
197 TUint wapId = plugin.GetIntAttributeL( CMManager::ECmWapId ); |
|
198 LOG_WRITEF( "CWsfAppLauncher::LaunchBrowserL_2 -->> ECmWapId %d", wapId ); |
|
199 |
|
200 // do we have start page for Access Point? |
|
201 HBufC* apHomepage = NULL; |
|
202 apHomepage = plugin.GetStringAttributeL( CMManager::ECmStartPage ); |
|
203 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> String Attrib got" ); |
|
204 CleanupStack::PushL( apHomepage ); |
|
205 |
|
206 if( apHomepage->Length() == 0 ) |
|
207 { |
|
208 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> hplength = 0" ); |
|
209 // if we can't have Access Point URL then |
|
210 // we try to get browser homepage URL |
|
211 TInt err = BrowserHomepage( urlPtr ); |
|
212 |
|
213 // if browser homepage is not defined either, |
|
214 // launch bookmarks view |
|
215 if ( err || url->Length() == 0 ) |
|
216 { |
|
217 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> err in url length" ); |
|
218 iLaunchBookMarks = ETrue; |
|
219 } |
|
220 } |
|
221 else |
|
222 { |
|
223 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> hplength>0" ); |
|
224 url->Des().Copy( *apHomepage ); |
|
225 } |
|
226 |
|
227 if ( ApSelectionMode() !=0 ) |
|
228 { |
|
229 // Set AP selection mode to user defined |
|
230 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> ap selection mode" ); |
|
231 SetApSelectionMode( 0 ); |
|
232 iRestoreSelectionMode = ETrue; |
|
233 } |
|
234 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> before setAP" ); |
|
235 SetAccessPoint( wapId ); |
|
236 |
|
237 LaunchBrowserL( aObserver, aIapId, wapId, *url ); |
|
238 |
|
239 LOG_WRITE( "CWsfAppLauncher::LaunchBrowserL_2 -->> after launch _3" ); |
|
240 CleanupStack::PopAndDestroy( apHomepage ); |
|
241 CleanupStack::PopAndDestroy( &plugin ); |
|
242 CleanupStack::PopAndDestroy( &cmManager ); |
|
243 CleanupStack::PopAndDestroy( url ); |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CWsfAppLauncher::DoLaunchBrowserL |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 void CWsfAppLauncher::DoLaunchBrowserL() |
|
252 { |
|
253 LOG_ENTERFN( "CWsfAppLauncher::DoLaunchBrowserL" ); |
|
254 _LIT( KFormatCommand, "%d %S %d" ); |
|
255 const TInt KBrowserFirstParamUrlFollows = 4; |
|
256 |
|
257 iLaunchState = EStartingUp; |
|
258 HBufC* param = NULL; |
|
259 if ( iLaunchBookMarks ) |
|
260 { |
|
261 param = KNullDesC().AllocLC(); |
|
262 } |
|
263 else |
|
264 { |
|
265 param = HBufC::NewLC( KFormatCommand().Length() + iURL->Length() ); |
|
266 param->Des().Format( KFormatCommand, |
|
267 KBrowserFirstParamUrlFollows, iURL, iWapId ); |
|
268 } |
|
269 |
|
270 RApaLsSession appArcSession; |
|
271 User::LeaveIfError( appArcSession.Connect() ); // connect to AppArc server |
|
272 CleanupClosePushL( appArcSession ); |
|
273 |
|
274 User::LeaveIfError( appArcSession.StartDocument( *param, iBrowserUid, |
|
275 iThreadId ) ); |
|
276 |
|
277 CleanupStack::PopAndDestroy( &appArcSession ); |
|
278 CleanupStack::PopAndDestroy( param ); |
|
279 |
|
280 |
|
281 iTimer.Cancel(); |
|
282 iTimer.After( iStatus, KTimerTickInterval ); |
|
283 SetActive(); |
|
284 } |
|
285 |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CWsfAppLauncher::BrowserExists |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 TBool CWsfAppLauncher::BrowserExists() |
|
292 { |
|
293 LOG_ENTERFN( "CWsfAppLauncher::BrowserExists" ); |
|
294 TApaTaskList taskList( iWsSession ); |
|
295 TApaTask startedtask = taskList.FindApp( iBrowserUid ); |
|
296 return startedtask.Exists(); |
|
297 } |
|
298 |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CWsfAppLauncher::BrowserHomepage |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 TInt CWsfAppLauncher::BrowserHomepage( TDes& aHomePageURL ) |
|
305 { |
|
306 LOG_ENTERFN( "CWsfAppLauncher::BrowserHomepage" ); |
|
307 CRepository* repository( iRepository ); |
|
308 |
|
309 // get the default starting page setting |
|
310 TInt startingPageMode( 0 ); |
|
311 TInt err = repository->Get( iBrowserStartingPageKey, startingPageMode ); |
|
312 if ( err == KErrNone ) |
|
313 { |
|
314 switch ( startingPageMode ) |
|
315 { |
|
316 case 1: |
|
317 case 2: |
|
318 { |
|
319 // user defined or current page |
|
320 err = repository->Get( iHomepageKey, aHomePageURL ); |
|
321 break; |
|
322 } |
|
323 default: |
|
324 { |
|
325 aHomePageURL.Zero(); |
|
326 } |
|
327 } |
|
328 } |
|
329 |
|
330 return err; |
|
331 } |
|
332 |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // CWsfAppLauncher::KillBrowserIfAlreadyExists |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 TBool CWsfAppLauncher::KillBrowserIfAlreadyExists() |
|
339 { |
|
340 LOG_ENTERFN( "CWsfAppLauncher::KillBrowserIfAlreadyExists" ); |
|
341 _ASSERTD( iLaunchState == EIdle); |
|
342 _ASSERTD( !IsActive() ); |
|
343 |
|
344 TBool killing = EFalse; |
|
345 |
|
346 TApaTaskList taskList( iWsSession ); |
|
347 TApaTask task = taskList.FindApp( iBrowserUid ); |
|
348 |
|
349 if ( task.Exists() ) |
|
350 { |
|
351 // kill the browser... |
|
352 task.EndTask(); |
|
353 killing = ETrue; |
|
354 |
|
355 iTimer.Cancel(); |
|
356 iTimer.After( iStatus, KTimerTickInterval ); |
|
357 } |
|
358 else |
|
359 { |
|
360 TRequestStatus* status = &iStatus; |
|
361 User::RequestComplete( status, KErrNone ); |
|
362 } |
|
363 |
|
364 SetActive(); |
|
365 iLaunchState = EShuttingDown; |
|
366 return killing; |
|
367 } |
|
368 |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // CWsfAppLauncher::ContinueBrowsingL |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 void CWsfAppLauncher::ContinueBrowsingL() |
|
375 { |
|
376 LOG_ENTERFN( "CWsfAppLauncher::ContinueBrowsingL_0" ); |
|
377 //Check if the application is already running |
|
378 TBool exists = BrowserExists(); |
|
379 if ( exists ) |
|
380 { |
|
381 TApaTaskList taskList( iWsSession ); |
|
382 TApaTask task = taskList.FindApp( iBrowserUid ); |
|
383 task.BringToForeground(); |
|
384 } |
|
385 else |
|
386 { |
|
387 User::Leave( KErrNotFound ); |
|
388 } |
|
389 } |
|
390 |
|
391 |
|
392 // --------------------------------------------------------------------------- |
|
393 // CWsfAppLauncher::ContinueBrowsingL |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 void CWsfAppLauncher::ContinueBrowsingL( MWsfBrowserLaunchObserver& aObserver, |
|
397 TUint aIapId ) |
|
398 { |
|
399 LOG_ENTERFN( "CWsfAppLauncher::ContinueBrowsingL_2" ); |
|
400 //Check if the application is already running |
|
401 TBool exists = BrowserExists(); |
|
402 if ( exists ) |
|
403 { |
|
404 TApaTaskList taskList( iWsSession ); |
|
405 TApaTask task = taskList.FindApp( iBrowserUid ); |
|
406 task.BringToForeground(); |
|
407 } |
|
408 else // browser not running - launch browser |
|
409 { |
|
410 LaunchBrowserL( aObserver, aIapId ); |
|
411 } |
|
412 } |
|
413 |
|
414 |
|
415 // --------------------------------------------------------------------------- |
|
416 // CWsfAppLauncher::Launching |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 TWsfLaunchState CWsfAppLauncher::Launching() |
|
420 { |
|
421 LOG_ENTERFN( "CWsfAppLauncher::Launching" ); |
|
422 return iLaunchState; |
|
423 } |
|
424 |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CWsfAppLauncher::BrowserIap |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 TUint32 CWsfAppLauncher::BrowserIap() const |
|
431 { |
|
432 return iIapId; |
|
433 } |
|
434 |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // CWsfAppLauncher::ApSelectionModeL |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 TInt CWsfAppLauncher::ApSelectionMode() |
|
441 { |
|
442 LOG_ENTERFN( "CWsfAppLauncher::ApSelectionMode" ); |
|
443 TInt currentState = 0; |
|
444 iRepository->Get( KBrowserAccessPointSelectionMode, currentState ); |
|
445 return currentState; |
|
446 } |
|
447 |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CWsfAppLauncher::SetApSelectionModeL |
|
451 // --------------------------------------------------------------------------- |
|
452 // |
|
453 void CWsfAppLauncher::SetApSelectionMode( TInt aApSelectionMode ) |
|
454 { |
|
455 LOG_ENTERFN( "CWsfAppLauncher::SetApSelectionMode" ); |
|
456 // Valid values: 0 = User Defined, 1 = Always Ask, 2=Destination |
|
457 if ( !iRestoreSelectionMode ) |
|
458 { |
|
459 //Store original setting |
|
460 TInt OriginalApSelectionMode = 0; |
|
461 iRepository->Get( KBrowserAccessPointSelectionMode, |
|
462 OriginalApSelectionMode ); |
|
463 iOriginalApSelectionMode = OriginalApSelectionMode; |
|
464 } |
|
465 iRepository->Set( KBrowserAccessPointSelectionMode, aApSelectionMode ); |
|
466 } |
|
467 |
|
468 |
|
469 // --------------------------------------------------------------------------- |
|
470 // CWsfAppLauncher::RestoreApSelectionMode |
|
471 // --------------------------------------------------------------------------- |
|
472 // |
|
473 void CWsfAppLauncher::RestoreApSelectionMode() |
|
474 { |
|
475 LOG_ENTERFN( "CWsfAppLauncher::RestoreApSelectionMode" ); |
|
476 if ( iRestoreSelectionMode ) |
|
477 { |
|
478 SetApSelectionMode( iOriginalApSelectionMode ); |
|
479 iRestoreSelectionMode = EFalse; |
|
480 } |
|
481 } |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // CWsfAppLauncher::SetAccessPoint |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 void CWsfAppLauncher::SetAccessPoint( TUint aAccessPointId ) |
|
488 { |
|
489 LOG_ENTERFN( "CWsfAppLauncher::SetAccessPoint" ); |
|
490 LOG_WRITEF( "aAccessPointId %d", aAccessPointId ); |
|
491 CRepository* repository( iRepository ); |
|
492 TUint defaultAccessPointUid = KBrowserDefaultAccessPoint; |
|
493 |
|
494 if ( !iRestoreAccessPoint ) |
|
495 { |
|
496 // Store Access point so it can be restored after the launch |
|
497 TInt id( 0 ); |
|
498 TInt err = repository->Get( defaultAccessPointUid, id ); |
|
499 if ( err != KErrNotFound ) |
|
500 { |
|
501 iOriginalApId = (TUint)id; |
|
502 iRestoreAccessPoint = ETrue; |
|
503 } |
|
504 } |
|
505 |
|
506 repository->Set( defaultAccessPointUid, (TInt)aAccessPointId ); |
|
507 repository = NULL; |
|
508 } |
|
509 |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // CWsfAppLauncher::RestoreAccessPoint |
|
513 // --------------------------------------------------------------------------- |
|
514 // |
|
515 void CWsfAppLauncher::RestoreAccessPoint() |
|
516 { |
|
517 LOG_ENTERFN( "CWsfAppLauncher::RestoreAccessPoint" ); |
|
518 if ( iRestoreAccessPoint ) |
|
519 { |
|
520 SetAccessPoint( iOriginalApId ); |
|
521 iRestoreAccessPoint = EFalse; |
|
522 } |
|
523 } |
|
524 |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // CWsfAppLauncher::DoCancel |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 void CWsfAppLauncher::DoCancel() |
|
531 { |
|
532 LOG_ENTERFN( "CWsfAppLauncher::DoCancel" ); |
|
533 iThread.LogonCancel( iStatus ); |
|
534 |
|
535 iThread.Close(); |
|
536 iTimer.Cancel(); |
|
537 RestoreApSelectionMode(); |
|
538 RestoreAccessPoint(); |
|
539 iLaunchState = EIdle; |
|
540 } |
|
541 |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // CWsfAppLauncher::RunL |
|
545 // --------------------------------------------------------------------------- |
|
546 // |
|
547 void CWsfAppLauncher::RunL() |
|
548 { |
|
549 LOG_ENTERFN( "CWsfAppLauncher::RunL" ); |
|
550 _ASSERTD( iObserver ); |
|
551 User::LeaveIfError( iStatus.Int() ); |
|
552 |
|
553 switch( iLaunchState ) |
|
554 { |
|
555 case EIdle: // Starting to launch |
|
556 { |
|
557 LOG_WRITE( "CWsfAppLauncher::RunL -->> EIdle" ); |
|
558 KillBrowserIfAlreadyExists(); |
|
559 break; |
|
560 } |
|
561 case EShuttingDown: // Existing browser was succesfully closed |
|
562 { |
|
563 LOG_WRITE( "CWsfAppLauncher::RunL -->> EShuttingDown" ); |
|
564 DoLaunchBrowserL(); |
|
565 break; |
|
566 } |
|
567 case EStartingUp: // Start-up completed, check browser exists |
|
568 { |
|
569 LOG_WRITE( "CWsfAppLauncher::RunL -->> EStartingUp" ); |
|
570 TBool exists = BrowserExists(); |
|
571 TInt err = exists ? KErrNone : KErrNotFound; |
|
572 iLaunchState = ECompleted; |
|
573 TRequestStatus* status = &iStatus; |
|
574 User::RequestComplete( status, err ); |
|
575 SetActive(); |
|
576 break; |
|
577 } |
|
578 case ECompleted: //Browser exists, notify observer about completion |
|
579 { |
|
580 LOG_WRITE( "CWsfAppLauncher::RunL -->> ECompleted" ); |
|
581 iLaunchState = EFinished; |
|
582 LOG_WRITE( "CWsfAppLauncher::RunL -->> Before thread open" ); |
|
583 User::LeaveIfError( iThread.Open( iThreadId, EOwnerProcess ) ); |
|
584 LOG_WRITE( "CWsfAppLauncher::RunL -->> Thread opened" ); |
|
585 iObserver->BrowserLaunchCompleteL(); |
|
586 TRequestStatus* status = &iStatus; |
|
587 iThread.Logon( *status ); |
|
588 SetActive(); |
|
589 break; |
|
590 } |
|
591 case EFinished: //Browser exists, notify observer about completion |
|
592 { |
|
593 LOG_WRITE( "CWsfAppLauncher::RunL -->> EFinished" ); |
|
594 iObserver->BrowserExitL(); |
|
595 RestoreAccessPoint(); |
|
596 RestoreApSelectionMode(); |
|
597 iLaunchState = EIdle; |
|
598 break; |
|
599 } |
|
600 default: |
|
601 { |
|
602 _ASSERTD( EFalse ); |
|
603 } |
|
604 } |
|
605 } |
|
606 |
|
607 // --------------------------------------------------------------------------- |
|
608 // CWsfAppLauncher::RunError |
|
609 // --------------------------------------------------------------------------- |
|
610 // |
|
611 TInt CWsfAppLauncher::RunError( TInt aError ) |
|
612 { |
|
613 LOG_ENTERFN( "CWsfAppLauncher::RunError" ); |
|
614 _ASSERTD( iObserver ); |
|
615 |
|
616 switch( iLaunchState ) |
|
617 { |
|
618 case EIdle: // |
|
619 case EShuttingDown: // Shuttind down existing browser failed |
|
620 case EStartingUp: // Starting up new browser failed |
|
621 case ECompleted: // Starting up new browser failed |
|
622 { |
|
623 RestoreApSelectionMode(); |
|
624 RestoreAccessPoint(); |
|
625 iObserver->BrowserLaunchFailed( aError ); |
|
626 break; |
|
627 } |
|
628 default: |
|
629 { |
|
630 _ASSERTD( EFalse ); |
|
631 } |
|
632 } |
|
633 |
|
634 iLaunchState = EIdle; |
|
635 return aError; |
|
636 } |
|
637 |