diff -r 646a02f170b9 -r 3cebc1a84278 metadataengine/server/src/mdsserver.cpp --- a/metadataengine/server/src/mdsserver.cpp Fri Mar 12 15:44:28 2010 +0200 +++ b/metadataengine/server/src/mdsserver.cpp Mon Mar 15 12:42:24 2010 +0200 @@ -35,7 +35,6 @@ __DEFINE_LOGGER const TInt64 KDiskSpaceGarbageCollectorThreshold = 1024*1024; // 1 MB -const TInt64 KDiskFullThreshold = 1024*50; // 50 kB _LIT( KSchema, "schema.mde" ); _LIT( KDefaultImportProfile, "defaultimportfile.mde" ); @@ -156,6 +155,36 @@ NULL //mdsElements }; +// ======================= LOCAL FUNCTIONS ================================ + +void CheckAndInitializeFileL( RFs& aFs, TBuf& aFile, const TDesC16& aFilePath, + RFileReadStream& aTempFile, CFileMan* aFileMan ) + { + __LOG1( ELogAlways, "CheckAndInitializeFileL() - handling file %S", &aFilePath ); + const TInt err = aTempFile.Open( aFs, aFile, EFileRead | EFileShareAny ); + __LOG1( ELogAlways, "CheckAndInitializeFileL() - open file error %d", err ); + aTempFile.Close(); + if ( err != KErrNone ) + { + if ( err == KErrNotFound ) + { + // Path found but not schema.mde, copy schema.m + const TInt error = aFileMan->Copy( aFilePath, aFile, CFileMan::EOverWrite ); + __LOG1( ELogAlways, "CheckAndInitializeFileL() - copy file error %d", error ); + } + else if ( err == KErrPathNotFound) + { + // Create private dir + User::LeaveIfError( aFs.CreatePrivatePath( EDriveC ) ); + + // Copy schema.mde + const TInt error = aFileMan->Copy( aFilePath, aFile, CFileMan::EOverWrite ); + __LOG1( ELogAlways, "CheckAndInitializeFileL() - copy file error %d", error ); + } + } + } + +// ======================= MEMBER FUNCTIONS =============================== CPolicyServer::TCustomResult CMdSServer::CustomSecurityCheckL( const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/ ) @@ -325,6 +354,10 @@ __INIT_LOGGER; StartL( KMdSServerName ); __LOGLB( ELogAlways, "Server start" ); + + RProcess process; + process.SetPriority( EPriorityBackground ); + process.Close(); CheckInitSriptL(); @@ -871,73 +904,13 @@ backupRegistration.Append( KBackupRegistration ); CFileMan* fileMan = CFileMan::NewL( fs ); - CleanupStack::PushL( fileMan); + CleanupStack::PushL( fileMan ); + + CheckAndInitializeFileL( fs, schema, KSchemaPath(), tmpFile, fileMan ); - TInt err = tmpFile.Open( fs, schema, EFileRead | EFileShareAny ); - __LOG1( ELogAlways, "open schema.mde %d", err ); - tmpFile.Close(); - if ( err != KErrNone ) - { - if ( err == KErrNotFound ) - { - // Path found but not schema.mde, copy schema.m - const TInt error = fileMan->Copy( KSchemaPath, schema, CFileMan::EOverWrite ); - __LOG1( ELogAlways, "copy schema.mde %d", error ); - } - else if ( err == KErrPathNotFound) - { - // Create private dir - User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) ); - - // Copy schema.mde - const TInt error = fileMan->Copy( KSchemaPath, schema, CFileMan::EOverWrite ); - __LOG1( ELogAlways, "copy schema.mde %d", error ); - } - } - - err = tmpFile.Open( fs, defaultImportProfile, EFileRead | EFileShareAny ); - __LOG1( ELogAlways, "open defaultimportprofile.mde %d", err ); - tmpFile.Close(); - if ( err != KErrNone ) - { - if ( err == KErrNotFound ) - { - // Path found but not schema.mde, copy schema.m - const TInt error1 = fileMan->Copy( KDefaultImportProfilePath, defaultImportProfile, CFileMan::EOverWrite ); - __LOG1( ELogAlways, "copy defaultimportprofile.mde %d", error1 ); - } - else if ( err == KErrPathNotFound) - { - // Create private dir - User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) ); - - // Copy schema.mde - const TInt error1 = fileMan->Copy( KDefaultImportProfilePath, defaultImportProfile, CFileMan::EOverWrite ); - __LOG1( ELogAlways, "copy defaultimportprofile.mde %d", error1 ); - } - } + CheckAndInitializeFileL( fs, defaultImportProfile, KDefaultImportProfilePath(), tmpFile, fileMan ); - err = tmpFile.Open( fs, backupRegistration, EFileRead | EFileShareAny ); - __LOG1( ELogAlways, "open backup_registration.xml %d", err ); - tmpFile.Close(); - if ( err != KErrNone ) - { - if ( err == KErrNotFound ) - { - // Path found but not schema.mde, copy schema.m - const TInt error2 = fileMan->Copy( KBackupRegistrationPath, backupRegistration, CFileMan::EOverWrite ); - __LOG1( ELogAlways, "copy backup_registration.xml %d", error2 ); - } - else if ( err == KErrPathNotFound) - { - // Create private dir - User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) ); - - // Copy schema.mde - const TInt error2 = fileMan->Copy( KBackupRegistrationPath, backupRegistration, CFileMan::EOverWrite ); - __LOG1( ELogAlways, "copy backup_registration.xml %d", error2 ); - } - } + CheckAndInitializeFileL( fs, backupRegistration, KBackupRegistrationPath(), tmpFile, fileMan ); CleanupStack::PopAndDestroy( 2 ); //fileman, fs }