Commit ed517f3a authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

InternetSetStatusCallback can be used on any handle and callbacks are

inherited by derived handles.
parent 56b9d3c7
......@@ -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);
if (hIC->lpfnStatusCB)
{
INTERNET_ASYNC_RESULT iar;
iar.dwResult = (DWORD)handle;
iar.dwResult = (DWORD_PTR)handle;
iar.dwError = ERROR_SUCCESS;
SendAsyncCallback(hIC, &lpwhs->hdr, dwContext,
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();
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
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);
}
......
......@@ -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);
}
......
......@@ -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 );
......
......@@ -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,
SendSyncCallback(hdr, dwContext, dwInternetStatus,
lpvStatusInfo, dwStatusInfoLength);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment