|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Definition of CNcdInstallationService |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdinstallationserviceimpl.h" |
|
20 |
|
21 #include <DocumentHandler.h> |
|
22 #include <apmstd.h> |
|
23 #include <apmrec.h> |
|
24 #include <bautils.h> |
|
25 |
|
26 #include <swi/sisregistrypackage.h> |
|
27 #include <caf/caf.h> |
|
28 #include <caf/supplier.h> |
|
29 #include <caf/importfile.h> |
|
30 #include <Oma2Agent.h> |
|
31 #include <s32file.h> |
|
32 #include <e32property.h> |
|
33 #include <sacls.h> |
|
34 |
|
35 #ifdef USE_OLD_JAVA_API |
|
36 #include <mjavaregistry.h> |
|
37 #include <swi/minstalledappsregistry.h> |
|
38 #else |
|
39 #include <javaregistry.h> |
|
40 #include <javaregistrypackageentry.h> |
|
41 |
|
42 using namespace Java; |
|
43 #endif |
|
44 |
|
45 #include "ncdinstallationserviceobserver.h" |
|
46 #include "ncdactiveoperationobserver.h" |
|
47 #include "ncdsilentinstallactiveobserver.h" |
|
48 #include "ncderrors.h" |
|
49 #include "catalogsutils.h" |
|
50 #include "catalogsconstants.h" |
|
51 #include "catalogsdebug.h" |
|
52 |
|
53 _LIT( KJadFileExtension, ".jad" ); |
|
54 const TInt KDelayWhenAppListInvalid = 500000; |
|
55 |
|
56 const TUint KFileOpenFlags = EFileShareReadersOrWriters; |
|
57 |
|
58 #ifdef __SERIES60_31__ |
|
59 |
|
60 const TInt32 KPSUidJavaLatestInstallation = KUidJmiLatestInstallation; |
|
61 |
|
62 #else |
|
63 |
|
64 // Defined originally in /mw/java/inc/javauids.h |
|
65 // This should become available at some point in javadomainpskeys.h |
|
66 //const TInt32 KPSUidJavaLatestInstallation = 0x10282567; |
|
67 #include <javadomainpskeys.h> |
|
68 |
|
69 #endif |
|
70 |
|
71 // length taken from WidgetRegistryData.h |
|
72 const TInt KWidgetBundleIdLength = KWidgetRegistryVal + 1; |
|
73 |
|
74 _LIT( KWidgetExtension, ".wgz" ); |
|
75 |
|
76 // ======== CALLBACK FUNCTION ======== |
|
77 |
|
78 static TInt InstallationCompleteCallback( TAny* aData ) |
|
79 { |
|
80 DLTRACEIN(("")); |
|
81 TRAPD( err, |
|
82 { |
|
83 CNcdInstallationService* service = |
|
84 reinterpret_cast<CNcdInstallationService*>( aData ); |
|
85 DASSERT( service ); |
|
86 service->NotifyObserverL(); |
|
87 } ); |
|
88 |
|
89 DLTRACEOUT(("")); |
|
90 return err; |
|
91 } |
|
92 |
|
93 |
|
94 // ======== MEMBER FUNCTIONS ======== |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Constructor. |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CNcdInstallationService* CNcdInstallationService::NewL() |
|
101 { |
|
102 CNcdInstallationService* self = NewLC(); |
|
103 CleanupStack::Pop(); |
|
104 return self; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // Constructor. |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 CNcdInstallationService* CNcdInstallationService::NewLC() |
|
112 { |
|
113 CNcdInstallationService* self = |
|
114 new (ELeave) CNcdInstallationService(); |
|
115 CleanupStack::PushL( self ); |
|
116 self->ConstructL(); |
|
117 return self; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Destructor. |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 CNcdInstallationService::~CNcdInstallationService() |
|
125 { |
|
126 DLTRACEIN(("")); |
|
127 delete iSilentInstallActiveObserver; |
|
128 iSilentInstallActiveObserver = NULL; |
|
129 delete iDocHandler; |
|
130 iRegistrySession.Close(); |
|
131 iFs.Close(); |
|
132 iAknsSrv.Close(); |
|
133 delete iInstallationCompleteCallback; |
|
134 delete iJadFileName; |
|
135 delete iRecognizedMime; |
|
136 #ifdef USE_OLD_JAVA_API |
|
137 iMIDletUids.Close(); |
|
138 #endif |
|
139 iApaLs.Close(); |
|
140 if( iThemes ) |
|
141 { |
|
142 iThemes->ResetAndDestroy(); |
|
143 delete iThemes; |
|
144 } |
|
145 |
|
146 // Deletes iInstallStatusObserver and closes iInstaller |
|
147 CancelInstall(); |
|
148 iRomUids.Close(); |
|
149 |
|
150 if ( iWidgetRegistry.Handle() ) |
|
151 { |
|
152 // decreases widget server's refcount but this cannot be called |
|
153 // if Connect has not been called or we'll get a KERN-EXEC 0 |
|
154 iWidgetRegistry.Disconnect(); |
|
155 } |
|
156 else |
|
157 { |
|
158 iWidgetRegistry.Close(); |
|
159 } |
|
160 iInstalledWidgets.ResetAndDestroy(); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // Constructor. |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 CNcdInstallationService::CNcdInstallationService() |
|
168 { |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // Constructor. |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CNcdInstallationService::ConstructL() |
|
176 { |
|
177 DLTRACEIN(("")); |
|
178 iDocHandler = CDocumentHandler::NewL(); |
|
179 iDocHandler->SetExitObserver( this ); |
|
180 |
|
181 User::LeaveIfError( iFs.Connect() ); |
|
182 User::LeaveIfError( iFs.ShareProtected() ); |
|
183 User::LeaveIfError( iRegistrySession.Connect() ); |
|
184 User::LeaveIfError( iAknsSrv.Connect() ); |
|
185 |
|
186 iInstallationCompleteCallback = new(ELeave) CAsyncCallBack( |
|
187 TCallBack( InstallationCompleteCallback, this ), |
|
188 CActive::EPriorityStandard ); |
|
189 |
|
190 InitializeRomApplicationListL(); |
|
191 } |
|
192 |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // Installs all kinds of files. |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CNcdInstallationService::InstallL( const TDesC& aFileName, |
|
199 const TDesC& aMimeType, |
|
200 const TNcdItemPurpose& aPurpose ) |
|
201 { |
|
202 DLTRACEIN(("")); |
|
203 RFile file; |
|
204 CleanupClosePushL( file ); |
|
205 User::LeaveIfError( file.Open( FileServerSession(), aFileName, KFileOpenFlags ) ); |
|
206 InstallL( file, aMimeType, aPurpose, NULL ); |
|
207 CleanupStack::PopAndDestroy( &file ); |
|
208 DLTRACEOUT(("")); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Installs all kinds of files. |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void CNcdInstallationService::InstallL( RFile& aFile, |
|
216 const TDesC& aMimeType, |
|
217 const TNcdItemPurpose& aPurpose ) |
|
218 { |
|
219 DLTRACEIN(("")); |
|
220 InstallL( aFile, aMimeType, aPurpose, NULL ); |
|
221 DLTRACEOUT(("")); |
|
222 } |
|
223 |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // Installs java files. |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CNcdInstallationService::InstallJavaL( const TDesC& aFileName, |
|
230 const TDesC& aMimeType, |
|
231 const TDesC8& aDescriptorData ) |
|
232 { |
|
233 DLTRACEIN(("")); |
|
234 RFile file; |
|
235 CleanupClosePushL( file ); |
|
236 User::LeaveIfError( file.Open( FileServerSession(), aFileName, KFileOpenFlags ) ); |
|
237 InstallJavaL( file, aMimeType, aDescriptorData, NULL ); |
|
238 CleanupStack::PopAndDestroy( &file ); |
|
239 DLTRACEOUT(("")); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // Installs java files. |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CNcdInstallationService::InstallJavaL( RFile& aFile, |
|
247 const TDesC& aMimeType, |
|
248 const TDesC8& aDescriptorData ) |
|
249 { |
|
250 DLTRACEIN(("")); |
|
251 InstallJavaL( aFile, aMimeType, aDescriptorData, NULL ); |
|
252 DLTRACEOUT(("")); |
|
253 } |
|
254 |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // Installs all kinds of files silently. |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CNcdInstallationService::SilentInstallL( RFile& aFile, |
|
261 const TDesC& aMimeType, |
|
262 const TNcdItemPurpose& aPurpose, |
|
263 const SwiUI::TInstallOptionsPckg& aInstallOptionsPckg ) |
|
264 { |
|
265 DLTRACEIN(("")); |
|
266 |
|
267 if ( iSilentInstallActiveObserver == NULL ) |
|
268 { |
|
269 DLINFO(("Create active observer for silent install")); |
|
270 iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this ); |
|
271 } |
|
272 |
|
273 InstallL( aFile, aMimeType, aPurpose, &aInstallOptionsPckg ); |
|
274 |
|
275 DLTRACEOUT(("")); |
|
276 } |
|
277 |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // Installs java files silently. |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CNcdInstallationService::SilentInstallJavaL( RFile& aFile, |
|
284 const TDesC& aMimeType, |
|
285 const TDesC8& aDescriptorData, |
|
286 const SwiUI::TInstallOptionsPckg& aInstallOptionsPckg ) |
|
287 { |
|
288 DLTRACEIN(("")); |
|
289 |
|
290 if ( iSilentInstallActiveObserver == NULL ) |
|
291 { |
|
292 DLINFO(("Create active observer for silent install")); |
|
293 iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this ); |
|
294 } |
|
295 |
|
296 InstallJavaL( aFile, aMimeType, aDescriptorData, &aInstallOptionsPckg ); |
|
297 |
|
298 DLTRACEOUT(("")); |
|
299 } |
|
300 |
|
301 |
|
302 // --------------------------------------------------------------------------- |
|
303 // Cancell silent install. |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 void CNcdInstallationService::CancelSilentInstall( HBufC*& aFileName, |
|
307 TUid& aAppUid, |
|
308 TInt& aError ) |
|
309 { |
|
310 DLTRACEIN(("")); |
|
311 |
|
312 // Silent install can only be cancelled if silent is allowed. |
|
313 // The capability check makes sure of this. |
|
314 |
|
315 // Set intial values for the reference parameters. |
|
316 delete aFileName; |
|
317 aFileName = NULL; |
|
318 aAppUid = KNullUid; |
|
319 aError = KErrCancel; |
|
320 |
|
321 if ( iBusy ) |
|
322 { |
|
323 DLINFO(("Install operation was busy")); |
|
324 |
|
325 // Some operation is on. Here we expect that it is silent. |
|
326 // Inform the installer that the asynchronous silent install request |
|
327 // needs to be cancelled. |
|
328 // Because we use a dummy active object to observe |
|
329 // completion of installation and that dummy object uses call backs |
|
330 // to inform completion to observer, we have to cancel the operation |
|
331 // by using the dummy object here. |
|
332 aError = iSilentInstallActiveObserver->CancelAsyncOperation(); |
|
333 |
|
334 if ( aError == KErrNone ) |
|
335 { |
|
336 DLINFO(("Installation was success even if cancel was issued.")) |
|
337 |
|
338 // The installation was finished after all. |
|
339 TRAPD( trapError, |
|
340 HandleSilentInstallSuccessAfterCancelL( aFileName, |
|
341 aAppUid, |
|
342 aError ) ); |
|
343 if ( trapError != KErrNone ) |
|
344 { |
|
345 DLERROR(("Install success handling leave.")); |
|
346 aError = trapError; |
|
347 } |
|
348 } |
|
349 |
|
350 // Do cleaning if necessary. |
|
351 if( iJadFileName != NULL ) |
|
352 { |
|
353 // Delete tmp JAD file that was created in the beginning of |
|
354 // the install operation. It will be recreated in new install operation |
|
355 // if needed. |
|
356 BaflUtils::DeleteFile( iFs, *iJadFileName ); // NOTE, error ignored |
|
357 delete iJadFileName; |
|
358 iJadFileName = NULL; |
|
359 } |
|
360 |
|
361 #ifdef USE_OLD_JAVA_API |
|
362 // Clean the array. |
|
363 iMIDletUids.Reset(); |
|
364 #endif |
|
365 |
|
366 // Reset information flags. |
|
367 InstallationFinishedSetup( aError ); |
|
368 } |
|
369 } |
|
370 |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // Sets observer for installation services. |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CNcdInstallationService::SetObserver( |
|
377 MNcdInstallationServiceObserver& aObserver ) |
|
378 { |
|
379 iObserver = &aObserver; |
|
380 } |
|
381 |
|
382 |
|
383 // --------------------------------------------------------------------------- |
|
384 // Gets version of installed application by using its UID. |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 TInt CNcdInstallationService::ApplicationVersion( const TUid& aUid, |
|
388 TCatalogsVersion& aVersion ) |
|
389 { |
|
390 DLTRACEIN(("Uid=%X",aUid.iUid)); |
|
391 |
|
392 // First case: see if the uid is directly in the sis registry. |
|
393 Swi::RSisRegistryEntry entry; |
|
394 |
|
395 TVersion version; |
|
396 TRAPD( err, |
|
397 { |
|
398 SisRegistryEntryLC( entry, aUid ); |
|
399 // Get version number |
|
400 version = entry.VersionL(); |
|
401 CleanupStack::PopAndDestroy( &entry ); |
|
402 }); |
|
403 |
|
404 if ( err != KErrNone ) |
|
405 { |
|
406 DLTRACEOUT(("Error: %d", err)); |
|
407 return err; |
|
408 } |
|
409 |
|
410 aVersion.iMajor = version.iMajor; |
|
411 aVersion.iMinor = version.iMinor; |
|
412 aVersion.iBuild = version.iBuild; |
|
413 |
|
414 DLTRACEOUT(("err=%d",err)); |
|
415 return err; |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // Checks whether an application is installed on the device. |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 TBool CNcdInstallationService::IsApplicationInstalledL( const TUid& aUid ) |
|
423 { |
|
424 DLTRACEIN(("uid=%X",aUid.iUid)); |
|
425 TBool result = EFalse; |
|
426 |
|
427 Swi::RSisRegistryEntry entry; |
|
428 |
|
429 // First case: See if the UID is directly in the SIS Registry. |
|
430 TRAPD( err, |
|
431 { |
|
432 SisRegistryEntryLC( entry, aUid ); |
|
433 |
|
434 DLTRACE(("Check that entry is present")); |
|
435 result = entry.IsPresentL(); |
|
436 CleanupStack::PopAndDestroy( &entry ); |
|
437 }); |
|
438 |
|
439 LeaveIfNotErrorL( err, KErrNotFound ); |
|
440 |
|
441 // Third case: see if the UID is mapped to the Java Registry or is a Widget |
|
442 if ( !result ) |
|
443 { |
|
444 result = ( JavaAppExistsL( aUid ) || |
|
445 WidgetExistsL( aUid ) ); |
|
446 } |
|
447 |
|
448 |
|
449 // Check if the app is ROM only |
|
450 if ( !result ) |
|
451 { |
|
452 result = IsRomApplication( aUid ); |
|
453 } |
|
454 DLTRACEOUT(("result=%d",result)); |
|
455 return result; |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // Opens SIS registry entry |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CNcdInstallationService::SisRegistryEntryLC( |
|
463 Swi::RSisRegistryEntry& aEntry, |
|
464 const TUid& aUid ) |
|
465 { |
|
466 DLTRACEIN(("")); |
|
467 CleanupClosePushL( aEntry ); |
|
468 |
|
469 if ( aEntry.Open( iRegistrySession, aUid ) == KErrNone ) |
|
470 { |
|
471 DLTRACEOUT(("Entry opened")); |
|
472 return; |
|
473 } |
|
474 |
|
475 // Second case: See if the UID is mapped to a package/entry |
|
476 // in the registry ( -> APP UID that differs from SIS UID ). |
|
477 |
|
478 Swi::CSisRegistryPackage* sisRegistryPackage = |
|
479 iRegistrySession.SidToPackageL( aUid ); |
|
480 CleanupStack::PushL( sisRegistryPackage ); |
|
481 |
|
482 TInt err = aEntry.OpenL( iRegistrySession, *sisRegistryPackage ); |
|
483 User::LeaveIfError( err ); |
|
484 |
|
485 CleanupStack::PopAndDestroy( sisRegistryPackage ); |
|
486 |
|
487 DLTRACEOUT(("Entry opened")); |
|
488 } |
|
489 |
|
490 |
|
491 // --------------------------------------------------------------------------- |
|
492 // Open java suite entry |
|
493 // |
|
494 // --------------------------------------------------------------------------- |
|
495 // |
|
496 #ifdef USE_OLD_JAVA_API |
|
497 |
|
498 TBool CNcdInstallationService::JavaAppExistsL( |
|
499 const TUid& aUid ) |
|
500 { |
|
501 DLTRACEIN(("")); |
|
502 |
|
503 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
|
504 CleanupReleasePushL( *javaRegistry ); |
|
505 |
|
506 TRAPD( err, |
|
507 { |
|
508 // Leaves with KErrNotFound if not found |
|
509 MJavaRegistryMIDletEntry* midletEntry = javaRegistry->MIDletEntryL( |
|
510 aUid ); |
|
511 midletEntry->Release(); |
|
512 }); |
|
513 |
|
514 LeaveIfNotErrorL( err, KErrNotFound ); |
|
515 |
|
516 CleanupStack::PopAndDestroy( javaRegistry ); |
|
517 return err == KErrNone; |
|
518 } |
|
519 |
|
520 #else |
|
521 |
|
522 TBool CNcdInstallationService::JavaAppExistsL( |
|
523 const TUid& aUid ) |
|
524 { |
|
525 DLTRACEIN(("")); |
|
526 |
|
527 CJavaRegistry* javaRegistry = CJavaRegistry::NewLC(); |
|
528 |
|
529 TBool exists = javaRegistry->RegistryEntryExistsL( aUid ); |
|
530 |
|
531 CleanupStack::PopAndDestroy( javaRegistry ); |
|
532 return exists; |
|
533 } |
|
534 |
|
535 #endif |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // Checks the application status |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 TNcdApplicationStatus CNcdInstallationService::IsApplicationInstalledL( |
|
542 const TUid& aUid, const TCatalogsVersion& aVersion ) |
|
543 { |
|
544 DLTRACEIN(("")); |
|
545 |
|
546 TNcdApplicationStatus status( ENcdApplicationNotInstalled ); |
|
547 |
|
548 if ( aUid == TUid::Null() ) |
|
549 { |
|
550 DLTRACEOUT(("Null uid")); |
|
551 return status; |
|
552 } |
|
553 |
|
554 |
|
555 Swi::RSisRegistryEntry entry; |
|
556 TCatalogsVersion installedVersion; |
|
557 |
|
558 // Get SIS-app version |
|
559 TRAPD( err, |
|
560 { |
|
561 SisRegistryEntryLC( entry, aUid ); |
|
562 |
|
563 DLTRACE(("Check that entry is present")); |
|
564 |
|
565 if ( entry.IsPresentL() ) |
|
566 { |
|
567 DLTRACE(("Is present")); |
|
568 status = ENcdApplicationInstalled; |
|
569 } |
|
570 |
|
571 TVersion version = entry.VersionL(); |
|
572 installedVersion = TCatalogsVersion( |
|
573 version.iMajor, |
|
574 version.iMinor, |
|
575 version.iBuild ); |
|
576 |
|
577 CleanupStack::PopAndDestroy( &entry ); |
|
578 }); |
|
579 |
|
580 // SIS app not found, try to get java |
|
581 if ( err == KErrNotFound && |
|
582 ( JavaAppExistsL( aUid ) || |
|
583 WidgetExistsL( aUid ) ) ) |
|
584 { |
|
585 status = ENcdApplicationInstalled; |
|
586 } |
|
587 |
|
588 LeaveIfNotErrorL( err, KErrNotFound ); |
|
589 |
|
590 // Some app found, check version numbers if they are something else than |
|
591 // 0.0.0 |
|
592 if ( err == KErrNone && |
|
593 status == ENcdApplicationInstalled && |
|
594 installedVersion != TCatalogsVersion() && |
|
595 aVersion != TCatalogsVersion() ) |
|
596 { |
|
597 DLINFO(("Installed version: %d.%d.%d, comparing to: %d.%d.%d", |
|
598 installedVersion.iMajor, |
|
599 installedVersion.iMinor, |
|
600 installedVersion.iBuild, |
|
601 aVersion.iMajor, |
|
602 aVersion.iMinor, |
|
603 aVersion.iBuild )); |
|
604 |
|
605 if ( installedVersion > aVersion ) |
|
606 { |
|
607 status = ENcdApplicationNewerVersionInstalled; |
|
608 } |
|
609 else if ( !( installedVersion == aVersion ) ) |
|
610 { |
|
611 status = ENcdApplicationOlderVersionInstalled; |
|
612 } |
|
613 } |
|
614 |
|
615 // Checking if the app is ROM only |
|
616 if ( status == ENcdApplicationNotInstalled && |
|
617 IsRomApplication( aUid ) ) |
|
618 { |
|
619 status = ENcdApplicationInstalled; |
|
620 } |
|
621 |
|
622 DLTRACEOUT(("Status: %d", status)); |
|
623 return status; |
|
624 } |
|
625 |
|
626 |
|
627 // --------------------------------------------------------------------------- |
|
628 // Gets the first SID from the SIS registry package |
|
629 // --------------------------------------------------------------------------- |
|
630 // |
|
631 TUid CNcdInstallationService::SidFromSisRegistryL( const TUid& aUid ) |
|
632 { |
|
633 DLTRACEIN(("uid=%X",aUid.iUid)); |
|
634 Swi::RSisRegistryEntry entry; |
|
635 TUid sid( KNullUid ); |
|
636 |
|
637 User::LeaveIfError( entry.Open( iRegistrySession, aUid ) ); |
|
638 CleanupClosePushL( entry ); |
|
639 |
|
640 RArray<TUid> sids; |
|
641 CleanupClosePushL( sids ); |
|
642 entry.SidsL( sids ); |
|
643 |
|
644 DLINFO(("sid count=%d",sids.Count())); |
|
645 |
|
646 if ( sids.Count() > 0 ) |
|
647 { |
|
648 sid.iUid = sids[0].iUid; |
|
649 } |
|
650 else |
|
651 { |
|
652 DLERROR(("No SIDs found")); |
|
653 User::Leave( KErrNotFound ); |
|
654 } |
|
655 |
|
656 CleanupStack::PopAndDestroy( &sids ); |
|
657 CleanupStack::PopAndDestroy( &entry ); |
|
658 |
|
659 DLTRACEOUT(("uid=%X",sid.iUid)); |
|
660 return sid; |
|
661 } |
|
662 |
|
663 // --------------------------------------------------------------------------- |
|
664 // Appends rights into the rights database. |
|
665 // --------------------------------------------------------------------------- |
|
666 // |
|
667 void CNcdInstallationService::AppendRightsL( |
|
668 const TDesC8& aRightsObject, |
|
669 const TDataType& aMimeType ) |
|
670 { |
|
671 DLTRACEIN(("MimeType: %S", &aMimeType.Des8() )); |
|
672 |
|
673 ContentAccess::CSupplier* supplier = |
|
674 ContentAccess::CSupplier::NewLC(); |
|
675 ContentAccess::CMetaDataArray* metaData = |
|
676 ContentAccess::CMetaDataArray::NewLC(); |
|
677 |
|
678 DLTRACE(("Creating CImportFile")); |
|
679 // Indicate what type of content we are importing. |
|
680 ContentAccess::CImportFile* file = supplier->ImportFileL( aMimeType.Des8(), *metaData ); |
|
681 CleanupStack::PushL( file ); |
|
682 |
|
683 DLTRACE(("Importing data")); |
|
684 // Start importing data. This can also be done in parts. |
|
685 User::LeaveIfError( file->WriteData( aRightsObject ) ); |
|
686 |
|
687 DLTRACE(("Finished importing")); |
|
688 // Indicate that we are finished |
|
689 User::LeaveIfError( file->WriteDataComplete() ); |
|
690 |
|
691 CleanupStack::PopAndDestroy( file ); |
|
692 CleanupStack::PopAndDestroy( metaData ); |
|
693 CleanupStack::PopAndDestroy( supplier ); |
|
694 DLTRACEOUT(("")); |
|
695 } |
|
696 |
|
697 |
|
698 // --------------------------------------------------------------------------- |
|
699 // Reads the package uid from a SISX file |
|
700 // --------------------------------------------------------------------------- |
|
701 // |
|
702 TUid CNcdInstallationService::PackageUidFromSisL( RFile& aFile ) const |
|
703 { |
|
704 DLTRACEIN(("")); |
|
705 RFileReadStream readStream( aFile ); |
|
706 CleanupClosePushL( readStream ); |
|
707 |
|
708 // Get Application UID |
|
709 // |
|
710 |
|
711 // NOTE: In 3.0 the SIS file format has changed |
|
712 // the UID is the third long word ( 32 bits ) of the file. |
|
713 TInt dummy = readStream.ReadUint32L(); |
|
714 dummy = readStream.ReadUint32L(); |
|
715 |
|
716 TUid uid( TUid::Uid( readStream.ReadUint32L() ) ); |
|
717 |
|
718 // this closes the attached file too |
|
719 CleanupStack::PopAndDestroy( &readStream ); |
|
720 DLTRACEOUT(( _L("Uid: %S"), &uid.Name() )); |
|
721 return uid; |
|
722 } |
|
723 |
|
724 |
|
725 // --------------------------------------------------------------------------- |
|
726 // IsThemeInstalled |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 TBool CNcdInstallationService::IsThemeInstalledL( const TDesC& aThemeName ) |
|
730 { |
|
731 DLTRACEIN(( _L("Theme: %S"), &aThemeName )); |
|
732 TInt result = EFalse; |
|
733 |
|
734 if ( aThemeName != KNullDesC ) |
|
735 { |
|
736 RAknsSrvSession skinSrvSession; |
|
737 User::LeaveIfError( skinSrvSession.Connect() ); |
|
738 CleanupClosePushL( skinSrvSession ); |
|
739 |
|
740 CArrayPtr<CAknsSrvSkinInformationPkg>* srvArray = NULL; |
|
741 // Look themes from C: and E: drives |
|
742 for ( TInt index = 0; index < 2; index++ ) |
|
743 { |
|
744 //TUint skinLocation = 0; |
|
745 if ( index == 0 ) |
|
746 { |
|
747 //skinLocation = EAknsSrvPhone; |
|
748 srvArray = skinSrvSession.EnumerateSkinPackagesL( EAknsSrvPhone ); |
|
749 CleanupStack::PushL( srvArray ); |
|
750 } |
|
751 else |
|
752 { |
|
753 //skinLocation = EAknsSrvMMC; |
|
754 srvArray = skinSrvSession.EnumerateSkinPackagesL( EAknsSrvMMC ); |
|
755 CleanupStack::PushL( srvArray ); |
|
756 } |
|
757 |
|
758 while ( srvArray && srvArray->Count() > 0 ) |
|
759 { |
|
760 CAknsSrvSkinInformationPkg* info = srvArray->At( 0 ); |
|
761 |
|
762 // If match is found, theme can be set |
|
763 if ( info->Name().Compare( aThemeName ) == 0 ) |
|
764 { |
|
765 result = ETrue; |
|
766 } |
|
767 |
|
768 delete info; |
|
769 srvArray->Delete( 0 ); |
|
770 } |
|
771 |
|
772 CleanupStack::PopAndDestroy( srvArray ); |
|
773 |
|
774 if ( result ) |
|
775 { |
|
776 break; |
|
777 } |
|
778 } |
|
779 |
|
780 CleanupStack::PopAndDestroy(); // skinSrvSession |
|
781 } |
|
782 DLTRACEOUT(("Result: %d", result)); |
|
783 return result; |
|
784 } |
|
785 |
|
786 |
|
787 // --------------------------------------------------------------------------- |
|
788 // Deletes the given file |
|
789 // --------------------------------------------------------------------------- |
|
790 // |
|
791 TInt CNcdInstallationService::DeleteFile( const TDesC& aFilename ) |
|
792 { |
|
793 DLTRACEIN(( _L("Filepath: %S"), &aFilename )); |
|
794 // Ensure that we don't accidentally delete whole directories |
|
795 // because of empty path |
|
796 if ( aFilename.Length() ) |
|
797 { |
|
798 return BaflUtils::DeleteFile( iFs, aFilename ); |
|
799 } |
|
800 return KErrArgument; |
|
801 } |
|
802 |
|
803 |
|
804 // --------------------------------------------------------------------------- |
|
805 // File server session getter |
|
806 // --------------------------------------------------------------------------- |
|
807 // |
|
808 RFs& CNcdInstallationService::FileServerSession() |
|
809 { |
|
810 return iFs; |
|
811 } |
|
812 |
|
813 |
|
814 // --------------------------------------------------------------------------- |
|
815 // JAD writer |
|
816 // --------------------------------------------------------------------------- |
|
817 // |
|
818 HBufC* CNcdInstallationService::WriteJadL( |
|
819 const TDesC& aJarFileName, const TDesC8& aJad ) |
|
820 { |
|
821 DLTRACEIN(("Writing JAD")); |
|
822 TParsePtrC jarParse( aJarFileName ); |
|
823 HBufC* jadFileName = HBufC::NewLC( |
|
824 aJarFileName.Length() + KJadFileExtension().Length() ); |
|
825 TPtr jadPtr( jadFileName->Des() ); |
|
826 jadPtr.Append( jarParse.DriveAndPath() ); |
|
827 jadPtr.Append( jarParse.Name() ); |
|
828 jadPtr.Append( KJadFileExtension ); |
|
829 |
|
830 RFile file; |
|
831 CleanupClosePushL( file ); |
|
832 User::LeaveIfError( file.Replace( iFs, *jadFileName, EFileWrite | EFileShareAny ) ); |
|
833 User::LeaveIfError( file.Write( aJad ) ); |
|
834 DLINFO(( _L("JAD=%S"), jadFileName )); |
|
835 CleanupStack::PopAndDestroy( &file ); |
|
836 CleanupStack::Pop( jadFileName ); |
|
837 return jadFileName; |
|
838 } |
|
839 |
|
840 |
|
841 // --------------------------------------------------------------------------- |
|
842 // Documenthandler getter |
|
843 // --------------------------------------------------------------------------- |
|
844 // |
|
845 CDocumentHandler& CNcdInstallationService::DocumentHandler() |
|
846 { |
|
847 return *iDocHandler; |
|
848 } |
|
849 |
|
850 |
|
851 // --------------------------------------------------------------------------- |
|
852 // Callback function of MNcdAsyncOperationObserver interface |
|
853 // This is called when an async operation has finished. |
|
854 // --------------------------------------------------------------------------- |
|
855 // |
|
856 void CNcdInstallationService::AsyncOperationComplete( TInt aError ) |
|
857 { |
|
858 DLTRACEIN(("aError: %d", aError)); |
|
859 |
|
860 iInstaller.Close(); |
|
861 |
|
862 if ( aError == SwiUI::KSWInstErrUserCancel ) |
|
863 { |
|
864 DLTRACE(("User cancelled, converting error to KErrAbort" ) ); |
|
865 aError = KErrAbort; |
|
866 } |
|
867 |
|
868 // Handle this like in normal cases. |
|
869 HandleServerAppExit( aError ); |
|
870 } |
|
871 |
|
872 |
|
873 // --------------------------------------------------------------------------- |
|
874 // Callback function of MNcdAsyncSilentInstallObserver interface |
|
875 // This is called when the silent install has finished. |
|
876 // --------------------------------------------------------------------------- |
|
877 // |
|
878 void CNcdInstallationService::AsyncSilentInstallComplete( TInt aError ) |
|
879 { |
|
880 DLTRACEIN(("aError: %d", aError)); |
|
881 |
|
882 // Handle this like in normal cases. |
|
883 HandleServerAppExit( aError ); |
|
884 } |
|
885 |
|
886 |
|
887 // --------------------------------------------------------------------------- |
|
888 // This function is called after application installer has finished. |
|
889 // --------------------------------------------------------------------------- |
|
890 // |
|
891 void CNcdInstallationService::NotifyObserverL() |
|
892 { |
|
893 DLTRACEIN(("install error: %d", iInstallError )); |
|
894 |
|
895 if ( iInstallType == EWidgetInstall ) |
|
896 { |
|
897 HandleInstalledWidgetL(); |
|
898 } |
|
899 else if ( iInstallType == EJavaInstall ) |
|
900 { |
|
901 if( iJadFileName ) |
|
902 { |
|
903 BaflUtils::DeleteFile( iFs, *iJadFileName ); // NOTE, error ignored |
|
904 delete iJadFileName; |
|
905 iJadFileName = 0; |
|
906 } |
|
907 |
|
908 if ( iInstallError != KErrNone ) |
|
909 { |
|
910 DLTRACE(("Notify install error")); |
|
911 #ifdef USE_OLD_JAVA_API |
|
912 iMIDletUids.Reset(); |
|
913 #endif |
|
914 iObserver->InstallationCompleteL( KNullDesC, TUid(), iInstallError ); |
|
915 return; |
|
916 } |
|
917 |
|
918 TUid midletUid = InstalledMidletUidL(); |
|
919 |
|
920 DLINFO(("Installed midlet uid=%X", midletUid.iUid )); |
|
921 |
|
922 iObserver->InstallationCompleteL( KNullDesC, midletUid, |
|
923 // Return error if nothing found. |
|
924 midletUid == KNullUid ? KErrNotFound : KErrNone ); |
|
925 } |
|
926 |
|
927 else if ( iInstallType == ESisInstall ) |
|
928 { |
|
929 |
|
930 if ( iInstallError != KErrNone ) |
|
931 { |
|
932 DLTRACE(("Notify install error")); |
|
933 iObserver->InstallationCompleteL( KNullDesC, TUid(), iInstallError ); |
|
934 return; |
|
935 } |
|
936 |
|
937 // Get theme name if such was installed |
|
938 const TDesC& name( LatestThemeL() ); |
|
939 |
|
940 // Notify about theme installation |
|
941 if ( iPackageUid.iUid == KNcdThemeSisUid || name != KNullDesC ) |
|
942 { |
|
943 DLTRACE(( _L("Notify observer about theme installation, theme: %S"), |
|
944 &name )); |
|
945 // Ensure that uid is theme uid |
|
946 iPackageUid.iUid = KNcdThemeSisUid; |
|
947 |
|
948 if ( name == KNullDesC && iThemePackageUid.iUid != KNcdThemeSisUid ) |
|
949 { |
|
950 DLTRACE(("Checking theme installation status with package uid, %x", |
|
951 iThemePackageUid.iUid )); |
|
952 |
|
953 TBool themeInstalled = EFalse; |
|
954 |
|
955 // Check if the theme was indeed successfully installed |
|
956 TRAP_IGNORE( themeInstalled = IsApplicationInstalledL( |
|
957 iThemePackageUid ) ); |
|
958 |
|
959 if ( themeInstalled ) |
|
960 { |
|
961 DLINFO(("Theme is installed but we didn't get the name")); |
|
962 iObserver->InstallationCompleteL( |
|
963 name, |
|
964 iPackageUid, |
|
965 KNcdThemeReinstalled ); |
|
966 } |
|
967 else |
|
968 { |
|
969 DLINFO(("Theme was not installed")); |
|
970 iObserver->InstallationCompleteL( |
|
971 name, |
|
972 iPackageUid, |
|
973 KErrGeneral ); |
|
974 |
|
975 } |
|
976 } |
|
977 else |
|
978 { |
|
979 DLTRACE(("Either theme name was acquired or package uid was theme")); |
|
980 iObserver->InstallationCompleteL( |
|
981 name, |
|
982 iPackageUid, |
|
983 // Consider missing theme name as a theme reinstallation |
|
984 name == KNullDesC ? KNcdThemePossiblyReinstalled : KErrNone ); |
|
985 } |
|
986 } |
|
987 else |
|
988 { |
|
989 |
|
990 // Get the actual app UID from sis registry |
|
991 TRAPD( err, iAppUid = SidFromSisRegistryL( iPackageUid ) ); |
|
992 |
|
993 DLTRACE(("Notify observer about application installation, uid: %x", |
|
994 iAppUid.iUid )); |
|
995 |
|
996 if ( err == KErrNotFound ) |
|
997 { |
|
998 DLTRACE(("Didn't get SID, using package UID: %x", |
|
999 iPackageUid.iUid)); |
|
1000 iAppUid.iUid = iPackageUid.iUid; |
|
1001 err = KErrNone; |
|
1002 } |
|
1003 |
|
1004 if ( err == KErrNone ) |
|
1005 { |
|
1006 DLTRACE(("Check the application is actually installed")); |
|
1007 TBool installed = EFalse; |
|
1008 TRAP( err, installed = IsApplicationInstalledL( iAppUid ) ); |
|
1009 if ( err == KErrNone ) |
|
1010 { |
|
1011 if ( !installed ) |
|
1012 { |
|
1013 err = KErrGeneral; |
|
1014 } |
|
1015 else |
|
1016 { |
|
1017 TCatalogsVersion version; |
|
1018 err = ApplicationVersion( iAppUid, version ); |
|
1019 if ( err == KErrNone ) |
|
1020 { |
|
1021 DLTRACE(("Converting version to string")); |
|
1022 // Put application version as the filename |
|
1023 HBufC* versionString = |
|
1024 TCatalogsVersion::ConvertLC( version ); |
|
1025 // Notify about application installation |
|
1026 iObserver->InstallationCompleteL( |
|
1027 *versionString, |
|
1028 iAppUid, |
|
1029 err ); |
|
1030 CleanupStack::PopAndDestroy( versionString ); |
|
1031 return; |
|
1032 } |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 } |
|
1037 |
|
1038 // Notify about application installation |
|
1039 iObserver->InstallationCompleteL( KNullDesC, iAppUid, err ); |
|
1040 } |
|
1041 } |
|
1042 else |
|
1043 { |
|
1044 DLTRACE(("Was not Java nor SIS install")); |
|
1045 // This is executed after a content file has been moved. |
|
1046 // We don't set the exit observer as NULL since it panics in debug builds |
|
1047 } |
|
1048 DLTRACEOUT(("")); |
|
1049 } |
|
1050 |
|
1051 |
|
1052 // --------------------------------------------------------------------------- |
|
1053 // This function is called after application installer has finished. |
|
1054 // --------------------------------------------------------------------------- |
|
1055 // |
|
1056 void CNcdInstallationService::HandleServerAppExit( TInt aReason ) |
|
1057 { |
|
1058 DLTRACEIN(("aReason=%d",aReason)); |
|
1059 |
|
1060 InstallationFinishedSetup( aReason ); |
|
1061 |
|
1062 // If observer exists, notify it. |
|
1063 iInstallationCompleteCallback->CallBack(); |
|
1064 } |
|
1065 |
|
1066 |
|
1067 // --------------------------------------------------------------------------- |
|
1068 // Update the list of installed themes |
|
1069 // --------------------------------------------------------------------------- |
|
1070 // |
|
1071 void CNcdInstallationService::UpdateInstalledThemesL() |
|
1072 { |
|
1073 DLTRACEIN(("")); |
|
1074 if ( iThemes ) |
|
1075 { |
|
1076 DLTRACE(("Delete old list")); |
|
1077 iThemes->ResetAndDestroy(); |
|
1078 delete iThemes; |
|
1079 iThemes = NULL; |
|
1080 } |
|
1081 |
|
1082 iThemes = iAknsSrv.EnumerateSkinPackagesL( EAknsSrvAll ); |
|
1083 |
|
1084 DLTRACEOUT(("Got new theme list")); |
|
1085 } |
|
1086 |
|
1087 |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // Get name of the theme installed after the latest UpdateInstalledThemesL() |
|
1090 // call |
|
1091 // --------------------------------------------------------------------------- |
|
1092 // |
|
1093 const TDesC& CNcdInstallationService::LatestThemeL() |
|
1094 { |
|
1095 DLTRACEIN(("")); |
|
1096 |
|
1097 if ( !iThemes ) |
|
1098 { |
|
1099 DLTRACEOUT(("Was not installing a theme")); |
|
1100 return KNullDesC(); |
|
1101 } |
|
1102 |
|
1103 CArrayPtr<CAknsSrvSkinInformationPkg>* newThemes = |
|
1104 iAknsSrv.EnumerateSkinPackagesL( EAknsSrvAll ); |
|
1105 |
|
1106 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
1107 DLTRACE(("Installed old themes, count: %d", iThemes->Count() )); |
|
1108 for ( TInt i = 0; i < iThemes->Count(); ++i ) |
|
1109 { |
|
1110 DLINFO(( _L("%S"), &iThemes->At( i )->Name() )); |
|
1111 } |
|
1112 |
|
1113 DLTRACE(("Installed new themes, count: %d", newThemes->Count() )); |
|
1114 for ( TInt i = 0; i < newThemes->Count(); ++i ) |
|
1115 { |
|
1116 DLINFO(( _L("%S"), &newThemes->At( i )->Name() )); |
|
1117 } |
|
1118 #endif |
|
1119 |
|
1120 // Empty previous information |
|
1121 delete iThemeName; |
|
1122 iThemeName = NULL; |
|
1123 iPID.Set( TUid::Uid( 0 ) ); |
|
1124 |
|
1125 // Check if new theme has been installed after last |
|
1126 // call to the GetInstalledSkinPackagesL() |
|
1127 if ( newThemes->Count() > iThemes->Count() ) |
|
1128 { |
|
1129 DLTRACE(("New themes installed, count: %d", |
|
1130 newThemes->Count() - iThemes->Count() )); |
|
1131 |
|
1132 // New theme has been installed |
|
1133 for ( TInt i = 0; i < newThemes->Count(); i++ ) |
|
1134 { |
|
1135 TInt j = 0; |
|
1136 |
|
1137 for ( ; j < iThemes->Count(); j++ ) |
|
1138 { |
|
1139 if ( newThemes->At( i )->PID() == iThemes->At( j )->PID() ) |
|
1140 { |
|
1141 // PID found from old theme list. This is not the |
|
1142 // new theme. |
|
1143 break; |
|
1144 } |
|
1145 } |
|
1146 |
|
1147 if ( j == iThemes->Count() ) |
|
1148 { |
|
1149 DLTRACE(("Found new theme")); |
|
1150 // PID was not found from old theme list. This is the |
|
1151 // new theme. |
|
1152 iPID = newThemes->At( i )->PID(); |
|
1153 TRAPD( err, iThemeName = newThemes->At( i )->Name().AllocL() ); |
|
1154 if ( err != KErrNone ) |
|
1155 { |
|
1156 newThemes->ResetAndDestroy(); |
|
1157 delete newThemes; |
|
1158 User::Leave( err ); |
|
1159 } |
|
1160 break; |
|
1161 } |
|
1162 } |
|
1163 } |
|
1164 |
|
1165 newThemes->ResetAndDestroy(); |
|
1166 delete newThemes; |
|
1167 if ( iThemeName ) |
|
1168 { |
|
1169 DLTRACEOUT(( _L("Theme: %S"), iThemeName )); |
|
1170 return *iThemeName; |
|
1171 } |
|
1172 DLTRACEOUT(("No theme")); |
|
1173 return KNullDesC(); |
|
1174 } |
|
1175 |
|
1176 |
|
1177 // --------------------------------------------------------------------------- |
|
1178 // Try to recognize the data from the file |
|
1179 // --------------------------------------------------------------------------- |
|
1180 // |
|
1181 HBufC* CNcdInstallationService::RecognizeDataL( const TDesC& aFileName ) |
|
1182 { |
|
1183 DLTRACEIN(( _L("Filename: %S"), &aFileName )); |
|
1184 |
|
1185 if ( aFileName.Length() == 0 ) |
|
1186 { |
|
1187 DLTRACEOUT(("Empty filename")); |
|
1188 return KNullDesC().AllocL(); |
|
1189 } |
|
1190 |
|
1191 ConnectApaLsL(); |
|
1192 |
|
1193 TInt recognizeBufferLength = 0; |
|
1194 User::LeaveIfError( iApaLs.GetPreferredBufSize( recognizeBufferLength ) ); |
|
1195 HBufC8* buffer = HBufC8::NewLC( recognizeBufferLength ); |
|
1196 TPtr8 ptr8( buffer->Des() ); |
|
1197 |
|
1198 TDataRecognitionResult result; |
|
1199 // Read necessary amount of bytes from the file |
|
1200 User::LeaveIfError( iFs.ReadFileSection( |
|
1201 aFileName, 0, ptr8, recognizeBufferLength ) ); |
|
1202 |
|
1203 |
|
1204 // Try to recognize data |
|
1205 User::LeaveIfError( iApaLs.RecognizeData( |
|
1206 aFileName, *buffer, result ) ); |
|
1207 |
|
1208 HBufC* resultMime = Des8ToDes16L( result.iDataType.Des8() ); |
|
1209 CleanupStack::PopAndDestroy( buffer ); |
|
1210 iApaLs.Close(); |
|
1211 DLTRACEOUT(( _L("Determined MIME: %S"), resultMime )); |
|
1212 return resultMime; |
|
1213 } |
|
1214 |
|
1215 // --------------------------------------------------------------------------- |
|
1216 // Try to recognize the data from the file |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // |
|
1219 HBufC* CNcdInstallationService::RecognizeDataL( RFile& aFile ) |
|
1220 { |
|
1221 DLTRACEIN(("")); |
|
1222 ConnectApaLsL(); |
|
1223 |
|
1224 TDataRecognitionResult result; |
|
1225 |
|
1226 // Try to recognize data |
|
1227 User::LeaveIfError( iApaLs.RecognizeData( |
|
1228 aFile, result ) ); |
|
1229 |
|
1230 HBufC* resultMime = Des8ToDes16L( result.iDataType.Des8() ); |
|
1231 |
|
1232 iApaLs.Close(); |
|
1233 DLTRACEOUT(( _L("Determined MIME: %S"), resultMime )); |
|
1234 return resultMime; |
|
1235 } |
|
1236 |
|
1237 |
|
1238 void CNcdInstallationService::ConnectApaLsL() |
|
1239 { |
|
1240 DLTRACEIN(("")); |
|
1241 User::LeaveIfError( iApaLs.Connect() ); |
|
1242 DLTRACEOUT(("Connected successfully")); |
|
1243 } |
|
1244 |
|
1245 |
|
1246 // --------------------------------------------------------------------------- |
|
1247 // Installs all kinds of files in normal or in silent way. |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // |
|
1250 void CNcdInstallationService::InstallL( RFile& aFile, |
|
1251 const TDesC& aMimeType, |
|
1252 const TNcdItemPurpose& aPurpose, |
|
1253 const SwiUI::TInstallOptionsPckg* aSilentInstallOptionsPckg ) |
|
1254 { |
|
1255 DLTRACEIN(( _L("iBusy=%d, MIME: %S"),iBusy, &aMimeType )); |
|
1256 DASSERT( iObserver ); |
|
1257 DASSERT( iDocHandler ); |
|
1258 |
|
1259 |
|
1260 // Check if some installation is already in progress. |
|
1261 if ( iBusy ) |
|
1262 { |
|
1263 DLERROR(("busy")); |
|
1264 User::Leave( KErrInUse ); |
|
1265 } |
|
1266 |
|
1267 // Reset app uid info |
|
1268 iAppUid.iUid = 0; |
|
1269 iPackageUid.iUid = 0; |
|
1270 iThemePackageUid.iUid = KNcdThemeSisUid; |
|
1271 |
|
1272 iPurpose = aPurpose; |
|
1273 |
|
1274 iInstallError = KErrNone; |
|
1275 |
|
1276 delete iRecognizedMime; |
|
1277 iRecognizedMime = NULL; |
|
1278 |
|
1279 // Try to recognize the data if no mime given or it's DRM content |
|
1280 // in which case we don't know the type of the actual content |
|
1281 |
|
1282 DLTRACE(("Recognizing mime type of the content")); |
|
1283 TRAPD( err, iRecognizedMime = RecognizeDataL( aFile ) ); |
|
1284 if ( err != KErrNone ) |
|
1285 { |
|
1286 DLERROR(("Couldn't recognize the mime type, error: %d", err)); |
|
1287 iRecognizedMime = KNullDesC().AllocL(); |
|
1288 } |
|
1289 |
|
1290 // Fail-safe in case someone tries to install a Java application |
|
1291 // with this method |
|
1292 if ( MatchJava( *iRecognizedMime ) ) |
|
1293 { |
|
1294 DLTRACE(("Java")); |
|
1295 InstallJavaL( |
|
1296 aFile, |
|
1297 *iRecognizedMime, |
|
1298 KNullDesC8, |
|
1299 aSilentInstallOptionsPckg ); |
|
1300 return; |
|
1301 } |
|
1302 else if ( MatchWidget( aFile, aMimeType ) ) |
|
1303 { |
|
1304 DLTRACE(("Widget")); |
|
1305 InstallWidgetL( |
|
1306 aFile, |
|
1307 aSilentInstallOptionsPckg ); |
|
1308 return; |
|
1309 } |
|
1310 |
|
1311 // Handle SIS(X) and DRM content which has a suitable purpose |
|
1312 if ( aMimeType.MatchF( KMimeTypeMatchSymbianInstall ) != KErrNotFound |
|
1313 || aMimeType.MatchF( KMimeTypeMatchSisx ) != KErrNotFound |
|
1314 || aMimeType.MatchF( KMimeTypeMatchApplicationStream ) != KErrNotFound |
|
1315 || iRecognizedMime->MatchF( KMimeTypeMatchSymbianInstall ) != KErrNotFound |
|
1316 || iRecognizedMime->MatchF( KMimeTypeMatchSisx ) != KErrNotFound |
|
1317 || iRecognizedMime->MatchF( KMimeTypeMatchApplicationStream ) != KErrNotFound ) |
|
1318 { |
|
1319 DLINFO(("Installing SIS")); |
|
1320 iInstallType = ESisInstall; |
|
1321 // Get package UID |
|
1322 |
|
1323 // PackageUidFromSisL( RFile& ) closes the filehandle so we need to make |
|
1324 // a duplicate |
|
1325 RFile fileCopy; |
|
1326 User::LeaveIfError( fileCopy.Duplicate( aFile ) ); |
|
1327 CleanupClosePushL( fileCopy ); |
|
1328 iPackageUid = PackageUidFromSisL( fileCopy ); |
|
1329 CleanupStack::PopAndDestroy( &fileCopy ); |
|
1330 |
|
1331 // Check if the file is a theme sis |
|
1332 if ( aPurpose == ENcdItemPurposeTheme || |
|
1333 iPackageUid.iUid == KNcdThemeSisUid ) |
|
1334 { |
|
1335 DLINFO(("This seems to be a theme")); |
|
1336 iThemePackageUid = iPackageUid; |
|
1337 // Ensure that package uid is a theme UID |
|
1338 iPackageUid.iUid = KNcdThemeSisUid; |
|
1339 } |
|
1340 |
|
1341 // Update the theme list in case it actually is a theme but purpose is wrong |
|
1342 // and the package doesn't have the theme uid |
|
1343 UpdateInstalledThemesL(); |
|
1344 |
|
1345 TDataType dataType; |
|
1346 // Start application installation. |
|
1347 DLINFO(( "Calling doc handler Open" )); |
|
1348 |
|
1349 if ( !aSilentInstallOptionsPckg ) |
|
1350 { |
|
1351 DLINFO(("Normal install")); |
|
1352 InitializeInstallerL(); |
|
1353 iCancelCode = SwiUI::ERequestInstallHandle; |
|
1354 |
|
1355 iInstaller.Install( iInstallStatusObserver->iStatus, aFile ); |
|
1356 iInstallStatusObserver->StartToObserve(); |
|
1357 } |
|
1358 else |
|
1359 { |
|
1360 DLINFO(("Silent install")); |
|
1361 // Set the observer active because it will be informed about the completion |
|
1362 // of the silent install and it will forward the information for the callback |
|
1363 // function of this class object. |
|
1364 iSilentInstallActiveObserver->StartToObserveL( aFile, |
|
1365 *aSilentInstallOptionsPckg ); |
|
1366 } |
|
1367 |
|
1368 iBusy = ETrue; |
|
1369 |
|
1370 } |
|
1371 else // Handle images etc. and DRM content that didn't have a matching purpose |
|
1372 { |
|
1373 DLINFO(("Installing content")); |
|
1374 // File is some common format. |
|
1375 iInstallType = EFileInstall; |
|
1376 TDataType dataType; |
|
1377 |
|
1378 if ( aMimeType != KNullDesC ) |
|
1379 { |
|
1380 // If mime type is given, it will be used in document handler. |
|
1381 HBufC8* tempBuf = Des16ToDes8LC( aMimeType ); |
|
1382 dataType = TDataType( *tempBuf ); |
|
1383 CleanupStack::PopAndDestroy( tempBuf ); |
|
1384 DLINFO(("DataType: %S", &dataType.Des8() )); |
|
1385 } |
|
1386 |
|
1387 TInt docHandlerError( KErrNone ); |
|
1388 |
|
1389 DLINFO(("Normal install")); |
|
1390 // Have to use CopyL since MoveL works only with filepaths |
|
1391 // We can't use SilentMoveL either |
|
1392 docHandlerError = |
|
1393 iDocHandler->CopyL( aFile, |
|
1394 KNullDesC(), |
|
1395 dataType, |
|
1396 KEntryAttNormal ); |
|
1397 |
|
1398 DLTRACE(("After move")); |
|
1399 if( docHandlerError != KErrNone ) |
|
1400 { |
|
1401 DLINFO(("error=%d",docHandlerError)); |
|
1402 |
|
1403 // Use KErrAbort for user cancellation |
|
1404 if ( docHandlerError == KUserCancel ) |
|
1405 { |
|
1406 docHandlerError = KErrAbort; |
|
1407 } |
|
1408 iObserver->InstallationCompleteL( KNullDesC, KNullUid, docHandlerError ); |
|
1409 } |
|
1410 else |
|
1411 { |
|
1412 DLTRACE(("Installation successful")); |
|
1413 |
|
1414 RBuf installFileName; |
|
1415 CleanupClosePushL( installFileName ); |
|
1416 |
|
1417 installFileName.CreateL( KMaxPath ); |
|
1418 |
|
1419 User::LeaveIfError( iDocHandler->GetPath( installFileName ) ); |
|
1420 iObserver->InstallationCompleteL( installFileName, KNullUid, KErrNone ); |
|
1421 CleanupStack::PopAndDestroy( &installFileName ); |
|
1422 |
|
1423 } |
|
1424 } |
|
1425 DLTRACEOUT(("")); |
|
1426 } |
|
1427 |
|
1428 |
|
1429 // --------------------------------------------------------------------------- |
|
1430 // Installs java files in normal or in silent way. |
|
1431 // --------------------------------------------------------------------------- |
|
1432 // |
|
1433 void CNcdInstallationService::InstallJavaL( RFile& aFile, |
|
1434 const TDesC& /*aMimeType*/, |
|
1435 const TDesC8& aDescriptorData, |
|
1436 const SwiUI::TInstallOptionsPckg* aSilentInstallOptionsPckg ) |
|
1437 { |
|
1438 DLTRACEIN((_L("iBusy=%d, descriptor=%d"),iBusy, aDescriptorData.Length() )); |
|
1439 DASSERT( iObserver ); |
|
1440 |
|
1441 // Check if some installation is already in progress. |
|
1442 if ( iBusy ) |
|
1443 { |
|
1444 DLERROR(("busy")); |
|
1445 User::Leave( KErrInUse ); |
|
1446 } |
|
1447 |
|
1448 iInstallError = KErrNone; |
|
1449 |
|
1450 #ifdef USE_OLD_JAVA_API |
|
1451 // Store installed java app uids before installation to see |
|
1452 // which one is a new java app later. |
|
1453 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
|
1454 CleanupReleasePushL( *javaRegistry ); |
|
1455 iMIDletUids.Reset(); |
|
1456 javaRegistry->InstalledMIDletUidsL( iMIDletUids ); |
|
1457 CleanupStack::PopAndDestroy( javaRegistry ); |
|
1458 #endif |
|
1459 |
|
1460 // In platform security systems JAR and JAD has to be in same folder |
|
1461 // to get the installation process work correctly. |
|
1462 // First form the JAD filename from the JAR filename. |
|
1463 |
|
1464 delete iJadFileName; |
|
1465 iJadFileName = 0; |
|
1466 |
|
1467 if( aDescriptorData != KNullDesC8 ) |
|
1468 { |
|
1469 DLINFO(("Writing JAD")); |
|
1470 TPath fileName; |
|
1471 User::LeaveIfError( aFile.FullName( fileName ) ); |
|
1472 |
|
1473 iJadFileName = WriteJadL( fileName, aDescriptorData ); |
|
1474 } |
|
1475 |
|
1476 |
|
1477 iInstallType = EJavaInstall; |
|
1478 TDataType dataType; |
|
1479 |
|
1480 if ( aSilentInstallOptionsPckg == NULL ) |
|
1481 { |
|
1482 DLINFO(("Normal install")); |
|
1483 InitializeInstallerL(); |
|
1484 if( iJadFileName ) |
|
1485 { |
|
1486 DLTRACE(("Installing JAD+JAR")); |
|
1487 // JAD+JAR install |
|
1488 iCancelCode = SwiUI::ERequestInstall; |
|
1489 iInstaller.Install( iInstallStatusObserver->iStatus, *iJadFileName ); |
|
1490 } |
|
1491 else |
|
1492 { |
|
1493 DLTRACE(("Installing JAR")); |
|
1494 // JAR install |
|
1495 iCancelCode = SwiUI::ERequestInstallHandle; |
|
1496 iInstaller.Install( iInstallStatusObserver->iStatus, aFile ); |
|
1497 } |
|
1498 |
|
1499 iInstallStatusObserver->StartToObserve(); |
|
1500 } |
|
1501 else |
|
1502 { |
|
1503 DLINFO(("Silent install")); |
|
1504 if( iJadFileName ) |
|
1505 { |
|
1506 DLINFO(("Silent jad and jar")); |
|
1507 // JAD+JAR install |
|
1508 // Set the observer active because it will be informed about the completion |
|
1509 // of the silent install and it will forward the information for the callback |
|
1510 // function of this class object. |
|
1511 iSilentInstallActiveObserver->StartToObserveL( *iJadFileName, |
|
1512 *aSilentInstallOptionsPckg ); |
|
1513 } |
|
1514 else |
|
1515 { |
|
1516 DLINFO(("Silent jar")); |
|
1517 // JAR install |
|
1518 // Set the observer active because it will be informed about the completion |
|
1519 // of the silent install and it will forward the information for the callback |
|
1520 // function of this class object. |
|
1521 iSilentInstallActiveObserver->StartToObserveL( aFile, |
|
1522 *aSilentInstallOptionsPckg ); |
|
1523 } |
|
1524 } |
|
1525 |
|
1526 iBusy = ETrue; |
|
1527 |
|
1528 DLTRACEOUT(("")); |
|
1529 } |
|
1530 |
|
1531 |
|
1532 // --------------------------------------------------------------------------- |
|
1533 // Installs Widgets files in normal or in silent way. |
|
1534 // --------------------------------------------------------------------------- |
|
1535 // |
|
1536 void CNcdInstallationService::InstallWidgetL( |
|
1537 RFile& aFile, |
|
1538 const SwiUI::TInstallOptionsPckg* aSilentInstallOptionsPckg ) |
|
1539 { |
|
1540 DLTRACEIN(("")); |
|
1541 |
|
1542 iInstallType = EWidgetInstall; |
|
1543 |
|
1544 // Get the list of installed widget uids so that we can |
|
1545 // get the uid of the new widget after installation |
|
1546 PopulateInstalledWidgetUidsL(); |
|
1547 |
|
1548 TDataType dataType; |
|
1549 // Start application installation. |
|
1550 DLINFO(( "Calling doc handler Open" )); |
|
1551 |
|
1552 if ( !aSilentInstallOptionsPckg ) |
|
1553 { |
|
1554 DLINFO(("Normal install")); |
|
1555 InitializeInstallerL(); |
|
1556 iCancelCode = SwiUI::ERequestInstallHandle; |
|
1557 |
|
1558 iInstaller.Install( iInstallStatusObserver->iStatus, aFile ); |
|
1559 iInstallStatusObserver->StartToObserve(); |
|
1560 } |
|
1561 else |
|
1562 { |
|
1563 DLINFO(("Silent install")); |
|
1564 // Set the observer active because it will be informed about the completion |
|
1565 // of the silent install and it will forward the information for the callback |
|
1566 // function of this class object. |
|
1567 iSilentInstallActiveObserver->StartToObserveL( aFile, |
|
1568 *aSilentInstallOptionsPckg ); |
|
1569 } |
|
1570 |
|
1571 iBusy = ETrue; |
|
1572 |
|
1573 } |
|
1574 |
|
1575 // --------------------------------------------------------------------------- |
|
1576 // Initializes installer |
|
1577 // --------------------------------------------------------------------------- |
|
1578 // |
|
1579 void CNcdInstallationService::InitializeInstallerL() |
|
1580 { |
|
1581 DLTRACEIN(("")); |
|
1582 DeletePtr( iInstallStatusObserver ); |
|
1583 iInstallStatusObserver = CNcdActiveOperationObserver::NewL( *this ); |
|
1584 |
|
1585 if ( !iInstaller.Handle() ) |
|
1586 { |
|
1587 User::LeaveIfError( iInstaller.Connect() ); |
|
1588 } |
|
1589 } |
|
1590 |
|
1591 |
|
1592 // --------------------------------------------------------------------------- |
|
1593 // Cancels installation |
|
1594 // --------------------------------------------------------------------------- |
|
1595 // |
|
1596 void CNcdInstallationService::CancelInstall() |
|
1597 { |
|
1598 DLTRACEIN(("")); |
|
1599 if ( iInstallStatusObserver && |
|
1600 iInstaller.Handle() ) |
|
1601 { |
|
1602 DLTRACE(("Cancelling installation")); |
|
1603 iInstaller.CancelAsyncRequest( iCancelCode ); |
|
1604 } |
|
1605 |
|
1606 DeletePtr( iInstallStatusObserver ); |
|
1607 iInstaller.Close(); |
|
1608 } |
|
1609 |
|
1610 |
|
1611 // --------------------------------------------------------------------------- |
|
1612 // Sets the flags after installation has been finished. |
|
1613 // --------------------------------------------------------------------------- |
|
1614 // |
|
1615 void CNcdInstallationService::InstallationFinishedSetup( TInt aReason ) |
|
1616 { |
|
1617 DLTRACEIN(("aReason=%d",aReason)); |
|
1618 |
|
1619 // Installation has finished. |
|
1620 iBusy = EFalse; |
|
1621 |
|
1622 iInstallError = aReason; |
|
1623 } |
|
1624 |
|
1625 |
|
1626 // --------------------------------------------------------------------------- |
|
1627 // Handles the situation when installation was finished even if cancel request |
|
1628 // was issued for silent install operation |
|
1629 // --------------------------------------------------------------------------- |
|
1630 // |
|
1631 void CNcdInstallationService::HandleSilentInstallSuccessAfterCancelL( HBufC*& aFileName, |
|
1632 TUid& aAppUid, |
|
1633 TInt& aError ) |
|
1634 { |
|
1635 DLTRACEIN(("")); |
|
1636 |
|
1637 // Set the error to KErrNone. |
|
1638 // So, initially we think that installation was success. |
|
1639 // If we later notice that installation was not finished, |
|
1640 // then we suppose that cancellation was success and set the |
|
1641 // value to KErrCancel |
|
1642 aError = KErrNone; |
|
1643 |
|
1644 if ( iInstallType == EJavaInstall ) |
|
1645 { |
|
1646 // Set the midlet UID for the aAppUid variable. |
|
1647 aAppUid = InstalledMidletUidL(); |
|
1648 |
|
1649 if ( aAppUid == KNullUid ) |
|
1650 { |
|
1651 DLINFO(("Installed midlet was not found")); |
|
1652 // Because the new midlet was not found, we can suppose that the |
|
1653 // application was not installed. So, set the error as KErrCancel. |
|
1654 aError = KErrCancel; |
|
1655 } |
|
1656 } |
|
1657 else if ( iInstallType == ESisInstall ) |
|
1658 { |
|
1659 // Get theme name if such was installed |
|
1660 const TDesC& name( LatestThemeL() ); |
|
1661 |
|
1662 // Notify about theme installation |
|
1663 if ( iPackageUid.iUid == KNcdThemeSisUid || name != KNullDesC ) |
|
1664 { |
|
1665 DLINFO(( _L("Theme installation, theme: %S"), &name )); |
|
1666 // Ensure that uid is theme uid |
|
1667 iPackageUid.iUid = KNcdThemeSisUid; |
|
1668 |
|
1669 // Set the uid value for the reference parameter |
|
1670 aAppUid = iPackageUid; |
|
1671 |
|
1672 if ( name == KNullDesC && iThemePackageUid.iUid != KNcdThemeSisUid ) |
|
1673 { |
|
1674 DLINFO(("Checking theme installation status with package uid, %x", |
|
1675 iThemePackageUid.iUid )); |
|
1676 |
|
1677 // Check if the theme was indeed successfully installed |
|
1678 TBool themeInstalled( EFalse ); |
|
1679 TRAP_IGNORE( |
|
1680 themeInstalled = IsApplicationInstalledL( iThemePackageUid ) ); |
|
1681 |
|
1682 if ( !themeInstalled ) |
|
1683 { |
|
1684 DLINFO(("Theme was not installed")); |
|
1685 // Theme was not installed. So, let us suppose that cancel |
|
1686 // was success after all |
|
1687 aError = KErrCancel; |
|
1688 // Because name is KNullDesC, do not set the aFileName here |
|
1689 } |
|
1690 } |
|
1691 else |
|
1692 { |
|
1693 DLTRACE(("Either theme name was acquired or package uid was theme")); |
|
1694 if ( name != KNullDesC ) |
|
1695 { |
|
1696 aFileName = name.AllocL(); |
|
1697 } |
|
1698 aAppUid = iPackageUid; |
|
1699 } |
|
1700 } |
|
1701 else |
|
1702 { |
|
1703 // Get the actual app UID from sis registry |
|
1704 TRAPD( err, aAppUid = SidFromSisRegistryL( iPackageUid ) ); |
|
1705 |
|
1706 DLTRACE(("Notify observer about application installation, uid: %x", |
|
1707 aAppUid.iUid )); |
|
1708 |
|
1709 if ( err == KErrNotFound ) |
|
1710 { |
|
1711 DLINFO(("Didn't get SID, using package UID: %x", |
|
1712 iPackageUid.iUid)); |
|
1713 aAppUid.iUid = iPackageUid.iUid; |
|
1714 err = KErrNone; |
|
1715 } |
|
1716 |
|
1717 if ( err == KErrNone ) |
|
1718 { |
|
1719 DLTRACE(("Check the application is actually installed")); |
|
1720 TBool installed = IsApplicationInstalledL( aAppUid ); |
|
1721 if ( !installed ) |
|
1722 { |
|
1723 aError = KErrCancel; |
|
1724 } |
|
1725 } |
|
1726 } |
|
1727 } |
|
1728 else |
|
1729 { |
|
1730 DLTRACE(("Was not Java nor SIS install")); |
|
1731 // This is executed after a content file has been moved. |
|
1732 } |
|
1733 |
|
1734 DLTRACEOUT(("")); |
|
1735 } |
|
1736 |
|
1737 |
|
1738 // --------------------------------------------------------------------------- |
|
1739 // Creates a list of applications that are in ROM but that are not |
|
1740 // in the SIS or Java registry |
|
1741 // --------------------------------------------------------------------------- |
|
1742 // |
|
1743 void CNcdInstallationService::InitializeRomApplicationListL() |
|
1744 { |
|
1745 DLTRACEIN(("")); |
|
1746 |
|
1747 TApaAppInfo info; |
|
1748 ConnectApaLsL(); |
|
1749 User::LeaveIfError( iApaLs.GetAllApps() ); |
|
1750 |
|
1751 iRomUids.Reset(); |
|
1752 |
|
1753 RArray<TUid> midletUids; |
|
1754 CleanupClosePushL( midletUids ); |
|
1755 |
|
1756 MidletUidsL( midletUids ); |
|
1757 |
|
1758 DLTRACE(("%d Midlet UIDs", midletUids.Count() )); |
|
1759 |
|
1760 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
1761 TInt appCount = 0; |
|
1762 iApaLs.AppCount( appCount ); |
|
1763 DLTRACE(("apps: %d", appCount)); |
|
1764 #endif // CATALOGS_BUILD_CONFIG_DEBUG |
|
1765 |
|
1766 // If the application list is not OK after 5 tries, give up |
|
1767 // Each break is 0.5 seconds |
|
1768 TInt retryCount = 5; |
|
1769 TInt appErr = KErrNone; |
|
1770 |
|
1771 do |
|
1772 { |
|
1773 appErr = iApaLs.GetNextApp( info ); |
|
1774 if ( appErr == KErrNone ) |
|
1775 { |
|
1776 // App is considered a ROM app if its not found either |
|
1777 // in SIS registry or midlet registry |
|
1778 // Note: ROM apps can be in SIS registry also but that doesn't |
|
1779 // matter because we just want to get a list of apps that are |
|
1780 // not found anywhere else but apparc |
|
1781 if ( midletUids.Find( info.iUid ) == KErrNotFound && |
|
1782 !iRegistrySession.IsSidPresentL( info.iUid ) ) |
|
1783 { |
|
1784 |
|
1785 DLTRACE(( _L("Found ROM app: %x, caption: %S, path: %S"), |
|
1786 info.iUid.iUid, |
|
1787 &info.iCaption, |
|
1788 &info.iFullName )); |
|
1789 iRomUids.AppendL( info.iUid ); |
|
1790 } |
|
1791 } |
|
1792 else if( appErr == RApaLsSession::EAppListInvalid ) |
|
1793 { |
|
1794 // Application list is not yet fully populated |
|
1795 // https://jira.bothi.fi/jira/browse/PRECLI-1364 |
|
1796 if ( retryCount > 0 ) |
|
1797 { |
|
1798 DLINFO(( "Application list not yet populated, waiting" )); |
|
1799 User::After( KDelayWhenAppListInvalid ); |
|
1800 retryCount--; |
|
1801 appErr = KErrNone; |
|
1802 } |
|
1803 else |
|
1804 { |
|
1805 User::Leave( KErrNotReady ); |
|
1806 } |
|
1807 } |
|
1808 // Some unknown error. That shouldn't happen. |
|
1809 else if( appErr != RApaLsSession::ENoMoreAppsInList ) |
|
1810 { |
|
1811 DLERROR(("Unknown error with application list. %d", appErr)); |
|
1812 User::Leave( KErrGeneral ); |
|
1813 } |
|
1814 } |
|
1815 while( appErr == KErrNone && retryCount >= 0 ); |
|
1816 |
|
1817 iApaLs.Close(); |
|
1818 CleanupStack::PopAndDestroy( &midletUids ); |
|
1819 |
|
1820 DLTRACEOUT(("ROM apps: %d", iRomUids.Count() )); |
|
1821 } |
|
1822 |
|
1823 |
|
1824 // --------------------------------------------------------------------------- |
|
1825 // Gets a list of installed midlet UIDs |
|
1826 // --------------------------------------------------------------------------- |
|
1827 // |
|
1828 #ifdef USE_OLD_JAVA_API |
|
1829 |
|
1830 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids ) |
|
1831 { |
|
1832 DLTRACEIN(("")); |
|
1833 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
|
1834 CleanupReleasePushL( *javaRegistry ); |
|
1835 javaRegistry->InstalledMIDletUidsL( aUids ); |
|
1836 CleanupStack::PopAndDestroy( javaRegistry ); |
|
1837 } |
|
1838 |
|
1839 #else |
|
1840 |
|
1841 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids ) |
|
1842 { |
|
1843 DLTRACEIN(("")); |
|
1844 CJavaRegistry* javaRegistry = CJavaRegistry::NewLC(); |
|
1845 javaRegistry->GetRegistryEntryUidsL( aUids ); |
|
1846 CleanupStack::PopAndDestroy( javaRegistry ); |
|
1847 } |
|
1848 |
|
1849 #endif |
|
1850 |
|
1851 |
|
1852 // --------------------------------------------------------------------------- |
|
1853 // Checks if the application is in ROM |
|
1854 // --------------------------------------------------------------------------- |
|
1855 // |
|
1856 TBool CNcdInstallationService::IsRomApplication( const TUid& aUid ) const |
|
1857 { |
|
1858 DLTRACEIN(("UID: %x", aUid.iUid )); |
|
1859 return iRomUids.Find( aUid ) != KErrNotFound; |
|
1860 } |
|
1861 |
|
1862 |
|
1863 // --------------------------------------------------------------------------- |
|
1864 // Returns the UID of the latest installed midlet, NULL UID if none have |
|
1865 // been installed since the last device restart |
|
1866 // --------------------------------------------------------------------------- |
|
1867 // |
|
1868 #ifdef USE_OLD_JAVA_API |
|
1869 |
|
1870 TUid CNcdInstallationService::LatestMidletUidL( |
|
1871 MJavaRegistry& aJavaRegistry ) const |
|
1872 { |
|
1873 DLTRACEIN(("")); |
|
1874 TInt suiteUid = 0; |
|
1875 |
|
1876 // Get UID for the latest installed Midlet suite |
|
1877 // KPSUidJavaLatestInstallation = 0x10282567 |
|
1878 // Ignoring error in case the key or read policy change so that client |
|
1879 // doesn't behave strangely |
|
1880 RProperty::Get( KUidSystemCategory, |
|
1881 KPSUidJavaLatestInstallation, suiteUid ); |
|
1882 |
|
1883 DLTRACE(("JMI UID: %x", suiteUid )); |
|
1884 |
|
1885 if ( !suiteUid ) |
|
1886 { |
|
1887 return KNullUid; |
|
1888 } |
|
1889 |
|
1890 // Get entry for the installed suite |
|
1891 MJavaRegistrySuiteEntry* suite = aJavaRegistry.SuiteEntryL( |
|
1892 TUid::Uid( suiteUid ) ); |
|
1893 CleanupReleasePushL( *suite ); |
|
1894 RArray<TUid> suiteUids; |
|
1895 CleanupClosePushL( suiteUids ); |
|
1896 |
|
1897 TUid midletUid = KNullUid; |
|
1898 suite->MIDletUidsL( suiteUids ); |
|
1899 |
|
1900 // Take first midlet UID from the suite |
|
1901 if ( suiteUids.Count() ) |
|
1902 { |
|
1903 midletUid = suiteUids[0]; |
|
1904 } |
|
1905 DLTRACE(("Midlets in suite: %d", suite->NumberOfMIDletsL() )); |
|
1906 CleanupStack::PopAndDestroy( &suiteUids ); |
|
1907 DLTRACE(("InstalledAppsEntryUid: %x", midletUid.iUid )); |
|
1908 |
|
1909 CleanupStack::PopAndDestroy( suite ); |
|
1910 return midletUid; |
|
1911 } |
|
1912 |
|
1913 #else |
|
1914 |
|
1915 TUid CNcdInstallationService::LatestMidletUidL( |
|
1916 CJavaRegistry& aJavaRegistry ) const |
|
1917 { |
|
1918 DLTRACEIN(("")); |
|
1919 TInt suiteUid = 0; |
|
1920 |
|
1921 // Get UID for the latest installed Midlet suite |
|
1922 // KPSUidJavaLatestInstallation = 0x10282567 |
|
1923 // Ignoring error in case the key or read policy change so that client |
|
1924 // doesn't behave strangely |
|
1925 RProperty::Get( KUidSystemCategory, |
|
1926 KPSUidJavaLatestInstallation, suiteUid ); |
|
1927 |
|
1928 DLTRACE(("JMI UID: %x", suiteUid )); |
|
1929 |
|
1930 if ( !suiteUid ) |
|
1931 { |
|
1932 return KNullUid; |
|
1933 } |
|
1934 |
|
1935 // Get entry for the installed suite |
|
1936 CJavaRegistryEntry* suite = aJavaRegistry.RegistryEntryL( |
|
1937 TUid::Uid( suiteUid ) ); |
|
1938 |
|
1939 if ( !suite ) |
|
1940 { |
|
1941 return KNullUid; |
|
1942 } |
|
1943 |
|
1944 CleanupStack::PushL( suite ); |
|
1945 |
|
1946 DASSERT( suite->Type() < EGeneralApplication && |
|
1947 suite->Type() >= EGeneralPackage ); |
|
1948 |
|
1949 CJavaRegistryPackageEntry* entry = |
|
1950 static_cast<CJavaRegistryPackageEntry*>( suite ); |
|
1951 |
|
1952 TUid midletUid = KNullUid; |
|
1953 TInt count = entry->NumberOfEmbeddedEntries(); |
|
1954 TBool appFound = EFalse; |
|
1955 TInt index = 0; |
|
1956 |
|
1957 // Find the first application from the suite |
|
1958 while ( index < count && !appFound ) |
|
1959 { |
|
1960 CJavaRegistryEntry* app = entry->EmbeddedEntryByNumberL( index ); |
|
1961 if ( app->Type() >= EGeneralApplication ) |
|
1962 { |
|
1963 midletUid = app->Uid(); |
|
1964 appFound = ETrue; |
|
1965 DLTRACE(( "Found app: %x", midletUid.iUid )); |
|
1966 } |
|
1967 delete app; |
|
1968 ++index; |
|
1969 } |
|
1970 |
|
1971 CleanupStack::PopAndDestroy( suite ); |
|
1972 return midletUid; |
|
1973 } |
|
1974 |
|
1975 |
|
1976 #endif |
|
1977 |
|
1978 // --------------------------------------------------------------------------- |
|
1979 // Returns true if the MIME type matches a Java application or descriptor |
|
1980 // --------------------------------------------------------------------------- |
|
1981 // |
|
1982 TBool CNcdInstallationService::MatchJava( const TDesC& aMime ) |
|
1983 { |
|
1984 return ( aMime.MatchF( KMimeTypeMatch1JavaApplication ) != KErrNotFound || |
|
1985 aMime.MatchF( KMimeTypeMatch2JavaApplication ) != KErrNotFound || |
|
1986 aMime.MatchF( KMimeTypeMatchJad ) != KErrNotFound ); |
|
1987 } |
|
1988 |
|
1989 |
|
1990 #ifdef USE_OLD_JAVA_API |
|
1991 |
|
1992 TUid CNcdInstallationService::InstalledMidletUidL() |
|
1993 { |
|
1994 DLTRACEIN(("")); |
|
1995 RArray<TUid> MIDletUids; |
|
1996 CleanupClosePushL( MIDletUids ); |
|
1997 |
|
1998 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
|
1999 CleanupReleasePushL( *javaRegistry ); |
|
2000 javaRegistry->InstalledMIDletUidsL( MIDletUids ); |
|
2001 TUid MIDletUid = KNullUid; |
|
2002 // Search for new uids in Java registry. |
|
2003 for ( TInt i = 0 ; i < MIDletUids.Count() ; i++ ) |
|
2004 { |
|
2005 if ( iMIDletUids.Find( MIDletUids[i] ) == KErrNotFound ) |
|
2006 { |
|
2007 // A new uid found, this is the installed midlet's uid |
|
2008 MIDletUid = MIDletUids[i]; |
|
2009 break; |
|
2010 } |
|
2011 } |
|
2012 |
|
2013 // We didn't get any new UID so we have to check Java installer's |
|
2014 // P&S key for the installed suite UID and the get the midlet UID |
|
2015 // from that. This happens when a midlet with predefined UID, |
|
2016 // eg. WidSets, is reinstalled. Midlet UIDs are predefined with |
|
2017 // the attribute Nokia-MIDlet-UID-<n> in a JAD or JAR manifest |
|
2018 if ( MIDletUid == KNullUid ) |
|
2019 { |
|
2020 MIDletUid = LatestMidletUidL( *javaRegistry ); |
|
2021 } |
|
2022 |
|
2023 CleanupStack::PopAndDestroy( javaRegistry ); |
|
2024 CleanupStack::PopAndDestroy( &MIDletUids ); |
|
2025 |
|
2026 iMIDletUids.Reset(); |
|
2027 return MIDletUid; |
|
2028 } |
|
2029 |
|
2030 #else // USE_OLD_JAVA_API |
|
2031 |
|
2032 TUid CNcdInstallationService::InstalledMidletUidL() |
|
2033 { |
|
2034 DLTRACEIN(("")); |
|
2035 CJavaRegistry* registry = CJavaRegistry::NewLC(); |
|
2036 TUid midletUid = LatestMidletUidL( *registry ); |
|
2037 CleanupStack::PopAndDestroy( registry ); |
|
2038 return midletUid; |
|
2039 } |
|
2040 |
|
2041 #endif // USE_OLD_JAVA_API |
|
2042 |
|
2043 |
|
2044 // --------------------------------------------------------------------------- |
|
2045 // Populates the list of installed widgets |
|
2046 // --------------------------------------------------------------------------- |
|
2047 // |
|
2048 void CNcdInstallationService::PopulateInstalledWidgetUidsL() |
|
2049 { |
|
2050 DLTRACEIN(("")); |
|
2051 |
|
2052 if ( !iWidgetRegistry.Handle() ) |
|
2053 { |
|
2054 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2055 } |
|
2056 |
|
2057 iInstalledWidgets.ResetAndDestroy(); |
|
2058 User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( iInstalledWidgets ) ); |
|
2059 } |
|
2060 |
|
2061 |
|
2062 // --------------------------------------------------------------------------- |
|
2063 // Gets the name of widget that was installed last |
|
2064 // --------------------------------------------------------------------------- |
|
2065 // |
|
2066 HBufC* CNcdInstallationService::InstalledWidgetNameLC() |
|
2067 { |
|
2068 DLTRACEIN(("")); |
|
2069 |
|
2070 TUid widgetUid = InstalledWidgetUidL(); |
|
2071 |
|
2072 if ( widgetUid == KNullUid ) |
|
2073 { |
|
2074 DLERROR(("No widget uid")); |
|
2075 // No new UID was found, so we assume user canceled the installation. |
|
2076 // Installer does not give any error code in that case. |
|
2077 return NULL; |
|
2078 } |
|
2079 |
|
2080 HBufC* bundleId = HBufC::NewLC( KWidgetBundleIdLength ); |
|
2081 TPtr des( bundleId->Des() ); |
|
2082 iWidgetRegistry.GetWidgetBundleId( widgetUid, des ); |
|
2083 |
|
2084 DLTRACEOUT(( _L("Widget bundle id: %S"), bundleId )); |
|
2085 return bundleId; |
|
2086 } |
|
2087 |
|
2088 |
|
2089 // --------------------------------------------------------------------------- |
|
2090 // Gets the UID of the widget that was just installed |
|
2091 // --------------------------------------------------------------------------- |
|
2092 // |
|
2093 TUid CNcdInstallationService::InstalledWidgetUidL() |
|
2094 { |
|
2095 DLTRACEIN(("")); |
|
2096 |
|
2097 RWidgetInfoArray widgets; |
|
2098 CleanupResetAndDestroyPushL( widgets ); |
|
2099 |
|
2100 User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( widgets ) ); |
|
2101 DLINFO(("widget count: %d", widgets.Count() )); |
|
2102 |
|
2103 TUid uid( KNullUid ); |
|
2104 |
|
2105 const TInt count = widgets.Count(); |
|
2106 const TInt installedCount = iInstalledWidgets.Count(); |
|
2107 |
|
2108 // Try to find a widget that was not installed earlier. |
|
2109 for ( TInt i = 0; i < count; ++i ) |
|
2110 { |
|
2111 TBool wasInstalled = EFalse; |
|
2112 CWidgetInfo* widgetInfo = widgets[ i ]; |
|
2113 for ( TInt j = 0; j < installedCount; j++ ) |
|
2114 { |
|
2115 if ( iInstalledWidgets[ j ]->iUid == widgetInfo->iUid ) |
|
2116 { |
|
2117 wasInstalled = ETrue; |
|
2118 break; |
|
2119 } |
|
2120 } |
|
2121 |
|
2122 if ( !wasInstalled ) |
|
2123 { |
|
2124 DLTRACE(("Found installed widget")); |
|
2125 uid = widgets[ i ]->iUid; |
|
2126 break; |
|
2127 } |
|
2128 } |
|
2129 |
|
2130 CleanupStack::PopAndDestroy( &widgets ); |
|
2131 |
|
2132 DLTRACEOUT(("Installed uid: %x", uid.iUid )); |
|
2133 return uid; |
|
2134 } |
|
2135 |
|
2136 |
|
2137 // --------------------------------------------------------------------------- |
|
2138 // Checks from the MIME type and file extension and returns ETrue if |
|
2139 // either of them matches widgets |
|
2140 // --------------------------------------------------------------------------- |
|
2141 // |
|
2142 TBool CNcdInstallationService::MatchWidget( RFile& aFile, const TDesC& aMime ) |
|
2143 { |
|
2144 DLTRACEIN(("")); |
|
2145 if ( aMime.CompareF( KMimeTypeMatchWidget ) == 0 ) |
|
2146 { |
|
2147 DLTRACEOUT(( "Mime type matches" )); |
|
2148 return ETrue; |
|
2149 } |
|
2150 |
|
2151 TBool match = EFalse; |
|
2152 TFileName filename; |
|
2153 TInt err = aFile.Name( filename ); |
|
2154 if ( err == KErrNone ) |
|
2155 { |
|
2156 TParsePtrC parse( filename ); |
|
2157 match = parse.ExtPresent() && |
|
2158 ( KWidgetExtension().CompareF( parse.Ext() ) == 0 ); |
|
2159 } |
|
2160 DLTRACEOUT(( "Filename match: %d", match )); |
|
2161 return match; |
|
2162 } |
|
2163 |
|
2164 |
|
2165 // --------------------------------------------------------------------------- |
|
2166 // |
|
2167 // --------------------------------------------------------------------------- |
|
2168 // |
|
2169 void CNcdInstallationService::HandleInstalledWidgetL() |
|
2170 { |
|
2171 DLTRACEIN(("")); |
|
2172 TUid uid( KNullUid ); |
|
2173 if ( iInstallError == KErrNone ) |
|
2174 { |
|
2175 uid = InstalledWidgetUidL(); |
|
2176 if ( uid == KNullUid ) |
|
2177 { |
|
2178 iInstallError = KErrAbort; |
|
2179 } |
|
2180 } |
|
2181 |
|
2182 iObserver->InstallationCompleteL( KNullDesC, uid, iInstallError ); |
|
2183 } |
|
2184 |
|
2185 |
|
2186 // --------------------------------------------------------------------------- |
|
2187 // |
|
2188 // --------------------------------------------------------------------------- |
|
2189 // |
|
2190 TBool CNcdInstallationService::WidgetExistsL( const TUid& aUid ) |
|
2191 { |
|
2192 DLTRACEIN(("")); |
|
2193 |
|
2194 if ( !iWidgetRegistry.Handle() ) |
|
2195 { |
|
2196 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2197 } |
|
2198 |
|
2199 if ( iWidgetRegistry.IsWidget( aUid ) ) |
|
2200 { |
|
2201 TBuf<KWidgetBundleIdLength> id; |
|
2202 iWidgetRegistry.GetWidgetBundleId( aUid, id ); |
|
2203 return iWidgetRegistry.WidgetExistsL( id ); |
|
2204 } |
|
2205 return EFalse; |
|
2206 } |