Commit 95ef6a1f authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Simplify the MEDIAPACKAGEPATH and DISKPROMPT cases.

parent fe987103
...@@ -395,9 +395,14 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, ...@@ -395,9 +395,14 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
LPCWSTR szProperty, LPCWSTR szValue) LPCWSTR szProperty, LPCWSTR szValue)
{ {
WCHAR squished_pc[GUID_SIZE]; WCHAR squished_pc[GUID_SIZE];
HKEY sourcekey; HKEY sourcekey, media;
LPCWSTR property;
UINT rc; UINT rc;
static const WCHAR media_package[] = {
'M','e','d','i','a','P','a','c','k','a','g','e',0
};
TRACE("%s %s %x %x %s %s\n", debugstr_w(szProduct), debugstr_w(szUserSid), TRACE("%s %s %x %x %s %s\n", debugstr_w(szProduct), debugstr_w(szUserSid),
dwContext, dwOptions, debugstr_w(szProperty), debugstr_w(szValue)); dwContext, dwOptions, debugstr_w(szProperty), debugstr_w(szValue));
...@@ -422,33 +427,23 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, ...@@ -422,33 +427,23 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED) if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n"); FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n");
property = szProperty;
if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW))
property = media_package;
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, FALSE); rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, FALSE);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
return rc; return rc;
if (strcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) == 0) if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) ||
!lstrcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW))
{ {
HKEY key; rc = OpenMediaSubkey(sourcekey, &media, TRUE);
DWORD size = lstrlenW(szValue)*sizeof(WCHAR);
rc = OpenMediaSubkey(sourcekey, &key, FALSE);
if (rc == ERROR_SUCCESS) if (rc == ERROR_SUCCESS)
rc = RegSetValueExW(key, INSTALLPROPERTY_MEDIAPACKAGEPATHW, 0,
REG_SZ, (const BYTE *)szValue, size);
if (rc != ERROR_SUCCESS)
rc = ERROR_UNKNOWN_PROPERTY;
RegCloseKey(key);
}
else if (strcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW) == 0)
{ {
HKEY key; rc = msi_reg_set_val_str(media, property, szValue);
DWORD size = lstrlenW(szValue)*sizeof(WCHAR); RegCloseKey(media);
rc = OpenMediaSubkey(sourcekey, &key, FALSE); }
if (rc == ERROR_SUCCESS)
rc = RegSetValueExW(key, INSTALLPROPERTY_DISKPROMPTW, 0,
REG_SZ, (const BYTE *)szValue, size);
if (rc != ERROR_SUCCESS)
rc = ERROR_UNKNOWN_PROPERTY;
RegCloseKey(key);
} }
else if (strcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW)==0) else if (strcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW)==0)
{ {
......
...@@ -1509,28 +1509,19 @@ static void test_MsiSourceListSetInfo(void) ...@@ -1509,28 +1509,19 @@ static void test_MsiSourceListSetInfo(void)
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT,
INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); INSTALLPROPERTY_MEDIAPACKAGEPATH, "path");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
}
/* Media key is created by MsiSourceListSetInfo */ /* Media key is created by MsiSourceListSetInfo */
res = RegOpenKeyA(source, "Media", &media); res = RegOpenKeyA(source, "Media", &media);
todo_wine
{
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
CHECK_REG_STR(media, "MediaPackage", "path"); CHECK_REG_STR(media, "MediaPackage", "path");
}
/* set the info again */ /* set the info again */
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT,
INSTALLPROPERTY_MEDIAPACKAGEPATH, "path2"); INSTALLPROPERTY_MEDIAPACKAGEPATH, "path2");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
CHECK_REG_STR(media, "MediaPackage", "path2"); CHECK_REG_STR(media, "MediaPackage", "path2");
}
/* NULL szProperty */ /* NULL szProperty */
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
...@@ -1557,11 +1548,8 @@ static void test_MsiSourceListSetInfo(void) ...@@ -1557,11 +1548,8 @@ static void test_MsiSourceListSetInfo(void)
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT,
INSTALLPROPERTY_MEDIAPACKAGEPATH, ""); INSTALLPROPERTY_MEDIAPACKAGEPATH, "");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
CHECK_REG_STR(media, "MediaPackage", ""); CHECK_REG_STR(media, "MediaPackage", "");
}
/* INSTALLPROPERTY_MEDIAPACKAGEPATH, MSISOURCETYPE_NETWORK */ /* INSTALLPROPERTY_MEDIAPACKAGEPATH, MSISOURCETYPE_NETWORK */
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
...@@ -1589,11 +1577,8 @@ static void test_MsiSourceListSetInfo(void) ...@@ -1589,11 +1577,8 @@ static void test_MsiSourceListSetInfo(void)
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT,
INSTALLPROPERTY_DISKPROMPT, "prompt"); INSTALLPROPERTY_DISKPROMPT, "prompt");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
CHECK_REG_STR(media, "DiskPrompt", "prompt"); CHECK_REG_STR(media, "DiskPrompt", "prompt");
}
/* INSTALLPROPERTY_DISKPROMPT, MSISOURCETYPE_NETWORK */ /* INSTALLPROPERTY_DISKPROMPT, MSISOURCETYPE_NETWORK */
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
...@@ -1750,18 +1735,12 @@ static void test_MsiSourceListSetInfo(void) ...@@ -1750,18 +1735,12 @@ static void test_MsiSourceListSetInfo(void)
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); INSTALLPROPERTY_MEDIAPACKAGEPATH, "path");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
}
/* Media key is created by MsiSourceListSetInfo */ /* Media key is created by MsiSourceListSetInfo */
res = RegOpenKeyA(source, "Media", &media); res = RegOpenKeyA(source, "Media", &media);
todo_wine
{
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
CHECK_REG_STR(media, "MediaPackage", "path"); CHECK_REG_STR(media, "MediaPackage", "path");
}
RegDeleteValueA(media, "MediaPackage"); RegDeleteValueA(media, "MediaPackage");
RegDeleteKeyA(media, ""); RegDeleteKeyA(media, "");
...@@ -1793,18 +1772,12 @@ static void test_MsiSourceListSetInfo(void) ...@@ -1793,18 +1772,12 @@ static void test_MsiSourceListSetInfo(void)
r = MsiSourceListSetInfoA(prodcode, NULL, r = MsiSourceListSetInfoA(prodcode, NULL,
MSIINSTALLCONTEXT_MACHINE, MSICODE_PRODUCT, MSIINSTALLCONTEXT_MACHINE, MSICODE_PRODUCT,
INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); INSTALLPROPERTY_MEDIAPACKAGEPATH, "path");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
}
/* Media key is created by MsiSourceListSetInfo */ /* Media key is created by MsiSourceListSetInfo */
res = RegOpenKeyA(source, "Media", &media); res = RegOpenKeyA(source, "Media", &media);
todo_wine
{
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
CHECK_REG_STR(media, "MediaPackage", "path"); CHECK_REG_STR(media, "MediaPackage", "path");
}
/* szUserSid is non-NULL */ /* szUserSid is non-NULL */
r = MsiSourceListSetInfoA(prodcode, usersid, r = MsiSourceListSetInfoA(prodcode, usersid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment