1 /* |
|
2 * Copyright (c) 2009 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 ECOM plug-in service interface providing |
|
15 * process and application control service. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef HTIAPPSERVICEPLUGIN_H__ |
|
22 #define HTIAPPSERVICEPLUGIN_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <HtiServicePluginInterface.h> |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // DATA TYPES |
|
33 |
|
34 // FUNCTION PROTOTYPES |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CDesC8ArrayFlat; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 /** |
|
41 * Implementation of ECOM plug-in service interface. |
|
42 * Provides the service to control processes and applications. |
|
43 * |
|
44 */ |
|
45 class CHtiAppServicePlugin : public CHTIServicePluginInterface |
|
46 { |
|
47 protected: |
|
48 //commands |
|
49 enum TAppCommand |
|
50 { |
|
51 //commands |
|
52 //process control |
|
53 EStartProcess = 0x02, |
|
54 EStartProcess_u = 0x03, |
|
55 EStatusProcess = 0x04, |
|
56 EStatusProcess_u = 0x05, |
|
57 EStatusProcess_id = 0x06, |
|
58 EStopProcess = 0x08, |
|
59 EStopProcess_u = 0x09, |
|
60 EStopProcess_id = 0x0A, |
|
61 EListProcesses = 0x0C, |
|
62 EListProcesses_u = 0x0D, |
|
63 EStartProcessRetVal = 0x0E, |
|
64 EStartProcessRetVal_u = 0x07, |
|
65 EGetProcessExitCode = 0x0B, |
|
66 |
|
67 EProcessLastCommand = 0x0F, //!!! used to sort process control from |
|
68 //!!! app control |
|
69 |
|
70 //app control |
|
71 EStartApp = 0x10, |
|
72 EStartApp_u = 0x11, |
|
73 EStartApp_uid = 0x12, |
|
74 EStartApp_uid_u = 0x13, |
|
75 EStartDoc = 0x14, |
|
76 EStartDoc_u = 0x15, |
|
77 EStatusApp = 0x16, |
|
78 EStatusApp_u = 0x17, |
|
79 EStatusDoc = 0x18, |
|
80 EStatusDoc_u = 0x19, |
|
81 EStatusApp_uid = 0x1A, |
|
82 EStopApp = 0x1C, |
|
83 EStopApp_u = 0x1D, |
|
84 EStopDoc = 0x1E, |
|
85 EStopDoc_u = 0x1F, |
|
86 EStopApp_uid = 0x20, |
|
87 EListApps = 0x24, |
|
88 EListApps_u = 0x25, |
|
89 |
|
90 EAppLastCommand = 0x2F, //!!! used to sort process control from |
|
91 //!!! app control |
|
92 EInstall = 0x30, |
|
93 EInstall_u = 0x31, |
|
94 EUnInstall = 0x32, |
|
95 EUnInstallName_u = 0x33, |
|
96 EUnInstallName = 0x34, |
|
97 |
|
98 ESisLastCommand = 0x3F, //!!! used to sort sis control from |
|
99 //!!! app control |
|
100 //responses |
|
101 EOk = 0xF0, |
|
102 ENotFound = 0xF1, |
|
103 EAlreadyRunning = 0xF2, |
|
104 EAlreadyStopped = 0xF3, |
|
105 ERunning = 0xF4, |
|
106 EKilled = 0xF5, |
|
107 EPanic = 0xF6 |
|
108 }; |
|
109 |
|
110 public: |
|
111 static CHtiAppServicePlugin* NewL(); |
|
112 |
|
113 // Interface implementation |
|
114 void ProcessMessageL(const TDesC8& aMessage, |
|
115 THtiMessagePriority aPriority); |
|
116 |
|
117 /** |
|
118 * Called by HTI-framework to initialize this plugin |
|
119 */ |
|
120 void InitL(); |
|
121 |
|
122 protected: |
|
123 CHtiAppServicePlugin(); |
|
124 void ConstructL(); |
|
125 |
|
126 virtual ~CHtiAppServicePlugin(); |
|
127 |
|
128 void HandleProcessControlL(const TDesC8& aMessage); |
|
129 |
|
130 /** |
|
131 * Extracts string from incoming request and convert it to unicode |
|
132 * for non-unicode request |
|
133 * aResult should have enough maz length and it will contain |
|
134 * Function returns either offset for a next parameter in aRequest |
|
135 * or some symbian error code |
|
136 */ |
|
137 TInt ParseString( const TDesC8& aRequest, |
|
138 TInt anOffset, |
|
139 TBool aUnicode, |
|
140 TDes& aResult); |
|
141 |
|
142 //command handlers |
|
143 void HandleStartProcessL( const TDesC& aProgramName, |
|
144 const TDesC& aCmdLine, |
|
145 TBool aStoreProcessHandle ); |
|
146 |
|
147 void HandleStopProcessL( RProcess& aProcess ); |
|
148 void HandleStatusProcessL( RProcess& aProcess ); |
|
149 |
|
150 void HandleListProcessesL( const TDesC& aMatch ); |
|
151 |
|
152 //construct and send short message |
|
153 void SendMessageL(TAppCommand aResponseCode, const TDesC8& aMsg = KNullDesC8 ); |
|
154 |
|
155 /** |
|
156 * Helper to send error message |
|
157 * @return KErrNone or some system-wide error code |
|
158 */ |
|
159 inline TInt SendErrorMsg( TInt anError, const TDesC8& aMsg ); |
|
160 |
|
161 /** |
|
162 * |
|
163 */ |
|
164 TInt OpenProcessL( RProcess& aProcess, const TDesC& aMatch ); |
|
165 TInt OpenProcessL( RProcess& aProcess, const TUint32 aProcessId ); |
|
166 |
|
167 /** |
|
168 * Convert string to T 32bit int (e.g. TUint, TInt32) |
|
169 */ |
|
170 template<class T> T Parse32( const TDesC8& a32int); |
|
171 |
|
172 |
|
173 |
|
174 protected: |
|
175 |
|
176 // Container array for process handles for querying the process exit codes |
|
177 RArray<RProcess> iProcessHandleArray; |
|
178 |
|
179 private: |
|
180 CHTIServicePluginInterface* iAppServiceUiPlugin; |
|
181 RLibrary iLibrary; |
|
182 |
|
183 |
|
184 }; |
|
185 |
|
186 #endif |
|
187 |
|
188 // End of file |
|