contentpublishingsrv/contentharvester/factorysettingsplugin/src/chfactorysettingsplugin.cpp
changeset 60 f62f87b200ec
parent 0 79c6a41cd166
equal deleted inserted replaced
4:1a2a00e78665 60:f62f87b200ec
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  
    14 * Description:
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 
    19 
    20 #include <ecom/implementationproxy.h>
    20 #include <ecom/implementationproxy.h>
    21 #include <sacls.h>
    21 #include <sacls.h>
    22 
    22 
    23 #include "chfactorysettingsplugin.h"
       
    24 #include "chfactorysettingsparser.h"
       
    25 #include "chfactorysettingsinstallnotifier.h"
    23 #include "chfactorysettingsinstallnotifier.h"
    26 #include "cpdebug.h"
    24 #include "cpdebug.h"
    27 #include "chdbstatehandler.h"
    25 #include "chdbstatehandler.h"
       
    26 #include "chfactorysettingsdomparser.h"
       
    27 #include "chfactorysettingsplugin.h"
    28 
    28 
    29 // LOCAL CONSTANTS AND MACROS
    29 // LOCAL CONSTANTS AND MACROS
    30 const TInt KADatFactorySettingsServerPluginUid( 0x102830EF);
    30 const TInt KADatFactorySettingsServerPluginUid( 0x102830EF);
    31 // Dynamically loaded data storage handler
    31 // Dynamically loaded data storage handler
    32 
    32 
    88     iFileNewList = new (ELeave) CDesCArrayFlat(KDefaultGranularity);
    88     iFileNewList = new (ELeave) CDesCArrayFlat(KDefaultGranularity);
    89     User::LeaveIfError( iFs.Connect( ) );
    89     User::LeaveIfError( iFs.Connect( ) );
    90     iInstallNotifier = CCHFactorySettingsInstallNotifier::NewL( this,
    90     iInstallNotifier = CCHFactorySettingsInstallNotifier::NewL( this,
    91         KUidSystemCategory, KSAUidSoftwareInstallKeyValue );
    91         KUidSystemCategory, KSAUidSoftwareInstallKeyValue );
    92 
    92 
    93     iParser = CCHFactorySettingsParser::NewL( iCPSInterface );
    93     iParser = CCHFactorySettingsDOMParser::NewL( iCPSInterface, iFs ); // mw
    94 
    94 
    95     iFileMan = CFileMan::NewL( iFs );
    95     iFileMan = CFileMan::NewL( iFs );
    96     iFilePath.CreateL( KMaxPath );
    96     iFilePath.CreateL( KMaxPath );
    97 
    97 
    98     iFs.CreatePrivatePath( EDriveC );
    98     iFs.CreatePrivatePath( EDriveC );
   151     delete iDBStateHandler;
   151     delete iDBStateHandler;
   152     }
   152     }
   153 
   153 
   154 // ----------------------------------------------------------------------------
   154 // ----------------------------------------------------------------------------
   155 // CCHFactorySettings::UpdateL
   155 // CCHFactorySettings::UpdateL
   156 // 
   156 //
   157 // ----------------------------------------------------------------------------
   157 // ----------------------------------------------------------------------------
   158 //	
   158 //
   159 void CCHFactorySettings::UpdateL()
   159 void CCHFactorySettings::UpdateL()
   160     {
   160     {
   161     CP_DEBUG(_L8("CCHFactorySettings::UpdateL" ));
   161     CP_DEBUG(_L8("CCHFactorySettings::UpdateL" ));
   162     CheckDrivesL( ); // fill in list with file names from all drives
   162     CheckDrivesL( ); // fill in list with file names from all drives
   163     AddNewL( ); // if any of them isn't added to db then add
   163     AddNewL( ); // if any of them isn't added to db then add
   164     UnInstallL( ); // if any of files from any drive was removed remove data 
   164     UnInstallL( ); // if any of files from any drive was removed remove data
   165     // from DB	 
   165     // from DB
   166 
   166 
   167     }
   167     }
   168 
   168 
   169 // ----------------------------------------------------------------------------
   169 // ----------------------------------------------------------------------------
   170 // CCHFactorySettings::AddNewL
   170 // CCHFactorySettings::AddNewL
   171 // Add new entries after sis intallation.
   171 // Add new entries after sis intallation.
   172 // ----------------------------------------------------------------------------
   172 // ----------------------------------------------------------------------------
   173 //    
   173 //
   174 void CCHFactorySettings::AddNewL()
   174 void CCHFactorySettings::AddNewL()
   175     {
   175     {
   176     CP_DEBUG(_L8("CCHFactorySettings::AddNewL" ));
   176     CP_DEBUG(_L8("CCHFactorySettings::AddNewL" ));
   177     CDir* fileListInstalled= NULL;
   177     CDir* fileListInstalled= NULL;
   178     RBuf filePath;
   178     RBuf filePath;
   186     CleanupStack::PushL( fileListInstalled );
   186     CleanupStack::PushL( fileListInstalled );
   187 
   187 
   188     for ( TInt i(0); i<iFileNewList->Count( ); i++ )
   188     for ( TInt i(0); i<iFileNewList->Count( ); i++ )
   189         {
   189         {
   190         TBool parse(ETrue);
   190         TBool parse(ETrue);
   191         TPtrC fileNewName = 
   191         TPtrC fileNewName =
   192             (*iFileNewList)[i].Mid( (*iFileNewList)[i].LocateReverse( '\\' ) + 1 );
   192             (*iFileNewList)[i].Mid( (*iFileNewList)[i].LocateReverse( '\\' ) + 1 );
   193         TInt count = fileListInstalled->Count( );
   193         TInt count = fileListInstalled->Count( );
   194         for ( TInt j(0); j< count; j++ )
   194         for ( TInt j(0); j< count; j++ )
   195             {
   195             {
   196             TPtrC existingFile = (*fileListInstalled)[j].iName;
   196             TPtrC existingFile = (*fileListInstalled)[j].iName;
   204                 break;
   204                 break;
   205                 }
   205                 }
   206             }
   206             }
   207         if ( parse )
   207         if ( parse )
   208             {
   208             {
   209             //file wasn't found in afterinstallation dir 
   209             //file wasn't found in afterinstallation dir
   210             //so should be copied and entries install  
   210             //so should be copied and entries install
   211             TBool fileOpened(ETrue);
   211             TBool fileOpened(ETrue);
   212             iFs.IsFileOpen( (*iFileNewList)[i], fileOpened );
   212             iFs.IsFileOpen( (*iFileNewList)[i], fileOpened );
   213 
   213 
   214             if ( !fileOpened )
   214             if ( !fileOpened )
   215                 {
   215                 {
   216                 TInt error = iParser->RestoreL( (*iFileNewList)[i], EFalse );
   216                 TInt error = iParser->Restore( (*iFileNewList)[i], EFalse );
   217                 if ( error == KErrNone )
   217                 if ( error == KErrNone )
   218                     {
   218                     {
   219                     iFileMan->Copy( (*iFileNewList)[i], filePath );
   219                     iFileMan->Copy( (*iFileNewList)[i], filePath );
   220                     }
   220                     }
   221                 }
   221                 }
   228 
   228 
   229 // ----------------------------------------------------------------------------
   229 // ----------------------------------------------------------------------------
   230 // CCHFactorySettings::UnInstallL
   230 // CCHFactorySettings::UnInstallL
   231 // Removes entries after uninstallation.
   231 // Removes entries after uninstallation.
   232 // ----------------------------------------------------------------------------
   232 // ----------------------------------------------------------------------------
   233 //  
   233 //
   234 void CCHFactorySettings::UnInstallL()
   234 void CCHFactorySettings::UnInstallL()
   235     {
   235     {
   236     CP_DEBUG(_L8("CCHFactorySettings::UnInstallL" ));
   236     CP_DEBUG(_L8("CCHFactorySettings::UnInstallL" ));
   237     TBool found(EFalse);
   237     TBool found(EFalse);
   238     CDir* fileListInstalled= NULL;
   238     CDir* fileListInstalled= NULL;
   251         TPtrC fileInstalledName = (*fileListInstalled)[i].iName;
   251         TPtrC fileInstalledName = (*fileListInstalled)[i].iName;
   252         found = EFalse;
   252         found = EFalse;
   253         for ( TInt j(0); j<iFileNewList->Count( ); j++ )
   253         for ( TInt j(0); j<iFileNewList->Count( ); j++ )
   254             {
   254             {
   255             TPtrC fileNewPath = (*iFileNewList)[j];
   255             TPtrC fileNewPath = (*iFileNewList)[j];
   256             TPtrC fileNewName = 
   256             TPtrC fileNewName =
   257                 (*iFileNewList)[j].Mid( (*iFileNewList)[j].LocateReverse( '\\' ) + 1 );
   257                 (*iFileNewList)[j].Mid( (*iFileNewList)[j].LocateReverse( '\\' ) + 1 );
   258             if ( fileInstalledName.Compare( fileNewName )==0 )
   258             if ( fileInstalledName.Compare( fileNewName )==0 )
   259                 {
   259                 {
   260                 if ( !(*fileListInstalled)[i].IsDir( ) )
   260                 if ( !(*fileListInstalled)[i].IsDir( ) )
   261                     {
   261                     {
   262                     found = ETrue;
   262                     found = ETrue;
   263                     break;
   263                     break;
   264                     }
   264                     }
   265                 }
   265                 }
   266             }
   266             }
   267         if ( !found ) //this file should be removed also entries from database 
   267         if ( !found ) //this file should be removed also entries from database
   268             {
   268             {
   269             filePath.Zero( );
   269             filePath.Zero( );
   270             filePath.Append( KDriveC );
   270             filePath.Append( KDriveC );
   271             filePath.Append( iFilePath );
   271             filePath.Append( iFilePath );
   272             filePath.Append( KParsedDir );
   272             filePath.Append( KParsedDir );
   273             filePath.Append( fileInstalledName );
   273             filePath.Append( fileInstalledName );
   274 
   274 
   275             iParser->RestoreL( filePath, ETrue );
   275             iParser->Restore( filePath, ETrue );
   276             iFileMan->Delete( filePath );
   276             iFileMan->Delete( filePath );
   277             }
   277             }
   278         }
   278         }
   279     CleanupStack::PopAndDestroy( fileListInstalled );
   279     CleanupStack::PopAndDestroy( fileListInstalled );
   280     CleanupStack::PopAndDestroy( &filePath );
   280     CleanupStack::PopAndDestroy( &filePath );
   281     }
   281     }
   282 
   282 
   283 // ----------------------------------------------------------------------------
   283 // ----------------------------------------------------------------------------
   284 // CCHFactorySettings::CheckDrivesL
   284 // CCHFactorySettings::CheckDrivesL
   285 // 
   285 //
   286 // ----------------------------------------------------------------------------
   286 // ----------------------------------------------------------------------------
   287 //	
   287 //
   288 void CCHFactorySettings::CheckDrivesL()
   288 void CCHFactorySettings::CheckDrivesL()
   289     {
   289     {
   290     CP_DEBUG(_L8("CCHFactorySettings::CheckDrivesL" ));
   290     CP_DEBUG(_L8("CCHFactorySettings::CheckDrivesL" ));
   291     iFileNewList->Reset( );
   291     iFileNewList->Reset( );
   292     TDriveList driveList;
   292     TDriveList driveList;