secureswitools/swisistools/source/sisxlibrary/sisinfo.cpp
changeset 0 ba25891c3a9e
child 24 5cc91383ab1e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2007-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  @internalComponent
       
    22  @released
       
    23 */
       
    24 
       
    25 #ifdef _MSC_VER
       
    26 #pragma warning (disable: 4786)
       
    27 #endif // _MSC_VER
       
    28 
       
    29 #include "sisinfo.h"
       
    30 #include "utility.h"
       
    31 #include "siscontents.h"
       
    32 
       
    33 static const SIdentifierTable KInstallType [] = 
       
    34 	{
       
    35 		{	L"PA",				CSISInfo::EInstPreInstalledApp,			0,	false	},
       
    36 		{	L"PARTIALUPGRADE",	CSISInfo::EInstPartialUpgrade,			0,	false	},
       
    37 		{	L"PIAPP",			CSISInfo::EInstPreInstalledApp,			0,	false	},
       
    38 		{	L"PIPATCH",			CSISInfo::EInstPreInstalledPatch,		0,	false	},
       
    39 		{	L"PP",				CSISInfo::EInstPreInstalledPatch,		0,	false	},
       
    40 		{	L"PU",				CSISInfo::EInstPartialUpgrade,			0,	false	},
       
    41 		{	L"SA",				CSISInfo::EInstInstallation,			0,	false	},
       
    42 		{	L"SC",				CSISInfo::EInstInstallation,			0,	true	},
       
    43 		{	L"SISAPP",			CSISInfo::EInstInstallation,			0,	false	},
       
    44 		{	L"SISCONFIG",		CSISInfo::EInstInstallation,			0,	true	},
       
    45 		{	L"SISOPTION",		CSISInfo::EInstInstallation,			0,	true	},
       
    46 		{	L"SISPATCH",		CSISInfo::EInstAugmentation,			0,	false	},
       
    47 		{	L"SISSYSTEM",		CSISInfo::EInstInstallation,			0,	true	},
       
    48 		{	L"SISUPGRADE",		CSISInfo::EInstInstallation,			0,	true	},
       
    49 		{	L"SO",				CSISInfo::EInstInstallation,			0,	true	},
       
    50 		{	L"SP",				CSISInfo::EInstAugmentation,			0,	false	},
       
    51 		{	L"SU",				CSISInfo::EInstInstallation,			0,	true	},
       
    52 		{	L"SY",				CSISInfo::EInstInstallation,			0,	true	},
       
    53 		{	NULL,				0	}
       
    54 	};
       
    55 
       
    56 
       
    57 void CSISInfo::InsertMembers ()
       
    58 	{
       
    59 	InsertMember (iUid);
       
    60 	InsertMember (iVendorUniqueName);
       
    61 	InsertMember (iNames);
       
    62 	InsertMember (iVendorNames);
       
    63 	InsertMember (iVersion);
       
    64 	InsertMember (iCreationTime);
       
    65 	InsertMember (iInstallType);
       
    66 	InsertMember (iInstallFlags);
       
    67 	}
       
    68 
       
    69 
       
    70 CSISInfo::CSISInfo (const CSISInfo& aInitialiser) :
       
    71 		CStructure <CSISFieldRoot::ESISInfo> (aInitialiser),
       
    72 		iUid (aInitialiser.iUid),
       
    73 		iVendorUniqueName (aInitialiser.iVendorUniqueName),
       
    74 		iNames (aInitialiser.iNames),
       
    75 		iVendorNames (aInitialiser.iVendorNames),
       
    76 		iVersion (aInitialiser.iVersion),
       
    77 		iCreationTime (aInitialiser.iCreationTime),
       
    78 		iInstallType (aInitialiser.iInstallType),
       
    79 		iInstallFlags (aInitialiser.iInstallFlags)
       
    80 	{
       
    81 	InsertMembers (); 
       
    82 	}
       
    83 
       
    84 
       
    85 void CSISInfo::Verify (const TUint32 aLanguages) const
       
    86 	{
       
    87 	CStructure <CSISFieldRoot::ESISInfo>::Verify (aLanguages);
       
    88 	int n = iNames.size ();
       
    89 	CSISException::ThrowIf (iNames.size () != aLanguages,
       
    90 							CSISException::ELanguage,
       
    91 							"language and name counts differ");
       
    92 
       
    93 	CSISException::ThrowIf (iVendorNames.size () != aLanguages,
       
    94 								CSISException::ELanguage,
       
    95 								"language and vendor name counts differ");
       
    96 	
       
    97 	}
       
    98 
       
    99 
       
   100 
       
   101 std::string CSISInfo::Name () const
       
   102 	{
       
   103 	return "Info";
       
   104 	}
       
   105 
       
   106 
       
   107 
       
   108 CSISInfo::TSISInstallationType CSISInfo::InterpretType (const std::wstring& aOption)
       
   109 	{
       
   110 	int index = SearchSortedUCTable (KInstallType, aOption);
       
   111 	CSISException::ThrowIf (index < 0, CSISException::ESyntax, L"unknown install type: " + aOption);
       
   112 	if (KInstallType [index].iDeprecated)
       
   113 		{
       
   114 		SISLogger::Log(L"Installation type ");
       
   115 		SISLogger::Log(aOption);
       
   116 		SISLogger::Log(L" ignored, application assumed.\n");
       
   117 		}
       
   118 	iInstallType = KInstallType [index].iValue;
       
   119 	CSISInfo::TSISInstallationType reply = static_cast <CSISInfo::TSISInstallationType> (KInstallType [index].iValue);
       
   120 	if ((reply == EInstPreInstalledApp) || (reply == EInstPreInstalledPatch))
       
   121 		{
       
   122 		CSISContents::SetStub (CSISContents::EStubPreInstalled);
       
   123 		}
       
   124 	return reply;
       
   125 	}
       
   126 
       
   127 void CSISInfo::AddPackageEntry(std::wostream& aStream, bool aVerbose) const
       
   128 	{
       
   129 	if (aVerbose)
       
   130 		{
       
   131 		aStream << L"; Package header" << std::endl;
       
   132 		}
       
   133 	aStream << L"#{";
       
   134 	for (int i=0; i < iNames.size(); ++i)
       
   135 		{
       
   136 		aStream << L"\"";
       
   137 		iNames[i].AddPackageEntry(aStream, aVerbose);
       
   138 		aStream << L"\"";
       
   139 		if ((i+1)<iNames.size())
       
   140 			{
       
   141 			aStream << L",";
       
   142 			}
       
   143 		}
       
   144 	aStream << L"}, (";
       
   145 	iUid.AddPackageEntry(aStream, aVerbose);
       
   146 	aStream << L"), ";
       
   147 	iVersion.AddPackageEntry(aStream, aVerbose);
       
   148 	aStream << L", TYPE=";
       
   149 	switch (iInstallType)
       
   150 		{
       
   151 		case EInstInstallation:
       
   152 			aStream << L"SA";
       
   153 			break;
       
   154 		case EInstAugmentation:
       
   155 			aStream << L"SP";
       
   156 			break;
       
   157 		case EInstPartialUpgrade:
       
   158 			aStream << L"PU";
       
   159 			break;
       
   160 		case EInstPreInstalledApp:
       
   161 			aStream << L"PA";
       
   162 			break;
       
   163 		case EInstPreInstalledPatch:
       
   164 			aStream << L"PP";
       
   165 			break;
       
   166 		default:
       
   167 			aStream << L"*UNKNOWN*";
       
   168 			break;
       
   169 		}
       
   170 		
       
   171 	//Flag indicates package is ROM upgradeable.
       
   172 	if (iInstallFlags & EInstFlagROMUpgrade)
       
   173 		{
       
   174 		aStream << L", RU";
       
   175 		}
       
   176 	
       
   177 	if (iInstallFlags & EInstFlagShutdownApps)
       
   178 		{
       
   179 		aStream << L", SH";
       
   180 		}
       
   181 	#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   182 	if (iInstallFlags & EInstFlagHide)
       
   183 		{
       
   184 		aStream << L", H";
       
   185 		}
       
   186 	#endif
       
   187 
       
   188 	aStream << std::endl;
       
   189 
       
   190 	TUint32 vendorCount = iVendorNames.size();
       
   191 	if (vendorCount)
       
   192 		{
       
   193 		if (aVerbose)
       
   194 			{
       
   195 			aStream << L"; Vendor names" << std::endl;
       
   196 			}
       
   197 		aStream << L"%{";
       
   198 		for (int j = 0; j < vendorCount; ++j)
       
   199 			{
       
   200 			aStream << L"\"";
       
   201 			iVendorNames[j].AddPackageEntry(aStream, aVerbose);
       
   202 			aStream << L"\"";
       
   203 			if ((j+1)<vendorCount)
       
   204 				{
       
   205 				aStream << L",";
       
   206 				}
       
   207 			}
       
   208 		aStream << L"}" << std::endl;
       
   209 		}
       
   210 	else if (aVerbose)
       
   211 		{
       
   212 		aStream << L"; No vendor names" << std::endl;
       
   213 		}
       
   214 
       
   215 	if (aVerbose)
       
   216 		{
       
   217 		aStream << L"; SIS file build time ";
       
   218 		iCreationTime.AddPackageEntry(aStream, aVerbose);
       
   219 		aStream << std::endl;
       
   220 		}
       
   221 	aStream << L":\"";
       
   222 	iVendorUniqueName.AddPackageEntry(aStream, aVerbose);
       
   223 	aStream << L"\"" << std::endl;
       
   224 	aStream << std::endl;
       
   225 	}
       
   226 
       
   227