diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index 5aaf3e6c072..b7ddb2b9a01 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -262,7 +262,7 @@ BOOL WINAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile, } hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); if (FTP_SendStore(lpwfs, lpszNewRemoteFile, dwFlags)) { @@ -288,13 +288,13 @@ lend: if (lpwfs->lstnSocket != -1) closesocket(lpwfs->lstnSocket); - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -407,7 +407,7 @@ BOOL WINAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpsz hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_CWD, lpszDirectory, - hIC->lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) + lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) goto lend; nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext); @@ -421,13 +421,13 @@ BOOL WINAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpsz } lend: - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : ERROR_INTERNET_EXTENDED_ERROR; - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } return bSuccess; @@ -545,13 +545,13 @@ BOOL WINAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDire lend: hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -677,7 +677,7 @@ HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs, hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_LIST, NULL, - hIC->lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) + lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) goto lend; nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext); @@ -705,7 +705,7 @@ lend: if (lpwfs->lstnSocket != -1) closesocket(lpwfs->lstnSocket); - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; @@ -713,13 +713,13 @@ lend: { iar.dwResult = (DWORD)hFindNext; iar.dwError = ERROR_SUCCESS; - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_HANDLE_CREATED, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_HANDLE_CREATED, &iar, sizeof(INTERNET_ASYNC_RESULT)); } iar.dwResult = (DWORD)hFindNext; iar.dwError = hFindNext ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -841,7 +841,7 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PWD, NULL, - hIC->lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) + lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) goto lend; nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext); @@ -875,13 +875,13 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC } lend: - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : ERROR_INTERNET_EXTENDED_ERROR; - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1022,6 +1022,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, lpwh->hdr.lpwhparent = WININET_AddRef( &lpwfs->hdr ); lpwh->hdr.dwRefCount = 1; lpwh->hdr.destroy = FTP_CloseFileTransferHandle; + lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB; lpwh->nDataSocket = nDataSocket; lpwh->session_deleted = FALSE; @@ -1037,7 +1038,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, closesocket(lpwfs->lstnSocket); hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; @@ -1045,13 +1046,13 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, { iar.dwResult = (DWORD)handle; iar.dwError = ERROR_SUCCESS; - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_HANDLE_CREATED, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_HANDLE_CREATED, &iar, sizeof(INTERNET_ASYNC_RESULT)); } iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1219,13 +1220,13 @@ lend: CloseHandle(hFile); hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1338,13 +1339,13 @@ BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName) } lend: hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1458,13 +1459,13 @@ BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory) lend: hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1588,13 +1589,13 @@ BOOL FTP_FtpRenameFileW( LPWININETFTPSESSIONW lpwfs, lend: hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)bSuccess; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1656,6 +1657,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, lpwfs->hdr.dwInternalFlags = dwInternalFlags; lpwfs->hdr.dwRefCount = 1; lpwfs->hdr.destroy = FTP_CloseSessionHandle; + lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB; lpwfs->download_in_progress = NULL; handle = WININET_AllocHandle( &lpwfs->hdr ); @@ -1682,19 +1684,19 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, } /* Don't send a handle created callback if this handle was created with InternetOpenUrl */ - if (hIC->lpfnStatusCB && !(lpwfs->hdr.dwInternalFlags & INET_OPENURL)) + if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL)) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)handle; iar.dwError = ERROR_SUCCESS; - SendAsyncCallback(hIC, &hIC->hdr, dwContext, + SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_HANDLE_CREATED, &iar, sizeof(INTERNET_ASYNC_RESULT)); } - SendAsyncCallback(hIC, &hIC->hdr, dwContext, INTERNET_STATUS_RESOLVING_NAME, + SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_RESOLVING_NAME, (LPWSTR) lpszServerName, strlenW(lpszServerName)); if (!GetAddress(lpszServerName, nServerPort, &phe, &socketAddr)) @@ -1703,7 +1705,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, goto lerror; } - SendAsyncCallback(hIC, &hIC->hdr, dwContext, INTERNET_STATUS_NAME_RESOLVED, + SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_NAME_RESOLVED, (LPWSTR) lpszServerName, strlenW(lpszServerName)); nsocket = socket(AF_INET,SOCK_STREAM,0); @@ -1713,7 +1715,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, goto lerror; } - SendAsyncCallback(hIC, &hIC->hdr, dwContext, INTERNET_STATUS_CONNECTING_TO_SERVER, + SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_CONNECTING_TO_SERVER, &socketAddr, sizeof(struct sockaddr_in)); if (connect(nsocket, (struct sockaddr *)&socketAddr, sizeof(socketAddr)) < 0) @@ -1725,7 +1727,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, { TRACE("Connected to server\n"); lpwfs->sndSocket = nsocket; - SendAsyncCallback(hIC, &hIC->hdr, dwContext, INTERNET_STATUS_CONNECTED_TO_SERVER, + SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_CONNECTED_TO_SERVER, &socketAddr, sizeof(struct sockaddr_in)); sock_namelen = sizeof(lpwfs->socketAddress); @@ -1750,13 +1752,13 @@ lerror: lpwfs = NULL; } - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) { INTERNET_ASYNC_RESULT iar; iar.dwResult = (DWORD)lpwfs; iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &hIC->hdr, dwContext, INTERNET_STATUS_REQUEST_COMPLETE, + SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1914,7 +1916,7 @@ INT FTP_ReceiveResponse(LPWININETFTPSESSIONW lpwfs, DWORD dwContext) TRACE("socket(%d) \n", lpwfs->sndSocket); hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent; - SendAsyncCallback(hIC, &lpwfs->hdr, dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + SendAsyncCallback(&lpwfs->hdr, dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); while(1) { @@ -1947,7 +1949,7 @@ INT FTP_ReceiveResponse(LPWININETFTPSESSIONW lpwfs, DWORD dwContext) { rc = atoi(lpszResponse); - SendAsyncCallback(hIC, &lpwfs->hdr, dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, + SendAsyncCallback(&lpwfs->hdr, dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &nRecv, sizeof(DWORD)); } @@ -2706,6 +2708,7 @@ HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LPCWSTR l lpwfn->hdr.dwContext = dwContext; lpwfn->hdr.dwRefCount = 1; lpwfn->hdr.destroy = FTP_CloseFindNextHandle; + lpwfn->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB; lpwfn->index = 1; /* Next index is 1 since we return index 0 */ lpwfn->size = dwSize; lpwfn->lpafp = lpafp; diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 644782ac046..7dac3a104cd 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -670,6 +670,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, HINTERNET handle = NULL; static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0}; DWORD len; + INTERNET_ASYNC_RESULT iar; TRACE("--> \n"); @@ -688,6 +689,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, lpwhr->hdr.dwContext = dwContext; lpwhr->hdr.dwRefCount = 1; lpwhr->hdr.destroy = HTTP_CloseHTTPRequestHandle; + lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB; handle = WININET_AllocHandle( &lpwhr->hdr ); if (NULL == handle) @@ -791,18 +793,12 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, HeapFree(GetProcessHeap(), 0, lpszUrl); + iar.dwResult = (DWORD_PTR)handle; + iar.dwError = ERROR_SUCCESS; - if (hIC->lpfnStatusCB) - { - INTERNET_ASYNC_RESULT iar; - - iar.dwResult = (DWORD)handle; - iar.dwError = ERROR_SUCCESS; - - SendAsyncCallback(hIC, &lpwhs->hdr, dwContext, - INTERNET_STATUS_HANDLE_CREATED, &iar, - sizeof(INTERNET_ASYNC_RESULT)); - } + SendAsyncCallback(&lpwhs->hdr, dwContext, + INTERNET_STATUS_HANDLE_CREATED, &iar, + sizeof(INTERNET_ASYNC_RESULT)); /* * A STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on windows @@ -811,7 +807,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, /* * According to my tests. The name is not resolved until a request is Opened */ - SendAsyncCallback(hIC, &lpwhs->hdr, dwContext, + SendAsyncCallback(&lpwhr->hdr, dwContext, INTERNET_STATUS_RESOLVING_NAME, lpwhs->lpszServerName, strlenW(lpwhs->lpszServerName)+1); @@ -824,7 +820,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, goto lend; } - SendAsyncCallback(hIC, &lpwhs->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_NAME_RESOLVED, &(lpwhs->socketAddress), sizeof(struct sockaddr_in)); @@ -1381,7 +1377,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST HTTP_ProcessHeader(lpwhr, g_szHost, hostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ); - SendAsyncCallback(hIC, &lpwhs->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_RESOLVING_NAME, lpwhs->lpszServerName, strlenW(lpwhs->lpszServerName)+1); @@ -1393,7 +1389,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST return FALSE; } - SendAsyncCallback(hIC, &lpwhs->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_NAME_RESOLVED, &(lpwhs->socketAddress), sizeof(struct sockaddr_in)); @@ -1469,6 +1465,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, LPWININETAPPINFOW hIC = NULL; BOOL loop_next = FALSE; int CustHeaderIndex; + INTERNET_ASYNC_RESULT iar; TRACE("--> %p\n", lpwhr); @@ -1636,17 +1633,17 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ascii_req[len] = 0; TRACE("full request -> %s\n", ascii_req ); - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); NETCON_send(&lpwhr->netConnection, ascii_req, len, 0, &cnt); HeapFree( GetProcessHeap(), 0, ascii_req ); - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, &len,sizeof(DWORD)); - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); if (cnt < 0) @@ -1656,7 +1653,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, if (responseLen) bSuccess = TRUE; - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen, sizeof(DWORD)); @@ -1757,7 +1754,7 @@ lend: dwIndex=0; if(HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,&dwIndex)) { - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_REDIRECT, szNewLocation, dwBufferSize); return HTTP_HandleRedirect(lpwhr, szNewLocation, lpszHeaders, @@ -1766,17 +1763,13 @@ lend: } } - if (hIC->lpfnStatusCB) - { - INTERNET_ASYNC_RESULT iar; - iar.dwResult = (DWORD)bSuccess; - iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); + iar.dwResult = (DWORD)bSuccess; + iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, - INTERNET_STATUS_REQUEST_COMPLETE, &iar, - sizeof(INTERNET_ASYNC_RESULT)); - } + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, + INTERNET_STATUS_REQUEST_COMPLETE, &iar, + sizeof(INTERNET_ASYNC_RESULT)); TRACE("<--\n"); return bSuccess; @@ -1829,6 +1822,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, lpwhs->hdr.dwInternalFlags = dwInternalFlags; lpwhs->hdr.dwRefCount = 1; lpwhs->hdr.destroy = HTTP_CloseHTTPSessionHandle; + lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB; handle = WININET_AllocHandle( &lpwhs->hdr ); if (NULL == handle) @@ -1851,14 +1845,14 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, lpwhs->nServerPort = nServerPort; /* Don't send a handle created callback if this handle was created with InternetOpenUrl */ - if (hIC->lpfnStatusCB && !(lpwhs->hdr.dwInternalFlags & INET_OPENURL)) + if (!(lpwhs->hdr.dwInternalFlags & INET_OPENURL)) { INTERNET_ASYNC_RESULT iar; - iar.dwResult = (DWORD)handle; + iar.dwResult = (DWORD_PTR)handle; iar.dwError = ERROR_SUCCESS; - SendAsyncCallback(hIC, &hIC->hdr, dwContext, + SendAsyncCallback(&lpwhs->hdr, dwContext, INTERNET_STATUS_HANDLE_CREATED, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -1907,7 +1901,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr) lpwhs = (LPWININETHTTPSESSIONW)lpwhr->hdr.lpwhparent; hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_CONNECTING_TO_SERVER, &(lpwhs->socketAddress), sizeof(struct sockaddr_in)); @@ -1926,7 +1920,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr) goto lend; } - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_CONNECTED_TO_SERVER, &(lpwhs->socketAddress), sizeof(struct sockaddr_in)); @@ -2437,7 +2431,7 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr) lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent; hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0); if (NETCON_connected(&lpwhr->netConnection)) @@ -2445,7 +2439,7 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr) NETCON_close(&lpwhr->netConnection); } - SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext, + SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0); } diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 7b393f21e07..72c259eb5b8 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -856,7 +856,6 @@ lend: BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData) { BOOL bSuccess = TRUE; - LPWININETAPPINFOW hIC = NULL; LPWIN32_FIND_DATAW lpFindFileData; TRACE("\n"); @@ -892,8 +891,7 @@ BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData) lend: - hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh); - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) + if (lpwh->hdr.dwFlags & INTERNET_FLAG_ASYNC && lpwh->hdr.lpfnStatusCB) { INTERNET_ASYNC_RESULT iar; @@ -901,7 +899,7 @@ lend: iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); - SendAsyncCallback(hIC, &lpwh->hdr, lpwh->hdr.dwContext, + SendAsyncCallback(&lpwh->hdr, lpwh->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -956,8 +954,7 @@ static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr) */ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet) { - LPWININETHANDLEHEADER lpwh, parent; - LPWININETAPPINFOW hIC; + LPWININETHANDLEHEADER lpwh; TRACE("%p\n",hInternet); @@ -968,12 +965,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet) return FALSE; } - parent = lpwh; - while( parent && (parent->htype != WH_HINIT ) ) - parent = parent->lpwhparent; - - hIC = (LPWININETAPPINFOW) parent; - SendAsyncCallback(hIC, lpwh, lpwh->dwContext, + SendAsyncCallback(lpwh, lpwh->dwContext, INTERNET_STATUS_HANDLE_CLOSING, hInternet, sizeof(HINTERNET)); @@ -1489,22 +1481,20 @@ BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer, INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA( HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB) { - INTERNET_STATUS_CALLBACK retVal = INTERNET_INVALID_STATUS_CALLBACK; - LPWININETAPPINFOW lpwai; + INTERNET_STATUS_CALLBACK retVal; + LPWININETHANDLEHEADER lpwh; - TRACE("(%p, %p)\n", hInternet, lpfnIntCB); + TRACE("0x%08lx\n", (ULONG)hInternet); - lpwai = (LPWININETAPPINFOW)WININET_GetObject(hInternet); - if (!lpwai) - return retVal; + lpwh = WININET_GetObject(hInternet); + if (!lpwh) + return INTERNET_INVALID_STATUS_CALLBACK; - if (lpwai->hdr.htype == WH_HINIT) - { - lpwai->hdr.dwInternalFlags &= ~INET_CALLBACKW; - retVal = lpwai->lpfnStatusCB; - lpwai->lpfnStatusCB = lpfnIntCB; - } - WININET_Release( &lpwai->hdr ); + lpwh->dwInternalFlags &= ~INET_CALLBACKW; + retVal = lpwh->lpfnStatusCB; + lpwh->lpfnStatusCB = lpfnIntCB; + + WININET_Release( lpwh ); return retVal; } @@ -1523,23 +1513,20 @@ INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA( INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW( HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB) { - INTERNET_STATUS_CALLBACK retVal = INTERNET_INVALID_STATUS_CALLBACK; - LPWININETAPPINFOW lpwai; + INTERNET_STATUS_CALLBACK retVal; + LPWININETHANDLEHEADER lpwh; - TRACE("(%p, %p)\n", hInternet, lpfnIntCB); + TRACE("0x%08lx\n", (ULONG)hInternet); - lpwai = (LPWININETAPPINFOW)WININET_GetObject(hInternet); - if (!lpwai) - return retVal; + lpwh = WININET_GetObject(hInternet); + if (!lpwh) + return INTERNET_INVALID_STATUS_CALLBACK; - if (lpwai->hdr.htype == WH_HINIT) - { - lpwai->hdr.dwInternalFlags |= INET_CALLBACKW; - retVal = lpwai->lpfnStatusCB; - lpwai->lpfnStatusCB = lpfnIntCB; - } + lpwh->dwInternalFlags |= INET_CALLBACKW; + retVal = lpwh->lpfnStatusCB; + lpwh->lpfnStatusCB = lpfnIntCB; - WININET_Release( &lpwai->hdr ); + WININET_Release( lpwh ); return retVal; } @@ -2714,11 +2701,10 @@ static VOID INTERNET_ExecuteWork() case SENDCALLBACK: { struct WORKREQ_SENDCALLBACK *req = &workRequest.u.SendCallback; - LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest.hdr; - TRACE("SENDCALLBACK %p\n", hIC); + TRACE("SENDCALLBACK %p\n", workRequest.hdr); - SendAsyncCallbackInt(hIC, req->hdr, + SendSyncCallback(workRequest.hdr, req->dwContext, req->dwInternetStatus, req->lpvStatusInfo, req->dwStatusInfoLength); } diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index e36010992bb..f02c4ae21b9 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -140,6 +140,7 @@ struct _WININETHANDLEHEADER DWORD dwInternalFlags; DWORD dwRefCount; WININET_object_destructor destroy; + INTERNET_STATUS_CALLBACK lpfnStatusCB; struct _WININETHANDLEHEADER *lpwhparent; }; @@ -153,7 +154,6 @@ typedef struct LPWSTR lpszProxyUsername; LPWSTR lpszProxyPassword; DWORD dwAccessType; - INTERNET_STATUS_CALLBACK lpfnStatusCB; } WININETAPPINFOW, *LPWININETAPPINFOW; @@ -345,7 +345,6 @@ struct WORKREQ_HTTPSENDREQUESTW struct WORKREQ_SENDCALLBACK { - WININETHANDLEHEADER *hdr; DWORD dwContext; DWORD dwInternetStatus; LPVOID lpvStatusInfo; @@ -443,13 +442,13 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD dwContext); -VOID SendAsyncCallback(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, - DWORD dwContext, DWORD dwInternetStatus, LPVOID - lpvStatusInfo , DWORD dwStatusInfoLength); +VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext, + DWORD dwInternetStatus, LPVOID lpvStatusInfo, + DWORD dwStatusInfoLength); -VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, - DWORD dwContext, DWORD dwInternetStatus, LPVOID - lpvStatusInfo , DWORD dwStatusInfoLength); +VOID SendSyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext, + DWORD dwInternetStatus, LPVOID lpvStatusInfo, + DWORD dwStatusInfoLength); BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr, LPCWSTR username, LPCWSTR password ); diff --git a/dlls/wininet/utility.c b/dlls/wininet/utility.c index e2f56c7adb3..ee07f740aec 100644 --- a/dlls/wininet/utility.c +++ b/dlls/wininet/utility.c @@ -216,14 +216,14 @@ static const char *get_callback_name(DWORD dwInternetStatus) { return "Unknown"; } -VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, - DWORD dwContext, DWORD dwInternetStatus, LPVOID - lpvStatusInfo, DWORD dwStatusInfoLength) +VOID SendSyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext, + DWORD dwInternetStatus, LPVOID lpvStatusInfo, + DWORD dwStatusInfoLength) { HINTERNET hHttpSession; LPVOID lpvNewInfo = NULL; - if( !hIC->lpfnStatusCB ) + if( !hdr->lpfnStatusCB ) return; /* the IE5 version of wininet does not @@ -238,7 +238,7 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, return; lpvNewInfo = lpvStatusInfo; - if(!(hIC->hdr.dwInternalFlags & INET_CALLBACKW)) { + if(!(hdr->dwInternalFlags & INET_CALLBACKW)) { switch(dwInternetStatus) { case INTERNET_STATUS_RESOLVING_NAME: @@ -246,7 +246,7 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, lpvNewInfo = WININET_strdup_WtoA(lpvStatusInfo); } } - hIC->lpfnStatusCB(hHttpSession, dwContext, dwInternetStatus, + hdr->lpfnStatusCB(hHttpSession, dwContext, dwInternetStatus, lpvNewInfo, dwStatusInfoLength); if(lpvNewInfo != lpvStatusInfo) HeapFree(GetProcessHeap(), 0, lpvNewInfo); @@ -258,23 +258,22 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, -VOID SendAsyncCallback(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, - DWORD dwContext, DWORD dwInternetStatus, LPVOID - lpvStatusInfo, DWORD dwStatusInfoLength) +VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext, + DWORD dwInternetStatus, LPVOID lpvStatusInfo, + DWORD dwStatusInfoLength) { TRACE("Send Callback %ld (%s)\n",dwInternetStatus, get_callback_name(dwInternetStatus)); - if (! (hIC->lpfnStatusCB)) + if (!(hdr->lpfnStatusCB)) return; - if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) + if (hdr->dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; struct WORKREQ_SENDCALLBACK *req; workRequest.asyncall = SENDCALLBACK; - workRequest.hdr = WININET_AddRef( &hIC->hdr ); + workRequest.hdr = WININET_AddRef( hdr ); req = &workRequest.u.SendCallback; - req->hdr = hdr; req->dwContext = dwContext; req->dwInternetStatus = dwInternetStatus; req->lpvStatusInfo = lpvStatusInfo; @@ -283,6 +282,6 @@ VOID SendAsyncCallback(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr, INTERNET_AsyncCall(&workRequest); } else - SendAsyncCallbackInt(hIC, hdr, dwContext, dwInternetStatus, - lpvStatusInfo, dwStatusInfoLength); + SendSyncCallback(hdr, dwContext, dwInternetStatus, + lpvStatusInfo, dwStatusInfoLength); }