wined3d: Use surface_blt_to_drawable() in IWineD3DSurfaceImpl_BltOverride().
[wine/multimedia.git] / dlls / urlmon / gopher.c
blobda241e9358e5349a5587611c8bdf03cbd455726c
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 Protocol base;
27 const IInternetProtocolVtbl *lpIInternetProtocolVtbl;
28 const IInternetPriorityVtbl *lpInternetPriorityVtbl;
30 LONG ref;
31 } GopherProtocol;
33 #define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
35 #define ASYNCPROTOCOL_THIS(iface) DEFINE_THIS2(GopherProtocol, base, iface)
37 static HRESULT GopherProtocol_open_request(Protocol *prot, IUri *uri, DWORD request_flags,
38 HINTERNET internet_session, IInternetBindInfo *bind_info)
40 GopherProtocol *This = ASYNCPROTOCOL_THIS(prot);
41 BSTR url;
42 HRESULT hres;
44 hres = IUri_GetAbsoluteUri(uri, &url);
45 if(FAILED(hres))
46 return hres;
48 This->base.request = InternetOpenUrlW(internet_session, url, NULL, 0,
49 request_flags, (DWORD_PTR)&This->base);
50 SysFreeString(url);
51 if (!This->base.request && GetLastError() != ERROR_IO_PENDING) {
52 WARN("InternetOpenUrl failed: %d\n", GetLastError());
53 return INET_E_RESOURCE_NOT_FOUND;
56 return S_OK;
59 static HRESULT GopherProtocol_end_request(Protocol *prot)
61 return E_NOTIMPL;
64 static HRESULT GopherProtocol_start_downloading(Protocol *prot)
66 return S_OK;
69 static void GopherProtocol_close_connection(Protocol *prot)
73 #undef ASYNCPROTOCOL_THIS
75 static const ProtocolVtbl AsyncProtocolVtbl = {
76 GopherProtocol_open_request,
77 GopherProtocol_end_request,
78 GopherProtocol_start_downloading,
79 GopherProtocol_close_connection
82 #define PROTOCOL_THIS(iface) DEFINE_THIS(GopherProtocol, IInternetProtocol, iface)
84 static HRESULT WINAPI GopherProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
86 GopherProtocol *This = PROTOCOL_THIS(iface);
88 *ppv = NULL;
89 if(IsEqualGUID(&IID_IUnknown, riid)) {
90 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
91 *ppv = PROTOCOL(This);
92 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
93 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
94 *ppv = PROTOCOL(This);
95 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
96 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
97 *ppv = PROTOCOL(This);
98 }else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
99 TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
100 *ppv = PRIORITY(This);
103 if(*ppv) {
104 IInternetProtocol_AddRef(iface);
105 return S_OK;
108 WARN("not supported interface %s\n", debugstr_guid(riid));
109 return E_NOINTERFACE;
112 static ULONG WINAPI GopherProtocol_AddRef(IInternetProtocol *iface)
114 GopherProtocol *This = PROTOCOL_THIS(iface);
115 LONG ref = InterlockedIncrement(&This->ref);
116 TRACE("(%p) ref=%d\n", This, ref);
117 return ref;
120 static ULONG WINAPI GopherProtocol_Release(IInternetProtocol *iface)
122 GopherProtocol *This = PROTOCOL_THIS(iface);
123 LONG ref = InterlockedDecrement(&This->ref);
125 TRACE("(%p) ref=%d\n", This, ref);
127 if(!ref) {
128 heap_free(This);
130 URLMON_UnlockModule();
133 return ref;
136 static HRESULT WINAPI GopherProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
137 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
138 DWORD grfPI, HANDLE_PTR dwReserved)
140 GopherProtocol *This = PROTOCOL_THIS(iface);
141 IUri *uri;
142 HRESULT hres;
144 TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
145 pOIBindInfo, grfPI, dwReserved);
147 hres = CreateUri(szUrl, 0, 0, &uri);
148 if(FAILED(hres))
149 return hres;
151 hres = protocol_start(&This->base, PROTOCOL(This), uri, pOIProtSink, pOIBindInfo);
153 IUri_Release(uri);
154 return hres;
157 static HRESULT WINAPI GopherProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
159 GopherProtocol *This = PROTOCOL_THIS(iface);
161 TRACE("(%p)->(%p)\n", This, pProtocolData);
163 return protocol_continue(&This->base, pProtocolData);
166 static HRESULT WINAPI GopherProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
167 DWORD dwOptions)
169 GopherProtocol *This = PROTOCOL_THIS(iface);
171 TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
173 return protocol_abort(&This->base, hrReason);
176 static HRESULT WINAPI GopherProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
178 GopherProtocol *This = PROTOCOL_THIS(iface);
180 TRACE("(%p)->(%08x)\n", This, dwOptions);
182 protocol_close_connection(&This->base);
183 return S_OK;
186 static HRESULT WINAPI GopherProtocol_Suspend(IInternetProtocol *iface)
188 GopherProtocol *This = PROTOCOL_THIS(iface);
189 FIXME("(%p)\n", This);
190 return E_NOTIMPL;
193 static HRESULT WINAPI GopherProtocol_Resume(IInternetProtocol *iface)
195 GopherProtocol *This = PROTOCOL_THIS(iface);
196 FIXME("(%p)\n", This);
197 return E_NOTIMPL;
200 static HRESULT WINAPI GopherProtocol_Read(IInternetProtocol *iface, void *pv,
201 ULONG cb, ULONG *pcbRead)
203 GopherProtocol *This = PROTOCOL_THIS(iface);
205 TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
207 return protocol_read(&This->base, pv, cb, pcbRead);
210 static HRESULT WINAPI GopherProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
211 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
213 GopherProtocol *This = PROTOCOL_THIS(iface);
214 FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
215 return E_NOTIMPL;
218 static HRESULT WINAPI GopherProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
220 GopherProtocol *This = PROTOCOL_THIS(iface);
222 TRACE("(%p)->(%08x)\n", This, dwOptions);
224 return protocol_lock_request(&This->base);
227 static HRESULT WINAPI GopherProtocol_UnlockRequest(IInternetProtocol *iface)
229 GopherProtocol *This = PROTOCOL_THIS(iface);
231 TRACE("(%p)\n", This);
233 return protocol_unlock_request(&This->base);
236 #undef PROTOCOL_THIS
238 static const IInternetProtocolVtbl GopherProtocolVtbl = {
239 GopherProtocol_QueryInterface,
240 GopherProtocol_AddRef,
241 GopherProtocol_Release,
242 GopherProtocol_Start,
243 GopherProtocol_Continue,
244 GopherProtocol_Abort,
245 GopherProtocol_Terminate,
246 GopherProtocol_Suspend,
247 GopherProtocol_Resume,
248 GopherProtocol_Read,
249 GopherProtocol_Seek,
250 GopherProtocol_LockRequest,
251 GopherProtocol_UnlockRequest
254 #define PRIORITY_THIS(iface) DEFINE_THIS(GopherProtocol, InternetPriority, iface)
256 static HRESULT WINAPI GopherPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
258 GopherProtocol *This = PRIORITY_THIS(iface);
259 return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
262 static ULONG WINAPI GopherPriority_AddRef(IInternetPriority *iface)
264 GopherProtocol *This = PRIORITY_THIS(iface);
265 return IInternetProtocol_AddRef(PROTOCOL(This));
268 static ULONG WINAPI GopherPriority_Release(IInternetPriority *iface)
270 GopherProtocol *This = PRIORITY_THIS(iface);
271 return IInternetProtocol_Release(PROTOCOL(This));
274 static HRESULT WINAPI GopherPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
276 GopherProtocol *This = PRIORITY_THIS(iface);
278 TRACE("(%p)->(%d)\n", This, nPriority);
280 This->base.priority = nPriority;
281 return S_OK;
284 static HRESULT WINAPI GopherPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
286 GopherProtocol *This = PRIORITY_THIS(iface);
288 TRACE("(%p)->(%p)\n", This, pnPriority);
290 *pnPriority = This->base.priority;
291 return S_OK;
294 #undef PRIORITY_THIS
296 static const IInternetPriorityVtbl GopherPriorityVtbl = {
297 GopherPriority_QueryInterface,
298 GopherPriority_AddRef,
299 GopherPriority_Release,
300 GopherPriority_SetPriority,
301 GopherPriority_GetPriority
304 HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
306 GopherProtocol *ret;
308 TRACE("(%p %p)\n", pUnkOuter, ppobj);
310 URLMON_LockModule();
312 ret = heap_alloc_zero(sizeof(GopherProtocol));
314 ret->base.vtbl = &AsyncProtocolVtbl;
315 ret->lpIInternetProtocolVtbl = &GopherProtocolVtbl;
316 ret->lpInternetPriorityVtbl = &GopherPriorityVtbl;
317 ret->ref = 1;
319 *ppobj = PROTOCOL(ret);
321 return S_OK;