MSHTML: Added MIME type checking to ResProtocol::Start
Jacek Caban
jack at itma.pwr.wroc.pl
Tue Sep 13 10:31:02 CDT 2005
Changelog:
Added MIME type checking to ResProtocol::Start
-------------- next part --------------
Index: dlls/mshtml/protocol.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/protocol.c,v
retrieving revision 1.14
diff -u -p -r1.14 protocol.c
--- dlls/mshtml/protocol.c 12 Sep 2005 20:12:58 -0000 1.14
+++ dlls/mshtml/protocol.c 13 Sep 2005 15:25:44 -0000
@@ -549,7 +549,7 @@ static HRESULT WINAPI ResProtocol_Start(
ResProtocol *This = PROTOCOL_THIS(iface);
DWORD grfBINDF = 0, len;
BINDINFO bindinfo;
- LPWSTR url_dll, url_file, url;
+ LPWSTR url_dll, url_file, url, mime;
HMODULE hdll;
HRSRC src;
HRESULT hres;
@@ -564,10 +564,6 @@ static HRESULT WINAPI ResProtocol_Start(
IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
ReleaseBindInfo(&bindinfo);
- /* FIXME:
- * Implement MIME type checking
- */
-
len = strlenW(szUrl)+16;
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
@@ -602,10 +598,10 @@ static HRESULT WINAPI ResProtocol_Start(
}
src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML);
- HeapFree(GetProcessHeap(), 0, url);
if(!src) {
WARN("Could not find resource\n");
IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
+ HeapFree(GetProcessHeap(), 0, url);
return HRESULT_FROM_WIN32(GetLastError());
}
@@ -621,6 +617,13 @@ static HRESULT WINAPI ResProtocol_Start(
FreeLibrary(hdll);
+ hres = FindMimeFromData(NULL, url_file, NULL, 0, NULL, 0, &mime, 0);
+ HeapFree(GetProcessHeap(), 0, url);
+ if(SUCCEEDED(hres)) {
+ IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
+ CoTaskMemFree(mime);
+ }
+
IInternetProtocolSink_ReportData(pOIProtSink,
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
This->data_len, This->data_len);
Index: dlls/mshtml/tests/protocol.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/tests/protocol.c,v
retrieving revision 1.7
diff -u -p -r1.7 protocol.c
--- dlls/mshtml/tests/protocol.c 12 Sep 2005 10:10:21 -0000 1.7
+++ dlls/mshtml/tests/protocol.c 13 Sep 2005 15:25:44 -0000
@@ -192,7 +192,7 @@ static void test_protocol_fail(IInternet
expect_GetBindInfo = called_GetBindInfo = FALSE;
}
-static void protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_mime_todo)
+static void protocol_start(IInternetProtocol *protocol, LPCWSTR url)
{
HRESULT hres;
@@ -202,16 +202,12 @@ static void protocol_start(IInternetProt
expect_ReportData = TRUE;
expect_hrResult = S_OK;
expect_hr_win32err = FALSE;
+
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
ok(hres == S_OK, "Start failed: %08lx\n", hres);
+
ok(called_GetBindInfo, "expected GetBindInfo\n");
- if(is_mime_todo) {
- todo_wine {
- ok(called_ReportProgress, "expected ReportProgress\n");
- }
- }else {
- ok(called_ReportProgress, "expected ReportProgress\n");
- }
+ ok(called_ReportProgress, "expected ReportProgress\n");
ok(called_ReportData, "expected ReportData\n");
ok(called_ReportResult, "expected ReportResult\n");
called_GetBindInfo = expect_GetBindInfo = FALSE;
@@ -311,7 +307,7 @@ static void test_res_protocol(void)
ok(hres == E_FAIL, "Read returned %08lx expected E_FAIL\n", hres);
ok(cb == 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb);
- protocol_start(protocol, blank_url, TRUE);
+ protocol_start(protocol, blank_url);
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
ok(cb == 2, "cb=%lu expected 2\n", cb);
@@ -323,7 +319,7 @@ static void test_res_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
- protocol_start(protocol, blank_url, TRUE);
+ protocol_start(protocol, blank_url);
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
hres = IInternetProtocol_LockRequest(protocol, 0);
@@ -333,7 +329,7 @@ static void test_res_protocol(void)
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
- protocol_start(protocol, blank_url, TRUE);
+ protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0);
@@ -350,12 +346,12 @@ static void test_res_protocol(void)
ok(hres == S_OK, "Read failed: %08lx\n", hres);
ok(cb == 2, "cb=%lu expected 2\n", cb);
- protocol_start(protocol, blank_url, TRUE);
+ protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
- protocol_start(protocol, blank_url, TRUE);
+ protocol_start(protocol, blank_url);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0);
@@ -443,7 +439,7 @@ static void test_about_protocol(void)
ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
if(SUCCEEDED(hres)) {
- protocol_start(protocol, blank_url, FALSE);
+ protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
@@ -453,7 +449,7 @@ static void test_about_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
- protocol_start(protocol, test_url, FALSE);
+ protocol_start(protocol, test_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
@@ -463,7 +459,7 @@ static void test_about_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
- protocol_start(protocol, res_url, FALSE);
+ protocol_start(protocol, res_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
More information about the wine-patches
mailing list