secureswitools/swisistools/source/interpretsis/main.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 24 5cc91383ab1e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
    26 // User include
    26 // User include
    27 #include "commandparser.h"
    27 #include "commandparser.h"
    28 #include "interpretsis.h"
    28 #include "interpretsis.h"
    29 #include "logger.h"
    29 #include "logger.h"
    30 #include "../common/exception.h"
    30 #include "../common/exception.h"
       
    31 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    32 #include "dirparse.h"
       
    33 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    31 
    34 
    32 
    35 
    33 #ifndef _WIN32
    36 #ifndef _WIN32
    34 #include <ctype.h>
    37 #include <ctype.h>
    35 
    38 
    45 #endif // _WIN32
    48 #endif // _WIN32
    46 
    49 
    47 
    50 
    48 int main(int argc, const char* argv[])
    51 int main(int argc, const char* argv[])
    49 	{
    52 	{
       
    53 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
    54 	std::string dbpath;
       
    55 #endif	
    50 	bool pauseWhenDone = false;
    56 	bool pauseWhenDone = false;
    51 
    57 
    52 	int result= SUCCESS;
    58 	int result= SUCCESS;
    53 	std::wofstream* logFile = NULL;
    59 	std::wofstream* logFile = NULL;
    54 	try
    60 	try
    74 
    80 
    75 		Logger::SetLevel( options.WarningLevel() );
    81 		Logger::SetLevel( options.WarningLevel() );
    76 
    82 
    77 		CInterpretSIS interpretSis(paramList);
    83 		CInterpretSIS interpretSis(paramList);
    78 		
    84 		
       
    85 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    86 		//Parsing Preprovisioned Resource file in not done if RegistryVersionExists
       
    87 		if(!paramPtr->RegistryVersionExists())
       
    88 		{
       
    89 			if ( paramPtr->IsFlagSet(CParameterList::EFlagsResourceFilePathSet)) 
       
    90 			{
       
    91 				ParseResourceDir(paramPtr, interpretSis);
       
    92 
       
    93 				if (NULL != logFile)
       
    94 				{
       
    95 					bool val = logFile->is_open();
       
    96 					logFile->close();
       
    97 					delete logFile;
       
    98 				}
       
    99 				return result;
       
   100 			}
       
   101 			else
       
   102 			{
       
   103 				ParseResourceDir(paramPtr, interpretSis);
       
   104 			}
       
   105 		}
       
   106 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK		
       
   107 	
    79 		result = interpretSis.Install();
   108 		result = interpretSis.Install();
    80 		
   109 
    81 		// Uninstall the sis files
   110 		// Uninstall the sis files
    82 		interpretSis.Uninstall();
   111 		interpretSis.Uninstall();
       
   112 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   113 		if(result != 0)
       
   114 			dbpath=GetDbPath(paramPtr);
       
   115 #endif
    83 		}
   116 		}
    84     catch( CCommandParser::CmdLineException err )
   117     catch( CCommandParser::CmdLineException err )
    85 		{
   118 		{
    86 		CCommandParser::DisplayError(err);
   119 		CCommandParser::DisplayError(err);
    87 		result = CMDLINE_ERROR;
   120 		result = CMDLINE_ERROR;
    96     	{
   129     	{
    97 		LERROR(L"Config Manager Error - ");
   130 		LERROR(L"Config Manager Error - ");
    98 		e.Display();
   131 		e.Display();
    99 		result = CONFIG_ERROR;
   132 		result = CONFIG_ERROR;
   100     	}
   133     	}
       
   134 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   135 	catch(const CResourceFileException& aObject)
       
   136 		{
       
   137 		LERROR(L"Resource File Parsing Error - ");
       
   138 		aObject.Display();
       
   139 		result = RSC_PARSING_ERROR;
       
   140 		}
       
   141 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   101     catch(const RomManagerException& e)
   142     catch(const RomManagerException& e)
   102     	{
   143     	{
   103 		LERROR(L"ROM Manager Error - ");
   144 		LERROR(L"ROM Manager Error - ");
   104 		e.Display();
   145 		e.Display();
   105 		result = ROM_MANAGER;
   146 		result = ROM_MANAGER;
   132 	catch (...)
   173 	catch (...)
   133 		{
   174 		{
   134 		result = UNKNOWN_EXCEPTION;
   175 		result = UNKNOWN_EXCEPTION;
   135 		LERROR(L"Unknown Error" << std::endl);
   176 		LERROR(L"Unknown Error" << std::endl);
   136 		}
   177 		}
   137 	
   178 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   179 	//Restore Database in case of installation error for SA over SA and PU case
       
   180 	if(result != 0)
       
   181 	{
       
   182 		std::string BackupDb(dbpath);
       
   183 		BackupDb.append("_backup");
       
   184 		if (FileExists(string2wstring(BackupDb)))
       
   185 		{	
       
   186 			#ifdef __TOOLS2_LINUX__
       
   187 				std::string command = "mv " + BackupDb + " " + dbpath;
       
   188 			#else
       
   189 				std::string command = "move " + BackupDb + " " + dbpath;
       
   190 			#endif
       
   191 			int err = system(command.c_str());
       
   192 			if (err != 0)
       
   193 				LERROR(L"Failed to Restore src.db ");
       
   194 		}
       
   195 	}
       
   196 #endif
   138 	if (NULL != logFile)
   197 	if (NULL != logFile)
   139 		{
   198 	{
   140 		bool val = logFile->is_open();
   199 		bool val = logFile->is_open();
   141 		logFile->close();
   200 		logFile->close();
   142 		delete logFile;
   201 		delete logFile;
   143 		}
   202 	}
   144 
   203 
   145 	return result;
   204 	return result;
   146 	}
   205 }