contentstorage/casrv/causifscanner/src/causifscanner.cpp
changeset 80 397d00875918
parent 66 32469d7d46ff
child 98 d2f833ab7940
equal deleted inserted replaced
73:4bc7b118b3df 80:397d00875918
    16  */
    16  */
    17 
    17 
    18 #include <e32property.h>
    18 #include <e32property.h>
    19 #include <f32file.h>
    19 #include <f32file.h>
    20 #include <badesca.h>
    20 #include <badesca.h>
    21 #include <usif/sif/sif.h>
       
    22 #include <usif/scr/scr.h>
       
    23 #include <usif/sif/sifcommon.h>
       
    24 
    21 
    25 #include "causifscanner.h"
    22 #include "causifscanner.h"
    26 #include "cainnerentry.h"
    23 #include "cainnerentry.h"
    27 #include "cainnerquery.h"
    24 #include "cainnerquery.h"
    28 #include "cadef.h"
    25 #include "cadef.h"
    81 //
    78 //
    82 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    83 //
    80 //
    84 CCaUsifScanner::~CCaUsifScanner()
    81 CCaUsifScanner::~CCaUsifScanner()
    85     {
    82     {
       
    83     iSoftwareRegistry.Close();
    86     delete iMmcWatcher;
    84     delete iMmcWatcher;
       
    85     iFs.Close();
       
    86     delete iJavaInstallNotifier;
       
    87     delete iUsifUninstallNotifier;
    87     delete iSystemInstallNotifier;
    88     delete iSystemInstallNotifier;
    88     delete iUsifUninstallNotifier;
       
    89     delete iJavaInstallNotifier;
       
    90     iFs.Close();
       
    91     iSoftwareRegistry.Close();
       
    92     }
    89     }
    93 
    90 
    94 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
    95 //
    92 //
    96 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
   196 
   193 
   197     RPointerArray<CComponentEntry> resultUsifArray;
   194     RPointerArray<CComponentEntry> resultUsifArray;
   198     CleanupResetAndDestroyPushL( resultUsifArray );
   195     CleanupResetAndDestroyPushL( resultUsifArray );
   199     GetUsifPackageEntriesL( resultUsifArray );
   196     GetUsifPackageEntriesL( resultUsifArray );
   200 
   197 
   201     for( TInt idx(0); idx < resultUsifArray.Count(); idx++ )
   198     for( TInt i(0); i < resultUsifArray.Count(); i++ )
   202         {
   199         {
   203         if( PackageExistL( entries, resultUsifArray[idx] ) == KErrNotFound )
   200         if( PackageExists( entries, resultUsifArray[i] ) == KErrNotFound )
   204             {
   201             {
   205             CCaInnerEntry *caEntry = CCaInnerEntry::NewLC();
   202             CCaInnerEntry *caEntry = CCaInnerEntry::NewLC();
   206             CreateCaEntryFromEntryL( resultUsifArray[idx], caEntry );
   203             CreateCaEntryFromEntryL( resultUsifArray[i], caEntry );
   207             iStorageProxy.AddL( caEntry );
   204             iStorageProxy.AddL( caEntry );
   208             CleanupStack::PopAndDestroy( caEntry );
   205             CleanupStack::PopAndDestroy( caEntry );
   209             }
   206             }
   210         }
   207         }
   211 
   208 
   240 //
   237 //
   241 void CCaUsifScanner::GetCaPackageEntriesL(
   238 void CCaUsifScanner::GetCaPackageEntriesL(
   242         RPointerArray<CCaInnerEntry>& aArray )
   239         RPointerArray<CCaInnerEntry>& aArray )
   243     {
   240     {
   244     CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
   241     CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
   245     CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 );
   242     CDesC16ArrayFlat* appType =
       
   243             new ( ELeave ) CDesC16ArrayFlat( KGranularityOne );
   246     CleanupStack::PushL( appType );
   244     CleanupStack::PushL( appType );
   247     appType->AppendL( KCaTypePackage );
   245     appType->AppendL( KCaTypePackage );
   248     allAppQuery->SetEntryTypeNames( appType );
   246     allAppQuery->SetEntryTypeNames( appType );
   249     CleanupStack::Pop( appType );
   247     CleanupStack::Pop( appType );
   250     iStorageProxy.GetEntriesL( allAppQuery, aArray );
   248     iStorageProxy.GetEntriesL( allAppQuery, aArray );
   268     CleanupClosePushL( scrView );
   266     CleanupClosePushL( scrView );
   269     scrView.OpenViewL( iSoftwareRegistry, filter );
   267     scrView.OpenViewL( iSoftwareRegistry, filter );
   270 
   268 
   271     // Iterate over the matching components
   269     // Iterate over the matching components
   272     //The ownership is transferred to the calling client.
   270     //The ownership is transferred to the calling client.
   273     CComponentEntry* entry = scrView.NextComponentL();
   271     while( CComponentEntry* entry = scrView.NextComponentL() )
   274     while( entry )
       
   275         {
   272         {
   276         CleanupStack::PushL( entry );
   273         CleanupStack::PushL( entry );
   277         if( iSoftwareRegistry.IsComponentPresentL( entry->ComponentId() ) )
   274         if( iSoftwareRegistry.IsComponentPresentL( entry->ComponentId() ) )
   278             {
   275             {
   279             aArray.AppendL( entry );
   276             aArray.AppendL( entry );
   281             }
   278             }
   282         else
   279         else
   283             {
   280             {
   284             CleanupStack::PopAndDestroy( entry );
   281             CleanupStack::PopAndDestroy( entry );
   285             }
   282             }
   286         entry = scrView.NextComponentL();
       
   287         }
   283         }
   288     CleanupStack::PopAndDestroy( &scrView );
   284     CleanupStack::PopAndDestroy( &scrView );
   289     CleanupStack::PopAndDestroy( filter );
   285     CleanupStack::PopAndDestroy( filter );
   290     }
   286     }
   291 
   287 
   292 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------
   293 //
   289 //
   294 // ---------------------------------------------------------------------------
   290 // ---------------------------------------------------------------------------
   295 //
   291 //
   296 TInt CCaUsifScanner::PackageExistL( RPointerArray<CCaInnerEntry>& aArray,
   292 TInt CCaUsifScanner::PackageExists( RPointerArray<CCaInnerEntry>& aArray,
   297         const CComponentEntry* aEntry )
   293         const CComponentEntry* aEntry )
   298     {
   294     {
   299     for( TInt idx( 0 ); idx < aArray.Count(); idx++ )
   295     TInt retVal( KErrNotFound );
       
   296     for( TInt i( 0 ); i < aArray.Count(); i++ )
   300         {
   297         {
   301         TBuf<KMaxUnits> compIdDes;
   298         TBuf<KMaxUnits> compIdDes;
   302         if( aArray[idx]->FindAttribute( KCaAttrComponentId, compIdDes ) )
   299         if( aArray[i]->FindAttribute( KCaAttrComponentId, compIdDes ) )
   303             {
   300             {
   304             TLex lex( compIdDes );
   301             TLex lex( compIdDes );
   305             TUint uint( 0 );
   302             TUint uint( 0 );
   306             User::LeaveIfError( lex.Val( uint ) );
   303             if( lex.Val( uint ) == KErrNone && aEntry->ComponentId() == uint )
   307             if( aEntry->ComponentId() == uint )
       
   308                 {
   304                 {
   309                 return idx;
   305                 retVal = i;
   310                 }
   306                 }
   311             }
   307             }
   312         }
   308         }
   313     return KErrNotFound;
   309     return retVal;
   314     }
   310     }
   315 
   311 
   316 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   317 //
   313 //
   318 // ---------------------------------------------------------------------------
   314 // ---------------------------------------------------------------------------
   319 //
   315 //
   320 void CCaUsifScanner::FindDeletedEntriesL(
   316 void CCaUsifScanner::FindDeletedEntriesL(
   321         RPointerArray<CCaInnerEntry>& aCaArray, const RPointerArray<
   317         RPointerArray<CCaInnerEntry>& aCaArray, const RPointerArray<
   322                 CComponentEntry>& aUsifArray )
   318                 CComponentEntry>& aUsifArray )
   323     {
   319     {
   324     for( TInt idx( aCaArray.Count() - 1 ); idx >= 0; idx-- )
   320     for( TInt i( aCaArray.Count() - 1 ); i >= 0; i-- )
   325         {
   321         {
   326         TBuf<KMaxUnits> compIdDes;
   322         TBuf<KMaxUnits> compIdDes;
   327         if( aCaArray[idx]->FindAttribute( KCaAttrComponentId, compIdDes ) )
   323         if( aCaArray[i]->FindAttribute( KCaAttrComponentId, compIdDes ) )
   328             {
   324             {
   329             TLex lex( compIdDes );
   325             TLex lex( compIdDes );
   330             TUint uint( 0 );
   326             TUint uint( 0 );
   331             User::LeaveIfError( lex.Val( uint ) );
   327             User::LeaveIfError( lex.Val( uint ) );
   332             //for each usif entry check if entry has to be removed
   328             //for each usif entry check if entry has to be removed
   333             for( TInt k( 0 ); k < aUsifArray.Count(); k++ )
   329             for( TInt k( 0 ); k < aUsifArray.Count(); k++ )
   334                 {
   330                 {
   335                 if( aUsifArray[k]->ComponentId() == uint
   331                 if( aUsifArray[k]->ComponentId() == uint
   336                         && iSoftwareRegistry.IsComponentPresentL( uint ) )
   332                         && iSoftwareRegistry.IsComponentPresentL( uint ) )
   337                     {
   333                     {
   338                     delete aCaArray[idx];
   334                     delete aCaArray[i];
   339                     aCaArray.Remove( idx );
   335                     aCaArray.Remove( i );
   340                     break;
   336                     break;
   341                     }
   337                     }
   342                 }
   338                 }
   343             }
   339             }
   344         }
   340         }