2001-06-23 01:02:48 +02:00
|
|
|
/*
|
|
|
|
* DDEML library
|
|
|
|
*
|
|
|
|
* Copyright 1997 Alexandre Julliard
|
|
|
|
* Copyright 1997 Len White
|
|
|
|
* Copyright 1999 Keith Matthews
|
|
|
|
* Copyright 2000 Corel
|
|
|
|
* Copyright 2001 Eric Pouech
|
2005-02-14 12:53:15 +01:00
|
|
|
* Copyright 2004, 2005 Dmitry Timoshkov
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-06-23 01:02:48 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-06-23 01:02:48 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2001-06-23 01:02:48 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2001-08-10 00:07:22 +02:00
|
|
|
#include "winnls.h"
|
2001-06-23 01:02:48 +02:00
|
|
|
#include "dde.h"
|
|
|
|
#include "ddeml.h"
|
2001-09-14 02:24:39 +02:00
|
|
|
#include "win.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2005-06-09 12:21:31 +02:00
|
|
|
#include "dde_private.h"
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddeml);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
static LRESULT CALLBACK WDML_ClientProc(HWND, UINT, WPARAM, LPARAM); /* only for one client, not conv list */
|
2005-07-08 13:33:09 +02:00
|
|
|
const char WDML_szClientConvClassA[] = "WineDdeClientA";
|
|
|
|
const WCHAR WDML_szClientConvClassW[] = {'W','i','n','e','D','d','e','C','l','i','e','n','t','W',0};
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DdeConnectList [USER32.@] Establishes conversation with DDE servers
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* idInst [I] Instance identifier
|
|
|
|
* hszService [I] Handle to service name string
|
|
|
|
* hszTopic [I] Handle to topic name string
|
|
|
|
* hConvList [I] Handle to conversation list
|
|
|
|
* pCC [I] Pointer to structure with context data
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Handle to new conversation list
|
|
|
|
* Failure: 0
|
|
|
|
*/
|
|
|
|
HCONVLIST WINAPI DdeConnectList(DWORD idInst, HSZ hszService, HSZ hszTopic,
|
2002-12-19 02:18:49 +01:00
|
|
|
HCONVLIST hConvList, PCONVCONTEXT pCC)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2006-09-30 00:25:15 +02:00
|
|
|
FIXME("(%d,%p,%p,%p,%p): stub\n", idInst, hszService, hszTopic, hConvList, pCC);
|
2001-06-23 01:02:48 +02:00
|
|
|
return (HCONVLIST)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* DdeQueryNextServer [USER32.@]
|
|
|
|
*/
|
|
|
|
HCONV WINAPI DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev)
|
|
|
|
{
|
2002-11-22 22:22:14 +01:00
|
|
|
FIXME("(%p,%p): stub\n", hConvList, hConvPrev);
|
2001-06-23 01:02:48 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DdeDisconnectList [USER32.@] Destroys list and terminates conversations
|
|
|
|
*
|
2001-08-10 00:07:22 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hConvList [I] Handle to conversation list
|
|
|
|
*
|
2001-06-23 01:02:48 +02:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
BOOL WINAPI DdeDisconnectList(HCONVLIST hConvList)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2002-11-22 22:22:14 +01:00
|
|
|
FIXME("(%p): stub\n", hConvList);
|
2001-06-23 01:02:48 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* DdeConnect (USER32.@)
|
|
|
|
*/
|
|
|
|
HCONV WINAPI DdeConnect(DWORD idInst, HSZ hszService, HSZ hszTopic,
|
2002-12-19 02:18:49 +01:00
|
|
|
PCONVCONTEXT pCC)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
HWND hwndClient;
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_INSTANCE* pInstance;
|
|
|
|
WDML_CONV* pConv = NULL;
|
|
|
|
ATOM aSrv = 0, aTpc = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-09-30 00:25:15 +02:00
|
|
|
TRACE("(0x%x,%p,%p,%p)\n", idInst, hszService, hszTopic, pCC);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
pInstance = WDML_GetInstance(idInst);
|
|
|
|
if (!pInstance)
|
2006-11-15 14:22:35 +01:00
|
|
|
return NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/* make sure this conv is never created */
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_FindConv(pInstance, WDML_CLIENT_SIDE, hszService, hszTopic);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (pConv != NULL)
|
|
|
|
{
|
2003-05-20 01:27:16 +02:00
|
|
|
ERR("This Conv already exists: (%p)\n", pConv);
|
2006-11-15 14:22:35 +01:00
|
|
|
return NULL;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/* we need to establish a conversation with
|
|
|
|
server, so create a window for it */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
if (pInstance->unicode)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW wndclass;
|
|
|
|
|
|
|
|
wndclass.cbSize = sizeof(wndclass);
|
|
|
|
wndclass.style = 0;
|
|
|
|
wndclass.lpfnWndProc = WDML_ClientProc;
|
|
|
|
wndclass.cbClsExtra = 0;
|
|
|
|
wndclass.cbWndExtra = 2 * sizeof(ULONG_PTR);
|
|
|
|
wndclass.hInstance = 0;
|
|
|
|
wndclass.hIcon = 0;
|
|
|
|
wndclass.hCursor = 0;
|
|
|
|
wndclass.hbrBackground = 0;
|
|
|
|
wndclass.lpszMenuName = NULL;
|
|
|
|
wndclass.lpszClassName = WDML_szClientConvClassW;
|
|
|
|
wndclass.hIconSm = 0;
|
|
|
|
|
|
|
|
RegisterClassExW(&wndclass);
|
|
|
|
|
|
|
|
hwndClient = CreateWindowW(WDML_szClientConvClassW, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WNDCLASSEXA wndclass;
|
|
|
|
|
|
|
|
wndclass.cbSize = sizeof(wndclass);
|
|
|
|
wndclass.style = 0;
|
|
|
|
wndclass.lpfnWndProc = WDML_ClientProc;
|
|
|
|
wndclass.cbClsExtra = 0;
|
|
|
|
wndclass.cbWndExtra = 2 * sizeof(ULONG_PTR);
|
|
|
|
wndclass.hInstance = 0;
|
|
|
|
wndclass.hIcon = 0;
|
|
|
|
wndclass.hCursor = 0;
|
|
|
|
wndclass.hbrBackground = 0;
|
|
|
|
wndclass.lpszMenuName = NULL;
|
|
|
|
wndclass.lpszClassName = WDML_szClientConvClassA;
|
|
|
|
wndclass.hIconSm = 0;
|
|
|
|
|
|
|
|
RegisterClassExA(&wndclass);
|
|
|
|
|
|
|
|
hwndClient = CreateWindowA(WDML_szClientConvClassA, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2005-02-14 12:53:15 +01:00
|
|
|
SetWindowLongPtrW(hwndClient, GWL_WDML_INSTANCE, (ULONG_PTR)pInstance);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (hszService)
|
|
|
|
{
|
|
|
|
aSrv = WDML_MakeAtomFromHsz(hszService);
|
|
|
|
if (!aSrv) goto theEnd;
|
|
|
|
}
|
|
|
|
if (hszTopic)
|
|
|
|
{
|
|
|
|
aTpc = WDML_MakeAtomFromHsz(hszTopic);
|
|
|
|
if (!aTpc) goto theEnd;
|
|
|
|
}
|
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
/* note: sent messages shall not use packing */
|
2003-10-31 05:18:55 +01:00
|
|
|
SendMessageTimeoutW( HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndClient, MAKELPARAM(aSrv, aTpc),
|
|
|
|
SMTO_ABORTIFHUNG, 2000, NULL );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pInstance = WDML_GetInstance(idInst);
|
|
|
|
if (!pInstance)
|
|
|
|
{
|
|
|
|
goto theEnd;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/* At this point, Client WM_DDE_ACK should have saved hwndServer
|
|
|
|
for this instance id and hwndClient if server responds.
|
|
|
|
So get HCONV and return it. And add it to conv list */
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConvFromWnd(hwndClient);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (pConv == NULL || pConv->hwndServer == 0)
|
|
|
|
{
|
2005-11-11 11:53:44 +01:00
|
|
|
WARN("Done with INITIATE, but no Server window available\n");
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = NULL;
|
|
|
|
goto theEnd;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE("Connected to Server window (%p)\n", pConv->hwndServer);
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->wConvst = XST_CONNECTED;
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/* finish init of pConv */
|
|
|
|
if (pCC != NULL)
|
|
|
|
{
|
|
|
|
pConv->convContext = *pCC;
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
else
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
memset(&pConv->convContext, 0, sizeof(pConv->convContext));
|
|
|
|
pConv->convContext.cb = sizeof(pConv->convContext);
|
2005-07-08 13:33:09 +02:00
|
|
|
pConv->convContext.iCodePage = (pInstance->unicode) ? CP_WINUNICODE : CP_WINANSI;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
theEnd:
|
|
|
|
|
|
|
|
if (aSrv) GlobalDeleteAtom(aSrv);
|
|
|
|
if (aTpc) GlobalDeleteAtom(aTpc);
|
|
|
|
return (HCONV)pConv;
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* DdeReconnect (DDEML.37)
|
|
|
|
* DdeReconnect (USER32.@)
|
|
|
|
*/
|
|
|
|
HCONV WINAPI DdeReconnect(HCONV hConv)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_CONV* pConv;
|
|
|
|
WDML_CONV* pNewConv = NULL;
|
|
|
|
ATOM aSrv = 0, aTpc = 0;
|
|
|
|
|
2003-05-20 01:27:16 +02:00
|
|
|
TRACE("(%p)\n", hConv);
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConv(hConv, FALSE);
|
|
|
|
if (pConv != NULL && (pConv->wStatus & ST_CLIENT))
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* to reestablist a connection, we have to make sure that:
|
|
|
|
* 1/ pConv is the converstation attached to the client window (it wouldn't be
|
2002-06-01 01:06:46 +02:00
|
|
|
* if a call to DdeReconnect would have already been done...)
|
2001-08-10 00:07:22 +02:00
|
|
|
* FIXME: is this really an error ???
|
|
|
|
* 2/ the pConv conversation had really been deconnected
|
|
|
|
*/
|
|
|
|
if (pConv == WDML_GetConvFromWnd(pConv->hwndClient) &&
|
|
|
|
(pConv->wStatus & ST_TERMINATED) && !(pConv->wStatus & ST_CONNECTED))
|
|
|
|
{
|
|
|
|
HWND hwndClient = pConv->hwndClient;
|
|
|
|
HWND hwndServer = pConv->hwndServer;
|
|
|
|
|
2005-02-14 12:53:15 +01:00
|
|
|
SetWindowLongPtrW(pConv->hwndClient, GWL_WDML_CONVERSATION, 0);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
aSrv = WDML_MakeAtomFromHsz(pConv->hszService);
|
|
|
|
aTpc = WDML_MakeAtomFromHsz(pConv->hszTopic);
|
|
|
|
if (!aSrv || !aTpc) goto theEnd;
|
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
/* note: sent messages shall not use packing */
|
2005-02-14 12:53:15 +01:00
|
|
|
ret = SendMessageW(hwndServer, WM_DDE_INITIATE, (WPARAM)hwndClient,
|
2002-01-18 20:30:15 +01:00
|
|
|
MAKELPARAM(aSrv, aTpc));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConv(hConv, FALSE);
|
|
|
|
if (pConv == NULL)
|
|
|
|
{
|
|
|
|
FIXME("Should fail reconnection\n");
|
|
|
|
goto theEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret && (pNewConv = WDML_GetConvFromWnd(pConv->hwndClient)) != NULL)
|
|
|
|
{
|
|
|
|
/* re-establish all links... */
|
|
|
|
WDML_LINK* pLink;
|
|
|
|
|
|
|
|
for (pLink = pConv->instance->links[WDML_CLIENT_SIDE]; pLink; pLink = pLink->next)
|
|
|
|
{
|
|
|
|
if (pLink->hConv == hConv)
|
|
|
|
{
|
|
|
|
/* try to reestablish the links... */
|
2002-06-01 01:06:46 +02:00
|
|
|
DdeClientTransaction(NULL, 0, (HCONV)pNewConv, pLink->hszItem, pLink->uFmt,
|
2001-08-10 00:07:22 +02:00
|
|
|
pLink->transactionType, 1000, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* reset the conversation as it was */
|
2005-02-14 12:53:15 +01:00
|
|
|
SetWindowLongPtrW(pConv->hwndClient, GWL_WDML_CONVERSATION, (ULONG_PTR)pConv);
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
theEnd:
|
|
|
|
|
|
|
|
if (aSrv) GlobalDeleteAtom(aSrv);
|
|
|
|
if (aTpc) GlobalDeleteAtom(aTpc);
|
|
|
|
return (HCONV)pNewConv;
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
2001-08-10 00:07:22 +02:00
|
|
|
* WDML_ClientQueueAdvise
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
|
|
|
* Creates and queue an WM_DDE_ADVISE transaction
|
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
static WDML_XACT* WDML_ClientQueueAdvise(WDML_CONV* pConv, UINT wType, UINT wFmt, HSZ hszItem)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
DDEADVISE* pDdeAdvise;
|
|
|
|
WDML_XACT* pXAct;
|
2001-08-10 00:07:22 +02:00
|
|
|
ATOM atom;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
TRACE("XTYP_ADVSTART (with%s data) transaction\n", (wType & XTYPF_NODATA) ? "out" : "");
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
atom = WDML_MakeAtomFromHsz(hszItem);
|
|
|
|
if (!atom) return NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_ADVISE, wFmt, hszItem);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (!pXAct)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
GlobalDeleteAtom(atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
return NULL;
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->wType = wType & ~0x0F;
|
|
|
|
pXAct->hMem = GlobalAlloc(GHND | GMEM_DDESHARE, sizeof(DDEADVISE));
|
2002-01-18 20:30:15 +01:00
|
|
|
/* FIXME: hMem is unfreed for now... should be deleted in server */
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/* pack DdeAdvise */
|
2001-08-10 00:07:22 +02:00
|
|
|
pDdeAdvise = (DDEADVISE*)GlobalLock(pXAct->hMem);
|
2001-06-23 01:02:48 +02:00
|
|
|
pDdeAdvise->fAckReq = (wType & XTYPF_ACKREQ) ? TRUE : FALSE;
|
|
|
|
pDdeAdvise->fDeferUpd = (wType & XTYPF_NODATA) ? TRUE : FALSE;
|
|
|
|
pDdeAdvise->cfFormat = wFmt;
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalUnlock(pXAct->hMem);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2003-05-20 01:27:16 +02:00
|
|
|
pXAct->lParam = PackDDElParam(WM_DDE_ADVISE, (UINT_PTR)pXAct->hMem, atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
return pXAct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandleAdviseReply
|
|
|
|
*
|
|
|
|
* handles the reply to an advise request
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleAdviseReply(WDML_CONV* pConv, MSG* msg, WDML_XACT* pXAct, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
DDEACK ddeAck;
|
2003-05-20 01:27:16 +02:00
|
|
|
UINT_PTR uiLo, uiHi;
|
2001-08-10 00:07:22 +02:00
|
|
|
HSZ hsz;
|
|
|
|
|
2002-09-04 21:37:01 +02:00
|
|
|
if (msg->message != WM_DDE_ACK || WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi);
|
2001-08-10 00:07:22 +02:00
|
|
|
hsz = WDML_MakeHszFromAtom(pConv->instance, uiHi);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (DdeCmpStringHandles(hsz, pXAct->hszItem) != 0)
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_PASS;
|
|
|
|
|
|
|
|
GlobalDeleteAtom(uiHi);
|
2001-08-10 00:07:22 +02:00
|
|
|
FreeDDElParam(WM_DDE_ACK, msg->lParam);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
if (ack) *ack = uiLo;
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_ExtractAck(uiLo, &ddeAck);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
if (ddeAck.fAck)
|
|
|
|
{
|
|
|
|
WDML_LINK* pLink;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/* billx: first to see if the link is already created. */
|
2002-06-01 01:06:46 +02:00
|
|
|
pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_CLIENT_SIDE,
|
2002-01-18 20:30:15 +01:00
|
|
|
pXAct->hszItem, TRUE, pXAct->wFmt);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (pLink != NULL)
|
|
|
|
{
|
2001-06-23 01:02:48 +02:00
|
|
|
/* we found a link, and only need to modify it in case it changes */
|
2001-08-10 00:07:22 +02:00
|
|
|
pLink->transactionType = pXAct->wType;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
WDML_AddLink(pConv->instance, (HCONV)pConv, WDML_CLIENT_SIDE,
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->wType, pXAct->hszItem, pXAct->wFmt);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2002-01-18 20:30:15 +01:00
|
|
|
pXAct->hDdeData = (HDDEDATA)1;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-01-18 20:30:15 +01:00
|
|
|
TRACE("Returning FALSE on XTYP_ADVSTART - fAck was FALSE\n");
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalFree(pXAct->hMem);
|
2002-12-02 19:10:57 +01:00
|
|
|
pXAct->hDdeData = NULL;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-08-10 00:07:22 +02:00
|
|
|
* WDML_ClientQueueUnadvise
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
|
|
|
* queues an unadvise transaction
|
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
static WDML_XACT* WDML_ClientQueueUnadvise(WDML_CONV* pConv, UINT wFmt, HSZ hszItem)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
WDML_XACT* pXAct;
|
2001-08-10 00:07:22 +02:00
|
|
|
ATOM atom;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
TRACE("XTYP_ADVSTOP transaction\n");
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
atom = WDML_MakeAtomFromHsz(hszItem);
|
|
|
|
if (!atom) return NULL;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_UNADVISE, wFmt, hszItem);
|
|
|
|
if (!pXAct)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalDeleteAtom(atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
/* end advise loop: post WM_DDE_UNADVISE to server to terminate link
|
2002-06-01 01:06:46 +02:00
|
|
|
* on the specified item.
|
2001-08-10 00:07:22 +02:00
|
|
|
*/
|
|
|
|
pXAct->lParam = PackDDElParam(WM_DDE_UNADVISE, wFmt, atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
return pXAct;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandleUnadviseReply
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleUnadviseReply(WDML_CONV* pConv, MSG* msg, WDML_XACT* pXAct, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
DDEACK ddeAck;
|
2003-05-20 01:27:16 +02:00
|
|
|
UINT_PTR uiLo, uiHi;
|
2001-08-10 00:07:22 +02:00
|
|
|
HSZ hsz;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-09-04 21:37:01 +02:00
|
|
|
if (msg->message != WM_DDE_ACK || WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi);
|
2001-08-10 00:07:22 +02:00
|
|
|
hsz = WDML_MakeHszFromAtom(pConv->instance, uiHi);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (DdeCmpStringHandles(hsz, pXAct->hszItem) != 0)
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_PASS;
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
FreeDDElParam(WM_DDE_ACK, msg->lParam);
|
2001-06-23 01:02:48 +02:00
|
|
|
GlobalDeleteAtom(uiHi);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
if (ack) *ack = uiLo;
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_ExtractAck(uiLo, &ddeAck);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
TRACE("WM_DDE_ACK received while waiting for a timeout\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
if (!ddeAck.fAck)
|
|
|
|
{
|
2002-01-18 20:30:15 +01:00
|
|
|
TRACE("Returning FALSE on XTYP_ADVSTOP - fAck was FALSE\n");
|
2002-12-02 19:10:57 +01:00
|
|
|
pXAct->hDdeData = NULL;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* billx: remove the link */
|
2002-06-01 01:06:46 +02:00
|
|
|
WDML_RemoveLink(pConv->instance, (HCONV)pConv, WDML_CLIENT_SIDE,
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->hszItem, pXAct->wFmt);
|
2002-01-18 20:30:15 +01:00
|
|
|
pXAct->hDdeData = (HDDEDATA)1;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
return WDML_QS_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-08-10 00:07:22 +02:00
|
|
|
* WDML_ClientQueueRequest
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
static WDML_XACT* WDML_ClientQueueRequest(WDML_CONV* pConv, UINT wFmt, HSZ hszItem)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
WDML_XACT* pXAct;
|
2001-08-10 00:07:22 +02:00
|
|
|
ATOM atom;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
TRACE("XTYP_REQUEST transaction\n");
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
atom = WDML_MakeAtomFromHsz(hszItem);
|
|
|
|
if (!atom) return NULL;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_REQUEST, wFmt, hszItem);
|
|
|
|
if (!pXAct)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalDeleteAtom(atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
pXAct->lParam = PackDDElParam(WM_DDE_REQUEST, wFmt, atom);
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return pXAct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandleRequestReply
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleRequestReply(WDML_CONV* pConv, MSG* msg, WDML_XACT* pXAct, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
DDEACK ddeAck;
|
|
|
|
WINE_DDEHEAD wdh;
|
2003-05-20 01:27:16 +02:00
|
|
|
UINT_PTR uiLo, uiHi;
|
2001-08-10 00:07:22 +02:00
|
|
|
HSZ hsz;
|
|
|
|
|
2002-09-04 21:37:01 +02:00
|
|
|
if (WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer)
|
2001-08-10 00:07:22 +02:00
|
|
|
return WDML_QS_PASS;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
switch (msg->message)
|
|
|
|
{
|
|
|
|
case WM_DDE_ACK:
|
2002-01-18 20:30:15 +01:00
|
|
|
UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi);
|
|
|
|
FreeDDElParam(WM_DDE_ACK, msg->lParam);
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalDeleteAtom(uiHi);
|
2005-07-08 13:33:09 +02:00
|
|
|
if (ack) *ack = uiLo;
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_ExtractAck(uiLo, &ddeAck);
|
2001-06-23 01:02:48 +02:00
|
|
|
pXAct->hDdeData = 0;
|
2001-08-10 00:07:22 +02:00
|
|
|
if (ddeAck.fAck)
|
|
|
|
ERR("Positive answer should appear in NACK for a request, assuming negative\n");
|
2001-06-23 01:02:48 +02:00
|
|
|
TRACE("Negative answer...\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DDE_DATA:
|
2002-01-18 20:30:15 +01:00
|
|
|
UnpackDDElParam(WM_DDE_DATA, msg->lParam, &uiLo, &uiHi);
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("Got the result (%08lx)\n", uiLo);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
hsz = WDML_MakeHszFromAtom(pConv->instance, uiHi);
|
|
|
|
|
|
|
|
if (DdeCmpStringHandles(hsz, pXAct->hszItem) != 0)
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_PASS;
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
pXAct->hDdeData = WDML_Global2DataHandle((HGLOBAL)uiLo, &wdh);
|
|
|
|
if (wdh.fRelease)
|
|
|
|
{
|
|
|
|
GlobalFree((HGLOBAL)uiLo);
|
|
|
|
}
|
|
|
|
if (wdh.fAckReq)
|
|
|
|
{
|
2002-01-18 20:30:15 +01:00
|
|
|
WDML_PostAck(pConv, WDML_CLIENT_SIDE, 0, FALSE, TRUE, uiHi, msg->lParam, WM_DDE_DATA);
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GlobalDeleteAtom(uiHi);
|
2002-01-18 20:30:15 +01:00
|
|
|
FreeDDElParam(WM_DDE_ACK, msg->lParam);
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-01-18 20:30:15 +01:00
|
|
|
FreeDDElParam(msg->message, msg->lParam);
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return WDML_QS_HANDLED;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
2001-08-10 00:07:22 +02:00
|
|
|
* WDML_BuildExecuteCommand
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
2001-08-10 00:07:22 +02:00
|
|
|
* Creates a DDE block suitable for sending in WM_DDE_COMMAND
|
|
|
|
* It also takes care of string conversion between the two window procedures
|
2001-06-23 01:02:48 +02:00
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
static HGLOBAL WDML_BuildExecuteCommand(WDML_CONV* pConv, LPCVOID pData, DWORD cbData)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
HGLOBAL hMem;
|
|
|
|
BOOL clientUnicode, serverUnicode;
|
|
|
|
DWORD memSize;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
clientUnicode = pConv->instance->unicode;
|
|
|
|
TRACE("client %p uses unicode = %d\n", pConv->hwndClient, clientUnicode);
|
|
|
|
/* FIXME: how exactly Windows determines what to use for the server side? */
|
|
|
|
serverUnicode = IsWindowUnicode(pConv->hwndServer) && IsWindowUnicode(pConv->hwndClient);
|
|
|
|
TRACE("server %p uses unicode = %d\n", pConv->hwndServer, serverUnicode);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (clientUnicode == serverUnicode)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
memSize = cbData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (clientUnicode)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
memSize = WideCharToMultiByte( CP_ACP, 0, pData, cbData, NULL, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-14 23:46:25 +02:00
|
|
|
memSize = MultiByteToWideChar( CP_ACP, 0, pData, cbData, NULL, 0) * sizeof(WCHAR);
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, memSize);
|
|
|
|
|
|
|
|
if (hMem)
|
|
|
|
{
|
2005-07-06 12:36:28 +02:00
|
|
|
LPSTR pDst;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pDst = GlobalLock(hMem);
|
|
|
|
if (pDst)
|
|
|
|
{
|
|
|
|
if (clientUnicode == serverUnicode)
|
|
|
|
{
|
|
|
|
memcpy(pDst, pData, cbData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (clientUnicode)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, pData, cbData, pDst, memSize, NULL, NULL);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-14 23:46:25 +02:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, pData, cbData, (LPWSTR)pDst, memSize/sizeof(WCHAR));
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
GlobalUnlock(hMem);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalFree(hMem);
|
|
|
|
hMem = 0;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
return hMem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_ClientQueueExecute
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2006-11-18 15:24:55 +01:00
|
|
|
static WDML_XACT* WDML_ClientQueueExecute(WDML_CONV* pConv, LPVOID pData, DWORD cbData)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
WDML_XACT* pXAct;
|
|
|
|
|
|
|
|
TRACE("XTYP_EXECUTE transaction\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_EXECUTE, 0, 0);
|
|
|
|
if (!pXAct)
|
|
|
|
return NULL;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (cbData == (DWORD)-1)
|
|
|
|
{
|
2006-11-18 15:24:55 +01:00
|
|
|
HDDEDATA hDdeData = pData;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pData = DdeAccessData(hDdeData, &cbData);
|
|
|
|
if (pData)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->hMem = WDML_BuildExecuteCommand(pConv, pData, cbData);
|
|
|
|
DdeUnaccessData(hDdeData);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
else
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->hMem = WDML_BuildExecuteCommand(pConv, pData, cbData);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2002-11-22 21:43:01 +01:00
|
|
|
pXAct->lParam = (LPARAM)pXAct->hMem;
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return pXAct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandleExecuteReply
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleExecuteReply(WDML_CONV* pConv, MSG* msg, WDML_XACT* pXAct, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
DDEACK ddeAck;
|
2003-05-20 01:27:16 +02:00
|
|
|
UINT_PTR uiLo, uiHi;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-09-04 21:37:01 +02:00
|
|
|
if (msg->message != WM_DDE_ACK || WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi);
|
|
|
|
FreeDDElParam(WM_DDE_ACK, msg->lParam);
|
|
|
|
|
2002-11-22 21:43:01 +01:00
|
|
|
if ((HANDLE)uiHi != pXAct->hMem)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2002-01-18 20:30:15 +01:00
|
|
|
return WDML_QS_PASS;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
if (ack) *ack = uiLo;
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_ExtractAck(uiLo, &ddeAck);
|
2002-10-19 02:52:55 +02:00
|
|
|
pXAct->hDdeData = (HDDEDATA)(UINT_PTR)ddeAck.fAck;
|
2002-01-18 20:30:15 +01:00
|
|
|
|
2004-06-14 18:58:19 +02:00
|
|
|
TRACE("hDdeData = %p\n", pXAct->hDdeData);
|
|
|
|
pConv->instance->lastError = (pXAct->hDdeData != 0) ? DMLERR_NO_ERROR : DMLERR_NOTPROCESSED;
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-08-10 00:07:22 +02:00
|
|
|
* WDML_ClientQueuePoke
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2006-11-18 15:24:55 +01:00
|
|
|
static WDML_XACT* WDML_ClientQueuePoke(WDML_CONV* pConv, LPVOID pData, DWORD cbData,
|
2001-08-10 00:07:22 +02:00
|
|
|
UINT wFmt, HSZ hszItem)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
WDML_XACT* pXAct;
|
2001-08-10 00:07:22 +02:00
|
|
|
ATOM atom;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
TRACE("XTYP_POKE transaction\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
atom = WDML_MakeAtomFromHsz(hszItem);
|
|
|
|
if (!atom) return NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_POKE, wFmt, hszItem);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (!pXAct)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
GlobalDeleteAtom(atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
return NULL;
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
if (cbData == (DWORD)-1)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->hMem = (HDDEDATA)pData;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DDEPOKE* ddePoke;
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct->hMem = GlobalAlloc(GHND | GMEM_DDESHARE, sizeof(DDEPOKE) + cbData);
|
|
|
|
ddePoke = GlobalLock(pXAct->hMem);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (ddePoke)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
memcpy(ddePoke->Value, pData, cbData);
|
|
|
|
ddePoke->fRelease = FALSE; /* FIXME: app owned ? */
|
|
|
|
ddePoke->cfFormat = wFmt;
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalUnlock(pXAct->hMem);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-20 01:27:16 +02:00
|
|
|
pXAct->lParam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)pXAct->hMem, atom);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
return pXAct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandlePokeReply
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandlePokeReply(WDML_CONV* pConv, MSG* msg, WDML_XACT* pXAct, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2003-05-20 01:27:16 +02:00
|
|
|
UINT_PTR uiLo, uiHi;
|
2001-08-10 00:07:22 +02:00
|
|
|
HSZ hsz;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-09-04 21:37:01 +02:00
|
|
|
if (msg->message != WM_DDE_ACK && WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi);
|
2001-08-10 00:07:22 +02:00
|
|
|
hsz = WDML_MakeHszFromAtom(pConv->instance, uiHi);
|
|
|
|
if (DdeCmpStringHandles(hsz, pXAct->hszItem) != 0)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
FreeDDElParam(WM_DDE_ACK, msg->lParam);
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalDeleteAtom(uiHi);
|
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
if (ack) *ack = uiLo;
|
2001-08-10 00:07:22 +02:00
|
|
|
GlobalFree(pXAct->hMem);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
pXAct->hDdeData = (HDDEDATA)TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
/******************************************************************
|
|
|
|
* WDML_ClientQueueTerminate
|
|
|
|
*
|
|
|
|
* Creates and queue an WM_DDE_TERMINATE transaction
|
|
|
|
*/
|
|
|
|
static WDML_XACT* WDML_ClientQueueTerminate(WDML_CONV* pConv)
|
|
|
|
{
|
|
|
|
WDML_XACT* pXAct;
|
|
|
|
|
|
|
|
pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_TERMINATE, 0, 0);
|
|
|
|
if (!pXAct)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pXAct->lParam = 0;
|
|
|
|
pConv->wStatus &= ~ST_CONNECTED;
|
|
|
|
|
|
|
|
return pXAct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandleTerminateReply
|
|
|
|
*
|
|
|
|
* handles the reply to a terminate request
|
|
|
|
*/
|
2006-11-21 07:43:48 +01:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleTerminateReply(WDML_CONV* pConv, MSG* msg)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
if (msg->message != WM_DDE_TERMINATE)
|
|
|
|
{
|
|
|
|
/* FIXME: should delete data passed here */
|
|
|
|
return WDML_QS_SWALLOWED;
|
|
|
|
}
|
|
|
|
|
2002-09-04 21:37:01 +02:00
|
|
|
if (WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
FIXME("hmmm shouldn't happen\n");
|
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
if (!pConv->instance->CBFflags & CBF_SKIP_DISCONNECTS)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
WDML_InvokeCallback(pConv->instance, XTYP_DISCONNECT, 0, (HCONV)pConv,
|
2001-08-10 00:07:22 +02:00
|
|
|
0, 0, 0, 0, (pConv->wStatus & ST_ISSELF) ? 1 : 0);
|
|
|
|
}
|
|
|
|
WDML_RemoveConv(pConv, WDML_CLIENT_SIDE);
|
|
|
|
return WDML_QS_HANDLED;
|
|
|
|
}
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/******************************************************************
|
2006-11-21 07:43:48 +01:00
|
|
|
* WDML_HandleIncomingData
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleIncomingData(WDML_CONV* pConv, MSG* msg, HDDEDATA* hdd)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2003-05-20 01:27:16 +02:00
|
|
|
UINT_PTR uiLo, uiHi;
|
2001-08-10 00:07:22 +02:00
|
|
|
HDDEDATA hDdeDataIn, hDdeDataOut;
|
|
|
|
WDML_LINK* pLink;
|
|
|
|
WINE_DDEHEAD wdh;
|
|
|
|
HSZ hsz;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
TRACE("WM_DDE_DATA message received in the Client Proc!\n");
|
|
|
|
/* wParam -- sending window handle */
|
|
|
|
/* lParam -- hDdeData & item HSZ */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
UnpackDDElParam(WM_DDE_DATA, msg->lParam, &uiLo, &uiHi);
|
2001-08-10 00:07:22 +02:00
|
|
|
hsz = WDML_MakeHszFromAtom(pConv->instance, uiHi);
|
|
|
|
|
|
|
|
hDdeDataIn = WDML_Global2DataHandle((HGLOBAL)uiLo, &wdh);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* billx:
|
2001-06-23 01:02:48 +02:00
|
|
|
* For hot link, data should be passed to its callback with
|
|
|
|
* XTYP_ADVDATA and callback should return the proper status.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_CLIENT_SIDE, hsz,
|
2002-01-18 20:30:15 +01:00
|
|
|
uiLo ? TRUE : FALSE, wdh.cfFormat);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!pLink)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
WDML_DecHSZ(pConv->instance, hsz);
|
2002-01-18 20:30:15 +01:00
|
|
|
DdeFreeDataHandle(hDdeDataIn);
|
2001-08-10 00:07:22 +02:00
|
|
|
return WDML_QS_PASS;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (hDdeDataIn != 0 && wdh.fAckReq)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2002-01-18 20:30:15 +01:00
|
|
|
WDML_PostAck(pConv, WDML_CLIENT_SIDE, 0, FALSE, TRUE, uiHi, msg->lParam, WM_DDE_DATA);
|
2001-08-10 00:07:22 +02:00
|
|
|
if (msg->lParam)
|
|
|
|
msg->lParam = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GlobalDeleteAtom(uiHi);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
hDdeDataOut = WDML_InvokeCallback(pConv->instance, XTYP_ADVDATA, pLink->uFmt, pLink->hConv,
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->hszTopic, pLink->hszItem, hDdeDataIn, 0, 0);
|
2002-01-18 20:30:15 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (hDdeDataOut != (HDDEDATA)DDE_FACK || wdh.fRelease)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
2002-11-22 21:43:01 +01:00
|
|
|
if (uiLo) GlobalFree((HANDLE)uiLo);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2002-01-18 20:30:15 +01:00
|
|
|
|
|
|
|
DdeFreeDataHandle(hDdeDataIn);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_DecHSZ(pConv->instance, hsz);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (msg->lParam)
|
|
|
|
FreeDDElParam(WM_DDE_DATA, msg->lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-08-10 00:07:22 +02:00
|
|
|
* WDML_HandleIncomingTerminate
|
2001-06-23 01:02:48 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleIncomingTerminate(WDML_CONV* pConv, MSG* msg, HDDEDATA* hdd)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2002-09-04 21:37:01 +02:00
|
|
|
if (pConv->hwndServer != WIN_GetFullHandle((HWND)msg->wParam))
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_PASS;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->wStatus |= ST_TERMINATED;
|
|
|
|
if (!pConv->instance->CBFflags & CBF_SKIP_DISCONNECTS)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
WDML_InvokeCallback(pConv->instance, XTYP_DISCONNECT, 0, (HCONV)pConv,
|
2001-08-10 00:07:22 +02:00
|
|
|
0, 0, 0, 0, (pConv->wStatus & ST_ISSELF) ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (pConv->wStatus & ST_CONNECTED)
|
|
|
|
{
|
|
|
|
/* don't care about result code (if server exists or not) */
|
2005-02-14 12:53:15 +01:00
|
|
|
PostMessageW(pConv->hwndServer, WM_DDE_TERMINATE, (WPARAM)pConv->hwndClient, 0L);
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->wStatus &= ~ST_CONNECTED;
|
|
|
|
}
|
|
|
|
/* have to keep connection around to allow reconnection */
|
2001-06-23 01:02:48 +02:00
|
|
|
return WDML_QS_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_HandleReply
|
|
|
|
*
|
|
|
|
* handles any incoming reply, and try to match to an already sent request
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static WDML_QUEUE_STATE WDML_HandleReply(WDML_CONV* pConv, MSG* msg, HDDEDATA* hdd, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_XACT* pXAct = pConv->transactions;
|
2001-06-23 01:02:48 +02:00
|
|
|
WDML_QUEUE_STATE qs;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (pConv->transactions)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
/* first check message against a pending transaction, if any */
|
|
|
|
switch (pXAct->ddeMsg)
|
|
|
|
{
|
|
|
|
case WM_DDE_ADVISE:
|
2005-07-08 13:33:09 +02:00
|
|
|
qs = WDML_HandleAdviseReply(pConv, msg, pXAct, ack);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case WM_DDE_UNADVISE:
|
2005-07-08 13:33:09 +02:00
|
|
|
qs = WDML_HandleUnadviseReply(pConv, msg, pXAct, ack);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case WM_DDE_EXECUTE:
|
2005-07-08 13:33:09 +02:00
|
|
|
qs = WDML_HandleExecuteReply(pConv, msg, pXAct, ack);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case WM_DDE_REQUEST:
|
2005-07-08 13:33:09 +02:00
|
|
|
qs = WDML_HandleRequestReply(pConv, msg, pXAct, ack);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case WM_DDE_POKE:
|
2005-07-08 13:33:09 +02:00
|
|
|
qs = WDML_HandlePokeReply(pConv, msg, pXAct, ack);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
2001-08-10 00:07:22 +02:00
|
|
|
case WM_DDE_TERMINATE:
|
2006-11-21 07:43:48 +01:00
|
|
|
qs = WDML_HandleTerminateReply(pConv, msg);
|
2001-08-10 00:07:22 +02:00
|
|
|
break;
|
2001-06-23 01:02:48 +02:00
|
|
|
default:
|
|
|
|
qs = WDML_QS_ERROR;
|
|
|
|
FIXME("oooch\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qs = WDML_QS_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now check the results */
|
2002-06-01 01:06:46 +02:00
|
|
|
switch (qs)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
case WDML_QS_ERROR:
|
2001-08-10 00:07:22 +02:00
|
|
|
case WDML_QS_SWALLOWED:
|
2001-06-23 01:02:48 +02:00
|
|
|
*hdd = 0;
|
|
|
|
break;
|
|
|
|
case WDML_QS_HANDLED:
|
|
|
|
/* ok, we have resolved a pending transaction
|
2006-11-21 07:43:48 +01:00
|
|
|
* notify callback if asynchronous.
|
2001-06-23 01:02:48 +02:00
|
|
|
*/
|
2001-08-10 00:07:22 +02:00
|
|
|
if (pXAct->dwTimeout == TIMEOUT_ASYNC && pXAct->ddeMsg != WM_DDE_TERMINATE)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_InvokeCallback(pConv->instance, XTYP_XACT_COMPLETE, pXAct->wFmt,
|
|
|
|
(HCONV)pConv, pConv->hszTopic, pXAct->hszItem,
|
|
|
|
pXAct->hDdeData, MAKELONG(0, pXAct->xActID), 0 /* FIXME */);
|
|
|
|
qs = WDML_QS_PASS;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*hdd = pXAct->hDdeData;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WDML_QS_PASS:
|
2002-01-18 20:30:15 +01:00
|
|
|
/* no pending transaction found, try a warm/hot link or a termination request */
|
2001-06-23 01:02:48 +02:00
|
|
|
switch (msg->message)
|
|
|
|
{
|
|
|
|
case WM_DDE_DATA:
|
2001-08-10 00:07:22 +02:00
|
|
|
qs = WDML_HandleIncomingData(pConv, msg, hdd);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case WM_DDE_TERMINATE:
|
2001-08-10 00:07:22 +02:00
|
|
|
qs = WDML_HandleIncomingTerminate(pConv, msg, hdd);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2001-08-10 00:07:22 +02:00
|
|
|
case WDML_QS_BLOCK:
|
|
|
|
FIXME("shouldn't be used on client side\n");
|
|
|
|
break;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return qs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WDML_SyncWaitTransactionReply
|
|
|
|
*
|
|
|
|
* waits until an answer for a sent request is received
|
|
|
|
* time out is also handled. only used for synchronous transactions
|
|
|
|
*/
|
2005-07-08 13:33:09 +02:00
|
|
|
static HDDEDATA WDML_SyncWaitTransactionReply(HCONV hConv, DWORD dwTimeout, WDML_XACT* pXAct, DWORD *ack)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
DWORD dwTime;
|
|
|
|
DWORD err;
|
|
|
|
WDML_CONV* pConv;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2006-09-30 00:25:15 +02:00
|
|
|
TRACE("Starting wait for a timeout of %d ms\n", dwTimeout);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
/* FIXME: time 32 bit wrap around */
|
|
|
|
dwTimeout += GetCurrentTime();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
while ((dwTime = GetCurrentTime()) < dwTimeout)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
/* we cannot be in the crit sect all the time because when client and server run in a
|
2001-06-23 01:02:48 +02:00
|
|
|
* single process they need to share the access to the internal data
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
if (MsgWaitForMultipleObjects(0, NULL, FALSE,
|
2002-01-18 20:30:15 +01:00
|
|
|
dwTimeout - dwTime, QS_POSTMESSAGE) == WAIT_OBJECT_0)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
MSG msg;
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
while (PeekMessageW(&msg, 0, WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE))
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2005-07-08 13:33:09 +02:00
|
|
|
HDDEDATA hdd;
|
|
|
|
|
|
|
|
pConv = WDML_GetConv(hConv, FALSE);
|
|
|
|
if (pConv == NULL)
|
|
|
|
{
|
|
|
|
/* conversation no longer available... return failure */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (msg.hwnd == pConv->hwndClient)
|
|
|
|
{
|
|
|
|
/* check that either pXAct has been processed or no more xActions are pending */
|
|
|
|
BOOL ret = (pConv->transactions == pXAct);
|
|
|
|
if (WDML_HandleReply(pConv, &msg, &hdd, ack) == WDML_QS_HANDLED)
|
|
|
|
{
|
|
|
|
TRACE("WDML_HandleReply returned WDML_QS_HANDLED\n");
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = (pConv->transactions == NULL || ret);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
pConv->instance->lastError = hdd ? DMLERR_NO_ERROR : DMLERR_NOTPROCESSED;
|
|
|
|
return hdd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Timeout !!\n");
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConv(hConv, FALSE);
|
|
|
|
if (pConv != NULL)
|
|
|
|
{
|
|
|
|
if (pConv->transactions)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
switch (pConv->transactions->ddeMsg)
|
|
|
|
{
|
|
|
|
case WM_DDE_ADVISE: err = DMLERR_ADVACKTIMEOUT; break;
|
|
|
|
case WM_DDE_REQUEST: err = DMLERR_DATAACKTIMEOUT; break;
|
|
|
|
case WM_DDE_EXECUTE: err = DMLERR_EXECACKTIMEOUT; break;
|
|
|
|
case WM_DDE_POKE: err = DMLERR_POKEACKTIMEOUT; break;
|
|
|
|
case WM_DDE_UNADVISE: err = DMLERR_UNADVACKTIMEOUT; break;
|
|
|
|
default: err = DMLERR_INVALIDPARAMETER; break;
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->instance->lastError = err;
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-11-21 07:43:48 +01:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* WDML_ClientHandle
|
|
|
|
*/
|
|
|
|
HDDEDATA WDML_ClientHandle(WDML_CONV *pConv, WDML_XACT *pXAct, DWORD dwTimeout, LPDWORD pdwResult)
|
|
|
|
{
|
|
|
|
HDDEDATA hDdeData;
|
|
|
|
|
|
|
|
if (!PostMessageW(pConv->hwndServer, pXAct->ddeMsg, (WPARAM)pConv->hwndClient, pXAct->lParam))
|
|
|
|
{
|
|
|
|
WARN("Failed posting message %x to %p (error=0x%x)\n",
|
|
|
|
pXAct->ddeMsg, pConv->hwndServer, GetLastError());
|
|
|
|
pConv->wStatus &= ~ST_CONNECTED;
|
|
|
|
pConv->instance->lastError = DMLERR_POSTMSG_FAILED;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
pXAct->dwTimeout = dwTimeout;
|
|
|
|
/* FIXME: should set the app bits on *pdwResult */
|
|
|
|
|
|
|
|
if (dwTimeout == TIMEOUT_ASYNC)
|
|
|
|
{
|
|
|
|
if (pdwResult)
|
|
|
|
*pdwResult = MAKELONG(0, pXAct->xActID);
|
|
|
|
|
|
|
|
hDdeData = (HDDEDATA)1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hDdeData = WDML_SyncWaitTransactionReply((HCONV)pConv, dwTimeout, pXAct, pdwResult);
|
|
|
|
|
|
|
|
return hDdeData;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/*****************************************************************
|
|
|
|
* DdeClientTransaction (USER32.@)
|
|
|
|
*/
|
|
|
|
HDDEDATA WINAPI DdeClientTransaction(LPBYTE pData, DWORD cbData, HCONV hConv, HSZ hszItem, UINT wFmt,
|
|
|
|
UINT wType, DWORD dwTimeout, LPDWORD pdwResult)
|
|
|
|
{
|
|
|
|
WDML_CONV* pConv;
|
|
|
|
WDML_XACT* pXAct;
|
|
|
|
HDDEDATA hDdeData = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-09-30 00:25:15 +02:00
|
|
|
TRACE("(%p,%d,%p,%p,%x,%x,%d,%p)\n",
|
2002-11-22 22:22:14 +01:00
|
|
|
pData, cbData, hConv, hszItem, wFmt, wType, dwTimeout, pdwResult);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
if (hConv == 0)
|
|
|
|
{
|
2005-11-11 11:53:44 +01:00
|
|
|
WARN("Invalid conversation handle NULL\n");
|
2001-06-23 01:02:48 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConv(hConv, TRUE);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (pConv == NULL)
|
|
|
|
{
|
|
|
|
/* cannot set error... cannot get back to DDE instance */
|
2006-11-15 14:22:35 +01:00
|
|
|
return 0;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (wType)
|
|
|
|
{
|
|
|
|
case XTYP_EXECUTE:
|
2005-07-08 13:33:09 +02:00
|
|
|
/* Windows simply ignores hszItem and wFmt in this case */
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_ClientQueueExecute(pConv, pData, cbData);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case XTYP_POKE:
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_ClientQueuePoke(pConv, pData, cbData, wFmt, hszItem);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case XTYP_ADVSTART|XTYPF_NODATA:
|
|
|
|
case XTYP_ADVSTART|XTYPF_NODATA|XTYPF_ACKREQ:
|
|
|
|
case XTYP_ADVSTART:
|
|
|
|
case XTYP_ADVSTART|XTYPF_ACKREQ:
|
|
|
|
if (pData)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->instance->lastError = DMLERR_INVALIDPARAMETER;
|
2006-11-15 14:22:35 +01:00
|
|
|
return 0;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_ClientQueueAdvise(pConv, wType, wFmt, hszItem);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case XTYP_ADVSTOP:
|
|
|
|
if (pData)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->instance->lastError = DMLERR_INVALIDPARAMETER;
|
2006-11-15 14:22:35 +01:00
|
|
|
return 0;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_ClientQueueUnadvise(pConv, wFmt, hszItem);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
case XTYP_REQUEST:
|
|
|
|
if (pData)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->instance->lastError = DMLERR_INVALIDPARAMETER;
|
2006-11-15 14:22:35 +01:00
|
|
|
return 0;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
pXAct = WDML_ClientQueueRequest(pConv, wFmt, hszItem);
|
2001-06-23 01:02:48 +02:00
|
|
|
break;
|
|
|
|
default:
|
2006-11-15 14:21:44 +01:00
|
|
|
FIXME("Unknown transaction type %04x\n", wType);
|
2001-06-23 01:02:48 +02:00
|
|
|
/* unknown transaction type */
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->instance->lastError = DMLERR_INVALIDPARAMETER;
|
2006-11-15 14:22:35 +01:00
|
|
|
return 0;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (pXAct == NULL)
|
|
|
|
{
|
|
|
|
pConv->instance->lastError = DMLERR_MEMORY_ERROR;
|
2006-11-15 14:22:35 +01:00
|
|
|
return 0;
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WDML_QueueTransaction(pConv, pXAct);
|
|
|
|
|
2006-11-21 07:43:48 +01:00
|
|
|
TRACE("pConv->wStatus %04x\n", pConv->wStatus);
|
|
|
|
|
|
|
|
if (pConv->wStatus & ST_BLOCKED)
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
2006-11-21 07:43:48 +01:00
|
|
|
TRACE("Transactions are blocked, add to the queue and exit\n");
|
|
|
|
return (HDDEDATA)1;
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-11-21 07:43:48 +01:00
|
|
|
hDdeData = WDML_ClientHandle(pConv, pXAct, dwTimeout, pdwResult);
|
|
|
|
if (dwTimeout != TIMEOUT_ASYNC)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2006-11-21 07:43:48 +01:00
|
|
|
WDML_UnQueueTransaction(pConv, pXAct);
|
|
|
|
WDML_FreeTransaction(pConv->instance, pXAct, TRUE);
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
return hDdeData;
|
|
|
|
}
|
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
/*****************************************************************
|
|
|
|
* DdeAbandonTransaction (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DdeAbandonTransaction(DWORD idInst, HCONV hConv, DWORD idTransaction)
|
|
|
|
{
|
|
|
|
WDML_INSTANCE* pInstance;
|
|
|
|
WDML_CONV* pConv;
|
|
|
|
WDML_XACT* pXAct;
|
|
|
|
|
2006-09-30 00:25:15 +02:00
|
|
|
TRACE("(%08x,%p,%08x);\n", idInst, hConv, idTransaction);
|
2002-01-18 20:30:15 +01:00
|
|
|
|
|
|
|
if ((pInstance = WDML_GetInstance(idInst)))
|
|
|
|
{
|
|
|
|
if (hConv)
|
|
|
|
{
|
|
|
|
if ((pConv = WDML_GetConv(hConv, TRUE)) && pConv->instance == pInstance)
|
|
|
|
{
|
|
|
|
for (pXAct = pConv->transactions; pXAct; pXAct = pXAct->next)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
if (pXAct->dwTimeout == TIMEOUT_ASYNC &&
|
2002-01-18 20:30:15 +01:00
|
|
|
(idTransaction == 0 || pXAct->xActID == idTransaction))
|
|
|
|
{
|
|
|
|
WDML_UnQueueTransaction(pConv, pXAct);
|
|
|
|
WDML_FreeTransaction(pInstance, pXAct, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (pConv = pInstance->convs[WDML_CLIENT_SIDE]; pConv; pConv = pConv->next)
|
|
|
|
{
|
2002-02-02 19:06:03 +01:00
|
|
|
if (!(pConv->wStatus & ST_CONNECTED)) continue;
|
2002-01-18 20:30:15 +01:00
|
|
|
for (pXAct = pConv->transactions; pXAct; pXAct = pXAct->next)
|
|
|
|
{
|
|
|
|
if (pXAct->dwTimeout == TIMEOUT_ASYNC)
|
|
|
|
{
|
|
|
|
WDML_UnQueueTransaction(pConv, pXAct);
|
|
|
|
WDML_FreeTransaction(pInstance, pXAct, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
/******************************************************************
|
|
|
|
* WDML_ClientProc
|
|
|
|
*
|
|
|
|
* Window Proc created on client side for each conversation
|
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK WDML_ClientProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
UINT uiLo, uiHi;
|
|
|
|
WDML_CONV* pConv = NULL;
|
|
|
|
HSZ hszSrv, hszTpc;
|
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("%p %04x %08lx %08lx\n", hwnd, iMsg, wParam , lParam);
|
2005-02-01 19:47:55 +01:00
|
|
|
|
2001-06-23 01:02:48 +02:00
|
|
|
if (iMsg == WM_DDE_ACK &&
|
2001-08-10 00:07:22 +02:00
|
|
|
/* in the initial WM_INITIATE sendmessage */
|
|
|
|
((pConv = WDML_GetConvFromWnd(hwnd)) == NULL || pConv->wStatus == XST_INIT1))
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
/* In response to WM_DDE_INITIATE, save server window */
|
2005-07-08 13:33:09 +02:00
|
|
|
char buf[256];
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_INSTANCE* pInstance;
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
/* note: sent messages do not need packing */
|
|
|
|
uiLo = LOWORD(lParam);
|
|
|
|
uiHi = HIWORD(lParam);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
/* FIXME: convlist should be handled here */
|
|
|
|
if (pConv)
|
|
|
|
{
|
|
|
|
/* we already have started the conv with a server, drop other replies */
|
|
|
|
GlobalDeleteAtom(uiLo);
|
|
|
|
GlobalDeleteAtom(uiHi);
|
2005-02-14 12:53:15 +01:00
|
|
|
PostMessageW((HWND)wParam, WM_DDE_TERMINATE, (WPARAM)hwnd, 0);
|
2001-08-10 00:07:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pInstance = WDML_GetInstanceFromWnd(hwnd);
|
|
|
|
|
|
|
|
hszSrv = WDML_MakeHszFromAtom(pInstance, uiLo);
|
|
|
|
hszTpc = WDML_MakeHszFromAtom(pInstance, uiHi);
|
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
pConv = WDML_AddConv(pInstance, WDML_CLIENT_SIDE, hszSrv, hszTpc, hwnd, (HWND)wParam);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2005-02-14 12:53:15 +01:00
|
|
|
SetWindowLongPtrW(hwnd, GWL_WDML_CONVERSATION, (ULONG_PTR)pConv);
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv->wStatus |= ST_CONNECTED;
|
|
|
|
pConv->wConvst = XST_INIT1;
|
|
|
|
|
|
|
|
/* check if server is handled by DDEML */
|
2005-07-08 13:33:09 +02:00
|
|
|
if ((GetClassNameA((HWND)wParam, buf, sizeof(buf)) &&
|
|
|
|
lstrcmpiA(buf, WDML_szServerConvClassA) == 0) ||
|
|
|
|
(GetClassNameW((HWND)wParam, (LPWSTR)buf, sizeof(buf)/sizeof(WCHAR)) &&
|
|
|
|
lstrcmpiW((LPWSTR)buf, WDML_szServerConvClassW) == 0))
|
2001-08-10 00:07:22 +02:00
|
|
|
{
|
|
|
|
pConv->wStatus |= ST_ISLOCAL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:24:39 +02:00
|
|
|
WDML_BroadcastDDEWindows(WDML_szEventClass, WM_WDML_CONNECT_CONFIRM, (WPARAM)hwnd, wParam);
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
GlobalDeleteAtom(uiLo);
|
|
|
|
GlobalDeleteAtom(uiHi);
|
|
|
|
|
|
|
|
/* accept conversation */
|
|
|
|
return 1;
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
|
|
|
|
if (iMsg >= WM_DDE_FIRST && iMsg <= WM_DDE_LAST)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConvFromWnd(hwnd);
|
2001-06-23 01:02:48 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (pConv)
|
2001-06-23 01:02:48 +02:00
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HDDEDATA hdd;
|
|
|
|
|
|
|
|
msg.hwnd = hwnd;
|
|
|
|
msg.message = iMsg;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
WDML_HandleReply(pConv, &msg, &hdd, NULL);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
return IsWindowUnicode(hwnd) ? DefWindowProcW(hwnd, iMsg, wParam, lParam) :
|
|
|
|
DefWindowProcA(hwnd, iMsg, wParam, lParam);
|
2001-06-23 01:02:48 +02:00
|
|
|
}
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
/*****************************************************************
|
|
|
|
* DdeDisconnect (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DdeDisconnect(HCONV hConv)
|
|
|
|
{
|
|
|
|
WDML_CONV* pConv = NULL;
|
|
|
|
WDML_XACT* pXAct;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2003-05-20 01:27:16 +02:00
|
|
|
TRACE("(%p)\n", hConv);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
if (hConv == 0)
|
|
|
|
{
|
2005-11-11 11:53:44 +01:00
|
|
|
WARN("DdeDisconnect(): hConv = 0\n");
|
2001-08-10 00:07:22 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
pConv = WDML_GetConv(hConv, TRUE);
|
2001-08-10 00:07:22 +02:00
|
|
|
if (pConv != NULL)
|
|
|
|
{
|
2002-01-18 20:30:15 +01:00
|
|
|
if (pConv->wStatus & ST_CLIENT)
|
|
|
|
{
|
|
|
|
/* FIXME: should abandon all pending transactions */
|
|
|
|
pXAct = WDML_ClientQueueTerminate(pConv);
|
|
|
|
if (pXAct != NULL)
|
|
|
|
{
|
2005-02-14 12:53:15 +01:00
|
|
|
if (PostMessageW(pConv->hwndServer, pXAct->ddeMsg,
|
2002-01-18 20:30:15 +01:00
|
|
|
(WPARAM)pConv->hwndClient, pXAct->lParam))
|
2006-11-15 14:21:44 +01:00
|
|
|
{
|
2005-07-08 13:33:09 +02:00
|
|
|
WDML_SyncWaitTransactionReply(hConv, 10000, pXAct, NULL);
|
2006-11-15 14:21:44 +01:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
2006-11-15 14:22:35 +01:00
|
|
|
else
|
2006-11-15 14:21:44 +01:00
|
|
|
pConv->instance->lastError = DMLERR_POSTMSG_FAILED;
|
|
|
|
|
2002-01-18 20:30:15 +01:00
|
|
|
WDML_FreeTransaction(pConv->instance, pXAct, TRUE);
|
|
|
|
/* still have to destroy data assosiated with conversation */
|
|
|
|
WDML_RemoveConv(pConv, WDML_CLIENT_SIDE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Not implemented yet for a server side conversation\n");
|
|
|
|
}
|
|
|
|
}
|
2001-08-10 00:07:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2001-06-23 01:02:48 +02:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* DdeImpersonateClient (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DdeImpersonateClient(HCONV hConv)
|
|
|
|
{
|
|
|
|
WDML_CONV* pConv;
|
|
|
|
BOOL ret = FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-05-20 01:27:16 +02:00
|
|
|
TRACE("(%p)\n", hConv);
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
pConv = WDML_GetConv(hConv, TRUE);
|
2001-06-23 01:02:48 +02:00
|
|
|
if (pConv)
|
|
|
|
{
|
|
|
|
ret = ImpersonateDdeClientWindow(pConv->hwndClient, pConv->hwndServer);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|