wininet: Option INTERNET_OPTION_CALLBACK is not settable.

This commit is contained in:
Hans Leidekker 2008-10-06 15:48:04 +02:00 committed by Alexandre Julliard
parent b981387383
commit 096fa3b9f5
2 changed files with 27 additions and 8 deletions

View File

@ -2259,9 +2259,14 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
{ {
case INTERNET_OPTION_CALLBACK: case INTERNET_OPTION_CALLBACK:
{ {
INTERNET_STATUS_CALLBACK callback = *(INTERNET_STATUS_CALLBACK *)lpBuffer; if (!lpwhh)
ret = (set_status_callback(lpwhh, callback, TRUE) != INTERNET_INVALID_STATUS_CALLBACK); {
break; INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
}
WININET_Release(lpwhh);
INTERNET_SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE);
return FALSE;
} }
case INTERNET_OPTION_HTTP_VERSION: case INTERNET_OPTION_HTTP_VERSION:
{ {
@ -2384,12 +2389,15 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
case INTERNET_OPTION_CALLBACK: case INTERNET_OPTION_CALLBACK:
{ {
LPWININETHANDLEHEADER lpwh; LPWININETHANDLEHEADER lpwh;
INTERNET_STATUS_CALLBACK callback = *(INTERNET_STATUS_CALLBACK *)lpBuffer;
if (!(lpwh = WININET_GetObject(hInternet))) return FALSE; if (!(lpwh = WININET_GetObject(hInternet)))
r = (set_status_callback(lpwh, callback, FALSE) != INTERNET_INVALID_STATUS_CALLBACK); {
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
}
WININET_Release(lpwh); WININET_Release(lpwh);
return r; INTERNET_SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE);
return FALSE;
} }
case INTERNET_OPTION_PROXY: case INTERNET_OPTION_PROXY:
{ {

View File

@ -1984,7 +1984,7 @@ static void test_open_url_async(void)
{ {
BOOL ret; BOOL ret;
HINTERNET ses, req; HINTERNET ses, req;
DWORD size; DWORD size, error;
struct context ctx; struct context ctx;
ULONG type; ULONG type;
@ -1994,6 +1994,17 @@ static void test_open_url_async(void)
ses = InternetOpen("AdvancedInstaller", 0, NULL, NULL, INTERNET_FLAG_ASYNC); ses = InternetOpen("AdvancedInstaller", 0, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(ses != NULL, "InternetOpen failed\n"); ok(ses != NULL, "InternetOpen failed\n");
SetLastError(0xdeadbeef);
ret = InternetSetOptionA(NULL, INTERNET_OPTION_CALLBACK, &cb, sizeof(DWORD_PTR));
error = GetLastError();
ok(!ret, "InternetSetOptionA succeeded\n");
ok(error == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "got %u expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE\n", error);
ret = InternetSetOptionA(ses, INTERNET_OPTION_CALLBACK, &cb, sizeof(DWORD_PTR));
error = GetLastError();
ok(!ret, "InternetSetOptionA failed\n");
ok(error == ERROR_INTERNET_OPTION_NOT_SETTABLE, "got %u expected ERROR_INTERNET_OPTION_NOT_SETTABLE\n", error);
pInternetSetStatusCallbackA(ses, cb); pInternetSetStatusCallbackA(ses, cb);
ResetEvent(ctx.event); ResetEvent(ctx.event);