Module: wine Branch: master Commit: 3314184597fc1357ab1d68ad038e93bbcd295333 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3314184597fc1357ab1d68ad03...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Feb 29 12:57:57 2008 +0100
wininet: Move InternetQueryDataAvailable to vtbl.
---
dlls/wininet/ftp.c | 3 + dlls/wininet/http.c | 52 +++++++++++++++++++++++ dlls/wininet/internet.c | 105 +++++++++++----------------------------------- dlls/wininet/internet.h | 1 + 4 files changed, 81 insertions(+), 80 deletions(-)
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index 76801c8..f92e545 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -1190,6 +1190,7 @@ static const HANDLEHEADERVtbl FTPFILEVtbl = { NULL, NULL, FTPFILE_WriteFile, + NULL, NULL };
@@ -2109,6 +2110,7 @@ static const HANDLEHEADERVtbl FTPSESSIONVtbl = { FTPSESSION_CloseConnection, NULL, NULL, + NULL, NULL };
@@ -3194,6 +3196,7 @@ static const HANDLEHEADERVtbl FTPFINDNEXTVtbl = { NULL, NULL, NULL, + NULL, FTPFINDNEXT_FindNextFileW };
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 432b142..b1a181d 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -1418,11 +1418,62 @@ static BOOL HTTPREQ_WriteFile(WININETHANDLEHEADER *hdr, const void *buffer, DWOR return NETCON_send(&lpwhr->netConnection, buffer, size, 0, (LPINT)written); }
+static void HTTPREQ_AsyncQueryDataAvailableProc(WORKREQUEST *workRequest) +{ + WININETHTTPREQW *req = (WININETHTTPREQW*)workRequest->hdr; + INTERNET_ASYNC_RESULT iar; + char buffer[4048]; + + TRACE("%p\n", workRequest->hdr); + + iar.dwResult = NETCON_recv(&req->netConnection, buffer, + min(sizeof(buffer), req->dwContentLength - req->dwContentRead), + MSG_PEEK, (int *)&iar.dwError); + + INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, + sizeof(INTERNET_ASYNC_RESULT)); +} + +static DWORD HTTPREQ_QueryDataAvailable(WININETHANDLEHEADER *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx) +{ + WININETHTTPREQW *req = (WININETHTTPREQW*)hdr; + BYTE buffer[4048]; + BOOL async; + + TRACE("(%p %p %x %lx)\n", req, available, flags, ctx); + + if(!NETCON_query_data_available(&req->netConnection, available) || *available) + return ERROR_SUCCESS; + + /* Even if we are in async mode, we need to determine whether + * there is actually more data available. We do this by trying + * to peek only a single byte in async mode. */ + async = (req->lpHttpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) != 0; + + if (NETCON_recv(&req->netConnection, buffer, + min(async ? 1 : sizeof(buffer), req->dwContentLength - req->dwContentRead), + MSG_PEEK, (int *)available) && async && *available) + { + WORKREQUEST workRequest; + + *available = 0; + workRequest.asyncproc = HTTPREQ_AsyncQueryDataAvailableProc; + workRequest.hdr = WININET_AddRef( &req->hdr ); + + INTERNET_AsyncCall(&workRequest); + + return ERROR_IO_PENDING; + } + + return ERROR_SUCCESS; +} + static const HANDLEHEADERVtbl HTTPREQVtbl = { HTTPREQ_Destroy, HTTPREQ_CloseConnection, HTTPREQ_SetOption, HTTPREQ_WriteFile, + HTTPREQ_QueryDataAvailable, NULL };
@@ -2948,6 +2999,7 @@ static const HANDLEHEADERVtbl HTTPSESSIONVtbl = { NULL, NULL, NULL, + NULL, NULL };
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index feda307..dcddfd2 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -476,6 +476,7 @@ static const HANDLEHEADERVtbl APPINFOVtbl = { NULL, NULL, NULL, + NULL, NULL };
@@ -2399,6 +2400,10 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d INTERNET_SetLastError(ERROR_INVALID_PARAMETER); } break; + case 66: + FIXME("66\n"); + bSuccess = TRUE; + break; default: FIXME("Stub! %d\n", dwOption); break; @@ -2556,6 +2561,9 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, case INTERNET_OPTION_SECURITY_FLAGS: FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n"); break; + case 86: + FIXME("86\n"); + break; default: FIXME("Option %d STUB\n",dwOption); INTERNET_SetLastError(ERROR_INTERNET_INVALID_OPTION); @@ -3400,96 +3408,33 @@ lend: * INTERNET_STATUS_REQUEST_COMPLETE will be sent when more * data is available. */ -void AsyncInternetQueryDataAvailableProc(WORKREQUEST *workRequest) -{ - LPWININETHTTPREQW lpwhr; - INTERNET_ASYNC_RESULT iar; - char buffer[4048]; - - TRACE("INTERNETQUERYDATAAVAILABLE %p\n", workRequest->hdr); - - switch (workRequest->hdr->htype) - { - case WH_HHTTPREQ: - lpwhr = (LPWININETHTTPREQW)workRequest->hdr; - iar.dwResult = NETCON_recv(&lpwhr->netConnection, buffer, - min(sizeof(buffer), - lpwhr->dwContentLength - lpwhr->dwContentRead), - MSG_PEEK, (int *)&iar.dwError); - INTERNET_SendCallback(workRequest->hdr, workRequest->hdr->dwContext, - INTERNET_STATUS_REQUEST_COMPLETE, &iar, - sizeof(INTERNET_ASYNC_RESULT)); - break; - - default: - FIXME("unsupported file type\n"); - break; - } -} - BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailble, DWORD dwFlags, DWORD_PTR dwContext) { - LPWININETHTTPREQW lpwhr; - BOOL retval = FALSE; - char buffer[4048]; + WININETHANDLEHEADER *hdr; + DWORD res;
- lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hFile ); - if (NULL == lpwhr) - { - INTERNET_SetLastError(ERROR_NO_MORE_FILES); + TRACE("(%p %p %x %lx)\n", hFile, lpdwNumberOfBytesAvailble, dwFlags, dwContext); + + hdr = WININET_GetObject( hFile ); + if (!hdr) { + INTERNET_SetLastError(ERROR_INVALID_HANDLE); return FALSE; }
- TRACE("--> %p %i\n",lpwhr,lpwhr->hdr.htype); - - switch (lpwhr->hdr.htype) - { - case WH_HHTTPREQ: - retval = TRUE; - if (NETCON_query_data_available(&lpwhr->netConnection, - lpdwNumberOfBytesAvailble) && - !*lpdwNumberOfBytesAvailble) - { - /* Even if we are in async mode, we need to determine whether - * there is actually more data available. We do this by trying - * to peek only a single byte in async mode. */ - BOOL async = (lpwhr->lpHttpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC); - if (NETCON_recv(&lpwhr->netConnection, buffer, - min(async ? 1 : sizeof(buffer), - lpwhr->dwContentLength - lpwhr->dwContentRead), - MSG_PEEK, (int *)lpdwNumberOfBytesAvailble) && - async && *lpdwNumberOfBytesAvailble) - { - WORKREQUEST workRequest; - - *lpdwNumberOfBytesAvailble = 0; - workRequest.asyncproc = AsyncInternetQueryDataAvailableProc; - workRequest.hdr = WININET_AddRef( &lpwhr->hdr ); - - retval = INTERNET_AsyncCall(&workRequest); - if (!retval) - { - WININET_Release( &lpwhr->hdr ); - } - else - { - INTERNET_SetLastError(ERROR_IO_PENDING); - retval = FALSE; - } - } - } - break; - - default: - FIXME("unsupported file type\n"); - break; + if(hdr->vtbl->QueryDataAvailable) { + res = hdr->vtbl->QueryDataAvailable(hdr, lpdwNumberOfBytesAvailble, dwFlags, dwContext); + }else { + WARN("wrong handle\n"); + res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE; } - WININET_Release( &lpwhr->hdr );
- TRACE("<-- %i\n",retval); - return retval; + WININET_Release(hdr); + + if(res != ERROR_SUCCESS) + SetLastError(res); + return res == ERROR_SUCCESS; }
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 3e95334..4cdab9f 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -140,6 +140,7 @@ typedef struct { void (*CloseConnection)(WININETHANDLEHEADER*); DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD); BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*); + DWORD (*QueryDataAvailable)(WININETHANDLEHEADER*,DWORD*,DWORD,DWORD_PTR); DWORD (*FindNextFileW)(WININETHANDLEHEADER*,void*); } HANDLEHEADERVtbl;