1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #ifndef __APACMDLN_H__
18 #define __APACMDLN_H__
20 #include <e32base.h> // class CBase
21 #include <apadef.h> // enum TApaCommand
26 /** Information for launching an application.
28 To start an application, passed a CApaCommandLine object to the RApaLsSession::StartApp() method.
30 This class is often referred to as a command line and contains:
31 the name of an application EXE to be launched, a document name,
32 a command code that defines the way the application is launched
33 trailing data; the structure of this depends on the application to be launched.
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.
42 class CApaCommandLine : public CBase
45 // Creates an empty command line object
46 IMPORT_C static CApaCommandLine* NewL();
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);
79 IMPORT_C ~CApaCommandLine();
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);
86 // Getting/setting the CApaCommandLine to/from process environment-slots
87 IMPORT_C void SetProcessEnvironmentL(RProcess& aProcess) const;
88 IMPORT_C static TInt GetCommandLineFromProcessEnvironment(CApaCommandLine*& aCommandLine);
89 // operations to support passing memory-allocation failure settings in to applications
90 IMPORT_C void SetDebugMemFailL(TInt aDebugMemFail);
91 IMPORT_C TInt DebugMemFail() const;
92 // operations to support the instrumentation (i.e. profiling) of application startup
93 IMPORT_C void SetAppStartupInstrumentationEventIdBaseL(TInt aEventIdBase);
94 IMPORT_C TInt AppStartupInstrumentationEventIdBase() const;
95 // operations on the server requirement/differentiator number - 0 means no server, non-zero sets the differentiator for the server name
96 IMPORT_C void SetServerNotRequiredL();
97 IMPORT_C void SetServerRequiredL(TUint aServerDifferentiator);
98 IMPORT_C TUint ServerRequired() const;
101 void ExternalizeL(RWriteStream& aStream) const;
102 void InternalizeL(RReadStream& aStream);
103 HBufC8* StreamableAttributesLC() const;
104 void DoGetCommandLineFromProcessEnvironmentL();
105 TInt DoGetParametersFromCommandLineString(const TDesC& aCmdLine);
106 static HBufC* NameOfExecutable(const TDesC& aCmdLine, TInt& aEndDocNameOffset);
107 static TPtrC StripQuotes(const TDesC& aDes);
108 void SetServerDifferentiatorL(TUint aServerDifferentiator);
110 enum // for internal use only
116 RBuf iExecutableName;
119 TApaCommand iCommand;
120 TUint iServerDifferentiator;
121 TInt iDefaultScreenNumber;
122 TInt iParentWindowGroupID;
124 TInt iAppStartupInstrumentationEventIdBase;
126 TProcessId iParentProcessId;
129 #endif // __APACMDLN_H__