This patch makes an application with built-in internet shop work.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/wininet/tests/urlcache.c | 53 ++++++++++++++++ dlls/wininet/urlcache.c | 113 +++++++++++++++++++++++++++++++--- 2 files changed, 158 insertions(+), 8 deletions(-)
diff --git a/dlls/wininet/tests/urlcache.c b/dlls/wininet/tests/urlcache.c index 3799500489..4794cb0b6e 100644 --- a/dlls/wininet/tests/urlcache.c +++ b/dlls/wininet/tests/urlcache.c @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define NONAMELESSUNION +#define NONAMELESSSTRUCT + #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -1100,6 +1103,55 @@ static void test_trailing_slash(void) DeleteFileA(filename); }
+static void test_GetUrlCacheConfigInfo(void) +{ + INTERNET_CACHE_CONFIG_INFOA info; + struct + { + INTERNET_CACHE_CONFIG_INFOA *info; + DWORD dwStructSize; + DWORD flags; + BOOL ret; + DWORD error; + } td[] = + { +#if 0 /* crashes under Vista */ + { NULL, 0, 0, FALSE, ERROR_INVALID_PARAMETER }, +#endif + { &info, 0, 0, TRUE }, + { &info, sizeof(info) - 1, 0, TRUE }, + { &info, sizeof(info) + 1, 0, TRUE }, + { &info, 0, CACHE_CONFIG_CONTENT_PATHS_FC, TRUE }, + { &info, sizeof(info), CACHE_CONFIG_CONTENT_PATHS_FC, TRUE }, + { &info, 0, CACHE_CONFIG_COOKIES_PATHS_FC, TRUE }, + { &info, sizeof(info), CACHE_CONFIG_COOKIES_PATHS_FC, TRUE }, + { &info, 0, CACHE_CONFIG_HISTORY_PATHS_FC, TRUE }, + { &info, sizeof(info), CACHE_CONFIG_HISTORY_PATHS_FC, TRUE }, + }; + int i; + BOOL ret; + + for (i = 0; i < ARRAY_SIZE(td); i++) + { + if (td[i].info) + { + memset(&info, 0, sizeof(*td[i].info)); + info.dwStructSize = td[i].dwStructSize; + } + + SetLastError(0xdeadbeef); + ret = GetUrlCacheConfigInfoA(td[i].info, NULL, td[i].flags); + ok(ret == td[i].ret, "%d: expected %d, got %d\n", i, td[i].ret, ret); + if (!ret) + ok(GetLastError() == td[i].error, "%d: expected %u, got %u\n", i, td[i].error, GetLastError()); + else + { + ok(info.dwStructSize == td[i].dwStructSize, "got %u\n", info.dwStructSize); + ok(info.u.s.CachePath[0], "%d: got empty path\n", i); + } + } +} + START_TEST(urlcache) { HMODULE hdll; @@ -1124,4 +1176,5 @@ START_TEST(urlcache) test_FindCloseUrlCache(); test_GetDiskInfoA(); test_trailing_slash(); + test_GetUrlCacheConfigInfo(); } diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index f26fa3468d..c8d141e3d9 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -23,6 +23,7 @@ */
#define NONAMELESSUNION +#define NONAMELESSSTRUCT
#include "ws2tcpip.h"
@@ -3764,21 +3765,117 @@ BOOL WINAPI SetUrlCacheEntryGroupW(LPCWSTR lpszUrlName, DWORD dwFlags, /*********************************************************************** * GetUrlCacheConfigInfoW (WININET.@) */ -BOOL WINAPI GetUrlCacheConfigInfoW(LPINTERNET_CACHE_CONFIG_INFOW CacheInfo, LPDWORD size, DWORD bitmask) +BOOL WINAPI GetUrlCacheConfigInfoW(LPINTERNET_CACHE_CONFIG_INFOW info, LPDWORD size, DWORD flags) { - FIXME("(%p, %p, %x)\n", CacheInfo, size, bitmask); - INTERNET_SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + cache_container *container; + + FIXME("(%p, %p, %x): semi-stub\n", info, size, flags); + + if (!info) + { + INTERNET_SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + info->dwContainer = 0; + info->dwQuota = 0x3e800; + info->dwReserved4 = 0; + info->fPerUser = TRUE; + info->dwSyncMode = 0; + info->dwNumCachePaths = 1; + info->dwNormalUsage = 0; + info->dwExemptUsage = 0; + + info->u.s.CachePath[0] = 0; + info->u.s.dwCacheSize = 0x3e800; /* FIXME */ + + LIST_FOR_EACH_ENTRY(container, &UrlContainers, cache_container, entry) + { + switch (flags & (CACHE_CONFIG_CONTENT_PATHS_FC | CACHE_CONFIG_COOKIES_PATHS_FC | CACHE_CONFIG_HISTORY_PATHS_FC)) + { + case 0: + case CACHE_CONFIG_CONTENT_PATHS_FC: + if (container->default_entry_type == NORMAL_CACHE_ENTRY) + lstrcpynW(info->u.s.CachePath, container->path, MAX_PATH); + break; + + case CACHE_CONFIG_COOKIES_PATHS_FC: + if (container->default_entry_type == COOKIE_CACHE_ENTRY) + lstrcpynW(info->u.s.CachePath, container->path, MAX_PATH); + break; + + case CACHE_CONFIG_HISTORY_PATHS_FC: + if (container->default_entry_type == URLHISTORY_CACHE_ENTRY) + lstrcpynW(info->u.s.CachePath, container->path, MAX_PATH); + break; + + default: + FIXME("flags %08x not handled\n", flags); + break; + } + } + + TRACE("CachePath %s\n", debugstr_w(info->u.s.CachePath)); + + return TRUE; }
/*********************************************************************** * GetUrlCacheConfigInfoA (WININET.@) */ -BOOL WINAPI GetUrlCacheConfigInfoA(LPINTERNET_CACHE_CONFIG_INFOA CacheInfo, LPDWORD size, DWORD bitmask) +BOOL WINAPI GetUrlCacheConfigInfoA(LPINTERNET_CACHE_CONFIG_INFOA info, LPDWORD size, DWORD flags) { - FIXME("(%p, %p, %x)\n", CacheInfo, size, bitmask); - INTERNET_SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + cache_container *container; + + FIXME("(%p, %p, %x): semi-stub\n", info, size, flags); + + if (!info) + { + INTERNET_SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + info->dwContainer = 0; + info->dwQuota = 0x3e800; + info->dwReserved4 = 0; + info->fPerUser = TRUE; + info->dwSyncMode = 0; + info->dwNumCachePaths = 1; + info->dwNormalUsage = 0; + info->dwExemptUsage = 0; + + info->u.s.CachePath[0] = 0; + info->u.s.dwCacheSize = 0x3e800; /* FIXME */ + + LIST_FOR_EACH_ENTRY(container, &UrlContainers, cache_container, entry) + { + switch (flags & (CACHE_CONFIG_CONTENT_PATHS_FC | CACHE_CONFIG_COOKIES_PATHS_FC | CACHE_CONFIG_HISTORY_PATHS_FC)) + { + case 0: + case CACHE_CONFIG_CONTENT_PATHS_FC: + if (container->default_entry_type == NORMAL_CACHE_ENTRY) + WideCharToMultiByte(CP_ACP, 0, container->path, -1, info->u.s.CachePath, MAX_PATH, NULL, NULL); + break; + + case CACHE_CONFIG_COOKIES_PATHS_FC: + if (container->default_entry_type == COOKIE_CACHE_ENTRY) + WideCharToMultiByte(CP_ACP, 0, container->path, -1, info->u.s.CachePath, MAX_PATH, NULL, NULL); + break; + + case CACHE_CONFIG_HISTORY_PATHS_FC: + if (container->default_entry_type == URLHISTORY_CACHE_ENTRY) + WideCharToMultiByte(CP_ACP, 0, container->path, -1, info->u.s.CachePath, MAX_PATH, NULL, NULL); + break; + + default: + FIXME("flags %08x not handled\n", flags); + break; + } + } + + TRACE("CachePath %s\n", debugstr_a(info->u.s.CachePath)); + + return TRUE; }
BOOL WINAPI GetUrlCacheGroupAttributeA( GROUPID gid, DWORD dwFlags, DWORD dwAttributes,