contentstorage/casrv/cawidgetscanner/src/cawidgetstoragehandler.cpp
changeset 94 dbb8300717f7
parent 93 82b66994846c
child 96 5d243a69bdda
equal deleted inserted replaced
93:82b66994846c 94:dbb8300717f7
    15  *
    15  *
    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 "widgetscannerutils.h"
    21 #include "widgetscannerutils.h"
    21 #include "cawidgetstoragehandler.h"
    22 #include "cawidgetstoragehandler.h"
    22 #include "cadef.h"
    23 #include "cadef.h"
    23 #include "cainnerentry.h"
    24 #include "cainnerentry.h"
    24 #include "cainnerquery.h"
    25 #include "cainnerquery.h"
    25 #include "castorageproxy.h"
    26 #include "castorageproxy.h"
    26 #include "caarraycleanup.inl"
    27 #include "caarraycleanup.inl"
    27 
    28 
       
    29 using namespace Usif;
       
    30 
    28 // ============================ MEMBER FUNCTIONS ===============================
    31 // ============================ MEMBER FUNCTIONS ===============================
    29 
    32 
    30 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    31 // CCaWidgetStorageHandler::CCaWidgetStorageHandler
    34 // CCaWidgetStorageHandler::CCaWidgetStorageHandler
    32 // C++ default constructor can NOT contain any code, that
    35 // C++ default constructor can NOT contain any code, that
    45 // Symbian 2nd phase constructor can leave.
    48 // Symbian 2nd phase constructor can leave.
    46 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    47 //
    50 //
    48 void CCaWidgetStorageHandler::ConstructL()
    51 void CCaWidgetStorageHandler::ConstructL()
    49     {
    52     {
       
    53     User::LeaveIfError( iSoftwareRegistry.Connect() );
    50     }
    54     }
    51 
    55 
    52 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    53 // CCaWidgetStorageHandler::NewL
    57 // CCaWidgetStorageHandler::NewL
    54 // Two-phased constructor.
    58 // Two-phased constructor.
    81 // Destructor
    85 // Destructor
    82 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    83 //
    87 //
    84 CCaWidgetStorageHandler::~CCaWidgetStorageHandler()
    88 CCaWidgetStorageHandler::~CCaWidgetStorageHandler()
    85     {
    89     {
       
    90     iSoftwareRegistry.Close();
    86     iWidgets.ResetAndDestroy();
    91     iWidgets.ResetAndDestroy();
    87     iUpdatedIndexes.Close();
    92     iUpdatedIndexes.Close();
    88     }
    93     }
    89 
    94 
    90 // ----------------------------------------------------------------------------
    95 // ----------------------------------------------------------------------------
   103 // ----------------------------------------------------------------------------
   108 // ----------------------------------------------------------------------------
   104 //
   109 //
   105 void CCaWidgetStorageHandler::AddL( const CCaWidgetDescription* aWidget )
   110 void CCaWidgetStorageHandler::AddL( const CCaWidgetDescription* aWidget )
   106     {
   111     {
   107     CCaInnerEntry* entry = aWidget->GetEntryLC();
   112     CCaInnerEntry* entry = aWidget->GetEntryLC();
       
   113     UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
   108     iStorage->AddL( entry );
   114     iStorage->AddL( entry );
   109     if( entry->GetFlags() & ERemovable )
   115     if( entry->GetFlags() & ERemovable )
   110         {
   116         {
   111         AddWidgetToDownloadCollectionL( entry );
   117         AddWidgetToDownloadCollectionL( entry );
   112         }
   118         }
   119 //
   125 //
   120 void CCaWidgetStorageHandler::UpdateL( const CCaWidgetDescription* aWidget,
   126 void CCaWidgetStorageHandler::UpdateL( const CCaWidgetDescription* aWidget,
   121         TUint aEntryId )
   127         TUint aEntryId )
   122     {
   128     {
   123     CCaInnerEntry* entry = aWidget->GetEntryLC();
   129     CCaInnerEntry* entry = aWidget->GetEntryLC();
       
   130     UpdateComponentIdL( aWidget->GetManifestFilePathName(), *entry );
   124     entry->SetId( aEntryId );
   131     entry->SetId( aEntryId );
   125     if( !aWidget->IsMissing() && aWidget->IsUsed() )
   132     if( !aWidget->IsMissing() && aWidget->IsUsed() )
   126         {
   133         {
   127         entry->SetFlags( entry->GetFlags() & ~EUsed );
   134         entry->SetFlags( entry->GetFlags() & ~EUsed );
   128         }
   135         }
   329             }
   336             }
   330         }
   337         }
   331     return massStorageNotInUse;
   338     return massStorageNotInUse;
   332     }
   339     }
   333 
   340 
       
   341 // ----------------------------------------------------------------------------
       
   342 //
       
   343 // ----------------------------------------------------------------------------
       
   344 //
       
   345 
       
   346 void CCaWidgetStorageHandler::UpdateComponentIdL( 
       
   347     const TDesC& aManifestFilePathName, 
       
   348     CCaInnerEntry& aEntry ) const
       
   349     {
       
   350     RArray<TComponentId> componentIds;
       
   351     CleanupClosePushL( componentIds );
       
   352     
       
   353     CComponentFilter* const fileNameFilter = CComponentFilter::NewLC();
       
   354     fileNameFilter->SetFileL( aManifestFilePathName );
       
   355     iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter );
       
   356 
       
   357     CleanupStack::PopAndDestroy( fileNameFilter );
       
   358     
       
   359     if ( componentIds.Count() == 1 )
       
   360         {
       
   361         RBuf newComponentId;
       
   362         newComponentId.CleanupClosePushL();
       
   363         newComponentId.CreateL( sizeof(TComponentId) + 1 );
       
   364         newComponentId.AppendNum( componentIds[0] );
       
   365         
       
   366         RBuf oldComponentId;
       
   367         oldComponentId.CleanupClosePushL();
       
   368         oldComponentId.CreateL( KCaMaxAttrValueLen );
       
   369         
       
   370         const TBool componentIdAttributeFound = 
       
   371             aEntry.FindAttribute( KCaComponentId, oldComponentId );
       
   372               
       
   373         if ( !componentIdAttributeFound 
       
   374             || oldComponentId.Compare( newComponentId ) != 0 )
       
   375             {
       
   376             // 'add' or 'update' the component id attribute value
       
   377             aEntry.AddAttributeL( KCaComponentId, 
       
   378                 newComponentId );
       
   379             }
       
   380         
       
   381         CleanupStack::PopAndDestroy( &oldComponentId );
       
   382         CleanupStack::PopAndDestroy( &newComponentId );
       
   383         }
       
   384 
       
   385     CleanupStack::PopAndDestroy( &componentIds );
       
   386     }
       
   387 
       
   388 
   334 //  End of File
   389 //  End of File