webengine/widgetregistry/Server/src/WidgetRegistry.cpp
branchRCL_3
changeset 94 919f36ff910f
parent 93 79859ed3eea9
child 95 d96eed154187
equal deleted inserted replaced
93:79859ed3eea9 94:919f36ff910f
    27 #include "WidgetInstaller.h"
    27 #include "WidgetInstaller.h"
    28 #include <libxml2_globals.h>
    28 #include <libxml2_globals.h>
    29 #include <libc/stdlib.h>
    29 #include <libc/stdlib.h>
    30 #include <libxml2_parser.h>
    30 #include <libxml2_parser.h>
    31 #include <libxml2_tree.h>
    31 #include <libxml2_tree.h>
       
    32 #include "WidgetMMCHandler.h"
    32 #include <xmlengxestd.h>
    33 #include <xmlengxestd.h>
    33 #include "UidAllocator.h"
    34 #include "UidAllocator.h"
    34 #if defined( BRDO_WRT_SECURITY_MGR_FF )
    35 #if defined( BRDO_WRT_SECURITY_MGR_FF )
    35 #include <rtsecmanager.h>
    36 #include <RTSecManager.h>
    36 #endif
    37 #endif
    37 #include <e32property.h>
    38 #include <e32property.h>
    38 
    39 
    39 // CONSTANTS
    40 // CONSTANTS
    40 
    41 
    60       "a:\\private\\10282822\\" );
    61       "a:\\private\\10282822\\" );
    61 _LIT( KWidgetEntryStoreBinaryFile,
    62 _LIT( KWidgetEntryStoreBinaryFile,
    62       "a:\\private\\10282f06\\WidgetEntryStore.dat" );
    63       "a:\\private\\10282f06\\WidgetEntryStore.dat" );
    63 _LIT( KWidgetEntryStoreXmlFile,
    64 _LIT( KWidgetEntryStoreXmlFile,
    64       "a:\\private\\10282f06\\WidgetEntryStore.xml" );
    65       "a:\\private\\10282f06\\WidgetEntryStore.xml" );
       
    66 _LIT( KCWRTWidgetEntryStoreXmlFile,
       
    67       "c:\\private\\10282f06\\CWRTWidgetEntryStore.xml" );
    65 _LIT( KWidgetEntryStoreXmlTempFile,
    68 _LIT( KWidgetEntryStoreXmlTempFile,
    66       "a:\\private\\10282f06\\WidgetEntryStoreTemp.xml" );
    69       "a:\\private\\10282f06\\WidgetEntryStoreTemp.xml" );
    67 _LIT( KWidgetDirFile, "widget_lproj.xml" );
    70 _LIT( KWidgetDirFile, "widget_lproj.xml" );
    68 _LIT( KWidgetAccessPolicy, "WidgetAccessPolicy.xml" );
    71 _LIT( KWidgetAccessPolicy, "WidgetAccessPolicy.xml" );
    69 _LIT( KWidgetPolicyIdFile, "WidgetPolicyId.dat" );
    72 _LIT( KWidgetPolicyIdFile, "WidgetPolicyId.dat" );
   131 // ============================================================================
   134 // ============================================================================
   132 // Changes the Publish & Subscribe key value
   135 // Changes the Publish & Subscribe key value
   133 // ============================================================================
   136 // ============================================================================
   134 //
   137 //
   135 
   138 
   136 static void NotifyWidgetAltered()
   139 void CWidgetRegistry::NotifyWidgetAltered()
   137     {
   140     {
   138     const TUid KMyPropertyCat = { 0x10282E5A };
   141     const TUid KMyPropertyCat = { 0x10282E5A };
   139     enum TMyPropertyKeys { EMyPropertyAltered = 110 };
   142     enum TMyPropertyKeys { EMyPropertyAltered = 110 };
   140     TInt altered( 1 );
   143     TInt altered( 1 );
   141     RProperty::Set( KMyPropertyCat, EMyPropertyAltered , altered );
   144     RProperty::Set( KMyPropertyCat, EMyPropertyAltered , altered );
   166 CWidgetRegistry::CWidgetRegistry( RFs& aFs ):
   169 CWidgetRegistry::CWidgetRegistry( RFs& aFs ):
   167     iFs( aFs ),
   170     iFs( aFs ),
   168     iWidgetInstallPath( KWidgetInstallPath ),
   171     iWidgetInstallPath( KWidgetInstallPath ),
   169     iRegistryBinaryFileName( KWidgetEntryStoreBinaryFile ),
   172     iRegistryBinaryFileName( KWidgetEntryStoreBinaryFile ),
   170     iRegistryXmlFileName( KWidgetEntryStoreXmlFile ),
   173     iRegistryXmlFileName( KWidgetEntryStoreXmlFile ),
       
   174     iRegistryCWRTXmlFileName( KCWRTWidgetEntryStoreXmlFile ),
   171     iRegistryXmlTempFileName( KWidgetEntryStoreXmlTempFile ),
   175     iRegistryXmlTempFileName( KWidgetEntryStoreXmlTempFile ),
   172     iPolicyId( 0 )
   176     iPolicyId( 0 )
   173     {
   177     {
   174     }
   178     }
   175 
   179 
   181 // ============================================================================
   185 // ============================================================================
   182 //
   186 //
   183 CWidgetRegistry::~CWidgetRegistry()
   187 CWidgetRegistry::~CWidgetRegistry()
   184     {
   188     {
   185     iEntries.ResetAndDestroy();
   189     iEntries.ResetAndDestroy();
       
   190     iOldEntries.ResetAndDestroy();
   186     iUsedUids.Close();
   191     iUsedUids.Close();
   187     // iFs not owned
   192     // iFs not owned
   188     iAppArch.Close();
   193     iAppArch.Close();
   189     delete iInstaller;
   194     delete iInstaller;
   190     iLangDirList.ResetAndDestroy();
   195     iLangDirList.ResetAndDestroy();
       
   196     delete iMMCHandler;
   191     delete iXmlProcessor;
   197     delete iXmlProcessor;
   192 	delete iApaAppListNotifier;
       
   193     iFs.Close();
   198     iFs.Close();
   194     LOG_DESTRUCT;
   199     LOG_DESTRUCT;
   195     }
   200     }
   196 
   201 
   197 // ============================================================================
   202 // ============================================================================
   248 #endif
   253 #endif
   249 
   254 
   250     LOG1( "ConstructL internalize done, registry count %d",
   255     LOG1( "ConstructL internalize done, registry count %d",
   251               iEntries.Count() );
   256               iEntries.Count() );
   252     LOG_CLOSE;
   257     LOG_CLOSE;
   253     iApaAppListNotifier = CApaAppListNotifier::NewL(this,CActive::EPriorityStandard);
   258     iMMCHandler = CWidgetMMCHandler::NewL( *this, iFs );
       
   259     iMMCHandler->Start();
   254     }
   260     }
   255 
   261 
   256 // ============================================================================
   262 // ============================================================================
   257 // CWidgetRegistry::FetchSecurityPolicyIdL()
   263 // CWidgetRegistry::FetchSecurityPolicyIdL()
   258 // Get policyId from security manager
   264 // Get policyId from security manager
   331                 CleanupStack::PopAndDestroy( secMgr );
   337                 CleanupStack::PopAndDestroy( secMgr );
   332                 }
   338                 }
   333             }
   339             }
   334         }
   340         }
   335 #else
   341 #else
   336 	iPolicyId = KErrNotSupported;
   342   iPolicyId = KErrNotSupported;
   337 #endif    
   343 #endif    
   338     return iPolicyId;
   344     return iPolicyId;
   339     }
   345     }
   340 
   346 
   341 // ============================================================================
   347 // ============================================================================
   372     CWidgetEntry*& aEntry) const
   378     CWidgetEntry*& aEntry) const
   373     {
   379     {
   374     for(TInt i = 0;i < iEntries.Count();i++)
   380     for(TInt i = 0;i < iEntries.Count();i++)
   375         {
   381         {
   376         CWidgetEntry* entry = iEntries[i];
   382         CWidgetEntry* entry = iEntries[i];
       
   383         if ( TUid::Uid( (*entry)[EUid] ) == aUid )
       
   384             {
       
   385             aEntry = entry;
       
   386             return i;
       
   387             }
       
   388         }
       
   389     return -1;
       
   390     }
       
   391 
       
   392 // ============================================================================
       
   393 // CWidgetRegistry::GetWidgetOldEntry()
       
   394 // Get the widget entry from iOldEntrys array
       
   395 //
       
   396 // @since 3.1
       
   397 // ============================================================================
       
   398 //
       
   399 TInt CWidgetRegistry::GetWidgetOldEntry(
       
   400     const TUid& aUid,
       
   401     CWidgetEntry*& aEntry) const
       
   402     {
       
   403     for(TInt i = 0;i < iOldEntries.Count();i++)
       
   404         {
       
   405         CWidgetEntry* entry = iOldEntries[i];
   377         if ( TUid::Uid( (*entry)[EUid] ) == aUid )
   406         if ( TUid::Uid( (*entry)[EUid] ) == aUid )
   378             {
   407             {
   379             aEntry = entry;
   408             aEntry = entry;
   380             return i;
   409             return i;
   381             }
   410             }
   525     aDirtyFlag = EFalse;
   554     aDirtyFlag = EFalse;
   526 
   555 
   527     // internal dirty flag, will be copied to arg dirty flag at
   556     // internal dirty flag, will be copied to arg dirty flag at
   528     // end if no leave occurs
   557     // end if no leave occurs
   529     TBool dirtyFlag = EFalse;
   558     TBool dirtyFlag = EFalse;
   530 
   559     
   531     // empty the registry
   560     // Copy the entries so we are able to use them later
   532     iEntries.ResetAndDestroy();
   561     // iOldEntries owns the data and is responcible to ResetAndDestroy()
       
   562     for ( TInt i = 0; i < iEntries.Count(); i++ )
       
   563         {
       
   564         iOldEntries.Append( iEntries[i] );
       
   565         }
       
   566     // Only reset here as the iOldEntries owns the data
       
   567     iEntries.Reset();
   533     iUsedUids.Reset();
   568     iUsedUids.Reset();
   534 
   569 
   535     CleanupClosePushL( appArchList );
   570     CleanupClosePushL( appArchList );
   536     CleanupClosePushL( appArchListFlags );
   571     CleanupClosePushL( appArchListFlags );
   537     if ( doConsistency )
   572     if ( doConsistency )
   547         // But once widgets are installed, they are assigned a unique
   582         // But once widgets are installed, they are assigned a unique
   548         // UID.  For UID allocation purposes, it is important that
   583         // UID.  For UID allocation purposes, it is important that
   549         // UIDs already known to app arch be reserved.
   584         // UIDs already known to app arch be reserved.
   550         for ( TInt i = 0; i < appArchList.Count(); i++ )
   585         for ( TInt i = 0; i < appArchList.Count(); i++ )
   551             {
   586             {
   552             if ( KErrNone != iUsedUids.Append( (appArchList)[i] ) )
   587             // Do not maintain the list of used CWRT widget UIDs
   553                 {
   588             if ( !TUidAllocator::IsCWRTWidget((appArchList)[i]) )
   554                 // no recovery possible
   589                 {
   555                 doConsistency = EFalse;
   590                   if ( KErrNone != iUsedUids.Append( (appArchList)[i] ) )
   556                 break;
   591                       {
       
   592                       // no recovery possible
       
   593                       doConsistency = EFalse;
       
   594                       break;
       
   595                       }
   557                 }
   596                 }
   558             }
   597             }
   559         }
   598         }
   560     LOG2( " iUsedUids %d and doConsistency %d",
   599     LOG2( " iUsedUids %d and doConsistency %d",
   561           (TInt)(iUsedUids.Count()), (TInt)doConsistency );
   600           (TInt)(iUsedUids.Count()), (TInt)doConsistency );
   564     if ( KErrNone != error )
   603     if ( KErrNone != error )
   565         {
   604         {
   566         // on error use english
   605         // on error use english
   567         iLprojName = _L("en");
   606         iLprojName = _L("en");
   568         }
   607         }
       
   608         
       
   609     // Internalize the CWRT widgets, without consistency checking
       
   610     // No multi-drive support for CWRT
       
   611     TDriveUnit driveUnit(EDriveC);
       
   612     CDir* installedListForDrive = NULL;
       
   613     RArray<TInt> installedListForDriveFlags;
       
   614     TRAP_IGNORE(  // consistency checking doesn't apply to CWRT
       
   615           InternalizeXmlL( iRegistryCWRTXmlFileName,
       
   616                            driveUnit,
       
   617                            EFalse,
       
   618                            appArchList,
       
   619                            appArchListFlags,
       
   620                            installedListForDrive,
       
   621                            installedListForDriveFlags,
       
   622                            dirtyFlag ) );
       
   623     delete installedListForDrive;
       
   624     installedListForDriveFlags.Close();
   569 
   625 
   570     // List all drives in the system
   626     // List all drives in the system
   571     TDriveList driveList;
   627     TDriveList driveList;
   572     User::LeaveIfError( iFs.DriveList(driveList) );
   628     User::LeaveIfError( iFs.DriveList(driveList) );
   573 
   629 
   673                                    dirtyFlag );
   729                                    dirtyFlag );
   674             }
   730             }
   675         delete installedListForDrive;
   731         delete installedListForDrive;
   676         installedListForDriveFlags.Close();
   732         installedListForDriveFlags.Close();
   677         } // for
   733         } // for
       
   734 
       
   735     // appArchList will not contain CWRT widgets, so 
       
   736     // consistency checking will not apply to them
   678     if ( doConsistency )
   737     if ( doConsistency )
   679         {
   738         {
   680         AppArchListConsistency( appArchList, appArchListFlags );
   739         AppArchListConsistency( appArchList, appArchListFlags );
   681         }    
   740         }
       
   741 
   682     CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
   742     CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
   683 
   743 
   684     aDirtyFlag = dirtyFlag;
   744     aDirtyFlag = dirtyFlag;
       
   745     // Reset and Destroy entries in iOldEntries array
       
   746     iOldEntries.ResetAndDestroy();
   685     LOG1( "Internalize done, dirty flag %d", (TInt)dirtyFlag );
   747     LOG1( "Internalize done, dirty flag %d", (TInt)dirtyFlag );
   686     LOG_CLOSE;
   748     LOG_CLOSE;
   687     }
   749     }
   688 
   750 
   689 // ============================================================================
   751 // ============================================================================
   710     RFileReadStream readStream;
   772     RFileReadStream readStream;
   711     CleanupClosePushL( readStream );
   773     CleanupClosePushL( readStream );
   712     readStream.Attach( file );
   774     readStream.Attach( file );
   713 
   775 
   714     TInt error = KErrNone;
   776     TInt error = KErrNone;
   715     TInt entryCount = 0;
   777     TInt entryCount = 0,errorCount =0;
   716     TRAP( error, entryCount = readStream.ReadInt32L() );
   778     TRAP( error, entryCount = readStream.ReadInt32L() );
   717     // TODO should limit entryCount to something like 1024
   779     // TODO should limit entryCount to something like 1024
   718     // for each entry in the registry file
   780     // for each entry in the registry file
   719     for ( TInt i = 0 ; i < entryCount; i++ )
   781     for ( TInt i = 0 ; i < entryCount; i++ )
   720         {
   782         {
   721         CWidgetEntry* entry = CWidgetEntry::NewL();
   783         CWidgetEntry* entry = CWidgetEntry::NewL();
   722         CleanupStack::PushL( entry );
   784         // push as delete entry so if we leave it will be handled
   723 
   785         CleanupDeletePushL( entry );
   724         // extract one entry
   786         // extract one entry
   725         TRAP( error,
   787         TRAP( error,
   726               entry->InternalizeBinaryL( readStream ) );
   788               entry->InternalizeBinaryL( readStream ) );
   727         if ( KErrNone == error )
   789         if ( KErrNone == error )
   728             {
   790             {
   740             if ( NULL != res )
   802             if ( NULL != res )
   741                 {
   803                 {
   742                 TRAP( error, InsertL( entry ) );
   804                 TRAP( error, InsertL( entry ) );
   743                 if ( KErrNone != error )
   805                 if ( KErrNone != error )
   744                     {
   806                     {
   745                     CleanupStack::PopAndDestroy( entry );
   807                      delete entry; 
   746                     }
   808                     }
   747                 else
   809                 else
   748                     {
   810                     {
   749                     __ASSERT_DEBUG( res == entry, User::Invariant() );
   811                     __ASSERT_DEBUG( res == entry, User::Invariant() );
   750                     // Entry was inserted successfully.
   812                     // Entry was inserted successfully.
   751                     CleanupStack::Pop( entry );
   813                     //CleanupStack::Pop( entry );
   752                     // add uid to AppArchList if not there,
   814                     // add uid to AppArchList if not there,
   753                     // this can happend due to UID
   815                     // this can happend due to UID
   754                     // reallocation for UID collision resolution
   816                     // reallocation for UID collision resolution
   755                     TInt uidInt = (*entry)[EUid];
   817                     TInt uidInt = (*entry)[EUid];
   756                     if ( aDoConsistency &&
   818                     if ( aDoConsistency &&
   762                         }
   824                         }
   763                     LOG2( " entry 0x%x (%d) added to registry",
   825                     LOG2( " entry 0x%x (%d) added to registry",
   764                               uidInt, uidInt );
   826                               uidInt, uidInt );
   765                     }
   827                     }
   766                 }
   828                 }
       
   829             else
       
   830                 {
       
   831                 // Pop and delete the un-needed entry so it is not left behind.
       
   832                 errorCount++; 
       
   833                 }
   767             }
   834             }
   768         else
   835         else
   769             {
   836             {
   770             // entry error
   837             // entry error
   771             CleanupStack::PopAndDestroy( entry );
   838             delete entry; 
   772             }
   839             }
       
   840         CleanupStack::Pop(); //entry
   773         } // for
   841         } // for
   774 
   842 
   775     CleanupStack::PopAndDestroy( 2, &file ); // readStream, file
   843     CleanupStack::PopAndDestroy( 2, &file ); // readStream, file
       
   844     if ( errorCount != 0 )
       
   845         {
       
   846         User::Leave(KErrGeneral);
       
   847         }
   776     }
   848     }
   777 
   849 
   778 // ============================================================================
   850 // ============================================================================
   779 // CWidgetRegistry::InternalizeXmlL()
   851 // CWidgetRegistry::InternalizeXmlL()
   780 // Read entry info from data file into memory
   852 // Read entry info from data file into memory
   865                                                   aInstalledListForDriveFlags,
   937                                                   aInstalledListForDriveFlags,
   866                                                   aDriveUnit,
   938                                                   aDriveUnit,
   867                                                   aDirtyFlag );
   939                                                   aDirtyFlag );
   868                         }
   940                         }
   869                     if ( NULL != entry )
   941                     if ( NULL != entry )
   870                         {
   942                         { 
       
   943                         CWidgetEntry* entry1 = NULL;
       
   944                         TInt uid = (*entry)[EUid];
       
   945                         TInt pos  = GetWidgetOldEntry( TUid::Uid( uid ), entry1 );
       
   946                         if ( pos != -1 )
       
   947                             {
       
   948                             entry->SetActive((iOldEntries[pos]->ActiveL()));
       
   949                             entry->SetFullView((iOldEntries[pos]->GetFullViewState()));
       
   950                             entry->SetMiniView((iOldEntries[pos]->GetMiniViewState()));
       
   951                             }
   871                         TRAP( error, InsertL( entry ) );
   952                         TRAP( error, InsertL( entry ) );
   872                         if ( KErrNone != error )
   953                         if ( KErrNone != error )
   873                             {
   954                             {
   874                             delete entry;
   955                             delete entry;
   875                             }
   956                             }
   922     // in order to have a list of all entries for a particular drive,
  1003     // in order to have a list of all entries for a particular drive,
   923     // create a hash map from the entries with the key as drive name
  1004     // create a hash map from the entries with the key as drive name
   924     // and value as an array of entry indices for that drive
  1005     // and value as an array of entry indices for that drive
   925     RPtrHashMap< TInt, CArrayFixFlat<TInt> > driveEntryHashMap;
  1006     RPtrHashMap< TInt, CArrayFixFlat<TInt> > driveEntryHashMap;
   926     CleanupClosePushL( driveEntryHashMap );
  1007     CleanupClosePushL( driveEntryHashMap );
       
  1008     CArrayFixFlat<TInt>* cwrtWidgetArray = new (ELeave) CArrayFixFlat<TInt>(1);
       
  1009     CleanupStack::PushL( cwrtWidgetArray );
   927 
  1010 
   928     for (TInt i = 0 ;i < iEntries.Count(); i++)
  1011     for (TInt i = 0 ;i < iEntries.Count(); i++)
   929         {
  1012         {
   930         CWidgetEntry* entry = iEntries[i];
  1013         CWidgetEntry* entry = iEntries[i];
       
  1014         
       
  1015         // Bypass if the widget is a CWRT widget, they're externalized
       
  1016         // independently
       
  1017         if (TUidAllocator::IsCWRTWidget(TUid::Uid((*entry)[EUid]))) {
       
  1018           cwrtWidgetArray->AppendL(i);
       
  1019           continue;
       
  1020         }
       
  1021         
   931         const TDesC& driveName = (*entry)[EDriveName];
  1022         const TDesC& driveName = (*entry)[EDriveName];
   932         TDriveUnit driveUnit( driveName );
  1023         TDriveUnit driveUnit( driveName );
   933         CArrayFixFlat<TInt>* array =
  1024         CArrayFixFlat<TInt>* array =
   934             driveEntryHashMap.Find( driveUnit );
  1025             driveEntryHashMap.Find( driveUnit );
   935         if( !array )
  1026         if( !array )
  1015                 {
  1106                 {
  1016                 BaflUtils::DeleteFile( iFs, iRegistryXmlTempFileName );
  1107                 BaflUtils::DeleteFile( iFs, iRegistryXmlTempFileName );
  1017                 }
  1108                 }
  1018             }
  1109             }
  1019         }
  1110         }
       
  1111     
       
  1112     TDriveUnit driveUnit( EDriveC );    
       
  1113     iRegistryXmlTempFileName[0] = driveUnit.Name()[0];
       
  1114     
       
  1115     iFs.CreatePrivatePath( driveUnit );
       
  1116     
       
  1117     // a transactional file update to protect against
       
  1118     // disk full, etc: overwrite temp then rename temp to original
       
  1119     
       
  1120     TRAPD( error,
       
  1121            ExternalizeXmlL( iRegistryXmlTempFileName, cwrtWidgetArray ) );
       
  1122     if ( KErrNone == error )
       
  1123         {
       
  1124         // last steps in transactional update
       
  1125         BaflUtils::DeleteFile( iFs, iRegistryCWRTXmlFileName );
       
  1126         BaflUtils::RenameFile( iFs, 
       
  1127                                iRegistryXmlTempFileName,
       
  1128                                iRegistryCWRTXmlFileName );
       
  1129         }
       
  1130      else  // handle leave by deleting temp file
       
  1131          {
       
  1132          BaflUtils::DeleteFile( iFs, iRegistryXmlTempFileName );
       
  1133          }
  1020 
  1134 
  1021     for ( TInt i = 0; i < driveEntryHashMap.Count(); i++ )
  1135     for ( TInt i = 0; i < driveEntryHashMap.Count(); i++ )
  1022         {
  1136         {
  1023         CleanupStack::Pop();
  1137         CleanupStack::Pop();
  1024         }
  1138         }
       
  1139     CleanupStack::PopAndDestroy( cwrtWidgetArray );
  1025     CleanupStack::Pop( &driveEntryHashMap );
  1140     CleanupStack::Pop( &driveEntryHashMap );
  1026     driveEntryHashMap.ResetAndDestroy();
  1141     driveEntryHashMap.ResetAndDestroy();
  1027     driveEntryHashMap.Close();
  1142     driveEntryHashMap.Close();
  1028     }
  1143     }
  1029 
  1144 
  1773     do
  1888     do
  1774         {
  1889         {
  1775         error = iAppArch.GetNextApp( info );
  1890         error = iAppArch.GetNextApp( info );
  1776         if ( KErrNone == error )
  1891         if ( KErrNone == error )
  1777             {
  1892             {
  1778             if ( TUidAllocator::IsWidget( info.iUid ) )
  1893             if ( TUidAllocator::IsWidget( info.iUid ) &&
       
  1894                  !TUidAllocator::IsCWRTWidget( info.iUid ) )
  1779                 {
  1895                 {
  1780                 LOG2( " widget uid 0x%x (%d)",
  1896                 LOG2( " widget uid 0x%x (%d)",
  1781                           (TUint)(info.iUid.iUid), info.iUid.iUid );
  1897                           (TUint)(info.iUid.iUid), info.iUid.iUid );
  1782                 error = aUids.Append( info.iUid );
  1898                 error = aUids.Append( info.iUid );
  1783                 if ( KErrNone !=  error )
  1899                 if ( KErrNone !=  error )
  1802         } while ( RApaLsSession::ENoMoreAppsInList != error );
  1918         } while ( RApaLsSession::ENoMoreAppsInList != error );
  1803     if ( RApaLsSession::ENoMoreAppsInList != error )
  1919     if ( RApaLsSession::ENoMoreAppsInList != error )
  1804         {
  1920         {
  1805         aUids.Reset();
  1921         aUids.Reset();
  1806         }
  1922         }
  1807 	else 
  1923   else 
  1808 		{
  1924     {
  1809 		error = KErrNone;
  1925     error = KErrNone;
  1810 		}
  1926     }
  1811     LOG_CODE( if ( aUids.Count() ) )
  1927     LOG_CODE( if ( aUids.Count() ) )
  1812     LOG1( "AppArchWidgetUids done widget count %d",
  1928     LOG1( "AppArchWidgetUids done widget count %d",
  1813               aUids.Count() );
  1929               aUids.Count() );
  1814     LOG_CODE( else )
  1930     LOG_CODE( else )
  1815     LOG( "AppArchWidgetUids done error NULL list" );
  1931     LOG( "AppArchWidgetUids done error NULL list" );
  1966         for ( TInt i = 0; i < aInstalledListForDrive->Count(); i++ )
  2082         for ( TInt i = 0; i < aInstalledListForDrive->Count(); i++ )
  1967             {
  2083             {
  1968             if ( !((aInstalledListForDriveFlags)[i] & EInstallListFlagEntry ))
  2084             if ( !((aInstalledListForDriveFlags)[i] & EInstallListFlagEntry ))
  1969                 {
  2085                 {
  1970                 TEntry dirEntry = (*aInstalledListForDrive)[i];
  2086                 TEntry dirEntry = (*aInstalledListForDrive)[i];
  1971                 if ( 0 == bundleIdentifier.Compare( dirEntry.iName ) )
  2087                 if ( 0 == bundleIdentifier.CompareF( dirEntry.iName ) )
  1972                     {
  2088                     {
  1973                     (aInstalledListForDriveFlags)[i] |= EInstallListFlagEntry;
  2089                     (aInstalledListForDriveFlags)[i] |= EInstallListFlagEntry;
  1974                     result = ETrue;
  2090                     result = ETrue;
  1975                     break;
  2091                     break;
  1976                     }
  2092                     }
  2229     }
  2345     }
  2230 
  2346 
  2231 void CWidgetRegistry::AppArchListConsistency( const RArray<TUid>& aAppArchList,
  2347 void CWidgetRegistry::AppArchListConsistency( const RArray<TUid>& aAppArchList,
  2232                                               RArray<TInt>& aAppArchListFlags )
  2348                                               RArray<TInt>& aAppArchListFlags )
  2233     {
  2349     {
  2234     LOG( "AppArchListConsistency" );
  2350     LOG( "AppArchListConsistency" );      
       
  2351     RArray<TUid> deRegisterList( KDefaultWidgetCount );  
       
  2352     CleanupClosePushL(deRegisterList);
  2235     for ( TInt i = 0; i < aAppArchList.Count(); i++ )
  2353     for ( TInt i = 0; i < aAppArchList.Count(); i++ )
  2236         {
  2354         {
  2237         if ( !( aAppArchListFlags[i] & EAppListFlagEntry ) )
  2355         if ( !( aAppArchListFlags[i] & EAppListFlagEntry ) )
  2238             {
  2356             {
  2239             LOG_CODE( TInt uidIntLog = aAppArchList[i].iUid );
  2357             LOG_CODE( TInt uidIntLog = aAppArchList[i].iUid );
  2240             LOG2( " deregistered widget 0x%x (%d)",
  2358             LOG2( " deregistered widget 0x%x (%d)",
  2241                       uidIntLog, uidIntLog );
  2359                       uidIntLog, uidIntLog );
  2242             TRAP_IGNORE( iInstaller->DeregisterWidgetL( aAppArchList[i] ) );
  2360 			deRegisterList.Append(aAppArchList[i]);          
  2243             }
  2361             }
  2244         }
  2362         }
       
  2363     if(deRegisterList.Count())
       
  2364     	{
       
  2365 		TRAP_IGNORE( iInstaller->DeregisterWidgetsL( deRegisterList ) );      		
       
  2366     	}    
       
  2367     CleanupStack::PopAndDestroy(&deRegisterList);
  2245     LOG( "AppArchListConsistency done" );
  2368     LOG( "AppArchListConsistency done" );
  2246     }
  2369     }
  2247 
  2370 
  2248 void CWidgetRegistry::HandleAppListEvent(TInt aEvent)
  2371 
  2249     {
       
  2250     TBool dirtyFlag = EFalse;
       
  2251     TInt parseError = KErrNone;
       
  2252     // Assume usual case and things are consistent
       
  2253     // and the registry entry file can be parsed and used.
       
  2254     TRAPD( error, InternalizeL( EFalse,
       
  2255                                 EFalse,
       
  2256                                 dirtyFlag,
       
  2257                                 parseError ) );
       
  2258     if ( KErrNone == error )
       
  2259         {
       
  2260         // internalize consistency enforcement may have altered registry
       
  2261         if ( dirtyFlag )
       
  2262             {
       
  2263             TRAP_IGNORE( ExternalizeL(); );
       
  2264             }
       
  2265         }
       
  2266     }
       
  2267 // End of File
  2372 // End of File