comctl32: toolbar: Make sure all TBUTTON_INFO fields are initialized when a button...
[wine] / dlls / dpnet / peer.c
1 /* 
2  * DirectPlay8 Peer
3  * 
4  * Copyright 2004 Raphael Junqueira
5  * Copyright 2008 Alexander N. Sørnes <alex@thehandofagony.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  *
21  */
22
23 #include "config.h"
24
25 #include <stdarg.h>
26
27 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "objbase.h"
33 #include "wine/debug.h"
34
35 #include "dplay8.h"
36 #include "dpnet_private.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
39
40 /* IUnknown interface follows */
41
42 static HRESULT WINAPI IDirectPlay8PeerImpl_QueryInterface(PDIRECTPLAY8PEER iface, REFIID riid, LPVOID* ppobj)
43 {
44     IDirectPlay8PeerImpl* This = (IDirectPlay8PeerImpl*)iface;
45
46     if(IsEqualGUID(riid, &IID_IUnknown) ||
47        IsEqualGUID(riid, &IID_IDirectPlay8Peer))
48     {
49         IUnknown_AddRef(iface);
50         *ppobj = This;
51         return DPN_OK;
52     }
53
54     WARN("(%p)->(%s,%p): not found\n", This, debugstr_guid(riid), ppobj);
55     return E_NOINTERFACE;
56 }
57
58 static ULONG WINAPI IDirectPlay8PeerImpl_AddRef(PDIRECTPLAY8PEER iface)
59 {
60     IDirectPlay8PeerImpl* This = (IDirectPlay8PeerImpl*)iface;
61     ULONG RefCount = InterlockedIncrement(&This->ref);
62
63     return RefCount;
64 }
65
66 static ULONG WINAPI IDirectPlay8PeerImpl_Release(PDIRECTPLAY8PEER iface)
67 {
68     IDirectPlay8PeerImpl* This = (IDirectPlay8PeerImpl*)iface;
69     ULONG RefCount = InterlockedDecrement(&This->ref);
70
71     if(!RefCount)
72         HeapFree(GetProcessHeap(), 0, This);
73
74     return RefCount;
75 }
76
77 /* IDirectPlay8Peer interface follows */
78
79 static HRESULT WINAPI IDirectPlay8PeerImpl_Initialize(PDIRECTPLAY8PEER iface, PVOID CONST pvUserContext, CONST PFNDPNMESSAGEHANDLER pfn, CONST DWORD dwFlags)
80 {
81     FIXME("(%p)->(%p,%p,%x): stub\n", iface, pvUserContext, pfn, dwFlags);
82
83     return DPNERR_GENERIC;
84 }
85
86 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumServiceProviders(PDIRECTPLAY8PEER iface, CONST GUID *CONST pguidServiceProvider, CONST GUID *CONST pguidApplication, DPN_SERVICE_PROVIDER_INFO *CONST pSPInfoBuffer, DWORD *CONST pcbEnumData, DWORD *CONST pcReturned, CONST DWORD dwFlags)
87 {
88     FIXME("(%p)->(%p,%p,%p,%p,%p,%x): stub\n", iface, pguidServiceProvider, pguidApplication, pSPInfoBuffer, pcbEnumData, pcReturned, dwFlags);
89     return DPNERR_GENERIC;
90 }
91
92 static HRESULT WINAPI IDirectPlay8PeerImpl_CancelAsyncOperation(PDIRECTPLAY8PEER iface,
93                                                                 CONST DPNHANDLE hAsyncHandle,
94                                                                 CONST DWORD dwFlags)
95 {
96     FIXME("(%p)->(%x,%x): stub\n", iface, hAsyncHandle, dwFlags);
97
98     return DPNERR_GENERIC;
99 }
100
101 static HRESULT WINAPI IDirectPlay8PeerImpl_Connect(PDIRECTPLAY8PEER iface,
102                                                    CONST DPN_APPLICATION_DESC* CONST pdnAppDesc,
103                                                    IDirectPlay8Address *CONST pHostAddr,
104                                                    IDirectPlay8Address *CONST pDeviceInfo,
105                                                    CONST DPN_SECURITY_DESC *CONST pdnSecurity,
106                                                    CONST DPN_SECURITY_CREDENTIALS *CONST pdnCredentials,
107                                                    CONST VOID *CONST pvUserConnectData,
108                                                    CONST DWORD dwUserConnectDataSize,
109                                                    VOID *CONST pvPlayerContext,
110                                                    VOID *CONST pvAsyncContext,
111                                                    DPNHANDLE *CONST phAsyncHandle,
112                                                    CONST DWORD dwFlags)
113 {
114     FIXME("(%p)->(%p,%p,%p,%p,%p,%p,%x,%p,%p,%p,%x): stub\n", iface, pdnAppDesc, pHostAddr, pDeviceInfo, pdnSecurity, pdnCredentials, pvUserConnectData, dwUserConnectDataSize, pvPlayerContext, pvAsyncContext, phAsyncHandle, dwFlags);
115
116     return DPNERR_GENERIC;
117 }
118
119 static HRESULT WINAPI IDirectPlay8PeerImpl_SendTo(PDIRECTPLAY8PEER iface,
120                                                   CONST DPNID dpnId,
121                                                   CONST DPN_BUFFER_DESC *pBufferDesc,
122                                                   CONST DWORD cBufferDesc,
123                                                   CONST DWORD dwTimeOut,
124                                                   VOID *CONST pvAsyncContext,
125                                                   DPNHANDLE *CONST phAsyncHandle,
126                                                   CONST DWORD dwFlags)
127 {
128     FIXME("(%p)->(%x,%p,%x,%x,%p,%p,%x): stub\n", iface, dpnId, pBufferDesc, cBufferDesc, dwTimeOut, pvAsyncContext, phAsyncHandle, dwFlags);
129
130     return DPNERR_GENERIC;
131 }
132
133 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSendQueueInfo(PDIRECTPLAY8PEER iface,
134                                                             CONST DPNID dpnid,
135                                                             DWORD *CONST pdwNumMsgs,
136                                                             DWORD *CONST pdwNumBytes,
137                                                             CONST DWORD dwFlags)
138 {
139     FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdwNumMsgs, pdwNumBytes, dwFlags);
140
141     return DPNERR_GENERIC;
142 }
143
144 static HRESULT WINAPI IDirectPlay8PeerImpl_Host(PDIRECTPLAY8PEER iface,
145                                                 CONST DPN_APPLICATION_DESC *CONST pdnAppDesc,
146                                                 IDirectPlay8Address **CONST prgpDeviceInfo,
147                                                 CONST DWORD cDeviceInfo,
148                                                 CONST DPN_SECURITY_DESC *CONST pdpSecurity,
149                                                 CONST DPN_SECURITY_CREDENTIALS *CONST pdpCredentials,
150                                                 VOID *CONST pvPlayerContext,
151                                                 CONST DWORD dwFlags)
152 {
153     FIXME("(%p)->(%p,%p,%x,%p,%p,%p,%x): stub\n", iface, pdnAppDesc, prgpDeviceInfo, cDeviceInfo, pdpSecurity, pdpCredentials, pvPlayerContext, dwFlags);
154
155     return DPNERR_GENERIC;
156 }
157
158 static HRESULT WINAPI IDirectPlay8PeerImpl_GetApplicationDesc(PDIRECTPLAY8PEER iface,
159                                                               DPN_APPLICATION_DESC *CONST pAppDescBuffer,
160                                                               DWORD *CONST pcbDataSize,
161                                                               CONST DWORD dwFlags)
162 {
163     FIXME("(%p)->(%p,%p,%x): stub\n", iface, pAppDescBuffer, pcbDataSize, dwFlags);
164
165     return DPNERR_GENERIC;
166 }
167
168 static HRESULT WINAPI IDirectPlay8PeerImpl_SetApplicationDesc(PDIRECTPLAY8PEER iface,
169                                                               CONST DPN_APPLICATION_DESC *CONST pad,
170                                                               CONST DWORD dwFlags)
171 {
172     FIXME("(%p)->(%p,%x): stub\n", iface, pad, dwFlags);
173
174     return DPNERR_GENERIC;
175 }
176
177 static HRESULT WINAPI IDirectPlay8PeerImpl_CreateGroup(PDIRECTPLAY8PEER iface,
178                                                        CONST DPN_GROUP_INFO *CONST pdpnGroupInfo,
179                                                        VOID *CONST pvGroupContext,
180                                                        VOID *CONST pvAsyncContext,
181                                                        DPNHANDLE *CONST phAsyncHandle,
182                                                        CONST DWORD dwFlags)
183 {
184     FIXME("(%p)->(%p,%p,%p,%p,%x): stub\n", iface, pdpnGroupInfo, pvGroupContext, pvAsyncContext, phAsyncHandle, dwFlags);
185
186     return DPNERR_GENERIC;
187 }
188
189 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyGroup(PDIRECTPLAY8PEER iface,
190                                                         CONST DPNID idGroup,
191                                                         PVOID CONST pvAsyncContext,
192                                                         DPNHANDLE *CONST phAsyncHandle,
193                                                         CONST DWORD dwFlags)
194 {
195     FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, idGroup, pvAsyncContext, phAsyncHandle, dwFlags);
196
197     return DPNERR_GENERIC;
198 }
199
200 static HRESULT WINAPI IDirectPlay8PeerImpl_AddPlayerToGroup(PDIRECTPLAY8PEER iface,
201                                                             CONST DPNID idGroup,
202                                                             CONST DPNID idClient,
203                                                             PVOID CONST pvAsyncContext,
204                                                             DPNHANDLE *CONST phAsyncHandle,
205                                                             CONST DWORD dwFlags)
206 {
207     FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
208
209     return DPNERR_GENERIC;
210 }
211
212 static HRESULT WINAPI IDirectPlay8PeerImpl_RemovePlayerFromGroup(PDIRECTPLAY8PEER iface,
213                                                                  CONST DPNID idGroup,
214                                                                  CONST DPNID idClient,
215                                                                  PVOID CONST pvAsyncContext,
216                                                                  DPNHANDLE *CONST phAsyncHandle,
217                                                                  CONST DWORD dwFlags)
218 {
219     FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
220
221     return DPNERR_GENERIC;
222 }
223
224 static HRESULT WINAPI IDirectPlay8PeerImpl_SetGroupInfo(PDIRECTPLAY8PEER iface,
225                                                         CONST DPNID dpnid,
226                                                         DPN_GROUP_INFO *CONST pdpnGroupInfo,
227                                                         PVOID CONST pvAsyncContext,
228                                                         DPNHANDLE *CONST phAsyncHandle,
229                                                         CONST DWORD dwFlags)
230 {
231     FIXME("(%p)->(%x,%p,%p,%p,%x): stub\n", iface, dpnid, pdpnGroupInfo, pvAsyncContext, phAsyncHandle, dwFlags);
232
233     return DPNERR_GENERIC;
234 }
235
236 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupInfo(PDIRECTPLAY8PEER iface,
237                                                         CONST DPNID dpnid,
238                                                         DPN_GROUP_INFO *CONST pdpnGroupInfo,
239                                                         DWORD *CONST pdwSize,
240                                                         CONST DWORD dwFlags)
241 {
242     FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdpnGroupInfo, pdwSize, dwFlags);
243
244     return DPNERR_GENERIC;
245 }
246
247 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumPlayersAndGroups(PDIRECTPLAY8PEER iface,
248                                                                 DPNID *CONST prgdpnid,
249                                                                 DWORD *CONST pcdpnid,
250                                                                 CONST DWORD dwFlags)
251 {
252     FIXME("(%p)->(%p,%p,%x): stub\n", iface, prgdpnid, pcdpnid, dwFlags);
253
254     return DPNERR_GENERIC;
255 }
256
257 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumGroupMembers(PDIRECTPLAY8PEER iface,
258                                                             CONST DPNID dpnid,
259                                                             DPNID *CONST prgdpnid,
260                                                             DWORD *CONST pcdpnid,
261                                                             CONST DWORD dwFlags)
262 {
263     FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, prgdpnid, pcdpnid, dwFlags);
264
265     return DPNERR_GENERIC;
266 }
267
268 static HRESULT WINAPI IDirectPlay8PeerImpl_SetPeerInfo(PDIRECTPLAY8PEER iface,
269                                                        CONST DPN_PLAYER_INFO *CONST pdpnPlayerInfo,
270                                                        PVOID CONST pvAsyncContext,
271                                                        DPNHANDLE *CONST phAsyncHandle,
272                                                        CONST DWORD dwFlags)
273 {
274     FIXME("(%p)->(%p,%p,%p,%x): stub\n", iface, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
275
276     return DPNERR_GENERIC;
277 }
278
279 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerInfo(PDIRECTPLAY8PEER iface,
280                                                        CONST DPNID dpnid,
281                                                        DPN_PLAYER_INFO *CONST pdpnPlayerInfo,
282                                                        DWORD *CONST pdwSize,
283                                                        CONST DWORD dwFlags)
284 {
285     FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdpnPlayerInfo, pdwSize, dwFlags);
286
287     return DPNERR_GENERIC;
288 }
289
290 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerAddress(PDIRECTPLAY8PEER iface,
291                                                           CONST DPNID dpnid,
292                                                           IDirectPlay8Address **CONST pAddress,
293                                                           CONST DWORD dwFlags)
294 {
295     FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, pAddress, dwFlags);
296
297     return DPNERR_GENERIC;
298 }
299
300 static HRESULT WINAPI IDirectPlay8PeerImpl_GetLocalHostAddresses(PDIRECTPLAY8PEER iface,
301                                                                  IDirectPlay8Address **CONST prgpAddress,
302                                                                  DWORD *CONST pcAddress,
303                                                                  CONST DWORD dwFlags)
304 {
305     FIXME("(%p)->(%p,%p,%x): stub\n", iface, prgpAddress, pcAddress, dwFlags);
306
307     return DPNERR_GENERIC;
308 }
309
310 static HRESULT WINAPI IDirectPlay8PeerImpl_Close(PDIRECTPLAY8PEER iface,
311                                                  CONST DWORD dwFlags)
312 {
313     FIXME("(%p)->(%x): stub\n", iface, dwFlags);
314
315     return DPN_OK;
316 }
317
318 static const IDirectPlay8PeerVtbl DirectPlay8Peer_Vtbl =
319 {
320     IDirectPlay8PeerImpl_QueryInterface,
321     IDirectPlay8PeerImpl_AddRef,
322     IDirectPlay8PeerImpl_Release,
323     IDirectPlay8PeerImpl_Initialize,
324     IDirectPlay8PeerImpl_EnumServiceProviders,
325     IDirectPlay8PeerImpl_CancelAsyncOperation,
326     IDirectPlay8PeerImpl_Connect,
327     IDirectPlay8PeerImpl_SendTo,
328     IDirectPlay8PeerImpl_GetSendQueueInfo,
329     IDirectPlay8PeerImpl_Host,
330     IDirectPlay8PeerImpl_GetApplicationDesc,
331     IDirectPlay8PeerImpl_SetApplicationDesc,
332     IDirectPlay8PeerImpl_CreateGroup,
333     IDirectPlay8PeerImpl_DestroyGroup,
334     IDirectPlay8PeerImpl_AddPlayerToGroup,
335     IDirectPlay8PeerImpl_RemovePlayerFromGroup,
336     IDirectPlay8PeerImpl_SetGroupInfo,
337     IDirectPlay8PeerImpl_GetGroupInfo,
338     IDirectPlay8PeerImpl_EnumPlayersAndGroups,
339     IDirectPlay8PeerImpl_EnumGroupMembers,
340     IDirectPlay8PeerImpl_SetPeerInfo,
341     IDirectPlay8PeerImpl_GetPeerInfo,
342     IDirectPlay8PeerImpl_GetPeerAddress,
343     IDirectPlay8PeerImpl_GetLocalHostAddresses,
344     IDirectPlay8PeerImpl_Close
345 };
346
347 HRESULT DPNET_CreateDirectPlay8Peer(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
348     IDirectPlay8PeerImpl* Client;
349     HRESULT Ret;
350
351     Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8PeerImpl));
352
353     if(Client == NULL)
354     {
355         *ppobj = NULL;
356         WARN("Not enough memory\n");
357         return E_OUTOFMEMORY;
358     }
359
360     Client->lpVtbl = &DirectPlay8Peer_Vtbl;
361     if((Ret = IDirectPlay8PeerImpl_QueryInterface((PDIRECTPLAY8PEER)Client, riid, ppobj)) != DPN_OK)
362         HeapFree(GetProcessHeap(), 0, Client);
363
364     return Ret;
365 }