|
1 /* |
|
2 * Copyright (c) 2008-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <iostream> |
|
20 |
|
21 #include "parameterlist.h" |
|
22 #include "stringutils.h" |
|
23 #include "sisregistry.h" |
|
24 |
|
25 #include "is_utils.h" |
|
26 |
|
27 CParameterList::CParameterList(): |
|
28 iSystemDriveLetter(L'c'), |
|
29 iLanguage( CSISLanguage::ELangEnglish ), |
|
30 iFlags( EFlagsNull ), |
|
31 iRegistryMajorVersion(0), |
|
32 iRegistryMinorVersion(0) |
|
33 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
34 ,iOriginVerified(true) |
|
35 #endif |
|
36 { |
|
37 } |
|
38 |
|
39 CParameterList::~CParameterList() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 void CParameterList::SetSystemDrive(const std::string& aFilePath) |
|
45 { |
|
46 iSystemDrivePath = StringUtils::FixPathDelimiters(aFilePath); |
|
47 if (!IsDirectory(iSystemDrivePath)) |
|
48 { |
|
49 throw EParamInvalidDir; |
|
50 } |
|
51 iFlags |= EFlagsCDriveSet; |
|
52 } |
|
53 |
|
54 void CParameterList::SetSystemDriveLetter(int aDriveLetter) |
|
55 { |
|
56 iSystemDriveLetter = aDriveLetter; |
|
57 |
|
58 if (iSystemDriveLetter < 'a' || iSystemDriveLetter > 'y') |
|
59 { |
|
60 throw EParamInvalidSystemDrive; |
|
61 } |
|
62 |
|
63 iFlags |= EFlagsSysDriveSet; |
|
64 } |
|
65 |
|
66 void CParameterList::SetZDrive(const std::string& aFilePath) |
|
67 { |
|
68 iZDrive = StringUtils::FixPathDelimiters(aFilePath); |
|
69 |
|
70 if (!IsDirectory(iZDrive)) |
|
71 throw EParamInvalidDir; |
|
72 |
|
73 iFlags |= EFlagsZDriveSet; |
|
74 } |
|
75 |
|
76 void CParameterList::SetFlag(TFlags aFlag) |
|
77 { |
|
78 iFlags |= aFlag; |
|
79 } |
|
80 |
|
81 void CParameterList::SetConfigFile(const std::string& aFilePath) |
|
82 { |
|
83 iConfigFile = StringUtils::FixPathDelimiters(aFilePath); |
|
84 |
|
85 if ( !FileExists( iConfigFile ) ) |
|
86 { |
|
87 throw EParamMissingConfigurationFile; |
|
88 } |
|
89 |
|
90 iFlags |= EFlagsConfigIniSet; |
|
91 } |
|
92 |
|
93 void CParameterList::SetStubDir(const std::string& aFilePath) |
|
94 { |
|
95 iSisStubPath = StringUtils::FixPathDelimiters(aFilePath); |
|
96 |
|
97 if (!IsDirectory(iSisStubPath)) |
|
98 throw EParamInvalidDir; |
|
99 |
|
100 iFlags |= EFlagsStubDirectorySet; |
|
101 } |
|
102 |
|
103 void CParameterList::SetLanguage(CSISLanguage::TLanguage aLanguage) |
|
104 { |
|
105 iLanguage = aLanguage; |
|
106 iFlags |= EFlagsLanguageWasSet; |
|
107 } |
|
108 |
|
109 void CParameterList::AddSISFile(InstallSISFile& aSISFile) |
|
110 { |
|
111 iFileNames.push_back(aSISFile); |
|
112 } |
|
113 |
|
114 void CParameterList::EmptyRomLogFiles() |
|
115 { |
|
116 iRomLogFiles.clear(); |
|
117 iFlags &= ~EFlagsRomRofsLogFilesSet; |
|
118 } |
|
119 |
|
120 void CParameterList::AddRomLogFile(std::wstring& aRomLogFile) |
|
121 { |
|
122 iRomLogFiles.push_back(aRomLogFile); |
|
123 iFlags |= EFlagsRomRofsLogFilesSet; |
|
124 } |
|
125 |
|
126 void CParameterList::EmptyPkgUids() |
|
127 { |
|
128 iPkgUIDs.clear(); |
|
129 } |
|
130 |
|
131 void CParameterList::AddPkgUid(std::wstring& aPkgUid) |
|
132 { |
|
133 iPkgUIDs.push_back(aPkgUid); |
|
134 } |
|
135 |
|
136 void CParameterList::SetSisRegistryVersion(const std::string& aVerString) |
|
137 { |
|
138 if (aVerString == SisRegistry::KRegistryV40string) |
|
139 { |
|
140 iRegistryMajorVersion = 4; |
|
141 iRegistryMinorVersion = 0; |
|
142 } |
|
143 else if (aVerString == SisRegistry::KRegistryV50string) // fixed DEF096906 - Added iRemoveWithLastDependant |
|
144 { |
|
145 iRegistryMajorVersion = 5; |
|
146 iRegistryMinorVersion = 0; |
|
147 } |
|
148 else if (aVerString == SisRegistry::KRegistryV51string) // introduced isRemovable flag |
|
149 { |
|
150 iRegistryMajorVersion = 5; |
|
151 iRegistryMinorVersion = 1; |
|
152 } |
|
153 else if (aVerString == SisRegistry::KRegistryV52string) // fixed DEF114705 - SIS controller incorrect |
|
154 { |
|
155 iRegistryMajorVersion = 5; |
|
156 iRegistryMinorVersion = 2; |
|
157 } |
|
158 else if (aVerString == SisRegistry::KRegistryV53string) // introduced SU cert flag |
|
159 { |
|
160 iRegistryMajorVersion = 5; |
|
161 iRegistryMinorVersion = 3; |
|
162 } |
|
163 else if (aVerString == SisRegistry::KRegistryV54string) // introduced Device Supported Languages ( Exact Match and Equivalent match ) |
|
164 { |
|
165 iRegistryMajorVersion = 5; |
|
166 iRegistryMinorVersion = 4; |
|
167 } |
|
168 else |
|
169 { |
|
170 throw EParamInvalidRegistryVersion; |
|
171 } |
|
172 } |
|
173 |
|
174 void CParameterList::ValidateParam() |
|
175 { |
|
176 if (!iFileNames.empty()) |
|
177 { |
|
178 SISFileList::iterator curr = iFileNames.begin(); |
|
179 |
|
180 // Touching up the InstallSISFile's iTargetDrive to the right System drive letter |
|
181 for (; curr != iFileNames.end(); ++curr) |
|
182 { |
|
183 if (curr->iTargetDrive == '$') |
|
184 { |
|
185 curr->iTargetDrive = iSystemDriveLetter; |
|
186 } |
|
187 } |
|
188 } |
|
189 |
|
190 if ( (iFlags & EFlagsDisableZDriveChecksSet) != 0) |
|
191 { |
|
192 return; |
|
193 } |
|
194 // Some options are mutually inclusive. |
|
195 // |
|
196 // When using -r, then -t must also be specified. |
|
197 // When using -z, -r cannot be specified. |
|
198 // |
|
199 const bool romLogs = ( iFlags & EFlagsRomRofsLogFilesSet ) != 0; |
|
200 const bool zDrive = ( iFlags & EFlagsZDriveSet ) != 0; |
|
201 const bool sisStubs = ( iFlags & EFlagsStubDirectorySet ) != 0; |
|
202 |
|
203 if ( romLogs && zDrive ) |
|
204 { |
|
205 // Both are not allowed |
|
206 throw EParamUseEitherRomRofsLogsOrZDrive; |
|
207 } |
|
208 else if ( romLogs && !sisStubs ) |
|
209 { |
|
210 // SIS stubs are mandatory when using -R |
|
211 throw EParamMissingSisStubFilePath; |
|
212 } |
|
213 else if (!iFileNames.empty() && !iPkgUIDs.empty()) |
|
214 { |
|
215 // -x and -s option are mutually exclusive |
|
216 throw EParamInstallRemoveExclusive; |
|
217 } |
|
218 } |
|
219 |
|
220 void CParameterList::DisplayError(TParamException aError) |
|
221 { |
|
222 wchar_t* msg = NULL; |
|
223 // |
|
224 switch(aError) |
|
225 { |
|
226 case EParamInvalidDir: |
|
227 msg = L"Invalid directory(s) specified"; |
|
228 break; |
|
229 case EParamInvalidSystemDrive: |
|
230 msg = L"Invalid system drive specified"; |
|
231 break; |
|
232 case EParamMissingConfigurationFile: |
|
233 msg = L"Configuration file not found"; |
|
234 break; |
|
235 case EParamUseEitherRomRofsLogsOrZDrive: |
|
236 msg = L"Cannot specify both -r and -z. Use one or the other"; |
|
237 break; |
|
238 case EParamMissingSisStubFilePath: |
|
239 msg = L"Must specify -t when using -r"; |
|
240 break; |
|
241 case EParamInvalidRegistryVersion: |
|
242 msg = L"Invalid SIS Registry version"; |
|
243 break; |
|
244 case EParamInstallRemoveExclusive: |
|
245 msg = L"Cannot have both -s and -x options at the sametime"; |
|
246 break; |
|
247 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
248 case EParamRegVersionOriginVerificationExclusive: |
|
249 msg = L"Cannot have both reg file version (via -k or file) and -f options at the sametime"; |
|
250 break; |
|
251 #endif |
|
252 case EParamUnknownOption: |
|
253 default: |
|
254 msg = L"Unknown error"; |
|
255 break; |
|
256 } |
|
257 LERROR(msg << std::endl); |
|
258 } |
|
259 |
|
260 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
261 void CParameterList::SetOriginVerificationStatus(bool aOriginVerified) |
|
262 { |
|
263 iOriginVerified = aOriginVerified; |
|
264 } |
|
265 #endif |
|
266 // End of File |