Storing an IP address in a signed int results in bugs if it starts
[wine] / dlls / dplayx / dplay_global.h
1 #ifndef __WINE_DPLAY_GLOBAL_INCLUDED
2 #define __WINE_DPLAY_GLOBAL_INCLUDED
3
4 #include "dplaysp.h"
5 #include "lobbysp.h"
6 #include "dplayx_queue.h"
7
8 extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, 
9                                 LPCVOID lpAddress, DWORD dwAddressSize, 
10                                 LPVOID lpContext );
11
12 extern DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi );
13
14 /*****************************************************************************
15  * Predeclare the interface implementation structures
16  */
17 typedef struct IDirectPlay2Impl IDirectPlay2AImpl;
18 typedef struct IDirectPlay2Impl IDirectPlay2Impl;
19 typedef struct IDirectPlay3Impl IDirectPlay3AImpl;
20 typedef struct IDirectPlay3Impl IDirectPlay3Impl;
21 typedef struct IDirectPlay4Impl IDirectPlay4AImpl;
22 typedef struct IDirectPlay4Impl IDirectPlay4Impl;
23
24 typedef struct tagDirectPlayIUnknownData
25 {
26   ULONG             ulObjRef;
27   CRITICAL_SECTION  DP_lock;
28 } DirectPlayIUnknownData;
29
30 typedef struct tagEnumSessionAsyncCallbackData
31 {
32   LPSPINITDATA lpSpData;
33   GUID         requestGuid;
34   DWORD        dwEnumSessionFlags;
35   DWORD        dwTimeout;
36   HANDLE       hSuicideRequest;
37 } EnumSessionAsyncCallbackData;
38
39 typedef struct tagDP_MSG_REPLY_STRUCT
40 {
41   HANDLE hReceipt;
42   WORD   wExpectedReply;
43   LPVOID lpReplyMsg;
44   DWORD  dwMsgBodySize;
45   /* FIXME: Is the message header required as well? */
46 } DP_MSG_REPLY_STRUCT, *LPDP_MSG_REPLY_STRUCT;
47
48 typedef struct tagDP_MSG_REPLY_STRUCT_LIST
49 {
50   DPQ_ENTRY(tagDP_MSG_REPLY_STRUCT_LIST) replysExpected; 
51   DP_MSG_REPLY_STRUCT replyExpected;
52 } DP_MSG_REPLY_STRUCT_LIST, *LPDP_MSG_REPLY_STRUCT_LIST;
53
54 struct PlayerData
55 {
56   /* Individual player information */
57   DPID dpid;
58
59   DPNAME name;
60   HANDLE hEvent;
61
62   ULONG  uRef;  /* What is the reference count on this data? */
63
64   /* View of local data */
65   LPVOID lpLocalData;
66   DWORD  dwLocalDataSize;
67
68   /* View of remote data */
69   LPVOID lpRemoteData;
70   DWORD  dwRemoteDataSize;
71
72   /* SP data on a per player basis */
73   LPVOID lpSPPlayerData;
74
75   DWORD  dwFlags; /* Special remarks about the type of player */
76 };
77 typedef struct PlayerData* lpPlayerData;
78
79 struct PlayerList
80 {
81   DPQ_ENTRY(PlayerList) players;
82
83   lpPlayerData lpPData;
84 };
85 typedef struct PlayerList* lpPlayerList;
86
87 struct GroupData
88 {
89   /* Internal information */
90   DPID parent; /* If parent == 0 it's a top level group */
91
92   ULONG uRef; /* Reference count */
93
94   DPQ_HEAD(GroupList)  groups;  /* A group has [0..n] groups */
95   DPQ_HEAD(PlayerList) players; /* A group has [0..n] players */
96
97   DPID idGroupOwner; /* ID of player who owns the group */
98
99   DWORD dwFlags; /* Flags describing anything special about the group */
100
101   DPID   dpid;
102   DPNAME name;
103
104   /* View of local data */
105   LPVOID lpLocalData;
106   DWORD  dwLocalDataSize;
107
108   /* View of remote data */
109   LPVOID lpRemoteData;
110   DWORD  dwRemoteDataSize;
111 };
112 typedef struct GroupData  GroupData;
113 typedef struct GroupData* lpGroupData;
114
115 struct GroupList
116 {
117   DPQ_ENTRY(GroupList) groups;
118
119   lpGroupData lpGData;
120 };
121 typedef struct GroupList* lpGroupList;
122
123 struct DPMSG
124 {
125   DPQ_ENTRY( DPMSG ) msgs;
126   DPMSG_GENERIC* msg;
127 };
128 typedef struct DPMSG* LPDPMSG;
129
130 enum SPSTATE
131 {
132   NO_PROVIDER = 0,
133   DP_SERVICE_PROVIDER = 1,
134   DP_LOBBY_PROVIDER = 2
135 };
136
137 /* Contains all data members. FIXME: Rename me */
138 typedef struct tagDirectPlay2Data
139 {
140   BOOL   bConnectionOpen;
141
142   /* For async EnumSessions requests */
143   HANDLE hEnumSessionThread;
144   HANDLE hKillEnumSessionThreadEvent;
145
146   LPVOID lpNameServerData; /* DPlay interface doesn't know contents */
147
148   BOOL bHostInterface; /* Did this interface create the session */
149
150   lpGroupData lpSysGroup; /* System group with _everything_ in it */
151
152   LPDPSESSIONDESC2 lpSessionDesc;
153
154   /* I/O Msg queues */
155   DPQ_HEAD( DPMSG ) receiveMsgs; /* Msg receive queue */
156   DPQ_HEAD( DPMSG ) sendMsgs;    /* Msg send pending queue */
157
158   /* Information about the service provider active on this connection */
159   SPINITDATA spData;
160   BOOL       bSPInitialized;
161
162   /* Information about the lobby server that's attached to this DP object */
163   SPDATA_INIT dplspData;
164   BOOL        bDPLSPInitialized;
165
166   /* Our service provider */
167   HMODULE hServiceProvider;
168
169   /* Our DP lobby provider */
170   HMODULE hDPLobbyProvider;
171
172   enum SPSTATE connectionInitialized;
173
174   /* Expected messages queue */
175   DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) replysExpected;
176 } DirectPlay2Data;
177
178 typedef struct tagDirectPlay3Data
179 {
180   BOOL dummy;
181 } DirectPlay3Data;
182 typedef struct tagDirectPlay4Data
183 {
184   BOOL dummy;
185 } DirectPlay4Data;
186
187 #define DP_IMPL_FIELDS \
188   ULONG ulInterfaceRef; \
189   DirectPlayIUnknownData*  unk; \
190   DirectPlay2Data*         dp2; \
191   DirectPlay3Data*         dp3; \
192   DirectPlay4Data*         dp4;
193
194 struct IDirectPlay2Impl
195 {
196   ICOM_VFIELD(IDirectPlay2);
197   DP_IMPL_FIELDS
198 };
199
200 struct IDirectPlay3Impl
201 {
202   ICOM_VFIELD(IDirectPlay3);
203   DP_IMPL_FIELDS
204 };
205
206 struct IDirectPlay4Impl
207 {
208   ICOM_VFIELD(IDirectPlay4);
209   DP_IMPL_FIELDS
210 };
211
212 /* Forward declarations of virtual tables */
213 extern ICOM_VTABLE(IDirectPlay2) directPlay2AVT;
214 extern ICOM_VTABLE(IDirectPlay3) directPlay3AVT;
215 extern ICOM_VTABLE(IDirectPlay4) directPlay4AVT;
216
217 extern ICOM_VTABLE(IDirectPlay2) directPlay2WVT;
218 extern ICOM_VTABLE(IDirectPlay3) directPlay3WVT;
219 extern ICOM_VTABLE(IDirectPlay4) directPlay4WVT;
220
221
222 HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpMessageBody,
223                           DWORD  dwMessageBodySize, LPCVOID lpMessageHeader,
224                           WORD wCommandId, WORD wVersion, 
225                           LPVOID* lplpReply, LPDWORD lpdwMsgSize );
226
227 /* DP SP external interfaces into DirectPlay */
228 extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData );
229 extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData );
230
231 /* DP external interfaces to call into DPSP interface */
232 extern LPVOID DPSP_CreateSPPlayerData(void);
233
234 #endif /* __WINE_DPLAY_GLOBAL_INCLUDED */