locationcentre/lcutils/src/lcapplauncher.cpp
branchRCL_3
changeset 16 4721bd00d3da
parent 14 3a25f69541ff
child 21 e15b7f06eba6
equal deleted inserted replaced
14:3a25f69541ff 16:4721bd00d3da
     1 /*
       
     2 * Copyright (c) 2007 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:  Utility class which provides the Application, Service and File
       
    15 *                launching services to Location Centre.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // SYSTEM INCLUDES
       
    21 #include <apgcli.h>
       
    22 #include <apgtask.h>
       
    23 #include <eikenv.h>
       
    24 #include <lcappexitobserver.h>
       
    25 #include <schemehandler.h>
       
    26 #include <DocumentHandler.h>
       
    27 #include <e32math.h>
       
    28 #include <eikappui.h>
       
    29 #include <avkon.hrh>
       
    30 
       
    31 // USER INCLUDES
       
    32 #include "lcapplauncher.h"
       
    33 #include "lcipcparams.h"
       
    34 #include "lcdebug.h"
       
    35 
       
    36 // CONSTANT DEFINITIONS
       
    37 _LIT( KLcFourSpace, "4 " );
       
    38 
       
    39 // Maximum value that the UID field can take in S60
       
    40 const TUint32   KUidMaxValue = 0xFFFFFFFF;
       
    41 
       
    42 // Application Server Service ID. This is the same valuw which AknAppService classes use
       
    43 const TUid KLcLaunchAppServiceUid = { 0x101F887A };
       
    44 
       
    45 // -------- Member functions of RLcLaunchAppService --------------------------
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // TUid RLcLaunchAppService::ServiceUid
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 TUid RLcLaunchAppService::ServiceUid() const
       
    52     {
       
    53     return KLcLaunchAppServiceUid;
       
    54     }
       
    55 
       
    56 // -------- Member functions of CLcLaunchAppService --------------------------
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CLcLaunchAppService* CLcLaunchAppService::NewL
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CLcLaunchAppService* CLcLaunchAppService::NewL()
       
    63 	{
       
    64 	CLcLaunchAppService* self = new ( ELeave ) CLcLaunchAppService();
       
    65 	return self;
       
    66 	}
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CLcLaunchAppService::~CLcLaunchAppService
       
    70 // ---------------------------------------------------------------------------
       
    71 //		
       
    72 CLcLaunchAppService::~CLcLaunchAppService()
       
    73 	{
       
    74     delete iMonitor;
       
    75     iService.Close();	
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Tvoid CLcLaunchAppService::ServerName
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CLcLaunchAppService::ServerName( TName& 	aServerName,
       
    83 					 				  TUid 		aAppServerUid,
       
    84 					 				  TUint 	aServerDifferentiator )
       
    85 	{
       
    86 	_LIT(KServerNameFormat, "%08x_%08x_AppServer");
       
    87 	aServerName.Format( KServerNameFormat, 
       
    88 						aServerDifferentiator, 
       
    89 						aAppServerUid );
       
    90 	}
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // TUid RLcLaunchAppService::ServiceUid
       
    94 // ---------------------------------------------------------------------------
       
    95 //	
       
    96 TUint CLcLaunchAppService::GenerateServerDifferentiatorAndName( 
       
    97 										TName& 		aServerName, 
       
    98 										TUid 		aAppServerUid )
       
    99 	{
       
   100 	TUint r;
       
   101 	FOREVER
       
   102 		{
       
   103 		r = Math::Random();
       
   104 		if ( r == 0 )
       
   105 			continue;
       
   106 		ServerName( aServerName, aAppServerUid, r );
       
   107 		TFindServer find( aServerName );
       
   108 		TFullName fullName;
       
   109 		if ( find.Next( fullName ) == KErrNone )
       
   110 			{
       
   111 			continue;
       
   112 			}			
       
   113 		break;
       
   114 		}		
       
   115 	return r;
       
   116 	}
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // void CLcLaunchAppService::LaunchAppL
       
   120 // ---------------------------------------------------------------------------
       
   121 //		
       
   122 void CLcLaunchAppService::LaunchAppL( const TUid& 						aAppUid, 
       
   123     					   				    MAknServerAppExitObserver& 	aObserver, 
       
   124     				 				  const TDesC&               		aCmdLineArg )
       
   125 	{	
       
   126 	DEBUG("+ CLcLaunchAppService::LaunchAppL")
       
   127 		
       
   128 	CEikonEnv* eikEnv = CEikonEnv::Static();		
       
   129 	RWindowGroup& wg = eikEnv->RootWin();
       
   130 	
       
   131 	TName notUsed;
       
   132 	const TUint differentiator = GenerateServerDifferentiatorAndName( notUsed, aAppUid );
       
   133 	TRequestStatus requestStatusForRendezvous;
       
   134 	
       
   135 	RApaLsSession apa;
       
   136 	User::LeaveIfError( apa.Connect());
       
   137 	CleanupClosePushL( apa );
       
   138 	
       
   139     // Check for the Application capabilities
       
   140     TApaAppCapabilityBuf capabilityBuf;
       
   141     User::LeaveIfError( apa.GetAppCapability( capabilityBuf, aAppUid ));
       
   142     TApaAppCapability& caps = capabilityBuf();
       
   143 	
       
   144 	// Launch only those applications can be embedded and will not be run the background
       
   145 	
       
   146 	if( caps.iLaunchInBackground || 
       
   147 	    caps.iEmbeddability == TApaAppCapability::ENotEmbeddable )
       
   148 		{
       
   149 		User::Leave( KErrNotSupported );
       
   150 		}
       
   151 			
       
   152 	TApaAppInfo info;
       
   153 	User::LeaveIfError( apa.GetAppInfo( info, aAppUid ));
       
   154 
       
   155     // Pack the command line arguments
       
   156 	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
   157 	cmdLine->SetExecutableNameL(info.iFullName);
       
   158 	cmdLine->SetServerRequiredL(differentiator);
       
   159 
       
   160     // Set the Command line arguments.
       
   161     if ( aCmdLineArg.Length())
       
   162         {
       
   163         // These arguments would be sent as Tail end arguments to the launched
       
   164         // Application. Its left to the application to handle those
       
   165         HBufC8* tailEnd = HBufC8::NewLC( aCmdLineArg.Length());
       
   166         tailEnd->Des().Copy( aCmdLineArg );
       
   167         
       
   168         // The Tail end buffer is copied to the Command line structure. Hence,
       
   169         // can delete this variable after the set operation succeeds.
       
   170         cmdLine->SetTailEndL( tailEnd->Des());
       
   171         
       
   172         CleanupStack::PopAndDestroy( tailEnd );
       
   173         }
       
   174 
       
   175 	cmdLine->SetCommandL( EApaCommandRun );
       
   176 
       
   177 	// Window chain the client with the current application
       
   178 	const TInt parentWindowGroupID = wg.Identifier();
       
   179 	if ( parentWindowGroupID )
       
   180 		{
       
   181 		cmdLine->SetParentWindowGroupID( parentWindowGroupID );
       
   182 		wg.AllowProcessToCreateChildWindowGroups( aAppUid );
       
   183 		}
       
   184 
       
   185 	// Launch the requested Application
       
   186 	TThreadId threadNotUsed;
       
   187 	User::LeaveIfError( apa.StartApp( *cmdLine, 
       
   188 								      threadNotUsed, 
       
   189 								      &requestStatusForRendezvous ));
       
   190 
       
   191 	CleanupStack::PopAndDestroy(2, &apa);	// cmdLine and apa	
       
   192 	
       
   193 	CEikAppUi* appUi = eikEnv->EikAppUi();
       
   194 	if ( appUi )
       
   195 		{
       
   196 		appUi->DeactivateActiveViewL();
       
   197 		}
       
   198 
       
   199 	User::WaitForRequest( requestStatusForRendezvous );
       
   200 	User::LeaveIfError( requestStatusForRendezvous.Int());
       
   201 	
       
   202 	// Establish a connection to the running server
       
   203 	TName serverName;
       
   204 	ServerName( serverName, aAppUid, differentiator );
       
   205 	
       
   206 	// Though the server had been successfully created the application
       
   207 	// has can shutdown before we can establish a connection. There is nothing
       
   208 	// that we can do here. Ignore the error.	
       
   209 	iService.ConnectExistingByNameL(serverName );
       
   210 
       
   211 	// Set the observer for receiving notifications of the application exit.
       
   212     iMonitor = CApaServerAppExitMonitor::NewL( iService, 
       
   213     										   aObserver,
       
   214     										   CActive::EPriorityStandard );
       
   215     										   
       
   216     DEBUG("- CLcLaunchAppService::LaunchAppL")    										   
       
   217 	}
       
   218     				 
       
   219 
       
   220 // ----- Member funtions for CLcAppLauncher ----------------------------------
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 // CLcAppLauncher::CLcAppLauncher
       
   224 // ---------------------------------------------------------------------------
       
   225 //
       
   226 CLcAppLauncher::CLcAppLauncher()
       
   227     {
       
   228     // C++ Default constructor. No allocations or functions which can Leave
       
   229     // should be called from here.
       
   230     }
       
   231          
       
   232 // ---------------------------------------------------------------------------
       
   233 // CLcAppLauncher::~CLcAppLauncher
       
   234 // ---------------------------------------------------------------------------
       
   235 //
       
   236 CLcAppLauncher::~CLcAppLauncher()
       
   237     {
       
   238 	
       
   239 	// Delete the Broswer launcher.
       
   240 	delete iBrowserLauncher;
       
   241 	
       
   242 	// Delete the document handler.
       
   243 	delete iDocHandler;
       
   244 	
       
   245 	// Delete the Application Service if it exists
       
   246 	delete iAppService;    	
       
   247     }
       
   248         
       
   249 // ---------------------------------------------------------------------------
       
   250 // CLcAppLauncher* CLcAppLauncher::NewL
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 EXPORT_C CLcAppLauncher* CLcAppLauncher::NewL()
       
   254     {
       
   255     CLcAppLauncher* self = NewLC();
       
   256     CleanupStack::Pop( self );
       
   257     return self;         
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // CLcAppLauncher* CLcAppLauncher::NewLC
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 EXPORT_C CLcAppLauncher* CLcAppLauncher::NewLC()
       
   265     {
       
   266     // Symbian Two phased constructor. Leaves the object on the Clean-up
       
   267     // stack.
       
   268     CLcAppLauncher* self = new ( ELeave ) CLcAppLauncher();
       
   269     CleanupStack::PushL( self );
       
   270     self->ConstructL();
       
   271     return self;         
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // void CLcAppLauncher::ConstructL
       
   276 // ---------------------------------------------------------------------------
       
   277 //
       
   278 void CLcAppLauncher::ConstructL()
       
   279     {
       
   280     // Second phase of the two phase constructor.    
       
   281     iEnv = CEikonEnv::Static();
       
   282     }
       
   283 
       
   284 // ---------------------------------------------------------------------------
       
   285 // void LcAppLauncher::LaunchLocationApplicationL
       
   286 // ---------------------------------------------------------------------------
       
   287 //
       
   288 EXPORT_C void CLcAppLauncher::LaunchLocationApplicationL(
       
   289                                 TInt                 	aAppType,
       
   290                           const TDesC&                  aIdentifer,
       
   291                                 TBool                   aStandAlone,
       
   292                           const TDesC&                  aCmdLineArg,
       
   293                                 MLcAppExitObserver*     aExitObserver )
       
   294     {  
       
   295     DEBUG("+ CLcLaunchAppService::LaunchLocationApplicationL")
       
   296     
       
   297     // Check for the validity of the request
       
   298     
       
   299     // Check if there is an outstanding Embedded launch request
       
   300     if(( isEmbeddedLaunchOutstanding && !aStandAlone ) ||
       
   301        ( !aStandAlone && !iEnv ))
       
   302     	{
       
   303         User::Leave( KErrNotSupported );    	
       
   304     	}
       
   305     
       
   306     // At any instant of time this class can one outstanding Exit observer.
       
   307     // There is currently no provision of storing a list of observers and
       
   308     // mapping them correspondingly to each of the assciated applications
       
   309     // Hence, Leave if there exists an Exit observer.
       
   310     if (( aExitObserver && iExitObserver ))
       
   311         {
       
   312         User::Leave( KErrAlreadyExists );
       
   313         }
       
   314         
       
   315     // Launch the Applications based on their type and Mode of launching
       
   316     switch ( aAppType )
       
   317         {
       
   318         case ELcNativeApplication:
       
   319             {
       
   320             // Since the request is for a Native S60 application, the Identifer
       
   321             // contains an UID. Obtain it using Lexer
       
   322             TLex lexer( aIdentifer );
       
   323             TUint32 uidValue;
       
   324             
       
   325             User::LeaveIfError( lexer.BoundedVal( uidValue, EHex, KUidMaxValue ));
       
   326             
       
   327             if ( aStandAlone )
       
   328             	{
       
   329 	            // Launch the Location based Application based standalone mode
       
   330 	            LaunchAppL( TUid::Uid( uidValue ), aCmdLineArg );   	
       
   331             	}
       
   332 			else
       
   333 				{
       
   334 				// Launch Application in the chained mode
       
   335 				LaunchAppAsChainedL( TUid::Uid( uidValue ), aCmdLineArg, aExitObserver );
       
   336 				}
       
   337                 
       
   338             break;
       
   339             }
       
   340         case ELcWebUrl:
       
   341             {
       
   342             LaunchWebBroserL( aIdentifer, aStandAlone, aExitObserver );
       
   343             break;
       
   344             }
       
   345         case ELcDocument:
       
   346             {
       
   347             LaunchContentL( aIdentifer, aStandAlone, aExitObserver );
       
   348             break;
       
   349             }
       
   350         default:
       
   351             {
       
   352             User::Leave( KErrNotSupported );
       
   353             break;
       
   354             }
       
   355         }
       
   356         
       
   357     DEBUG("+ CLcLaunchAppService::LaunchLocationApplicationL")        
       
   358     }
       
   359         
       
   360 // ---------------------------------------------------------------------------
       
   361 // void LcAppLauncher::LaunchAppL
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 void CLcAppLauncher::LaunchAppL(
       
   365                                 TUid                    aApplicationUid,
       
   366                           const TDesC&                  aCmdLineArg )
       
   367     {  
       
   368     DEBUG("+ CLcAppLauncher::LaunchAppL")
       
   369     
       
   370     // Create the Session handle and connect to the Application architecture
       
   371     // server. This is required to obtain the details of the application from
       
   372     // the Application UID.
       
   373     RApaLsSession lsSession;
       
   374     User::LeaveIfError( lsSession.Connect() );
       
   375     CleanupClosePushL( lsSession );
       
   376         
       
   377     // Get the Application's capability.
       
   378     TApaAppCapabilityBuf capabilityBuf;
       
   379     User::LeaveIfError( lsSession.GetAppCapability( capabilityBuf, aApplicationUid ));
       
   380     TApaAppCapability& caps = capabilityBuf();
       
   381 	
       
   382 	if ( caps.iEmbeddability == TApaAppCapability::EEmbeddableOnly ||
       
   383 	     caps.iEmbeddability == TApaAppCapability::EEmbeddableUiNotStandAlone )
       
   384 	    {
       
   385 	    User::Leave( KErrNotSupported );
       
   386 	    }
       
   387 		            
       
   388     // Get the Application Information.
       
   389     TApaAppInfo appInfo;    
       
   390     User::LeaveIfError( lsSession.GetAppInfo( appInfo, aApplicationUid ) );
       
   391     
       
   392     // Fill the command line argument structure
       
   393     CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
   394     
       
   395     // Set the Application name.    
       
   396     TFileName appName = appInfo.iFullName;
       
   397     cmdLine->SetExecutableNameL( appName );
       
   398     
       
   399     // Set the Command
       
   400     if ( caps.iLaunchInBackground )
       
   401         {
       
   402         cmdLine->SetCommandL( EApaCommandBackground );
       
   403         }
       
   404     else
       
   405         {
       
   406         cmdLine->SetCommandL( EApaCommandRun );
       
   407         }
       
   408 
       
   409     // Set the Command line arguments.
       
   410     if ( aCmdLineArg.Length())
       
   411         {
       
   412         // These arguments would be sent as Tail end arguments to the launched
       
   413         // Application. Its left to the application to handle those
       
   414         HBufC8* tailEnd = HBufC8::NewLC( aCmdLineArg.Length());
       
   415         tailEnd->Des().Copy( aCmdLineArg );
       
   416         
       
   417         // The Tail end buffer is copied to the Command line structure. Hence,
       
   418         // can delete this variable after the set operation succeeds.
       
   419         cmdLine->SetTailEndL( tailEnd->Des());
       
   420         
       
   421         CleanupStack::PopAndDestroy( tailEnd );
       
   422         }
       
   423 
       
   424 	// Start the Application
       
   425 	User::LeaveIfError( lsSession.StartApp( *cmdLine ));
       
   426     
       
   427     // Clean up all the allocated heap variables.
       
   428     CleanupStack::PopAndDestroy( cmdLine );
       
   429     CleanupStack::PopAndDestroy(); //lsSession 		         
       
   430     
       
   431     DEBUG("- CLcAppLauncher::LaunchAppL")
       
   432     }
       
   433 
       
   434 // ---------------------------------------------------------------------------
       
   435 // void LcAppLauncher::LaunchAppAsChainedL
       
   436 // ---------------------------------------------------------------------------
       
   437 //
       
   438 void CLcAppLauncher::LaunchAppAsChainedL( 	  
       
   439 							  TUid                    aApplicationUid,                               
       
   440                  		const TDesC&                  aCmdLineArg,
       
   441                  			  MLcAppExitObserver*     aExitObserver )
       
   442 	{
       
   443 	DEBUG("+ CLcAppLauncher::LaunchAppAsChainedL" )
       
   444 	
       
   445 	// Createt the App service object and launch the application
       
   446 	CLcLaunchAppService* appService = CLcLaunchAppService::NewL();
       
   447 	CleanupStack::PushL( appService );
       
   448 	appService->LaunchAppL( aApplicationUid, *this, aCmdLineArg );
       
   449 	CleanupStack::Pop( appService );
       
   450 	
       
   451 	// Transfer the ownership to this class.
       
   452 	iAppService = appService;	
       
   453 	isEmbeddedLaunchOutstanding = ETrue;
       
   454 	
       
   455 	// Store the Observer for future reference
       
   456 	iExitObserver = aExitObserver;
       
   457 	
       
   458 	DEBUG("- CLcAppLauncher::LaunchAppAsChainedL" )	
       
   459 	}
       
   460 	
       
   461 // ---------------------------------------------------------------------------
       
   462 // void LcAppLauncher::LaunchWebBroserL
       
   463 // ---------------------------------------------------------------------------
       
   464 // 
       
   465 void CLcAppLauncher::LaunchWebBroserL( const TDesC&              aUrl,
       
   466                                              TBool               aStandAlone,
       
   467                                              MLcAppExitObserver* aObserver )
       
   468     {
       
   469     // The parameters need to be packed in the order specified by the browser.
       
   470     // Parameters are separated by space
       
   471     // 1st parameter: Type of the second parameter. In this case 4 to indicate
       
   472     //                that the second parameter is a URL.
       
   473     // 2nd parameter: URL that needs to be launched in the browser.
       
   474     // Since we have to pack "4 " before the URL name, the total length of
       
   475     // the parameter string should be Length of the URL + 2.
       
   476     HBufC* param = HBufC::NewLC(( 2 + aUrl.Length()));
       
   477     param->Des().Append( KLcFourSpace );
       
   478     param->Des().Append( aUrl );
       
   479     
       
   480     if ( aStandAlone )
       
   481         {
       
   482         // The URL is launched in the Browser. Set the Browser UID as the UID
       
   483         // of the application which needs to be launched.
       
   484         const TInt KBrowserUid = 0x10008D39;
       
   485         TUid id( TUid::Uid( KBrowserUid ) );
       
   486         
       
   487         // Check if the Browser application is already running. Incase its
       
   488         // running Open this URL in the browser.
       
   489         TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   490         TApaTask task = taskList.FindApp( id );
       
   491         if ( task.Exists() )
       
   492             {
       
   493             // The browser is running. Launch the URL.
       
   494             HBufC8* param8 = HBufC8::NewLC( param->Length() );
       
   495             param8->Des().Append( *param );
       
   496             task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
       
   497             CleanupStack::PopAndDestroy();
       
   498             }
       
   499         else 
       
   500             {
       
   501             // The browser is not running. Start the browser application with
       
   502             // the specified parameter. This is done by launching the browser with
       
   503             // a document name as the URL.
       
   504             RApaLsSession appArcSession;
       
   505             
       
   506             // Connect to the Application architecture server.
       
   507             User::LeaveIfError( appArcSession.Connect());
       
   508             CleanupClosePushL( appArcSession );
       
   509             TThreadId id;
       
   510             
       
   511             // Start the browser with the URL
       
   512             User::LeaveIfError( appArcSession.StartDocument( *param, 
       
   513                                                              TUid::Uid( KBrowserUid ),
       
   514                                                              id ));
       
   515             CleanupStack::PopAndDestroy( &appArcSession );
       
   516             }        
       
   517         }
       
   518     else
       
   519         {
       
   520         
       
   521         if ( !iBrowserLauncher )
       
   522             {
       
   523             // Create the Browser instance    
       
   524             iBrowserLauncher = CSchemeHandler::NewL( aUrl );
       
   525             }
       
   526             
       
   527         // Launch the Web URL in a browser in the Embedded mode.
       
   528         iBrowserLauncher->HandleUrlEmbeddedL();
       
   529         iBrowserLauncher->Observer( this );
       
   530             
       
   531         // Set the Observer incase we need to notify the termination of the
       
   532         // browser                                              
       
   533         aObserver ? ( iExitObserver = aObserver ) : NULL;
       
   534         
       
   535         isEmbeddedLaunchOutstanding = ETrue;      
       
   536         }
       
   537     CleanupStack::PopAndDestroy( param ); // param
       
   538     
       
   539     }
       
   540 
       
   541 // ---------------------------------------------------------------------------
       
   542 // void LcAppLauncher::LaunchContentL
       
   543 // ---------------------------------------------------------------------------
       
   544 //    
       
   545 void CLcAppLauncher::LaunchContentL( const TDesC&       		aFileName,
       
   546     						   			   TBool                aStandAlone,
       
   547     						   			   MLcAppExitObserver*  aObserver )
       
   548     {
       
   549     if ( !iDocHandler )
       
   550     	{
       
   551     	iDocHandler = CDocumentHandler::NewL();
       
   552     	iDocHandler->SetExitObserver( this );
       
   553     	}
       
   554    
       
   555     TDataType dataType;    
       
   556     if ( aStandAlone )
       
   557     	{
       
   558 	   	// The return values are ignored since, the User Cancelling the event doesnt
       
   559 	   	// make any difference to the Client Application	
       
   560 	    User::LeaveIfError( iDocHandler->OpenFileL( aFileName, dataType ));      	
       
   561     	}
       
   562 	else
       
   563 		{
       
   564 		iExitObserver = aObserver;
       
   565 	   	// The return values are ignored since, the User Cancelling the event doesnt
       
   566 	   	// make any difference to the Client Application	
       
   567 	    User::LeaveIfError( iDocHandler->OpenFileEmbeddedL( aFileName, dataType ));
       
   568 	    
       
   569         isEmbeddedLaunchOutstanding = ETrue;	    	
       
   570 		}    	
       
   571     }
       
   572 
       
   573 // ---------------------------------------------------------------------------
       
   574 // void LcAppLauncher::HandleServerAppExit
       
   575 // ---------------------------------------------------------------------------
       
   576 //    
       
   577 void CLcAppLauncher::HandleServerAppExit( TInt aReason )
       
   578     {
       
   579     isEmbeddedLaunchOutstanding = EFalse;
       
   580     
       
   581     // Delete the App Service
       
   582   	delete iAppService;
       
   583   	iAppService = NULL;    
       
   584   	
       
   585     MLcAppExitObserver* observer = iExitObserver;        
       
   586     if ( observer )
       
   587     	{
       
   588     	// Once the request has been issued we can NULLify the observer. Nullifying
       
   589 	    // it before the actual callback to faciliate the launching of another app
       
   590 	    // with an exit observer when the call is executed.
       
   591 	    iExitObserver = NULL;
       
   592     
       
   593     	TRAP_IGNORE( observer->HandleChainedLocationAppExitL( aReason ));
       
   594     	}
       
   595     	
       
   596 	MAknServerAppExitObserver::HandleServerAppExit( aReason );	  
       
   597     }
       
   598 
       
   599 // End of File
       
   600