|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Contains the entry point for the interpretsis program |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #pragma warning (disable: 4786) |
|
21 |
|
22 // System include |
|
23 #include <iostream> |
|
24 #include <fstream> |
|
25 |
|
26 // User include |
|
27 #include "commandparser.h" |
|
28 #include "interpretsis.h" |
|
29 #include "logger.h" |
|
30 #include "../common/exception.h" |
|
31 |
|
32 int main(int argc, const char* argv[]) |
|
33 { |
|
34 bool pauseWhenDone = false; |
|
35 |
|
36 int result= SUCCESS; |
|
37 std::wofstream* logFile = NULL; |
|
38 try |
|
39 { |
|
40 CCommandParser options; |
|
41 CInterpretSIS::TParamPtr paramList(options.ParseOptions(argc, argv)); |
|
42 |
|
43 CParameterList* paramPtr = paramList.get(); |
|
44 if(NULL == paramPtr) |
|
45 { |
|
46 return 0; |
|
47 } |
|
48 |
|
49 if (options.LogFile().size() > 0) |
|
50 { |
|
51 logFile = new std::wofstream(Ucs2ToUtf8(options.LogFile()).c_str(), std::ios::app); |
|
52 Logger::SetStream(*logFile); |
|
53 } |
|
54 else |
|
55 { |
|
56 Logger::SetStream(std::wcout); |
|
57 } |
|
58 |
|
59 Logger::SetLevel( options.WarningLevel() ); |
|
60 |
|
61 CInterpretSIS interpretSis(paramList); |
|
62 |
|
63 result = interpretSis.Install(); |
|
64 |
|
65 // Uninstall the sis files |
|
66 interpretSis.Uninstall(); |
|
67 } |
|
68 catch( CCommandParser::CmdLineException err ) |
|
69 { |
|
70 CCommandParser::DisplayError(err); |
|
71 result = CMDLINE_ERROR; |
|
72 } |
|
73 catch(CParameterList::TParamException err) |
|
74 { |
|
75 CParameterList::DisplayError(err); |
|
76 CCommandParser::DisplayUsage(); |
|
77 result = CMDLINE_ERROR; |
|
78 } |
|
79 catch(const ConfigManagerException& e) |
|
80 { |
|
81 LERROR(L"Config Manager Error - "); |
|
82 e.Display(); |
|
83 result = CONFIG_ERROR; |
|
84 } |
|
85 catch(const RomManagerException& e) |
|
86 { |
|
87 LERROR(L"ROM Manager Error - "); |
|
88 e.Display(); |
|
89 result = ROM_MANAGER; |
|
90 } |
|
91 catch (InterpretSisError& e) |
|
92 { |
|
93 LERROR(L"\t" << Utf8ToUcs2(e.what())); |
|
94 result = e.GetErrorCode(); |
|
95 } |
|
96 catch (CSISException e) |
|
97 { |
|
98 LERROR(L"FileContents Error - "); |
|
99 std::cout << e.what() << std::endl; |
|
100 result = INVALID_SIS; |
|
101 } |
|
102 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
103 catch (CException& e) |
|
104 { |
|
105 LERROR(L"DB Manager Error - "); |
|
106 std::cout << "DB Manager Error - " << e.GetMessageA() << " Code: " << e.GetCode() << std::endl; |
|
107 result = DB_EXCEPTION; |
|
108 } |
|
109 #endif |
|
110 catch (std::exception &err) |
|
111 { |
|
112 std::wstring emessage = Utf8ToUcs2( err.what() ); |
|
113 LERROR( L"Error: " << emessage); |
|
114 result = STD_EXCEPTION; |
|
115 } |
|
116 catch (...) |
|
117 { |
|
118 result = UNKNOWN_EXCEPTION; |
|
119 LERROR(L"Unknown Error" << std::endl); |
|
120 } |
|
121 |
|
122 if (NULL != logFile) |
|
123 { |
|
124 bool val = logFile->is_open(); |
|
125 logFile->close(); |
|
126 delete logFile; |
|
127 } |
|
128 |
|
129 return result; |
|
130 } |