110 // ---------------------------------------------------------------------------- |
110 // ---------------------------------------------------------------------------- |
111 // |
111 // |
112 void CCaWidgetStorageHandler::AddL( const CCaWidgetDescription* aWidget ) |
112 void CCaWidgetStorageHandler::AddL( const CCaWidgetDescription* aWidget ) |
113 { |
113 { |
114 CCaInnerEntry* entry = aWidget->GetEntryLC(); |
114 CCaInnerEntry* entry = aWidget->GetEntryLC(); |
115 UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry ); |
115 UpdateCompIdAndRemovableFlagL( aWidget->GetManifestFilePathName(), *entry ); |
116 iStorage->AddL( entry ); |
116 iStorage->AddL( entry ); |
117 |
117 |
118 SetLocalizationsL( aWidget, entry->GetId() ); |
118 SetLocalizationsL( aWidget, entry->GetId() ); |
119 |
119 |
120 if ( entry->GetFlags() & ERemovable ) |
120 if ( entry->GetFlags() & ERemovable ) |
130 // |
130 // |
131 void CCaWidgetStorageHandler::UpdateL( const CCaWidgetDescription* aWidget, |
131 void CCaWidgetStorageHandler::UpdateL( const CCaWidgetDescription* aWidget, |
132 TUint aEntryId ) |
132 TUint aEntryId ) |
133 { |
133 { |
134 CCaInnerEntry* entry = aWidget->GetEntryLC(); |
134 CCaInnerEntry* entry = aWidget->GetEntryLC(); |
135 UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry ); |
135 UpdateCompIdAndRemovableFlagL( aWidget->GetManifestFilePathName(), *entry ); |
136 entry->SetId( aEntryId ); |
136 entry->SetId( aEntryId ); |
137 if ( !aWidget->IsMissing() && aWidget->IsUsed() ) |
137 if ( !aWidget->IsMissing() && aWidget->IsUsed() ) |
138 { |
138 { |
139 entry->SetFlags( entry->GetFlags() & ~EUsed ); |
139 entry->SetFlags( entry->GetFlags() & ~EUsed ); |
140 } |
140 } |
146 entry->SetFlags( entry->GetFlags() & ~EMissing | EVisible ); |
146 entry->SetFlags( entry->GetFlags() & ~EMissing | EVisible ); |
147 iStorage->AddL( entry, EFalse, itemAppearanceChange ); |
147 iStorage->AddL( entry, EFalse, itemAppearanceChange ); |
148 |
148 |
149 SetLocalizationsL( aWidget, entry->GetId() ); |
149 SetLocalizationsL( aWidget, entry->GetId() ); |
150 |
150 |
151 if ( !aWidget->IsMissing() ) |
151 if ( !aWidget->IsMissing() && ( entry->GetFlags() & ERemovable ) ) |
152 { |
152 { |
153 AddWidgetToDownloadCollectionL( entry ); |
153 AddWidgetToDownloadCollectionL( entry ); |
154 } |
154 } |
155 CleanupStack::PopAndDestroy( entry ); |
155 CleanupStack::PopAndDestroy( entry ); |
156 } |
156 } |
398 // ---------------------------------------------------------------------------- |
398 // ---------------------------------------------------------------------------- |
399 // |
399 // |
400 // ---------------------------------------------------------------------------- |
400 // ---------------------------------------------------------------------------- |
401 // |
401 // |
402 |
402 |
403 void CCaWidgetStorageHandler::UpdateComponentIdL( |
403 void CCaWidgetStorageHandler::UpdateCompIdAndRemovableFlagL( |
404 const TDesC& aManifestFilePathName, CCaInnerEntry& aEntry ) const |
404 const TDesC& aManifestFilePathName, CCaInnerEntry& aEntry ) const |
405 { |
405 { |
406 RArray<TComponentId> componentIds; |
406 RArray<TComponentId> componentIds; |
407 CleanupClosePushL( componentIds ); |
407 CleanupClosePushL( componentIds ); |
408 |
408 |
410 fileNameFilter->SetFileL( aManifestFilePathName ); |
410 fileNameFilter->SetFileL( aManifestFilePathName ); |
411 iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter ); |
411 iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter ); |
412 |
412 |
413 CleanupStack::PopAndDestroy( fileNameFilter ); |
413 CleanupStack::PopAndDestroy( fileNameFilter ); |
414 |
414 |
415 if ( componentIds.Count() == 1 ) |
415 if( componentIds.Count() == 1 ) |
416 { |
416 { |
417 RBuf newComponentId; |
417 RBuf newComponentId; |
418 newComponentId.CleanupClosePushL(); |
418 newComponentId.CleanupClosePushL(); |
419 newComponentId.CreateL( sizeof(TComponentId) + 1 ); |
419 newComponentId.CreateL( sizeof(TComponentId) + 1 ); |
420 newComponentId.AppendNum( componentIds[0] ); |
420 newComponentId.AppendNum( componentIds[0] ); |
424 oldComponentId.CreateL( KCaMaxAttrValueLen ); |
424 oldComponentId.CreateL( KCaMaxAttrValueLen ); |
425 |
425 |
426 const TBool componentIdAttributeFound = aEntry.FindAttribute( |
426 const TBool componentIdAttributeFound = aEntry.FindAttribute( |
427 KCaComponentId, oldComponentId ); |
427 KCaComponentId, oldComponentId ); |
428 |
428 |
429 if ( !componentIdAttributeFound || oldComponentId.Compare( |
429 if( !componentIdAttributeFound || oldComponentId.Compare( |
430 newComponentId ) != 0 ) |
430 newComponentId ) != 0 ) |
431 { |
431 { |
432 // 'add' or 'update' the component id attribute value |
432 // 'add' or 'update' the component id attribute value |
433 aEntry.AddAttributeL( KCaComponentId, newComponentId ); |
433 aEntry.AddAttributeL( KCaComponentId, newComponentId ); |
434 } |
434 } |
435 |
435 CComponentEntry* entry = CComponentEntry::NewLC(); |
|
436 iSoftwareRegistry.GetComponentL( componentIds[0] , *entry ); |
|
437 if( entry->IsRemovable() ) |
|
438 { |
|
439 aEntry.SetFlags( aEntry.GetFlags() | ERemovable ); |
|
440 } |
|
441 CleanupStack::PopAndDestroy( entry ); |
436 CleanupStack::PopAndDestroy( &oldComponentId ); |
442 CleanupStack::PopAndDestroy( &oldComponentId ); |
437 CleanupStack::PopAndDestroy( &newComponentId ); |
443 CleanupStack::PopAndDestroy( &newComponentId ); |
438 } |
444 } |
439 |
445 |
440 CleanupStack::PopAndDestroy( &componentIds ); |
446 CleanupStack::PopAndDestroy( &componentIds ); |