msi: Read supported platform and language ids from the summary information stream.

This commit is contained in:
Hans Leidekker 2010-09-17 15:20:26 +02:00 committed by Alexandre Julliard
parent 3ef3e81f9e
commit a0ebe951b6
3 changed files with 95 additions and 6 deletions

View File

@ -304,10 +304,20 @@ struct tagMSIVIEW
struct msi_dialog_tag;
typedef struct msi_dialog_tag msi_dialog;
enum platform
{
PLATFORM_INTEL,
PLATFORM_INTEL64,
PLATFORM_X64
};
typedef struct tagMSIPACKAGE
{
MSIOBJECTHDR hdr;
MSIDATABASE *db;
enum platform platform;
UINT num_langids;
LANGID *langids;
struct list patches;
struct list components;
struct list features;
@ -1127,6 +1137,9 @@ static const WCHAR szLocalPackage[] = {'L','o','c','a','l','P','a','c','k','a','
static const WCHAR szOriginalDatabase[] = {'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
static const WCHAR szUpgradeCode[] = {'U','p','g','r','a','d','e','C','o','d','e',0};
static const WCHAR szAdminUser[] = {'A','d','m','i','n','U','s','e','r',0};
static const WCHAR szIntel[] = {'I','n','t','e','l',0};
static const WCHAR szIntel64[] = {'I','n','t','e','l','6','4',0};
static const WCHAR szX64[] = {'x','6','4',0};
/* memory allocation macro functions */
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);

View File

@ -280,6 +280,7 @@ static void free_package_structures( MSIPACKAGE *package )
msi_free( package->ProductCode );
msi_free( package->ActionFormat );
msi_free( package->LastAction );
msi_free( package->langids );
/* cleanup control event subscriptions */
ControlEvent_CleanupSubscriptions( package );
@ -681,7 +682,6 @@ static VOID set_installer_properties(MSIPACKAGE *package)
static const WCHAR szScreenY[] = {'S','c','r','e','e','n','Y',0};
static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0};
static const WCHAR szIntFormat[] = {'%','d',0};
static const WCHAR szIntel[] = { 'I','n','t','e','l',0 };
static const WCHAR szMsiAMD64[] = { 'M','s','i','A','M','D','6','4',0 };
static const WCHAR szMsix64[] = { 'M','s','i','x','6','4',0 };
static const WCHAR szSystem64Folder[] = { 'S','y','s','t','e','m','6','4','F','o','l','d','e','r',0 };
@ -1271,6 +1271,64 @@ static UINT apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code )
return r;
}
static UINT msi_parse_summary( MSISUMMARYINFO *si, MSIPACKAGE *package )
{
WCHAR *template, *p, *q;
DWORD i, count;
template = msi_suminfo_dup_string( si, PID_TEMPLATE );
if (!template)
return ERROR_SUCCESS; /* native accepts missing template property */
TRACE("template: %s\n", debugstr_w(template));
p = strchrW( template, ';' );
if (!p)
{
WARN("invalid template string %s\n", debugstr_w(template));
msi_free( template );
return ERROR_PATCH_PACKAGE_INVALID;
}
*p = 0;
if (!template[0] || !strcmpW( template, szIntel ))
package->platform = PLATFORM_INTEL;
else if (!strcmpW( template, szIntel64 ))
package->platform = PLATFORM_INTEL64;
else if (!strcmpW( template, szX64 ))
package->platform = PLATFORM_X64;
else
{
WARN("unknown platform %s\n", debugstr_w(template));
msi_free( template );
return ERROR_PATCH_PACKAGE_INVALID;
}
count = 1;
for (q = ++p; (q = strchrW( q, ',' )); q++) count++;
package->langids = msi_alloc( count * sizeof(LANGID) );
if (!package->langids)
{
msi_free( template );
return ERROR_OUTOFMEMORY;
}
i = 0;
while (*p)
{
q = strchrW( p, ',' );
if (q) *q = 0;
package->langids[i] = atoiW( p );
if (!q) break;
p = q + 1;
i++;
}
package->num_langids = i + 1;
msi_free( template );
return ERROR_SUCCESS;
}
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
{
static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0};
@ -1283,6 +1341,7 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
WCHAR temppath[MAX_PATH], localfile[MAX_PATH], cachefile[MAX_PATH];
LPCWSTR file = szPackage;
DWORD index = 0;
MSISUMMARYINFO *si;
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
@ -1382,6 +1441,23 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
if( file != szPackage )
track_tempfile( package, file );
si = MSI_GetSummaryInformationW( db->storage, 0 );
if (!si)
{
WARN("failed to load summary info %u\n", r);
msiobj_release( &package->hdr );
return ERROR_INSTALL_PACKAGE_INVALID;
}
r = msi_parse_summary( si, package );
msiobj_release( &si->hdr );
if (r != ERROR_SUCCESS)
{
WARN("failed to parse summary info %u\n", r);
msiobj_release( &package->hdr );
return r;
}
msi_set_property( package->db, Database, db->path );
if( UrlIsW( szPackage, URLIS_URL ) )
@ -1412,7 +1488,7 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
if (r != ERROR_SUCCESS)
{
ERR("registered patch failed to apply %u\n", r);
MSI_FreePackage( (MSIOBJECTHDR *)package );
msiobj_release( &package->hdr );
return r;
}

View File

@ -1998,7 +1998,7 @@ static const CHAR suminfo[] = "PropertyId\tValue\n"
"4\tWineHQ\n"
"5\tInstaller\n"
"6\tInstaller comments\n"
"7\tIntel;1033\n"
"7\tIntel;1033,2057\n"
"9\t{12345678-1234-1234-1234-123456789012}\n"
"12\t2009/04/12 15:46:11\n"
"13\t2009/04/12 15:46:11\n"
@ -2107,8 +2107,8 @@ static void test_suminfo_import(void)
r = MsiSummaryInfoGetPropertyA(hsi, PID_TEMPLATE, &type, NULL, NULL, str_value, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
ok(type == VT_LPSTR, "Expected VT_LPSTR, got %u\n", type);
ok(!strcmp(str_value, "Intel;1033"),
"Expected \"Intel;1033\", got %s\n", str_value);
ok(!strcmp(str_value, "Intel;1033,2057"),
"Expected \"Intel;1033,2057\", got %s\n", str_value);
size = sizeof(str_value);
r = MsiSummaryInfoGetPropertyA(hsi, PID_REVNUMBER, &type, NULL, NULL, str_value, &size);
@ -2877,7 +2877,7 @@ static UINT set_summary_info(MSIHANDLE hdb)
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
";1033");
";1033,2057");
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,