516 // Open java suite entry |
469 // Open java suite entry |
517 // |
470 // |
518 // --------------------------------------------------------------------------- |
471 // --------------------------------------------------------------------------- |
519 // |
472 // |
520 |
473 |
521 #ifdef USE_OLD_JAVA_API |
|
522 |
|
523 TBool CNcdInstallationService::JavaAppExistsL( |
474 TBool CNcdInstallationService::JavaAppExistsL( |
524 const TUid& aUid ) |
475 const TUid& aUid ) |
525 { |
476 { |
526 |
477 DLTRACEIN(("")); |
527 /* HLa - temporary java remove |
478 |
528 DLTRACEIN(("")); |
479 TBool retVal = EFalse; |
529 |
480 Usif::TComponentId compId = 0; |
530 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
481 |
531 CleanupReleasePushL( *javaRegistry ); |
482 // Get component id |
532 |
483 TRAPD( ret, compId = iScrSession.GetComponentIdForAppL( aUid ) ); |
533 TRAPD( err, |
484 if ( ret == KErrNotFound ) |
534 { |
485 { |
535 // Leaves with KErrNotFound if not found |
486 return EFalse; |
536 MJavaRegistryMIDletEntry* midletEntry = javaRegistry->MIDletEntryL( |
487 } |
537 aUid ); |
488 else if (ret != KErrNone ) |
538 midletEntry->Release(); |
489 { |
539 }); |
490 User::Leave( ret ); |
540 |
491 } |
541 LeaveIfNotErrorL( err, KErrNotFound ); |
492 |
542 |
493 Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); |
543 CleanupStack::PopAndDestroy( javaRegistry ); |
494 TRAPD(err, iScrSession.GetComponentL(compId, *entry)); |
544 return err == KErrNone; |
495 |
545 */ |
496 if ( err == KErrNotFound ) |
546 |
497 { |
547 } |
498 retVal = EFalse; |
548 |
499 } |
549 #else |
500 else if (err != KErrNone ) |
550 |
501 { |
551 TBool CNcdInstallationService::JavaAppExistsL( |
502 User::Leave( err ); |
552 const TUid& aUid ) |
503 } |
553 { |
504 else |
554 DLTRACEIN(("")); |
505 { |
555 /* HLa - temporary java remove |
506 // type == Java ? |
556 |
507 if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeJava ) == 0 ) |
557 CJavaRegistry* javaRegistry = CJavaRegistry::NewLC(); |
508 { |
558 |
509 retVal = ETrue; |
559 TBool exists = javaRegistry->RegistryEntryExistsL( aUid ); |
510 } |
560 |
511 else |
561 CleanupStack::PopAndDestroy( javaRegistry ); |
512 { |
562 return exists; |
513 retVal = EFalse; |
563 */ |
514 } |
564 return EFalse; |
515 } |
565 |
516 CleanupStack::PopAndDestroy(entry); |
566 } |
517 return retVal; |
567 |
518 |
568 #endif |
519 } |
569 |
520 |
570 // Check via widget registry API |
521 // Check via widget registry API |
571 TNcdApplicationStatus CNcdInstallationService::IsWidgetInstalledL(const TDesC& aIdentifier, const TCatalogsVersion& aVersion) |
522 TNcdApplicationStatus CNcdInstallationService::IsWidgetInstalledL(const TDesC& aIdentifier, const TCatalogsVersion& aVersion) |
572 { |
523 { |
573 DLTRACEIN(("")); |
524 DLTRACEIN(("")); |
1920 |
1858 |
1921 // --------------------------------------------------------------------------- |
1859 // --------------------------------------------------------------------------- |
1922 // Gets a list of installed midlet UIDs |
1860 // Gets a list of installed midlet UIDs |
1923 // --------------------------------------------------------------------------- |
1861 // --------------------------------------------------------------------------- |
1924 // |
1862 // |
1925 #ifdef USE_OLD_JAVA_API |
|
1926 |
1863 |
1927 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids ) |
1864 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids ) |
1928 { |
1865 { |
1929 /* HLa - temporary java remove |
1866 |
1930 DLTRACEIN(("")); |
1867 // Get ids of all java components in scr |
1931 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
1868 RArray<Usif::TComponentId> javaComponentIdList; |
1932 CleanupReleasePushL( *javaRegistry ); |
1869 CleanupClosePushL( javaComponentIdList ); |
1933 javaRegistry->InstalledMIDletUidsL( aUids ); |
1870 |
1934 CleanupStack::PopAndDestroy( javaRegistry ); |
1871 Usif::CComponentFilter *pJavaSwTypeFilter = Usif::CComponentFilter::NewLC(); |
1935 */ |
1872 pJavaSwTypeFilter->SetSoftwareTypeL( Usif::KSoftwareTypeJava ); |
1936 } |
1873 iScrSession.GetComponentIdsL( javaComponentIdList, pJavaSwTypeFilter ); |
1937 |
1874 CleanupStack::PopAndDestroy( pJavaSwTypeFilter ); |
1938 #else |
1875 |
1939 |
1876 |
1940 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids ) |
1877 // Get components |
1941 { |
1878 TInt aUidIndex = 0; |
1942 /* HLa - temporary java remove |
1879 for ( TInt i = 0; i < javaComponentIdList.Count(); ++i ) |
1943 DLTRACEIN(("")); |
1880 { |
1944 CJavaRegistry* javaRegistry = CJavaRegistry::NewLC(); |
1881 RArray<TUid> midletUids; |
1945 javaRegistry->GetRegistryEntryUidsL( aUids ); |
1882 CleanupClosePushL( midletUids ); |
1946 CleanupStack::PopAndDestroy( javaRegistry ); |
1883 iScrSession.GetAppUidsForComponentL( javaComponentIdList[i], midletUids ); |
1947 */ |
1884 for ( TInt j = 0; j < midletUids.Count(); ++j ) |
1948 } |
1885 { |
1949 |
1886 aUids[aUidIndex] = aUids[j]; |
1950 #endif |
1887 aUidIndex++; |
1951 |
1888 } |
|
1889 CleanupStack::PopAndDestroy(); // midletUids |
|
1890 } |
|
1891 |
|
1892 CleanupStack::PopAndDestroy(); // javaComponentIdList |
|
1893 |
|
1894 } |
1952 |
1895 |
1953 // --------------------------------------------------------------------------- |
1896 // --------------------------------------------------------------------------- |
1954 // Checks if the application is in ROM |
1897 // Checks if the application is in ROM |
1955 // --------------------------------------------------------------------------- |
1898 // --------------------------------------------------------------------------- |
1956 // |
1899 // |
1957 TBool CNcdInstallationService::IsRomApplication( const TUid& aUid ) const |
1900 TBool CNcdInstallationService::IsRomApplication( const TUid& aUid ) const |
1958 { |
1901 { |
1959 DLTRACEIN(("UID: %x", aUid.iUid )); |
1902 DLTRACEIN(("UID: %x", aUid.iUid )); |
1960 return iRomUids.Find( aUid ) != KErrNotFound; |
1903 return iRomUids.Find( aUid ) != KErrNotFound; |
1961 } |
1904 } |
1962 |
|
1963 |
|
1964 // --------------------------------------------------------------------------- |
|
1965 // Returns the UID of the latest installed midlet, NULL UID if none have |
|
1966 // been installed since the last device restart |
|
1967 // --------------------------------------------------------------------------- |
|
1968 // |
|
1969 |
|
1970 /* HLa - temporary java remove |
|
1971 #ifdef USE_OLD_JAVA_API |
|
1972 |
|
1973 TUid CNcdInstallationService::LatestMidletUidL( |
|
1974 MJavaRegistry& aJavaRegistry ) const |
|
1975 { |
|
1976 DLTRACEIN(("")); |
|
1977 TInt suiteUid = 0; |
|
1978 |
|
1979 // Get UID for the latest installed Midlet suite |
|
1980 // KPSUidJavaLatestInstallation = 0x10282567 |
|
1981 // Ignoring error in case the key or read policy change so that client |
|
1982 // doesn't behave strangely |
|
1983 RProperty::Get( KUidSystemCategory, |
|
1984 KPSUidJavaLatestInstallation, suiteUid ); |
|
1985 |
|
1986 DLTRACE(("JMI UID: %x", suiteUid )); |
|
1987 |
|
1988 if ( !suiteUid ) |
|
1989 { |
|
1990 return KNullUid; |
|
1991 } |
|
1992 |
|
1993 // Get entry for the installed suite |
|
1994 MJavaRegistrySuiteEntry* suite = aJavaRegistry.SuiteEntryL( |
|
1995 TUid::Uid( suiteUid ) ); |
|
1996 CleanupReleasePushL( *suite ); |
|
1997 RArray<TUid> suiteUids; |
|
1998 CleanupClosePushL( suiteUids ); |
|
1999 |
|
2000 TUid midletUid = KNullUid; |
|
2001 suite->MIDletUidsL( suiteUids ); |
|
2002 |
|
2003 // Take first midlet UID from the suite |
|
2004 if ( suiteUids.Count() ) |
|
2005 { |
|
2006 midletUid = suiteUids[0]; |
|
2007 } |
|
2008 DLTRACE(("Midlets in suite: %d", suite->NumberOfMIDletsL() )); |
|
2009 CleanupStack::PopAndDestroy( &suiteUids ); |
|
2010 DLTRACE(("InstalledAppsEntryUid: %x", midletUid.iUid )); |
|
2011 |
|
2012 CleanupStack::PopAndDestroy( suite ); |
|
2013 return midletUid; |
|
2014 } |
|
2015 |
|
2016 #else |
|
2017 |
|
2018 TUid CNcdInstallationService::LatestMidletUidL( |
|
2019 CJavaRegistry& aJavaRegistry ) const |
|
2020 { |
|
2021 DLTRACEIN(("")); |
|
2022 TInt suiteUid = 0; |
|
2023 |
|
2024 // Get UID for the latest installed Midlet suite |
|
2025 // KPSUidJavaLatestInstallation = 0x10282567 |
|
2026 // Ignoring error in case the key or read policy change so that client |
|
2027 // doesn't behave strangely |
|
2028 RProperty::Get( KUidSystemCategory, |
|
2029 KPSUidJavaLatestInstallation, suiteUid ); |
|
2030 |
|
2031 DLTRACE(("JMI UID: %x", suiteUid )); |
|
2032 |
|
2033 if ( !suiteUid ) |
|
2034 { |
|
2035 return KNullUid; |
|
2036 } |
|
2037 |
|
2038 // Get entry for the installed suite |
|
2039 CJavaRegistryEntry* suite = aJavaRegistry.RegistryEntryL( |
|
2040 TUid::Uid( suiteUid ) ); |
|
2041 |
|
2042 if ( !suite ) |
|
2043 { |
|
2044 return KNullUid; |
|
2045 } |
|
2046 |
|
2047 CleanupStack::PushL( suite ); |
|
2048 |
|
2049 DASSERT( suite->Type() < EGeneralApplication && |
|
2050 suite->Type() >= EGeneralPackage ); |
|
2051 |
|
2052 CJavaRegistryPackageEntry* entry = |
|
2053 static_cast<CJavaRegistryPackageEntry*>( suite ); |
|
2054 |
|
2055 TUid midletUid = KNullUid; |
|
2056 TInt count = entry->NumberOfEmbeddedEntries(); |
|
2057 TBool appFound = EFalse; |
|
2058 TInt index = 0; |
|
2059 |
|
2060 // Find the first application from the suite |
|
2061 while ( index < count && !appFound ) |
|
2062 { |
|
2063 CJavaRegistryEntry* app = entry->EmbeddedEntryByNumberL( index ); |
|
2064 if ( app->Type() >= EGeneralApplication ) |
|
2065 { |
|
2066 midletUid = app->Uid(); |
|
2067 appFound = ETrue; |
|
2068 DLTRACE(( "Found app: %x", midletUid.iUid )); |
|
2069 } |
|
2070 delete app; |
|
2071 ++index; |
|
2072 } |
|
2073 |
|
2074 CleanupStack::PopAndDestroy( suite ); |
|
2075 return midletUid; |
|
2076 } |
|
2077 |
|
2078 |
|
2079 #endif |
|
2080 */ |
|
2081 |
1905 |
2082 // --------------------------------------------------------------------------- |
1906 // --------------------------------------------------------------------------- |
2083 // Returns true if the MIME type matches a Java application or descriptor |
1907 // Returns true if the MIME type matches a Java application or descriptor |
2084 // --------------------------------------------------------------------------- |
1908 // --------------------------------------------------------------------------- |
2085 // |
1909 // |
2089 aMime.MatchF( KMimeTypeMatch2JavaApplication ) != KErrNotFound || |
1913 aMime.MatchF( KMimeTypeMatch2JavaApplication ) != KErrNotFound || |
2090 aMime.MatchF( KMimeTypeMatchJad ) != KErrNotFound ); |
1914 aMime.MatchF( KMimeTypeMatchJad ) != KErrNotFound ); |
2091 } |
1915 } |
2092 |
1916 |
2093 |
1917 |
2094 #ifdef USE_OLD_JAVA_API |
|
2095 |
1918 |
2096 |
1919 |
2097 TUid CNcdInstallationService::InstalledMidletUidL() |
1920 TUid CNcdInstallationService::InstalledMidletUidL() |
2098 { |
1921 { |
2099 |
1922 |
2100 /* HLa - temporary java remove |
1923 Usif::COpaqueNamedParams* iResults = 0; // to be removed |
2101 DLTRACEIN(("")); |
1924 |
2102 RArray<TUid> MIDletUids; |
1925 RArray<TUid> appUids; |
2103 CleanupClosePushL( MIDletUids ); |
1926 TUid midletUid = KNullUid; |
2104 |
1927 TInt compId = 0; |
2105 MJavaRegistry* javaRegistry = MJavaRegistry::CreateL(); |
1928 |
2106 CleanupReleasePushL( *javaRegistry ); |
1929 // Get component id |
2107 javaRegistry->InstalledMIDletUidsL( MIDletUids ); |
1930 TRAPD ( err, iResults->IntByNameL( Usif::KSifOutParam_ComponentId )); |
2108 TUid MIDletUid = KNullUid; |
1931 if ( err == KErrNotFound ) |
2109 // Search for new uids in Java registry. |
1932 { |
2110 for ( TInt i = 0 ; i < MIDletUids.Count() ; i++ ) |
1933 return midletUid; |
2111 { |
1934 } |
2112 if ( iMIDletUids.Find( MIDletUids[i] ) == KErrNotFound ) |
1935 |
2113 { |
1936 // Get components |
2114 // A new uid found, this is the installed midlet's uid |
1937 CleanupClosePushL( appUids ); |
2115 MIDletUid = MIDletUids[i]; |
1938 iScrSession.GetAppUidsForComponentL( compId, appUids ); |
2116 break; |
1939 |
2117 } |
1940 // return first midlet uid, if exists |
2118 } |
1941 if ( appUids.Count() != 0 ) |
2119 |
1942 { |
2120 // We didn't get any new UID so we have to check Java installer's |
1943 midletUid = appUids[0]; |
2121 // P&S key for the installed suite UID and the get the midlet UID |
1944 } |
2122 // from that. This happens when a midlet with predefined UID, |
1945 CleanupStack::PopAndDestroy(); // appUids |
2123 // eg. WidSets, is reinstalled. Midlet UIDs are predefined with |
|
2124 // the attribute Nokia-MIDlet-UID-<n> in a JAD or JAR manifest |
|
2125 if ( MIDletUid == KNullUid ) |
|
2126 { |
|
2127 MIDletUid = LatestMidletUidL( *javaRegistry ); |
|
2128 } |
|
2129 |
|
2130 CleanupStack::PopAndDestroy( javaRegistry ); |
|
2131 CleanupStack::PopAndDestroy( &MIDletUids ); |
|
2132 |
|
2133 iMIDletUids.Reset(); |
|
2134 return MIDletUid; |
|
2135 */ |
|
2136 |
|
2137 } |
|
2138 |
|
2139 #else // USE_OLD_JAVA_API |
|
2140 |
|
2141 TUid CNcdInstallationService::InstalledMidletUidL() |
|
2142 { |
|
2143 /* HLa - temporary java remove |
|
2144 DLTRACEIN(("")); |
|
2145 CJavaRegistry* registry = CJavaRegistry::NewLC(); |
|
2146 TUid midletUid = LatestMidletUidL( *registry ); |
|
2147 CleanupStack::PopAndDestroy( registry ); |
|
2148 return midletUid; |
1946 return midletUid; |
2149 */ |
|
2150 |
|
2151 return KNullUid; |
|
2152 |
|
2153 } |
|
2154 |
|
2155 #endif // USE_OLD_JAVA_API |
|
2156 |
|
2157 |
|
2158 // --------------------------------------------------------------------------- |
|
2159 // Populates the list of installed widgets |
|
2160 // --------------------------------------------------------------------------- |
|
2161 // |
|
2162 void CNcdInstallationService::PopulateInstalledWidgetUidsL() |
|
2163 { |
|
2164 DLTRACEIN(("")); |
|
2165 |
|
2166 if ( !iWidgetRegistry.Handle() ) |
|
2167 { |
|
2168 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2169 } |
|
2170 |
|
2171 iInstalledWidgets.ResetAndDestroy(); |
|
2172 User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( iInstalledWidgets ) ); |
|
2173 } |
1947 } |
2174 |
1948 |
2175 // --------------------------------------------------------------------------- |
1949 // --------------------------------------------------------------------------- |
2176 // Populates the list of installed widgets |
1950 // Populates the list of installed widgets |
2177 // --------------------------------------------------------------------------- |
1951 // --------------------------------------------------------------------------- |
2179 void CNcdInstallationService::PopulateInstalledWidgetsL |
1953 void CNcdInstallationService::PopulateInstalledWidgetsL |
2180 (RExtendedWidgetInfoArray& aWidgets) |
1954 (RExtendedWidgetInfoArray& aWidgets) |
2181 { |
1955 { |
2182 DLTRACEIN(("")); |
1956 DLTRACEIN(("")); |
2183 |
1957 |
2184 // Get the list of installed widget uids |
1958 // Get ids of all widget components in scr |
2185 PopulateInstalledWidgetUidsL(); |
1959 RArray<Usif::TComponentId> widgetComponentIdList; |
2186 |
1960 Usif::CComponentFilter *pWidgetSwTypeFilter = Usif::CComponentFilter::NewLC(); |
2187 const TInt count = iInstalledWidgets.Count(); |
1961 pWidgetSwTypeFilter->SetSoftwareTypeL(Usif::KSoftwareTypeWidget); |
2188 |
1962 |
2189 // Create array with UID & Version infos |
1963 iScrSession.GetComponentIdsL(widgetComponentIdList, pWidgetSwTypeFilter); |
|
1964 |
|
1965 CleanupStack::PopAndDestroy(pWidgetSwTypeFilter); |
|
1966 CleanupClosePushL(widgetComponentIdList); |
|
1967 |
|
1968 const TInt count = widgetComponentIdList.Count(); |
|
1969 |
|
1970 // Create array with id & version infos |
2190 for ( TInt i = 0; i < count; ++i ) |
1971 for ( TInt i = 0; i < count; ++i ) |
2191 { |
1972 { |
2192 CExtendedWidgetInfo* tempInfo = new ( ELeave ) CExtendedWidgetInfo(); |
1973 CExtendedWidgetInfo* tempInfo = new ( ELeave ) CExtendedWidgetInfo(); |
2193 CleanupStack::PushL( tempInfo ); |
1974 CleanupStack::PushL( tempInfo ); |
2194 |
1975 |
2195 CWidgetInfo* widgetInfo = iInstalledWidgets[i]; |
1976 // Get widget |
2196 |
1977 Usif::TComponentId compId = widgetComponentIdList[i]; |
2197 CWidgetPropertyValue* version = iWidgetRegistry.GetWidgetPropertyValueL |
1978 Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); |
2198 (widgetInfo->iUid, EBundleVersion ); |
1979 iScrSession.GetComponentL(compId, *entry); |
2199 CleanupStack::PushL( version ); |
1980 |
2200 |
1981 // Fill id & version |
2201 // Fill info |
1982 tempInfo->iUid.iUid= compId; |
2202 tempInfo->iUid = widgetInfo->iUid; |
1983 *(tempInfo->iVersion) = entry->Version(); |
2203 if (!version->iValue.s) |
|
2204 *(tempInfo->iVersion) = KDefVersion; |
|
2205 else |
|
2206 *(tempInfo->iVersion) = *(version->iValue.s); |
|
2207 |
1984 |
2208 // Append to arrayt |
1985 // Append to arrayt |
2209 aWidgets.AppendL( tempInfo ); |
1986 aWidgets.AppendL( tempInfo ); |
2210 |
1987 |
2211 CleanupStack::PopAndDestroy( version ); |
1988 CleanupStack::PopAndDestroy(entry); |
2212 CleanupStack::Pop( tempInfo ); |
1989 CleanupStack::Pop( tempInfo ); |
2213 } |
1990 } |
|
1991 |
|
1992 |
|
1993 CleanupStack::PopAndDestroy(); // widgetComponentIdList |
2214 |
1994 |
2215 DLTRACEOUT(("")); |
1995 DLTRACEOUT(("")); |
2216 |
1996 |
2217 } |
1997 } |
2218 |
1998 |
2219 // --------------------------------------------------------------------------- |
1999 // --------------------------------------------------------------------------- |
2220 // Gets the name of widget that was installed last |
2000 // Gets the name of widget that was installed last |
2221 // --------------------------------------------------------------------------- |
2001 // --------------------------------------------------------------------------- |
2222 // |
2002 // |
|
2003 |
2223 HBufC* CNcdInstallationService::InstalledWidgetNameLC() |
2004 HBufC* CNcdInstallationService::InstalledWidgetNameLC() |
2224 { |
2005 { |
2225 DLTRACEIN(("")); |
2006 DLTRACEIN(("")); |
2226 |
2007 |
2227 TUid widgetUid = InstalledWidgetUidL(); |
2008 // Not currently suported |
2228 |
2009 return NULL; |
2229 if ( widgetUid == KNullUid ) |
|
2230 { |
|
2231 DLERROR(("No widget uid")); |
|
2232 // No new UID was found, so we assume user canceled the installation. |
|
2233 // Installer does not give any error code in that case. |
|
2234 return NULL; |
|
2235 } |
|
2236 |
|
2237 HBufC* bundleId = HBufC::NewLC( KWidgetBundleIdLength ); |
|
2238 TPtr des( bundleId->Des() ); |
|
2239 iWidgetRegistry.GetWidgetBundleId( widgetUid, des ); |
|
2240 |
|
2241 DLTRACEOUT(( _L("Widget bundle id: %S"), bundleId )); |
|
2242 return bundleId; |
|
2243 } |
2010 } |
2244 |
2011 |
2245 |
2012 |
2246 // --------------------------------------------------------------------------- |
2013 // --------------------------------------------------------------------------- |
2247 // Gets the UID of the widget that was just installed |
2014 // Gets the UID of the widget that was just installed |
2347 iObserver->InstallationCompleteL( KNullDesC, uid, iInstallError ); |
2114 iObserver->InstallationCompleteL( KNullDesC, uid, iInstallError ); |
2348 } |
2115 } |
2349 |
2116 |
2350 |
2117 |
2351 // --------------------------------------------------------------------------- |
2118 // --------------------------------------------------------------------------- |
2352 // |
|
2353 // --------------------------------------------------------------------------- |
|
2354 // |
|
2355 TBool CNcdInstallationService::WidgetExistsL( const TUid& aUid ) |
|
2356 { |
|
2357 DLTRACEIN(("")); |
|
2358 |
|
2359 if ( !iWidgetRegistry.Handle() ) |
|
2360 { |
|
2361 User::LeaveIfError( iWidgetRegistry.Connect() ); |
|
2362 } |
|
2363 |
|
2364 if ( iWidgetRegistry.IsWidget( aUid ) ) |
|
2365 { |
|
2366 TBuf<KWidgetBundleIdLength> id; |
|
2367 iWidgetRegistry.GetWidgetBundleId( aUid, id ); |
|
2368 return iWidgetRegistry.WidgetExistsL( id ); |
|
2369 } |
|
2370 return EFalse; |
|
2371 } |
|
2372 |
|
2373 // --------------------------------------------------------------------------- |
|
2374 //Calling widget registry API to check if a widget with given uid is installed |
2119 //Calling widget registry API to check if a widget with given uid is installed |
2375 //already |
2120 //already |
2376 // --------------------------------------------------------------------------- |
2121 // --------------------------------------------------------------------------- |
2377 // |
2122 // |
|
2123 TBool CNcdInstallationService::WidgetExistsL( const TUid& aUid ) |
|
2124 { |
|
2125 DLTRACEIN(("")); |
|
2126 |
|
2127 TBool retVal = EFalse; |
|
2128 |
|
2129 // Get entry |
|
2130 Usif::TComponentId compId = aUid.iUid; |
|
2131 Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); |
|
2132 TRAPD(err, iScrSession.GetComponentL(compId, *entry)); |
|
2133 |
|
2134 if ( err == KErrNotFound || !retVal ) |
|
2135 { |
|
2136 retVal = EFalse; |
|
2137 } |
|
2138 else if (err != KErrNone ) |
|
2139 { |
|
2140 User::Leave( err ); |
|
2141 } |
|
2142 else |
|
2143 { |
|
2144 // widget ?? |
|
2145 if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeWidget ) == 0 ) |
|
2146 { |
|
2147 retVal = ETrue; |
|
2148 } |
|
2149 else |
|
2150 { |
|
2151 retVal = EFalse; |
|
2152 } |
|
2153 } |
|
2154 CleanupStack::PopAndDestroy(entry); |
|
2155 return retVal; |
|
2156 } |
|
2157 |
|
2158 // --------------------------------------------------------------------------- |
|
2159 //Calling widget registry API to check if a widget with given uid is installed |
|
2160 //already. Returns the version of the installed widget. |
|
2161 // --------------------------------------------------------------------------- |
|
2162 // |
2378 TBool CNcdInstallationService::WidgetExistsL( |
2163 TBool CNcdInstallationService::WidgetExistsL( |
2379 const TUid& aUid, TCatalogsVersion& aVersion ) |
2164 const TUid& aUid, TCatalogsVersion& aVersion ) |
2380 { |
2165 { |
2381 DLTRACEIN(("")); |
2166 DLTRACEIN(("")); |
2382 |
2167 |
2383 if ( !iWidgetRegistry.Handle() ) |
2168 TBool retVal = EFalse; |
2384 { |
2169 |
2385 User::LeaveIfError( iWidgetRegistry.Connect() ); |
2170 // Get entry |
2386 } |
2171 Usif::TComponentId compId = aUid.iUid; |
2387 |
2172 Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); |
2388 if ( iWidgetRegistry.IsWidget( aUid ) ) |
2173 TRAPD(err, retVal= iScrSession.GetComponentL(compId, *entry)); |
2389 { |
2174 |
2390 TBuf<KWidgetBundleIdLength> id; |
2175 if ( err == KErrNotFound || !retVal ) |
2391 iWidgetRegistry.GetWidgetBundleId( aUid, id ); |
2176 { |
2392 if (iWidgetRegistry.WidgetExistsL( id )) |
2177 retVal = EFalse; |
2393 { |
2178 } |
|
2179 else if (err != KErrNone ) |
|
2180 { |
|
2181 User::Leave( err ); |
|
2182 } |
|
2183 else |
|
2184 { |
|
2185 // widget ?? |
|
2186 if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeWidget ) == 0 ) |
|
2187 { |
|
2188 retVal = ETrue; |
|
2189 |
2394 // Get version |
2190 // Get version |
2395 CWidgetPropertyValue* version = |
2191 TPtrC entryVersion = entry->Version(); |
2396 iWidgetRegistry.GetWidgetPropertyValueL(aUid, EBundleVersion ); |
2192 TCatalogsVersion::ConvertL( aVersion, entryVersion ); |
2397 CleanupStack::PushL( version ); |
|
2398 TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) ); |
|
2399 CleanupStack::PopAndDestroy( version ); |
|
2400 return (ETrue); |
|
2401 } |
2193 } |
2402 else |
2194 else |
2403 { |
2195 { |
2404 return (EFalse); |
2196 retVal = EFalse; |
2405 } |
2197 } |
2406 } |
2198 } |
2407 else |
2199 CleanupStack::PopAndDestroy(entry); |
2408 return(EFalse); |
2200 return retVal; |
2409 |
2201 |
2410 } |
2202 } |
2411 |
2203 |
2412 // --------------------------------------------------------------------------- |
2204 // --------------------------------------------------------------------------- |
2413 // Calling widget registry API to check if a widget with given identifier is |
2205 // Calling widget registry API to check if a widget with given identifier is |
2414 // installed already |
2206 // installed already |
2417 TBool CNcdInstallationService::WidgetExistsL |
2209 TBool CNcdInstallationService::WidgetExistsL |
2418 ( const TDesC& aIdentifier, TCatalogsVersion& aVersion ) |
2210 ( const TDesC& aIdentifier, TCatalogsVersion& aVersion ) |
2419 { |
2211 { |
2420 DLTRACEIN(("")); |
2212 DLTRACEIN(("")); |
2421 |
2213 |
2422 if ( !iWidgetRegistry.Handle() ) |
2214 TBool retVal = EFalse; |
2423 { |
2215 Usif::TComponentId compId = 0; |
2424 User::LeaveIfError( iWidgetRegistry.Connect() ); |
2216 |
2425 } |
2217 // Get widget component id by identifier |
2426 |
2218 TRAPD( err, compId = |
2427 RPointerArray<CWidgetInfo> widgetInfoArr; |
2219 iScrSession.GetComponentIdL( aIdentifier, Usif::KSoftwareTypeWidget )); |
2428 |
2220 |
2429 CleanupResetAndDestroyPushL( widgetInfoArr ); |
2221 if ( err == KErrNotFound ) |
2430 TInt err = iWidgetRegistry.InstalledWidgetsL(widgetInfoArr); |
2222 { |
2431 |
2223 retVal = EFalse; |
2432 for( TInt i( widgetInfoArr.Count() - 1 ); i >= 0; --i ) |
2224 } |
2433 { |
2225 else if (err != KErrNone ) |
2434 CWidgetInfo* widgetInfo( widgetInfoArr[i] ); |
2226 { |
2435 CWidgetPropertyValue* bundleId = |
2227 User::Leave( err ); |
2436 iWidgetRegistry.GetWidgetPropertyValueL |
2228 } |
2437 (widgetInfo->iUid, EBundleIdentifier ); |
2229 else |
2438 CleanupStack::PushL( bundleId ); |
2230 { |
2439 |
2231 // Widget found |
2440 if( aIdentifier.Compare( *(bundleId->iValue.s) )== 0 ) |
2232 retVal = ETrue; |
2441 { |
2233 |
2442 CWidgetPropertyValue* version = |
2234 // Get entry |
2443 iWidgetRegistry.GetWidgetPropertyValueL |
2235 Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC(); |
2444 (widgetInfo->iUid, EBundleVersion ); |
2236 retVal = iScrSession.GetComponentL(compId, *entry); |
2445 CleanupStack::PushL( version ); |
2237 |
2446 TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) ); |
2238 // Get version |
2447 |
2239 if ( retVal ) |
2448 CleanupStack::PopAndDestroy( version ); |
2240 { |
2449 CleanupStack::PopAndDestroy( bundleId ); |
2241 TPtrC entryVersion = entry->Version(); |
2450 CleanupStack::PopAndDestroy( &widgetInfoArr ); |
2242 TCatalogsVersion::ConvertL( aVersion, entryVersion ); |
2451 |
2243 } |
2452 return ETrue; |
2244 |
2453 } |
2245 CleanupStack::PopAndDestroy(entry); |
2454 CleanupStack::PopAndDestroy( bundleId ); |
2246 } |
2455 } |
2247 |
2456 CleanupStack::PopAndDestroy( &widgetInfoArr ); |
2248 return retVal; |
2457 return EFalse; |
2249 } |
2458 } |
2250 |
2459 |
2251 |
2460 // --------------------------------------------------------------------------- |
2252 // --------------------------------------------------------------------------- |
2461 // Calling widget registry API to return the Uid of the widget |
2253 // Calling widget registry API to return the Uid of the widget |
2462 // with given identifier. |
2254 // with given identifier. |
2463 // --------------------------------------------------------------------------- |
2255 // --------------------------------------------------------------------------- |