wininet: Moved InternetFindNextFileW implementation to vtbl.

This commit is contained in:
Jacek Caban 2008-02-27 18:55:09 +01:00 committed by Alexandre Julliard
parent 34002d4c7e
commit 8c45eecca7
4 changed files with 90 additions and 100 deletions

View File

@ -1170,7 +1170,8 @@ static const HANDLEHEADERVtbl FTPFILEVtbl = {
FTPFILE_Destroy, FTPFILE_Destroy,
NULL, NULL,
NULL, NULL,
FTPFILE_WriteFile FTPFILE_WriteFile,
NULL
}; };
/*********************************************************************** /***********************************************************************
@ -2088,6 +2089,7 @@ static const HANDLEHEADERVtbl FTPSESSIONVtbl = {
FTPSESSION_Destroy, FTPSESSION_Destroy,
FTPSESSION_CloseConnection, FTPSESSION_CloseConnection,
NULL, NULL,
NULL,
NULL NULL
}; };
@ -3083,63 +3085,6 @@ recv_end:
return (nRC != -1); return (nRC != -1);
} }
/***********************************************************************
* FTP_FindNextFileW (Internal)
*
* Continues a file search from a previous call to FindFirstFile
*
* RETURNS
* TRUE on success
* FALSE on failure
*
*/
BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData)
{
BOOL bSuccess = TRUE;
LPWIN32_FIND_DATAW lpFindFileData;
TRACE("index(%d) size(%d)\n", lpwh->index, lpwh->size);
assert (lpwh->hdr.htype == WH_HFTPFINDNEXT);
/* Clear any error information */
INTERNET_SetLastError(0);
lpFindFileData = (LPWIN32_FIND_DATAW) lpvFindData;
ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
if (lpwh->index >= lpwh->size)
{
INTERNET_SetLastError(ERROR_NO_MORE_FILES);
bSuccess = FALSE;
goto lend;
}
FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
lpwh->index++;
TRACE("\nName: %s\nSize: %d\n", debugstr_w(lpFindFileData->cFileName), lpFindFileData->nFileSizeLow);
lend:
if (lpwh->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
INTERNET_ASYNC_RESULT iar;
iar.dwResult = (DWORD)bSuccess;
iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
INTERNET_GetLastError();
INTERNET_SendCallback(&lpwh->hdr, lpwh->hdr.dwContext,
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
}
return bSuccess;
}
/*********************************************************************** /***********************************************************************
* FTPFINDNEXT_Destroy (internal) * FTPFINDNEXT_Destroy (internal)
* *
@ -3163,11 +3108,74 @@ static void FTPFINDNEXT_Destroy(WININETHANDLEHEADER *hdr)
HeapFree(GetProcessHeap(), 0, lpwfn); HeapFree(GetProcessHeap(), 0, lpwfn);
} }
static DWORD WINAPI FTPFINDNEXT_FindNextFileProc(WININETFTPFINDNEXTW *find, LPVOID data)
{
WIN32_FIND_DATAW *find_data = data;
DWORD res = ERROR_SUCCESS;
TRACE("index(%d) size(%d)\n", find->index, find->size);
ZeroMemory(find_data, sizeof(WIN32_FIND_DATAW));
if (find->index < find->size) {
FTP_ConvertFileProp(&find->lpafp[find->index], find_data);
find->index++;
TRACE("Name: %s\nSize: %d\n", debugstr_w(find_data->cFileName), find_data->nFileSizeLow);
}else {
res = ERROR_NO_MORE_FILES;
}
if (find->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
INTERNET_ASYNC_RESULT iar;
iar.dwResult = (res == ERROR_SUCCESS);
iar.dwError = res;
INTERNET_SendCallback(&find->hdr, find->hdr.dwContext,
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
}
return res;
}
static void FTPFINDNEXT_AsyncFindNextFileProc(WORKREQUEST *workRequest)
{
struct WORKREQ_FTPFINDNEXTW *req = &workRequest->u.FtpFindNextW;
FTPFINDNEXT_FindNextFileProc((WININETFTPFINDNEXTW*)workRequest->hdr, req->lpFindFileData);
}
static DWORD FTPFINDNEXT_FindNextFileW(WININETHANDLEHEADER *hdr, void *data)
{
WININETFTPFINDNEXTW *find = (WININETFTPFINDNEXTW*)hdr;
if (find->lpFtpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
WORKREQUEST workRequest;
struct WORKREQ_FTPFINDNEXTW *req;
workRequest.asyncproc = FTPFINDNEXT_AsyncFindNextFileProc;
workRequest.hdr = WININET_AddRef( &find->hdr );
req = &workRequest.u.FtpFindNextW;
req->lpFindFileData = data;
INTERNET_AsyncCall(&workRequest);
return ERROR_SUCCESS;
}
return FTPFINDNEXT_FindNextFileProc(find, data);
}
static const HANDLEHEADERVtbl FTPFINDNEXTVtbl = { static const HANDLEHEADERVtbl FTPFINDNEXTVtbl = {
FTPFINDNEXT_Destroy, FTPFINDNEXT_Destroy,
NULL, NULL,
NULL, NULL,
NULL NULL,
FTPFINDNEXT_FindNextFileW
}; };
/*********************************************************************** /***********************************************************************

View File

@ -1422,7 +1422,8 @@ static const HANDLEHEADERVtbl HTTPREQVtbl = {
HTTPREQ_Destroy, HTTPREQ_Destroy,
HTTPREQ_CloseConnection, HTTPREQ_CloseConnection,
HTTPREQ_SetOption, HTTPREQ_SetOption,
HTTPREQ_WriteFile HTTPREQ_WriteFile,
NULL
}; };
/*********************************************************************** /***********************************************************************
@ -2946,6 +2947,7 @@ static const HANDLEHEADERVtbl HTTPSESSIONVtbl = {
HTTPSESSION_Destroy, HTTPSESSION_Destroy,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View File

@ -475,6 +475,7 @@ static const HANDLEHEADERVtbl APPINFOVtbl = {
APPINFO_Destroy, APPINFO_Destroy,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };
@ -944,53 +945,32 @@ BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
* FALSE on failure * FALSE on failure
* *
*/ */
static void AsyncFtpFindNextFileProc(WORKREQUEST *workRequest)
{
struct WORKREQ_FTPFINDNEXTW *req = &workRequest->u.FtpFindNextW;
LPWININETFTPFINDNEXTW lpwh = (LPWININETFTPFINDNEXTW) workRequest->hdr;
TRACE("%p\n", lpwh);
FTP_FindNextFileW(lpwh, req->lpFindFileData);
}
BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData) BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
{ {
LPWININETAPPINFOW hIC = NULL; WININETHANDLEHEADER *hdr;
LPWININETFTPFINDNEXTW lpwh; DWORD res;
BOOL bSuccess = FALSE;
TRACE("\n"); TRACE("\n");
lpwh = (LPWININETFTPFINDNEXTW) WININET_GetObject( hFind ); hdr = WININET_GetObject(hFind);
if (NULL == lpwh || lpwh->hdr.htype != WH_HFTPFINDNEXT) if(!hdr) {
{ WARN("Invalid handle\n");
FIXME("Only FTP supported\n"); SetLastError(ERROR_INVALID_HANDLE);
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); return FALSE;
goto lend;
} }
hIC = lpwh->lpFtpSession->lpAppInfo; if(hdr->vtbl->FindNextFileW) {
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) res = hdr->vtbl->FindNextFileW(hdr, lpvFindData);
{ }else {
WORKREQUEST workRequest; WARN("Handle doesn't support NextFile\n");
struct WORKREQ_FTPFINDNEXTW *req; res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
workRequest.asyncproc = AsyncFtpFindNextFileProc;
workRequest.hdr = WININET_AddRef( &lpwh->hdr );
req = &workRequest.u.FtpFindNextW;
req->lpFindFileData = lpvFindData;
bSuccess = INTERNET_AsyncCall(&workRequest);
} }
else
{ WININET_Release(hdr);
bSuccess = FTP_FindNextFileW(lpwh, lpvFindData);
} if(res != ERROR_SUCCESS)
lend: SetLastError(res);
if( lpwh ) return res == ERROR_SUCCESS;
WININET_Release( &lpwh->hdr );
return bSuccess;
} }
/*********************************************************************** /***********************************************************************

View File

@ -140,6 +140,7 @@ typedef struct {
void (*CloseConnection)(WININETHANDLEHEADER*); void (*CloseConnection)(WININETHANDLEHEADER*);
DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD); DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD);
BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*); BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*);
DWORD (*FindNextFileW)(WININETHANDLEHEADER*,void*);
} HANDLEHEADERVtbl; } HANDLEHEADERVtbl;
struct _WININETHANDLEHEADER struct _WININETHANDLEHEADER
@ -429,7 +430,6 @@ BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDire
BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory); BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs, INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext); LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext);
BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory, BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
LPDWORD lpdwCurrentDirectory); LPDWORD lpdwCurrentDirectory);
BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData); BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);