From 097750cf956ce54491a059d9d57205851c389fb8 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 14 Sep 2005 10:29:56 +0000 Subject: [PATCH] Added MIME type checking to FileProtocol::Start. --- dlls/urlmon/file.c | 16 ++++++++++------ dlls/urlmon/tests/protocol.c | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/urlmon/file.c b/dlls/urlmon/file.c index b89a8dab783..be54cea221e 100644 --- a/dlls/urlmon/file.c +++ b/dlls/urlmon/file.c @@ -103,7 +103,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl DWORD grfBINDF = 0; LARGE_INTEGER size; DWORD len; - LPWSTR url; + LPWSTR url, mime = NULL; HRESULT hres; static const WCHAR wszFile[] = {'f','i','l','e',':'}; @@ -127,9 +127,9 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl return hres; } - /* FIXME: - * Implement MIME type checking - */ + hres = FindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0); + if(SUCCEEDED(hres)) + IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DIRECTBIND, mime); if(!This->file) { This->file = CreateFileW(url+sizeof(wszFile)/sizeof(WCHAR), GENERIC_READ, FILE_SHARE_READ, @@ -140,16 +140,20 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl IInternetProtocolSink_ReportResult(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, GetLastError(), NULL); HeapFree(GetProcessHeap(), 0, url); + CoTaskMemFree(mime); return INET_E_RESOURCE_NOT_FOUND; } IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_CACHEFILENAMEAVAILABLE, url+sizeof(wszFile)/sizeof(WCHAR)); + if(mime) + IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime); IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL); - - HeapFree(GetProcessHeap(), 0, url); } + CoTaskMemFree(mime); + HeapFree(GetProcessHeap(), 0, url); + if(GetFileSizeEx(This->file, &size)) IInternetProtocolSink_ReportData(pOIProtSink, BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION, diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c index 4a409517498..eea12843a7e 100644 --- a/dlls/urlmon/tests/protocol.c +++ b/dlls/urlmon/tests/protocol.c @@ -215,10 +215,10 @@ static void file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL i ok(hres == S_OK, "Start failed: %08lx\n", hres); CHECK_CALLED(GetBindInfo); - todo_wine { CHECK_CALLED(ReportProgress_DIRECTBIND); } + CHECK_CALLED(ReportProgress_DIRECTBIND); if(is_first) { CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE); - todo_wine { CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); } + CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); CHECK_CALLED(ReportResult); } CHECK_CALLED(ReportData); @@ -373,7 +373,7 @@ static void test_file_protocol(void) { ok(hres == INET_E_RESOURCE_NOT_FOUND, "Start failed: %08lx expected INET_E_RESOURCE_NOT_FOUND\n", hres); CHECK_CALLED(GetBindInfo); - todo_wine { CHECK_CALLED(ReportProgress_DIRECTBIND); } + CHECK_CALLED(ReportProgress_DIRECTBIND); CHECK_CALLED(ReportResult); IInternetProtocol_Release(protocol); @@ -392,7 +392,7 @@ static void test_file_protocol(void) { ok(hres == INET_E_RESOURCE_NOT_FOUND, "Start failed: %08lx, expected INET_E_RESOURCE_NOT_FOUND\n", hres); CHECK_CALLED(GetBindInfo); - todo_wine { CHECK_CALLED(ReportProgress_DIRECTBIND); } + CHECK_CALLED(ReportProgress_DIRECTBIND); CHECK_CALLED(ReportResult); IInternetProtocol_Release(protocol);