client.c 10.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* 
 * DirectPlay8 Client
 * 
 * Copyright 2004 Raphael Junqueira
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 23 24 25
 *
 */

#include "config.h"

#include <stdarg.h>

26
#define COBJMACROS
27 28 29 30 31 32 33 34 35 36 37 38 39
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "objbase.h"
#include "wine/debug.h"

#include "dplay8.h"
#include "dpnet_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(dpnet);

/* IDirectPlay8Client IUnknown parts follow: */
40
static HRESULT WINAPI IDirectPlay8ClientImpl_QueryInterface(PDIRECTPLAY8CLIENT iface, REFIID riid, LPVOID *ppobj)
41
{
42
    IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
43 44 45

    if (IsEqualGUID(riid, &IID_IUnknown)
        || IsEqualGUID(riid, &IID_IDirectPlay8Client)) {
46
        IUnknown_AddRef(iface);
47 48 49 50 51 52 53 54
        *ppobj = This;
        return DPN_OK;
    }

    WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
    return E_NOINTERFACE;
}

55
static ULONG WINAPI IDirectPlay8ClientImpl_AddRef(PDIRECTPLAY8CLIENT iface) {
56
    IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
57 58
    ULONG refCount = InterlockedIncrement(&This->ref);

59
    TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
60 61

    return refCount;
62 63
}

64
static ULONG WINAPI IDirectPlay8ClientImpl_Release(PDIRECTPLAY8CLIENT iface) {
65
    IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
66 67
    ULONG refCount = InterlockedDecrement(&This->ref);

68
    TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
69 70

    if (!refCount) {
71 72
        HeapFree(GetProcessHeap(), 0, This);
    }
73
    return refCount;
74 75 76 77
}

/* IDirectPlay8Client Interface follow: */

78
static HRESULT WINAPI IDirectPlay8ClientImpl_Initialize(PDIRECTPLAY8CLIENT iface,  PVOID CONST pvUserContext, CONST PFNDPNMESSAGEHANDLER pfn, CONST DWORD dwFlags) { 
79
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
80
  FIXME("(%p):(%p,%p,%x): Stub\n", This, pvUserContext, pfn, dwFlags);
81 82 83
  return DPN_OK; 
}

84
static HRESULT WINAPI IDirectPlay8ClientImpl_EnumServiceProviders(PDIRECTPLAY8CLIENT iface, 
85 86 87 88 89 90
							   CONST GUID * CONST pguidServiceProvider, 
							   CONST GUID * CONST pguidApplication, 
							   DPN_SERVICE_PROVIDER_INFO * CONST pSPInfoBuffer, 
							   PDWORD CONST pcbEnumData, 
							   PDWORD CONST pcReturned, 
							   CONST DWORD dwFlags) { 
91
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
92
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
93 94 95
  return DPN_OK; 
}

96
static HRESULT WINAPI IDirectPlay8ClientImpl_EnumHosts(PDIRECTPLAY8CLIENT iface, 
97 98 99 100 101 102 103 104 105
						PDPN_APPLICATION_DESC CONST pApplicationDesc, 
						IDirectPlay8Address * CONST pAddrHost, 
						IDirectPlay8Address * CONST pDeviceInfo, 
						PVOID CONST pUserEnumData, CONST DWORD dwUserEnumDataSize, CONST DWORD dwEnumCount, 
						CONST DWORD dwRetryInterval, 
						CONST DWORD dwTimeOut, 
						PVOID CONST pvUserContext, 
						DPNHANDLE * CONST pAsyncHandle, 
						CONST DWORD dwFlags) { 
106
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
107
  /*FIXME("(%p):(%p,%p,%p,%p,%lu,%lu,%lu,%lu): Stub\n", This, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount, dwRetryInterval, dwTimeOut);*/
108
  FIXME("(%p):(%p,%p,%x): Stub\n", This, pvUserContext, pAsyncHandle, dwFlags);
109 110 111
  return DPN_OK; 
}

112
static HRESULT WINAPI IDirectPlay8ClientImpl_CancelAsyncOperation(PDIRECTPLAY8CLIENT iface, CONST DPNHANDLE hAsyncHandle, CONST DWORD dwFlags) { 
113
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
114
  FIXME("(%p):(%u,%x): Stub\n", This, hAsyncHandle, dwFlags);
115 116 117
  return DPN_OK; 
}

118
static HRESULT WINAPI IDirectPlay8ClientImpl_Connect(PDIRECTPLAY8CLIENT iface, 
119 120 121 122 123 124 125 126 127 128
					      CONST DPN_APPLICATION_DESC * CONST pdnAppDesc,
					      IDirectPlay8Address * CONST pHostAddr,
					      IDirectPlay8Address * CONST pDeviceInfo, 
					      CONST DPN_SECURITY_DESC * CONST pdnSecurity, 
					      CONST DPN_SECURITY_CREDENTIALS * CONST pdnCredentials, 
					      CONST void * CONST pvUserConnectData, 
					      CONST DWORD dwUserConnectDataSize, 
					      void * CONST pvAsyncContext, 
					      DPNHANDLE * CONST phAsyncHandle, 
					      CONST DWORD dwFlags) { 
129
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
130
  FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
131 132 133
  return DPN_OK; 
}

134
static HRESULT WINAPI IDirectPlay8ClientImpl_Send(PDIRECTPLAY8CLIENT iface, 
135 136 137 138 139 140
					   CONST DPN_BUFFER_DESC * CONST prgBufferDesc, 
					   CONST DWORD cBufferDesc, 
					   CONST DWORD dwTimeOut, 
					   void * CONST pvAsyncContext, 
					   DPNHANDLE * CONST phAsyncHandle, 
					   CONST DWORD dwFlags) { 
141
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
142
  FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
143 144 145
  return DPN_OK; 
}

146
static HRESULT WINAPI IDirectPlay8ClientImpl_GetSendQueueInfo(PDIRECTPLAY8CLIENT iface, DWORD * CONST pdwNumMsgs, DWORD * CONST pdwNumBytes, CONST DWORD dwFlags) {
147
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
148
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
149 150 151
  return DPN_OK; 
}

152
static HRESULT WINAPI IDirectPlay8ClientImpl_GetApplicationDesc(PDIRECTPLAY8CLIENT iface, DPN_APPLICATION_DESC * CONST pAppDescBuffer, DWORD * CONST pcbDataSize, CONST DWORD dwFlags) { 
153
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
154
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
155 156 157
  return DPN_OK; 
}

158
static HRESULT WINAPI IDirectPlay8ClientImpl_SetClientInfo(PDIRECTPLAY8CLIENT iface, 
159 160 161 162
						    CONST DPN_PLAYER_INFO * CONST pdpnPlayerInfo, 
						    PVOID CONST pvAsyncContext, 
						    DPNHANDLE * CONST phAsyncHandle, 
						    CONST DWORD dwFlags) { 
163
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
164
  FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
165 166 167
  return DPN_OK; 
}

168
static HRESULT WINAPI IDirectPlay8ClientImpl_GetServerInfo(PDIRECTPLAY8CLIENT iface, DPN_PLAYER_INFO * CONST pdpnPlayerInfo, DWORD * CONST pdwSize, CONST DWORD dwFlags) { 
169
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
170
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
171 172 173
  return DPN_OK; 
}

174
static HRESULT WINAPI IDirectPlay8ClientImpl_GetServerAddress(PDIRECTPLAY8CLIENT iface, IDirectPlay8Address ** CONST pAddress, CONST DWORD dwFlags) { 
175
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
176
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
177 178 179
  return DPN_OK; 
}

180
static HRESULT WINAPI IDirectPlay8ClientImpl_Close(PDIRECTPLAY8CLIENT iface, CONST DWORD dwFlags) { 
181
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
182
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
183 184 185
  return DPN_OK; 
}

186
static HRESULT WINAPI IDirectPlay8ClientImpl_ReturnBuffer(PDIRECTPLAY8CLIENT iface, CONST DPNHANDLE hBufferHandle, CONST DWORD dwFlags) { 
187
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
188
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
189 190 191
  return DPN_OK; 
}

192
static HRESULT WINAPI IDirectPlay8ClientImpl_GetCaps(PDIRECTPLAY8CLIENT iface, DPN_CAPS * CONST pdpCaps, CONST DWORD dwFlags) { 
193
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
194
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
195 196
  return DPN_OK; 
}
197

198
static HRESULT WINAPI IDirectPlay8ClientImpl_SetCaps(PDIRECTPLAY8CLIENT iface, CONST DPN_CAPS * CONST pdpCaps, CONST DWORD dwFlags) { 
199
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
200
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
201 202 203
  return DPN_OK; 
}

204
static HRESULT WINAPI IDirectPlay8ClientImpl_SetSPCaps(PDIRECTPLAY8CLIENT iface, CONST GUID * CONST pguidSP, CONST DPN_SP_CAPS * CONST pdpspCaps, CONST DWORD dwFlags ) { 
205
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
206
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
207 208 209
  return DPN_OK; 
}

210
static HRESULT WINAPI IDirectPlay8ClientImpl_GetSPCaps(PDIRECTPLAY8CLIENT iface, CONST GUID * CONST pguidSP, DPN_SP_CAPS * CONST pdpspCaps, CONST DWORD dwFlags) { 
211
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
212
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
213 214 215
  return DPN_OK; 
}

216
static HRESULT WINAPI IDirectPlay8ClientImpl_GetConnectionInfo(PDIRECTPLAY8CLIENT iface, DPN_CONNECTION_INFO * CONST pdpConnectionInfo, CONST DWORD dwFlags) { 
217
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
218
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
219 220 221
  return DPN_OK; 
}

222
static HRESULT WINAPI IDirectPlay8ClientImpl_RegisterLobby(PDIRECTPLAY8CLIENT iface, CONST DPNHANDLE dpnHandle, struct IDirectPlay8LobbiedApplication * CONST pIDP8LobbiedApplication, CONST DWORD dwFlags) { 
223
  IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface;
224
  FIXME("(%p):(%x): Stub\n", This, dwFlags);
225 226
  return DPN_OK; 
}
227

228
static const IDirectPlay8ClientVtbl DirectPlay8Client_Vtbl =
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
{
    IDirectPlay8ClientImpl_QueryInterface,
    IDirectPlay8ClientImpl_AddRef,
    IDirectPlay8ClientImpl_Release,
    IDirectPlay8ClientImpl_Initialize,
    IDirectPlay8ClientImpl_EnumServiceProviders,
    IDirectPlay8ClientImpl_EnumHosts,
    IDirectPlay8ClientImpl_CancelAsyncOperation,
    IDirectPlay8ClientImpl_Connect,
    IDirectPlay8ClientImpl_Send,
    IDirectPlay8ClientImpl_GetSendQueueInfo,
    IDirectPlay8ClientImpl_GetApplicationDesc,
    IDirectPlay8ClientImpl_SetClientInfo,
    IDirectPlay8ClientImpl_GetServerInfo,
    IDirectPlay8ClientImpl_GetServerAddress,
    IDirectPlay8ClientImpl_Close,
    IDirectPlay8ClientImpl_ReturnBuffer,
    IDirectPlay8ClientImpl_GetCaps,
    IDirectPlay8ClientImpl_SetCaps,
    IDirectPlay8ClientImpl_SetSPCaps,
    IDirectPlay8ClientImpl_GetSPCaps,
    IDirectPlay8ClientImpl_GetConnectionInfo,
    IDirectPlay8ClientImpl_RegisterLobby
};

HRESULT DPNET_CreateDirectPlay8Client(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
  IDirectPlay8ClientImpl* client;

  TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
  
  client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ClientImpl));
  if (NULL == client) {
    *ppobj = NULL;
    return E_OUTOFMEMORY;
  }
  client->lpVtbl = &DirectPlay8Client_Vtbl;
  client->ref = 0; /* will be inited with QueryInterface */
  return IDirectPlay8ClientImpl_QueryInterface ((PDIRECTPLAY8CLIENT)client, riid, ppobj);
}