--- a/webengine/widgetregistry/Server/src/WidgetRegistry.cpp Thu Aug 19 10:58:56 2010 +0300
+++ b/webengine/widgetregistry/Server/src/WidgetRegistry.cpp Tue Aug 31 16:17:46 2010 +0300
@@ -29,11 +29,10 @@
#include <libc/stdlib.h>
#include <libxml2_parser.h>
#include <libxml2_tree.h>
-#include "WidgetMMCHandler.h"
#include <xmlengxestd.h>
#include "UidAllocator.h"
#if defined( BRDO_WRT_SECURITY_MGR_FF )
-#include <RTSecManager.h>
+#include <rtsecmanager.h>
#endif
#include <e32property.h>
@@ -63,8 +62,6 @@
"a:\\private\\10282f06\\WidgetEntryStore.dat" );
_LIT( KWidgetEntryStoreXmlFile,
"a:\\private\\10282f06\\WidgetEntryStore.xml" );
-_LIT( KCWRTWidgetEntryStoreXmlFile,
- "c:\\private\\10282f06\\CWRTWidgetEntryStore.xml" );
_LIT( KWidgetEntryStoreXmlTempFile,
"a:\\private\\10282f06\\WidgetEntryStoreTemp.xml" );
_LIT( KWidgetDirFile, "widget_lproj.xml" );
@@ -136,7 +133,7 @@
// ============================================================================
//
-void CWidgetRegistry::NotifyWidgetAltered()
+static void NotifyWidgetAltered()
{
const TUid KMyPropertyCat = { 0x10282E5A };
enum TMyPropertyKeys { EMyPropertyAltered = 110 };
@@ -171,7 +168,6 @@
iWidgetInstallPath( KWidgetInstallPath ),
iRegistryBinaryFileName( KWidgetEntryStoreBinaryFile ),
iRegistryXmlFileName( KWidgetEntryStoreXmlFile ),
- iRegistryCWRTXmlFileName( KCWRTWidgetEntryStoreXmlFile ),
iRegistryXmlTempFileName( KWidgetEntryStoreXmlTempFile ),
iPolicyId( 0 )
{
@@ -187,14 +183,13 @@
CWidgetRegistry::~CWidgetRegistry()
{
iEntries.ResetAndDestroy();
- iOldEntries.ResetAndDestroy();
iUsedUids.Close();
// iFs not owned
iAppArch.Close();
delete iInstaller;
iLangDirList.ResetAndDestroy();
- delete iMMCHandler;
delete iXmlProcessor;
+ delete iApaAppListNotifier;
iFs.Close();
LOG_DESTRUCT;
}
@@ -255,8 +250,7 @@
LOG1( "ConstructL internalize done, registry count %d",
iEntries.Count() );
LOG_CLOSE;
- iMMCHandler = CWidgetMMCHandler::NewL( *this, iFs );
- iMMCHandler->Start();
+ iApaAppListNotifier = CApaAppListNotifier::NewL(this,CActive::EPriorityStandard);
}
// ============================================================================
@@ -339,7 +333,7 @@
}
}
#else
- iPolicyId = KErrNotSupported;
+ iPolicyId = KErrNotSupported;
#endif
return iPolicyId;
}
@@ -390,29 +384,6 @@
}
// ============================================================================
-// CWidgetRegistry::GetWidgetOldEntry()
-// Get the widget entry from iOldEntrys array
-//
-// @since 3.1
-// ============================================================================
-//
-TInt CWidgetRegistry::GetWidgetOldEntry(
- const TUid& aUid,
- CWidgetEntry*& aEntry) const
- {
- for(TInt i = 0;i < iOldEntries.Count();i++)
- {
- CWidgetEntry* entry = iOldEntries[i];
- if ( TUid::Uid( (*entry)[EUid] ) == aUid )
- {
- aEntry = entry;
- return i;
- }
- }
- return -1;
- }
-
-// ============================================================================
// CWidgetRegistry::GetWidgetEntry()
// Get the widget entry
//
@@ -556,15 +527,9 @@
// internal dirty flag, will be copied to arg dirty flag at
// end if no leave occurs
TBool dirtyFlag = EFalse;
-
- // Copy the entries so we are able to use them later
- // iOldEntries owns the data and is responcible to ResetAndDestroy()
- for ( TInt i = 0; i < iEntries.Count(); i++ )
- {
- iOldEntries.Append( iEntries[i] );
- }
- // Only reset here as the iOldEntries owns the data
- iEntries.Reset();
+
+ // empty the registry
+ iEntries.ResetAndDestroy();
iUsedUids.Reset();
CleanupClosePushL( appArchList );
@@ -584,15 +549,11 @@
// UIDs already known to app arch be reserved.
for ( TInt i = 0; i < appArchList.Count(); i++ )
{
- // Do not maintain the list of used CWRT widget UIDs
- if ( !TUidAllocator::IsCWRTWidget((appArchList)[i]) )
+ if ( KErrNone != iUsedUids.Append( (appArchList)[i] ) )
{
- if ( KErrNone != iUsedUids.Append( (appArchList)[i] ) )
- {
- // no recovery possible
- doConsistency = EFalse;
- break;
- }
+ // no recovery possible
+ doConsistency = EFalse;
+ break;
}
}
}
@@ -605,23 +566,6 @@
// on error use english
iLprojName = _L("en");
}
-
- // Internalize the CWRT widgets, without consistency checking
- // No multi-drive support for CWRT
- TDriveUnit driveUnit(EDriveC);
- CDir* installedListForDrive = NULL;
- RArray<TInt> installedListForDriveFlags;
- TRAP_IGNORE( // consistency checking doesn't apply to CWRT
- InternalizeXmlL( iRegistryCWRTXmlFileName,
- driveUnit,
- EFalse,
- appArchList,
- appArchListFlags,
- installedListForDrive,
- installedListForDriveFlags,
- dirtyFlag ) );
- delete installedListForDrive;
- installedListForDriveFlags.Close();
// List all drives in the system
TDriveList driveList;
@@ -731,19 +675,13 @@
delete installedListForDrive;
installedListForDriveFlags.Close();
} // for
-
- // appArchList will not contain CWRT widgets, so
- // consistency checking will not apply to them
if ( doConsistency )
{
AppArchListConsistency( appArchList, appArchListFlags );
- }
-
+ }
CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
aDirtyFlag = dirtyFlag;
- // Reset and Destroy entries in iOldEntries array
- iOldEntries.ResetAndDestroy();
LOG1( "Internalize done, dirty flag %d", (TInt)dirtyFlag );
LOG_CLOSE;
}
@@ -774,15 +712,15 @@
readStream.Attach( file );
TInt error = KErrNone;
- TInt entryCount = 0,errorCount =0;
+ TInt entryCount = 0;
TRAP( error, entryCount = readStream.ReadInt32L() );
// TODO should limit entryCount to something like 1024
// for each entry in the registry file
for ( TInt i = 0 ; i < entryCount; i++ )
{
CWidgetEntry* entry = CWidgetEntry::NewL();
- // push as delete entry so if we leave it will be handled
- CleanupDeletePushL( entry );
+ CleanupStack::PushL( entry );
+
// extract one entry
TRAP( error,
entry->InternalizeBinaryL( readStream ) );
@@ -804,13 +742,13 @@
TRAP( error, InsertL( entry ) );
if ( KErrNone != error )
{
- delete entry;
+ CleanupStack::PopAndDestroy( entry );
}
else
{
__ASSERT_DEBUG( res == entry, User::Invariant() );
// Entry was inserted successfully.
- //CleanupStack::Pop( entry );
+ CleanupStack::Pop( entry );
// add uid to AppArchList if not there,
// this can happend due to UID
// reallocation for UID collision resolution
@@ -826,25 +764,15 @@
uidInt, uidInt );
}
}
- else
- {
- // Pop and delete the un-needed entry so it is not left behind.
- errorCount++;
- }
}
else
{
// entry error
- delete entry;
+ CleanupStack::PopAndDestroy( entry );
}
- CleanupStack::Pop(); //entry
} // for
CleanupStack::PopAndDestroy( 2, &file ); // readStream, file
- if ( errorCount != 0 )
- {
- User::Leave(KErrGeneral);
- }
}
// ============================================================================
@@ -939,16 +867,7 @@
aDirtyFlag );
}
if ( NULL != entry )
- {
- CWidgetEntry* entry1 = NULL;
- TInt uid = (*entry)[EUid];
- TInt pos = GetWidgetOldEntry( TUid::Uid( uid ), entry1 );
- if ( pos != -1 )
- {
- entry->SetActive((iOldEntries[pos]->ActiveL()));
- entry->SetFullView((iOldEntries[pos]->GetFullViewState()));
- entry->SetMiniView((iOldEntries[pos]->GetMiniViewState()));
- }
+ {
TRAP( error, InsertL( entry ) );
if ( KErrNone != error )
{
@@ -1005,20 +924,10 @@
// and value as an array of entry indices for that drive
RPtrHashMap< TInt, CArrayFixFlat<TInt> > driveEntryHashMap;
CleanupClosePushL( driveEntryHashMap );
- CArrayFixFlat<TInt>* cwrtWidgetArray = new (ELeave) CArrayFixFlat<TInt>(1);
- CleanupStack::PushL( cwrtWidgetArray );
for (TInt i = 0 ;i < iEntries.Count(); i++)
{
CWidgetEntry* entry = iEntries[i];
-
- // Bypass if the widget is a CWRT widget, they're externalized
- // independently
- if (TUidAllocator::IsCWRTWidget(TUid::Uid((*entry)[EUid]))) {
- cwrtWidgetArray->AppendL(i);
- continue;
- }
-
const TDesC& driveName = (*entry)[EDriveName];
TDriveUnit driveUnit( driveName );
CArrayFixFlat<TInt>* array =
@@ -1108,35 +1017,11 @@
}
}
}
-
- TDriveUnit driveUnit( EDriveC );
- iRegistryXmlTempFileName[0] = driveUnit.Name()[0];
-
- iFs.CreatePrivatePath( driveUnit );
-
- // a transactional file update to protect against
- // disk full, etc: overwrite temp then rename temp to original
-
- TRAPD( error,
- ExternalizeXmlL( iRegistryXmlTempFileName, cwrtWidgetArray ) );
- if ( KErrNone == error )
- {
- // last steps in transactional update
- BaflUtils::DeleteFile( iFs, iRegistryCWRTXmlFileName );
- BaflUtils::RenameFile( iFs,
- iRegistryXmlTempFileName,
- iRegistryCWRTXmlFileName );
- }
- else // handle leave by deleting temp file
- {
- BaflUtils::DeleteFile( iFs, iRegistryXmlTempFileName );
- }
for ( TInt i = 0; i < driveEntryHashMap.Count(); i++ )
{
CleanupStack::Pop();
}
- CleanupStack::PopAndDestroy( cwrtWidgetArray );
CleanupStack::Pop( &driveEntryHashMap );
driveEntryHashMap.ResetAndDestroy();
driveEntryHashMap.Close();
@@ -1890,8 +1775,7 @@
error = iAppArch.GetNextApp( info );
if ( KErrNone == error )
{
- if ( TUidAllocator::IsWidget( info.iUid ) &&
- !TUidAllocator::IsCWRTWidget( info.iUid ) )
+ if ( TUidAllocator::IsWidget( info.iUid ) )
{
LOG2( " widget uid 0x%x (%d)",
(TUint)(info.iUid.iUid), info.iUid.iUid );
@@ -1920,10 +1804,10 @@
{
aUids.Reset();
}
- else
- {
- error = KErrNone;
- }
+ else
+ {
+ error = KErrNone;
+ }
LOG_CODE( if ( aUids.Count() ) )
LOG1( "AppArchWidgetUids done widget count %d",
aUids.Count() );
@@ -2084,7 +1968,7 @@
if ( !((aInstalledListForDriveFlags)[i] & EInstallListFlagEntry ))
{
TEntry dirEntry = (*aInstalledListForDrive)[i];
- if ( 0 == bundleIdentifier.CompareF( dirEntry.iName ) )
+ if ( 0 == bundleIdentifier.Compare( dirEntry.iName ) )
{
(aInstalledListForDriveFlags)[i] |= EInstallListFlagEntry;
result = ETrue;
@@ -2347,9 +2231,7 @@
void CWidgetRegistry::AppArchListConsistency( const RArray<TUid>& aAppArchList,
RArray<TInt>& aAppArchListFlags )
{
- LOG( "AppArchListConsistency" );
- RArray<TUid> deRegisterList( KDefaultWidgetCount );
- CleanupClosePushL(deRegisterList);
+ LOG( "AppArchListConsistency" );
for ( TInt i = 0; i < aAppArchList.Count(); i++ )
{
if ( !( aAppArchListFlags[i] & EAppListFlagEntry ) )
@@ -2357,16 +2239,29 @@
LOG_CODE( TInt uidIntLog = aAppArchList[i].iUid );
LOG2( " deregistered widget 0x%x (%d)",
uidIntLog, uidIntLog );
- deRegisterList.Append(aAppArchList[i]);
+ TRAP_IGNORE( iInstaller->DeregisterWidgetL( aAppArchList[i] ) );
}
}
- if(deRegisterList.Count())
- {
- TRAP_IGNORE( iInstaller->DeregisterWidgetsL( deRegisterList ) );
- }
- CleanupStack::PopAndDestroy(&deRegisterList);
LOG( "AppArchListConsistency done" );
}
-
+void CWidgetRegistry::HandleAppListEvent(TInt aEvent)
+ {
+ TBool dirtyFlag = EFalse;
+ TInt parseError = KErrNone;
+ // Assume usual case and things are consistent
+ // and the registry entry file can be parsed and used.
+ TRAPD( error, InternalizeL( EFalse,
+ EFalse,
+ dirtyFlag,
+ parseError ) );
+ if ( KErrNone == error )
+ {
+ // internalize consistency enforcement may have altered registry
+ if ( dirtyFlag )
+ {
+ TRAP_IGNORE( ExternalizeL(); );
+ }
+ }
+ }
// End of File