|
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 /** |
|
20 @file |
|
21 @publishedPartner |
|
22 @released |
|
23 */ |
|
24 #ifndef __PARAMETER_H__ |
|
25 #define __PARAMETER_H__ |
|
26 |
|
27 #pragma warning (disable: 4786) |
|
28 |
|
29 // System includes |
|
30 #include <istream> |
|
31 #include <list> |
|
32 #include <vector> |
|
33 #include <map> |
|
34 #include <string> |
|
35 |
|
36 // User includes |
|
37 #include "logger.h" |
|
38 #include "sislanguage.h" |
|
39 |
|
40 |
|
41 struct InstallSISFile |
|
42 { |
|
43 public: |
|
44 /** |
|
45 * Default constructor. |
|
46 */ |
|
47 InstallSISFile() : iFileName(L""), iTargetDrive(L'$'), iGenerateStub(false), |
|
48 iNonRemovable(false), iNotRegister(false), iSUFlag(false) {} |
|
49 |
|
50 /** |
|
51 * Constructor |
|
52 */ |
|
53 InstallSISFile(std::wstring aName, int aDrive, bool aSUFlag) |
|
54 : iFileName(aName), iTargetDrive(aDrive), iGenerateStub(false), |
|
55 iNonRemovable(false), iNotRegister(false), iSUFlag(aSUFlag) {} |
|
56 |
|
57 /** |
|
58 * Constructor |
|
59 */ |
|
60 InstallSISFile(std::wstring aName, int aDrive, bool aGenerateStub, bool aNonRemovable, |
|
61 bool aNotRegister, bool aSUFlag) |
|
62 : iFileName(aName), iTargetDrive(aDrive), iGenerateStub(aGenerateStub), |
|
63 iNonRemovable(aNonRemovable), iNotRegister(aNotRegister), iSUFlag(aSUFlag) {} |
|
64 |
|
65 public: |
|
66 std::wstring iFileName; // SIS file name |
|
67 int iTargetDrive; // Target drive |
|
68 bool iGenerateStub; // Whether to generate stub sis file for this sis or not. |
|
69 bool iNonRemovable; // Whether this is a non-removable SIS or not. |
|
70 bool iNotRegister; // Whether to register the sis or not. |
|
71 bool iSUFlag; // Whether SU flag is set for this or not. |
|
72 }; |
|
73 |
|
74 |
|
75 |
|
76 /** |
|
77 * Contains the parameter required by interpretsis for instalaltion/un-installation |
|
78 */ |
|
79 class CParameterList |
|
80 { |
|
81 public: |
|
82 // Type definitions |
|
83 typedef std::list<std::wstring> OptionList; |
|
84 typedef std::list<InstallSISFile> SISFileList; |
|
85 |
|
86 public: // Enumerations |
|
87 /** |
|
88 * Enumeration which represents invalid arguement error. |
|
89 */ |
|
90 enum TParamException |
|
91 { |
|
92 EParamUnknownOption = 0, |
|
93 EParamInvalidDir, |
|
94 EParamInvalidSystemDrive, |
|
95 EParamMissingConfigurationFile, |
|
96 EParamUseEitherRomRofsLogsOrZDrive, |
|
97 EParamMissingSisStubFilePath, |
|
98 EParamInvalidRegistryVersion, |
|
99 EParamInstallRemoveExclusive, |
|
100 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
101 EParamRegVersionOriginVerificationExclusive |
|
102 #endif |
|
103 }; |
|
104 |
|
105 /** |
|
106 * Installation/un-installation flags used by interpretsis. |
|
107 */ |
|
108 enum TFlags |
|
109 { |
|
110 EFlagsNull = 0x0000, |
|
111 EFlagsLanguageWasSet = 0x0001, |
|
112 EFlagsRomRofsLogFilesSet = 0x0002, |
|
113 EFlagsCDriveSet = 0x0004, |
|
114 EFlagsZDriveSet = 0x0008, |
|
115 EFlagsSysDriveSet = 0x0010, |
|
116 EFlagsStubDirectorySet = 0x0020, |
|
117 EFlagsConfigIniSet = 0x0040, |
|
118 EFlagsDisableZDriveChecksSet= 0x0080 |
|
119 }; |
|
120 |
|
121 public: // Constructors & destructor |
|
122 /** |
|
123 * Default Constructor |
|
124 */ |
|
125 CParameterList(); |
|
126 /** |
|
127 * Cleanup owned resources. |
|
128 */ |
|
129 ~CParameterList(); |
|
130 |
|
131 public: |
|
132 /** |
|
133 * This function will log the error in the logger. |
|
134 * @param aError type of error. |
|
135 */ |
|
136 static void DisplayError(TParamException aError); |
|
137 /** |
|
138 * Set the path which represent the system drive. |
|
139 * @param File-system path which represents system drive |
|
140 */ |
|
141 void SetSystemDrive(const std::string& aFilePath); |
|
142 /** |
|
143 * Drive letter of the system drive |
|
144 * @param Drive letter |
|
145 */ |
|
146 void SetSystemDriveLetter(int aDriveLetter); |
|
147 /** |
|
148 * Set the file-system path of the ROM (Z) drive. |
|
149 * @param aFilePath path |
|
150 */ |
|
151 void SetZDrive(const std::string& aFilePath); |
|
152 /** |
|
153 * Set the stub director. |
|
154 * @param aFilePath Path for stubs. |
|
155 */ |
|
156 void SetStubDir(const std::string& aFilePath); |
|
157 /** |
|
158 * Set the config file. |
|
159 * @param aFilePath config file name |
|
160 */ |
|
161 void SetConfigFile(const std::string& aFilePath); |
|
162 /** |
|
163 * Function will set the sis registry path. |
|
164 */ |
|
165 void SetSisRegistryVersion(const std::string& aVerString); |
|
166 /** |
|
167 * Set the log file name. |
|
168 * @param aLogFile Log filename |
|
169 */ |
|
170 void SetLogFile(const std::wstring& aLogFile); |
|
171 /** |
|
172 * Set the installation language. |
|
173 * @param aLanguage language code. |
|
174 */ |
|
175 void SetLanguage(CSISLanguage::TLanguage aLanguage); |
|
176 /** |
|
177 * Set the installation/un-installation flag. |
|
178 */ |
|
179 void SetFlag(TFlags aFlag); |
|
180 /** |
|
181 * Set registry's major version. |
|
182 * @param aMajorVersion major version of registry. |
|
183 */ |
|
184 inline void SetRegistryMajorVersion(int aMajorVersion); |
|
185 /** |
|
186 * Set registry's minor version. |
|
187 * @param aMajorVersion minor version of registry. |
|
188 */ |
|
189 inline void SetRegistryMinorVersion(int aMinorVersion); |
|
190 /** |
|
191 * Add a new SIS file into the installation list. |
|
192 * @param aSISFile new sis file to be installed. |
|
193 */ |
|
194 void AddSISFile(InstallSISFile& aSISFile); |
|
195 /** |
|
196 * Add ROM log file into the existing list. |
|
197 */ |
|
198 void AddRomLogFile(std::wstring& aRomLogFile); |
|
199 /** |
|
200 * Empty the ROM log file list. |
|
201 */ |
|
202 void EmptyRomLogFiles(); |
|
203 /** |
|
204 * Add pkg UID to the existing list of UIDs for un-installation. |
|
205 */ |
|
206 void AddPkgUid(std::wstring& aPkgUID); |
|
207 /** |
|
208 * Clear the package UID list. |
|
209 */ |
|
210 void EmptyPkgUids(); |
|
211 /** |
|
212 * This function will validate all the parameters supplied. |
|
213 * Throws an exception of it encounters any illegal parameter. |
|
214 */ |
|
215 void ValidateParam(); |
|
216 |
|
217 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
218 /** |
|
219 * This function will set the Origin Verification status of the application. |
|
220 * By default, verification status is set to TRUE (verified). |
|
221 */ |
|
222 void SetOriginVerificationStatus(bool aOriginVerified); |
|
223 #endif |
|
224 |
|
225 /** |
|
226 * Retrieves the list of SIS files marked for installation |
|
227 */ |
|
228 inline const SISFileList& FileNames() const; |
|
229 /** |
|
230 * Retrieves the list of ROM log files. |
|
231 */ |
|
232 inline const OptionList& RomLogFileNames() const; |
|
233 /** |
|
234 * Retrieves the list of package UIDs marked for un-installation. |
|
235 */ |
|
236 inline const OptionList& PkgUidsToRemove() const; |
|
237 /** |
|
238 * Get the system drive path. |
|
239 */ |
|
240 inline const std::wstring& SystemDrivePath() const; |
|
241 /** |
|
242 * Gets the ROM drive (Z) path in the file-system. |
|
243 */ |
|
244 inline const std::wstring& RomDrivePath() const; |
|
245 /** |
|
246 * Gets the config file name. |
|
247 */ |
|
248 inline const std::wstring& ConfigFileName() const; |
|
249 /** |
|
250 * Gets the stub path. |
|
251 */ |
|
252 inline const std::wstring& SisStubPath() const; |
|
253 /** |
|
254 * Retrieves the language code. |
|
255 */ |
|
256 inline CSISLanguage::TLanguage Language() const; |
|
257 /** |
|
258 * Retrieves the System drive letter |
|
259 */ |
|
260 inline int SystemDriveLetter() const; |
|
261 /** |
|
262 * Checks if a particular installation/un-installation flag is set or not. |
|
263 * @return true if the flag is set else false. |
|
264 */ |
|
265 inline bool IsFlagSet(TFlags aFlag) const; |
|
266 /** |
|
267 * Returns the major version of registry |
|
268 */ |
|
269 inline int RegistryMajorVersion() const; |
|
270 /** |
|
271 * Returns the minor version of registry |
|
272 */ |
|
273 inline int RegistryMinorVersion() const; |
|
274 |
|
275 /** |
|
276 * Checks whether registry version exists or not. |
|
277 */ |
|
278 inline bool RegistryVersionExists() const; |
|
279 |
|
280 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
281 /** |
|
282 * Gives the OriginVerification status. |
|
283 */ |
|
284 inline bool OriginVerificationStatus() const; |
|
285 #endif |
|
286 |
|
287 private: |
|
288 typedef std::map<std::string, WarnLevel> WarnMap; |
|
289 |
|
290 SISFileList iFileNames; |
|
291 OptionList iRomLogFiles; |
|
292 OptionList iPkgUIDs; |
|
293 std::wstring iSystemDrivePath; |
|
294 std::wstring iZDrive; |
|
295 std::wstring iConfigFile; |
|
296 std::wstring iSisStubPath; |
|
297 int iSystemDriveLetter; |
|
298 CSISLanguage::TLanguage iLanguage; |
|
299 int iFlags; |
|
300 int iRegistryMajorVersion; |
|
301 int iRegistryMinorVersion; |
|
302 static WarnMap KString2Warning; |
|
303 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
304 bool iOriginVerified; |
|
305 #endif |
|
306 }; |
|
307 |
|
308 // Inline Member Functions |
|
309 inline const CParameterList::SISFileList& CParameterList::FileNames() const |
|
310 { |
|
311 return iFileNames; |
|
312 } |
|
313 |
|
314 inline const CParameterList::OptionList& CParameterList::RomLogFileNames() const |
|
315 { |
|
316 return iRomLogFiles; |
|
317 } |
|
318 |
|
319 inline const CParameterList::OptionList& CParameterList::PkgUidsToRemove() const |
|
320 { |
|
321 return iPkgUIDs; |
|
322 } |
|
323 |
|
324 inline const std::wstring& CParameterList::SystemDrivePath() const |
|
325 { |
|
326 return iSystemDrivePath; |
|
327 } |
|
328 |
|
329 inline const std::wstring& CParameterList::RomDrivePath() const |
|
330 { |
|
331 return iZDrive; |
|
332 } |
|
333 |
|
334 inline const std::wstring& CParameterList::ConfigFileName() const |
|
335 { |
|
336 return iConfigFile; |
|
337 } |
|
338 |
|
339 inline const std::wstring& CParameterList::SisStubPath() const |
|
340 { |
|
341 return iSisStubPath; |
|
342 } |
|
343 |
|
344 inline CSISLanguage::TLanguage CParameterList::Language() const |
|
345 { |
|
346 return iLanguage; |
|
347 } |
|
348 |
|
349 inline int CParameterList::SystemDriveLetter() const |
|
350 { |
|
351 return iSystemDriveLetter; |
|
352 } |
|
353 |
|
354 inline bool CParameterList::IsFlagSet(TFlags aFlag) const |
|
355 { |
|
356 return (iFlags & aFlag)? true: false; |
|
357 } |
|
358 |
|
359 inline int CParameterList::RegistryMajorVersion() const |
|
360 { |
|
361 return iRegistryMajorVersion; |
|
362 } |
|
363 |
|
364 inline int CParameterList::RegistryMinorVersion() const |
|
365 { |
|
366 return iRegistryMinorVersion; |
|
367 } |
|
368 |
|
369 inline void CParameterList::SetRegistryMajorVersion(int aMajorVersion) |
|
370 { |
|
371 iRegistryMajorVersion = aMajorVersion; |
|
372 } |
|
373 |
|
374 inline void CParameterList::SetRegistryMinorVersion(int aMinorVersion) |
|
375 { |
|
376 iRegistryMinorVersion = aMinorVersion; |
|
377 } |
|
378 |
|
379 inline bool CParameterList::RegistryVersionExists() const |
|
380 { |
|
381 return (iRegistryMajorVersion != 0 || iRegistryMinorVersion != 0); |
|
382 } |
|
383 |
|
384 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
385 inline bool CParameterList::OriginVerificationStatus() const |
|
386 { |
|
387 return iOriginVerified; |
|
388 } |
|
389 #endif |
|
390 |
|
391 #endif // __PARAMETER_H__ |