localisation/apparchitecture/inc/APACMDLN.H
branchSymbian3
changeset 57 b8d18c84f71c
parent 6 c108117318cb
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
       
    14 // apacmdln.h
    14 //
    15 //
    15 
    16 
    16 #if !defined(__APACMDLN_H__)
    17 #ifndef __APACMDLN_H__
    17 #define __APACMDLN_H__
    18 #define __APACMDLN_H__
    18 
    19 
    19 #if !defined(__E32BASE_H__)
    20 #include <e32base.h>	// class CBase
    20 #include <e32base.h>
    21 #include <apadef.h>		// enum TApaCommand
    21 #endif
       
    22 
       
    23 #if !defined(__APADEF_H__)
       
    24 #include <apadef.h>
       
    25 #endif
       
    26 
       
    27 #if !defined(__F32FILE_H__)
       
    28 #include <f32file.h>
    22 #include <f32file.h>
    29 #endif
       
    30 
       
    31 #if !defined(__S32STRM_H__)
       
    32 #include <s32strm.h>
    23 #include <s32strm.h>
    33 #endif
       
    34 
    24 
    35 
    25 
    36 class CApaCommandLine : public CBase
       
    37 /** Information for launching an application.
    26 /** Information for launching an application.
    38 
    27 
    39 This is often referred to as a command line and contains:
    28 To start an application, passed a CApaCommandLine object to the RApaLsSession::StartApp() method.
    40 
    29 
    41 the name of an application EXE to be launched,
    30 This class is often referred to as a command line and contains:
    42 
    31 the name of an application EXE to be launched, a document name,
    43 a document name,
       
    44 
       
    45 a command code that defines the way the application is launched
    32 a command code that defines the way the application is launched
    46 
       
    47 trailing data; the structure of this depends on the application to be launched.
    33 trailing data; the structure of this depends on the application to be launched.
    48 
    34 
    49 The information is held in a buffer implemented by a heap descriptor. 
    35 To start an application, startup parameters are set on the CApaCommandLine object that is 
       
    36 then externalized into a stream and attached to a new RProcess object. These parameters 
       
    37 are then used to re-populate a new CApaCommandLine object inside the process by 
       
    38 EikStart::RunApplication() and used to bootstrap the launching application.
    50 
    39 
    51 @publishedAll
    40 @publishedAll
    52 @released */
    41 @released */
       
    42 class CApaCommandLine : public CBase
    53 	{
    43 	{
    54 public:
    44 public:
    55 	// construction/destruction
    45 	// Creates an empty command line object
    56 	IMPORT_C static CApaCommandLine* NewL();
    46 	IMPORT_C static CApaCommandLine* NewL();
    57 	IMPORT_C static CApaCommandLine* NewLC();
    47 	IMPORT_C static CApaCommandLine* NewLC();
       
    48 	// Specify how the application is to be started (see TApaCommand in apadef.h)
       
    49 	IMPORT_C void SetCommandL(TApaCommand aCommand);
       
    50 	IMPORT_C TApaCommand Command() const;
       
    51 	// Launch the application associated with the mime-type of the document file
       
    52 	IMPORT_C void SetDocumentNameL(const TDesC& aDocName);
       
    53 	IMPORT_C TPtrC DocumentName() const;
       
    54 	IMPORT_C void SetFileByHandleL(const RFile& aFile);
       
    55 	IMPORT_C void GetFileByHandleL(RFile& aFile) const;
       
    56 	// Launch the application explicitly named
       
    57 	IMPORT_C void SetExecutableNameL(const TDesC& aAppName);
       
    58 	IMPORT_C TPtrC ExecutableName() const;
       
    59 	// Additional application execution arguments (added to the tail if the command line)
       
    60 	IMPORT_C void SetTailEndL(const TDesC8& aTailEnd);
       
    61 	IMPORT_C TPtrC8 TailEnd() const;
       
    62 	// Set the process id of the application being the conceptual parent.
       
    63 	// The child process will be closed down automatically when the parent is.
       
    64 	IMPORT_C void SetParentProcessId(TProcessId aProcessId);
       
    65 	IMPORT_C TProcessId ParentProcessId() const;
       
    66 	// Starting the application on a specific screen
       
    67 	IMPORT_C void SetDefaultScreenL(TInt aDefaultScreenNumber);
       
    68 	IMPORT_C TInt DefaultScreen() const;
       
    69 	IMPORT_C TBool IsDefaultScreenSet() const;
       
    70 	// Managed order of applications' window groups.
       
    71 	// A child applicatoin's windows will always be kept in front of the parent's windows.
       
    72 	IMPORT_C void SetParentWindowGroupID(TInt aParentWindowGroupID);
       
    73 	IMPORT_C TInt ParentWindowGroupID() const;
       
    74 	// Process environment-slot for public use. These can be used for passing parameters 
       
    75 	// to the starting application. However, use of the EndTail should be prefered.
       
    76 	IMPORT_C static TInt NumberOfEnvironmentSlotsForPublicUse();
       
    77 	IMPORT_C static TInt EnvironmentSlotForPublicUse(TInt aIndex);
       
    78 public:	// Internal
    58 	IMPORT_C ~CApaCommandLine();
    79 	IMPORT_C ~CApaCommandLine();
    59 
    80 	// Set opaque data sent to the application being started
       
    81 	IMPORT_C void SetOpaqueDataL(const TDesC8& aOpaqueData);
       
    82 	IMPORT_C TPtrC8 OpaqueData() const;
       
    83 	// Getting/setting the CApaCommandLine to/from a server IPC-message
       
    84 	IMPORT_C void GetIpcArgsLC(TIpcArgs& aIpcArgs) const;
       
    85 	IMPORT_C void ConstructCmdLineFromMessageL(const RMessage2& aMessage);
    60 	// Getting/setting the CApaCommandLine to/from process environment-slots
    86 	// Getting/setting the CApaCommandLine to/from process environment-slots
    61 	IMPORT_C void SetProcessEnvironmentL(RProcess& aProcess) const;
    87 	IMPORT_C void SetProcessEnvironmentL(RProcess& aProcess) const;
    62 	IMPORT_C static TInt GetCommandLineFromProcessEnvironment(CApaCommandLine*& aCommandLine);
    88 	IMPORT_C static TInt GetCommandLineFromProcessEnvironment(CApaCommandLine*& aCommandLine);
    63 
    89 	// operations to support passing memory-allocation failure settings in to applications
    64 	// Getting/setting the CApaCommandLine to/from a server IPC-message
    90 	IMPORT_C void SetDebugMemFailL(TInt aDebugMemFail);
    65 	IMPORT_C void GetIpcArgsLC(TIpcArgs& aIpcArgs) const;
    91 	IMPORT_C TInt DebugMemFail() const;
    66 	IMPORT_C void ConstructCmdLineFromMessageL(const RMessage2& aMessage);
    92 	// operations to support the instrumentation (i.e. profiling) of application startup
    67 
    93 	IMPORT_C void SetAppStartupInstrumentationEventIdBaseL(TInt aEventIdBase);
    68 	// operations on the document name
    94 	IMPORT_C TInt AppStartupInstrumentationEventIdBase() const;
    69 	IMPORT_C void SetDocumentNameL(const TDesC& aDocName);
       
    70 	IMPORT_C TPtrC DocumentName() const;
       
    71 
       
    72 	// operations on the executable name
       
    73 	IMPORT_C void SetExecutableNameL(const TDesC& aAppName);
       
    74 	IMPORT_C TPtrC ExecutableName() const;
       
    75 	
       
    76 	IMPORT_C void SetOpaqueDataL(const TDesC8& aOpaqueData);
       
    77 	IMPORT_C TPtrC8 OpaqueData() const;
       
    78 
       
    79 	// operations on the tail end
       
    80 	IMPORT_C void SetTailEndL(const TDesC8& aTailEnd);
       
    81 	IMPORT_C TPtrC8 TailEnd() const;
       
    82 
       
    83 	// operations on the command
       
    84 	IMPORT_C void SetCommandL(TApaCommand aCommand);
       
    85 	IMPORT_C TApaCommand Command() const;
       
    86 
       
    87 	// operations on the parent process id
       
    88 	IMPORT_C void SetParentProcessId(TProcessId aProcessId);
       
    89 	IMPORT_C TProcessId ParentProcessId() const;
       
    90 
       
    91 	// operations on the file passed by handle
       
    92 	IMPORT_C void SetFileByHandleL(const RFile& aFile);
       
    93 	IMPORT_C void GetFileByHandleL(RFile& aFile) const;
       
    94 public:
       
    95 
       
    96 	// operations on the server requirement/differentiator number - 0 means no server, non-zero sets the differentiator for the server name
    95 	// operations on the server requirement/differentiator number - 0 means no server, non-zero sets the differentiator for the server name
    97 	IMPORT_C void SetServerNotRequiredL();
    96 	IMPORT_C void SetServerNotRequiredL();
    98 	IMPORT_C void SetServerRequiredL(TUint aServerDifferentiator);
    97 	IMPORT_C void SetServerRequiredL(TUint aServerDifferentiator);
    99 	IMPORT_C TUint ServerRequired() const;
    98 	IMPORT_C TUint ServerRequired() const;
   100 
       
   101 	// operations to support starting an application with a specific screen number
       
   102 	IMPORT_C void SetDefaultScreenL(TInt aDefaultScreenNumber);
       
   103 	IMPORT_C TInt DefaultScreen() const;
       
   104 	IMPORT_C TBool IsDefaultScreenSet() const;
       
   105 
       
   106 	// Operations to support window chaining
       
   107 	IMPORT_C void SetParentWindowGroupID(TInt aParentWindowGroupID);
       
   108 	IMPORT_C TInt ParentWindowGroupID() const;
       
   109 
       
   110 	// operations to support passing memory-allocation failure settings in to applications
       
   111 	IMPORT_C void SetDebugMemFailL(TInt aDebugMemFail);
       
   112 	IMPORT_C TInt DebugMemFail() const;
       
   113 
       
   114 	// operations to support the instrumentation (i.e. profiling) of application startup
       
   115 	IMPORT_C void SetAppStartupInstrumentationEventIdBaseL(TInt aEventIdBase);
       
   116 	IMPORT_C TInt AppStartupInstrumentationEventIdBase() const;
       
   117 
       
   118 	IMPORT_C static TInt EnvironmentSlotForPublicUse(TInt aIndex);
       
   119 
       
   120 private:
       
   121 	struct SOption
       
   122 		{
       
   123 		const TDesC* iToken;
       
   124 		TInt* iResult;
       
   125 		TRadix iRadix;
       
   126 		HBufC8* iHBufC8Result;
       
   127 		};
       
   128 
       
   129 private:
    99 private:
   130 	CApaCommandLine();
   100 	CApaCommandLine();
   131 	void SetServerDifferentiatorL(TUint aServerDifferentiator);
       
   132 	void ExternalizeL(RWriteStream& aStream) const;
   101 	void ExternalizeL(RWriteStream& aStream) const;
   133 	void InternalizeL(RReadStream& aStream);
   102 	void InternalizeL(RReadStream& aStream);
   134 	HBufC8* StreamableAttributesLC() const;
   103 	HBufC8* StreamableAttributesLC() const;
   135 	void GetCommandLineFromProcessEnvironmentL();
   104 	void DoGetCommandLineFromProcessEnvironmentL();
   136 	TInt Parse(const TDesC& aCmdLine);
   105 	TInt DoGetParametersFromCommandLineString(const TDesC& aCmdLine);
   137 	TPtrC StripQuotes(const TDesC& aDes) const;
   106 	static HBufC* NameOfExecutable(const TDesC& aCmdLine, TInt& aEndDocNameOffset);
   138 
   107 	static TPtrC StripQuotes(const TDesC& aDes);
   139 private:
   108 	void SetServerDifferentiatorL(TUint aServerDifferentiator);
   140 	enum
       
   141 		{
       
   142 		EEnvironmentSlotUnused=0,
       
   143 
       
   144 		EEnvironmentSlotMain=1,
       
   145 		EEnvironmentSlotFsSession=2,
       
   146 		EEnvironmentSlotFile=3,
       
   147 
       
   148 		EFirstEnvironmentSlotForPublicUse=8,
       
   149 		ENumberOfEnvironmentSlotsForPublicUse=4
       
   150 		};
       
   151 
       
   152 	enum
       
   153 		{
       
   154 		EIpcSlotMain=0,
       
   155 		EIpcSlotFsSession=1,
       
   156 		EIpcSlotFile=2
       
   157 		};
       
   158 public:
   109 public:
   159 	enum
   110 	enum	// for internal use only
   160 		{
   111 		{
   161 		EIpcFirstFreeSlot=3
   112 		EIpcFirstFreeSlot=3
   162 		};
   113 		};
   163 private:
   114 private:
   164 	HBufC* iDocumentName;
   115 	RBuf iDocumentName;
   165 	HBufC* iExecutableName;
   116 	RBuf iExecutableName;
   166 	HBufC8* iOpaqueData;
   117 	RBuf8 iOpaqueData;
   167 	HBufC8* iTailEnd;
   118 	RBuf8 iTailEnd;
   168 	TApaCommand iCommand;
   119 	TApaCommand iCommand;
   169 	TUint iServerDifferentiator;
   120 	TUint iServerDifferentiator;
   170 	TInt iDefaultScreenNumber;
   121 	TInt iDefaultScreenNumber;
   171 	TInt iParentWindowGroupID;
   122 	TInt iParentWindowGroupID;
   172 	TInt iDebugMemFail;
   123 	TInt iDebugMemFail;
   173 	TInt iAppStartupInstrumentationEventIdBase;
   124 	TInt iAppStartupInstrumentationEventIdBase;
   174 	RFile iFile;
   125 	RFile iFile;
   175 	TProcessId iParentProcessId;
   126 	TProcessId iParentProcessId;
   176 	};
   127 	};
   177 
   128 
   178 #endif
   129 #endif // __APACMDLN_H__