webengine/widgetregistry/Server/src/WidgetRegistry.cpp
branchRCL_3
changeset 35 1f3c3f2f5b0a
parent 34 220a17280356
child 47 e1bea15f9a39
equal deleted inserted replaced
34:220a17280356 35:1f3c3f2f5b0a
    61       "a:\\private\\10282822\\" );
    61       "a:\\private\\10282822\\" );
    62 _LIT( KWidgetEntryStoreBinaryFile,
    62 _LIT( KWidgetEntryStoreBinaryFile,
    63       "a:\\private\\10282f06\\WidgetEntryStore.dat" );
    63       "a:\\private\\10282f06\\WidgetEntryStore.dat" );
    64 _LIT( KWidgetEntryStoreXmlFile,
    64 _LIT( KWidgetEntryStoreXmlFile,
    65       "a:\\private\\10282f06\\WidgetEntryStore.xml" );
    65       "a:\\private\\10282f06\\WidgetEntryStore.xml" );
       
    66 _LIT( KCWRTWidgetEntryStoreXmlFile,
       
    67       "c:\\private\\10282f06\\CWRTWidgetEntryStore.xml" );
    66 _LIT( KWidgetEntryStoreXmlTempFile,
    68 _LIT( KWidgetEntryStoreXmlTempFile,
    67       "a:\\private\\10282f06\\WidgetEntryStoreTemp.xml" );
    69       "a:\\private\\10282f06\\WidgetEntryStoreTemp.xml" );
    68 _LIT( KWidgetDirFile, "widget_lproj.xml" );
    70 _LIT( KWidgetDirFile, "widget_lproj.xml" );
    69 _LIT( KWidgetAccessPolicy, "WidgetAccessPolicy.xml" );
    71 _LIT( KWidgetAccessPolicy, "WidgetAccessPolicy.xml" );
    70 _LIT( KWidgetPolicyIdFile, "WidgetPolicyId.dat" );
    72 _LIT( KWidgetPolicyIdFile, "WidgetPolicyId.dat" );
   167 CWidgetRegistry::CWidgetRegistry( RFs& aFs ):
   169 CWidgetRegistry::CWidgetRegistry( RFs& aFs ):
   168     iFs( aFs ),
   170     iFs( aFs ),
   169     iWidgetInstallPath( KWidgetInstallPath ),
   171     iWidgetInstallPath( KWidgetInstallPath ),
   170     iRegistryBinaryFileName( KWidgetEntryStoreBinaryFile ),
   172     iRegistryBinaryFileName( KWidgetEntryStoreBinaryFile ),
   171     iRegistryXmlFileName( KWidgetEntryStoreXmlFile ),
   173     iRegistryXmlFileName( KWidgetEntryStoreXmlFile ),
       
   174     iRegistryCWRTXmlFileName( KCWRTWidgetEntryStoreXmlFile ),
   172     iRegistryXmlTempFileName( KWidgetEntryStoreXmlTempFile ),
   175     iRegistryXmlTempFileName( KWidgetEntryStoreXmlTempFile ),
   173     iPolicyId( 0 )
   176     iPolicyId( 0 )
   174     {
   177     {
   175     }
   178     }
   176 
   179 
   334                 CleanupStack::PopAndDestroy( secMgr );
   337                 CleanupStack::PopAndDestroy( secMgr );
   335                 }
   338                 }
   336             }
   339             }
   337         }
   340         }
   338 #else
   341 #else
   339 	iPolicyId = KErrNotSupported;
   342   iPolicyId = KErrNotSupported;
   340 #endif    
   343 #endif    
   341     return iPolicyId;
   344     return iPolicyId;
   342     }
   345     }
   343 
   346 
   344 // ============================================================================
   347 // ============================================================================
   579         // But once widgets are installed, they are assigned a unique
   582         // But once widgets are installed, they are assigned a unique
   580         // UID.  For UID allocation purposes, it is important that
   583         // UID.  For UID allocation purposes, it is important that
   581         // UIDs already known to app arch be reserved.
   584         // UIDs already known to app arch be reserved.
   582         for ( TInt i = 0; i < appArchList.Count(); i++ )
   585         for ( TInt i = 0; i < appArchList.Count(); i++ )
   583             {
   586             {
   584             if ( KErrNone != iUsedUids.Append( (appArchList)[i] ) )
   587             // Do not maintain the list of used CWRT widget UIDs
   585                 {
   588             if ( !TUidAllocator::IsCWRTWidget((appArchList)[i]) )
   586                 // no recovery possible
   589                 {
   587                 doConsistency = EFalse;
   590                   if ( KErrNone != iUsedUids.Append( (appArchList)[i] ) )
   588                 break;
   591                       {
       
   592                       // no recovery possible
       
   593                       doConsistency = EFalse;
       
   594                       break;
       
   595                       }
   589                 }
   596                 }
   590             }
   597             }
   591         }
   598         }
   592     LOG2( " iUsedUids %d and doConsistency %d",
   599     LOG2( " iUsedUids %d and doConsistency %d",
   593           (TInt)(iUsedUids.Count()), (TInt)doConsistency );
   600           (TInt)(iUsedUids.Count()), (TInt)doConsistency );
   596     if ( KErrNone != error )
   603     if ( KErrNone != error )
   597         {
   604         {
   598         // on error use english
   605         // on error use english
   599         iLprojName = _L("en");
   606         iLprojName = _L("en");
   600         }
   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();
   601 
   625 
   602     // List all drives in the system
   626     // List all drives in the system
   603     TDriveList driveList;
   627     TDriveList driveList;
   604     User::LeaveIfError( iFs.DriveList(driveList) );
   628     User::LeaveIfError( iFs.DriveList(driveList) );
   605 
   629 
   705                                    dirtyFlag );
   729                                    dirtyFlag );
   706             }
   730             }
   707         delete installedListForDrive;
   731         delete installedListForDrive;
   708         installedListForDriveFlags.Close();
   732         installedListForDriveFlags.Close();
   709         } // for
   733         } // for
       
   734 
       
   735     // appArchList will not contain CWRT widgets, so 
       
   736     // consistency checking will not apply to them
   710     if ( doConsistency )
   737     if ( doConsistency )
   711         {
   738         {
   712         AppArchListConsistency( appArchList, appArchListFlags );
   739         AppArchListConsistency( appArchList, appArchListFlags );
   713         }    
   740         }
       
   741 
   714     CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
   742     CleanupStack::PopAndDestroy( 2, &appArchList );//appArchListFlags, appArchList
   715 
   743 
   716     aDirtyFlag = dirtyFlag;
   744     aDirtyFlag = dirtyFlag;
   717     // Reset and Destroy entries in iOldEntries array
   745     // Reset and Destroy entries in iOldEntries array
   718     iOldEntries.ResetAndDestroy();
   746     iOldEntries.ResetAndDestroy();
   975     // 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,
   976     // 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
   977     // and value as an array of entry indices for that drive
  1005     // and value as an array of entry indices for that drive
   978     RPtrHashMap< TInt, CArrayFixFlat<TInt> > driveEntryHashMap;
  1006     RPtrHashMap< TInt, CArrayFixFlat<TInt> > driveEntryHashMap;
   979     CleanupClosePushL( driveEntryHashMap );
  1007     CleanupClosePushL( driveEntryHashMap );
       
  1008     CArrayFixFlat<TInt>* cwrtWidgetArray = new (ELeave) CArrayFixFlat<TInt>(1);
       
  1009     CleanupStack::PushL( cwrtWidgetArray );
   980 
  1010 
   981     for (TInt i = 0 ;i < iEntries.Count(); i++)
  1011     for (TInt i = 0 ;i < iEntries.Count(); i++)
   982         {
  1012         {
   983         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         
   984         const TDesC& driveName = (*entry)[EDriveName];
  1022         const TDesC& driveName = (*entry)[EDriveName];
   985         TDriveUnit driveUnit( driveName );
  1023         TDriveUnit driveUnit( driveName );
   986         CArrayFixFlat<TInt>* array =
  1024         CArrayFixFlat<TInt>* array =
   987             driveEntryHashMap.Find( driveUnit );
  1025             driveEntryHashMap.Find( driveUnit );
   988         if( !array )
  1026         if( !array )
  1068                 {
  1106                 {
  1069                 BaflUtils::DeleteFile( iFs, iRegistryXmlTempFileName );
  1107                 BaflUtils::DeleteFile( iFs, iRegistryXmlTempFileName );
  1070                 }
  1108                 }
  1071             }
  1109             }
  1072         }
  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          }
  1073 
  1134 
  1074     for ( TInt i = 0; i < driveEntryHashMap.Count(); i++ )
  1135     for ( TInt i = 0; i < driveEntryHashMap.Count(); i++ )
  1075         {
  1136         {
  1076         CleanupStack::Pop();
  1137         CleanupStack::Pop();
  1077         }
  1138         }
       
  1139     CleanupStack::PopAndDestroy( cwrtWidgetArray );
  1078     CleanupStack::Pop( &driveEntryHashMap );
  1140     CleanupStack::Pop( &driveEntryHashMap );
  1079     driveEntryHashMap.ResetAndDestroy();
  1141     driveEntryHashMap.ResetAndDestroy();
  1080     driveEntryHashMap.Close();
  1142     driveEntryHashMap.Close();
  1081     }
  1143     }
  1082 
  1144 
  1826     do
  1888     do
  1827         {
  1889         {
  1828         error = iAppArch.GetNextApp( info );
  1890         error = iAppArch.GetNextApp( info );
  1829         if ( KErrNone == error )
  1891         if ( KErrNone == error )
  1830             {
  1892             {
  1831             if ( TUidAllocator::IsWidget( info.iUid ) )
  1893             if ( TUidAllocator::IsWidget( info.iUid ) &&
       
  1894                  !TUidAllocator::IsCWRTWidget( info.iUid ) )
  1832                 {
  1895                 {
  1833                 LOG2( " widget uid 0x%x (%d)",
  1896                 LOG2( " widget uid 0x%x (%d)",
  1834                           (TUint)(info.iUid.iUid), info.iUid.iUid );
  1897                           (TUint)(info.iUid.iUid), info.iUid.iUid );
  1835                 error = aUids.Append( info.iUid );
  1898                 error = aUids.Append( info.iUid );
  1836                 if ( KErrNone !=  error )
  1899                 if ( KErrNone !=  error )
  1855         } while ( RApaLsSession::ENoMoreAppsInList != error );
  1918         } while ( RApaLsSession::ENoMoreAppsInList != error );
  1856     if ( RApaLsSession::ENoMoreAppsInList != error )
  1919     if ( RApaLsSession::ENoMoreAppsInList != error )
  1857         {
  1920         {
  1858         aUids.Reset();
  1921         aUids.Reset();
  1859         }
  1922         }
  1860 	else 
  1923   else 
  1861 		{
  1924     {
  1862 		error = KErrNone;
  1925     error = KErrNone;
  1863 		}
  1926     }
  1864     LOG_CODE( if ( aUids.Count() ) )
  1927     LOG_CODE( if ( aUids.Count() ) )
  1865     LOG1( "AppArchWidgetUids done widget count %d",
  1928     LOG1( "AppArchWidgetUids done widget count %d",
  1866               aUids.Count() );
  1929               aUids.Count() );
  1867     LOG_CODE( else )
  1930     LOG_CODE( else )
  1868     LOG( "AppArchWidgetUids done error NULL list" );
  1931     LOG( "AppArchWidgetUids done error NULL list" );
  2295             TRAP_IGNORE( iInstaller->DeregisterWidgetL( aAppArchList[i] ) );
  2358             TRAP_IGNORE( iInstaller->DeregisterWidgetL( aAppArchList[i] ) );
  2296             }
  2359             }
  2297         }
  2360         }
  2298     LOG( "AppArchListConsistency done" );
  2361     LOG( "AppArchListConsistency done" );
  2299     }
  2362     }
       
  2363 
       
  2364 
  2300 // End of File
  2365 // End of File