|
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 <apgcli.h> |
|
27 #include <w32std.h> |
|
28 #include <SWInstDefs.h> |
|
29 #include <swi/sisregistryentry.h> |
|
30 #include <HTIServicePluginInterface.h> |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 // MACROS |
|
35 |
|
36 // DATA TYPES |
|
37 |
|
38 // FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 class CDesC8ArrayFlat; |
|
42 class TApaTask; |
|
43 |
|
44 // CLASS DECLARATION |
|
45 |
|
46 NONSHARABLE_CLASS (CHtiAppControl) : public CHTIServicePluginInterface |
|
47 { |
|
48 protected: |
|
49 //commands |
|
50 enum TAppCommand |
|
51 { |
|
52 //commands |
|
53 EProcessLastCommand = 0x0F, //!!! used to sort process control from |
|
54 //!!! app control |
|
55 |
|
56 //app control |
|
57 EStartApp = 0x10, |
|
58 EStartApp_u = 0x11, |
|
59 EStartApp_uid = 0x12, |
|
60 EStartApp_uid_u = 0x13, |
|
61 EStartDoc = 0x14, |
|
62 EStartDoc_u = 0x15, |
|
63 EStatusApp = 0x16, |
|
64 EStatusApp_u = 0x17, |
|
65 EStatusDoc = 0x18, |
|
66 EStatusDoc_u = 0x19, |
|
67 EStatusApp_uid = 0x1A, |
|
68 EStopApp = 0x1C, |
|
69 EStopApp_u = 0x1D, |
|
70 EStopDoc = 0x1E, |
|
71 EStopDoc_u = 0x1F, |
|
72 EStopApp_uid = 0x20, |
|
73 EListApps = 0x24, |
|
74 EListApps_u = 0x25, |
|
75 EListInstalledApps = 0x26, |
|
76 EListInstalledApps_u = 0x27, |
|
77 |
|
78 EAppLastCommand = 0x2F, //!!! used to sort process control from |
|
79 //!!! app control |
|
80 EInstall = 0x30, |
|
81 EInstall_u = 0x31, |
|
82 EUnInstall = 0x32, |
|
83 EUnInstallName_u = 0x33, |
|
84 EUnInstallName = 0x34, |
|
85 |
|
86 ESisLastCommand = 0x3F, //!!! used to sort sis control from |
|
87 //!!! app control |
|
88 //responses |
|
89 EOk = 0xF0, |
|
90 ENotFound = 0xF1, |
|
91 EAlreadyRunning = 0xF2, |
|
92 EAlreadyStopped = 0xF3, |
|
93 ERunning = 0xF4, |
|
94 EKilled = 0xF5, |
|
95 EPanic = 0xF6 |
|
96 }; |
|
97 |
|
98 public: |
|
99 static CHtiAppControl* NewL(); |
|
100 |
|
101 // Interface implementation |
|
102 void ProcessMessageL(const TDesC8& aMessage, |
|
103 THtiMessagePriority aPriority); |
|
104 |
|
105 protected: |
|
106 CHtiAppControl(); |
|
107 void ConstructL(); |
|
108 |
|
109 virtual ~CHtiAppControl(); |
|
110 |
|
111 void HandleAppControlL(const TDesC8& aMessage); |
|
112 void HandleInstallerControlL( const TDesC8& aMessage ); |
|
113 /** |
|
114 * Extracts string from incoming request and convert it to unicode |
|
115 * for non-unicode request |
|
116 * aResult should have enough maz length and it will contain |
|
117 * Function returns either offset for a next parameter in aRequest |
|
118 * or some symbian error code |
|
119 */ |
|
120 TInt ParseString( const TDesC8& aRequest, |
|
121 TInt anOffset, |
|
122 TBool aUnicode, |
|
123 TDes& aResult); |
|
124 |
|
125 //command handlers |
|
126 void HandleStartProcessL( const TDesC& aProgramName, |
|
127 const TDesC& aCmdLine, |
|
128 TBool aStoreProcessHandle ); |
|
129 |
|
130 void HandleStopProcessL( RProcess& aProcess ); |
|
131 void HandleStatusProcessL( RProcess& aProcess ); |
|
132 |
|
133 void HandleListProcessesL( const TDesC& aMatch ); |
|
134 |
|
135 void HandleStartAppL( TApaAppInfo &aAppInfo, const TDesC& aDocName ); |
|
136 |
|
137 void HandleListAppsL( TBool aIncludeHidden, |
|
138 TBool aIncludeSystem, |
|
139 TBool aUnicode ); |
|
140 |
|
141 void HandleListInstalledAppsL( TBool aUnicode ); |
|
142 |
|
143 //construct and send short message |
|
144 void SendMessageL(TAppCommand aResponseCode, const TDesC8& aMsg = KNullDesC8 ); |
|
145 |
|
146 /** |
|
147 * Helper to send error message |
|
148 * @return KErrNone or some system-wide error code |
|
149 */ |
|
150 inline TInt SendErrorMsg( TInt anError, const TDesC8& aMsg ); |
|
151 |
|
152 /** |
|
153 * |
|
154 */ |
|
155 TInt OpenProcessL( RProcess& aProcess, const TDesC& aMatch ); |
|
156 TInt OpenProcessL( RProcess& aProcess, const TUint32 aProcessId ); |
|
157 |
|
158 SwiUI::TPolicy ConvertToPolicy( const TInt8 aValue ); |
|
159 TInt GetPackageUidL( const TDesC& aPackageName, TInt aMimeIndex ); |
|
160 |
|
161 TBool ValidateInstallParams( const TDesC8& aParams, TBool aIsUnicode ); |
|
162 |
|
163 /** |
|
164 * Find application based on its full path name and fill in aAppInfo |
|
165 * @return KErrNone or KErrNotFound |
|
166 */ |
|
167 TBool FindAppL( TApaAppInfo &aAppInfo, const TDesC& aAppFullName ); |
|
168 TBool FindAppL( TApaAppInfo &aAppInfo, const TInt32 aUid ); |
|
169 |
|
170 /** |
|
171 * Find a task running the application specified by the UID as a root app |
|
172 * (i.e. not embedded. |
|
173 * @param aAppUid the UID of the application to find |
|
174 * @return the found task or an empty task if not found |
|
175 */ |
|
176 TApaTask FindRunningRootApp( TUid aAppUid ); |
|
177 |
|
178 /** |
|
179 * Convert string to T 32bit int (e.g. TUint, TInt32) |
|
180 */ |
|
181 template<class T> T Parse32( const TDesC8& a32int); |
|
182 |
|
183 protected: |
|
184 |
|
185 // Session to Window Server |
|
186 RWsSession iWs; |
|
187 |
|
188 // Session to Application Architecture Server |
|
189 RApaLsSession iAppServer; |
|
190 |
|
191 // A flag that is set to EFalse if connecting to Window Server or |
|
192 // Application Architecture Server fails. In that case all application |
|
193 // related commands will return a "not supported" error. |
|
194 TBool iIsAppCmdsSupported; |
|
195 |
|
196 // Container array for process handles for querying the process exit codes |
|
197 RArray<RProcess> iProcessHandleArray; |
|
198 |
|
199 // possible mimetypes for silent software uninstallation |
|
200 CDesC8ArrayFlat* iMimeTypes; |
|
201 |
|
202 SwiUI::TInstallOptions iInstOpts; |
|
203 SwiUI::TInstallOptionsPckg iInstOptsPckg; |
|
204 SwiUI::TUninstallOptions iUnInstOpts; |
|
205 SwiUI::TUninstallOptionsPckg iUnInstOptsPckg; |
|
206 RPointerArray<Swi::CSisRegistryPackage> iAugmentations; |
|
207 TInt iAugmentationIndex; |
|
208 }; |
|
209 |
|
210 #endif |
|
211 |
|
212 // End of file |