msado15: Implement Dispatch functions in _Connection.
[wine.git] / dlls / dpwsockx / dpwsockx_main.c
blob2c73c17be2144f868b50a3e6e43af078fc59dd95
1 /* Internet TCP/IP and IPX Connection For DirectPlay
3 * Copyright 2008 Ismael Barros Barros
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winsock2.h"
26 #include "dpwsockx_dll.h"
27 #include "wine/debug.h"
28 #include "dplay.h"
29 #include "wine/dplaysp.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
33 static HRESULT WINAPI DPWSCB_EnumSessions( LPDPSP_ENUMSESSIONSDATA data )
35 FIXME( "(%p,%d,%p,%u) stub\n",
36 data->lpMessage, data->dwMessageSize,
37 data->lpISP, data->bReturnStatus );
38 return DPERR_UNSUPPORTED;
41 static HRESULT WINAPI DPWSCB_Reply( LPDPSP_REPLYDATA data )
43 FIXME( "(%p,%p,%d,%d,%p) stub\n",
44 data->lpSPMessageHeader, data->lpMessage, data->dwMessageSize,
45 data->idNameServer, data->lpISP );
46 return DPERR_UNSUPPORTED;
49 static HRESULT WINAPI DPWSCB_Send( LPDPSP_SENDDATA data )
51 FIXME( "(0x%08x,%d,%d,%p,%d,%u,%p) stub\n",
52 data->dwFlags, data->idPlayerTo, data->idPlayerFrom,
53 data->lpMessage, data->dwMessageSize,
54 data->bSystemMessage, data->lpISP );
55 return DPERR_UNSUPPORTED;
58 static HRESULT WINAPI DPWSCB_CreatePlayer( LPDPSP_CREATEPLAYERDATA data )
60 FIXME( "(%d,0x%08x,%p,%p) stub\n",
61 data->idPlayer, data->dwFlags,
62 data->lpSPMessageHeader, data->lpISP );
63 return DPERR_UNSUPPORTED;
66 static HRESULT WINAPI DPWSCB_DeletePlayer( LPDPSP_DELETEPLAYERDATA data )
68 FIXME( "(%d,0x%08x,%p) stub\n",
69 data->idPlayer, data->dwFlags, data->lpISP );
70 return DPERR_UNSUPPORTED;
73 static HRESULT WINAPI DPWSCB_GetAddress( LPDPSP_GETADDRESSDATA data )
75 FIXME( "(%d,0x%08x,%p,%p,%p) stub\n",
76 data->idPlayer, data->dwFlags, data->lpAddress,
77 data->lpdwAddressSize, data->lpISP );
78 return DPERR_UNSUPPORTED;
81 static HRESULT WINAPI DPWSCB_GetCaps( LPDPSP_GETCAPSDATA data )
83 TRACE( "(%d,%p,0x%08x,%p)\n",
84 data->idPlayer, data->lpCaps, data->dwFlags, data->lpISP );
86 data->lpCaps->dwFlags = ( DPCAPS_ASYNCSUPPORTED |
87 DPCAPS_GUARANTEEDOPTIMIZED |
88 DPCAPS_GUARANTEEDSUPPORTED );
90 data->lpCaps->dwMaxQueueSize = DPWS_MAXQUEUESIZE;
91 data->lpCaps->dwHundredBaud = DPWS_HUNDREDBAUD;
92 data->lpCaps->dwLatency = DPWS_LATENCY;
93 data->lpCaps->dwMaxLocalPlayers = DPWS_MAXLOCALPLAYERS;
94 data->lpCaps->dwHeaderLength = sizeof(DPSP_MSG_HEADER);
95 data->lpCaps->dwTimeout = DPWS_TIMEOUT;
97 if ( data->dwFlags & DPGETCAPS_GUARANTEED )
99 data->lpCaps->dwMaxBufferSize = DPWS_GUARANTEED_MAXBUFFERSIZE;
100 data->lpCaps->dwMaxPlayers = DPWS_GUARANTEED_MAXPLAYERS;
102 else
104 data->lpCaps->dwMaxBufferSize = DPWS_MAXBUFFERSIZE;
105 data->lpCaps->dwMaxPlayers = DPWS_MAXPLAYERS;
108 return DP_OK;
111 static HRESULT WINAPI DPWSCB_Open( LPDPSP_OPENDATA data )
113 FIXME( "(%u,%p,%p,%u,0x%08x,0x%08x) stub\n",
114 data->bCreate, data->lpSPMessageHeader, data->lpISP,
115 data->bReturnStatus, data->dwOpenFlags, data->dwSessionFlags );
116 return DPERR_UNSUPPORTED;
119 static HRESULT WINAPI DPWSCB_CloseEx( LPDPSP_CLOSEDATA data )
121 FIXME( "(%p) stub\n", data->lpISP );
122 return DPERR_UNSUPPORTED;
125 static HRESULT WINAPI DPWSCB_ShutdownEx( LPDPSP_SHUTDOWNDATA data )
127 FIXME( "(%p) stub\n", data->lpISP );
128 return DPERR_UNSUPPORTED;
131 static HRESULT WINAPI DPWSCB_GetAddressChoices( LPDPSP_GETADDRESSCHOICESDATA data )
133 FIXME( "(%p,%p,%p) stub\n",
134 data->lpAddress, data->lpdwAddressSize, data->lpISP );
135 return DPERR_UNSUPPORTED;
138 static HRESULT WINAPI DPWSCB_SendEx( LPDPSP_SENDEXDATA data )
140 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p,%u) stub\n",
141 data->lpISP, data->dwFlags, data->idPlayerTo, data->idPlayerFrom,
142 data->lpSendBuffers, data->cBuffers, data->dwMessageSize,
143 data->dwPriority, data->dwTimeout, data->lpDPContext,
144 data->lpdwSPMsgID, data->bSystemMessage );
145 return DPERR_UNSUPPORTED;
148 static HRESULT WINAPI DPWSCB_SendToGroupEx( LPDPSP_SENDTOGROUPEXDATA data )
150 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p) stub\n",
151 data->lpISP, data->dwFlags, data->idGroupTo, data->idPlayerFrom,
152 data->lpSendBuffers, data->cBuffers, data->dwMessageSize,
153 data->dwPriority, data->dwTimeout, data->lpDPContext,
154 data->lpdwSPMsgID );
155 return DPERR_UNSUPPORTED;
158 static HRESULT WINAPI DPWSCB_Cancel( LPDPSP_CANCELDATA data )
160 FIXME( "(%p,0x%08x,%p,%d,0x%08x,0x%08x) stub\n",
161 data->lpISP, data->dwFlags, data->lprglpvSPMsgID, data->cSPMsgID,
162 data->dwMinPriority, data->dwMaxPriority );
163 return DPERR_UNSUPPORTED;
166 static HRESULT WINAPI DPWSCB_GetMessageQueue( LPDPSP_GETMESSAGEQUEUEDATA data )
168 FIXME( "(%p,0x%08x,%d,%d,%p,%p) stub\n",
169 data->lpISP, data->dwFlags, data->idFrom, data->idTo,
170 data->lpdwNumMsgs, data->lpdwNumBytes );
171 return DPERR_UNSUPPORTED;
174 static void setup_callbacks( LPDPSP_SPCALLBACKS lpCB )
176 lpCB->EnumSessions = DPWSCB_EnumSessions;
177 lpCB->Reply = DPWSCB_Reply;
178 lpCB->Send = DPWSCB_Send;
179 lpCB->CreatePlayer = DPWSCB_CreatePlayer;
180 lpCB->DeletePlayer = DPWSCB_DeletePlayer;
181 lpCB->GetAddress = DPWSCB_GetAddress;
182 lpCB->GetCaps = DPWSCB_GetCaps;
183 lpCB->Open = DPWSCB_Open;
184 lpCB->CloseEx = DPWSCB_CloseEx;
185 lpCB->ShutdownEx = DPWSCB_ShutdownEx;
186 lpCB->GetAddressChoices = DPWSCB_GetAddressChoices;
187 lpCB->SendEx = DPWSCB_SendEx;
188 lpCB->SendToGroupEx = DPWSCB_SendToGroupEx;
189 lpCB->Cancel = DPWSCB_Cancel;
190 lpCB->GetMessageQueue = DPWSCB_GetMessageQueue;
192 lpCB->AddPlayerToGroup = NULL;
193 lpCB->Close = NULL;
194 lpCB->CreateGroup = NULL;
195 lpCB->DeleteGroup = NULL;
196 lpCB->RemovePlayerFromGroup = NULL;
197 lpCB->SendToGroup = NULL;
198 lpCB->Shutdown = NULL;
203 /******************************************************************
204 * SPInit (DPWSOCKX.1)
206 HRESULT WINAPI SPInit( LPSPINITDATA lpspData )
208 WSADATA wsaData;
209 DPWS_DATA dpwsData;
211 TRACE( "Initializing library for %s (%s)\n",
212 wine_dbgstr_guid(lpspData->lpGuid), debugstr_w(lpspData->lpszName) );
214 /* We only support TCP/IP service */
215 if ( !IsEqualGUID(lpspData->lpGuid, &DPSPGUID_TCPIP) )
217 return DPERR_UNAVAILABLE;
220 /* Assign callback functions */
221 setup_callbacks( lpspData->lpCB );
223 /* Load Winsock 2.0 DLL */
224 if ( WSAStartup( MAKEWORD(2, 0), &wsaData ) != 0 )
226 ERR( "WSAStartup() failed\n" );
227 return DPERR_UNAVAILABLE;
230 /* Initialize internal data */
231 memset( &dpwsData, 0, sizeof(DPWS_DATA) );
232 dpwsData.lpISP = lpspData->lpISP;
233 IDirectPlaySP_SetSPData( lpspData->lpISP, &dpwsData, sizeof(DPWS_DATA),
234 DPSET_LOCAL );
236 /* dplay needs to know the size of the header */
237 lpspData->dwSPHeaderSize = sizeof(DPSP_MSG_HEADER);
239 return DP_OK;