wined3d: Move material applying to the state table.
[wine] / dlls / dpnet / client.c
1 /* 
2  * DirectPlay8 Client
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 "winreg.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 /* IDirectPlay8Client IUnknown parts follow: */
41 static HRESULT WINAPI IDirectPlay8ClientImpl_QueryInterface(PDIRECTPLAY8CLIENT iface, REFIID riid, LPVOID *ppobj)
42 {
43     IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
44
45     if (IsEqualGUID(riid, &IID_IUnknown)
46         || IsEqualGUID(riid, &IID_IDirectPlay8Client)) {
47         IUnknown_AddRef(iface);
48         *ppobj = This;
49         return DPN_OK;
50     }
51
52     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
53     return E_NOINTERFACE;
54 }
55
56 static ULONG WINAPI IDirectPlay8ClientImpl_AddRef(PDIRECTPLAY8CLIENT iface) {
57     IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
58     ULONG refCount = InterlockedIncrement(&This->ref);
59
60     TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
61
62     return refCount;
63 }
64
65 static ULONG WINAPI IDirectPlay8ClientImpl_Release(PDIRECTPLAY8CLIENT iface) {
66     IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
67     ULONG refCount = InterlockedDecrement(&This->ref);
68
69     TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
70
71     if (!refCount) {
72         HeapFree(GetProcessHeap(), 0, This);
73     }
74     return refCount;
75 }
76
77 /* IDirectPlay8Client Interface follow: */
78
79 static HRESULT WINAPI IDirectPlay8ClientImpl_Initialize(PDIRECTPLAY8CLIENT iface,  PVOID CONST pvUserContext, CONST PFNDPNMESSAGEHANDLER pfn, CONST DWORD dwFlags) { 
80   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
81   FIXME("(%p):(%p,%p,%x): Stub\n", This, pvUserContext, pfn, dwFlags);
82   return DPN_OK; 
83 }
84
85 static HRESULT WINAPI IDirectPlay8ClientImpl_EnumServiceProviders(PDIRECTPLAY8CLIENT iface, 
86                                                            CONST GUID * CONST pguidServiceProvider, 
87                                                            CONST GUID * CONST pguidApplication, 
88                                                            DPN_SERVICE_PROVIDER_INFO * CONST pSPInfoBuffer, 
89                                                            PDWORD CONST pcbEnumData, 
90                                                            PDWORD CONST pcReturned, 
91                                                            CONST DWORD dwFlags) { 
92   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
93   FIXME("(%p):(%x): Stub\n", This, dwFlags);
94   return DPN_OK; 
95 }
96
97 static HRESULT WINAPI IDirectPlay8ClientImpl_EnumHosts(PDIRECTPLAY8CLIENT iface, 
98                                                 PDPN_APPLICATION_DESC CONST pApplicationDesc, 
99                                                 IDirectPlay8Address * CONST pAddrHost, 
100                                                 IDirectPlay8Address * CONST pDeviceInfo, 
101                                                 PVOID CONST pUserEnumData, CONST DWORD dwUserEnumDataSize, CONST DWORD dwEnumCount, 
102                                                 CONST DWORD dwRetryInterval, 
103                                                 CONST DWORD dwTimeOut, 
104                                                 PVOID CONST pvUserContext, 
105                                                 DPNHANDLE * CONST pAsyncHandle, 
106                                                 CONST DWORD dwFlags) { 
107   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
108   /*FIXME("(%p):(%p,%p,%p,%p,%lu,%lu,%lu,%lu): Stub\n", This, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount, dwRetryInterval, dwTimeOut);*/
109   FIXME("(%p):(%p,%p,%x): Stub\n", This, pvUserContext, pAsyncHandle, dwFlags);
110   return DPN_OK; 
111 }
112
113 static HRESULT WINAPI IDirectPlay8ClientImpl_CancelAsyncOperation(PDIRECTPLAY8CLIENT iface, CONST DPNHANDLE hAsyncHandle, CONST DWORD dwFlags) { 
114   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
115   FIXME("(%p):(%u,%x): Stub\n", This, hAsyncHandle, dwFlags);
116   return DPN_OK; 
117 }
118
119 static HRESULT WINAPI IDirectPlay8ClientImpl_Connect(PDIRECTPLAY8CLIENT iface, 
120                                               CONST DPN_APPLICATION_DESC * CONST pdnAppDesc,
121                                               IDirectPlay8Address * CONST pHostAddr,
122                                               IDirectPlay8Address * CONST pDeviceInfo, 
123                                               CONST DPN_SECURITY_DESC * CONST pdnSecurity, 
124                                               CONST DPN_SECURITY_CREDENTIALS * CONST pdnCredentials, 
125                                               CONST void * CONST pvUserConnectData, 
126                                               CONST DWORD dwUserConnectDataSize, 
127                                               void * CONST pvAsyncContext, 
128                                               DPNHANDLE * CONST phAsyncHandle, 
129                                               CONST DWORD dwFlags) { 
130   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
131   FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
132   return DPN_OK; 
133 }
134
135 static HRESULT WINAPI IDirectPlay8ClientImpl_Send(PDIRECTPLAY8CLIENT iface, 
136                                            CONST DPN_BUFFER_DESC * CONST prgBufferDesc, 
137                                            CONST DWORD cBufferDesc, 
138                                            CONST DWORD dwTimeOut, 
139                                            void * CONST pvAsyncContext, 
140                                            DPNHANDLE * CONST phAsyncHandle, 
141                                            CONST DWORD dwFlags) { 
142   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
143   FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
144   return DPN_OK; 
145 }
146
147 static HRESULT WINAPI IDirectPlay8ClientImpl_GetSendQueueInfo(PDIRECTPLAY8CLIENT iface, DWORD * CONST pdwNumMsgs, DWORD * CONST pdwNumBytes, CONST DWORD dwFlags) {
148   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
149   FIXME("(%p):(%x): Stub\n", This, dwFlags);
150   return DPN_OK; 
151 }
152
153 static HRESULT WINAPI IDirectPlay8ClientImpl_GetApplicationDesc(PDIRECTPLAY8CLIENT iface, DPN_APPLICATION_DESC * CONST pAppDescBuffer, DWORD * CONST pcbDataSize, CONST DWORD dwFlags) { 
154   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
155   FIXME("(%p):(%x): Stub\n", This, dwFlags);
156   return DPN_OK; 
157 }
158
159 static HRESULT WINAPI IDirectPlay8ClientImpl_SetClientInfo(PDIRECTPLAY8CLIENT iface, 
160                                                     CONST DPN_PLAYER_INFO * CONST pdpnPlayerInfo, 
161                                                     PVOID CONST pvAsyncContext, 
162                                                     DPNHANDLE * CONST phAsyncHandle, 
163                                                     CONST DWORD dwFlags) { 
164   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
165   FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
166   return DPN_OK; 
167 }
168
169 static HRESULT WINAPI IDirectPlay8ClientImpl_GetServerInfo(PDIRECTPLAY8CLIENT iface, DPN_PLAYER_INFO * CONST pdpnPlayerInfo, DWORD * CONST pdwSize, CONST DWORD dwFlags) { 
170   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
171   FIXME("(%p):(%x): Stub\n", This, dwFlags);
172   return DPN_OK; 
173 }
174
175 static HRESULT WINAPI IDirectPlay8ClientImpl_GetServerAddress(PDIRECTPLAY8CLIENT iface, IDirectPlay8Address ** CONST pAddress, CONST DWORD dwFlags) { 
176   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
177   FIXME("(%p):(%x): Stub\n", This, dwFlags);
178   return DPN_OK; 
179 }
180
181 static HRESULT WINAPI IDirectPlay8ClientImpl_Close(PDIRECTPLAY8CLIENT iface, CONST DWORD dwFlags) { 
182   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
183   FIXME("(%p):(%x): Stub\n", This, dwFlags);
184   return DPN_OK; 
185 }
186
187 static HRESULT WINAPI IDirectPlay8ClientImpl_ReturnBuffer(PDIRECTPLAY8CLIENT iface, CONST DPNHANDLE hBufferHandle, CONST DWORD dwFlags) { 
188   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
189   FIXME("(%p):(%x): Stub\n", This, dwFlags);
190   return DPN_OK; 
191 }
192
193 static HRESULT WINAPI IDirectPlay8ClientImpl_GetCaps(PDIRECTPLAY8CLIENT iface, DPN_CAPS * CONST pdpCaps, CONST DWORD dwFlags) { 
194   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
195   FIXME("(%p):(%x): Stub\n", This, dwFlags);
196   return DPN_OK; 
197 }
198
199 static HRESULT WINAPI IDirectPlay8ClientImpl_SetCaps(PDIRECTPLAY8CLIENT iface, CONST DPN_CAPS * CONST pdpCaps, CONST DWORD dwFlags) { 
200   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
201   FIXME("(%p):(%x): Stub\n", This, dwFlags);
202   return DPN_OK; 
203 }
204
205 static HRESULT WINAPI IDirectPlay8ClientImpl_SetSPCaps(PDIRECTPLAY8CLIENT iface, CONST GUID * CONST pguidSP, CONST DPN_SP_CAPS * CONST pdpspCaps, CONST DWORD dwFlags ) { 
206   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
207   FIXME("(%p):(%x): Stub\n", This, dwFlags);
208   return DPN_OK; 
209 }
210
211 static HRESULT WINAPI IDirectPlay8ClientImpl_GetSPCaps(PDIRECTPLAY8CLIENT iface, CONST GUID * CONST pguidSP, DPN_SP_CAPS * CONST pdpspCaps, CONST DWORD dwFlags) { 
212   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
213   FIXME("(%p):(%x): Stub\n", This, dwFlags);
214   return DPN_OK; 
215 }
216
217 static HRESULT WINAPI IDirectPlay8ClientImpl_GetConnectionInfo(PDIRECTPLAY8CLIENT iface, DPN_CONNECTION_INFO * CONST pdpConnectionInfo, CONST DWORD dwFlags) { 
218   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
219   FIXME("(%p):(%x): Stub\n", This, dwFlags);
220   return DPN_OK; 
221 }
222
223 static HRESULT WINAPI IDirectPlay8ClientImpl_RegisterLobby(PDIRECTPLAY8CLIENT iface, CONST DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication * CONST pIDP8LobbiedApplication, CONST DWORD dwFlags) { 
224   IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
225   FIXME("(%p):(%x): Stub\n", This, dwFlags);
226   return DPN_OK; 
227 }
228
229 static const IDirectPlay8ClientVtbl DirectPlay8Client_Vtbl =
230 {
231     IDirectPlay8ClientImpl_QueryInterface,
232     IDirectPlay8ClientImpl_AddRef,
233     IDirectPlay8ClientImpl_Release,
234     IDirectPlay8ClientImpl_Initialize,
235     IDirectPlay8ClientImpl_EnumServiceProviders,
236     IDirectPlay8ClientImpl_EnumHosts,
237     IDirectPlay8ClientImpl_CancelAsyncOperation,
238     IDirectPlay8ClientImpl_Connect,
239     IDirectPlay8ClientImpl_Send,
240     IDirectPlay8ClientImpl_GetSendQueueInfo,
241     IDirectPlay8ClientImpl_GetApplicationDesc,
242     IDirectPlay8ClientImpl_SetClientInfo,
243     IDirectPlay8ClientImpl_GetServerInfo,
244     IDirectPlay8ClientImpl_GetServerAddress,
245     IDirectPlay8ClientImpl_Close,
246     IDirectPlay8ClientImpl_ReturnBuffer,
247     IDirectPlay8ClientImpl_GetCaps,
248     IDirectPlay8ClientImpl_SetCaps,
249     IDirectPlay8ClientImpl_SetSPCaps,
250     IDirectPlay8ClientImpl_GetSPCaps,
251     IDirectPlay8ClientImpl_GetConnectionInfo,
252     IDirectPlay8ClientImpl_RegisterLobby
253 };
254
255 HRESULT DPNET_CreateDirectPlay8Client(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
256   IDirectPlay8ClientImpl* client;
257
258   TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
259   
260   client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ClientImpl));
261   if (NULL == client) {
262     *ppobj = NULL;
263     return E_OUTOFMEMORY;
264   }
265   client->lpVtbl = &DirectPlay8Client_Vtbl;
266   client->ref = 0; /* will be inited with QueryInterface */
267   return IDirectPlay8ClientImpl_QueryInterface ((PDIRECTPLAY8CLIENT)client, riid, ppobj);
268 }