wininet: Use stored status code in HTTP_HttpEndRequestW.
[wine] / dlls / dpnet / address.c
1 /* 
2  * DirectPlay8 Address
3  * 
4  * Copyright 2004 Raphael Junqueira
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25
26 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "objbase.h"
32 #include "wine/debug.h"
33
34 #include "dplay8.h"
35 #include "dpnet_private.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
38
39 static inline IDirectPlay8AddressImpl *impl_from_IDirectPlay8Address(IDirectPlay8Address *iface)
40 {
41     return CONTAINING_RECORD(iface, IDirectPlay8AddressImpl, IDirectPlay8Address_iface);
42 }
43
44 /* IDirectPlay8Address IUnknown parts follow: */
45 static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(IDirectPlay8Address *iface,
46         REFIID riid, void **ppv)
47 {
48     if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
49         IUnknown_AddRef(iface);
50         *ppv = iface;
51         return DPN_OK;
52     }
53
54     WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
55     return E_NOINTERFACE;
56 }
57
58 static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(IDirectPlay8Address *iface)
59 {
60     IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
61     ULONG refCount = InterlockedIncrement(&This->ref);
62
63     TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
64
65     return refCount;
66 }
67
68 static ULONG WINAPI IDirectPlay8AddressImpl_Release(IDirectPlay8Address *iface)
69 {
70     IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
71     ULONG refCount = InterlockedDecrement(&This->ref);
72
73     TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
74
75     if (!refCount) {
76         HeapFree(GetProcessHeap(), 0, This);
77     }
78     return refCount;
79 }
80
81 /* returns name of given GUID */
82 static const char *debugstr_SP(const GUID *id) {
83   static const guid_info guids[] = {
84     /* CLSIDs */
85     GE(CLSID_DP8SP_IPX),
86     GE(CLSID_DP8SP_TCPIP),
87     GE(CLSID_DP8SP_SERIAL),
88     GE(CLSID_DP8SP_MODEM)
89   };
90   unsigned int i;
91
92   if (!id) return "(null)";
93
94   for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
95     if (IsEqualGUID(id, guids[i].guid))
96       return guids[i].name;
97   }
98   /* if we didn't find it, act like standard debugstr_guid */
99   return debugstr_guid(id);
100 }
101
102 /* IDirectPlay8Address Interface follow: */
103
104 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(IDirectPlay8Address *iface,
105         WCHAR *pwszSourceURL)
106 {
107   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
108   TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
109   return DPN_OK; 
110 }
111
112 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(IDirectPlay8Address *iface,
113        CHAR *pszSourceURL)
114 {
115   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
116   TRACE("(%p, %s): stub\n", This, pszSourceURL);
117   return DPN_OK; 
118 }
119
120 static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *iface,
121         IDirectPlay8Address **ppdpaNewAddress)
122 {
123   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
124   TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
125   return DPN_OK; 
126 }
127
128 static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address *iface,
129         IDirectPlay8Address *pdpaAddress)
130 {
131   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
132   TRACE("(%p, %p): stub\n", This, pdpaAddress);
133   return DPN_OK; 
134 }
135
136 static HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(IDirectPlay8Address *iface,
137         IDirectPlay8Address *pdpaAddress)
138 {
139   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
140   TRACE("(%p, %p): stub\n", This, pdpaAddress);
141   return DPN_OK; 
142 }
143
144 static HRESULT WINAPI IDirectPlay8AddressImpl_Clear(IDirectPlay8Address *iface)
145 {
146   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
147   TRACE("(%p): stub\n", This);
148   return DPN_OK; 
149 }
150
151 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(IDirectPlay8Address *iface, WCHAR *pwszURL,
152         DWORD *pdwNumChars)
153 {
154   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
155   TRACE("(%p): stub\n", This);
156   return DPN_OK; 
157 }
158
159 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(IDirectPlay8Address *iface, CHAR *pszURL,
160         DWORD *pdwNumChars)
161 {
162   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
163   TRACE("(%p): stub\n", This);
164   return DPN_OK; 
165 }
166
167 static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(IDirectPlay8Address *iface, GUID *pguidSP)
168 {
169   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
170
171   TRACE("(%p, %p)\n", iface, pguidSP);
172
173   *pguidSP = This->SP_guid;
174   return DPN_OK; 
175 }
176
177 static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address *iface,
178         void *pvUserData, DWORD *pdwBufferSize)
179 {
180   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
181   TRACE("(%p): stub\n", This);
182   return DPN_OK; 
183 }
184
185 static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(IDirectPlay8Address *iface,
186         const GUID *const pguidSP)
187 {
188   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
189
190   TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
191
192   This->SP_guid = *pguidSP;
193   return DPN_OK; 
194 }
195
196 static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address *iface,
197         const void *const pvUserData, const DWORD dwDataSize)
198 {
199   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
200   TRACE("(%p): stub\n", This);
201   return DPN_OK; 
202 }
203
204 static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Address *iface,
205         DWORD *pdwNumComponents)
206 {
207   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
208   TRACE("(%p): stub\n", This);
209   return DPN_OK; 
210 }
211
212 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address *iface,
213         const WCHAR *const pwszName, void *pvBuffer, DWORD *pdwBufferSize, DWORD *pdwDataType)
214 {
215   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
216   TRACE("(%p): stub\n", This);
217   return DPN_OK; 
218 }
219
220 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Address *iface,
221         const DWORD dwComponentID, WCHAR *pwszName, DWORD *pdwNameLen, void *pvBuffer,
222         DWORD *pdwBufferSize, DWORD *pdwDataType)
223 {
224   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
225   TRACE("(%p): stub\n", This);
226   return DPN_OK; 
227 }
228
229 static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *iface,
230         const WCHAR *const pwszName, const void* const lpvData, const DWORD dwDataSize,
231         const DWORD dwDataType)
232 {
233   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
234   TRACE("(%p, %s, %p, %u, %x): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
235   
236   if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
237   switch (dwDataType) {
238   case DPNA_DATATYPE_DWORD:
239     if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
240     TRACE("(%p, %u): DWORD Type -> %u\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
241     break;
242   case DPNA_DATATYPE_GUID:
243     if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
244     TRACE("(%p, %u): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid(lpvData));
245     break;
246   case DPNA_DATATYPE_STRING:
247     TRACE("(%p, %u): STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
248     break;
249   case DPNA_DATATYPE_BINARY:
250     TRACE("(%p, %u): BINARY Type\n", lpvData, dwDataSize);
251     break;
252   }
253   
254   return DPN_OK; 
255 }
256
257 static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(IDirectPlay8Address *iface, GUID *pDevGuid) {
258   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
259   TRACE("(%p): stub\n", This);
260   return DPN_OK; 
261 }
262
263 static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(IDirectPlay8Address *iface,
264         const GUID *const devGuid)
265 {
266   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
267   TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
268   return DPN_OK; 
269 }
270
271 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(IDirectPlay8Address *iface,
272         void *pvAddress, DWORD dwDataSize)
273 {
274   IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
275   TRACE("(%p): stub\n", This);
276   return DPN_OK; 
277 }
278
279 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
280 {
281     IDirectPlay8AddressImpl_QueryInterface,
282     IDirectPlay8AddressImpl_AddRef,
283     IDirectPlay8AddressImpl_Release,
284     IDirectPlay8AddressImpl_BuildFromURLW,
285     IDirectPlay8AddressImpl_BuildFromURLA,
286     IDirectPlay8AddressImpl_Duplicate,
287     IDirectPlay8AddressImpl_SetEqual,
288     IDirectPlay8AddressImpl_IsEqual,
289     IDirectPlay8AddressImpl_Clear,
290     IDirectPlay8AddressImpl_GetURLW,
291     IDirectPlay8AddressImpl_GetURLA,
292     IDirectPlay8AddressImpl_GetSP,
293     IDirectPlay8AddressImpl_GetUserData,
294     IDirectPlay8AddressImpl_SetSP,
295     IDirectPlay8AddressImpl_SetUserData,
296     IDirectPlay8AddressImpl_GetNumComponents,
297     IDirectPlay8AddressImpl_GetComponentByName,
298     IDirectPlay8AddressImpl_GetComponentByIndex,
299     IDirectPlay8AddressImpl_AddComponent,
300     IDirectPlay8AddressImpl_GetDevice,
301     IDirectPlay8AddressImpl_SetDevice,
302     IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
303 };
304
305 HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
306   IDirectPlay8AddressImpl* client;
307
308   TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
309   
310   client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
311   if (NULL == client) {
312     *ppobj = NULL;
313     return E_OUTOFMEMORY;
314   }
315   client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl;
316   client->ref = 0; /* will be inited with QueryInterface */
317   return IDirectPlay8AddressImpl_QueryInterface (&client->IDirectPlay8Address_iface, riid, ppobj);
318 }