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