1 /* |
1 /* |
2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
296 InstallJavaL( aFile, aMimeType, aDescriptorData, &aInstallOptionsPckg ); |
295 InstallJavaL( aFile, aMimeType, aDescriptorData, &aInstallOptionsPckg ); |
297 |
296 |
298 DLTRACEOUT(("")); |
297 DLTRACEOUT(("")); |
299 } |
298 } |
300 |
299 |
301 |
300 // --------------------------------------------------------------------------- |
|
301 // Installs widget silently. |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CNcdInstallationService::SilentInstallWidgetL( RFile& aFile, |
|
305 const SwiUI::TInstallOptionsPckg& aInstallOptionsPckg ) |
|
306 { |
|
307 DLTRACEIN(("")); |
|
308 |
|
309 if ( iSilentInstallActiveObserver == NULL ) |
|
310 { |
|
311 DLINFO(("Create active observer for silent install")); |
|
312 iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this ); |
|
313 } |
|
314 |
|
315 InstallWidgetL( aFile, &aInstallOptionsPckg ); |
|
316 |
|
317 DLTRACEOUT(("")); |
|
318 } |
302 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
303 // Cancell silent install. |
320 // Cancell silent install. |
304 // --------------------------------------------------------------------------- |
321 // --------------------------------------------------------------------------- |
305 // |
322 // |
306 void CNcdInstallationService::CancelSilentInstall( HBufC*& aFileName, |
323 void CNcdInstallationService::CancelSilentInstall( HBufC*& aFileName, |
531 CleanupStack::PopAndDestroy( javaRegistry ); |
548 CleanupStack::PopAndDestroy( javaRegistry ); |
532 return exists; |
549 return exists; |
533 } |
550 } |
534 |
551 |
535 #endif |
552 #endif |
536 |
553 |
|
554 // Check via widget registry API |
|
555 TNcdApplicationStatus CNcdInstallationService::IsWidgetInstalledL(const TDesC& aIdentifier, const TCatalogsVersion& aVersion) |
|
556 { |
|
557 DLTRACEIN(("")); |
|
558 |
|
559 TNcdApplicationStatus status( ENcdApplicationNotInstalled ); |
|
560 |
|
561 if ( aIdentifier.Length() == 0 ) |
|
562 { |
|
563 DLTRACEOUT(("Null identifier")); |
|
564 return status; |
|
565 } |
|
566 |
|
567 |
|
568 TCatalogsVersion installedVersion; |
|
569 |
|
570 //check widget existance and get version number if it is installed |
|
571 if ( WidgetExistsL( aIdentifier, installedVersion ) ) |
|
572 { |
|
573 status = ENcdApplicationInstalled; |
|
574 } |
|
575 |
|
576 //compare the version |
|
577 if ( status == ENcdApplicationInstalled && |
|
578 aVersion != TCatalogsVersion() ) |
|
579 { |
|
580 DLINFO(("Installed widget version: %d.%d.%d, comparing to: %d.%d.%d", |
|
581 installedVersion.iMajor, |
|
582 installedVersion.iMinor, |
|
583 installedVersion.iBuild, |
|
584 aVersion.iMajor, |
|
585 aVersion.iMinor, |
|
586 aVersion.iBuild )); |
|
587 |
|
588 if ( installedVersion > aVersion ) |
|
589 { |
|
590 status = ENcdApplicationNewerVersionInstalled; |
|
591 } |
|
592 else if ( !( installedVersion == aVersion ) ) |
|
593 { |
|
594 status = ENcdApplicationOlderVersionInstalled; |
|
595 } |
|
596 } |
|
597 |
|
598 DLTRACEOUT(("widget Status: %d", status)); |
|
599 return status; |
|
600 } |
|
601 |
537 // --------------------------------------------------------------------------- |
602 // --------------------------------------------------------------------------- |
538 // Checks the application status |
603 // Checks the application status |
539 // --------------------------------------------------------------------------- |
604 // --------------------------------------------------------------------------- |
540 // |
605 // |
541 TNcdApplicationStatus CNcdInstallationService::IsApplicationInstalledL( |
606 TNcdApplicationStatus CNcdInstallationService::IsApplicationInstalledL( |
578 }); |
643 }); |
579 |
644 |
580 // SIS app not found, try to get java |
645 // SIS app not found, try to get java |
581 if ( err == KErrNotFound && |
646 if ( err == KErrNotFound && |
582 ( JavaAppExistsL( aUid ) || |
647 ( JavaAppExistsL( aUid ) || |
583 WidgetExistsL( aUid ) ) ) |
648 WidgetExistsL( aUid, installedVersion ) ) ) |
584 { |
649 { |
585 status = ENcdApplicationInstalled; |
650 status = ENcdApplicationInstalled; |
|
651 err = KErrNone; |
586 } |
652 } |
587 |
653 |
588 LeaveIfNotErrorL( err, KErrNotFound ); |
654 LeaveIfNotErrorL( err, KErrNotFound ); |
589 |
655 |
590 // Some app found, check version numbers if they are something else than |
656 // Some app found, check version numbers if they are something else than |
1538 { |
1604 { |
1539 DLTRACEIN(("")); |
1605 DLTRACEIN(("")); |
1540 |
1606 |
1541 iInstallType = EWidgetInstall; |
1607 iInstallType = EWidgetInstall; |
1542 |
1608 |
1543 // Get the list of installed widget uids so that we can |
1609 // Get the list of installed widgets so that we can |
1544 // get the uid of the new widget after installation |
1610 // get the uid of the new widget after installation |
1545 PopulateInstalledWidgetUidsL(); |
1611 PopulateInstalledWidgetsL(iInstalledWidgetsInfos); |
1546 |
1612 |
1547 TDataType dataType; |
1613 TDataType dataType; |
1548 // Start application installation. |
1614 // Start application installation. |
1549 DLINFO(( "Calling doc handler Open" )); |
1615 DLINFO(( "Calling doc handler Open" )); |
1550 |
1616 |
1551 if ( !aSilentInstallOptionsPckg ) |
1617 if ( !aSilentInstallOptionsPckg ) |
1647 |
1713 |
1648 if ( aAppUid == KNullUid ) |
1714 if ( aAppUid == KNullUid ) |
1649 { |
1715 { |
1650 DLINFO(("Installed midlet was not found")); |
1716 DLINFO(("Installed midlet was not found")); |
1651 // Because the new midlet was not found, we can suppose that the |
1717 // Because the new midlet was not found, we can suppose that the |
|
1718 // application was not installed. So, set the error as KErrCancel. |
|
1719 aError = KErrCancel; |
|
1720 } |
|
1721 } |
|
1722 else if ( iInstallType == EWidgetInstall ) |
|
1723 { |
|
1724 // Set the midlet UID for the aAppUid variable. |
|
1725 aAppUid = InstalledWidgetUidL(); |
|
1726 |
|
1727 if ( aAppUid == KNullUid ) |
|
1728 { |
|
1729 DLINFO(("Installed widget was not found")); |
|
1730 // Because the new widget was not found, we can suppose that the |
1652 // application was not installed. So, set the error as KErrCancel. |
1731 // application was not installed. So, set the error as KErrCancel. |
1653 aError = KErrCancel; |
1732 aError = KErrCancel; |
1654 } |
1733 } |
1655 } |
1734 } |
1656 else if ( iInstallType == ESisInstall ) |
1735 else if ( iInstallType == ESisInstall ) |
2055 |
2134 |
2056 iInstalledWidgets.ResetAndDestroy(); |
2135 iInstalledWidgets.ResetAndDestroy(); |
2057 User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( iInstalledWidgets ) ); |
2136 User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( iInstalledWidgets ) ); |
2058 } |
2137 } |
2059 |
2138 |
|
2139 // --------------------------------------------------------------------------- |
|
2140 // Populates the list of installed widgets |
|
2141 // --------------------------------------------------------------------------- |
|
2142 // |
|
2143 void CNcdInstallationService::PopulateInstalledWidgetsL |
|
2144 (RExtendedWidgetInfoArray& aWidgets) |
|
2145 { |
|
2146 DLTRACEIN(("")); |
|
2147 |
|
2148 // Get the list of installed widget uids |
|
2149 PopulateInstalledWidgetUidsL(); |
|
2150 |
|
2151 const TInt count = iInstalledWidgets.Count(); |
|
2152 |
|
2153 // Create array with UID & Version infos |
|
2154 for ( TInt i = 0; i < count; ++i ) |
|
2155 { |
|
2156 CExtendedWidgetInfo* tempInfo = new ( ELeave ) CExtendedWidgetInfo(); |
|
2157 CleanupStack::PushL( tempInfo ); |
|
2158 |
|
2159 CWidgetInfo* widgetInfo = iInstalledWidgets[i]; |
|
2160 |
|
2161 CWidgetPropertyValue* version = iWidgetRegistry.GetWidgetPropertyValueL |
|
2162 (widgetInfo->iUid, EBundleVersion ); |
|
2163 CleanupStack::PushL( version ); |
|
2164 |
|
2165 // Fill info |
|
2166 tempInfo->iUid = widgetInfo->iUid; |
|
2167 if (!version->iValue.s) |
|
2168 *(tempInfo->iVersion) = KDefVersion; |
|
2169 else |
|
2170 *(tempInfo->iVersion) = *(version->iValue.s); |
|
2171 |
|
2172 // Append to arrayt |
|
2173 aWidgets.AppendL( tempInfo ); |
|
2174 |
|
2175 CleanupStack::PopAndDestroy( version ); |
|
2176 CleanupStack::Pop( tempInfo ); |
|
2177 } |
|
2178 |
|
2179 DLTRACEOUT(("")); |
|
2180 |
|
2181 } |
2060 |
2182 |
2061 // --------------------------------------------------------------------------- |
2183 // --------------------------------------------------------------------------- |
2062 // Gets the name of widget that was installed last |
2184 // Gets the name of widget that was installed last |
2063 // --------------------------------------------------------------------------- |
2185 // --------------------------------------------------------------------------- |
2064 // |
2186 // |
2091 // |
2213 // |
2092 TUid CNcdInstallationService::InstalledWidgetUidL() |
2214 TUid CNcdInstallationService::InstalledWidgetUidL() |
2093 { |
2215 { |
2094 DLTRACEIN(("")); |
2216 DLTRACEIN(("")); |
2095 |
2217 |
2096 RWidgetInfoArray widgets; |
2218 RExtendedWidgetInfoArray widgets; |
|
2219 PopulateInstalledWidgetsL(widgets); |
2097 CleanupResetAndDestroyPushL( widgets ); |
2220 CleanupResetAndDestroyPushL( widgets ); |
2098 |
2221 |
2099 User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( widgets ) ); |
2222 |
2100 DLINFO(("widget count: %d", widgets.Count() )); |
2223 DLINFO(("widget count: %d", widgets.Count() )); |
2101 |
2224 |
2102 TUid uid( KNullUid ); |
2225 TUid uid( KNullUid ); |
2103 |
2226 |
2104 const TInt count = widgets.Count(); |
2227 const TInt count = widgets.Count(); |
2105 const TInt installedCount = iInstalledWidgets.Count(); |
2228 const TInt installedCount = iInstalledWidgetsInfos.Count(); |
2106 |
2229 |
2107 // Try to find a widget that was not installed earlier. |
2230 // Try to find a widget that was not installed earlier. |
2108 for ( TInt i = 0; i < count; ++i ) |
2231 for ( TInt i = 0; i < count; ++i ) |
2109 { |
2232 { |
2110 TBool wasInstalled = EFalse; |
2233 TBool wasInstalled = EFalse; |
2111 CWidgetInfo* widgetInfo = widgets[ i ]; |
2234 CExtendedWidgetInfo * widgetInfo = widgets[ i ]; |
2112 for ( TInt j = 0; j < installedCount; j++ ) |
2235 for ( TInt j = 0; j < installedCount; j++ ) |
2113 { |
2236 { |
2114 if ( iInstalledWidgets[ j ]->iUid == widgetInfo->iUid ) |
2237 |
|
2238 TCatalogsVersion versionBefore, versionAfter; |
|
2239 TCatalogsVersion::ConvertL |
|
2240 ( versionBefore, *(iInstalledWidgetsInfos[ j ]->iVersion) ); |
|
2241 TCatalogsVersion::ConvertL( versionAfter, *(widgetInfo->iVersion) ); |
|
2242 |
|
2243 if ( iInstalledWidgetsInfos[ j ]->iUid == widgetInfo->iUid && |
|
2244 versionBefore >= versionAfter) |
2115 { |
2245 { |
2116 wasInstalled = ETrue; |
2246 wasInstalled = ETrue; |
2117 break; |
2247 break; |
2118 } |
2248 } |
2119 } |
2249 } |
2201 iWidgetRegistry.GetWidgetBundleId( aUid, id ); |
2331 iWidgetRegistry.GetWidgetBundleId( aUid, id ); |
2202 return iWidgetRegistry.WidgetExistsL( id ); |
2332 return iWidgetRegistry.WidgetExistsL( id ); |
2203 } |
2333 } |
2204 return EFalse; |
2334 return EFalse; |
2205 } |
2335 } |
|
2336 |
|
2337 // --------------------------------------------------------------------------- |
|
2338 //Calling widget registry API to check if a widget with given uid is installed |
|
2339 //already |
|
2340 // --------------------------------------------------------------------------- |
|
2341 // |
|
2342 TBool CNcdInstallationService::WidgetExistsL( |
|
2343 const TUid& aUid, TCatalogsVersion& aVersion ) |
|
2344 { |
|
2345 DLTRACEIN(("")); |
|
2346 |
|
2347 if ( !iWidgetRegistry.Handle() ) |
|
2348 { |
|
2349 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2350 } |
|
2351 |
|
2352 if ( iWidgetRegistry.IsWidget( aUid ) ) |
|
2353 { |
|
2354 TBuf<KWidgetBundleIdLength> id; |
|
2355 iWidgetRegistry.GetWidgetBundleId( aUid, id ); |
|
2356 if (iWidgetRegistry.WidgetExistsL( id )) |
|
2357 { |
|
2358 // Get version |
|
2359 CWidgetPropertyValue* version = |
|
2360 iWidgetRegistry.GetWidgetPropertyValueL(aUid, EBundleVersion ); |
|
2361 CleanupStack::PushL( version ); |
|
2362 TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) ); |
|
2363 CleanupStack::PopAndDestroy( version ); |
|
2364 return (ETrue); |
|
2365 } |
|
2366 else |
|
2367 { |
|
2368 return (EFalse); |
|
2369 } |
|
2370 } |
|
2371 else |
|
2372 return(EFalse); |
|
2373 |
|
2374 } |
|
2375 |
|
2376 // --------------------------------------------------------------------------- |
|
2377 // Calling widget registry API to check if a widget with given identifier is |
|
2378 // installed already |
|
2379 // --------------------------------------------------------------------------- |
|
2380 // |
|
2381 TBool CNcdInstallationService::WidgetExistsL |
|
2382 ( const TDesC& aIdentifier, TCatalogsVersion& aVersion ) |
|
2383 { |
|
2384 DLTRACEIN(("")); |
|
2385 |
|
2386 if ( !iWidgetRegistry.Handle() ) |
|
2387 { |
|
2388 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2389 } |
|
2390 |
|
2391 RPointerArray<CWidgetInfo> widgetInfoArr; |
|
2392 |
|
2393 CleanupResetAndDestroyPushL( widgetInfoArr ); |
|
2394 TInt err = iWidgetRegistry.InstalledWidgetsL(widgetInfoArr); |
|
2395 |
|
2396 for( TInt i( widgetInfoArr.Count() - 1 ); i >= 0; --i ) |
|
2397 { |
|
2398 CWidgetInfo* widgetInfo( widgetInfoArr[i] ); |
|
2399 CWidgetPropertyValue* bundleId = |
|
2400 iWidgetRegistry.GetWidgetPropertyValueL |
|
2401 (widgetInfo->iUid, EBundleIdentifier ); |
|
2402 CleanupStack::PushL( bundleId ); |
|
2403 |
|
2404 if( aIdentifier.Compare( *(bundleId->iValue.s) )== 0 ) |
|
2405 { |
|
2406 CWidgetPropertyValue* version = |
|
2407 iWidgetRegistry.GetWidgetPropertyValueL |
|
2408 (widgetInfo->iUid, EBundleVersion ); |
|
2409 CleanupStack::PushL( version ); |
|
2410 TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) ); |
|
2411 |
|
2412 CleanupStack::PopAndDestroy( version ); |
|
2413 CleanupStack::PopAndDestroy( bundleId ); |
|
2414 CleanupStack::PopAndDestroy( &widgetInfoArr ); |
|
2415 |
|
2416 return ETrue; |
|
2417 } |
|
2418 CleanupStack::PopAndDestroy( bundleId ); |
|
2419 } |
|
2420 CleanupStack::PopAndDestroy( &widgetInfoArr ); |
|
2421 return EFalse; |
|
2422 } |
|
2423 |
|
2424 // --------------------------------------------------------------------------- |
|
2425 // Calling widget registry API to return the Uid of the widget |
|
2426 // with given identifier. |
|
2427 // --------------------------------------------------------------------------- |
|
2428 // |
|
2429 TUid CNcdInstallationService::WidgetUidL( const TDesC& aIdentifier) |
|
2430 { |
|
2431 DLTRACEIN(("")); |
|
2432 |
|
2433 TUid id = TUid::Uid(0); |
|
2434 |
|
2435 if ( !iWidgetRegistry.Handle() ) |
|
2436 { |
|
2437 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2438 } |
|
2439 |
|
2440 id.iUid = iWidgetRegistry.GetWidgetUidL( aIdentifier); |
|
2441 |
|
2442 return id; |
|
2443 |
|
2444 } |
|
2445 |
|
2446 |