webengine/widgetregistry/Server/src/WidgetRegistry.cpp
changeset 15 60c5402cb945
parent 11 c8a366e56285
child 25 0ed94ceaa377
equal deleted inserted replaced
11:c8a366e56285 15:60c5402cb945
    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 <xmlengxestd.h>
    32 #include <xmlengxestd.h>
    33 #include "WidgetMMCHandler.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>
   187     iUsedUids.Close();
   186     iUsedUids.Close();
   188     // iFs not owned
   187     // iFs not owned
   189     iAppArch.Close();
   188     iAppArch.Close();
   190     delete iInstaller;
   189     delete iInstaller;
   191     iLangDirList.ResetAndDestroy();
   190     iLangDirList.ResetAndDestroy();
   192     delete iMMCHandler;
       
   193     delete iXmlProcessor;
   191     delete iXmlProcessor;
   194 
   192 	delete iApaAppListNotifier;
   195     iFs.Close();
   193     iFs.Close();
   196     LOG_DESTRUCT;
   194     LOG_DESTRUCT;
   197     }
   195     }
   198 
   196 
   199 // ============================================================================
   197 // ============================================================================
   218     // If internalizing leaves, then the registry will be out-of-sync
   216     // If internalizing leaves, then the registry will be out-of-sync
   219     // with the installed widgets and apparc.  But that's okay since
   217     // with the installed widgets and apparc.  But that's okay since
   220     // it should be detected and corrected once the resource limit
   218     // it should be detected and corrected once the resource limit
   221     // that caused the leave is removed.
   219     // that caused the leave is removed.
   222     TBool dirtyFlag = EFalse;
   220     TBool dirtyFlag = EFalse;
       
   221     TInt parseError = KErrNone;
   223     iXmlProcessor = CWidgetRegistryXml::NewL();
   222     iXmlProcessor = CWidgetRegistryXml::NewL();
   224     TRAP_IGNORE( InternalizeL( dirtyFlag ) );
   223     // For first attempt assume usual case that things are consistent
       
   224     // and the registry entry file can be parsed and used.
       
   225     TRAP_IGNORE( InternalizeL( EFalse, // aDoConsistency,
       
   226                                EFalse, // aIgnoreParseError
       
   227                                dirtyFlag,
       
   228                                parseError ) );
       
   229     if ( parseError )
       
   230         {
       
   231         // Special case where we need to do consistency because
       
   232         // the widget registry entry file is corrupt.
       
   233         TRAP_IGNORE( InternalizeL( ETrue, // aDoConsistency,
       
   234                                    ETrue, // aIgnoreParseError
       
   235                                    dirtyFlag,
       
   236                                    parseError ) );
       
   237         }
   225     if ( dirtyFlag )
   238     if ( dirtyFlag )
   226         {
   239         {
   227         // Basically same reason to ignore leaves here.
   240         // Basically same reason to ignore leaves here.
   228         TRAP_IGNORE( ExternalizeL() );
   241         TRAP_IGNORE( ExternalizeL() );
   229         }
   242         }
   235 #endif
   248 #endif
   236 
   249 
   237     LOG1( "ConstructL internalize done, registry count %d",
   250     LOG1( "ConstructL internalize done, registry count %d",
   238               iEntries.Count() );
   251               iEntries.Count() );
   239     LOG_CLOSE;
   252     LOG_CLOSE;
   240 
   253     iApaAppListNotifier = CApaAppListNotifier::NewL(this,CActive::EPriorityStandard);
   241     iMMCHandler = CWidgetMMCHandler::NewL( *this, iFs );
       
   242     iMMCHandler->Start();
       
   243     }
   254     }
   244 
   255 
   245 // ============================================================================
   256 // ============================================================================
   246 // CWidgetRegistry::FetchSecurityPolicyIdL()
   257 // CWidgetRegistry::FetchSecurityPolicyIdL()
   247 // Get policyId from security manager
   258 // Get policyId from security manager
   494 // Read entry info from data file into memory
   505 // Read entry info from data file into memory
   495 //
   506 //
   496 // @since 3.1
   507 // @since 3.1
   497 // ============================================================================
   508 // ============================================================================
   498 //
   509 //
   499 void CWidgetRegistry::InternalizeL( TBool& aDirtyFlag )
   510 void CWidgetRegistry::InternalizeL( TBool doConsistency, // in param
       
   511                                     TBool aIgnoreParseError, // in param
       
   512                                     TBool& aDirtyFlag, // out param
       
   513                                     TInt& aParseError )// out param
   500     {
   514     {
   501     LOG_OPEN;
   515     LOG_OPEN;
   502     LOG( "Internalize" );
   516     LOG( "Internalize" );
   503 
   517 
   504     // prepare for consistency enforcement
   518     // prepare for consistency enforcement
   518     iEntries.ResetAndDestroy();
   532     iEntries.ResetAndDestroy();
   519     iUsedUids.Reset();
   533     iUsedUids.Reset();
   520 
   534 
   521     CleanupClosePushL( appArchList );
   535     CleanupClosePushL( appArchList );
   522     CleanupClosePushL( appArchListFlags );
   536     CleanupClosePushL( appArchListFlags );
   523     TBool doConsistency = AppArchWidgets( appArchList, appArchListFlags );
   537     if ( doConsistency )
       
   538         {
       
   539         doConsistency = AppArchWidgets( appArchList, appArchListFlags );
       
   540         }
   524     if ( doConsistency )
   541     if ( doConsistency )
   525         {
   542         {
   526 
   543 
   527         // UIDs are the key differentiator of apps in app arch.  The
   544         // UIDs are the key differentiator of apps in app arch.  The
   528         // widget implementation used BundleID to differentiate
   545         // widget implementation used BundleID to differentiate
   620         // installed widgets and apparc.  But that's okay since it
   637         // installed widgets and apparc.  But that's okay since it
   621         // should be detected and corrected once the resource limit
   638         // should be detected and corrected once the resource limit
   622         // that caused the leave is removed.
   639         // that caused the leave is removed.
   623         if ( xmlExists )
   640         if ( xmlExists )
   624             {
   641             {
   625             TRAP_IGNORE( InternalizeXmlL( iRegistryXmlFileName,
   642             TRAP( aParseError,
   626                                           driveUnit,
   643                   InternalizeXmlL( iRegistryXmlFileName,
   627                                           doConsistency,
   644                                    driveUnit,
   628                                           appArchList,
   645                                    doConsistency,
   629                                           appArchListFlags,
   646                                    appArchList,
   630                                           installedListForDrive,
   647                                    appArchListFlags,
   631                                           installedListForDriveFlags,
   648                                    installedListForDrive,
   632                                           dirtyFlag ) );
   649                                    installedListForDriveFlags,
       
   650                                    dirtyFlag ) );
   633             }
   651             }
   634         else if ( binaryExists )
   652         else if ( binaryExists )
   635             {
   653             {
   636             TRAP_IGNORE( InternalizeBinaryL( iRegistryBinaryFileName,
   654             TRAP( aParseError,
   637                                              driveUnit,
   655                   InternalizeBinaryL( iRegistryBinaryFileName,
   638                                              doConsistency,
   656                                       driveUnit,
   639                                              appArchList,
   657                                       doConsistency,
   640                                              appArchListFlags,
   658                                       appArchList,
   641                                              installedListForDrive,
   659                                       appArchListFlags,
   642                                              installedListForDriveFlags,
   660                                       installedListForDrive,
   643                                              dirtyFlag ) );
   661                                       installedListForDriveFlags,
       
   662                                       dirtyFlag ) );
       
   663             }
       
   664         if ( !aIgnoreParseError && aParseError )
       
   665             {
       
   666             User::Leave( aParseError );
   644             }
   667             }
   645 
   668 
   646         if ( doConsistency )
   669         if ( doConsistency )
   647             {
   670             {
   648             InstallDirConsistency( installedListForDrive,
   671             InstallDirConsistency( installedListForDrive,
  2220             }
  2243             }
  2221         }
  2244         }
  2222     LOG( "AppArchListConsistency done" );
  2245     LOG( "AppArchListConsistency done" );
  2223     }
  2246     }
  2224 
  2247 
  2225 
  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     }
  2226 // End of File
  2267 // End of File