diff -r 7ec726f93df1 -r 489cf6208544 dbcreator/commsdatstartup/Src/cdccommsdatstartup.cpp --- a/dbcreator/commsdatstartup/Src/cdccommsdatstartup.cpp Fri May 14 16:15:46 2010 +0300 +++ b/dbcreator/commsdatstartup/Src/cdccommsdatstartup.cpp Thu May 27 13:17:01 2010 +0300 @@ -27,7 +27,6 @@ #include #include -#include "cdccommsdatcreatorcrkeys.h" #include "cdccommsdatstartup.h" #include "cdccommsdatcreator.h" @@ -37,6 +36,7 @@ // CONSTANTS const TUid KCRUidCommsDb = { 0xcccccc00 }; +_LIT( KVariantXmlFile, "Z:\\private\\10281BC3\\VariantData_commsdat.xml" ); //------------------------------------------------ // CCdcCommsDatStartup::DoStartL @@ -50,11 +50,6 @@ CheckCreatorUIdL(); - CreateRepositoryL(); - - // Set status to not initialised - SetStartupStatusL( ECommsDatInitialisationFailed ); - CLOG_WRITE( "CCdcCommsDatStartup::ResetCommsDatToDefaultL()" ); // In all RFS cases CommsDat must be reset ResetCommsDatToDefaultL(); @@ -71,136 +66,40 @@ // In all RFS cases CommsDat tables must be checked/created cdc->CreateTablesL(); - TFileName fileName; - GetInputFileNameL( fileName ); - - // CommsDatCreator feature is supported if input file name - // lenght is not 0. However file name lenght at least 5. (x.xml) - if( fileName.Length() > 0 ) + // If variant XML file exists, read it and create settings + TFileName fileName( KVariantXmlFile ); + RFs fs; + User::LeaveIfError( fs.Connect() ); + RFile file; + if ( KErrNone == file.Open( fs, fileName, EFileRead ) ) { + file.Close(); CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation enabled" ); - - TFileName path( _L("Z:\\private\\10281BC3\\" ) ); - path.Append( fileName ); + + TRAPD(err, cdc->CreateCommsDatL( fileName ) ); + if ( err != KErrNone ) + { + // CommsDat creation leaved so something must be wrong. + // Reset CommsDat and EAP settings. + ResetCommsDatToDefaultL(); + ResetEAPSettingsL(); + cdc->CreateTablesL(); + User::Leave( err ); + } - CLOG_WRITE( "CCdcCommsDatStartup::CreateCommsDatL begin" ); - - TRAPD(err, cdc->CreateCommsDatL( path ) ); - if(err != KErrNone ) - { - // CommsDat creation leaved so something must be wrong. - // Reset CommsDat and EAP settings. - ResetCommsDatToDefaultL(); - ResetEAPSettingsL(); - cdc->CreateTablesL(); - User::Leave( err ); - } - - CLOG_WRITE( "CCdcCommsDatStartup::CreateCommsDatL end" ); + CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation done" ); } - else - { - CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation disabled" ); - } - - // If nothing has leaved then everything is okay (both in disabled and - // enabled cases. - SetStartupStatusL( ECommsDatInitialised ); + else + { + CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation disabled" ); + } + fs.Close(); CleanupStack::PopAndDestroy( cdc ); CLOG_WRITE( "CCdcCommsDatStartup::DoStartL end" ); } // ---------------------------------------------------------------------------- -// CCdcCommsDatStartup::CreateRepositoryL() -// ---------------------------------------------------------------------------- -// -void CCdcCommsDatStartup::CreateRepositoryL() - { - CLOG_WRITE( "CCdcCommsDatStartup::CreateRepositoryL()" ); - - TRAPD( err, iRepository = CRepository::NewL( KCRUidCommsDatCreator ) ); - - // Log is important now, because repository cannot contain the - // error value if it cannot be used - if( err != KErrNone ) - { - CLOG_WRITE_FORMAT( "Repository could not created err : %d", err ); - User::Leave( err ); - } - } - -// ---------------------------------------------------------------------------- -// CCdcCommsDatStartup::SetStartupStatusL() -// ---------------------------------------------------------------------------- -// -void CCdcCommsDatStartup::SetStartupStatusL( TInt aResult ) - { - CLOG_WRITE_FORMAT( "CCdcCommsDatStartup::SetStartupStatusL() %d", aResult ); - - TInt err = iRepository->Set( KCommsDatCreatorStartupStatus, aResult ); - if( err != KErrNone ) - { - CLOG_WRITE_FORMAT( - "Value could not write to repository err : %d", err ); - User::Leave( err ); - } - - CLOG_WRITE_FORMAT( "CCdcCommsDatStartup::SetStartupStatusL() %d", aResult ); - } - -// ---------------------------------------------------------------------------- -// CCdcCommsDatStartup::GetInputFileNameL() -// ---------------------------------------------------------------------------- -// -void CCdcCommsDatStartup::GetInputFileNameL( TFileName &aFileName ) - { - CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL()" ); - - TInt err = iRepository->Get( KCommsDatCreatorInputFileName, aFileName ); - if( err != KErrNone ) - { - CLOG_WRITE_FORMAT( - "Value could not red from repository err : %d", err ); - User::Leave( err ); - } - - CLOG_WRITE( "Input filename red" ); - - HBufC *fileName = aFileName.AllocLC(); - - CLOG_WRITE_FORMAT( "Input filename value : %S", fileName ); - - CleanupStack::PopAndDestroy( fileName ); - - // Check if file exists. If it doesn't reset filename. - RFs fs; - err = fs.Connect();//check - - if( err == KErrNone ) - { - RFile file; - - TFileName path( _L("Z:\\private\\10281BC3\\" ) ); - path.Append( aFileName ); - - err = file.Open(fs, path, EFileRead); - if( err != KErrNone ) - { - CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL() File does not exist"); - aFileName.Zero(); - } - else - { - file.Close(); - } - fs.Close(); - } - - CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL()" ); - } - -// ---------------------------------------------------------------------------- // CCdcCommsDatStartup::CheckCreatorUIdL() // ---------------------------------------------------------------------------- // @@ -211,7 +110,7 @@ CLOG_WRITE( "CCdcCommsDatStartup::CheckCreatorUIdL" ); - TUid creatorId = User::CreatorIdentity(); + TUid creatorId = User::CreatorSecureId(); CLOG_WRITE_FORMAT( "CreatorId : %x", creatorId ); @@ -229,10 +128,6 @@ // CCdcCommsDatStartup::~CCdcCommsDatStartup() { - if( iRepository ) - { - delete iRepository; - } } // ----------------------------------------------------------------------------