--- a/contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp Tue Jun 01 11:30:17 2010 +0300
+++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp Fri Jun 11 16:13:51 2010 +0300
@@ -18,6 +18,8 @@
#include <badesca.h>
#include <usif/scr/screntries.h>
+#include <hbtextresolversymbian.h>
+
#include "widgetscannerutils.h"
#include "cawidgetstoragehandler.h"
#include "cadef.h"
@@ -26,41 +28,36 @@
#include "castorageproxy.h"
#include "caarraycleanup.inl"
#include "calocalizationentry.h"
-
+#include "cawidgetscannerparser.h"
#include "cawidgetscannerdef.h"
-
using namespace Usif;
-
-// ============================ MEMBER FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ============================z===
// -----------------------------------------------------------------------------
-// CCaWidgetStorageHandler::CCaWidgetStorageHandler
-// C++ default constructor can NOT contain any code, that
-// might leave.
+//
// -----------------------------------------------------------------------------
//
-CCaWidgetStorageHandler::CCaWidgetStorageHandler(
- CCaStorageProxy* aStorage, RFs& aFs )
+CCaWidgetStorageHandler::CCaWidgetStorageHandler( CCaStorageProxy* aStorage,
+ RFs& aFs )
{
iStorage = aStorage;
iFs = aFs;
}
// -----------------------------------------------------------------------------
-// CCaWidgetStorageHandler::ConstructL
-// Symbian 2nd phase constructor can leave.
+//
// -----------------------------------------------------------------------------
//
void CCaWidgetStorageHandler::ConstructL()
{
User::LeaveIfError( iSoftwareRegistry.Connect() );
+ iParser = CCaWidgetScannerParser::NewL( iFs );
}
// -----------------------------------------------------------------------------
-// CCaWidgetStorageHandler::NewL
-// Two-phased constructor.
+//
// -----------------------------------------------------------------------------
//
CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewL(
@@ -72,8 +69,7 @@
}
// -----------------------------------------------------------------------------
-// CCaWidgetStorageHandler::NewLC
-// Two-phased constructor.
+//
// -----------------------------------------------------------------------------
//
CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewLC(
@@ -87,24 +83,24 @@
}
// -----------------------------------------------------------------------------
-// Destructor
+//
// -----------------------------------------------------------------------------
//
CCaWidgetStorageHandler::~CCaWidgetStorageHandler()
{
+ delete iParser;
iSoftwareRegistry.Close();
iWidgets.ResetAndDestroy();
- iUpdatedIndexes.Close();
}
// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------
//
-void CCaWidgetStorageHandler::SynchronizeL( const RWidgetArray& aWidgets )
+void CCaWidgetStorageHandler::SynchronizeL()
{
FetchWidgetsL();
- AddWidgetsL( aWidgets );
+ AddWidgetsL( iParser->WidgetsScanL( iWidgets ) );
RemoveWidgetsL();
}
@@ -119,8 +115,8 @@
iStorage->AddL( entry );
SetLocalizationsL( aWidget, entry->GetId() );
-
- if( entry->GetFlags() & ERemovable )
+
+ if ( entry->GetFlags() & ERemovable )
{
AddWidgetToDownloadCollectionL( entry );
}
@@ -137,22 +133,21 @@
CCaInnerEntry* entry = aWidget->GetEntryLC();
UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
entry->SetId( aEntryId );
- if( !aWidget->IsMissing() && aWidget->IsUsed() )
+ if ( !aWidget->IsMissing() && aWidget->IsUsed() )
{
entry->SetFlags( entry->GetFlags() & ~EUsed );
}
TItemAppearance itemAppearanceChange = EItemAppearanceNotChanged;
- if( ( entry->GetFlags() & EMissing ) ||
- !( entry->GetFlags() & EVisible ) )
+ if ( ( entry->GetFlags() & EMissing ) || !( entry->GetFlags() & EVisible ) )
{
itemAppearanceChange = EItemAppeared;
}
entry->SetFlags( entry->GetFlags() & ~EMissing | EVisible );
iStorage->AddL( entry, EFalse, itemAppearanceChange );
-
+
SetLocalizationsL( aWidget, entry->GetId() );
-
- if( !aWidget->IsMissing() )
+
+ if ( !aWidget->IsMissing() )
{
AddWidgetToDownloadCollectionL( entry );
}
@@ -165,29 +160,28 @@
//
void CCaWidgetStorageHandler::AddWidgetsL( const RWidgetArray& aWidgets )
{
- iUpdatedIndexes.Reset();
- for( TInt i = 0; i < aWidgets.Count(); i++ )
+ for ( TInt i = 0; i < aWidgets.Count(); i++ )
{
aWidgets[i]->LocalizeTextsL();
- TInt index = iWidgets.Find(
- aWidgets[i], CCaWidgetDescription::Compare );
- if( index != KErrNotFound )
+ TInt index = iWidgets.Find( aWidgets[i], CCaWidgetDescription::Compare );
+ if ( index != KErrNotFound )
{
- if( !iWidgets[index]->Compare( *aWidgets[i] ) ||
- iWidgets[index]->IsMissing() )
+ iWidgets[index]->SetValid( ETrue );
+ if ( !iWidgets[index]->Compare( *aWidgets[i] )
+ || iWidgets[index]->IsMissing() )
{
- aWidgets[i]->SetMissing( iWidgets[index]->IsMissing() );
- aWidgets[i]->SetUsed( iWidgets[index]->IsUsed() );
- aWidgets[i]->SetVisible( iWidgets[index]->IsVisible() );
+ 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() );
}
- iUpdatedIndexes.AppendL( index );
}
else
{
AddL( aWidgets[i] );
}
}
+ HbTextResolverSymbian::Init( _L(""), KLocalizationFilepathZ );
}
// ----------------------------------------------------------------------------
@@ -196,11 +190,11 @@
//
void CCaWidgetStorageHandler::RemoveWidgetsL()
{
- for( TInt i = 0; i < iWidgets.Count(); i++ )
+ for ( TInt i = 0; i < iWidgets.Count(); i++ )
{
- if( iUpdatedIndexes.Find( i ) == KErrNotFound )
+ if ( !iWidgets[i]->IsValid() )
{
- if( iWidgets[i]->GetMmcId() != KNullDesC )
+ if ( iWidgets[i]->GetMmcId() != KNullDesC )
{
RBuf currentMmcId;
currentMmcId.CreateL( KMassStorageIdLength );
@@ -218,15 +212,12 @@
{
SetMissingFlagL( iWidgets[i] );
}
- CleanupStack::PopAndDestroy(¤tMmcId);
+ CleanupStack::PopAndDestroy( ¤tMmcId );
}
else
{
//item was uninstalled so we remove its mmc id
- if ( iWidgets[i]->IsVisible() )
- {
- ClearVisibleFlagL( iWidgets[i] );
- }
+ ClearVisibleFlagL( iWidgets[i] );
}
}
}
@@ -284,12 +275,11 @@
RPointerArray<CCaInnerEntry> entries;
CleanupResetAndDestroyPushL( entries );
iStorage->GetEntriesL( query, entries );
-
+
iWidgets.ResetAndDestroy();
- for( TInt i = 0; i < entries.Count(); i++ )
+ for ( TInt i = 0; i < entries.Count(); i++ )
{
- CCaWidgetDescription* widget = CCaWidgetDescription::NewLC(
- entries[i] );
+ CCaWidgetDescription* widget = CCaWidgetDescription::NewLC( entries[i] );
iWidgets.AppendL( widget ); //iWidgets takes ownership
CleanupStack::Pop( widget );
}
@@ -304,11 +294,11 @@
void CCaWidgetStorageHandler::SetMissingFlagL(
const CCaWidgetDescription* aWidget )
{
- if( !aWidget->IsMissing() )
+ if ( !aWidget->IsMissing() )
{
CCaInnerEntry* entry = aWidget->GetEntryLC();
- entry->SetFlags( entry->GetFlags() | EMissing );
- if( aWidget->IsUsed() )
+ entry->SetFlags( ( entry->GetFlags() | EMissing ) & ~EUninstall );
+ if ( aWidget->IsUsed() )
{
entry->SetFlags( entry->GetFlags() | EUsed );
}
@@ -324,10 +314,17 @@
void CCaWidgetStorageHandler::ClearVisibleFlagL(
const CCaWidgetDescription* aWidget )
{
- CCaInnerEntry* entry = aWidget->GetEntryLC();
- entry->SetFlags( entry->GetFlags() & ~EVisible & ~EMissing & ~EUsed );
- iStorage->AddL( entry, EFalse, EItemDisappeared );
- CleanupStack::PopAndDestroy( entry );
+ if ( aWidget->IsVisible() )
+ {
+ CCaInnerEntry* entry = aWidget->GetEntryLC();
+ entry->SetFlags( entry->GetFlags()
+ & ~EUninstall
+ & ~EVisible
+ & ~EMissing
+ & ~EUsed );
+ iStorage->AddL( entry, EFalse, EItemDisappeared );
+ CleanupStack::PopAndDestroy( entry );
+ }
}
// ----------------------------------------------------------------------------
@@ -355,24 +352,24 @@
// ----------------------------------------------------------------------------
//
-void CCaWidgetStorageHandler::SetLocalizationsL( const CCaWidgetDescription* aWidget,
- TInt aEntryId )
+void CCaWidgetStorageHandler::SetLocalizationsL(
+ const CCaWidgetDescription* aWidget, TInt aEntryId )
{
RBuf filename;
- filename.Create( aWidget->GetUri().Length() + 1 ); //1 for _
+ filename.CreateL( aWidget->GetUri().Length() + 1 ); //1 for _
CleanupClosePushL( filename );
filename.Copy( aWidget->GetUri() );
filename.Append( KWidgetScannerUnderline );
-
+
// prepare localizations
- if ( aWidget->GetTitle().Length() > 0 &&
- aWidget->GetTitle().Compare( aWidget->GetStringIdTitle() ) )
- // lets do not add localization when key and value are identical
+ if ( aWidget->GetTitle().Length() > 0 && aWidget->GetTitle().Compare(
+ aWidget->GetStringIdTitle() ) )
+ // lets do not add localization when key and value are identical
{
CCaLocalizationEntry* titleEntry = CCaLocalizationEntry::NewL();
CleanupStack::PushL( titleEntry );
- titleEntry->SetTableNameL( KWidgetScannerCaEntry );
- titleEntry->SetAttributeNameL( KWidgetScannerEnText );
+ titleEntry->SetTableNameL( KLocalizationCaEntry );
+ titleEntry->SetAttributeNameL( KLocalizationEnText );
titleEntry->SetStringIdL( aWidget->GetStringIdTitle() );
titleEntry->SetQmFilenameL( filename );
titleEntry->SetRowId( aEntryId );
@@ -382,12 +379,12 @@
if ( aWidget->GetDescription().Length() > 0 &&
aWidget->GetDescription().Compare(
aWidget->GetStringIdDescription() ) )
- // lets do not add localization when key and value are identical
+ // lets do not add localization when key and value are identical
{
CCaLocalizationEntry* descEntry = CCaLocalizationEntry::NewL();
CleanupStack::PushL( descEntry );
- descEntry->SetTableNameL( KWidgetScannerCaEntry );
- descEntry->SetAttributeNameL( KWidgetScannerEnDescription );
+ descEntry->SetTableNameL( KLocalizationCaEntry );
+ descEntry->SetAttributeNameL( KLocalizationEnDescription );
descEntry->SetStringIdL( aWidget->GetStringIdDescription() );
descEntry->SetQmFilenameL( filename );
descEntry->SetRowId( aEntryId );
@@ -402,41 +399,39 @@
// ----------------------------------------------------------------------------
//
-void CCaWidgetStorageHandler::UpdateComponentIdL(
- const TDesC& aManifestFilePathName,
- CCaInnerEntry& aEntry ) const
+void CCaWidgetStorageHandler::UpdateComponentIdL(
+ const TDesC& aManifestFilePathName, CCaInnerEntry& aEntry ) const
{
RArray<TComponentId> componentIds;
CleanupClosePushL( componentIds );
-
+
CComponentFilter* const fileNameFilter = CComponentFilter::NewLC();
fileNameFilter->SetFileL( aManifestFilePathName );
iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter );
CleanupStack::PopAndDestroy( fileNameFilter );
-
+
if ( componentIds.Count() == 1 )
{
RBuf newComponentId;
newComponentId.CleanupClosePushL();
newComponentId.CreateL( sizeof(TComponentId) + 1 );
newComponentId.AppendNum( componentIds[0] );
-
+
RBuf oldComponentId;
oldComponentId.CleanupClosePushL();
oldComponentId.CreateL( KCaMaxAttrValueLen );
-
- const TBool componentIdAttributeFound =
- aEntry.FindAttribute( KCaComponentId, oldComponentId );
-
- if ( !componentIdAttributeFound
- || oldComponentId.Compare( newComponentId ) != 0 )
+
+ const TBool componentIdAttributeFound = aEntry.FindAttribute(
+ KCaComponentId, oldComponentId );
+
+ if ( !componentIdAttributeFound || oldComponentId.Compare(
+ newComponentId ) != 0 )
{
// 'add' or 'update' the component id attribute value
- aEntry.AddAttributeL( KCaComponentId,
- newComponentId );
+ aEntry.AddAttributeL( KCaComponentId, newComponentId );
}
-
+
CleanupStack::PopAndDestroy( &oldComponentId );
CleanupStack::PopAndDestroy( &newComponentId );
}
@@ -444,5 +439,4 @@
CleanupStack::PopAndDestroy( &componentIds );
}
-
// End of File