--- a/contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp Tue Jul 06 14:37:10 2010 +0300
+++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp Wed Aug 18 10:05:49 2010 +0300
@@ -40,7 +40,8 @@
// -----------------------------------------------------------------------------
//
CCaWidgetStorageHandler::CCaWidgetStorageHandler( CCaStorageProxy* aStorage,
- RFs& aFs )
+ Usif::RSoftwareComponentRegistry& aSoftwareRegistry, RFs& aFs ) :
+ iSoftwareRegistry(aSoftwareRegistry)
{
iStorage = aStorage;
iFs = aFs;
@@ -52,7 +53,6 @@
//
void CCaWidgetStorageHandler::ConstructL()
{
- User::LeaveIfError( iSoftwareRegistry.Connect() );
iParser = CCaWidgetScannerParser::NewL( iFs );
}
@@ -61,9 +61,10 @@
// -----------------------------------------------------------------------------
//
CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewL(
- CCaStorageProxy* aStorage, RFs& aFs )
+ CCaStorageProxy* aStorage,
+ Usif::RSoftwareComponentRegistry& aSoftwareRegistry, RFs& aFs )
{
- CCaWidgetStorageHandler* self = NewLC( aStorage, aFs );
+ CCaWidgetStorageHandler* self = NewLC( aStorage, aSoftwareRegistry, aFs );
CleanupStack::Pop( self );
return self;
}
@@ -73,10 +74,11 @@
// -----------------------------------------------------------------------------
//
CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewLC(
- CCaStorageProxy* aStorage, RFs& aFs )
+ CCaStorageProxy* aStorage,
+ Usif::RSoftwareComponentRegistry& aSoftwareRegistry, RFs& aFs )
{
CCaWidgetStorageHandler* self = new ( ELeave ) CCaWidgetStorageHandler(
- aStorage, aFs );
+ aStorage, aSoftwareRegistry, aFs );
CleanupStack::PushL( self );
self->ConstructL();
return self;
@@ -89,8 +91,7 @@
CCaWidgetStorageHandler::~CCaWidgetStorageHandler()
{
delete iParser;
- iSoftwareRegistry.Close();
- iWidgets.ResetAndDestroy();
+ iWidgetDBCache.ResetAndDestroy();
}
// ----------------------------------------------------------------------------
@@ -100,7 +101,7 @@
void CCaWidgetStorageHandler::SynchronizeL()
{
FetchWidgetsL();
- AddWidgetsL( iParser->WidgetsScanL( iWidgets ) );
+ AddWidgetsL( iParser->WidgetsScanL( iWidgetDBCache ) );
RemoveWidgetsL();
}
@@ -111,7 +112,7 @@
void CCaWidgetStorageHandler::AddL( const CCaWidgetDescription* aWidget )
{
CCaInnerEntry* entry = aWidget->GetEntryLC();
- UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
+ UpdateCompIdAndRemovableFlagL( aWidget->GetManifestFilePathName(), *entry );
iStorage->AddL( entry );
SetLocalizationsL( aWidget, entry->GetId() );
@@ -131,7 +132,7 @@
TUint aEntryId )
{
CCaInnerEntry* entry = aWidget->GetEntryLC();
- UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
+ UpdateCompIdAndRemovableFlagL( aWidget->GetManifestFilePathName(), *entry );
entry->SetId( aEntryId );
if ( !aWidget->IsMissing() && aWidget->IsUsed() )
{
@@ -147,7 +148,7 @@
SetLocalizationsL( aWidget, entry->GetId() );
- if ( !aWidget->IsMissing() )
+ if ( !aWidget->IsMissing() && ( entry->GetFlags() & ERemovable ) )
{
AddWidgetToDownloadCollectionL( entry );
}
@@ -160,25 +161,40 @@
//
void CCaWidgetStorageHandler::AddWidgetsL( const RWidgetArray& aWidgets )
{
- for ( TInt i = 0; i < aWidgets.Count(); i++ )
+ const TInt newWidgetsCount = aWidgets.Count();
+
+ for ( TInt i = 0; i < newWidgetsCount; ++i )
{
- aWidgets[i]->LocalizeTextsL();
- TInt index = iWidgets.Find( aWidgets[i], CCaWidgetDescription::Compare );
- if ( index != KErrNotFound )
+ CCaWidgetDescription *const newWidget = aWidgets[i];
+
+ newWidget->LocalizeTextsL();
+
+ const TInt dbCacheIndex =
+ iWidgetDBCache.Find(
+ newWidget, CCaWidgetDescription::CompareUri );
+
+ if ( dbCacheIndex != KErrNotFound )
{
- iWidgets[index]->SetValid( ETrue );
- if ( !iWidgets[index]->Compare( *aWidgets[i] )
- || iWidgets[index]->IsMissing() )
+ CCaWidgetDescription *const cachedWidget =
+ iWidgetDBCache[dbCacheIndex];
+
+ cachedWidget->SetValid( ETrue );
+
+ const TBool cachedDifferentThanNew =
+ !cachedWidget->Compare( *newWidget );
+
+ if ( cachedDifferentThanNew || cachedWidget->IsMissing() )
{
- aWidgets[i]->SetFlag( EMissing, iWidgets[index]->IsMissing() );
- aWidgets[i]->SetFlag( EUsed, iWidgets[index]->IsUsed() );
- aWidgets[i]->SetFlag( EVisible, iWidgets[index]->IsVisible() );
- UpdateL( aWidgets[i], iWidgets[index]->GetEntryId() );
+ newWidget->SetFlag( EMissing, cachedWidget->IsMissing() );
+ newWidget->SetFlag( EUsed, cachedWidget->IsUsed() );
+ newWidget->SetFlag( EVisible, cachedWidget->IsVisible() );
+
+ UpdateL( newWidget, cachedWidget->GetEntryId() );
}
}
else
{
- AddL( aWidgets[i] );
+ AddL( newWidget );
}
}
HbTextResolverSymbian::Init( _L(""), KLocalizationFilepathZ );
@@ -190,34 +206,36 @@
//
void CCaWidgetStorageHandler::RemoveWidgetsL()
{
- for ( TInt i = 0; i < iWidgets.Count(); i++ )
+ const TInt cacheCount = iWidgetDBCache.Count();
+ for ( TInt i = 0; i < cacheCount; ++i)
{
- if ( !iWidgets[i]->IsValid() )
+ CCaWidgetDescription *const cachedWidget = iWidgetDBCache[i];
+ if ( !cachedWidget->IsValid() )
{
- if ( iWidgets[i]->GetMmcId() != KNullDesC )
+ if ( cachedWidget->GetMmcId() != KNullDesC )
{
RBuf currentMmcId;
currentMmcId.CreateL( KMassStorageIdLength );
currentMmcId.CleanupClosePushL();
WidgetScannerUtils::CurrentMmcId( iFs, currentMmcId );
- if( iWidgets[i]->GetMmcId() == currentMmcId ||
- ( iWidgets[i]->GetMmcId() == KCaMassStorage() &&
+ if( cachedWidget->GetMmcId() == currentMmcId ||
+ ( cachedWidget->GetMmcId() == KCaMassStorage() &&
MassStorageNotInUse() ) )
{
//item was uninstalled so we remove its mmc id
- iWidgets[i]->RemoveMmcId();
- ClearVisibleFlagL( iWidgets[i] );
+ cachedWidget->RemoveMmcId();
+ ClearVisibleFlagL( cachedWidget );
}
else
{
- SetMissingFlagL( iWidgets[i] );
+ SetMissingFlagL( cachedWidget );
}
CleanupStack::PopAndDestroy( ¤tMmcId );
}
else
{
//item was uninstalled so we remove its mmc id
- ClearVisibleFlagL( iWidgets[i] );
+ ClearVisibleFlagL( cachedWidget );
}
}
}
@@ -276,11 +294,11 @@
CleanupResetAndDestroyPushL( entries );
iStorage->GetEntriesL( query, entries );
- iWidgets.ResetAndDestroy();
+ iWidgetDBCache.ResetAndDestroy();
for ( TInt i = 0; i < entries.Count(); i++ )
{
CCaWidgetDescription* widget = CCaWidgetDescription::NewLC( entries[i] );
- iWidgets.AppendL( widget ); //iWidgets takes ownership
+ iWidgetDBCache.AppendL( widget ); //iWidgets takes ownership
CleanupStack::Pop( widget );
}
CleanupStack::PopAndDestroy( &entries );
@@ -399,7 +417,7 @@
// ----------------------------------------------------------------------------
//
-void CCaWidgetStorageHandler::UpdateComponentIdL(
+void CCaWidgetStorageHandler::UpdateCompIdAndRemovableFlagL(
const TDesC& aManifestFilePathName, CCaInnerEntry& aEntry ) const
{
RArray<TComponentId> componentIds;
@@ -411,7 +429,7 @@
CleanupStack::PopAndDestroy( fileNameFilter );
- if ( componentIds.Count() == 1 )
+ if( componentIds.Count() == 1 )
{
RBuf newComponentId;
newComponentId.CleanupClosePushL();
@@ -425,13 +443,19 @@
const TBool componentIdAttributeFound = aEntry.FindAttribute(
KCaComponentId, oldComponentId );
- if ( !componentIdAttributeFound || oldComponentId.Compare(
+ if( !componentIdAttributeFound || oldComponentId.Compare(
newComponentId ) != 0 )
{
// 'add' or 'update' the component id attribute value
aEntry.AddAttributeL( KCaComponentId, newComponentId );
}
-
+ CComponentEntry* entry = CComponentEntry::NewLC();
+ iSoftwareRegistry.GetComponentL( componentIds[0] , *entry );
+ if( entry->IsRemovable() )
+ {
+ aEntry.SetFlags( aEntry.GetFlags() | ERemovable );
+ }
+ CleanupStack::PopAndDestroy( entry );
CleanupStack::PopAndDestroy( &oldComponentId );
CleanupStack::PopAndDestroy( &newComponentId );
}