Added http and ftp protocol stub implementation.
[wine] / dlls / urlmon / ftp.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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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     LONG ref;
37 } FtpProtocol;
38
39 #define PROTOCOL_THIS(iface) DEFINE_THIS(FtpProtocol, InternetProtocol, iface)
40
41 #define PROTOCOL(x)  ((IInternetProtocol*)  &(x)->lpInternetProtocolVtbl)
42
43 static HRESULT WINAPI FtpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
44 {
45     FtpProtocol *This = PROTOCOL_THIS(iface);
46
47     *ppv = NULL;
48     if(IsEqualGUID(&IID_IUnknown, riid)) {
49         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
50         *ppv = PROTOCOL(This);
51     }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
52         TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
53         *ppv = PROTOCOL(This);
54     }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
55         TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
56         *ppv = PROTOCOL(This);
57     }
58
59     if(*ppv) {
60         IInternetProtocol_AddRef(iface);
61         return S_OK;
62     }
63
64     WARN("not supported interface %s\n", debugstr_guid(riid));
65     return E_NOINTERFACE;
66 }
67
68 static ULONG WINAPI FtpProtocol_AddRef(IInternetProtocol *iface)
69 {
70     FtpProtocol *This = PROTOCOL_THIS(iface);
71     LONG ref = InterlockedIncrement(&This->ref);
72     TRACE("(%p) ref=%ld\n", This, ref);
73     return ref;
74 }
75
76 static ULONG WINAPI FtpProtocol_Release(IInternetProtocol *iface)
77 {
78     FtpProtocol *This = PROTOCOL_THIS(iface);
79     LONG ref = InterlockedDecrement(&This->ref);
80
81     TRACE("(%p) ref=%ld\n", This, ref);
82
83     if(!ref) {
84         HeapFree(GetProcessHeap(), 0, This);
85
86         URLMON_UnlockModule();
87     }
88
89     return ref;
90 }
91
92 static HRESULT WINAPI FtpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
93         IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
94         DWORD grfPI, DWORD dwReserved)
95 {
96     FtpProtocol *This = PROTOCOL_THIS(iface);
97     FIXME("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
98             pOIBindInfo, grfPI, dwReserved);
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI FtpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
103 {
104     FtpProtocol *This = PROTOCOL_THIS(iface);
105     FIXME("(%p)->(%p)\n", This, pProtocolData);
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI FtpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
110         DWORD dwOptions)
111 {
112     FtpProtocol *This = PROTOCOL_THIS(iface);
113     FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
114     return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI FtpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
118 {
119     FtpProtocol *This = PROTOCOL_THIS(iface);
120     FIXME("(%p)->(%08lx)\n", This, dwOptions);
121     return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI FtpProtocol_Suspend(IInternetProtocol *iface)
125 {
126     FtpProtocol *This = PROTOCOL_THIS(iface);
127     FIXME("(%p)\n", This);
128     return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI FtpProtocol_Resume(IInternetProtocol *iface)
132 {
133     FtpProtocol *This = PROTOCOL_THIS(iface);
134     FIXME("(%p)\n", This);
135     return E_NOTIMPL;
136 }
137
138 static HRESULT WINAPI FtpProtocol_Read(IInternetProtocol *iface, void *pv,
139         ULONG cb, ULONG *pcbRead)
140 {
141     FtpProtocol *This = PROTOCOL_THIS(iface);
142     FIXME("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI FtpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
147         DWORD dwOrgin, ULARGE_INTEGER *plibNewPosition)
148 {
149     FtpProtocol *This = PROTOCOL_THIS(iface);
150     FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrgin, plibNewPosition);
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI FtpProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
155 {
156     FtpProtocol *This = PROTOCOL_THIS(iface);
157     FIXME("(%p)->(%08lx)\n", This, dwOptions);
158     return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI FtpProtocol_UnlockRequest(IInternetProtocol *iface)
162 {
163     FtpProtocol *This = PROTOCOL_THIS(iface);
164     FIXME("(%p)\n", This);
165     return E_NOTIMPL;
166 }
167
168 #undef PROTOCOL_THIS
169
170 static const IInternetProtocolVtbl FtpProtocolVtbl = {
171     FtpProtocol_QueryInterface,
172     FtpProtocol_AddRef,
173     FtpProtocol_Release,
174     FtpProtocol_Start,
175     FtpProtocol_Continue,
176     FtpProtocol_Abort,
177     FtpProtocol_Terminate,
178     FtpProtocol_Suspend,
179     FtpProtocol_Resume,
180     FtpProtocol_Read,
181     FtpProtocol_Seek,
182     FtpProtocol_LockRequest,
183     FtpProtocol_UnlockRequest
184 };
185
186 HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
187 {
188     FtpProtocol *ret;
189
190     TRACE("(%p %p)\n", pUnkOuter, ppobj);
191
192     URLMON_LockModule();
193
194     ret = HeapAlloc(GetProcessHeap(), 0, sizeof(FtpProtocol));
195
196     ret->lpInternetProtocolVtbl = &FtpProtocolVtbl;
197     ret->ref = 1;
198
199     *ppobj = PROTOCOL(ret);
200     
201     return S_OK;
202 }