Module: wine Branch: master Commit: 13a95f16488f62c64e3e77777f2e81d08a6d88e5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=13a95f16488f62c64e3e77777f...
Author: Jacek Caban jacek@codeweavers.com Date: Sat Jul 19 12:29:01 2008 +0200
wininet: Move InternetQueryOption(INTERNET_OPTION_USER_AGENT) to vtbl.
---
dlls/wininet/http.c | 2 +- dlls/wininet/internet.c | 64 +++++++++++++++++----------------------- dlls/wininet/tests/internet.c | 4 +- 3 files changed, 30 insertions(+), 40 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 38023a8..cefa836 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -3473,7 +3473,7 @@ static DWORD HTTPSESSION_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, voi }
FIXME("Not implemented option %d\n", option); - return ERROR_INTERNET_INVALID_OPTION; + return ERROR_INTERNET_INCORRECT_HANDLE_TYPE; }
static const HANDLEHEADERVtbl HTTPSESSIONVtbl = { diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index b054765..cce504f 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -495,6 +495,8 @@ static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr)
static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode) { + LPWININETAPPINFOW ai = (LPWININETAPPINFOW)hdr; + switch(option) { case INTERNET_OPTION_HANDLE_TYPE: TRACE("INTERNET_OPTION_HANDLE_TYPE\n"); @@ -505,6 +507,30 @@ static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b *size = sizeof(DWORD); *(DWORD*)buffer = INTERNET_HANDLE_TYPE_INTERNET; return ERROR_SUCCESS; + + case INTERNET_OPTION_USER_AGENT: { + DWORD bufsize; + + TRACE("INTERNET_OPTION_USER_AGENT\n"); + + bufsize = *size; + + if (unicode) { + *size = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR); + if(!buffer || bufsize < *size) + return ERROR_INSUFFICIENT_BUFFER; + + strcpyW(buffer, ai->lpszAgent); + }else { + *size = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL); + if(!buffer || bufsize < *size) + return ERROR_INSUFFICIENT_BUFFER; + + WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, buffer, *size, NULL, NULL); + } + + return ERROR_SUCCESS; + } }
FIXME("Not implemented option %d\n", option); @@ -1959,43 +1985,6 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d break; }
- case INTERNET_OPTION_USER_AGENT: - { - DWORD required; - LPWININETAPPINFOW ai = (LPWININETAPPINFOW)lpwhh; - - TRACE("INTERNET_OPTION_USER_AGENT\n"); - - if (!lpwhh || lpwhh->htype != INTERNET_HANDLE_TYPE_INTERNET) - { - INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); - return FALSE; - } - if (bIsUnicode) - { - required = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR); - if (*lpdwBufferLength < required) - INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); - else if (lpBuffer) - { - strcpyW(lpBuffer, ai->lpszAgent); - bSuccess = TRUE; - } - } - else - { - required = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL); - if (*lpdwBufferLength < required) - INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); - else if (lpBuffer) - { - WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, lpBuffer, required, NULL, NULL); - bSuccess = TRUE; - } - } - *lpdwBufferLength = required; - break; - } case INTERNET_OPTION_HTTP_VERSION: { if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO)) @@ -2230,6 +2219,7 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d SetLastError(res); }else { FIXME("Stub! %d\n", dwOption); + SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); break; } } diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c index 2c5f4e3..14adc43 100644 --- a/dlls/wininet/tests/internet.c +++ b/dlls/wininet/tests/internet.c @@ -161,7 +161,7 @@ static void test_InternetQueryOptionA(void) err=GetLastError(); ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent)); ok(retval == 0,"Got wrong return value %d\n",retval); - todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err); + ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
SetLastError(0xdeadbeef); len=strlen(useragent)+1; @@ -221,7 +221,7 @@ static void test_InternetQueryOptionA(void) err=GetLastError(); todo_wine ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1); ok(retval == 0,"Got wrong return value %d\n",retval); - todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err); + ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
InternetCloseHandle(hinet); }