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