msi: Make the version information of DllGetVersion same as in version resource.
[wine] / dlls / urlmon / http.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
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"
29
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
33
34 typedef struct {
35     const IInternetProtocolVtbl *lpInternetProtocolVtbl;
36     const IInternetPriorityVtbl *lpInternetPriorityVtbl;
37
38     LONG priority;
39
40     LONG ref;
41 } HttpProtocol;
42
43 #define PROTOCOL(x)  ((IInternetProtocol*)  &(x)->lpInternetProtocolVtbl)
44 #define PRIORITY(x)  ((IInternetPriority*)  &(x)->lpInternetPriorityVtbl)
45
46 #define PROTOCOL_THIS(iface) DEFINE_THIS(HttpProtocol, InternetProtocol, iface)
47
48 static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
49 {
50     HttpProtocol *This = PROTOCOL_THIS(iface);
51
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);
65     }
66
67     if(*ppv) {
68         IInternetProtocol_AddRef(iface);
69         return S_OK;
70     }
71
72     WARN("not supported interface %s\n", debugstr_guid(riid));
73     return E_NOINTERFACE;
74 }
75
76 static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocol *iface)
77 {
78     HttpProtocol *This = PROTOCOL_THIS(iface);
79     LONG ref = InterlockedIncrement(&This->ref);
80     TRACE("(%p) ref=%ld\n", This, ref);
81     return ref;
82 }
83
84 static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface)
85 {
86     HttpProtocol *This = PROTOCOL_THIS(iface);
87     LONG ref = InterlockedDecrement(&This->ref);
88
89     TRACE("(%p) ref=%ld\n", This, ref);
90
91     if(!ref) {
92         HeapFree(GetProcessHeap(), 0, This);
93
94         URLMON_UnlockModule();
95     }
96
97     return ref;
98 }
99
100 static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
101         IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
102         DWORD grfPI, DWORD dwReserved)
103 {
104     HttpProtocol *This = PROTOCOL_THIS(iface);
105     FIXME("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
106             pOIBindInfo, grfPI, dwReserved);
107     return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
111 {
112     HttpProtocol *This = PROTOCOL_THIS(iface);
113     FIXME("(%p)->(%p)\n", This, pProtocolData);
114     return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI HttpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
118         DWORD dwOptions)
119 {
120     HttpProtocol *This = PROTOCOL_THIS(iface);
121     FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
122     return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
126 {
127     HttpProtocol *This = PROTOCOL_THIS(iface);
128     FIXME("(%p)->(%08lx)\n", This, dwOptions);
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI HttpProtocol_Suspend(IInternetProtocol *iface)
133 {
134     HttpProtocol *This = PROTOCOL_THIS(iface);
135     FIXME("(%p)\n", This);
136     return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI HttpProtocol_Resume(IInternetProtocol *iface)
140 {
141     HttpProtocol *This = PROTOCOL_THIS(iface);
142     FIXME("(%p)\n", This);
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI HttpProtocol_Read(IInternetProtocol *iface, void *pv,
147         ULONG cb, ULONG *pcbRead)
148 {
149     HttpProtocol *This = PROTOCOL_THIS(iface);
150     FIXME("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI HttpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
155         DWORD dwOrgin, ULARGE_INTEGER *plibNewPosition)
156 {
157     HttpProtocol *This = PROTOCOL_THIS(iface);
158     FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrgin, plibNewPosition);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI HttpProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
163 {
164     HttpProtocol *This = PROTOCOL_THIS(iface);
165     FIXME("(%p)->(%08lx)\n", This, dwOptions);
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocol *iface)
170 {
171     HttpProtocol *This = PROTOCOL_THIS(iface);
172     FIXME("(%p)\n", This);
173     return E_NOTIMPL;
174 }
175
176 #undef PROTOCOL_THIS
177
178 #define PRIORITY_THIS(iface) DEFINE_THIS(HttpProtocol, InternetPriority, iface)
179
180 static HRESULT WINAPI HttpPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
181 {
182     HttpProtocol *This = PRIORITY_THIS(iface);
183     return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
184 }
185
186 static ULONG WINAPI HttpPriority_AddRef(IInternetPriority *iface)
187 {
188     HttpProtocol *This = PRIORITY_THIS(iface);
189     return IInternetProtocol_AddRef(PROTOCOL(This));
190 }
191
192 static ULONG WINAPI HttpPriority_Release(IInternetPriority *iface)
193 {
194     HttpProtocol *This = PRIORITY_THIS(iface);
195     return IInternetProtocol_Release(PROTOCOL(This));
196 }
197
198 static HRESULT WINAPI HttpPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
199 {
200     HttpProtocol *This = PRIORITY_THIS(iface);
201
202     TRACE("(%p)->(%ld)\n", This, nPriority);
203
204     This->priority = nPriority;
205     return S_OK;
206 }
207
208 static HRESULT WINAPI HttpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
209 {
210     HttpProtocol *This = PRIORITY_THIS(iface);
211
212     TRACE("(%p)->(%p)\n", This, pnPriority);
213
214     *pnPriority = This->priority;
215     return S_OK;
216 }
217
218 #undef PRIORITY_THIS
219
220 static const IInternetPriorityVtbl HttpPriorityVtbl = {
221     HttpPriority_QueryInterface,
222     HttpPriority_AddRef,
223     HttpPriority_Release,
224     HttpPriority_SetPriority,
225     HttpPriority_GetPriority
226 };
227
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
242 };
243
244 HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
245 {
246     HttpProtocol *ret;
247
248     TRACE("(%p %p)\n", pUnkOuter, ppobj);
249
250     URLMON_LockModule();
251
252     ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HttpProtocol));
253
254     ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
255     ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
256
257     ret->ref = 1;
258
259     ret->priority = 0;
260
261     *ppobj = PROTOCOL(ret);
262     
263     return S_OK;
264 }