urlmon: Added gopher protocol handler stub implementation.
[wine] / dlls / urlmon / gopher.c
1 /*
2  * Copyright 2009 Jacek Caban for CodeWeavers
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 "urlmon_main.h"
20 #include "wine/debug.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
23
24 typedef struct {
25     const IInternetProtocolVtbl  *lpInternetProtocolVtbl;
26
27     LONG ref;
28 } GopherProtocol;
29
30 #define PROTOCOL(x)  ((IInternetProtocol*)  &(x)->lpInternetProtocolVtbl)
31
32 #define PROTOCOL_THIS(iface) DEFINE_THIS(GopherProtocol, InternetProtocol, iface)
33
34 static HRESULT WINAPI GopherProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
35 {
36     GopherProtocol *This = PROTOCOL_THIS(iface);
37
38     *ppv = NULL;
39     if(IsEqualGUID(&IID_IUnknown, riid)) {
40         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
41         *ppv = PROTOCOL(This);
42     }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
43         TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
44         *ppv = PROTOCOL(This);
45     }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
46         TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
47         *ppv = PROTOCOL(This);
48     }
49
50     if(*ppv) {
51         IInternetProtocol_AddRef(iface);
52         return S_OK;
53     }
54
55     WARN("not supported interface %s\n", debugstr_guid(riid));
56     return E_NOINTERFACE;
57 }
58
59 static ULONG WINAPI GopherProtocol_AddRef(IInternetProtocol *iface)
60 {
61     GopherProtocol *This = PROTOCOL_THIS(iface);
62     LONG ref = InterlockedIncrement(&This->ref);
63     TRACE("(%p) ref=%d\n", This, ref);
64     return ref;
65 }
66
67 static ULONG WINAPI GopherProtocol_Release(IInternetProtocol *iface)
68 {
69     GopherProtocol *This = PROTOCOL_THIS(iface);
70     LONG ref = InterlockedDecrement(&This->ref);
71
72     TRACE("(%p) ref=%d\n", This, ref);
73
74     if(!ref) {
75         heap_free(This);
76
77         URLMON_UnlockModule();
78     }
79
80     return ref;
81 }
82
83 static HRESULT WINAPI GopherProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
84         IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
85         DWORD grfPI, DWORD dwReserved)
86 {
87     GopherProtocol *This = PROTOCOL_THIS(iface);
88     FIXME("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
89           pOIBindInfo, grfPI, dwReserved);
90     return E_NOTIMPL;
91 }
92
93 static HRESULT WINAPI GopherProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
94 {
95     GopherProtocol *This = PROTOCOL_THIS(iface);
96     FIXME("(%p)->(%p)\n", This, pProtocolData);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI GopherProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
101         DWORD dwOptions)
102 {
103     GopherProtocol *This = PROTOCOL_THIS(iface);
104     FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI GopherProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
109 {
110     GopherProtocol *This = PROTOCOL_THIS(iface);
111     FIXME("(%p)->(%08x)\n", This, dwOptions);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI GopherProtocol_Suspend(IInternetProtocol *iface)
116 {
117     GopherProtocol *This = PROTOCOL_THIS(iface);
118     FIXME("(%p)\n", This);
119     return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI GopherProtocol_Resume(IInternetProtocol *iface)
123 {
124     GopherProtocol *This = PROTOCOL_THIS(iface);
125     FIXME("(%p)\n", This);
126     return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI GopherProtocol_Read(IInternetProtocol *iface, void *pv,
130         ULONG cb, ULONG *pcbRead)
131 {
132     GopherProtocol *This = PROTOCOL_THIS(iface);
133     FIXME("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
134     return E_NOTIMPL;
135 }
136
137 static HRESULT WINAPI GopherProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
138         DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
139 {
140     GopherProtocol *This = PROTOCOL_THIS(iface);
141     FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI GopherProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
146 {
147     GopherProtocol *This = PROTOCOL_THIS(iface);
148     FIXME("(%p)->(%08x)\n", This, dwOptions);
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI GopherProtocol_UnlockRequest(IInternetProtocol *iface)
153 {
154     GopherProtocol *This = PROTOCOL_THIS(iface);
155     FIXME("(%p)\n", This);
156     return E_NOTIMPL;
157 }
158
159 #undef PROTOCOL_THIS
160
161 static const IInternetProtocolVtbl GopherProtocolVtbl = {
162     GopherProtocol_QueryInterface,
163     GopherProtocol_AddRef,
164     GopherProtocol_Release,
165     GopherProtocol_Start,
166     GopherProtocol_Continue,
167     GopherProtocol_Abort,
168     GopherProtocol_Terminate,
169     GopherProtocol_Suspend,
170     GopherProtocol_Resume,
171     GopherProtocol_Read,
172     GopherProtocol_Seek,
173     GopherProtocol_LockRequest,
174     GopherProtocol_UnlockRequest
175 };
176
177 HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
178 {
179     GopherProtocol *ret;
180
181     TRACE("(%p %p)\n", pUnkOuter, ppobj);
182
183     URLMON_LockModule();
184
185     ret = heap_alloc_zero(sizeof(GopherProtocol));
186
187     ret->lpInternetProtocolVtbl = &GopherProtocolVtbl;
188     ret->ref = 1;
189
190     *ppobj = PROTOCOL(ret);
191
192     return S_OK;
193 }