kernel32/tests: Init pointers in common way, add some win_skip() while skipping.
[wine/hramrach.git] / dlls / urlmon / mimefilter.c
blobee6f50f238f69258d6b7a081c9fcff310c5dfb9c
1 /*
2 * Copyright 2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "urlmon_main.h"
20 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
24 typedef struct {
25 const IInternetProtocolVtbl *lpIInternetProtocolVtbl;
26 const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
28 LONG ref;
29 } MimeFilter;
31 #define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolVtbl)
32 #define PROTOCOLSINK(x) ((IInternetProtocolSink*) &(x)->lpIInternetProtocolSinkVtbl)
34 #define PROTOCOL_THIS(iface) DEFINE_THIS(MimeFilter, IInternetProtocol, iface)
36 static HRESULT WINAPI MimeFilterProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
38 MimeFilter *This = PROTOCOL_THIS(iface);
40 *ppv = NULL;
41 if(IsEqualGUID(&IID_IUnknown, riid)) {
42 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
43 *ppv = PROTOCOL(This);
44 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
45 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
46 *ppv = PROTOCOL(This);
47 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
48 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
49 *ppv = PROTOCOL(This);
50 }else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
51 TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
52 *ppv = PROTOCOLSINK(This);
55 if(*ppv) {
56 IInternetProtocol_AddRef(iface);
57 return S_OK;
60 WARN("not supported interface %s\n", debugstr_guid(riid));
61 return E_NOINTERFACE;
64 static ULONG WINAPI MimeFilterProtocol_AddRef(IInternetProtocol *iface)
66 MimeFilter *This = PROTOCOL_THIS(iface);
67 LONG ref = InterlockedIncrement(&This->ref);
68 TRACE("(%p) ref=%d\n", This, ref);
69 return ref;
72 static ULONG WINAPI MimeFilterProtocol_Release(IInternetProtocol *iface)
74 MimeFilter *This = PROTOCOL_THIS(iface);
75 LONG ref = InterlockedDecrement(&This->ref);
77 TRACE("(%p) ref=%d\n", This, ref);
79 if(!ref) {
80 heap_free(This);
82 URLMON_UnlockModule();
85 return ref;
88 static HRESULT WINAPI MimeFilterProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
89 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
90 DWORD grfPI, HANDLE_PTR dwReserved)
92 MimeFilter *This = PROTOCOL_THIS(iface);
93 FIXME("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
94 pOIBindInfo, grfPI, dwReserved);
95 return E_NOTIMPL;
98 static HRESULT WINAPI MimeFilterProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
100 MimeFilter *This = PROTOCOL_THIS(iface);
101 FIXME("(%p)->(%p)\n", This, pProtocolData);
102 return E_NOTIMPL;
105 static HRESULT WINAPI MimeFilterProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
106 DWORD dwOptions)
108 MimeFilter *This = PROTOCOL_THIS(iface);
109 FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
110 return E_NOTIMPL;
113 static HRESULT WINAPI MimeFilterProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
115 MimeFilter *This = PROTOCOL_THIS(iface);
116 FIXME("(%p)->(%08x)\n", This, dwOptions);
117 return E_NOTIMPL;
120 static HRESULT WINAPI MimeFilterProtocol_Suspend(IInternetProtocol *iface)
122 MimeFilter *This = PROTOCOL_THIS(iface);
123 FIXME("(%p)\n", This);
124 return E_NOTIMPL;
127 static HRESULT WINAPI MimeFilterProtocol_Resume(IInternetProtocol *iface)
129 MimeFilter *This = PROTOCOL_THIS(iface);
130 FIXME("(%p)\n", This);
131 return E_NOTIMPL;
134 static HRESULT WINAPI MimeFilterProtocol_Read(IInternetProtocol *iface, void *pv,
135 ULONG cb, ULONG *pcbRead)
137 MimeFilter *This = PROTOCOL_THIS(iface);
138 FIXME("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
139 return E_NOTIMPL;
142 static HRESULT WINAPI MimeFilterProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
143 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
145 MimeFilter *This = PROTOCOL_THIS(iface);
146 FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
147 return E_NOTIMPL;
150 static HRESULT WINAPI MimeFilterProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
152 MimeFilter *This = PROTOCOL_THIS(iface);
153 FIXME("(%p)->(%08x)\n", This, dwOptions);
154 return E_NOTIMPL;
157 static HRESULT WINAPI MimeFilterProtocol_UnlockRequest(IInternetProtocol *iface)
159 MimeFilter *This = PROTOCOL_THIS(iface);
160 FIXME("(%p)\n", This);
161 return E_NOTIMPL;
164 #undef PROTOCOL_THIS
166 static const IInternetProtocolVtbl MimeFilterProtocolVtbl = {
167 MimeFilterProtocol_QueryInterface,
168 MimeFilterProtocol_AddRef,
169 MimeFilterProtocol_Release,
170 MimeFilterProtocol_Start,
171 MimeFilterProtocol_Continue,
172 MimeFilterProtocol_Abort,
173 MimeFilterProtocol_Terminate,
174 MimeFilterProtocol_Suspend,
175 MimeFilterProtocol_Resume,
176 MimeFilterProtocol_Read,
177 MimeFilterProtocol_Seek,
178 MimeFilterProtocol_LockRequest,
179 MimeFilterProtocol_UnlockRequest
182 #define PROTSINK_THIS(iface) DEFINE_THIS(MimeFilter, IInternetProtocolSink, iface)
184 static HRESULT WINAPI MimeFilterSink_QueryInterface(IInternetProtocolSink *iface,
185 REFIID riid, void **ppv)
187 MimeFilter *This = PROTSINK_THIS(iface);
188 return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
191 static ULONG WINAPI MimeFilterSink_AddRef(IInternetProtocolSink *iface)
193 MimeFilter *This = PROTSINK_THIS(iface);
194 return IInternetProtocol_AddRef(PROTOCOL(This));
197 static ULONG WINAPI MimeFilterSink_Release(IInternetProtocolSink *iface)
199 MimeFilter *This = PROTSINK_THIS(iface);
200 return IInternetProtocol_Release(PROTOCOL(This));
203 static HRESULT WINAPI MimeFilterSink_Switch(IInternetProtocolSink *iface,
204 PROTOCOLDATA *pProtocolData)
206 MimeFilter *This = PROTSINK_THIS(iface);
207 FIXME("(%p)->(%p)\n", This, pProtocolData);
208 return E_NOTIMPL;
211 static HRESULT WINAPI MimeFilterSink_ReportProgress(IInternetProtocolSink *iface,
212 ULONG ulStatusCode, LPCWSTR szStatusText)
214 MimeFilter *This = PROTSINK_THIS(iface);
215 FIXME("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
216 return E_NOTIMPL;
219 static HRESULT WINAPI MimeFilterSink_ReportData(IInternetProtocolSink *iface,
220 DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
222 MimeFilter *This = PROTSINK_THIS(iface);
223 FIXME("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax);
224 return E_NOTIMPL;
227 static HRESULT WINAPI MimeFilterSink_ReportResult(IInternetProtocolSink *iface,
228 HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
230 MimeFilter *This = PROTSINK_THIS(iface);
231 FIXME("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
232 return E_NOTIMPL;
235 #undef PROTSINK_THIS
237 static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
238 MimeFilterSink_QueryInterface,
239 MimeFilterSink_AddRef,
240 MimeFilterSink_Release,
241 MimeFilterSink_Switch,
242 MimeFilterSink_ReportProgress,
243 MimeFilterSink_ReportData,
244 MimeFilterSink_ReportResult
247 HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
249 MimeFilter *ret;
251 TRACE("(%p %p)\n", pUnkOuter, ppobj);
253 URLMON_LockModule();
255 ret = heap_alloc_zero(sizeof(MimeFilter));
257 ret->lpIInternetProtocolVtbl = &MimeFilterProtocolVtbl;
258 ret->lpIInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl;
259 ret->ref = 1;
261 *ppobj = PROTOCOL(ret);
262 return S_OK;