|
1 /* |
|
2 * Copyright (c) 2000 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 applicationmanagement components |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __APPLICATIONMANAGEMENTSERVER_H__ |
|
19 #define __APPLICATIONMANAGEMENTSERVER_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <SyncMLClient.h> |
|
23 #include <e32base.h> |
|
24 #include <centralrepository.h> |
|
25 #include <SWInstApi.h> |
|
26 #include <ssl.h> |
|
27 #include <swi/launcher.h> |
|
28 #include <swi/sisregistrysession.h> |
|
29 #include <swi/sisregistrypackage.h> |
|
30 #include <swi/sisregistryentry.h> |
|
31 #include <DownloadMgrClient.h> |
|
32 |
|
33 #include "ApplicationManagementClientServer.h" |
|
34 #include "PlatformSecurityPolicies.h" |
|
35 #include "AMDeploymentComponent.h" |
|
36 #include "amstorage.h" |
|
37 #include "ApplicationManagementUtility.h" |
|
38 #include "AMDownloaddb.h" |
|
39 |
|
40 #include "AMDownloadManager.h" |
|
41 // CONSTANTS |
|
42 const TInt KBase64BufSize = 131072; |
|
43 class CAppMgmtSrvApp; |
|
44 |
|
45 namespace NApplicationManagement |
|
46 { |
|
47 |
|
48 // ----------------------------------------------------------- |
|
49 // ApplicationManagement server panic codes |
|
50 // ----------------------------------------------------------- |
|
51 enum TApplicationManagementPanic |
|
52 { |
|
53 EPanicGeneral, |
|
54 EBadSubsessionHandle, |
|
55 EPanicIllegalFunction, |
|
56 EBadDescriptor |
|
57 }; |
|
58 |
|
59 // FUNCTION PROTOTYPES |
|
60 |
|
61 void PanicClient(const RMessagePtr2& aMessage, |
|
62 TApplicationManagementPanic aPanic); |
|
63 |
|
64 // CLASS DECLARATION |
|
65 class CShutdown : public CTimer |
|
66 { |
|
67 enum |
|
68 { |
|
69 KApplicationManagementShutdownDelay = 0x3000000 // approx 30s |
|
70 }; |
|
71 public: |
|
72 inline CShutdown(); |
|
73 inline void ConstructL(); |
|
74 inline void Start(); |
|
75 inline void Stop(); |
|
76 private: |
|
77 void RunL(); |
|
78 }; |
|
79 |
|
80 /** |
|
81 * CApplicationManagementServer |
|
82 * Description. |
|
83 */ |
|
84 |
|
85 class CApplicationManagementServer : public CAknAppServer, |
|
86 public MDownloadMngrObserver |
|
87 { |
|
88 public: |
|
89 static CApplicationManagementServer* NewL(); |
|
90 ~CApplicationManagementServer(); |
|
91 |
|
92 void Panic(TInt aPanicCode); |
|
93 void AddSession(); |
|
94 void DropSession(); |
|
95 |
|
96 CPolicyServer::TCustomResult CreateServiceSecurityCheckL( |
|
97 TUid aServiceType, const RMessage2& aMsg, TInt& aAction, |
|
98 TSecurityInfo& aMissing); |
|
99 private: |
|
100 |
|
101 CApplicationManagementServer(); |
|
102 virtual void ConstructL(const TDesC &aServerName); |
|
103 /*CSession2* NewSessionL(const TVersion& aVersion, |
|
104 const RMessage2& aMessage) const;*/ |
|
105 |
|
106 //From CPolicyServer |
|
107 CPolicyServer::TCustomResult |
|
108 CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, |
|
109 TSecurityInfo& aMissing); |
|
110 |
|
111 // browses sis registry |
|
112 void LookupSisRegistryL(); |
|
113 |
|
114 //New methods |
|
115 void DownloadCompleteL(CDeploymentComponent *aComponent, TInt iapid, |
|
116 HBufC8* aServerId); |
|
117 |
|
118 void InstallCompleteL(const CDeploymentComponent &aCompo, |
|
119 const TBool &aInstallSuccess=ETrue); |
|
120 |
|
121 TInt GetErrorStatus(TInt aErrorDownload, TInt aErrorInstall); |
|
122 |
|
123 void EnableDMNetworkMonL(TInt iapid, HBufC8 *aServerId); |
|
124 |
|
125 public: |
|
126 |
|
127 /** |
|
128 * Storage Returns the storage |
|
129 * @return The storage pointer |
|
130 */ |
|
131 inline CDeliveryComponentStorage *Storage() |
|
132 { |
|
133 return iStorage; |
|
134 } |
|
135 |
|
136 /** |
|
137 * UninstallL Uninstalls the given deployment component. |
|
138 * @param aComponent The component to be uninstalled |
|
139 * @param aStatus TRequestStatus of the call |
|
140 */ |
|
141 void UninstallL(const CDeploymentComponent &aComponent, |
|
142 TRequestStatus &aStatus); |
|
143 |
|
144 void AddDownloadL(CDeploymentComponent *aComponent); |
|
145 |
|
146 void PerformRFSL(); |
|
147 void RemoveInternalL(const CDeploymentComponent &aCompo, |
|
148 TBool aDoUninstall = ETrue); |
|
149 |
|
150 TBool CheckCertL(const TCertInfo &aInfo) const; |
|
151 void DoTheInstallL(CDeploymentComponent &aCompo); |
|
152 |
|
153 void GetAMServerDownloadDBL(TUint32 internalid, TInt& finalresult, |
|
154 TDes8& atargetURI); |
|
155 |
|
156 TBool IsOMASCOMOEnabledL(); |
|
157 |
|
158 /** |
|
159 * JavaUidsL Returns java uids. |
|
160 * @param aUids the array to hold uids |
|
161 */ |
|
162 void JavaUidsL(RArray<TUid> &aUids) const; |
|
163 |
|
164 /** |
|
165 * FullUpdateL updates target with source |
|
166 * @param sid Source deployment component id |
|
167 * @param tid Target deployment component id |
|
168 */ |
|
169 void FullUpdateL(const TUint32 sid, const TUint32 tid); |
|
170 |
|
171 /** |
|
172 * SetDataL sets data to deployment component and checks possible uid overlaps |
|
173 * @param aCompo deployment component where data is set |
|
174 * @param aData new data to be set |
|
175 * @param aMime mimetype of the new data to be set |
|
176 */ |
|
177 void SetDataL(CDeploymentComponent &aCompo, const TDesC8 &aData, |
|
178 const TDesC8 &aMime); |
|
179 /** |
|
180 * Checks of data in file is Base64 decoded. |
|
181 * @param aFile file to be checked if data is encoded |
|
182 * @param aLength data length in file |
|
183 * @return ETrue if given data in file is Base64 encoded |
|
184 */ |
|
185 TBool IsDataFileB64EncodedL(RFile &aFile, TInt& aLength); |
|
186 |
|
187 /** |
|
188 * Checks of data is Base64 decoded. |
|
189 * @param aData data to be checked for encoding |
|
190 * @return ETrue if given data is Base64 encoded |
|
191 */ |
|
192 TBool CheckB64Encode(const TDesC8& aData); |
|
193 |
|
194 /** |
|
195 * B64 Decodes data in aData and return decoded data |
|
196 * @param aSourceFile file containing decoded data |
|
197 * @param aDestinationFile file where to decode data |
|
198 */ |
|
199 void DecodeB64DataFileL(RFile& aSourceFile, RFile& aDestinationFile); |
|
200 |
|
201 /** |
|
202 * B64 Decodes data in aData and return decoded data |
|
203 * @param aData decoded data |
|
204 * @return Decoded data |
|
205 */ |
|
206 HBufC8* DecodeB64DataLC(const TDesC8 &aData); |
|
207 |
|
208 /** |
|
209 * B64 Encodes data in aData to aTarget |
|
210 * @param aData data which is encoded |
|
211 * @param aTarget encoded data buffer |
|
212 */ |
|
213 void EncodeDataL(const TDesC8& aData, CBufBase &aTarget); |
|
214 void HandleAllClientsClosed(); |
|
215 |
|
216 void DeleteGenericAlertForIDL(TUint32 internalid); |
|
217 void CheckforDuplicateMidletsL(TMidletParameters& amidletParameters); |
|
218 |
|
219 public: |
|
220 // from MDownloadMngrObserver |
|
221 |
|
222 /** |
|
223 * |
|
224 * @param aComponent |
|
225 * @param aStatus |
|
226 */ |
|
227 void ComponentDownloadComplete(CDeploymentComponent *aComponent, |
|
228 TInt iapid, HBufC8 *aServerId); |
|
229 |
|
230 /** |
|
231 * Looks all deployments components and sis & java registries |
|
232 * to find out whether given uid is already used... |
|
233 * @param aUid The uid to be looked for |
|
234 * @return ETrue if uid is found, EFalse otherwise |
|
235 */ |
|
236 TBool HasUidL(const TUid &aUid, CDeploymentComponent *& aCompo, |
|
237 CDeploymentComponent *aIgnored); |
|
238 |
|
239 void ComponentDownloadFailed(CDeploymentComponent *aComponent, |
|
240 TInt aReason); |
|
241 |
|
242 void StartShutDownTimerL(); |
|
243 |
|
244 void SendServerToBackground(); |
|
245 |
|
246 void BringServertoForeground(); |
|
247 |
|
248 void BringDMUItoForeground(); |
|
249 TBool IsInstalledAppRemovableL(TDriveNumber &iDrive); |
|
250 |
|
251 private: |
|
252 |
|
253 /** |
|
254 * FullUpdateL updates target with source |
|
255 * @param sid Source deployment component |
|
256 * @param tid Target deployment component |
|
257 */ |
|
258 void FullUpdateL(CDeploymentComponent &scompo, |
|
259 const CDeploymentComponent &tcompo); |
|
260 |
|
261 /** |
|
262 * InstallL Installs the given deployment component. Async version. |
|
263 * @param aComponent The component to be installed |
|
264 * @param aStatus TRequestStatus of the call |
|
265 */ |
|
266 void InstallL(const CDeploymentComponent &aComponent, |
|
267 TRequestStatus &aStatus); |
|
268 /** |
|
269 * InstallL Installs the given deployment component. Syncronized version. |
|
270 * @param aComponent The component to be installed |
|
271 */ |
|
272 void InstallL(const CDeploymentComponent &aComponent); |
|
273 |
|
274 /** |
|
275 * PrepareInstallL Prepares install of given component. |
|
276 * @param aComponent The component to be installed |
|
277 * @param aFileName If call is successful, will contain |
|
278 * the name of file ready to be installed |
|
279 * @return ETrue if preparation is successful, EFalse otherwise |
|
280 */ |
|
281 TBool PrepareInstallL(const CDeploymentComponent &aComponent, |
|
282 TFileName &aFileName); |
|
283 |
|
284 /** |
|
285 * Finds whether the given uid is found in sis or java registry. |
|
286 * Searches first sis registry and uses FindJavaUidL if not found |
|
287 */ |
|
288 TBool FindInstalledSisUidL(const TUid &aUid) const; |
|
289 |
|
290 /** |
|
291 * Finds whether the given uid is found in java registry |
|
292 */ |
|
293 TBool FindInstalledJavaUidL(const TUid &aUid) const; |
|
294 void SetSisAppVersionAndDriveL(CDeploymentComponent &aCompo); |
|
295 void JavaInstallL(CDeploymentComponent &aCompo); |
|
296 void SisInstallL(const CDeploymentComponent &aCompo); |
|
297 TUid FindNewUid(const RArray<TUid> &aUidsOrig, |
|
298 const RArray<TUid> &aUidsNew) const; |
|
299 |
|
300 /** |
|
301 * Reads Jar file name from Jad file |
|
302 * @param aFile file handle for Jad file where to find Jar filename |
|
303 * @return aFileName If call is successful, will contain the name of file ready to be installed |
|
304 */ |
|
305 TFileName ReadJarFileNameL(RFile& aFile) const; |
|
306 |
|
307 /** |
|
308 * Reads line of data from file. |
|
309 * @param aStream stream handle where to read data |
|
310 * @param aLineBuffer buffer where function appends read data for line. Return a full line at time. |
|
311 */ |
|
312 void ReadLineL(RReadStream& aStream, TDes8& aLineBuffer) const; |
|
313 |
|
314 /** |
|
315 * DoDataUpdateCheck checks whether there's dc having same data uid |
|
316 * @return The conflicting DC or NULL |
|
317 */ |
|
318 CDeploymentComponent * DoDataUpdateCheckL( |
|
319 CDeploymentComponent &aCompo); |
|
320 |
|
321 // Functions used to generate temporary files Java installation use case |
|
322 // where both Jad and Jar files are delivered to phone and Jad file is used to install |
|
323 // the Java application from local Jar file. |
|
324 void GenerateTempJarFileNameL(RFs &aFs, const TDesC& aMetaSource, |
|
325 TFileName &aFileName) const; |
|
326 |
|
327 void GenerateTempFileNameL(const RFs &aFs, const TDesC& aSource, |
|
328 TFileName &aFileName) const; |
|
329 |
|
330 void GenerateTempFileNameL(RFs &aFs, |
|
331 const CDeploymentComponent& aCompo, TFileName& aSource, |
|
332 TFileName &aMetaSource, TFileName &aFileName, |
|
333 TFileName &aMetaFileName) const; |
|
334 |
|
335 void GenerateTempFileNameL(RFs &aFs, |
|
336 const CDeploymentComponent& aCompo, TFileName &aFileName, |
|
337 TFileName &aMetaFileName) const; |
|
338 |
|
339 CApaAppServiceBase* CreateServiceL(TUid aServiceType) const; |
|
340 |
|
341 public: |
|
342 |
|
343 CAppMgmtSrvApp* iParentApp; |
|
344 |
|
345 private: |
|
346 |
|
347 TInt iSessionCount; |
|
348 CShutdown iShutdown; |
|
349 CApplicationManagementUtility* iUtility; |
|
350 CDeliveryComponentStorage *iStorage; |
|
351 TBool iInstallInProgress; |
|
352 |
|
353 //SwiUI::RSWInstSilentLauncher iInstaller; |
|
354 SwiUI::RSWInstLauncher iInstaller; |
|
355 SwiUI::TInstallOptionsPckg iInstallOptions; |
|
356 SwiUI::TUninstallOptionsPckg iUninstallOptions; |
|
357 SwiUI::TInstallReqPckg iInstallReq; |
|
358 |
|
359 RFs iInstallRFs; |
|
360 RFile iInstallFile; |
|
361 |
|
362 CAMDownloadManager* iDownloadMngr; |
|
363 |
|
364 CAMDownloaddb* iAMServerDB; |
|
365 TBool iOMASCOMOEnabled; |
|
366 |
|
367 }; |
|
368 |
|
369 namespace NPolicyConstants |
|
370 { |
|
371 |
|
372 // "CSF" + CA + SerialNumber + Fingerprint) ; |
|
373 //_LIT( KSubjectFormat, "CSF%S%S%S" ); |
|
374 namespace NActions |
|
375 { |
|
376 _LIT8( KUse, "Use" ); |
|
377 } |
|
378 _LIT8( KResourceValue, "ApplicationManagement" ); |
|
379 } |
|
380 |
|
381 class CApplicationManagementSession : public CAknAppServiceBase |
|
382 { |
|
383 public: |
|
384 inline CApplicationManagementSession(); |
|
385 inline CApplicationManagementSession(const TCertInfo &aInfo); |
|
386 void CreateL(); |
|
387 private: |
|
388 ~CApplicationManagementSession(); |
|
389 inline CApplicationManagementServer& Server() const; |
|
390 |
|
391 void ServiceL(const RMessage2& aMessage); |
|
392 TBool PreDispatchMessageL(const RMessage2 &aMessage); |
|
393 void DispatchMessageL(const RMessage2& aMessage); |
|
394 void ServiceError(const RMessage2& aMessage, TInt aError); |
|
395 |
|
396 void ComponentCountL(const RMessage2& aMessage); |
|
397 void ComponentIdsL(const RMessage2& aMessage) const; |
|
398 void Deliver2L(const RMessage2& aMessage) const; |
|
399 void DeliverCompleteL(const RMessage2& aMessage) const; |
|
400 void GetComponentL(const RMessage2& aMessage) const; |
|
401 void InstallL(const RMessage2 &aMessage) const; |
|
402 void UpdateL(const RMessage2 &aMessage) const; |
|
403 void GetDataL(const RMessage2 &aMessage) const; |
|
404 void GetDataLengthL(const RMessage2 &aMessage) const; |
|
405 void RemoveL(const RMessage2 &aMessage) const; |
|
406 void UpdateDataL(const RMessage2 &aMessage) const; |
|
407 void UpdateStreamedDataL(const RMessage2& aMessage) const; |
|
408 void DownloadL(const RMessage2 &aMessage) const; |
|
409 void AddTrustL(const RMessage2 &aMessage); |
|
410 void FullUpdateL(const RMessage2 &aMessage) const; |
|
411 void GetUserIdL(const RMessage2 &aMessage) const; |
|
412 void StartDownloadL(const RMessage2& aMessage) const; |
|
413 void StateChangeComponentIdsL(const RMessage2& aMessage) const; |
|
414 void StateChangeComponentIdsCountL(const RMessage2& aMessage) const; |
|
415 void StateChangeCompleteL(const RMessage2& aMessage) const; |
|
416 void ActivateL(const RMessage2& aMessage) const; |
|
417 void DeactivateL(const RMessage2& aMessage) const; |
|
418 void GetTemporaryInstFileL(const RMessage2 &aMessage) const; |
|
419 void GetFinalResultForGAL(const RMessage2 &aMessage); |
|
420 |
|
421 TInt PackageSizeL(Swi::RSisRegistrySession& aSession, |
|
422 Swi::RSisRegistryEntry& aEntry); |
|
423 TInt AugmentationSizeL(Swi::RSisRegistrySession& aSession, |
|
424 const Swi::CSisRegistryPackage& aPackage); |
|
425 |
|
426 void RemoveInternalL(const TUint32 &aId) const; |
|
427 |
|
428 /** |
|
429 * Collects active components in aArrt and places them in aArr |
|
430 */ |
|
431 void ActiveComponentsL(const RComponentIdArray &aArrt, |
|
432 RComponentIdArray &aArr,TDeploymentComponentState &aState) const; |
|
433 |
|
434 void GenericAlertSentForIdL(const RMessage2& aMessage) const; |
|
435 |
|
436 void CheckStatusNodesValuesL(); |
|
437 |
|
438 private: |
|
439 void LookupSisRegistryL(); |
|
440 |
|
441 TCertInfo iCertInfo; |
|
442 TBool iTrustAdded; |
|
443 }; |
|
444 |
|
445 } |
|
446 #endif //__APPLICATIONMANAGEMENTSERVER_H__ |
|
447 // End of File |
|
448 |