contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp
changeset 103 b99b84bcd2d1
parent 83 156f692b1687
child 104 9b022b1f357c
equal deleted inserted replaced
83:156f692b1687 103:b99b84bcd2d1
    16  */
    16  */
    17 // INCLUDE FILES
    17 // INCLUDE FILES
    18 
    18 
    19 #include <badesca.h>
    19 #include <badesca.h>
    20 #include <usif/scr/screntries.h>
    20 #include <usif/scr/screntries.h>
       
    21 #include <hbtextresolversymbian.h>
       
    22 
    21 #include "widgetscannerutils.h"
    23 #include "widgetscannerutils.h"
    22 #include "cawidgetstoragehandler.h"
    24 #include "cawidgetstoragehandler.h"
    23 #include "cadef.h"
    25 #include "cadef.h"
    24 #include "cainnerentry.h"
    26 #include "cainnerentry.h"
    25 #include "cainnerquery.h"
    27 #include "cainnerquery.h"
    26 #include "castorageproxy.h"
    28 #include "castorageproxy.h"
    27 #include "caarraycleanup.inl"
    29 #include "caarraycleanup.inl"
    28 #include "calocalizationentry.h"
    30 #include "calocalizationentry.h"
    29 
    31 #include "cawidgetscannerparser.h"
    30 #include "cawidgetscannerdef.h"
    32 #include "cawidgetscannerdef.h"
    31 
    33 
    32 
       
    33 using namespace Usif;
    34 using namespace Usif;
    34 
    35 
    35 
    36 // ============================ MEMBER FUNCTIONS ============================z===
    36 // ============================ MEMBER FUNCTIONS ===============================
    37 
    37 
    38 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    39 // 
    39 // CCaWidgetStorageHandler::CCaWidgetStorageHandler
    40 // -----------------------------------------------------------------------------
    40 // C++ default constructor can NOT contain any code, that
    41 //
    41 // might leave.
    42 CCaWidgetStorageHandler::CCaWidgetStorageHandler( CCaStorageProxy* aStorage,
    42 // -----------------------------------------------------------------------------
    43         RFs& aFs )
    43 //
       
    44 CCaWidgetStorageHandler::CCaWidgetStorageHandler(
       
    45         CCaStorageProxy* aStorage, RFs& aFs )
       
    46     {
    44     {
    47     iStorage = aStorage;
    45     iStorage = aStorage;
    48     iFs = aFs;
    46     iFs = aFs;
    49     }
    47     }
    50 
    48 
    51 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    52 // CCaWidgetStorageHandler::ConstructL
    50 // 
    53 // Symbian 2nd phase constructor can leave.
       
    54 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    55 //
    52 //
    56 void CCaWidgetStorageHandler::ConstructL()
    53 void CCaWidgetStorageHandler::ConstructL()
    57     {
    54     {
    58     User::LeaveIfError( iSoftwareRegistry.Connect() );
    55     User::LeaveIfError( iSoftwareRegistry.Connect() );
    59     }
    56     iParser = CCaWidgetScannerParser::NewL( iFs );
    60 
    57     }
    61 // -----------------------------------------------------------------------------
    58 
    62 // CCaWidgetStorageHandler::NewL
    59 // -----------------------------------------------------------------------------
    63 // Two-phased constructor.
    60 // 
    64 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    65 //
    62 //
    66 CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewL(
    63 CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewL(
    67         CCaStorageProxy* aStorage, RFs& aFs )
    64         CCaStorageProxy* aStorage, RFs& aFs )
    68     {
    65     {
    70     CleanupStack::Pop( self );
    67     CleanupStack::Pop( self );
    71     return self;
    68     return self;
    72     }
    69     }
    73 
    70 
    74 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    75 // CCaWidgetStorageHandler::NewLC
    72 // 
    76 // Two-phased constructor.
       
    77 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    78 //
    74 //
    79 CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewLC(
    75 CCaWidgetStorageHandler* CCaWidgetStorageHandler::NewLC(
    80         CCaStorageProxy* aStorage, RFs& aFs )
    76         CCaStorageProxy* aStorage, RFs& aFs )
    81     {
    77     {
    85     self->ConstructL();
    81     self->ConstructL();
    86     return self;
    82     return self;
    87     }
    83     }
    88 
    84 
    89 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    90 // Destructor
    86 // 
    91 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    92 //
    88 //
    93 CCaWidgetStorageHandler::~CCaWidgetStorageHandler()
    89 CCaWidgetStorageHandler::~CCaWidgetStorageHandler()
    94     {
    90     {
       
    91     delete iParser;
    95     iSoftwareRegistry.Close();
    92     iSoftwareRegistry.Close();
    96     iWidgets.ResetAndDestroy();
    93     iWidgets.ResetAndDestroy();
    97     iUpdatedIndexes.Close();
    94     }
    98     }
    95 
    99 
    96 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    97 //
   101 //
    98 // ----------------------------------------------------------------------------
   102 // ----------------------------------------------------------------------------
    99 //
   103 //
   100 void CCaWidgetStorageHandler::SynchronizeL()
   104 void CCaWidgetStorageHandler::SynchronizeL( const RWidgetArray& aWidgets )
       
   105     {
   101     {
   106     FetchWidgetsL();
   102     FetchWidgetsL();
   107     AddWidgetsL( aWidgets );
   103     AddWidgetsL( iParser->WidgetsScanL( iWidgets ) );
   108     RemoveWidgetsL();
   104     RemoveWidgetsL();
   109     }
   105     }
   110 
   106 
   111 // ----------------------------------------------------------------------------
   107 // ----------------------------------------------------------------------------
   112 //
   108 //
   117     CCaInnerEntry* entry = aWidget->GetEntryLC();
   113     CCaInnerEntry* entry = aWidget->GetEntryLC();
   118     UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
   114     UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
   119     iStorage->AddL( entry );
   115     iStorage->AddL( entry );
   120 
   116 
   121     SetLocalizationsL( aWidget, entry->GetId() );
   117     SetLocalizationsL( aWidget, entry->GetId() );
   122     
   118 
   123     if( entry->GetFlags() & ERemovable )
   119     if ( entry->GetFlags() & ERemovable )
   124         {
   120         {
   125         AddWidgetToDownloadCollectionL( entry );
   121         AddWidgetToDownloadCollectionL( entry );
   126         }
   122         }
   127     CleanupStack::PopAndDestroy( entry );
   123     CleanupStack::PopAndDestroy( entry );
   128     }
   124     }
   135         TUint aEntryId )
   131         TUint aEntryId )
   136     {
   132     {
   137     CCaInnerEntry* entry = aWidget->GetEntryLC();
   133     CCaInnerEntry* entry = aWidget->GetEntryLC();
   138     UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
   134     UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
   139     entry->SetId( aEntryId );
   135     entry->SetId( aEntryId );
   140     if( !aWidget->IsMissing() && aWidget->IsUsed() )
   136     if ( !aWidget->IsMissing() && aWidget->IsUsed() )
   141         {
   137         {
   142         entry->SetFlags( entry->GetFlags() & ~EUsed );
   138         entry->SetFlags( entry->GetFlags() & ~EUsed );
   143         }
   139         }
   144     TItemAppearance itemAppearanceChange = EItemAppearanceNotChanged;
   140     TItemAppearance itemAppearanceChange = EItemAppearanceNotChanged;
   145     if( ( entry->GetFlags() & EMissing ) ||
   141     if ( ( entry->GetFlags() & EMissing ) || !( entry->GetFlags() & EVisible ) )
   146         !( entry->GetFlags() & EVisible ) )
       
   147         {
   142         {
   148         itemAppearanceChange = EItemAppeared;
   143         itemAppearanceChange = EItemAppeared;
   149         }
   144         }
   150     entry->SetFlags( entry->GetFlags() & ~EMissing | EVisible );
   145     entry->SetFlags( entry->GetFlags() & ~EMissing | EVisible );
   151     iStorage->AddL( entry, EFalse, itemAppearanceChange );
   146     iStorage->AddL( entry, EFalse, itemAppearanceChange );
   152     
   147 
   153     SetLocalizationsL( aWidget, entry->GetId() );
   148     SetLocalizationsL( aWidget, entry->GetId() );
   154     
   149 
   155     if( !aWidget->IsMissing() )
   150     if ( !aWidget->IsMissing() )
   156         {
   151         {
   157         AddWidgetToDownloadCollectionL( entry );
   152         AddWidgetToDownloadCollectionL( entry );
   158         }
   153         }
   159     CleanupStack::PopAndDestroy( entry );
   154     CleanupStack::PopAndDestroy( entry );
   160     }
   155     }
   163 //
   158 //
   164 // ----------------------------------------------------------------------------
   159 // ----------------------------------------------------------------------------
   165 //
   160 //
   166 void CCaWidgetStorageHandler::AddWidgetsL( const RWidgetArray& aWidgets )
   161 void CCaWidgetStorageHandler::AddWidgetsL( const RWidgetArray& aWidgets )
   167     {
   162     {
   168     iUpdatedIndexes.Reset();
   163     for ( TInt i = 0; i < aWidgets.Count(); i++ )
   169     for( TInt i = 0; i < aWidgets.Count(); i++ )
       
   170         {
   164         {
   171         aWidgets[i]->LocalizeTextsL();
   165         aWidgets[i]->LocalizeTextsL();
   172         TInt index = iWidgets.Find(
   166         TInt index = iWidgets.Find( aWidgets[i], CCaWidgetDescription::Compare );
   173                 aWidgets[i], CCaWidgetDescription::Compare );
   167         if ( index != KErrNotFound )
   174         if( index != KErrNotFound )
   168             {
   175             {
   169             iWidgets[index]->SetValid( ETrue );
   176             if( !iWidgets[index]->Compare( *aWidgets[i] ) ||
   170             if ( !iWidgets[index]->Compare( *aWidgets[i] )
   177                     iWidgets[index]->IsMissing() )
   171                     || iWidgets[index]->IsMissing() )
   178                 {
   172                 {
   179                 aWidgets[i]->SetMissing( iWidgets[index]->IsMissing() );
   173                 aWidgets[i]->SetFlag( EMissing, iWidgets[index]->IsMissing() );
   180                 aWidgets[i]->SetUsed( iWidgets[index]->IsUsed() );
   174                 aWidgets[i]->SetFlag( EUsed, iWidgets[index]->IsUsed() );
   181                 aWidgets[i]->SetVisible( iWidgets[index]->IsVisible() );
   175                 aWidgets[i]->SetFlag( EVisible, iWidgets[index]->IsVisible() );
   182                 UpdateL( aWidgets[i], iWidgets[index]->GetEntryId() );
   176                 UpdateL( aWidgets[i], iWidgets[index]->GetEntryId() );
   183                 }
   177                 }
   184             iUpdatedIndexes.AppendL( index );
       
   185             }
   178             }
   186         else
   179         else
   187             {
   180             {
   188             AddL( aWidgets[i] );
   181             AddL( aWidgets[i] );
   189             }
   182             }
   190         }
   183         }
       
   184     HbTextResolverSymbian::Init( _L(""), KLocalizationFilepathZ );
   191     }
   185     }
   192 
   186 
   193 // ----------------------------------------------------------------------------
   187 // ----------------------------------------------------------------------------
   194 //
   188 //
   195 // ----------------------------------------------------------------------------
   189 // ----------------------------------------------------------------------------
   196 //
   190 //
   197 void CCaWidgetStorageHandler::RemoveWidgetsL()
   191 void CCaWidgetStorageHandler::RemoveWidgetsL()
   198     {
   192     {
   199     for( TInt i = 0; i < iWidgets.Count(); i++ )
   193     for ( TInt i = 0; i < iWidgets.Count(); i++ )
   200         {
   194         {
   201         if( iUpdatedIndexes.Find( i ) == KErrNotFound )
   195         if ( !iWidgets[i]->IsValid() )
   202             {
   196             {
   203             if( iWidgets[i]->GetMmcId() != KNullDesC )
   197             if ( iWidgets[i]->GetMmcId() != KNullDesC )
   204                 {
   198                 {
   205                 RBuf currentMmcId;
   199                 RBuf currentMmcId;
   206                 currentMmcId.CreateL( KMassStorageIdLength );
   200                 currentMmcId.CreateL( KMassStorageIdLength );
   207                 currentMmcId.CleanupClosePushL();
   201                 currentMmcId.CleanupClosePushL();
   208                 WidgetScannerUtils::CurrentMmcId( iFs, currentMmcId );
   202                 WidgetScannerUtils::CurrentMmcId( iFs, currentMmcId );
   216                     }
   210                     }
   217                 else
   211                 else
   218                     {
   212                     {
   219                     SetMissingFlagL( iWidgets[i] );
   213                     SetMissingFlagL( iWidgets[i] );
   220                     }
   214                     }
   221                 CleanupStack::PopAndDestroy(&currentMmcId);
   215                 CleanupStack::PopAndDestroy( &currentMmcId );
   222                 }
   216                 }
   223             else
   217             else
   224                 {
   218                 {
   225                 //item was uninstalled so we remove its mmc id
   219                 //item was uninstalled so we remove its mmc id
   226                 if ( iWidgets[i]->IsVisible() )
   220                 ClearVisibleFlagL( iWidgets[i] );
   227                     {
       
   228                     ClearVisibleFlagL( iWidgets[i] );
       
   229                     }
       
   230                 }
   221                 }
   231             }
   222             }
   232         }
   223         }
   233     }
   224     }
   234 
   225 
   282     CleanupStack::Pop( widgetType );
   273     CleanupStack::Pop( widgetType );
   283 
   274 
   284     RPointerArray<CCaInnerEntry> entries;
   275     RPointerArray<CCaInnerEntry> entries;
   285     CleanupResetAndDestroyPushL( entries );
   276     CleanupResetAndDestroyPushL( entries );
   286     iStorage->GetEntriesL( query, entries );
   277     iStorage->GetEntriesL( query, entries );
   287        
   278 
   288     iWidgets.ResetAndDestroy();
   279     iWidgets.ResetAndDestroy();
   289     for( TInt i = 0; i < entries.Count(); i++ )
   280     for ( TInt i = 0; i < entries.Count(); i++ )
   290         {
   281         {
   291         CCaWidgetDescription* widget = CCaWidgetDescription::NewLC(
   282         CCaWidgetDescription* widget = CCaWidgetDescription::NewLC( entries[i] );
   292                 entries[i] );
       
   293         iWidgets.AppendL( widget ); //iWidgets takes ownership
   283         iWidgets.AppendL( widget ); //iWidgets takes ownership
   294         CleanupStack::Pop( widget );
   284         CleanupStack::Pop( widget );
   295         }
   285         }
   296     CleanupStack::PopAndDestroy( &entries );
   286     CleanupStack::PopAndDestroy( &entries );
   297     CleanupStack::PopAndDestroy( query );
   287     CleanupStack::PopAndDestroy( query );
   302 // ----------------------------------------------------------------------------
   292 // ----------------------------------------------------------------------------
   303 //
   293 //
   304 void CCaWidgetStorageHandler::SetMissingFlagL(
   294 void CCaWidgetStorageHandler::SetMissingFlagL(
   305         const CCaWidgetDescription* aWidget )
   295         const CCaWidgetDescription* aWidget )
   306     {
   296     {
   307     if( !aWidget->IsMissing() )
   297     if ( !aWidget->IsMissing() )
   308         {
   298         {
   309         CCaInnerEntry* entry = aWidget->GetEntryLC();
   299         CCaInnerEntry* entry = aWidget->GetEntryLC();
   310         entry->SetFlags( entry->GetFlags() | EMissing );
   300         entry->SetFlags( ( entry->GetFlags() | EMissing ) & ~EUninstall );
   311         if( aWidget->IsUsed() )
   301         if ( aWidget->IsUsed() )
   312             {
   302             {
   313             entry->SetFlags( entry->GetFlags() | EUsed );
   303             entry->SetFlags( entry->GetFlags() | EUsed );
   314             }
   304             }
   315         iStorage->AddL( entry, EFalse, EItemDisappeared );
   305         iStorage->AddL( entry, EFalse, EItemDisappeared );
   316         CleanupStack::PopAndDestroy( entry );
   306         CleanupStack::PopAndDestroy( entry );
   322 // ----------------------------------------------------------------------------
   312 // ----------------------------------------------------------------------------
   323 //
   313 //
   324 void CCaWidgetStorageHandler::ClearVisibleFlagL(
   314 void CCaWidgetStorageHandler::ClearVisibleFlagL(
   325         const CCaWidgetDescription* aWidget )
   315         const CCaWidgetDescription* aWidget )
   326     {
   316     {
   327     CCaInnerEntry* entry = aWidget->GetEntryLC();
   317     if ( aWidget->IsVisible() )
   328     entry->SetFlags( entry->GetFlags() & ~EVisible & ~EMissing & ~EUsed );
   318         {
   329     iStorage->AddL( entry, EFalse, EItemDisappeared );
   319         CCaInnerEntry* entry = aWidget->GetEntryLC();
   330     CleanupStack::PopAndDestroy( entry );
   320         entry->SetFlags( entry->GetFlags()
       
   321                 & ~EUninstall
       
   322                 & ~EVisible 
       
   323                 & ~EMissing 
       
   324                 & ~EUsed );
       
   325         iStorage->AddL( entry, EFalse, EItemDisappeared );
       
   326         CleanupStack::PopAndDestroy( entry );
       
   327         }
   331     }
   328     }
   332 
   329 
   333 // ----------------------------------------------------------------------------
   330 // ----------------------------------------------------------------------------
   334 //
   331 //
   335 // ----------------------------------------------------------------------------
   332 // ----------------------------------------------------------------------------
   353 // ----------------------------------------------------------------------------
   350 // ----------------------------------------------------------------------------
   354 //
   351 //
   355 // ----------------------------------------------------------------------------
   352 // ----------------------------------------------------------------------------
   356 //
   353 //
   357 
   354 
   358 void CCaWidgetStorageHandler::SetLocalizationsL(  const CCaWidgetDescription* aWidget,
   355 void CCaWidgetStorageHandler::SetLocalizationsL(
   359         TInt aEntryId  )
   356         const CCaWidgetDescription* aWidget, TInt aEntryId )
   360     {
   357     {
   361     RBuf filename;
   358     RBuf filename;
   362     filename.Create( aWidget->GetUri().Length() + 1 ); //1 for _
   359     filename.CreateL( aWidget->GetUri().Length() + 1 ); //1 for _
   363     CleanupClosePushL( filename );
   360     CleanupClosePushL( filename );
   364     filename.Copy( aWidget->GetUri() );
   361     filename.Copy( aWidget->GetUri() );
   365     filename.Append( KWidgetScannerUnderline );
   362     filename.Append( KWidgetScannerUnderline );
   366     
   363 
   367     // prepare localizations
   364     // prepare localizations
   368     if ( aWidget->GetTitle().Length() > 0 &&
   365     if ( aWidget->GetTitle().Length() > 0 && aWidget->GetTitle().Compare(
   369             aWidget->GetTitle().Compare( aWidget->GetStringIdTitle() ) )
   366             aWidget->GetStringIdTitle() ) )
   370         // lets do not add localization when key and value are identical
   367     // lets do not add localization when key and value are identical
   371         {
   368         {
   372         CCaLocalizationEntry* titleEntry = CCaLocalizationEntry::NewL();
   369         CCaLocalizationEntry* titleEntry = CCaLocalizationEntry::NewL();
   373         CleanupStack::PushL( titleEntry );
   370         CleanupStack::PushL( titleEntry );
   374         titleEntry->SetTableNameL( KWidgetScannerCaEntry );
   371         titleEntry->SetTableNameL( KLocalizationCaEntry );
   375         titleEntry->SetAttributeNameL( KWidgetScannerEnText );
   372         titleEntry->SetAttributeNameL( KLocalizationEnText );
   376         titleEntry->SetStringIdL( aWidget->GetStringIdTitle() );
   373         titleEntry->SetStringIdL( aWidget->GetStringIdTitle() );
   377         titleEntry->SetQmFilenameL( filename );
   374         titleEntry->SetQmFilenameL( filename );
   378         titleEntry->SetRowId( aEntryId );
   375         titleEntry->SetRowId( aEntryId );
   379         iStorage->AddLocalizationL( *titleEntry );
   376         iStorage->AddLocalizationL( *titleEntry );
   380         CleanupStack::PopAndDestroy( titleEntry );
   377         CleanupStack::PopAndDestroy( titleEntry );
   381         }
   378         }
   382     if ( aWidget->GetDescription().Length() > 0 &&
   379     if ( aWidget->GetDescription().Length() > 0 &&
   383             aWidget->GetDescription().Compare(
   380             aWidget->GetDescription().Compare(
   384                     aWidget->GetStringIdDescription() ) )
   381                     aWidget->GetStringIdDescription() ) )
   385         // lets do not add localization when key and value are identical
   382     // lets do not add localization when key and value are identical
   386         {
   383         {
   387         CCaLocalizationEntry* descEntry = CCaLocalizationEntry::NewL();
   384         CCaLocalizationEntry* descEntry = CCaLocalizationEntry::NewL();
   388         CleanupStack::PushL( descEntry );
   385         CleanupStack::PushL( descEntry );
   389         descEntry->SetTableNameL( KWidgetScannerCaEntry );
   386         descEntry->SetTableNameL( KLocalizationCaEntry );
   390         descEntry->SetAttributeNameL( KWidgetScannerEnDescription );
   387         descEntry->SetAttributeNameL( KLocalizationEnDescription );
   391         descEntry->SetStringIdL( aWidget->GetStringIdDescription() );
   388         descEntry->SetStringIdL( aWidget->GetStringIdDescription() );
   392         descEntry->SetQmFilenameL( filename );
   389         descEntry->SetQmFilenameL( filename );
   393         descEntry->SetRowId( aEntryId );
   390         descEntry->SetRowId( aEntryId );
   394         iStorage->AddLocalizationL( *descEntry );
   391         iStorage->AddLocalizationL( *descEntry );
   395         CleanupStack::PopAndDestroy( descEntry );
   392         CleanupStack::PopAndDestroy( descEntry );
   400 // ----------------------------------------------------------------------------
   397 // ----------------------------------------------------------------------------
   401 //
   398 //
   402 // ----------------------------------------------------------------------------
   399 // ----------------------------------------------------------------------------
   403 //
   400 //
   404 
   401 
   405 void CCaWidgetStorageHandler::UpdateComponentIdL( 
   402 void CCaWidgetStorageHandler::UpdateComponentIdL(
   406     const TDesC& aManifestFilePathName, 
   403         const TDesC& aManifestFilePathName, CCaInnerEntry& aEntry ) const
   407     CCaInnerEntry& aEntry ) const
       
   408     {
   404     {
   409     RArray<TComponentId> componentIds;
   405     RArray<TComponentId> componentIds;
   410     CleanupClosePushL( componentIds );
   406     CleanupClosePushL( componentIds );
   411     
   407 
   412     CComponentFilter* const fileNameFilter = CComponentFilter::NewLC();
   408     CComponentFilter* const fileNameFilter = CComponentFilter::NewLC();
   413     fileNameFilter->SetFileL( aManifestFilePathName );
   409     fileNameFilter->SetFileL( aManifestFilePathName );
   414     iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter );
   410     iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter );
   415 
   411 
   416     CleanupStack::PopAndDestroy( fileNameFilter );
   412     CleanupStack::PopAndDestroy( fileNameFilter );
   417     
   413 
   418     if ( componentIds.Count() == 1 )
   414     if ( componentIds.Count() == 1 )
   419         {
   415         {
   420         RBuf newComponentId;
   416         RBuf newComponentId;
   421         newComponentId.CleanupClosePushL();
   417         newComponentId.CleanupClosePushL();
   422         newComponentId.CreateL( sizeof(TComponentId) + 1 );
   418         newComponentId.CreateL( sizeof(TComponentId) + 1 );
   423         newComponentId.AppendNum( componentIds[0] );
   419         newComponentId.AppendNum( componentIds[0] );
   424         
   420 
   425         RBuf oldComponentId;
   421         RBuf oldComponentId;
   426         oldComponentId.CleanupClosePushL();
   422         oldComponentId.CleanupClosePushL();
   427         oldComponentId.CreateL( KCaMaxAttrValueLen );
   423         oldComponentId.CreateL( KCaMaxAttrValueLen );
   428         
   424 
   429         const TBool componentIdAttributeFound = 
   425         const TBool componentIdAttributeFound = aEntry.FindAttribute(
   430             aEntry.FindAttribute( KCaComponentId, oldComponentId );
   426                 KCaComponentId, oldComponentId );
   431               
   427 
   432         if ( !componentIdAttributeFound 
   428         if ( !componentIdAttributeFound || oldComponentId.Compare(
   433             || oldComponentId.Compare( newComponentId ) != 0 )
   429                 newComponentId ) != 0 )
   434             {
   430             {
   435             // 'add' or 'update' the component id attribute value
   431             // 'add' or 'update' the component id attribute value
   436             aEntry.AddAttributeL( KCaComponentId, 
   432             aEntry.AddAttributeL( KCaComponentId, newComponentId );
   437                 newComponentId );
   433             }
   438             }
   434 
   439         
       
   440         CleanupStack::PopAndDestroy( &oldComponentId );
   435         CleanupStack::PopAndDestroy( &oldComponentId );
   441         CleanupStack::PopAndDestroy( &newComponentId );
   436         CleanupStack::PopAndDestroy( &newComponentId );
   442         }
   437         }
   443 
   438 
   444     CleanupStack::PopAndDestroy( &componentIds );
   439     CleanupStack::PopAndDestroy( &componentIds );
   445     }
   440     }
   446 
   441 
   447 
       
   448 //  End of File
   442 //  End of File