secureswitools/swisistools/source/interpretsis/main.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
    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
       
    34 
    31 
    35 
    32 
    36 #ifndef _WIN32
    33 #ifndef _WIN32
    37 #include <ctype.h>
    34 #include <ctype.h>
    38 
    35 
    48 #endif // _WIN32
    45 #endif // _WIN32
    49 
    46 
    50 
    47 
    51 int main(int argc, const char* argv[])
    48 int main(int argc, const char* argv[])
    52 	{
    49 	{
    53 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
    54 	std::string dbpath;
       
    55 #endif	
       
    56 	bool pauseWhenDone = false;
    50 	bool pauseWhenDone = false;
    57 
    51 
    58 	int result= SUCCESS;
    52 	int result= SUCCESS;
    59 	std::wofstream* logFile = NULL;
    53 	std::wofstream* logFile = NULL;
    60 	try
    54 	try
    80 
    74 
    81 		Logger::SetLevel( options.WarningLevel() );
    75 		Logger::SetLevel( options.WarningLevel() );
    82 
    76 
    83 		CInterpretSIS interpretSis(paramList);
    77 		CInterpretSIS interpretSis(paramList);
    84 		
    78 		
    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 	
       
   108 		result = interpretSis.Install();
    79 		result = interpretSis.Install();
   109 
    80 		
   110 		// Uninstall the sis files
    81 		// Uninstall the sis files
   111 		interpretSis.Uninstall();
    82 		interpretSis.Uninstall();
   112 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   113 		if(result != 0)
       
   114 			dbpath=GetDbPath(paramPtr);
       
   115 #endif
       
   116 		}
    83 		}
   117     catch( CCommandParser::CmdLineException err )
    84     catch( CCommandParser::CmdLineException err )
   118 		{
    85 		{
   119 		CCommandParser::DisplayError(err);
    86 		CCommandParser::DisplayError(err);
   120 		result = CMDLINE_ERROR;
    87 		result = CMDLINE_ERROR;
   129     	{
    96     	{
   130 		LERROR(L"Config Manager Error - ");
    97 		LERROR(L"Config Manager Error - ");
   131 		e.Display();
    98 		e.Display();
   132 		result = CONFIG_ERROR;
    99 		result = CONFIG_ERROR;
   133     	}
   100     	}
   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	
       
   142     catch(const RomManagerException& e)
   101     catch(const RomManagerException& e)
   143     	{
   102     	{
   144 		LERROR(L"ROM Manager Error - ");
   103 		LERROR(L"ROM Manager Error - ");
   145 		e.Display();
   104 		e.Display();
   146 		result = ROM_MANAGER;
   105 		result = ROM_MANAGER;
   173 	catch (...)
   132 	catch (...)
   174 		{
   133 		{
   175 		result = UNKNOWN_EXCEPTION;
   134 		result = UNKNOWN_EXCEPTION;
   176 		LERROR(L"Unknown Error" << std::endl);
   135 		LERROR(L"Unknown Error" << std::endl);
   177 		}
   136 		}
   178 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   137 	
   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
       
   197 	if (NULL != logFile)
   138 	if (NULL != logFile)
   198 	{
   139 		{
   199 		bool val = logFile->is_open();
   140 		bool val = logFile->is_open();
   200 		logFile->close();
   141 		logFile->close();
   201 		delete logFile;
   142 		delete logFile;
   202 	}
   143 		}
   203 
   144 
   204 	return result;
   145 	return result;
   205 }
   146 	}