|
1 /* |
|
2 * Copyright (c) 2004-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 the License "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: |
|
15 * Definition of the CApplication |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #include "application.h" |
|
25 #include "userselections.h" |
|
26 #include "sisregistryfiledescription.h" |
|
27 #include "siscontroller.h" |
|
28 #include "sisregistrypackage.h" |
|
29 #include "hashcontainer.h" |
|
30 #include "secutils.h" |
|
31 #include "securityinfo.h" |
|
32 |
|
33 using namespace Swi; |
|
34 |
|
35 |
|
36 EXPORT_C CApplication* CApplication::NewL() |
|
37 { |
|
38 CApplication* self=NewLC(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 EXPORT_C CApplication* CApplication::NewLC() |
|
44 { |
|
45 CApplication* self = new (ELeave) CApplication(); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // CApplication |
|
52 |
|
53 CApplication::CApplication() |
|
54 : iShutdown(EFalse), |
|
55 iCanPropagate(ETrue), |
|
56 iPropagateDrive('!'), |
|
57 iDeletablePreinstalled(EFalse) |
|
58 { |
|
59 } |
|
60 |
|
61 CApplication::~CApplication() |
|
62 { |
|
63 // do not destroy, these are only pointers, there are not owned by this class |
|
64 iProperties.Reset(); |
|
65 |
|
66 // owned by this class |
|
67 iFilesToAdd.ResetAndDestroy(); |
|
68 iFilesToDisplayOnInstall.ResetAndDestroy(); |
|
69 iFilesToRunOnInstall.ResetAndDestroy(); |
|
70 iFilesToRemove.ResetAndDestroy(); |
|
71 iFilesToDisplayOnUninstall.ResetAndDestroy(); |
|
72 iFilesToRunOnUninstall.ResetAndDestroy(); |
|
73 iFilesToSkipOnInstall.ResetAndDestroy(); |
|
74 |
|
75 iEmbeddedApplications.ResetAndDestroy(); |
|
76 iDeviceSupportedLanguages.Close(); |
|
77 iMatchingDeviceLanguages.Close(); |
|
78 delete iUserSelections; |
|
79 delete iUid; |
|
80 delete iPackage; |
|
81 } |
|
82 |
|
83 |
|
84 void CApplication::ConstructL() |
|
85 { |
|
86 iUserSelections = CUserSelections::NewL(); |
|
87 } |
|
88 |
|
89 |
|
90 EXPORT_C void CApplication::AddSisStubFileL(const CSisRegistryFileDescription& aFileDescription) |
|
91 { |
|
92 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription); |
|
93 User::LeaveIfError(iFilesToAdd.Append(fileDescription)); |
|
94 CleanupStack::Pop(fileDescription); |
|
95 } |
|
96 |
|
97 EXPORT_C void CApplication::AddFileL(const Sis::CFileDescription& aFileDescription, TChar aDrive) |
|
98 { |
|
99 aDrive.Fold(); |
|
100 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription, aDrive, iIsStub); |
|
101 User::LeaveIfError(iFilesToAdd.Append(fileDescription)); |
|
102 CleanupStack::Pop(fileDescription); |
|
103 |
|
104 // Update the propagation status |
|
105 |
|
106 if (iCanPropagate) |
|
107 { |
|
108 TChar drive = fileDescription->Target()[0]; |
|
109 drive.Fold(); |
|
110 if (iPropagateDrive != '!') |
|
111 { |
|
112 // This is not the first file description, check the drive letter against the first |
|
113 iCanPropagate = (iPropagateDrive == drive); |
|
114 } |
|
115 else |
|
116 { |
|
117 // This is the first file description, just update the drive |
|
118 iPropagateDrive = (drive == '!' ? aDrive : drive); |
|
119 } |
|
120 } |
|
121 |
|
122 } |
|
123 |
|
124 EXPORT_C void CApplication::RemoveFileL(const CSisRegistryFileDescription& aFileDescription) |
|
125 { |
|
126 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription); |
|
127 User::LeaveIfError(iFilesToRemove.Append(fileDescription)); |
|
128 CleanupStack::Pop(fileDescription); |
|
129 } |
|
130 |
|
131 EXPORT_C void CApplication::RemoveFileL(const TDesC& aFileName) |
|
132 { |
|
133 // Create dummy CSisRegistryFileDescription for a file to be removed based |
|
134 // solely on the file name. |
|
135 |
|
136 CHashContainer* hashContainer = CHashContainer::NewLC(CMessageDigest::ESHA1, KNullDesC8); |
|
137 |
|
138 Sis::TSISFileOperationOptions options = static_cast<Sis::TSISFileOperationOptions>(0); |
|
139 |
|
140 RFs fs; |
|
141 User::LeaveIfError(fs.Connect()); |
|
142 CleanupClosePushL(fs); |
|
143 |
|
144 // If the file is an EXE get the SID otherwise use KNullUid |
|
145 TUid sid(KNullUid); |
|
146 if (SecUtils::IsExeL(aFileName)) |
|
147 { |
|
148 TSecurityInfo info; |
|
149 SecurityInfo::RetrieveExecutableSecurityInfoL(fs, aFileName, info); |
|
150 sid.iUid = info.iSecureId.iId; |
|
151 } |
|
152 |
|
153 // get the file length, this is used later for the progress bar |
|
154 TEntry entry; |
|
155 User::LeaveIfError(fs.Entry( aFileName, entry )); |
|
156 TInt64 length = entry.iSize; |
|
157 |
|
158 CSisRegistryFileDescription* fileDescription = |
|
159 CSisRegistryFileDescription::NewL(*hashContainer, |
|
160 aFileName, |
|
161 KNullDesC, |
|
162 Sis::EOpNull, |
|
163 options, |
|
164 length, |
|
165 0, |
|
166 sid); |
|
167 CleanupStack::PushL(fileDescription); |
|
168 User::LeaveIfError(iFilesToRemove.Append(fileDescription)); |
|
169 CleanupStack::Pop(fileDescription); |
|
170 CleanupStack::PopAndDestroy(2); // fs, hashContainer |
|
171 } |
|
172 |
|
173 |
|
174 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToAdd() const |
|
175 { |
|
176 return iFilesToAdd; |
|
177 } |
|
178 |
|
179 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToRemove() const |
|
180 { |
|
181 return iFilesToRemove; |
|
182 } |
|
183 |
|
184 EXPORT_C void CApplication::RunFileOnInstallL(const Sis::CFileDescription& aFileDescription, TChar aDrive) |
|
185 { |
|
186 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription, aDrive, iIsStub); |
|
187 User::LeaveIfError(iFilesToRunOnInstall.Append(fileDescription)); |
|
188 CleanupStack::Pop(fileDescription); |
|
189 } |
|
190 |
|
191 EXPORT_C void CApplication::RunFileOnUninstallL(const CSisRegistryFileDescription& aFileDescription) |
|
192 { |
|
193 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription); |
|
194 User::LeaveIfError(iFilesToRunOnUninstall.Append(fileDescription)); |
|
195 CleanupStack::Pop(fileDescription); |
|
196 } |
|
197 |
|
198 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToRunOnInstall() const |
|
199 { |
|
200 return iFilesToRunOnInstall; |
|
201 } |
|
202 |
|
203 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToRunOnUninstall() const |
|
204 { |
|
205 return iFilesToRunOnUninstall; |
|
206 } |
|
207 |
|
208 EXPORT_C void CApplication::DisplayFileOnInstallL(const Sis::CFileDescription& aFileDescription, TChar aDrive) |
|
209 { |
|
210 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription, aDrive, iIsStub); |
|
211 User::LeaveIfError(iFilesToDisplayOnInstall.Append(fileDescription)); |
|
212 CleanupStack::Pop(fileDescription); |
|
213 } |
|
214 |
|
215 EXPORT_C void CApplication::DisplayFileOnUninstallL(const CSisRegistryFileDescription& aFileDescription) |
|
216 { |
|
217 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription); |
|
218 User::LeaveIfError(iFilesToDisplayOnUninstall.Append(fileDescription)); |
|
219 CleanupStack::Pop(fileDescription); |
|
220 } |
|
221 |
|
222 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToDisplayOnInstall() const |
|
223 { |
|
224 return iFilesToDisplayOnInstall; |
|
225 } |
|
226 |
|
227 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToDisplayOnUninstall() const |
|
228 { |
|
229 return iFilesToDisplayOnUninstall; |
|
230 } |
|
231 |
|
232 EXPORT_C TBool CApplication::IsUpgrade() const |
|
233 { |
|
234 return iFlags & EUpgrade; |
|
235 } |
|
236 |
|
237 EXPORT_C void CApplication::SetUpgrade(const Sis::CController& aController) |
|
238 { |
|
239 iFlags |= EUpgrade; |
|
240 SetController(aController); |
|
241 } |
|
242 |
|
243 EXPORT_C TBool CApplication::IsInstall() const |
|
244 { |
|
245 return iFlags & EInstall; |
|
246 } |
|
247 |
|
248 EXPORT_C void CApplication::SetInstall(const Sis::CController& aController) |
|
249 { |
|
250 iFlags |= EInstall; |
|
251 SetController(aController); |
|
252 } |
|
253 |
|
254 EXPORT_C TBool CApplication::IsUninstall() const |
|
255 { |
|
256 return iFlags & EUninstall; |
|
257 } |
|
258 |
|
259 EXPORT_C void CApplication::SetUninstallL(const CSisRegistryPackage& aPackage) |
|
260 { |
|
261 iFlags |= EUninstall; |
|
262 SetPackageL(aPackage); |
|
263 } |
|
264 |
|
265 EXPORT_C TBool CApplication::IsAugmentation() const |
|
266 { |
|
267 return iFlags & EAugmentation; |
|
268 } |
|
269 |
|
270 EXPORT_C void CApplication::SetAugmentation(const Sis::CController& aController) |
|
271 { |
|
272 iFlags |= EAugmentation; |
|
273 SetController(aController); |
|
274 } |
|
275 |
|
276 EXPORT_C TBool CApplication::IsPartialUpgrade() const |
|
277 { |
|
278 return iFlags & EPartialUpgrade; |
|
279 } |
|
280 |
|
281 EXPORT_C void CApplication::SetPartialUpgrade(const Sis::CController& aController) |
|
282 { |
|
283 iFlags |= EPartialUpgrade; |
|
284 SetController(aController); |
|
285 } |
|
286 |
|
287 EXPORT_C TBool CApplication::IsPreInstalledPatch() const |
|
288 { |
|
289 return iFlags & EPreInstalledPatch; |
|
290 } |
|
291 |
|
292 EXPORT_C void CApplication::SetPreInstalledPatch(const Sis::CController& aController) |
|
293 { |
|
294 iFlags |= EPreInstalledPatch; |
|
295 SetController(aController); |
|
296 } |
|
297 |
|
298 EXPORT_C void CApplication::SetPreInstalledPatch() |
|
299 { |
|
300 iFlags |= EPreInstalledPatch; |
|
301 } |
|
302 |
|
303 EXPORT_C TBool CApplication::IsPreInstalledApp() const |
|
304 { |
|
305 return iFlags & EPreInstalledApp; |
|
306 } |
|
307 |
|
308 EXPORT_C void CApplication::SetPreInstalledApp(const Sis::CController& aController) |
|
309 { |
|
310 iFlags |= EPreInstalledApp; |
|
311 SetController(aController); |
|
312 } |
|
313 |
|
314 EXPORT_C void CApplication::SetPreInstalledApp() |
|
315 { |
|
316 iFlags |= EPreInstalledApp; |
|
317 } |
|
318 |
|
319 EXPORT_C TBool CApplication::IsInROM(void) const |
|
320 { |
|
321 return iFlags & EInRom; |
|
322 } |
|
323 |
|
324 EXPORT_C void CApplication::SetInROM(void) |
|
325 { |
|
326 iFlags |= EInRom; |
|
327 } |
|
328 |
|
329 EXPORT_C void CApplication::AddPropertyL(const TProperty& aProperty) |
|
330 { |
|
331 User::LeaveIfError(iProperties.Append(aProperty)); |
|
332 } |
|
333 |
|
334 EXPORT_C const RArray<CApplication::TProperty>& CApplication::Properties() const |
|
335 { |
|
336 return iProperties; |
|
337 } |
|
338 |
|
339 EXPORT_C const CSisRegistryPackage& CApplication::PackageL() const |
|
340 { |
|
341 if (!iPackage) |
|
342 { |
|
343 User::Leave(KErrGeneral); |
|
344 } |
|
345 return *iPackage; |
|
346 } |
|
347 |
|
348 EXPORT_C void CApplication::SetPackageL(const CSisRegistryPackage& aPackage) |
|
349 { |
|
350 delete iPackage; |
|
351 iPackage=0; |
|
352 iPackage=CSisRegistryPackage::NewL(aPackage); |
|
353 } |
|
354 |
|
355 EXPORT_C const Sis::CController& CApplication::ControllerL(void) const |
|
356 { |
|
357 if (!iController) |
|
358 { |
|
359 User::Leave(KErrGeneral); |
|
360 } |
|
361 return (*iController); |
|
362 } |
|
363 |
|
364 EXPORT_C void CApplication::SetController(TUid aUid) |
|
365 { |
|
366 delete iUid; |
|
367 iUid=new(ELeave) TUid(aUid); |
|
368 } |
|
369 |
|
370 |
|
371 EXPORT_C void CApplication::SetController(const Sis::CController& aController) |
|
372 { |
|
373 iController=&aController; |
|
374 } |
|
375 |
|
376 |
|
377 EXPORT_C const RPointerArray<CApplication>& CApplication::EmbeddedApplications() const |
|
378 { |
|
379 return iEmbeddedApplications; |
|
380 } |
|
381 |
|
382 EXPORT_C void CApplication::AddEmbeddedApplicationL(CApplication* aApplication) |
|
383 { |
|
384 User::LeaveIfError(iEmbeddedApplications.Append(aApplication)); |
|
385 } |
|
386 |
|
387 EXPORT_C TBool CApplication::CanPropagate() const |
|
388 { |
|
389 return iCanPropagate && (iPropagateDrive != '!'); |
|
390 } |
|
391 |
|
392 EXPORT_C TChar CApplication::StubDrive() const |
|
393 { |
|
394 return iPropagateDrive; |
|
395 } |
|
396 |
|
397 EXPORT_C void CApplication::CopyDeviceSupportedLanguagesL(const RArray<TInt> &aDeviceSupportedLanguages) |
|
398 { |
|
399 TInt size = aDeviceSupportedLanguages.Count(); |
|
400 while (size--) |
|
401 User::LeaveIfError(iDeviceSupportedLanguages.Append(aDeviceSupportedLanguages[size])); |
|
402 } |
|
403 |
|
404 EXPORT_C void CApplication::PopulateMatchingDeviceLanguagesL(TInt aLanguageId) |
|
405 { |
|
406 TRAPD(error,iMatchingDeviceLanguages.InsertInOrderL(aLanguageId)) |
|
407 if ( error != KErrNone && error != KErrAlreadyExists) |
|
408 { |
|
409 User::Leave(error); |
|
410 } |
|
411 } |
|
412 |
|
413 EXPORT_C const RArray<TInt>& CApplication::GetMatchingDeviceLanguages(void) |
|
414 { |
|
415 return iMatchingDeviceLanguages; |
|
416 } |
|
417 |
|
418 EXPORT_C TBool CApplication::IsDeviceMatchingLanguage(TInt aLangId)const |
|
419 { |
|
420 TInt found = iDeviceSupportedLanguages.Find(aLangId); |
|
421 if ( found == KErrNotFound ) |
|
422 { |
|
423 return EFalse; |
|
424 } |
|
425 |
|
426 return ETrue; |
|
427 } |
|
428 |
|
429 EXPORT_C TBool CApplication::IsInstallSuCertBased() const |
|
430 { |
|
431 return iFlags & EInstallSuCertBased; |
|
432 } |
|
433 |
|
434 EXPORT_C void CApplication::SetInstallSuCertBased() |
|
435 { |
|
436 iFlags |= EInstallSuCertBased; |
|
437 } |
|
438 |
|
439 EXPORT_C const RPointerArray<CSisRegistryFileDescription>& CApplication::FilesToSkipOnInstall() const |
|
440 { |
|
441 return iFilesToSkipOnInstall; |
|
442 } |
|
443 |
|
444 EXPORT_C void CApplication::SkipFileOnInstallL(const Sis::CFileDescription& aFileDescription, TChar aDrive) |
|
445 { |
|
446 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription, aDrive, iIsStub); |
|
447 User::LeaveIfError(iFilesToSkipOnInstall.Append(fileDescription)); |
|
448 CleanupStack::Pop(fileDescription); |
|
449 } |
|
450 |
|
451 EXPORT_C void CApplication::AddFileL(const CSisRegistryFileDescription& aFileDescription) |
|
452 { |
|
453 CSisRegistryFileDescription* fileDescription = CSisRegistryFileDescription::NewLC(aFileDescription); |
|
454 User::LeaveIfError(iFilesToAdd.Append(fileDescription)); |
|
455 CleanupStack::Pop(fileDescription); |
|
456 |
|
457 // Update the propagation status |
|
458 |
|
459 if (iCanPropagate) |
|
460 { |
|
461 TChar drive = fileDescription->Target()[0]; |
|
462 drive.Fold(); |
|
463 if (iPropagateDrive != '!') |
|
464 { |
|
465 // This is not the first file description, check the drive letter against the first |
|
466 iCanPropagate = (iPropagateDrive == drive); |
|
467 } |
|
468 else |
|
469 { |
|
470 // This is the first file description, just update the drive |
|
471 iPropagateDrive = drive; |
|
472 } |
|
473 } |
|
474 |
|
475 } |
|
476 |
|
477 EXPORT_C void CApplication::SetSisHelper(const RSisHelper& aSisHelper) |
|
478 { |
|
479 iSisHelper = &aSisHelper; |
|
480 } |
|
481 |
|
482 EXPORT_C RSisHelper& CApplication::GetSisHelper() |
|
483 { |
|
484 return (const_cast <RSisHelper&> (*iSisHelper)); |
|
485 } |
|
486 |
|
487 |
|
488 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
489 EXPORT_C void CApplication::SetDrmProtected(TBool aIsDrmProtected) |
|
490 { |
|
491 iIsDrmProtected = aIsDrmProtected; |
|
492 } |
|
493 #else |
|
494 EXPORT_C void CApplication::SetDrmProtected(TBool /*aIsDrmProtected*/) |
|
495 { |
|
496 __ASSERT_ALWAYS(EFalse, User::Invariant()); |
|
497 } |
|
498 #endif |
|
499 |
|
500 EXPORT_C TBool CApplication::IsDrmProtected() const |
|
501 { |
|
502 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
503 return iIsDrmProtected; |
|
504 #else |
|
505 __ASSERT_ALWAYS(EFalse, User::Invariant()); |
|
506 return EFalse; |
|
507 #endif |
|
508 } |
|
509 |