wininet: Moved close_connection to vtbl.

This commit is contained in:
Jacek Caban 2008-02-26 20:21:00 +01:00 committed by Alexandre Julliard
parent 5a535d6b23
commit 7dc9bf677b
4 changed files with 84 additions and 99 deletions

View File

@ -122,7 +122,6 @@ static const CHAR *const szFtpCommands[] = {
static const CHAR szMonths[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
static const WCHAR szNoAccount[] = {'n','o','a','c','c','o','u','n','t','\0'};
static void FTP_CloseConnection(LPWININETHANDLEHEADER hdr);
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam,
INTERNET_STATUS_CALLBACK lpfnStatusCB, LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext);
static BOOL FTP_SendStore(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, DWORD dwType);
@ -1157,7 +1156,8 @@ static void FTPFILE_Destroy(WININETHANDLEHEADER *hdr)
}
static const HANDLEHEADERVtbl FTPFILEVtbl = {
FTPFILE_Destroy
FTPFILE_Destroy,
NULL
};
/***********************************************************************
@ -1205,7 +1205,6 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs,
lpwh->hdr.dwFlags = dwFlags;
lpwh->hdr.dwContext = dwContext;
lpwh->hdr.dwRefCount = 1;
lpwh->hdr.close_connection = NULL;
lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwh->nDataSocket = nDataSocket;
lpwh->session_deleted = FALSE;
@ -2047,9 +2046,34 @@ static void FTPSESSION_Destroy(WININETHANDLEHEADER *hdr)
HeapFree(GetProcessHeap(), 0, lpwfs);
}
static void FTPSESSION_CloseConnection(WININETHANDLEHEADER *hdr)
{
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) hdr;
TRACE("\n");
SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
if (lpwfs->download_in_progress != NULL)
lpwfs->download_in_progress->session_deleted = TRUE;
if (lpwfs->sndSocket != -1)
closesocket(lpwfs->sndSocket);
if (lpwfs->lstnSocket != -1)
closesocket(lpwfs->lstnSocket);
if (lpwfs->pasvSocket != -1)
closesocket(lpwfs->pasvSocket);
SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext,
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
}
static const HANDLEHEADERVtbl FTPSESSIONVtbl = {
FTPSESSION_Destroy
FTPSESSION_Destroy,
FTPSESSION_CloseConnection
};
@ -2121,7 +2145,6 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwfs->hdr.dwContext = dwContext;
lpwfs->hdr.dwInternalFlags = dwInternalFlags;
lpwfs->hdr.dwRefCount = 1;
lpwfs->hdr.close_connection = FTP_CloseConnection;
lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
lpwfs->download_in_progress = NULL;
lpwfs->sndSocket = -1;
@ -3045,36 +3068,6 @@ recv_end:
return (nRC != -1);
}
/***********************************************************************
* FTP_CloseConnection (internal)
*
* Close connections
*/
static void FTP_CloseConnection(LPWININETHANDLEHEADER hdr)
{
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) hdr;
TRACE("\n");
SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
if (lpwfs->download_in_progress != NULL)
lpwfs->download_in_progress->session_deleted = TRUE;
if (lpwfs->sndSocket != -1)
closesocket(lpwfs->sndSocket);
if (lpwfs->lstnSocket != -1)
closesocket(lpwfs->lstnSocket);
if (lpwfs->pasvSocket != -1)
closesocket(lpwfs->pasvSocket);
SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext,
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
}
/***********************************************************************
* FTP_FindNextFileW (Internal)
@ -3156,7 +3149,8 @@ static void FTPFINDNEXT_Destroy(WININETHANDLEHEADER *hdr)
}
static const HANDLEHEADERVtbl FTPFINDNEXTVtbl = {
FTPFINDNEXT_Destroy
FTPFINDNEXT_Destroy,
NULL
};
/***********************************************************************
@ -3191,7 +3185,6 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
lpwfn->hdr.vtbl = &FTPFINDNEXTVtbl;
lpwfn->hdr.dwContext = dwContext;
lpwfn->hdr.dwRefCount = 1;
lpwfn->hdr.close_connection = NULL;
lpwfn->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwfn->index = 1; /* Next index is 1 since we return index 0 */
lpwfn->size = dwSize;

View File

@ -103,7 +103,6 @@ struct HttpAuthInfo
BOOL finished; /* finished authenticating */
};
static void HTTP_CloseConnection(LPWININETHANDLEHEADER hdr);
static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr);
static BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr);
static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR value, DWORD dwModifier);
@ -1349,8 +1348,53 @@ static void HTTPREQ_Destroy(WININETHANDLEHEADER *hdr)
HeapFree(GetProcessHeap(), 0, lpwhr);
}
static void HTTPREQ_CloseConnection(WININETHANDLEHEADER *hdr)
{
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr;
LPWININETHTTPSESSIONW lpwhs = NULL;
LPWININETAPPINFOW hIC = NULL;
TRACE("%p\n",lpwhr);
if (!NETCON_connected(&lpwhr->netConnection))
return;
if (lpwhr->pAuthInfo)
{
DeleteSecurityContext(&lpwhr->pAuthInfo->ctx);
FreeCredentialsHandle(&lpwhr->pAuthInfo->cred);
HeapFree(GetProcessHeap(), 0, lpwhr->pAuthInfo->auth_data);
HeapFree(GetProcessHeap(), 0, lpwhr->pAuthInfo->scheme);
HeapFree(GetProcessHeap(), 0, lpwhr->pAuthInfo);
lpwhr->pAuthInfo = NULL;
}
if (lpwhr->pProxyAuthInfo)
{
DeleteSecurityContext(&lpwhr->pProxyAuthInfo->ctx);
FreeCredentialsHandle(&lpwhr->pProxyAuthInfo->cred);
HeapFree(GetProcessHeap(), 0, lpwhr->pProxyAuthInfo->auth_data);
HeapFree(GetProcessHeap(), 0, lpwhr->pProxyAuthInfo->scheme);
HeapFree(GetProcessHeap(), 0, lpwhr->pProxyAuthInfo);
lpwhr->pProxyAuthInfo = NULL;
}
lpwhs = lpwhr->lpHttpSession;
hIC = lpwhs->lpAppInfo;
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
NETCON_close(&lpwhr->netConnection);
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
}
static const HANDLEHEADERVtbl HTTPREQVtbl = {
HTTPREQ_Destroy
HTTPREQ_Destroy,
HTTPREQ_CloseConnection
};
/***********************************************************************
@ -1394,7 +1438,6 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->hdr.dwFlags = dwFlags;
lpwhr->hdr.dwContext = dwContext;
lpwhr->hdr.dwRefCount = 1;
lpwhr->hdr.close_connection = HTTP_CloseConnection;
lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB;
lpwhr->hdr.dwInternalFlags = lpwhs->hdr.dwInternalFlags & INET_CALLBACKW;
@ -2872,7 +2915,8 @@ static void HTTPSESSION_Destroy(WININETHANDLEHEADER *hdr)
static const HANDLEHEADERVtbl HTTPSESSIONVtbl = {
HTTPSESSION_Destroy
HTTPSESSION_Destroy,
NULL
};
@ -2922,7 +2966,6 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwhs->hdr.dwContext = dwContext;
lpwhs->hdr.dwInternalFlags = dwInternalFlags | (hIC->hdr.dwInternalFlags & INET_CALLBACKW);
lpwhs->hdr.dwRefCount = 1;
lpwhs->hdr.close_connection = NULL;
lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
WININET_AddRef( &hIC->hdr );
@ -3429,57 +3472,6 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v
}
/***********************************************************************
* HTTP_CloseConnection (internal)
*
* Close socket connection
*
*/
static void HTTP_CloseConnection(LPWININETHANDLEHEADER hdr)
{
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr;
LPWININETHTTPSESSIONW lpwhs = NULL;
LPWININETAPPINFOW hIC = NULL;
TRACE("%p\n",lpwhr);
if (!NETCON_connected(&lpwhr->netConnection))
return;
if (lpwhr->pAuthInfo)
{
DeleteSecurityContext(&lpwhr->pAuthInfo->ctx);
FreeCredentialsHandle(&lpwhr->pAuthInfo->cred);
HeapFree(GetProcessHeap(), 0, lpwhr->pAuthInfo->auth_data);
HeapFree(GetProcessHeap(), 0, lpwhr->pAuthInfo->scheme);
HeapFree(GetProcessHeap(), 0, lpwhr->pAuthInfo);
lpwhr->pAuthInfo = NULL;
}
if (lpwhr->pProxyAuthInfo)
{
DeleteSecurityContext(&lpwhr->pProxyAuthInfo->ctx);
FreeCredentialsHandle(&lpwhr->pProxyAuthInfo->cred);
HeapFree(GetProcessHeap(), 0, lpwhr->pProxyAuthInfo->auth_data);
HeapFree(GetProcessHeap(), 0, lpwhr->pProxyAuthInfo->scheme);
HeapFree(GetProcessHeap(), 0, lpwhr->pProxyAuthInfo);
lpwhr->pProxyAuthInfo = NULL;
}
lpwhs = lpwhr->lpHttpSession;
hIC = lpwhs->lpAppInfo;
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
NETCON_close(&lpwhr->netConnection);
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
}
/***********************************************************************
* HTTP_FinishedReading (internal)
*
@ -3497,7 +3489,7 @@ BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr)
&dwBufferSize, NULL) ||
strcmpiW(szConnectionResponse, szKeepAlive))
{
HTTP_CloseConnection(&lpwhr->hdr);
HTTPREQ_CloseConnection(&lpwhr->hdr);
}
/* FIXME: store data in the URL cache here */

View File

@ -174,10 +174,10 @@ BOOL WININET_Release( LPWININETHANDLEHEADER info )
TRACE( "object %p refcount = %d\n", info, info->dwRefCount );
if( !info->dwRefCount )
{
if ( info->close_connection )
if ( info->vtbl->CloseConnection )
{
TRACE( "closing connection %p\n", info);
info->close_connection( info );
info->vtbl->CloseConnection( info );
}
INTERNET_SendCallback(info, info->dwContext,
INTERNET_STATUS_HANDLE_CLOSING, &info->hInternet,
@ -472,7 +472,8 @@ static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr)
}
static const HANDLEHEADERVtbl APPINFOVtbl = {
APPINFO_Destroy
APPINFO_Destroy,
NULL
};
@ -531,7 +532,6 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
lpwai->hdr.vtbl = &APPINFOVtbl;
lpwai->hdr.dwFlags = dwFlags;
lpwai->hdr.dwRefCount = 1;
lpwai->hdr.close_connection = NULL;
lpwai->dwAccessType = dwAccessType;
lpwai->lpszProxyUsername = NULL;
lpwai->lpszProxyPassword = NULL;

View File

@ -140,6 +140,7 @@ typedef void (*WININET_object_function)( LPWININETHANDLEHEADER );
typedef struct {
void (*Destroy)(WININETHANDLEHEADER*);
void (*CloseConnection)(WININETHANDLEHEADER*);
} HANDLEHEADERVtbl;
struct _WININETHANDLEHEADER
@ -152,7 +153,6 @@ struct _WININETHANDLEHEADER
DWORD dwError;
DWORD dwInternalFlags;
DWORD dwRefCount;
WININET_object_function close_connection;
INTERNET_STATUS_CALLBACK lpfnStatusCB;
struct list entry;
struct list children;