diff -r d17dc5398051 -r 92f864ef0288 ncdengine/provider/deviceinteraction/src/ncdinstallationserviceimpl.cpp --- a/ncdengine/provider/deviceinteraction/src/ncdinstallationserviceimpl.cpp Fri Jun 11 13:45:18 2010 +0300 +++ b/ncdengine/provider/deviceinteraction/src/ncdinstallationserviceimpl.cpp Wed Jun 23 18:20:02 2010 +0300 @@ -32,17 +32,6 @@ #include #include -/* HLa - temporary java remove -#ifdef USE_OLD_JAVA_API - #include - #include -#else - #include - #include - - using namespace Java; -#endif -*/ #include "ncdinstallationserviceobserver.h" #include "ncdactiveoperationobserver.h" #include "ncdsilentinstallactiveobserver.h" @@ -56,23 +45,7 @@ const TUint KFileOpenFlags = EFileShareReadersOrWriters; -/* HLa - temporary java remove -#ifdef __SERIES60_31__ - - const TInt32 KPSUidJavaLatestInstallation = KUidJmiLatestInstallation; - -#else - - // Defined originally in /mw/java/inc/javauids.h - // This should become available at some point in javadomainpskeys.h - //const TInt32 KPSUidJavaLatestInstallation = 0x10282567; - #include - -#endif -*/ - -// length taken from WidgetRegistryData.h -const TInt KWidgetBundleIdLength = KWidgetRegistryVal + 1; +const TInt KWidgetBundleIdLength = KMaxFileName + 1; // ======== CALLBACK FUNCTION ======== @@ -135,12 +108,6 @@ delete iJadFileName; delete iRecognizedMime; - /* HLa - temporary java remove -#ifdef USE_OLD_JAVA_API - iMIDletUids.Close(); -#endif - iApaLs.Close(); - */ if( iThemes ) { @@ -152,17 +119,7 @@ CancelInstall(); iRomUids.Close(); - if ( iWidgetRegistry.Handle() ) - { - // decreases widget server's refcount but this cannot be called - // if Connect has not been called or we'll get a KERN-EXEC 0 - iWidgetRegistry.Disconnect(); - } - else - { - iWidgetRegistry.Close(); - } - iInstalledWidgets.ResetAndDestroy(); + iScrSession.Close(); iInstalledWidgetsInfos.ResetAndDestroy(); } @@ -187,7 +144,8 @@ User::LeaveIfError( iFs.Connect() ); User::LeaveIfError( iFs.ShareProtected() ); User::LeaveIfError( iRegistrySession.Connect() ); - User::LeaveIfError( iAknsSrv.Connect() ); + User::LeaveIfError( iAknsSrv.Connect() ); + User::LeaveIfError( iScrSession.Connect()); iInstallationCompleteCallback = new(ELeave) CAsyncCallBack( TCallBack( InstallationCompleteCallback, this ), @@ -382,11 +340,6 @@ iJadFileName = NULL; } -#ifdef USE_OLD_JAVA_API - // Clean the array. - iMIDletUids.Reset(); -#endif - // Reset information flags. InstallationFinishedSetup( aError ); } @@ -518,55 +471,53 @@ // --------------------------------------------------------------------------- // -#ifdef USE_OLD_JAVA_API - -TBool CNcdInstallationService::JavaAppExistsL( - const TUid& aUid ) - { - - /* HLa - temporary java remove - DLTRACEIN(("")); - - MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); - CleanupReleasePushL( *javaRegistry ); - - TRAPD( err, - { - // Leaves with KErrNotFound if not found - MJavaRegistryMIDletEntry* midletEntry = javaRegistry->MIDletEntryL( - aUid ); - midletEntry->Release(); - }); - - LeaveIfNotErrorL( err, KErrNotFound ); - - CleanupStack::PopAndDestroy( javaRegistry ); - return err == KErrNone; - */ - - } - -#else - TBool CNcdInstallationService::JavaAppExistsL( const TUid& aUid ) { DLTRACEIN(("")); - /* HLa - temporary java remove - CJavaRegistry* javaRegistry = CJavaRegistry::NewLC(); - - TBool exists = javaRegistry->RegistryEntryExistsL( aUid ); + TBool retVal = EFalse; + Usif::TComponentId compId = 0; + + // Get component id + TRAPD( ret, compId = iScrSession.GetComponentIdForAppL( aUid ) ); + if ( ret == KErrNotFound ) + { + return EFalse; + } + else if (ret != KErrNone ) + { + User::Leave( ret ); + } + + Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); + TRAPD(err, iScrSession.GetComponentL(compId, *entry)); - CleanupStack::PopAndDestroy( javaRegistry ); - return exists; - */ - return EFalse; + if ( err == KErrNotFound ) + { + retVal = EFalse; + } + else if (err != KErrNone ) + { + User::Leave( err ); + } + else + { + // type == Java ? + if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeJava ) == 0 ) + { + retVal = ETrue; + } + else + { + retVal = EFalse; + } + } + CleanupStack::PopAndDestroy(entry); + return retVal; } -#endif - // Check via widget registry API TNcdApplicationStatus CNcdInstallationService::IsWidgetInstalledL(const TDesC& aIdentifier, const TCatalogsVersion& aVersion) { @@ -989,9 +940,7 @@ if ( iInstallError != KErrNone ) { DLTRACE(("Notify install error")); -#ifdef USE_OLD_JAVA_API - iMIDletUids.Reset(); -#endif + iObserver->InstallationCompleteL( KNullDesC, TUid(), iInstallError ); return; } @@ -1528,17 +1477,6 @@ iInstallError = KErrNone; -#ifdef USE_OLD_JAVA_API - // Store installed java app uids before installation to see - // which one is a new java app later. - /* HLa - temporary java remove - MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); - CleanupReleasePushL( *javaRegistry ); - iMIDletUids.Reset(); - javaRegistry->InstalledMIDletUidsL( iMIDletUids ); - CleanupStack::PopAndDestroy( javaRegistry ); - */ -#endif // In platform security systems JAR and JAD has to be in same folder // to get the installation process work correctly. @@ -1922,34 +1860,39 @@ // Gets a list of installed midlet UIDs // --------------------------------------------------------------------------- // -#ifdef USE_OLD_JAVA_API void CNcdInstallationService::MidletUidsL( RArray& aUids ) { - /* HLa - temporary java remove - DLTRACEIN(("")); - MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); - CleanupReleasePushL( *javaRegistry ); - javaRegistry->InstalledMIDletUidsL( aUids ); - CleanupStack::PopAndDestroy( javaRegistry ); - */ - } -#else + // Get ids of all java components in scr + RArray javaComponentIdList; + CleanupClosePushL( javaComponentIdList ); + + Usif::CComponentFilter *pJavaSwTypeFilter = Usif::CComponentFilter::NewLC(); + pJavaSwTypeFilter->SetSoftwareTypeL( Usif::KSoftwareTypeJava ); + iScrSession.GetComponentIdsL( javaComponentIdList, pJavaSwTypeFilter ); + CleanupStack::PopAndDestroy( pJavaSwTypeFilter ); -void CNcdInstallationService::MidletUidsL( RArray& aUids ) - { - /* HLa - temporary java remove - DLTRACEIN(("")); - CJavaRegistry* javaRegistry = CJavaRegistry::NewLC(); - javaRegistry->GetRegistryEntryUidsL( aUids ); - CleanupStack::PopAndDestroy( javaRegistry ); - */ + + // Get components + TInt aUidIndex = 0; + for ( TInt i = 0; i < javaComponentIdList.Count(); ++i ) + { + RArray midletUids; + CleanupClosePushL( midletUids ); + iScrSession.GetAppUidsForComponentL( javaComponentIdList[i], midletUids ); + for ( TInt j = 0; j < midletUids.Count(); ++j ) + { + aUids[aUidIndex] = aUids[j]; + aUidIndex++; + } + CleanupStack::PopAndDestroy(); // midletUids + } + + CleanupStack::PopAndDestroy(); // javaComponentIdList + } -#endif - - // --------------------------------------------------------------------------- // Checks if the application is in ROM // --------------------------------------------------------------------------- @@ -1960,125 +1903,6 @@ return iRomUids.Find( aUid ) != KErrNotFound; } - -// --------------------------------------------------------------------------- -// Returns the UID of the latest installed midlet, NULL UID if none have -// been installed since the last device restart -// --------------------------------------------------------------------------- -// - -/* HLa - temporary java remove -#ifdef USE_OLD_JAVA_API - -TUid CNcdInstallationService::LatestMidletUidL( - MJavaRegistry& aJavaRegistry ) const - { - DLTRACEIN(("")); - TInt suiteUid = 0; - - // Get UID for the latest installed Midlet suite - // KPSUidJavaLatestInstallation = 0x10282567 - // Ignoring error in case the key or read policy change so that client - // doesn't behave strangely - RProperty::Get( KUidSystemCategory, - KPSUidJavaLatestInstallation, suiteUid ); - - DLTRACE(("JMI UID: %x", suiteUid )); - - if ( !suiteUid ) - { - return KNullUid; - } - - // Get entry for the installed suite - MJavaRegistrySuiteEntry* suite = aJavaRegistry.SuiteEntryL( - TUid::Uid( suiteUid ) ); - CleanupReleasePushL( *suite ); - RArray suiteUids; - CleanupClosePushL( suiteUids ); - - TUid midletUid = KNullUid; - suite->MIDletUidsL( suiteUids ); - - // Take first midlet UID from the suite - if ( suiteUids.Count() ) - { - midletUid = suiteUids[0]; - } - DLTRACE(("Midlets in suite: %d", suite->NumberOfMIDletsL() )); - CleanupStack::PopAndDestroy( &suiteUids ); - DLTRACE(("InstalledAppsEntryUid: %x", midletUid.iUid )); - - CleanupStack::PopAndDestroy( suite ); - return midletUid; - } - -#else - -TUid CNcdInstallationService::LatestMidletUidL( - CJavaRegistry& aJavaRegistry ) const - { - DLTRACEIN(("")); - TInt suiteUid = 0; - - // Get UID for the latest installed Midlet suite - // KPSUidJavaLatestInstallation = 0x10282567 - // Ignoring error in case the key or read policy change so that client - // doesn't behave strangely - RProperty::Get( KUidSystemCategory, - KPSUidJavaLatestInstallation, suiteUid ); - - DLTRACE(("JMI UID: %x", suiteUid )); - - if ( !suiteUid ) - { - return KNullUid; - } - - // Get entry for the installed suite - CJavaRegistryEntry* suite = aJavaRegistry.RegistryEntryL( - TUid::Uid( suiteUid ) ); - - if ( !suite ) - { - return KNullUid; - } - - CleanupStack::PushL( suite ); - - DASSERT( suite->Type() < EGeneralApplication && - suite->Type() >= EGeneralPackage ); - - CJavaRegistryPackageEntry* entry = - static_cast( suite ); - - TUid midletUid = KNullUid; - TInt count = entry->NumberOfEmbeddedEntries(); - TBool appFound = EFalse; - TInt index = 0; - - // Find the first application from the suite - while ( index < count && !appFound ) - { - CJavaRegistryEntry* app = entry->EmbeddedEntryByNumberL( index ); - if ( app->Type() >= EGeneralApplication ) - { - midletUid = app->Uid(); - appFound = ETrue; - DLTRACE(( "Found app: %x", midletUid.iUid )); - } - delete app; - ++index; - } - - CleanupStack::PopAndDestroy( suite ); - return midletUid; - } - - -#endif -*/ - // --------------------------------------------------------------------------- // Returns true if the MIME type matches a Java application or descriptor // --------------------------------------------------------------------------- @@ -2091,85 +1915,35 @@ } -#ifdef USE_OLD_JAVA_API TUid CNcdInstallationService::InstalledMidletUidL() { - - /* HLa - temporary java remove - DLTRACEIN(("")); - RArray MIDletUids; - CleanupClosePushL( MIDletUids ); + + Usif::COpaqueNamedParams* iResults = 0; // to be removed - MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); - CleanupReleasePushL( *javaRegistry ); - javaRegistry->InstalledMIDletUidsL( MIDletUids ); - TUid MIDletUid = KNullUid; - // Search for new uids in Java registry. - for ( TInt i = 0 ; i < MIDletUids.Count() ; i++ ) + RArray appUids; + TUid midletUid = KNullUid; + TInt compId = 0; + + // Get component id + TRAPD ( err, iResults->IntByNameL( Usif::KSifOutParam_ComponentId )); + if ( err == KErrNotFound ) { - if ( iMIDletUids.Find( MIDletUids[i] ) == KErrNotFound ) - { - // A new uid found, this is the installed midlet's uid - MIDletUid = MIDletUids[i]; - break; - } - } - - // We didn't get any new UID so we have to check Java installer's - // P&S key for the installed suite UID and the get the midlet UID - // from that. This happens when a midlet with predefined UID, - // eg. WidSets, is reinstalled. Midlet UIDs are predefined with - // the attribute Nokia-MIDlet-UID- in a JAD or JAR manifest - if ( MIDletUid == KNullUid ) - { - MIDletUid = LatestMidletUidL( *javaRegistry ); + return midletUid; } - CleanupStack::PopAndDestroy( javaRegistry ); - CleanupStack::PopAndDestroy( &MIDletUids ); - - iMIDletUids.Reset(); - return MIDletUid; - */ - - } - -#else // USE_OLD_JAVA_API - -TUid CNcdInstallationService::InstalledMidletUidL() - { - /* HLa - temporary java remove - DLTRACEIN(("")); - CJavaRegistry* registry = CJavaRegistry::NewLC(); - TUid midletUid = LatestMidletUidL( *registry ); - CleanupStack::PopAndDestroy( registry ); - return midletUid; - */ + // Get components + CleanupClosePushL( appUids ); + iScrSession.GetAppUidsForComponentL( compId, appUids ); - return KNullUid; - - } - -#endif // USE_OLD_JAVA_API - - -// --------------------------------------------------------------------------- -// Populates the list of installed widgets -// --------------------------------------------------------------------------- -// -void CNcdInstallationService::PopulateInstalledWidgetUidsL() - { - DLTRACEIN(("")); - - if ( !iWidgetRegistry.Handle() ) + // return first midlet uid, if exists + if ( appUids.Count() != 0 ) { - User::LeaveIfError( iWidgetRegistry.Connect() ); + midletUid = appUids[0]; } - - iInstalledWidgets.ResetAndDestroy(); - User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( iInstalledWidgets ) ); + CleanupStack::PopAndDestroy(); // appUids + return midletUid; } // --------------------------------------------------------------------------- @@ -2181,38 +1955,44 @@ { DLTRACEIN(("")); - // Get the list of installed widget uids - PopulateInstalledWidgetUidsL(); + // Get ids of all widget components in scr + RArray widgetComponentIdList; + Usif::CComponentFilter *pWidgetSwTypeFilter = Usif::CComponentFilter::NewLC(); + pWidgetSwTypeFilter->SetSoftwareTypeL(Usif::KSoftwareTypeWidget); + + iScrSession.GetComponentIdsL(widgetComponentIdList, pWidgetSwTypeFilter); - const TInt count = iInstalledWidgets.Count(); + CleanupStack::PopAndDestroy(pWidgetSwTypeFilter); + CleanupClosePushL(widgetComponentIdList); - // Create array with UID & Version infos + const TInt count = widgetComponentIdList.Count(); + + // Create array with id & version infos for ( TInt i = 0; i < count; ++i ) { CExtendedWidgetInfo* tempInfo = new ( ELeave ) CExtendedWidgetInfo(); CleanupStack::PushL( tempInfo ); - CWidgetInfo* widgetInfo = iInstalledWidgets[i]; + // Get widget + Usif::TComponentId compId = widgetComponentIdList[i]; + Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); + iScrSession.GetComponentL(compId, *entry); - CWidgetPropertyValue* version = iWidgetRegistry.GetWidgetPropertyValueL - (widgetInfo->iUid, EBundleVersion ); - CleanupStack::PushL( version ); - - // Fill info - tempInfo->iUid = widgetInfo->iUid; - if (!version->iValue.s) - *(tempInfo->iVersion) = KDefVersion; - else - *(tempInfo->iVersion) = *(version->iValue.s); + // Fill id & version + tempInfo->iUid.iUid= compId; + *(tempInfo->iVersion) = entry->Version(); // Append to arrayt aWidgets.AppendL( tempInfo ); - - CleanupStack::PopAndDestroy( version ); + + CleanupStack::PopAndDestroy(entry); CleanupStack::Pop( tempInfo ); } + + + CleanupStack::PopAndDestroy(); // widgetComponentIdList - DLTRACEOUT(("")); + DLTRACEOUT(("")); } @@ -2220,26 +2000,13 @@ // Gets the name of widget that was installed last // --------------------------------------------------------------------------- // + HBufC* CNcdInstallationService::InstalledWidgetNameLC() { DLTRACEIN(("")); - TUid widgetUid = InstalledWidgetUidL(); - - if ( widgetUid == KNullUid ) - { - DLERROR(("No widget uid")); - // No new UID was found, so we assume user canceled the installation. - // Installer does not give any error code in that case. - return NULL; - } - - HBufC* bundleId = HBufC::NewLC( KWidgetBundleIdLength ); - TPtr des( bundleId->Des() ); - iWidgetRegistry.GetWidgetBundleId( widgetUid, des ); - - DLTRACEOUT(( _L("Widget bundle id: %S"), bundleId )); - return bundleId; + // Not currently suported + return NULL; } @@ -2349,30 +2116,48 @@ // --------------------------------------------------------------------------- -// +//Calling widget registry API to check if a widget with given uid is installed +//already // --------------------------------------------------------------------------- // TBool CNcdInstallationService::WidgetExistsL( const TUid& aUid ) { DLTRACEIN(("")); - - if ( !iWidgetRegistry.Handle() ) - { - User::LeaveIfError( iWidgetRegistry.Connect() ); - } + + TBool retVal = EFalse; + + // Get entry + Usif::TComponentId compId = aUid.iUid; + Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); + TRAPD(err, iScrSession.GetComponentL(compId, *entry)); - if ( iWidgetRegistry.IsWidget( aUid ) ) + if ( err == KErrNotFound || !retVal ) + { + retVal = EFalse; + } + else if (err != KErrNone ) + { + User::Leave( err ); + } + else { - TBuf id; - iWidgetRegistry.GetWidgetBundleId( aUid, id ); - return iWidgetRegistry.WidgetExistsL( id ); + // widget ?? + if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeWidget ) == 0 ) + { + retVal = ETrue; + } + else + { + retVal = EFalse; + } } - return EFalse; + CleanupStack::PopAndDestroy(entry); + return retVal; } // --------------------------------------------------------------------------- //Calling widget registry API to check if a widget with given uid is installed -//already +//already. Returns the version of the installed widget. // --------------------------------------------------------------------------- // TBool CNcdInstallationService::WidgetExistsL( @@ -2380,33 +2165,40 @@ { DLTRACEIN(("")); - if ( !iWidgetRegistry.Handle() ) + TBool retVal = EFalse; + + // Get entry + Usif::TComponentId compId = aUid.iUid; + Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); + TRAPD(err, retVal= iScrSession.GetComponentL(compId, *entry)); + + if ( err == KErrNotFound || !retVal ) { - User::LeaveIfError( iWidgetRegistry.Connect() ); + retVal = EFalse; } - - if ( iWidgetRegistry.IsWidget( aUid ) ) + else if (err != KErrNone ) { - TBuf id; - iWidgetRegistry.GetWidgetBundleId( aUid, id ); - if (iWidgetRegistry.WidgetExistsL( id )) + User::Leave( err ); + } + else + { + // widget ?? + if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeWidget ) == 0 ) { + retVal = ETrue; + // Get version - CWidgetPropertyValue* version = - iWidgetRegistry.GetWidgetPropertyValueL(aUid, EBundleVersion ); - CleanupStack::PushL( version ); - TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) ); - CleanupStack::PopAndDestroy( version ); - return (ETrue); + TPtrC entryVersion = entry->Version(); + TCatalogsVersion::ConvertL( aVersion, entryVersion ); } else { - return (EFalse); + retVal = EFalse; } } - else - return(EFalse); - + CleanupStack::PopAndDestroy(entry); + return retVal; + } // --------------------------------------------------------------------------- @@ -2419,44 +2211,44 @@ { DLTRACEIN(("")); - if ( !iWidgetRegistry.Handle() ) - { - User::LeaveIfError( iWidgetRegistry.Connect() ); - } - - RPointerArray widgetInfoArr; + TBool retVal = EFalse; + Usif::TComponentId compId = 0; + + // Get widget component id by identifier + TRAPD( err, compId = + iScrSession.GetComponentIdL( aIdentifier, Usif::KSoftwareTypeWidget )); - CleanupResetAndDestroyPushL( widgetInfoArr ); - TInt err = iWidgetRegistry.InstalledWidgetsL(widgetInfoArr); - - for( TInt i( widgetInfoArr.Count() - 1 ); i >= 0; --i ) + if ( err == KErrNotFound ) + { + retVal = EFalse; + } + else if (err != KErrNone ) { - CWidgetInfo* widgetInfo( widgetInfoArr[i] ); - CWidgetPropertyValue* bundleId = - iWidgetRegistry.GetWidgetPropertyValueL - (widgetInfo->iUid, EBundleIdentifier ); - CleanupStack::PushL( bundleId ); + User::Leave( err ); + } + else + { + // Widget found + retVal = ETrue; - if( aIdentifier.Compare( *(bundleId->iValue.s) )== 0 ) + // Get entry + Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); + retVal = iScrSession.GetComponentL(compId, *entry); + + // Get version + if ( retVal ) { - CWidgetPropertyValue* version = - iWidgetRegistry.GetWidgetPropertyValueL - (widgetInfo->iUid, EBundleVersion ); - CleanupStack::PushL( version ); - TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) ); - - CleanupStack::PopAndDestroy( version ); - CleanupStack::PopAndDestroy( bundleId ); - CleanupStack::PopAndDestroy( &widgetInfoArr ); - - return ETrue; + TPtrC entryVersion = entry->Version(); + TCatalogsVersion::ConvertL( aVersion, entryVersion ); } - CleanupStack::PopAndDestroy( bundleId ); + + CleanupStack::PopAndDestroy(entry); } - CleanupStack::PopAndDestroy( &widgetInfoArr ); - return EFalse; + + return retVal; } + // --------------------------------------------------------------------------- // Calling widget registry API to return the Uid of the widget // with given identifier. @@ -2468,15 +2260,13 @@ TUid id = TUid::Uid(0); - if ( !iWidgetRegistry.Handle() ) - { - User::LeaveIfError( iWidgetRegistry.Connect() ); - } + Usif::TComponentId compId = iScrSession.GetComponentIdL(aIdentifier, Usif::KSoftwareTypeNative); - id.iUid = iWidgetRegistry.GetWidgetUidL( aIdentifier); - + id.iUid = compId; + return id; + }