winealsa.drv: Conform critical section DebugInfo names.
[wine/hacks.git] / dlls / urlmon / http.c
blobf761314095990db3a2b18590ff04a9fd4fb12ba8
1 /*
2 * Copyright 2005 Jacek Caban
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 <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27 #include "urlmon.h"
28 #include "urlmon_main.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
34 typedef struct {
35 const IInternetProtocolVtbl *lpInternetProtocolVtbl;
36 const IInternetPriorityVtbl *lpInternetPriorityVtbl;
38 LONG priority;
40 LONG ref;
41 } HttpProtocol;
43 #define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
44 #define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
46 #define PROTOCOL_THIS(iface) DEFINE_THIS(HttpProtocol, InternetProtocol, iface)
48 static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
50 HttpProtocol *This = PROTOCOL_THIS(iface);
52 *ppv = NULL;
53 if(IsEqualGUID(&IID_IUnknown, riid)) {
54 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
55 *ppv = PROTOCOL(This);
56 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
57 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
58 *ppv = PROTOCOL(This);
59 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
60 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
61 *ppv = PROTOCOL(This);
62 }else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
63 TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
64 *ppv = PRIORITY(This);
67 if(*ppv) {
68 IInternetProtocol_AddRef(iface);
69 return S_OK;
72 WARN("not supported interface %s\n", debugstr_guid(riid));
73 return E_NOINTERFACE;
76 static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocol *iface)
78 HttpProtocol *This = PROTOCOL_THIS(iface);
79 LONG ref = InterlockedIncrement(&This->ref);
80 TRACE("(%p) ref=%d\n", This, ref);
81 return ref;
84 static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface)
86 HttpProtocol *This = PROTOCOL_THIS(iface);
87 LONG ref = InterlockedDecrement(&This->ref);
89 TRACE("(%p) ref=%d\n", This, ref);
91 if(!ref) {
92 HeapFree(GetProcessHeap(), 0, This);
94 URLMON_UnlockModule();
97 return ref;
100 static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
101 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
102 DWORD grfPI, DWORD dwReserved)
104 HttpProtocol *This = PROTOCOL_THIS(iface);
105 FIXME("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
106 pOIBindInfo, grfPI, dwReserved);
107 return E_NOTIMPL;
110 static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
112 HttpProtocol *This = PROTOCOL_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, pProtocolData);
114 return E_NOTIMPL;
117 static HRESULT WINAPI HttpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
118 DWORD dwOptions)
120 HttpProtocol *This = PROTOCOL_THIS(iface);
121 FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
122 return E_NOTIMPL;
125 static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
127 HttpProtocol *This = PROTOCOL_THIS(iface);
128 FIXME("(%p)->(%08x)\n", This, dwOptions);
129 return E_NOTIMPL;
132 static HRESULT WINAPI HttpProtocol_Suspend(IInternetProtocol *iface)
134 HttpProtocol *This = PROTOCOL_THIS(iface);
135 FIXME("(%p)\n", This);
136 return E_NOTIMPL;
139 static HRESULT WINAPI HttpProtocol_Resume(IInternetProtocol *iface)
141 HttpProtocol *This = PROTOCOL_THIS(iface);
142 FIXME("(%p)\n", This);
143 return E_NOTIMPL;
146 static HRESULT WINAPI HttpProtocol_Read(IInternetProtocol *iface, void *pv,
147 ULONG cb, ULONG *pcbRead)
149 HttpProtocol *This = PROTOCOL_THIS(iface);
150 FIXME("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
151 return E_NOTIMPL;
154 static HRESULT WINAPI HttpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
155 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
157 HttpProtocol *This = PROTOCOL_THIS(iface);
158 FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
159 return E_NOTIMPL;
162 static HRESULT WINAPI HttpProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
164 HttpProtocol *This = PROTOCOL_THIS(iface);
165 FIXME("(%p)->(%08x)\n", This, dwOptions);
166 return E_NOTIMPL;
169 static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocol *iface)
171 HttpProtocol *This = PROTOCOL_THIS(iface);
172 FIXME("(%p)\n", This);
173 return E_NOTIMPL;
176 #undef PROTOCOL_THIS
178 #define PRIORITY_THIS(iface) DEFINE_THIS(HttpProtocol, InternetPriority, iface)
180 static HRESULT WINAPI HttpPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
182 HttpProtocol *This = PRIORITY_THIS(iface);
183 return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
186 static ULONG WINAPI HttpPriority_AddRef(IInternetPriority *iface)
188 HttpProtocol *This = PRIORITY_THIS(iface);
189 return IInternetProtocol_AddRef(PROTOCOL(This));
192 static ULONG WINAPI HttpPriority_Release(IInternetPriority *iface)
194 HttpProtocol *This = PRIORITY_THIS(iface);
195 return IInternetProtocol_Release(PROTOCOL(This));
198 static HRESULT WINAPI HttpPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
200 HttpProtocol *This = PRIORITY_THIS(iface);
202 TRACE("(%p)->(%d)\n", This, nPriority);
204 This->priority = nPriority;
205 return S_OK;
208 static HRESULT WINAPI HttpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
210 HttpProtocol *This = PRIORITY_THIS(iface);
212 TRACE("(%p)->(%p)\n", This, pnPriority);
214 *pnPriority = This->priority;
215 return S_OK;
218 #undef PRIORITY_THIS
220 static const IInternetPriorityVtbl HttpPriorityVtbl = {
221 HttpPriority_QueryInterface,
222 HttpPriority_AddRef,
223 HttpPriority_Release,
224 HttpPriority_SetPriority,
225 HttpPriority_GetPriority
228 static const IInternetProtocolVtbl HttpProtocolVtbl = {
229 HttpProtocol_QueryInterface,
230 HttpProtocol_AddRef,
231 HttpProtocol_Release,
232 HttpProtocol_Start,
233 HttpProtocol_Continue,
234 HttpProtocol_Abort,
235 HttpProtocol_Terminate,
236 HttpProtocol_Suspend,
237 HttpProtocol_Resume,
238 HttpProtocol_Read,
239 HttpProtocol_Seek,
240 HttpProtocol_LockRequest,
241 HttpProtocol_UnlockRequest
244 HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
246 HttpProtocol *ret;
248 TRACE("(%p %p)\n", pUnkOuter, ppobj);
250 URLMON_LockModule();
252 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HttpProtocol));
254 ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
255 ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
257 ret->ref = 1;
259 ret->priority = 0;
261 *ppobj = PROTOCOL(ret);
263 return S_OK;