locationcentre/lcutils/inc/lcapplauncher.h
branchRCL_3
changeset 9 4721bd00d3da
parent 8 3a25f69541ff
child 11 e15b7f06eba6
equal deleted inserted replaced
8:3a25f69541ff 9: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 #ifndef LCAPPLAUNCHER_H
       
    21 #define LCAPPLAUNCHER_H
       
    22 
       
    23 // SYSTEM INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <AknServerApp.h>
       
    26 
       
    27 // USER INCLUDES
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CEikonEnv;
       
    31 class MLcAppExitObserver;
       
    32 class CSchemeHandler;
       
    33 class CDocumentHandler;
       
    34 
       
    35 /**
       
    36  * Lc Launch Application Service class. This class provides the return path
       
    37  * for the Application termination call issued from an application launched
       
    38  * in the chanied mode
       
    39  */
       
    40 class RLcLaunchAppService : public RAknAppServiceBase
       
    41 	{
       
    42 public: // Inherited from Base classes
       
    43 
       
    44     /**
       
    45      * Imherited from RAknAppServiceBase
       
    46      */
       
    47 	TUid ServiceUid() const;	
       
    48 	};
       
    49 
       
    50 /** 
       
    51  * Chained Application launcher for Location Centre. This class almost acts
       
    52  * like a duplication for CAknLaunchAppService class. This is required because
       
    53  * CAknLaunchAppService doesnt take any command line arguments.
       
    54  */
       
    55 class CLcLaunchAppService : public CBase
       
    56 	{
       
    57 public:	
       
    58     /**
       
    59      * Static two phases constructor
       
    60      */
       
    61 	static CLcLaunchAppService* NewL();
       
    62 	
       
    63 	/**
       
    64 	 * C++ Destructor
       
    65 	 */
       
    66 	~CLcLaunchAppService();
       
    67 	
       
    68 	/**
       
    69 	 * Launches an Application in the chained mode.
       
    70 	 *
       
    71      * @since S60 v5.0
       
    72      * @param aApplicationUid UID of the application that needs to be
       
    73      *                        launched.    
       
    74      * @param aExitObserver   Application Exit Observer     
       
    75      * @param aCmdLineArg     Command line arguments which needs to be passed
       
    76      *                        when the application is launched.
       
    77 	 */
       
    78     void LaunchAppL( const TUid& 						aAppUid, 
       
    79     					   MAknServerAppExitObserver& 	aObserver, 
       
    80     				 const TDesC&               		aExitObserver );
       
    81 	    				 
       
    82     				 
       
    83 private:
       
    84     /**
       
    85      * Generates a Server name. This function has been duplicated
       
    86      * from CAknLaunchAppService
       
    87      *
       
    88      * @since S60 v5.0
       
    89      * @param[out] aServerName	  		 Application Server name   
       
    90      * @param[in]  aAppServerUid  		 Application server UID    
       
    91      * @param[in]  aServerDifferentiator Server differentiator    
       
    92      */
       
    93     void ServerName( TName& aServerName, TUid aAppServerUid, TUint aServerDifferentiator );
       
    94     
       
    95     /**
       
    96      * Generates a Server name and a differentiator. This function has been duplicated
       
    97      * from CAknLaunchAppService
       
    98      *
       
    99      * @since S60 v5.0
       
   100      * @param[in]  aServerName	  		 Application Server name   
       
   101      * @param[in]  aAppServerUid  		 Application server UID    
       
   102      * return Server differentiator      
       
   103      */
       
   104     TUint GenerateServerDifferentiatorAndName( TName& aServerName, TUid aAppServerUid );
       
   105     
       
   106 private: // Data members
       
   107 	/**
       
   108 	 * App Server exit monitor
       
   109 	 * Owns
       
   110 	 */    
       
   111 	CApaServerAppExitMonitor*	iMonitor;
       
   112 	
       
   113 	/**
       
   114 	 * Service class for establishing communication with the Application server
       
   115 	 */
       
   116 	RLcLaunchAppService			iService;	    				 	
       
   117 	};
       
   118 	
       
   119 /**
       
   120  *  Utility class which provides Application, Content and Services
       
   121  *  launch functionality to Location Centre.
       
   122  *
       
   123  *  @lib lcutils.lib
       
   124  *  @since S60 v5.0
       
   125  */
       
   126 class CLcAppLauncher : public CBase,
       
   127 					   public MAknServerAppExitObserver
       
   128     {
       
   129 public:
       
   130     /**
       
   131      * Constructs a new instance of Location Centre Application launcher.
       
   132      *
       
   133      * @return The new instance of Location Centre Application launcher object.
       
   134      * @leave System wide error code if the object creation fails.         
       
   135      */
       
   136     IMPORT_C static CLcAppLauncher* NewL();
       
   137     
       
   138     /**
       
   139      * Constructs a new instance of Location Centre Application launcher.
       
   140      * Leaves the created instance on the cleanup stack.
       
   141      *
       
   142      * @return The new instance of Location Centre Application launcher object.
       
   143      * @leave System wide error code if the object creation fails.         
       
   144      */
       
   145     IMPORT_C static CLcAppLauncher* NewLC();        
       
   146 
       
   147     /**
       
   148      * C++ Destructor.
       
   149      * Frees all the resources associated with this Location Centre
       
   150      * interface.
       
   151      */
       
   152     virtual ~CLcAppLauncher();
       
   153    
       
   154     /**
       
   155      * Launchers an S60 Application or a Content/Service.
       
   156      *
       
   157      * This function acts a generic interface which the Location Centre
       
   158      * Utility class provides to the Location Centre Client Library. Using
       
   159      * this class Location Centre Client library can request the launch
       
   160      * of an S60 Application, a Java based Application, Location based
       
   161      * Content / Service.
       
   162      *
       
   163      * @since v5.0
       
   164      * @param   aAppType        Application Type
       
   165      * @param   aIdentifier     Application Identifier
       
   166      * @param   aStandAlone     Boolen value indicating whether the Application
       
   167      *                          is Launched in the Stand-alone mode or in the
       
   168      *                          Chained mode.
       
   169      * @param   aCmdLineArg     Command line arguments which needs to be passed
       
   170      *                          when the application is launched.
       
   171      * @param   aExitObserver   The observer to notify the termination of the
       
   172      *                          Launched application.  
       
   173      */
       
   174     IMPORT_C void LaunchLocationApplicationL(
       
   175                                 TInt                    aAppType,
       
   176                           const TDesC&                  aIdentifer,
       
   177                                 TBool                   aStandAlone,
       
   178                           const TDesC&                  aCmdLineArg,
       
   179                                 MLcAppExitObserver*     aExitObserver );
       
   180     
       
   181 private:                          
       
   182     /**
       
   183      * Launches an S60 Application as a stand-alone application.
       
   184      *
       
   185      * This function launches an S60 application using the S60 Application
       
   186      * architecture. Each S60 application is identified by a Unique
       
   187      * identifier ( the UID of the application ). This function launches the
       
   188      * application corresponding to the UID passed to it as a standalone
       
   189      * application.
       
   190      *
       
   191      * @since S60 v5.0
       
   192      * @param aApplicationUid UID of the application that needs to be
       
   193      *                        launched.    
       
   194      * @param aCmdLineArg     Command line arguments which needs to be passed
       
   195      *                        when the application is launched.  
       
   196      */
       
   197     void LaunchAppL(       TUid                    aApplicationUid,                               
       
   198                      const TDesC&                  aCmdLineArg );
       
   199                            
       
   200 	 
       
   201     /**
       
   202      * Launches an S60 Application as a chained application.
       
   203      *
       
   204      * This function launches an S60 application using the S60 Application
       
   205      * architecture. Each S60 application is identified by a Unique
       
   206      * identifier ( the UID of the application ). This function launches the
       
   207      * application corresponding to the UID passed to it as a chained
       
   208      * application. In addition to that the caller function can also register
       
   209      * an observer to notify the termination of the launched application.
       
   210      *
       
   211      * @since S60 v5.0
       
   212      * @param aApplicationUid UID of the application that needs to be
       
   213      *                        launched.    
       
   214      * @param aCmdLineArg     Command line arguments which needs to be passed
       
   215      *                        when the application is launched.
       
   216      * @param aExitObserver   Application Exit Observer
       
   217      */	                           
       
   218 	void LaunchAppAsChainedL( 	  TUid                    aApplicationUid,                               
       
   219                      		const TDesC&                  aCmdLineArg,
       
   220                      			  MLcAppExitObserver*     aExitObserver );                           
       
   221     
       
   222     /**
       
   223      * Launches a Web URL using the S60 Web browser.
       
   224      *
       
   225      * This function launched a Web URL as specified by the argument in
       
   226      * the S60 Web browser. This function invokes the existing instance
       
   227      * of the browser with the URL if the browser is already running. In case
       
   228      * the browser is not running, it launches the browser in the stand alone
       
   229      * mode with the specified URL. Incase, the Chained mode is requested, then
       
   230      * the browser is launched in the Embedded mode.
       
   231      *
       
   232      * @since S60 v5.0
       
   233      * @param aUrl The URL which needs to be launched in the browser.
       
   234      * @param aStandAlone     Boolen value indicating whether the Application
       
   235      *                        is Launched in the Stand-alone mode or in the
       
   236      *                        Chained mode.
       
   237      * @param aObserver       Observer to notify the termination of the
       
   238      *                        Web browser.
       
   239      */                            
       
   240     void LaunchWebBroserL( const TDesC&              aUrl,
       
   241                                  TBool               aStandAlone,
       
   242                                  MLcAppExitObserver* aObserver );
       
   243     
       
   244     /**
       
   245      * Launches content present in a file using an appropriate Application.
       
   246      *
       
   247      * This function launches the content using an appropriate S60 application. It
       
   248      * uses the S60 Document handler to load the corresponding application
       
   249      * with the specified file name.
       
   250      *
       
   251      * @since S60 v5.0
       
   252      * @param aFileName 	The name with full path of the file containing the content.
       
   253      * @param aStandAlone   Boolen value indicating whether the Application
       
   254      *                      is Launched in the Stand-alone mode or in the
       
   255      *                      Chained mode.     
       
   256      * @param aObserver 	The observer to notify the termination of the launched
       
   257      *                  	application.     
       
   258      */     
       
   259     void LaunchContentL( const TDesC&       		aFileName,
       
   260     						   TBool                aStandAlone,
       
   261     						   MLcAppExitObserver*  aObserver );
       
   262                                                                          
       
   263 public: // Inherited from Base classes    
       
   264     /**
       
   265      * Inherited from MAknServerAppExitObserver
       
   266      * Notifies the termination of the Chained Application.
       
   267      *
       
   268      * @param aReason Reason for the application termination.
       
   269      */
       
   270     void HandleServerAppExit( TInt aReason );
       
   271     
       
   272 private:
       
   273     /**
       
   274      * Default C++ Constructor.
       
   275      */
       
   276     CLcAppLauncher();
       
   277 
       
   278     /**
       
   279      * Second phase of the two phase constructor.
       
   280      */
       
   281     void ConstructL();
       
   282                                                  
       
   283 private:
       
   284     /**
       
   285      * Pointer to the Eikon Environment.
       
   286      */
       
   287     CEikonEnv*              iEnv;
       
   288     
       
   289     /**
       
   290      * Observer to notify the termination of the Location Application.
       
   291      */
       
   292     MLcAppExitObserver*     iExitObserver;
       
   293     
       
   294     /**
       
   295      * Launcher class used to launch the S60 browser as a chained
       
   296      * application.
       
   297      * Owns.
       
   298      */
       
   299     CSchemeHandler*         iBrowserLauncher;
       
   300     
       
   301     /**
       
   302      * Document handler used for launching documents.
       
   303      * Owns
       
   304      */
       
   305     CDocumentHandler*		iDocHandler;
       
   306     
       
   307     /**
       
   308      * Application Service class. This class is used to launch an application
       
   309      * as an embedded application
       
   310      */
       
   311     CLcLaunchAppService*	iAppService;
       
   312     
       
   313     /**
       
   314      * Flag to check whether an Embedded launch is outstanding 
       
   315      */
       
   316     TBool					isEmbeddedLaunchOutstanding;
       
   317     
       
   318     };          
       
   319 
       
   320 #endif // LCAPPLAUNCHER_H