/****************************************************************** * WDML_HandleAdviseReply * * handles the reply to an advise request */ static WDML_QUEUE_STATE WDML_HandleAdviseReply(WDML_CONV* pConv, MSG* msg, WDML_XACT* pXAct, DWORD *ack) { DDEACK ddeAck; UINT_PTR uiLo, uiHi; HSZ hsz; if (msg->message != WM_DDE_ACK || WIN_GetFullHandle((HWND)msg->wParam) != pConv->hwndServer) { return WDML_QS_PASS; } UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi); hsz = WDML_MakeHszFromAtom(pConv->instance, uiHi); if (DdeCmpStringHandles(hsz, pXAct->hszItem) != 0) return WDML_QS_PASS; GlobalDeleteAtom(uiHi); FreeDDElParam(WM_DDE_ACK, msg->lParam); if (ack) *ack = uiLo; WDML_ExtractAck(uiLo, &ddeAck); if (ddeAck.fAck) { WDML_LINK* pLink; /* billx: first to see if the link is already created. */ pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_CLIENT_SIDE, pXAct->hszItem, TRUE, pXAct->wFmt); if (pLink != NULL) { /* we found a link, and only need to modify it in case it changes */ pLink->transactionType = pXAct->wType; } else { WDML_AddLink(pConv->instance, (HCONV)pConv, WDML_CLIENT_SIDE, pXAct->wType, pXAct->hszItem, pXAct->wFmt); } pXAct->hDdeData = (HDDEDATA)1; } else { TRACE("Returning FALSE on XTYP_ADVSTART - fAck was FALSE\n"); GlobalFree(pXAct->hMem); pXAct->hDdeData = NULL; } return WDML_QS_HANDLED; }
/****************************************************************** * WDML_ServerHandleAdvise * * */ static WDML_QUEUE_STATE WDML_ServerHandleAdvise(WDML_CONV* pConv, WDML_XACT* pXAct) { UINT uType; WDML_LINK* pLink; DDEADVISE* pDdeAdvise; HDDEDATA hDdeData; BOOL fAck; pDdeAdvise = (DDEADVISE*)GlobalLock(pXAct->hMem); uType = XTYP_ADVSTART | (pDdeAdvise->fDeferUpd ? XTYPF_NODATA : 0) | (pDdeAdvise->fAckReq ? XTYPF_ACKREQ : 0); if (!(pConv->instance->CBFflags & CBF_FAIL_ADVISES)) { hDdeData = WDML_InvokeCallback(pConv->instance, XTYP_ADVSTART, pDdeAdvise->cfFormat, (HCONV)pConv, pConv->hszTopic, pXAct->hszItem, 0, 0, 0); } else { hDdeData = 0; } if ((UINT)hDdeData) { fAck = TRUE; /* billx: first to see if the link is already created. */ pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE, pXAct->hszItem, TRUE, pDdeAdvise->cfFormat); if (pLink != NULL) { /* we found a link, and only need to modify it in case it changes */ pLink->transactionType = uType; } else { TRACE("Adding Link with hConv=0x%lx\n", (DWORD)pConv); WDML_AddLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE, uType, pXAct->hszItem, pDdeAdvise->cfFormat); } } else { TRACE("No data returned from the Callback\n"); fAck = FALSE; } GlobalUnlock(pXAct->hMem); if (fAck) { GlobalFree(pXAct->hMem); } pXAct->hMem = 0; WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, FALSE, fAck, pXAct->atom, pXAct->lParam, WM_DDE_ADVISE); WDML_DecHSZ(pConv->instance, pXAct->hszItem); return WDML_QS_HANDLED; }