diff -r 000000000000 -r ba25891c3a9e secureswitools/swisistools/source/scrtool/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/secureswitools/swisistools/source/scrtool/main.cpp Thu Dec 17 08:51:10 2009 +0200 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "dblayer.h" +#include "xmlparser.h" +#include "logs.h" +#include "exception.h" +#include "options.h" + +#include +#include +#include + +typedef std::vector::iterator StringIterator; +typedef std::vector EnvDetails; +typedef std::vector SchemaDetails; + + +int main (int argc, char** argv) + { + int returnCode = 0; + + try + { + const char* epocRoot = getenv("EPOCROOT"); + if(NULL == epocRoot) + { + throw CException("EPOCROOT environment variable not specified.", ExceptionCodes::EEnvNotSpecified); + } + std::string epocRootStr(epocRoot); + + COptions options(argc, argv); + + std::string logFileName(options.GetLogFileName()); + std::auto_ptr logger(new CLogger(logFileName, options.GetLogLevel())); + + std::string dllPath = "sqlite3.dll"; + std::auto_ptr db( new CDbLayer(dllPath, options.GetDbFileName())); + std::auto_ptr xmlParser( new CScrXmlParser()); + + if(options.IsDbAbsent()) + { + std::string dbFileName = epocRootStr + "epoc32\\tools\\create_db.xml"; + std::auto_ptr schema(xmlParser->ParseDbSchema(dbFileName)); + db->CreateScrDatabase(*schema); + } + + std::vector xmlFileNames = options.GetEnvFileNames(); + for(StringIterator xmlIter=xmlFileNames.begin(); xmlIter != xmlFileNames.end(); ++xmlIter) + { + std::auto_ptr envDetails(xmlParser->GetEnvironmentDetails(*xmlIter)); + db->PopulateScrDatabase(*envDetails); + } + + if(options.IsPreProvisionInfoAvailable()) + { + std::string preProvFileName = options.GetPrePovisionFileName(); + XmlDetails::TScrPreProvisionDetail preProvisionDetailList = xmlParser->GetPreProvisionDetails(preProvFileName); + db->PopulatePreProvisionDetails(preProvisionDetailList); + } + } + catch(CException& aException) + { + const std::string& exc = aException.GetMessageA(); + returnCode = aException.GetCode(); + std::cout << "Exception caught::" << exc << std::endl; + std::cout << "Error Code::" << returnCode << std::endl; + } + + return returnCode; + } + +