From 14d439c8634db2f06b49fd2a4f54fc574de29da4 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Mon, 5 Nov 2007 04:32:00 -0500 Subject: [PATCH] msi: Handle the MSIINSTALLCONTEXT_USERMANAGED context. --- dlls/msi/source.c | 43 ++++++++++++++---------------------- dlls/msi/tests/install.c | 9 +++++--- dlls/msi/tests/source.c | 47 +++++++++++----------------------------- 3 files changed, 35 insertions(+), 64 deletions(-) diff --git a/dlls/msi/source.c b/dlls/msi/source.c index 7f25d633910..e79cb615b1e 100644 --- a/dlls/msi/source.c +++ b/dlls/msi/source.c @@ -52,20 +52,28 @@ typedef struct tagMediaInfo DWORD index; } media_info; -static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, DWORD dwOptions, BOOL user, BOOL create) +static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, DWORD dwOptions, + MSIINSTALLCONTEXT context, BOOL create) { HKEY rootkey = 0; - UINT rc; + UINT rc = ERROR_FUNCTION_FAILED; static const WCHAR szSourceList[] = {'S','o','u','r','c','e','L','i','s','t',0}; - if (user) + if (context == MSIINSTALLCONTEXT_USERUNMANAGED) { if (dwOptions == MSICODE_PATCH) rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create); else rc = MSIREG_OpenUserProductsKey(szProduct, &rootkey, create); } - else + else if (context == MSIINSTALLCONTEXT_USERMANAGED) + { + if (dwOptions == MSICODE_PATCH) + rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create); + else + rc = MSIREG_OpenLocalManagedProductKey(szProduct, &rootkey, create); + } + else if (context == MSIINSTALLCONTEXT_MACHINE) { if (dwOptions == MSICODE_PATCH) rc = MSIREG_OpenPatchesKey(szProduct, &rootkey, create); @@ -235,11 +243,7 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED) FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n"); - if (dwContext == MSIINSTALLCONTEXT_MACHINE) - rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, FALSE, FALSE); - else - rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, TRUE, FALSE); - + rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, dwContext, FALSE); if (rc != ERROR_SUCCESS) return rc; @@ -382,11 +386,7 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED) FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n"); - if (dwContext == MSIINSTALLCONTEXT_MACHINE) - rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, FALSE, TRUE); - else - rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, TRUE, TRUE); - + rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, TRUE); if (rc != ERROR_SUCCESS) return ERROR_UNKNOWN_PRODUCT; @@ -670,14 +670,7 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid, if (szUserSid) FIXME("Unhandled UserSid %s\n",debugstr_w(szUserSid)); - if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED) - FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n"); - - if (dwContext == MSIINSTALLCONTEXT_MACHINE) - rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, FALSE, FALSE); - else - rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, TRUE, FALSE); - + rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, FALSE); if (rc != ERROR_SUCCESS) return rc; @@ -797,11 +790,7 @@ UINT WINAPI MsiSourceListAddMediaDiskW(LPCWSTR szProduct, LPCWSTR szUserSid, if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED) FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n"); - if (dwContext == MSIINSTALLCONTEXT_MACHINE) - rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, FALSE, TRUE); - else - rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, TRUE, TRUE); - + rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, TRUE); if (rc != ERROR_SUCCESS) return ERROR_UNKNOWN_PRODUCT; diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index a9c9a0fedab..8c8aadf1ddb 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -2345,9 +2345,12 @@ static void test_publishsourcelist(void) lstrcpyA(value, "aaa"); r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value); - ok(size == 11, "Expected 11, got %d\n", size); + todo_wine + { + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value); + ok(size == 11, "Expected 11, got %d\n", size); + } /* complete uninstall */ r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL"); diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c index 254473e509c..991d2796cea 100644 --- a/dlls/msi/tests/source.c +++ b/dlls/msi/tests/source.c @@ -591,10 +591,7 @@ static void test_MsiSourceListAddSourceEx(void) r = pMsiSourceListAddSourceExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0); - todo_wine - { - ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - } + ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\"); lstrcatA(keypath, usersid); @@ -608,10 +605,7 @@ static void test_MsiSourceListAddSourceEx(void) r = pMsiSourceListAddSourceExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_URL, "C:\\source", 0); - todo_wine - { - ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r); - } + ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r); res = RegCreateKeyA(prodkey, "SourceList", &hkey); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); @@ -624,19 +618,13 @@ static void test_MsiSourceListAddSourceEx(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); res = RegOpenKeyA(prodkey, "SourceList\\URL", &url); - todo_wine - { - ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); - } + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); size = MAX_PATH; res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size); - todo_wine - { - ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); - ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value); - ok(size == 11, "Expected 11, got %d\n", size); - } + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value); + ok(size == 11, "Expected 11, got %d\n", size); RegCloseKey(url); @@ -648,28 +636,19 @@ static void test_MsiSourceListAddSourceEx(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); res = RegOpenKeyA(prodkey, "SourceList\\URL", &url); - todo_wine - { - ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); - } + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); size = MAX_PATH; res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size); - todo_wine - { - ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); - ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value); - ok(size == 11, "Expected 11, got %d\n", size); - } + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value); + ok(size == 11, "Expected 11, got %d\n", size); size = MAX_PATH; res = RegQueryValueExA(url, "2", NULL, NULL, (LPBYTE)value, &size); - todo_wine - { - ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); - ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value); - ok(size == 9, "Expected 9, got %d\n", size); - } + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value); + ok(size == 9, "Expected 9, got %d\n", size); RegCloseKey(url); RegCloseKey(prodkey);