webengine/widgetregistry/Server/src/WidgetRegistry.cpp
changeset 36 0ed94ceaa377
parent 27 60c5402cb945
child 37 cb62a4f66ebe
equal deleted inserted replaced
32:9a9a761f03f1 36:0ed94ceaa377
    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
   181 // ============================================================================
   182 // ============================================================================
   182 //
   183 //
   183 CWidgetRegistry::~CWidgetRegistry()
   184 CWidgetRegistry::~CWidgetRegistry()
   184     {
   185     {
   185     iEntries.ResetAndDestroy();
   186     iEntries.ResetAndDestroy();
       
   187     iOldEntries.ResetAndDestroy();
   186     iUsedUids.Close();
   188     iUsedUids.Close();
   187     // iFs not owned
   189     // iFs not owned
   188     iAppArch.Close();
   190     iAppArch.Close();
   189     delete iInstaller;
   191     delete iInstaller;
   190     iLangDirList.ResetAndDestroy();
   192     iLangDirList.ResetAndDestroy();
       
   193     delete iMMCHandler;
   191     delete iXmlProcessor;
   194     delete iXmlProcessor;
   192 	delete iApaAppListNotifier;
       
   193     iFs.Close();
   195     iFs.Close();
   194     LOG_DESTRUCT;
   196     LOG_DESTRUCT;
   195     }
   197     }
   196 
   198 
   197 // ============================================================================
   199 // ============================================================================
   248 #endif
   250 #endif
   249 
   251 
   250     LOG1( "ConstructL internalize done, registry count %d",
   252     LOG1( "ConstructL internalize done, registry count %d",
   251               iEntries.Count() );
   253               iEntries.Count() );
   252     LOG_CLOSE;
   254     LOG_CLOSE;
   253     iApaAppListNotifier = CApaAppListNotifier::NewL(this,CActive::EPriorityStandard);
   255     iMMCHandler = CWidgetMMCHandler::NewL( *this, iFs );
       
   256     iMMCHandler->Start();
   254     }
   257     }
   255 
   258 
   256 // ============================================================================
   259 // ============================================================================
   257 // CWidgetRegistry::FetchSecurityPolicyIdL()
   260 // CWidgetRegistry::FetchSecurityPolicyIdL()
   258 // Get policyId from security manager
   261 // Get policyId from security manager
   382         }
   385         }
   383     return -1;
   386     return -1;
   384     }
   387     }
   385 
   388 
   386 // ============================================================================
   389 // ============================================================================
       
   390 // CWidgetRegistry::GetWidgetOldEntry()
       
   391 // Get the widget entry from iOldEntrys array
       
   392 //
       
   393 // @since 3.1
       
   394 // ============================================================================
       
   395 //
       
   396 TInt CWidgetRegistry::GetWidgetOldEntry(
       
   397     const TUid& aUid,
       
   398     CWidgetEntry*& aEntry) const
       
   399     {
       
   400     for(TInt i = 0;i < iOldEntries.Count();i++)
       
   401         {
       
   402         CWidgetEntry* entry = iOldEntries[i];
       
   403         if ( TUid::Uid( (*entry)[EUid] ) == aUid )
       
   404             {
       
   405             aEntry = entry;
       
   406             return i;
       
   407             }
       
   408         }
       
   409     return -1;
       
   410     }
       
   411 
       
   412 // ============================================================================
   387 // CWidgetRegistry::GetWidgetEntry()
   413 // CWidgetRegistry::GetWidgetEntry()
   388 // Get the widget entry
   414 // Get the widget entry
   389 //
   415 //
   390 // @since 3.1
   416 // @since 3.1
   391 // ============================================================================
   417 // ============================================================================
   525     aDirtyFlag = EFalse;
   551     aDirtyFlag = EFalse;
   526 
   552 
   527     // internal dirty flag, will be copied to arg dirty flag at
   553     // internal dirty flag, will be copied to arg dirty flag at
   528     // end if no leave occurs
   554     // end if no leave occurs
   529     TBool dirtyFlag = EFalse;
   555     TBool dirtyFlag = EFalse;
   530 
   556     
   531     // empty the registry
   557     // Copy the entries so we are able to use them later
   532     iEntries.ResetAndDestroy();
   558     // iOldEntries owns the data and is responcible to ResetAndDestroy()
       
   559     for ( TInt i = 0; i < iEntries.Count(); i++ )
       
   560         {
       
   561         iOldEntries.Append( iEntries[i] );
       
   562         }
       
   563     // Only reset here as the iOldEntries owns the data
       
   564     iEntries.Reset();
   533     iUsedUids.Reset();
   565     iUsedUids.Reset();
   534 
   566 
   535     CleanupClosePushL( appArchList );
   567     CleanupClosePushL( appArchList );
   536     CleanupClosePushL( appArchListFlags );
   568     CleanupClosePushL( appArchListFlags );
   537     if ( doConsistency )
   569     if ( doConsistency )
   680         AppArchListConsistency( appArchList, appArchListFlags );
   712         AppArchListConsistency( appArchList, appArchListFlags );
   681         }    
   713         }    
   682     CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
   714     CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
   683 
   715 
   684     aDirtyFlag = dirtyFlag;
   716     aDirtyFlag = dirtyFlag;
       
   717     // Reset and Destroy entries in iOldEntries array
       
   718     iOldEntries.ResetAndDestroy();
   685     LOG1( "Internalize done, dirty flag %d", (TInt)dirtyFlag );
   719     LOG1( "Internalize done, dirty flag %d", (TInt)dirtyFlag );
   686     LOG_CLOSE;
   720     LOG_CLOSE;
   687     }
   721     }
   688 
   722 
   689 // ============================================================================
   723 // ============================================================================
   710     RFileReadStream readStream;
   744     RFileReadStream readStream;
   711     CleanupClosePushL( readStream );
   745     CleanupClosePushL( readStream );
   712     readStream.Attach( file );
   746     readStream.Attach( file );
   713 
   747 
   714     TInt error = KErrNone;
   748     TInt error = KErrNone;
   715     TInt entryCount = 0;
   749     TInt entryCount = 0,errorCount =0;
   716     TRAP( error, entryCount = readStream.ReadInt32L() );
   750     TRAP( error, entryCount = readStream.ReadInt32L() );
   717     // TODO should limit entryCount to something like 1024
   751     // TODO should limit entryCount to something like 1024
   718     // for each entry in the registry file
   752     // for each entry in the registry file
   719     for ( TInt i = 0 ; i < entryCount; i++ )
   753     for ( TInt i = 0 ; i < entryCount; i++ )
   720         {
   754         {
   721         CWidgetEntry* entry = CWidgetEntry::NewL();
   755         CWidgetEntry* entry = CWidgetEntry::NewL();
   722         CleanupStack::PushL( entry );
   756         // push as delete entry so if we leave it will be handled
   723 
   757         CleanupDeletePushL( entry );
   724         // extract one entry
   758         // extract one entry
   725         TRAP( error,
   759         TRAP( error,
   726               entry->InternalizeBinaryL( readStream ) );
   760               entry->InternalizeBinaryL( readStream ) );
   727         if ( KErrNone == error )
   761         if ( KErrNone == error )
   728             {
   762             {
   762                         }
   796                         }
   763                     LOG2( " entry 0x%x (%d) added to registry",
   797                     LOG2( " entry 0x%x (%d) added to registry",
   764                               uidInt, uidInt );
   798                               uidInt, uidInt );
   765                     }
   799                     }
   766                 }
   800                 }
       
   801             else
       
   802                 {
       
   803                 // Pop and delete the un-needed entry so it is not left behind.
       
   804                 errorCount++; 
       
   805                 CleanupStack::PopAndDestroy( entry );                
       
   806                 }
   767             }
   807             }
   768         else
   808         else
   769             {
   809             {
   770             // entry error
   810             // entry error
   771             CleanupStack::PopAndDestroy( entry );
   811             CleanupStack::PopAndDestroy( entry );
   772             }
   812             }
   773         } // for
   813         } // for
   774 
   814 
   775     CleanupStack::PopAndDestroy( 2, &file ); // readStream, file
   815     CleanupStack::PopAndDestroy( 2, &file ); // readStream, file
       
   816     if ( errorCount != 0 )
       
   817         {
       
   818         User::Leave(KErrGeneral);
       
   819         }
   776     }
   820     }
   777 
   821 
   778 // ============================================================================
   822 // ============================================================================
   779 // CWidgetRegistry::InternalizeXmlL()
   823 // CWidgetRegistry::InternalizeXmlL()
   780 // Read entry info from data file into memory
   824 // Read entry info from data file into memory
   865                                                   aInstalledListForDriveFlags,
   909                                                   aInstalledListForDriveFlags,
   866                                                   aDriveUnit,
   910                                                   aDriveUnit,
   867                                                   aDirtyFlag );
   911                                                   aDirtyFlag );
   868                         }
   912                         }
   869                     if ( NULL != entry )
   913                     if ( NULL != entry )
   870                         {
   914                         { 
       
   915                         CWidgetEntry* entry1 = NULL;
       
   916                         TInt uid = (*entry)[EUid];
       
   917                         TInt pos  = GetWidgetOldEntry( TUid::Uid( uid ), entry1 );
       
   918                         if ( pos != -1 )
       
   919                             {
       
   920                             entry->SetActive((iOldEntries[pos]->ActiveL()));
       
   921                             entry->SetFullView((iOldEntries[pos]->GetFullViewState()));
       
   922                             entry->SetMiniView((iOldEntries[pos]->GetMiniViewState()));
       
   923                             }
   871                         TRAP( error, InsertL( entry ) );
   924                         TRAP( error, InsertL( entry ) );
   872                         if ( KErrNone != error )
   925                         if ( KErrNone != error )
   873                             {
   926                             {
   874                             delete entry;
   927                             delete entry;
   875                             }
   928                             }
  2242             TRAP_IGNORE( iInstaller->DeregisterWidgetL( aAppArchList[i] ) );
  2295             TRAP_IGNORE( iInstaller->DeregisterWidgetL( aAppArchList[i] ) );
  2243             }
  2296             }
  2244         }
  2297         }
  2245     LOG( "AppArchListConsistency done" );
  2298     LOG( "AppArchListConsistency done" );
  2246     }
  2299     }
  2247 
       
  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     }
       
  2267 // End of File
  2300 // End of File