1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1997 Alexandre Julliard
7 * Copyright 1997 Len White
8 * Copyright 1999 Keith Matthews
10 * Copyright 2001 Eric Pouech
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #ifndef __WINE_DDEML_PRIVATE_H
28 #define __WINE_DDEML_PRIVATE_H
30 /* defined in atom.c file.
32 #define MAX_ATOM_LEN 255
34 /* Maximum buffer size ( including the '\0' ).
36 #define MAX_BUFFER_LEN (MAX_ATOM_LEN + 1)
38 /* The internal structures (prefixed by WDML) are used as follows:
39 * + a WDML_INSTANCE is created for each instance creation (DdeInitialize)
40 * - a popup window (InstanceClass) is created for each instance.
41 * - this window is used to receive all the DDEML events (server registration,
42 * conversation confirmation...). See the WM_WDML_???? messages for details
43 * + when registering a server (DdeNameService) a WDML_SERVER is created
44 * - a popup window (ServerNameClass) is created
45 * + a conversation is represented by two WDML_CONV structures:
46 * - one on the client side, the other one on the server side
47 * - this is needed because the address spaces may be different
48 * - therefore, two lists of links are kept for each instance
49 * - two windows are created for a conversation:
50 * o a popup window on client side (ClientConvClass)
51 * o a child window (of the ServerName) on the server side
53 * - all the exchanges then take place between those two windows
54 * - windows for the conversation exist in two forms (Ansi & Unicode). This
55 * is only needed when a partner in a conv is not handled by DDEML. The
56 * type (A/W) of the window is used to handle the ansi <=> unicode
58 * - two handles are created for a conversation (on each side). Each handle
59 * is linked to a structure. To help differentiate those handles, the
60 * local one has an even value, whereas the remote one has an odd value.
61 * + a (warm or link) is represented by two WDML_LINK structures:
62 * - one on client side, the other one on server side
63 * - therefore, two lists of links are kept for each instance
65 * To help getting back to data, WDML windows store information:
66 * - offset 0: the DDE instance
67 * - offset 4: the current conversation (for ClientConv and ServerConv only)
69 * All the implementation (client & server) makes the assumption that the other side
70 * is not always a DDEML partner. However, if it's the case, supplementary services
71 * are available (most notably the REGISTER/UNREGISTER and CONNECT_CONFIRM messages
72 * to the callback function). To be correct in every situation, all the basic
73 * exchanges are made using the 'pure' DDE protocol. A (future !) enhancement would
74 * be to provide a new protocol in the case were both partners are handled by DDEML.
76 * The StringHandles are in fact stored as local atoms. So an HSZ and a (local) atom
77 * can be used interchangably. However, in order to keep track of the allocated HSZ,
78 * and to free them upon instance termination, all HSZ are stored in a link list.
79 * When the HSZ need to be passed thru DDE messages, we need to convert them back and
80 * forth to global atoms.
83 /* this struct has the same mapping as all the DDE??? structures */
85 unsigned short unused
:12,
93 typedef struct tagHSZNode
95 struct tagHSZNode
* next
;
100 typedef struct tagWDML_SERVER
102 struct tagWDML_SERVER
* next
;
106 ATOM atomServiceSpec
;
111 typedef struct tagWDML_XACT
{
112 struct tagWDML_XACT
* next
; /* list of transactions in conversation */
121 ATOM atom
; /* as converted from or to hszItem */
123 LPARAM lParam
; /* useful for reusing */
126 typedef struct tagWDML_CONV
128 struct tagWDML_CONV
* next
; /* to link all the conversations */
129 struct tagWDML_INSTANCE
* instance
;
130 HSZ hszService
; /* pmt used for connection */
131 HSZ hszTopic
; /* pmt used for connection */
132 UINT afCmd
; /* service name flag */
133 CONVCONTEXT convContext
;
134 HWND hwndClient
; /* source of conversation (ClientConvClass) */
135 HWND hwndServer
; /* destination of conversation (ServerConvClass) */
136 WDML_XACT
* transactions
; /* pending transactions */
137 DWORD hUser
; /* user defined value */
138 DWORD wStatus
; /* same bits as convinfo.wStatus */
139 DWORD wConvst
; /* same values as convinfo.wConvst */
142 /* DDE_LINK struct defines hot, warm, and cold links */
143 typedef struct tagWDML_LINK
{
144 struct tagWDML_LINK
* next
; /* to link all the active links */
145 HCONV hConv
; /* to get back to the converstaion */
146 UINT transactionType
;/* 0 for no link */
147 HSZ hszItem
; /* item targetted for (hot/warm) link */
148 UINT uFmt
; /* format for data */
151 typedef struct tagWDML_INSTANCE
153 struct tagWDML_INSTANCE
* next
;
154 DWORD instanceID
; /* needed to track monitor usage */
155 DWORD threadID
; /* needed to keep instance linked to a unique thread */
156 BOOL monitor
; /* have these two as full Booleans cos they'll be tested frequently */
157 BOOL clientOnly
; /* bit wasteful of space but it will be faster */
158 BOOL win16
; /* flag to indicate Win16 API used to initialize */
159 HSZNode
* nodeList
; /* for cleaning upon exit */
160 PFNCALLBACK callback
;
165 WDML_SERVER
* servers
; /* list of registered servers */
166 WDML_CONV
* convs
[2]; /* active conversations for this instance (client and server) */
167 WDML_LINK
* links
[2]; /* active links for this instance (client and server) */
170 extern CRITICAL_SECTION WDML_CritSect
; /* protection for instance list */
172 /* header for the DDE Data objects */
173 typedef struct tagDDE_DATAHANDLE_HEAD
177 } DDE_DATAHANDLE_HEAD
;
179 typedef enum tagWDML_SIDE
181 WDML_CLIENT_SIDE
= 0, WDML_SERVER_SIDE
= 1
185 WDML_QS_ERROR
, WDML_QS_HANDLED
, WDML_QS_PASS
, WDML_QS_SWALLOWED
, WDML_QS_BLOCK
,
188 extern HDDEDATA
WDML_InvokeCallback(WDML_INSTANCE
* pInst
, UINT uType
, UINT uFmt
, HCONV hConv
,
189 HSZ hsz1
, HSZ hsz2
, HDDEDATA hdata
,
190 ULONG_PTR dwData1
, ULONG_PTR dwData2
);
191 extern HDDEDATA
WDML_InvokeCallback16(PFNCALLBACK pfn
, UINT uType
, UINT uFmt
, HCONV hConv
,
192 HSZ hsz1
, HSZ hsz2
, HDDEDATA hdata
,
193 DWORD dwData1
, DWORD dwData2
);
194 extern WDML_SERVER
* WDML_AddServer(WDML_INSTANCE
* pInstance
, HSZ hszService
, HSZ hszTopic
);
195 extern void WDML_RemoveServer(WDML_INSTANCE
* pInstance
, HSZ hszService
, HSZ hszTopic
);
196 extern WDML_SERVER
* WDML_FindServer(WDML_INSTANCE
* pInstance
, HSZ hszService
, HSZ hszTopic
);
197 /* transaction handler on the server side */
198 extern WDML_QUEUE_STATE
WDML_ServerHandle(WDML_CONV
* pConv
, WDML_XACT
* pXAct
);
199 /* called both in DdeClientTransaction and server side. */
200 extern UINT
WDML_Initialize(LPDWORD pidInst
, PFNCALLBACK pfnCallback
,
201 DWORD afCmd
, DWORD ulRes
, BOOL b16
);
202 extern WDML_CONV
* WDML_AddConv(WDML_INSTANCE
* pInstance
, WDML_SIDE side
,
203 HSZ hszService
, HSZ hszTopic
, HWND hwndClient
, HWND hwndServer
);
204 extern void WDML_RemoveConv(WDML_CONV
* pConv
, WDML_SIDE side
);
205 extern WDML_CONV
* WDML_GetConv(HCONV hConv
, BOOL checkConnected
);
206 extern WDML_CONV
* WDML_GetConvFromWnd(HWND hWnd
);
207 extern WDML_CONV
* WDML_FindConv(WDML_INSTANCE
* pInstance
, WDML_SIDE side
,
208 HSZ hszService
, HSZ hszTopic
);
209 extern BOOL
WDML_PostAck(WDML_CONV
* pConv
, WDML_SIDE side
, WORD appRetCode
,
210 BOOL fBusy
, BOOL fAck
, UINT pmt
, LPARAM lParam
, UINT oldMsg
);
211 extern void WDML_AddLink(WDML_INSTANCE
* pInstance
, HCONV hConv
, WDML_SIDE side
,
212 UINT wType
, HSZ hszItem
, UINT wFmt
);
213 extern WDML_LINK
* WDML_FindLink(WDML_INSTANCE
* pInstance
, HCONV hConv
, WDML_SIDE side
,
214 HSZ hszItem
, BOOL use_fmt
, UINT uFmt
);
215 extern void WDML_RemoveLink(WDML_INSTANCE
* pInstance
, HCONV hConv
, WDML_SIDE side
,
216 HSZ hszItem
, UINT wFmt
);
217 extern void WDML_RemoveAllLinks(WDML_INSTANCE
* pInstance
, WDML_CONV
* pConv
, WDML_SIDE side
);
218 /* string internals */
219 extern void WDML_FreeAllHSZ(WDML_INSTANCE
* pInstance
);
220 extern BOOL
WDML_DecHSZ(WDML_INSTANCE
* pInstance
, HSZ hsz
);
221 extern BOOL
WDML_IncHSZ(WDML_INSTANCE
* pInstance
, HSZ hsz
);
222 extern ATOM
WDML_MakeAtomFromHsz(HSZ hsz
);
223 extern HSZ
WDML_MakeHszFromAtom(WDML_INSTANCE
* pInstance
, ATOM atom
);
224 /* client calls these */
225 extern WDML_XACT
* WDML_AllocTransaction(WDML_INSTANCE
* pInstance
, UINT ddeMsg
, UINT wFmt
, HSZ hszItem
);
226 extern void WDML_QueueTransaction(WDML_CONV
* pConv
, WDML_XACT
* pXAct
);
227 extern BOOL
WDML_UnQueueTransaction(WDML_CONV
* pConv
, WDML_XACT
* pXAct
);
228 extern void WDML_FreeTransaction(WDML_INSTANCE
* pInstance
, WDML_XACT
* pXAct
, BOOL doFreePmt
);
229 extern WDML_XACT
* WDML_FindTransaction(WDML_CONV
* pConv
, DWORD tid
);
230 extern HGLOBAL
WDML_DataHandle2Global(HDDEDATA hDdeData
, BOOL fResponse
, BOOL fRelease
,
231 BOOL fDeferUpd
, BOOL dAckReq
);
232 extern HDDEDATA
WDML_Global2DataHandle(HGLOBAL hMem
, WINE_DDEHEAD
* da
);
233 extern BOOL
WDML_IsAppOwned(HDDEDATA hDdeData
);
234 extern WDML_INSTANCE
* WDML_GetInstance(DWORD InstId
);
235 extern WDML_INSTANCE
* WDML_GetInstanceFromWnd(HWND hWnd
);
236 /* broadcasting to DDE windows */
237 extern void WDML_BroadcastDDEWindows(LPCWSTR clsName
, UINT uMsg
,
238 WPARAM wParam
, LPARAM lParam
);
239 extern void WDML_NotifyThreadExit(DWORD tid
);
241 static inline void WDML_ExtractAck(WORD status
, DDEACK
* da
)
243 *da
= *((DDEACK
*)&status
);
246 extern const WCHAR WDML_szEventClass
[]; /* class of window for events (aka instance) */
247 extern const WCHAR WDML_szServerConvClass
[]; /* class of window for server side conv */
248 extern const WCHAR WDML_szClientConvClass
[]; /* class of window for client side conv */
250 #define WM_WDML_REGISTER (WM_USER + 0x200)
251 #define WM_WDML_UNREGISTER (WM_USER + 0x201)
252 #define WM_WDML_CONNECT_CONFIRM (WM_USER + 0x202)
254 /* parameters for messages:
256 * Register atom for service name atom for service spec
257 * Unregister atom for service name atom for service spec
258 * ConnectConfirm client window handle server window handle
261 #define GWL_WDML_INSTANCE (0)
262 #define GWL_WDML_CONVERSATION (sizeof(ULONG_PTR))
263 #define GWL_WDML_SERVER (sizeof(ULONG_PTR))
265 #endif /* __WINE_DDEML_PRIVATE_H */