secureswitools/swisistools/source/sisxlibrary/sisinfo.h
changeset 0 ba25891c3a9e
child 26 04d4a7bbc3e0
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2005-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 * Note: This file may contain code to generate corrupt files for test purposes.
       
    16 * Such code is excluded from production builds by use of compiler defines;
       
    17 * it is recommended that such code should be removed if this code is ever published publicly.
       
    18 * As specified in SGL.GT0188.251
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 /**
       
    24  @file 
       
    25  @publishedPartner
       
    26  @released
       
    27 */
       
    28 
       
    29 #ifndef __SISINFO_H__
       
    30 #define __SISINFO_H__
       
    31 
       
    32 
       
    33 #include "stringarray.h"
       
    34 #include "sisuid.h"
       
    35 #include "sisversion.h"
       
    36 #include "sisdatetime.h"
       
    37 #include "version.h"
       
    38 
       
    39 class CSISInfo : public CStructure <CSISFieldRoot::ESISInfo>
       
    40 	{
       
    41 public:
       
    42 	/**
       
    43 	 * Installatation type enumeration
       
    44 	 */
       
    45 	typedef enum 
       
    46 		{
       
    47 		EInstInstallation,
       
    48 		EInstAugmentation,
       
    49 		EInstPartialUpgrade,
       
    50 		EInstPreInstalledApp,
       
    51 		EInstPreInstalledPatch,
       
    52 		EInstIllegal
       
    53 		} TSISInstallationType;
       
    54 
       
    55 	/**
       
    56 	 * Installation flags. Considered to be of 8 bit length, and 
       
    57 	 * bitwise OR-ed to give more than one option. So the values
       
    58 	 * must be of 2 power n, where n => 0 to 7.
       
    59 	 */
       
    60 	typedef enum
       
    61 		{
       
    62 		EInstFlagShutdownApps	= 1<<0,
       
    63 		EInstFlagNonRemovable	= 1<<1,
       
    64 		EInstFlagROMUpgrade		= 1<<2,
       
    65 		#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    66 		EInstFlagHide			= 1<<3
       
    67 		#endif
       
    68 		} TInstallFlags;
       
    69 		
       
    70 public:
       
    71 	/**
       
    72 	 * Default constructor
       
    73 	 */
       
    74 	CSISInfo ();
       
    75 	/**
       
    76 	 * Copy constructor
       
    77 	 */
       
    78 	CSISInfo (const CSISInfo& aInitialiser);
       
    79 	
       
    80 public:
       
    81 	/**
       
    82 	 * This function verifies the structure
       
    83 	 * @param aLanguage - language
       
    84 	 */ 
       
    85 	virtual void Verify (const TUint32 aLanguages) const;
       
    86 	/**
       
    87 	 * @return name of the class.
       
    88 	 */
       
    89 	virtual std::string Name () const;
       
    90 #ifdef GENERATE_ERRORS
       
    91 	virtual void CreateDefects ();
       
    92 #endif // GENERATE_ERRORS
       
    93 
       
    94 	/**
       
    95 	 * @return UID of the SIS file.
       
    96 	 */
       
    97 	CSISUid::TUid UID1 () const;
       
    98 	/**
       
    99 	 * Set the UID of the SIS.
       
   100 	 * @param aUID new UID for the SIS.
       
   101 	 */
       
   102 	void SetUID (const CSISUid::TUid aUID);
       
   103 	/**
       
   104 	 * Add package name to the existing list of package names for the SIS.
       
   105 	 * @param aPackageName - package name
       
   106 	 */ 
       
   107 	void AddName (const std::wstring& aLan);
       
   108 	/**
       
   109 	 * Add vendor name to the existing list of vendor names for the controller.
       
   110 	 * @param aVendorName vendor name.
       
   111 	 */
       
   112 	void AddVendorName (const std::wstring& aVendor);
       
   113 	/**
       
   114 	 * Set the unique vendor name for the controller.
       
   115 	 * @param VendorUniqueName unique vendor name.
       
   116 	 */
       
   117 	void SetVendorUniqueName (const std::wstring& aVendorUniqueName);
       
   118 	/**
       
   119 	 * Set SIS version
       
   120 	 * @param aVersion new version to be set.
       
   121 	 */
       
   122 	void SetVersion (const TVersion& aVersion);
       
   123 	/**
       
   124 	 * @return UID of the SIS file.
       
   125 	 */
       
   126 	const CSISUid& uid () const;
       
   127 	/**
       
   128 	 * @return total number of languages present in the controller.
       
   129 	 */
       
   130 	TUint32 LanguageCount () const;
       
   131 	/**
       
   132 	 * Converts the string into installation type (only if its valid) and sets the
       
   133 	 * type to controller.
       
   134 	 * @param aOption installation type string.
       
   135 	 * @return returns the installation type.
       
   136 	 */
       
   137 	TSISInstallationType InterpretType (const std::wstring& aOption);
       
   138 	/**
       
   139 	 * Only preinstalled apps must be compressed. 
       
   140 	 * @return false if the sis is preinstalled app or preinstalled patch, else true
       
   141 	 */
       
   142 	bool MustRejectCompression () const;
       
   143 	/**
       
   144 	 * Adds a new install
       
   145 	 * @param aFlag new installation flag.
       
   146 	 */
       
   147 	void AddFlag(const TUint8 aFlag);
       
   148 	/**
       
   149 	 * Set the current time as the sis creation time.
       
   150 	 */
       
   151 	void SetNow ();
       
   152 	/**
       
   153 	 * Adds package entry related to sis info.
       
   154 	 * @param aStream stream into which the package details need to be written.
       
   155 	 * @param aVerbose If this option is set then detail description of pkg
       
   156 	 * 			will be written into the stream.
       
   157 	 */
       
   158 	void AddPackageEntry(std::wostream& aStream, bool aVerbose) const;
       
   159 	/**
       
   160 	 * @return Vendor Name Count
       
   161 	 */
       
   162 	inline TUint32 VendorNameCount() const;
       
   163 	/**
       
   164 	 * @return Package Name Count
       
   165 	 */
       
   166 	inline TUint32 PackageNameCount() const;
       
   167 	/**
       
   168 	 * Retrieves the vendor name pointed by index.
       
   169 	 * @param index index of the vendor name.
       
   170 	 * @return vendor Name 
       
   171 	 */
       
   172 	inline std::wstring VendorName(TUint32 index = 0) const;
       
   173 	/**
       
   174 	 * @return UNique vendor Name 
       
   175 	 */
       
   176 	inline std::wstring UniqueVendorName() const;
       
   177 	/**
       
   178 	 * Retrieves the package name pointed by index.
       
   179 	 * @param index index of the package name.
       
   180 	 * @return Package Name 
       
   181 	 */
       
   182 	inline std::wstring PackageName(TUint32 index = 0) const;
       
   183 	/**
       
   184 	 * @return installation type.
       
   185 	 */
       
   186 	inline TSISInstallationType InstallationType() const;
       
   187 	/**
       
   188 	 * @return Installation flag
       
   189 	 */
       
   190 	inline TInstallFlags InstallationFlag() const;
       
   191 	/**
       
   192 	 * @return version of the sis.
       
   193 	 */
       
   194 	inline const CSISVersion& SISVersion() const;
       
   195 
       
   196 private:
       
   197 	void InsertMembers ();
       
   198 
       
   199 private:
       
   200 	CSISUid				iUid;
       
   201 	CSISString			iVendorUniqueName;
       
   202 	CSISArrayOfStrings	iNames;
       
   203 	CSISArrayOfStrings	iVendorNames;
       
   204 	CSISVersion			iVersion;
       
   205 	CSISDateTime		iCreationTime;
       
   206 	CSISUInt8			iInstallType;
       
   207 	CSISUInt8			iInstallFlags;
       
   208 	};
       
   209 
       
   210 
       
   211 inline CSISInfo::CSISInfo ()
       
   212 	{
       
   213 	InsertMembers ();
       
   214 	}
       
   215 
       
   216 
       
   217 inline CSISUid::TUid CSISInfo::UID1 () const
       
   218 	{ 
       
   219 	return iUid.UID1 (); 
       
   220 	}
       
   221 
       
   222 
       
   223 inline void CSISInfo::SetUID (const CSISUid::TUid aUID)
       
   224 	{ 
       
   225 	iUid.SetUID (aUID); 
       
   226 	}
       
   227 
       
   228 
       
   229 inline void CSISInfo::AddName (const std::wstring& aLan)
       
   230 	{ 
       
   231 	iNames.Push (CSISString (aLan)); 
       
   232 	}
       
   233 
       
   234 
       
   235 inline void CSISInfo::AddVendorName (const std::wstring& aVendor)
       
   236 	{ 
       
   237 	iVendorNames.Push (CSISString (aVendor)); 
       
   238 	}
       
   239 
       
   240 
       
   241 inline void CSISInfo::SetVersion (const TVersion& aVersion)
       
   242 	{ 
       
   243 	iVersion.SetVersion (aVersion); 
       
   244 	}
       
   245 
       
   246 
       
   247 inline const CSISUid& CSISInfo::uid () const
       
   248 	{ 
       
   249 	return iUid; 
       
   250 	}
       
   251 
       
   252 
       
   253 inline TUint32 CSISInfo::LanguageCount () const
       
   254 	{ 
       
   255 	return iNames.size (); 
       
   256 	}
       
   257 
       
   258 #ifdef GENERATE_ERRORS
       
   259 inline void CSISInfo::CreateDefects ()
       
   260 	{
       
   261 	if (CSISFieldRoot::IsBugToBeCreated (CSISFieldRoot::EBugInvalidValues))
       
   262 		{
       
   263 		iInstallType = rand ();
       
   264 		}
       
   265 	}
       
   266 #endif // GENERATE_ERRORS
       
   267 
       
   268 inline void CSISInfo::SetVendorUniqueName (const std::wstring& aVendorUniqueName)
       
   269 	{
       
   270 	iVendorUniqueName = aVendorUniqueName;
       
   271 	}
       
   272 
       
   273 inline bool  CSISInfo::MustRejectCompression () const
       
   274 	{
       
   275 	return ((iInstallType != EInstPreInstalledApp) && (iInstallType != EInstPreInstalledPatch));
       
   276 	}
       
   277 
       
   278 inline void CSISInfo::AddFlag(const TUint8 aFlag)
       
   279 	{
       
   280 	iInstallFlags |= aFlag;
       
   281 	}
       
   282 
       
   283 inline void CSISInfo::SetNow ()
       
   284 	{
       
   285 	iCreationTime.SetNow ();
       
   286 	}
       
   287 
       
   288 inline std::wstring CSISInfo::VendorName(TUint32 index) const
       
   289 	{
       
   290 	assert(iVendorNames.size() > index);
       
   291 	return iVendorNames[index].GetString();
       
   292 	}
       
   293 
       
   294 inline std::wstring CSISInfo::UniqueVendorName() const
       
   295 	{
       
   296 	return iVendorUniqueName.GetString();
       
   297 	}
       
   298 
       
   299 inline std::wstring CSISInfo::PackageName(TUint32 index) const
       
   300 	{
       
   301 	assert(iNames.size() > index);
       
   302 	return iNames[index].GetString();
       
   303 	}
       
   304 
       
   305 inline CSISInfo::TSISInstallationType CSISInfo::InstallationType() const
       
   306 	{
       
   307 	return (TSISInstallationType)(int)iInstallType;
       
   308 	}
       
   309 
       
   310 inline CSISInfo::TInstallFlags CSISInfo::InstallationFlag() const
       
   311 	{
       
   312 	return (TInstallFlags)(int)iInstallFlags;
       
   313 	}
       
   314 
       
   315 inline const CSISVersion& CSISInfo::SISVersion() const
       
   316 	{
       
   317 	return iVersion;
       
   318 	}
       
   319 
       
   320 inline TUint32 CSISInfo::VendorNameCount() const
       
   321 	{
       
   322 	return iVendorNames.size();
       
   323 	}
       
   324 
       
   325 inline TUint32 CSISInfo::PackageNameCount() const
       
   326 	{
       
   327 	return iNames.size();
       
   328 	}
       
   329 
       
   330 #endif // __SISINFO_H__
       
   331