diff options
Diffstat (limited to 'svl/source/svdde')
-rw-r--r-- | svl/source/svdde/ddedata.cxx | 10 | ||||
-rw-r--r-- | svl/source/svdde/ddedll.cxx | 64 | ||||
-rw-r--r-- | svl/source/svdde/ddeml1.cxx | 2658 | ||||
-rw-r--r-- | svl/source/svdde/ddeml2.cxx | 1011 | ||||
-rw-r--r-- | svl/source/svdde/ddemldeb.cxx | 280 | ||||
-rw-r--r-- | svl/source/svdde/ddemldeb.hxx | 66 | ||||
-rw-r--r-- | svl/source/svdde/ddemlimp.hxx | 433 | ||||
-rw-r--r-- | svl/source/svdde/ddemlos2.h | 374 | ||||
-rw-r--r-- | svl/source/svdde/ddestrg.cxx | 4 | ||||
-rw-r--r-- | svl/source/svdde/makefile.mk | 60 |
10 files changed, 3 insertions, 4957 deletions
diff --git a/svl/source/svdde/ddedata.cxx b/svl/source/svdde/ddedata.cxx index ba67d451be34..369306c22874 100644 --- a/svl/source/svdde/ddedata.cxx +++ b/svl/source/svdde/ddedata.cxx @@ -41,10 +41,6 @@ #include <osl/thread.h> -#if defined( WIN ) && defined( MSC ) -#pragma code_seg( "SVDDE_MISC_CODE" ) -#endif - // --- DdeData::DdeData() ------------------------------------------ DdeData::DdeData() @@ -164,10 +160,10 @@ ULONG DdeData::GetExternalFormat( ULONG nFmt ) default: { -#if defined(WNT) || defined(WIN) || defined( PM2 ) +#if defined(WNT) || defined( PM2 ) String aName( SotExchange::GetFormatName( nFmt ) ); -#if defined(WNT) || defined(WIN) +#if defined(WNT) if( aName.Len() ) nFmt = RegisterClipboardFormat( reinterpret_cast<LPCWSTR>(aName.GetBuffer()) ); @@ -203,7 +199,7 @@ ULONG DdeData::GetInternalFormat( ULONG nFmt ) break; default: -#if defined(WIN) || defined(WNT) +#if defined(WNT) if( nFmt >= CF_MAX ) { TCHAR szName[ 256 ]; diff --git a/svl/source/svdde/ddedll.cxx b/svl/source/svdde/ddedll.cxx deleted file mode 100644 index a71662dd5e63..000000000000 --- a/svl/source/svdde/ddedll.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svl.hxx" -#ifdef WIN - - -#include <sysdep.hxx> // included svwin.h - -// Statische DLL-Verwaltungs-Variablen -static HINSTANCE hDLLInst = 0; // HANDLE der DLL - -/*************************************************************************** -|* LibMain() -|* Beschreibung Initialisierungsfunktion der DLL -***************************************************************************/ -extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR ) -{ -#ifndef WNT - if ( nHeap ) - UnlockData( 0 ); -#endif - - hDLLInst = hDLL; - - return TRUE; -} - -/*************************************************************************** -|* WEP() -|* Beschreibung DLL-Deinitialisierung -***************************************************************************/ -extern "C" int CALLBACK WEP( int ) -{ - return 1; -} - -#endif - diff --git a/svl/source/svdde/ddeml1.cxx b/svl/source/svdde/ddeml1.cxx deleted file mode 100644 index dd9cc2abdaa7..000000000000 --- a/svl/source/svdde/ddeml1.cxx +++ /dev/null @@ -1,2658 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svl.hxx" - -/* - ToDo / Bugs: - - - DdeInitiate: Eigener Thread? - - Timeout bei Disconnects (IBM:nicht auf Ack warten!) - - Konzept Errorhandling (globale/lokale Fehler) - - Bedeutung/Anwendung Conversation-Contexte - - Bei Zugriffen auf ConversationHandles WindowHandles checken - - Namen der Partner-App ermitteln - - Codepage-Geraffel -*/ -#define INCL_DOSPROCESS - -#include "ddemlimp.hxx" - -#define LOGFILE -#define STATUSFILE -#define DDEDATAFILE -#include "ddemldeb.hxx" - - -#if defined (OS2) && defined (__BORLANDC__) -#pragma option -w-par -#endif - -// static -inline BOOL ImpDdeMgr::MyWinDdePostMsg( HWND hWndTo, HWND hWndFrom, - USHORT nMsg, PDDESTRUCT pData, ULONG nFlags ) -{ - BOOL bSuccess = WinDdePostMsg( hWndTo,hWndFrom,nMsg,pData,nFlags); - if( !bSuccess ) - { - WRITELOG("WinDdePostMsg:Failed!") - if ( !(nFlags & DDEPM_NOFREE) ) - { - MyDosFreeMem( pData,"MyWinDdePostMsg" ); - } - } - return bSuccess; -} - - -// ********************************************************************* -// ImpDdeMgr -// ********************************************************************* - -USHORT ImpDdeMgr::nLastErrInstance = 0; - -// -// Conversation-WndProc -// Steuert Transaktionen eines Conversationhandles -// -MRESULT EXPENTRY ConvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2) -{ -#if defined(DBG_UTIL) && defined(OV_DEBUG) - if( nMsg >= WM_DDE_FIRST && nMsg <= WM_DDE_LAST) - { - ////WRITELOG("::ConvWndProc:DDE-Msg received") - } -#endif - ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 ); - return pObj->pThis->ConvWndProc( hWnd, nMsg, nPar1, nPar2 ); -} - -// -// Server-WndProc -// DDE-Server-Window der App -// -MRESULT EXPENTRY ServerWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2) -{ -#if defined(DBG_UTIL) && defined(OV_DEBUG) - if( nMsg >= WM_DDE_FIRST && nMsg <= WM_DDE_LAST) - { - ////WRITELOG("::ServerWndProc:DDE-Msg received") - } -#endif - ImpDdeMgr* pObj = (ImpDdeMgr*)WinQueryWindowULong( hWnd, 0 ); - return pObj->SrvWndProc( hWnd, nMsg, nPar1, nPar2 ); -} - - -inline HDDEDATA ImpDdeMgr::Callback( USHORT nTransactionType, - USHORT nClipboardFormat, HCONV hConversationHandle, HSZ hsz1, - HSZ hsz2, HDDEDATA hData, ULONG nData1, ULONG nData2 ) -{ - HDDEDATA hRet = (HDDEDATA)0; - if( pCallback ) - hRet = (*pCallback)(nTransactionType, nClipboardFormat, - hConversationHandle, hsz1, hsz2, hData, nData1, nData2); - return hRet; -} - - - -ImpDdeMgr::ImpDdeMgr() -{ - nLastErrInstance = DMLERR_NO_ERROR; - pCallback = 0; - nTransactFilter = 0; - nServiceCount = 0; - pServices = 0; - pAppTable = 0; - pConvTable = 0; - pTransTable = 0; - bServFilterOn = TRUE; - bInSyncTrans = FALSE; - - CreateServerWnd(); - pData = InitAll(); - if ( !pData ) - nLastErrInstance = DMLERR_MEMORY_ERROR; - else - RegisterDDEMLApp(); -} - -ImpDdeMgr::~ImpDdeMgr() -{ - CleanUp(); - DestroyServerWnd(); -// Named Shared Mem vom BS loeschen lassen, da nicht bekannt ist, -// wieviele DDEML-Instanzen die App erzeugt hat, und OS/2 -// keinen App-Referenzzaehler fuer shared mem fuehrt. -// if ( pData ) -// DosFreeMem( pData ); -} - - -BOOL ImpDdeMgr::IsSameInstance( HWND hWnd ) -{ - TID tid; PID pid; - WinQueryWindowProcess( hWnd, &pid, &tid ); - return (BOOL)(pid == pidThis); -} - -HSZ ImpDdeMgr::GetAppName( HWND hWnd ) -{ - return 0; -} - -// static -ImpDdeMgr* ImpDdeMgr::GetImpDdeMgrInstance( HWND hWnd ) -{ - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if( !pData ) - return 0; - - ImpDdeMgr* pResult = 0; - TID tid; PID pidApp; - WinQueryWindowProcess( hWnd, &pidApp, &tid ); - HWND* pApp = ImpDdeMgr::GetAppTable( pData ); - USHORT nCurApp = 0; - while( nCurApp < pData->nMaxAppCount ) - { - HWND hCurWin = *pApp; - if( hCurWin ) - { - PID pidCurApp; - WinQueryWindowProcess( hCurWin, &pidCurApp, &tid ); - if( pidCurApp == pidApp ) - { - pResult = (ImpDdeMgr*)WinQueryWindowULong( hCurWin, 0 ); - break; - } - } - pApp++; - nCurApp++; - } - return pResult; -} - - - - - -void ImpDdeMgr::CleanUp() -{ - DisconnectAll(); - ImpService* pPtr = pServices; - if( pPtr ) - { - for( USHORT nIdx = 0; nIdx < nServiceCount; nIdx++, pPtr++ ) - { - HSZ hStr = pPtr->hBaseServName; - if( hStr ) - DdeFreeStringHandle( hStr ); - hStr = pPtr->hInstServName; - if( hStr ) - DdeFreeStringHandle( hStr ); - } - nServiceCount = 0; - delete pServices; - pServices = 0; - } - bServFilterOn = TRUE; // default setting DDEML - UnregisterDDEMLApp(); -} - -void ImpDdeMgr::RegisterDDEMLApp() -{ - HWND* pPtr = pAppTable; - HWND hCur; - USHORT nPos = 0; - while( nPos < pData->nMaxAppCount ) - { - hCur = *pPtr; - if (hCur == (HWND)0 ) - { - // in Tabelle stellen - *pPtr = hWndServer; - break; - } - nPos++; - pPtr++; - } -} - -void ImpDdeMgr::UnregisterDDEMLApp() -{ - HWND* pPtr = pAppTable; - USHORT nPos = 0; - while( nPos < pData->nMaxAppCount ) - { - if (*pPtr == hWndServer ) - { - *pPtr = 0; - break; - } - nPos++; - pPtr++; - } -} - -// static -ImpDdeMgrData* ImpDdeMgr::AccessMgrData() -{ - ImpDdeMgrData* pData = 0; - APIRET nRet = DosGetNamedSharedMem((PPVOID)&pData,DDEMLDATA,PAG_READ|PAG_WRITE); - DBG_ASSERT(!nRet,"DDE:AccessMgrData failed"); - return pData; -} - -USHORT ImpDdeMgr::DdeGetLastError() -{ - USHORT nErr; - if ( !pData ) - nErr = DMLERR_DLL_NOT_INITIALIZED; - else if ( nLastErrInstance ) - nErr = nLastErrInstance; - else - nErr = pData->nLastErr; - - nLastErrInstance = 0; - pData->nLastErr = 0; - return nErr; -} - - - -USHORT ImpDdeMgr::DdeInitialize( PFNCALLBACK pCallbackProc, ULONG nTransactionFilter ) -{ - if ( !nLastErrInstance ) - { - if ( !pCallbackProc ) - { - nLastErrInstance = DMLERR_INVALIDPARAMETER; - return nLastErrInstance; - } - pCallback = pCallbackProc; - nTransactFilter = nTransactionFilter; - nTransactFilter |= CBF_FAIL_SELFCONNECTIONS; - } - return nLastErrInstance; -} - - -// static -HWND ImpDdeMgr::NextFrameWin( HENUM hEnum ) -{ - char aBuf[ 10 ]; - - HWND hWnd = WinGetNextWindow( hEnum ); - while( hWnd ) - { - WinQueryClassName( hWnd, sizeof(aBuf)-1, (PCH)aBuf ); - // Frame-Window ? - if( !strcmp( aBuf, "#1" ) ) // #define WC_FRAME ((PSZ)0xffff0001L) - break; - hWnd = WinGetNextWindow( hEnum ); - } - return hWnd; -} - - -HCONV ImpDdeMgr::DdeConnectImp( HSZ hszService,HSZ hszTopic,CONVCONTEXT* pCC) -{ - hCurConv = 0; - if( !pCC ) - pCC = &aDefaultContext; - - ULONG nBufLen; - PSZ pService = AllocAtomName( (ATOM)hszService, nBufLen ); - PSZ pTopic = AllocAtomName( (ATOM)hszTopic, nBufLen ); -#if 0 && defined(OV_DEBUG) - String aStr("DdeConnectImp Service:"); - aStr += pService; - aStr += " Topic:"; - aStr += pTopic; - WRITELOG((char*)(const char*)aStr) -#endif - -#if defined(OV_DEBUG) - if( !strcmp(pService,"oliver voeltz") ) - { - WRITESTATUS("Table of connections"); - MyDosFreeMem( pTopic,"DdeConnectImp" ); - MyDosFreeMem( pService,"DdeConnectImp" ); - return 0; - } -#endif - -#if 0 - // original pm-fkt benutzen - HWND hWndCurClient = CreateConversationWnd(); - WinDdeInitiate( hWndCurClient, pService, pTopic, pCC ); - if( GetConversationWndRefCount(hWndCurClient) == 0) - DestroyConversationWnd( hWndCurClient ); -#else - // eigener Verbindungsaufbau - HENUM hEnum = WinBeginEnumWindows( HWND_DESKTOP ); - HWND hWndCurSrv = NextFrameWin( hEnum ); - HWND hWndCurClient = CreateConversationWnd(); - while( hWndCurSrv && !hCurConv ) - { - if( hWndCurSrv != hWndServer || - ((nTransactFilter & CBF_FAIL_SELFCONNECTIONS)==0 )) - { - // pro DDE-Server ein Conversation-Window erzeugen - if( GetConversationWndRefCount(hWndCurClient) >= 2) - { - DestroyConversationWnd( hWndCurClient ); - hWndCurClient = CreateConversationWnd(); - } - MyInitiateDde(hWndCurSrv,hWndCurClient,hszService,hszTopic,pCC); - if( !bListConnect && hCurConv ) - break; - } - hWndCurSrv = NextFrameWin( hEnum ); - } - - if( GetConversationWndRefCount(hWndCurClient) == 0) - DestroyConversationWnd( hWndCurClient ); - WinEndEnumWindows( hEnum ); -#endif - - if( !hCurConv ) - nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED; - -#if 0 && defined(OV_DEBUG) - String aCStr( "DdeConnectImp:End "); - if( nLastErrInstance != DMLERR_NO_CONV_ESTABLISHED ) - aCStr += "(Success)"; - else - aCStr += "(Failed)"; - WRITELOG((char*)aCStr.GetStr()) -#endif - - MyDosFreeMem( pTopic,"DdeConnectImp" ); - MyDosFreeMem( pService,"DdeConnectImp" ); - return hCurConv; -} - -HCONV ImpDdeMgr::DdeConnect( HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC) -{ - ////WRITELOG("DdeConnect:Start") - bListConnect = FALSE; - HCONV hResult = DdeConnectImp( hszService, hszTopic, pCC ); - ////WRITELOG("DdeConnect:End") - ////WRITESTATUS("DdeConnect:End") - return hResult; -} - - -HCONVLIST ImpDdeMgr::DdeConnectList( HSZ hszService, HSZ hszTopic, - HCONVLIST hConvList, CONVCONTEXT* pCC ) -{ - nPrevConv = 0; - ////WRITESTATUS("Before DdeConnectList") - if( hConvList ) - { - HCONV hLastConvInList; - - hCurListId = hConvList; - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConvList; - if( (USHORT)hConvList >= pData->nMaxConvCount ||pConv->hWndThis==0 ) - { - nLastErrInstance = DMLERR_INVALIDPARAMETER; - return 0; - } - GetLastServer(pData, hConvList, hLastConvInList); - nPrevConv = (USHORT)hLastConvInList; - } - else - hCurListId = (HCONVLIST)WinCreateWindow( HWND_OBJECT, WC_FRAME, - CONVLISTNAME, 0,0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0,0,0); - - bListConnect = TRUE; - DdeConnectImp( hszService, hszTopic, pCC ); -#if 0 && defined(OV_DEBUG) - WRITELOG("DdeConnectList:ConnectionList:") - HCONV hDebug = 0; - do - { - hDebug = DdeQueryNextServer( hCurListId, hDebug); - String aStr( (ULONG)hDebug ); - WRITELOG((char*)(const char*)aStr) - } while( hDebug ); -#endif - ////WRITESTATUS("After DdeConnectList") - return (HCONVLIST)hCurListId; -} - -DDEINIT* ImpDdeMgr::CreateDDEInitData( HWND hWndDestination, HSZ hszService, - HSZ hszTopic, CONVCONTEXT* pCC ) -{ - ULONG nLen1 = 0, nLen2 = 0; - HATOMTBL hAtomTable = WinQuerySystemAtomTable(); - - if( hszService ) - nLen1 = WinQueryAtomLength( hAtomTable, hszService ); - if( hszTopic ) - nLen2 = WinQueryAtomLength( hAtomTable, hszTopic ); - nLen1++; nLen2++; - - DDEINIT* pBuf = 0; - - ULONG nLen = sizeof(DDEINIT) + nLen1+ nLen2 + sizeof(CONVCONTEXT); - if( !(MyDosAllocSharedMem((PPVOID)&pBuf, NULL, nLen, - PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE | OBJ_ANY, - "CreateDDEInitData"))) - { - memset( pBuf, 0, nLen ); - - /* - PID pid; TID tid; - WinQueryWindowProcess( hWndDestination, &pid, &tid ); - APIRET nRet = DosGiveSharedMem( pBuf, pid, PAG_READ | PAG_WRITE ); - */ - - pBuf->cb = nLen; - pBuf->offConvContext = sizeof( DDEINIT ); - char* pBase = (char*)pBuf; - pBase += sizeof(DDEINIT); - if( pCC ) - memcpy( pBase, pCC, sizeof(CONVCONTEXT) ); - pBase += sizeof(CONVCONTEXT); - pBuf->pszAppName = pBase; - if( hszService ) - WinQueryAtomName( hAtomTable, hszService, pBase, nLen1 ); - pBase += nLen1; - pBuf->pszTopic = pBase; - if( hszTopic ) - WinQueryAtomName( hAtomTable, hszTopic, pBase, nLen2 ); - } - return pBuf; -} - - - -void ImpDdeMgr::MyInitiateDde( HWND hWndSrv, HWND hWndClient, - HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC ) -{ - DDEINIT* pBuf = CreateDDEInitData( hWndSrv, hszService, hszTopic, pCC ); - if( pBuf ) - { - PID pid; TID tid; - WinQueryWindowProcess( hWndSrv, &pid, &tid ); - APIRET nRet = DosGiveSharedMem( pBuf, pid, PAG_READ | PAG_WRITE ); - WinSendMsg( hWndSrv,WM_DDE_INITIATE,(MPARAM)hWndClient,(MPARAM)pBuf); - MyDosFreeMem( pBuf,"MyInitiateDde" ); - } -} - -// static -ImpHCONV* ImpDdeMgr::GetFirstServer(ImpDdeMgrData* pData, HCONVLIST hConvList, - HCONV& rhConv ) -{ - ImpHCONV* pPtr = GetConvTable( pData ); - HCONV hConv; - if( !rhConv ) - { - pPtr++; - hConv = 1; - } - else - { - // Startposition - pPtr += (USHORT)rhConv; - hConv = rhConv; - pPtr++; hConv++; // auf den naechsten - } - while( hConv < pData->nMaxConvCount ) - { - if( pPtr->hConvList == hConvList ) - { - rhConv = hConv; - return pPtr; - } - pPtr++; - hConv++; - } - rhConv = 0; - return 0; -} - -// static -ImpHCONV* ImpDdeMgr::GetLastServer(ImpDdeMgrData* pData, HCONVLIST hConvList, - HCONV& rhConv ) -{ - ImpHCONV* pPtr = GetConvTable( pData ); - pPtr += pData->nMaxConvCount; - pPtr--; - HCONV hConv = pData->nMaxConvCount; - hConv--; - while( hConv > 0 ) - { - if( pPtr->hConvList == hConvList ) - { - rhConv = hConv; - return pPtr; - } - pPtr--; - hConv--; - } - rhConv = 0; - return 0; -} - -// static -BOOL ImpDdeMgr::CheckConvListId( HCONVLIST hConvListId ) -{ - HAB hAB = WinQueryAnchorBlock( (HWND)hConvListId ); - if( hAB ) - return WinIsWindow( hAB, (HWND)hConvListId ); - return FALSE; - /* - HAB hAB = WinQueryAnchorBlock( (HWND)hConvListId ); - if( hAB ) - { - char aBuf[ 16 ]; - WinQueryWindowText( (HWND)hConvListId, sizeof(aBuf), aBuf ); - if( strcmp(aBuf, CONVLISTNAME ) == 0 ) - return TRUE; - } - return FALSE; - */ -} - -// static -HCONV ImpDdeMgr::DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev) -{ - if( !CheckConvListId( hConvList ) ) - return (HCONV)0; - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - GetFirstServer( pData, hConvList, hConvPrev ); - return hConvPrev; -} - -// static - -// Idee: DisconnectAll uebergibt das ServerWindow. Zu jedem HCONV -// wird das Creator-Server-Wnd gespeichert. Disconnect braucht -// dann nur noch die Window-Handles zu vergleichen -BOOL ImpDdeMgr::DdeDisconnect( HCONV hConv ) -{ - WRITELOG("DdeDisconnect:Start") - ////WRITESTATUS("DdeDisconnect:Start") - - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if ( !pData ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return FALSE; - } - ImpHCONV* pConv = GetConvTable(pData) + (USHORT)hConv; - - if( (USHORT)hConv >= pData->nMaxConvCount || pConv->hWndThis==0 ) - { - nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED; - return FALSE; - } - - PID pidApp; TID tid; - HWND hWndDummy = WinCreateWindow( HWND_OBJECT, WC_FRAME, - "Bla", 0, 0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 ); - WinQueryWindowProcess( hWndDummy, &pidApp, &tid ); - WinDestroyWindow( hWndDummy ); - PID pidThis; PID pidPartner; - - HWND hWndThis = pConv->hWndThis; - HWND hWndPartner = pConv->hWndPartner; - - WinQueryWindowProcess( hWndThis, &pidThis, &tid ); - WinQueryWindowProcess( hWndPartner, &pidPartner, &tid ); - if( pidApp != pidThis && pidApp != pidPartner ) - return TRUE; // gehoert nicht der App -> ueberspringen - - HCONV hConvPartner = pConv->hConvPartner; - - // die App benachrichtigen, dass alle offenen Advise-Loops - // beendet werden, egal ob sie vom Server oder Client - // initiiert wurden. Die Dinger aber nicht loeschen, da sie evtl. - // noch vom Partner gebraucht werden. - ImpConvWndData* pObj = - (ImpConvWndData*)WinQueryWindowULong( pConv->hWndThis, 0 ); - ImpDdeMgr* pThis = pObj->pThis; - pThis->SendUnadvises( hConv, 0, FALSE ); // alle Formate & NICHT loeschen - pThis->SendUnadvises( hConvPartner, 0, FALSE ); // alle Formate & NICHT loeschen - - pConv->nStatus |= ST_TERMINATED; - - HAB hAB = WinQueryAnchorBlock( pConv->hWndThis ); - // um die MessageQueue inne Gaenge zu halten - ULONG nTimerId = WinStartTimer( hAB, 0, 0, 50 ); - - /* - Die Partner-App muss ein DDE_TERMINATE posten, auf das - wir warten muessen, um alle Messages zu bearbeiten, die - _vor_ dem DdeDisconnect von der Partner-App gepostet - wurden. - */ - WRITELOG("DdeDisconnect:Waiting for acknowledge...") - WinDdePostMsg( hWndPartner, hWndThis, WM_DDE_TERMINATE, - (PDDESTRUCT)0,DDEPM_RETRY); - - QMSG aQueueMsg; - BOOL bContinue = TRUE; - while( bContinue ) - { - if( WinGetMsg( hAB, &aQueueMsg, 0, 0, 0 )) - { - WinDispatchMsg( hAB, &aQueueMsg ); - if( (!WinIsWindow( hAB, hWndPartner)) || - (pConv->nStatus & ST_TERMACKREC) ) - { - bContinue = FALSE; - if( pConv->nStatus & ST_TERMACKREC ) - { - WRITELOG("DdeDisconnect: TermAck received") - } - else - { - WRITELOG("DdeDisconnect: Partner died") - } - } - } - else - bContinue = FALSE; - } - - WinStopTimer( hAB, 0, nTimerId ); - - // WRITELOG("DdeDisconnect:Freeing data") - // Transaktionstabelle aufraeumen - FreeTransactions( pData, hConv ); - if( hConvPartner ) - FreeTransactions( pData, hConvPartner ); - - FreeConvHandle( pData, hConv ); - - WRITELOG("DdeDisconnect:End") - //WRITESTATUS("DdeDisconnect:End") - return TRUE; -} - -// static -BOOL ImpDdeMgr::DdeDisconnectList( HCONVLIST hConvList ) -{ - if( !CheckConvListId( hConvList ) ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER; - return FALSE; - } - - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if ( !pData ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return FALSE; - } - HCONV hConv = 0; - GetFirstServer( pData, hConvList, hConv ); - while( hConv ) - { - DdeDisconnect( hConv ); - GetFirstServer( pData, hConvList, hConv ); - } - WinDestroyWindow( (HWND)hConvList ); - return TRUE; -} - - - -// static -HCONV ImpDdeMgr::DdeReconnect(HCONV hConv) -{ - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if ( !pData ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return 0; - } - return 0; -} - -// static -USHORT ImpDdeMgr::DdeQueryConvInfo(HCONV hConv, ULONG nTransId, CONVINFO* pCI) -{ - if( !pCI || pCI->nSize == 0) - return 0; - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if ( !pData ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return 0; - } - Transaction* pTrans; - if( nTransId != QID_SYNC ) - { - pTrans = ImpDdeMgr::GetTransTable( pData ); - pTrans += nTransId; - if( nTransId >= pData->nMaxTransCount || pTrans->hConvOwner == 0 ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_UNFOUND_QUEUE_ID; - return 0; - } - } - else - pTrans = 0; - - ImpHCONV* pConv = ImpDdeMgr::GetConvTable( pData ); - pConv += (ULONG)hConv; - if( hConv >= pData->nMaxConvCount || pConv->hWndThis == 0 ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED; - return 0; - } - - USHORT nSize = pCI->nSize; - if( nSize > sizeof(CONVINFO) ) - nSize = sizeof(CONVINFO); - CONVINFO aTempInfo; - memset( &aTempInfo, 0, sizeof(CONVINFO) ); - aTempInfo.nSize = pCI->nSize; - aTempInfo.hConvPartner = pConv->hConvPartner; - aTempInfo.hszPartner = pConv->hszPartner; - aTempInfo.hszServiceReq = pConv->hszServiceReq; - aTempInfo.hszTopic = pConv->hszTopic; - aTempInfo.nStatus = pConv->nStatus; - aTempInfo.hConvList = pConv->hConvList; - aTempInfo.aConvCtxt = pConv->aConvContext; - if( pTrans ) - { - aTempInfo.nUser = pTrans->nUser; - aTempInfo.hszItem = pTrans->hszItem; - aTempInfo.nFormat = pTrans->nFormat; - aTempInfo.nType = pTrans->nType; - aTempInfo.nConvst = pTrans->nConvst; - aTempInfo.nLastError= pTrans->nLastError; - } - memcpy( pCI, &aTempInfo, nSize ); - - return nSize; -} - -// static -BOOL ImpDdeMgr::DdeSetUserHandle(HCONV hConv, ULONG nTransId, ULONG hUser) -{ - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if ( !pData ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return FALSE; - } - Transaction* pTrans = GetTransTable( pData ); - pTrans += nTransId; - if( !nTransId || !hConv || nTransId >= pData->nMaxTransCount || - pTrans->hConvOwner != hConv ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER; - return FALSE; - } - if( !pTrans->hConvOwner) - { - ImpDdeMgr::nLastErrInstance = DMLERR_UNFOUND_QUEUE_ID; - return FALSE; - } - pTrans->nUser = hUser; - return TRUE; -} - -BOOL ImpDdeMgr::DdeAbandonTransaction( HCONV hConv, ULONG nTransId ) -{ - ////WRITELOG("DdeAbandonTransaction:Start") - if( !pData ) - { - nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return FALSE; - } - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - if( nTransId < 1 || nTransId >= pData->nMaxTransCount || - hConv < 1 || hConv >= pData->nMaxConvCount || !pConv->hWndThis) - { - nLastErrInstance = DMLERR_INVALIDPARAMETER; - return FALSE; - } - if( !hConv ) - { - DBG_ASSERT(0,"DdeAbandonTransaction:NULL-hConv not supported"); - nLastErrInstance = DMLERR_INVALIDPARAMETER; - return FALSE; - } - Transaction* pTrans = pTransTable; - pTrans += (USHORT)nTransId; - if( pTrans->hConvOwner != hConv ) - { - nLastErrInstance = DMLERR_UNFOUND_QUEUE_ID; - return FALSE; - } - - if( bInSyncTrans && nTransId == nSyncTransId ) - { - bSyncAbandonTrans = TRUE; - return TRUE; - } - USHORT nTempType = pTrans->nType; - nTempType &= (~XTYPF_MASK); - if( nTempType == (XTYP_ADVREQ & ~(XTYPF_NOBLOCK))) - { - ////WRITELOG("DdeAbandTrans:Advise Loop") - -// ---------------------------------------------------------------------- -// Der von der Deutschen Bank eingesetzte DDE-Server -// "Invision V2.71 Build 36 Mar 12 1999 V4.8.2" hat einen Bug, der -// dazu fuehrt, dass auf per WM_DDE_TERMINATE geschlossene Verbindungen -// nicht mit einem WM_DDE_TERMINATE geantwortet wird, wenn der -// entsprechende Link vorher per WM_DDE_UNADVISE beendet wurde. Dieser -// Bug tritt ab zwei parallel laufenden Links auf. Auf Wunsch der DB -// wurde das folgende Workaround eingebaut. -// ---------------------------------------------------------------------- -#define DEUTSCHE_BANK -#ifndef DEUTSCHE_BANK - -// Acknowledge ist beim Unadvise nicht ueblich -//#define SO_DDE_ABANDON_TRANSACTION_WAIT_ACK -#ifdef SO_DDE_ABANDON_TRANSACTION_WAIT_ACK - DDESTRUCT* pOutDDEData = MakeDDEObject( pConv->hWndPartner, - pTrans->hszItem, DDE_FACKREQ, 0 /*pTrans->nFormat*/, 0, 0); -#else - DDESTRUCT* pOutDDEData = MakeDDEObject( pConv->hWndPartner, - pTrans->hszItem, 0, 0 /*pTrans->nFormat*/, 0, 0); -#endif - WRITELOG("DdeAbandTrans:Waiting for acknowledge...") - pTrans->nConvst = XST_UNADVSENT; - if ( !MyWinDdePostMsg( pConv->hWndPartner, pConv->hWndThis, - WM_DDE_UNADVISE, pOutDDEData, DDEPM_RETRY ) ) - { - WRITELOG("DdeAbandTrans:PostMsg Failed") - return FALSE; - } -#ifdef SO_DDE_ABANDON_TRANSACTION_WAIT_ACK - WaitTransState( pTrans, nTransId, XST_UNADVACKRCVD, 0 ); -#else - pTrans->nConvst = XST_UNADVACKRCVD; -#endif - -#endif // DEUTSCHE_BANK - - WRITELOG("DdeAbandTrans:Ack received->Freeing transaction") - FreeTransaction( pData, nTransId ); - } - WRITELOG("DdeAbandonTransaction:End") - return TRUE; -} - -// wird von einem Server aufgerufen, wenn sich die Daten des -// Topic/Item-Paars geaendert haben. Diese Funktion fordert -// dann den Server auf, die Daten zu rendern (bei Hotlinks) und -// benachrichtigt die Clients -BOOL ImpDdeMgr::DdePostAdvise( HSZ hszTopic, HSZ hszItem) -{ - ////WRITELOG("DdePostAdvise:Start") - ////WRITESTATUS("DdePostAdvise:Start") - -#if 0 && defined( OV_DEBUG ) - String aDebStr("DdePostAdvise:Item "); - aDebStr += (ULONG)hszItem; - WRITELOG((char*)(const char*)aDebStr) -#endif - - Transaction* pTrans = pTransTable; - pTrans++; - USHORT nCurTrans = 1; - USHORT nUsedTransactions = pData->nCurTransCount; - while( nUsedTransactions && nCurTrans < pData->nMaxTransCount ) - { - HCONV hOwner = pTrans->hConvOwner; - if( hOwner ) - { - nUsedTransactions--; - USHORT nTempType = pTrans->nType; - nTempType &= (~XTYPF_MASK); - if( nTempType == (XTYP_ADVREQ & (~XTYPF_NOBLOCK) ) ) - { - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hOwner; - if(hszItem == pTrans->hszItem && pConv->hszTopic == hszTopic) - { - if( pConv->hConvPartner ) - { - // Transaktionen werden immer vom Client erzeugt - // -> auf Server-HCONV umschalten - hOwner = pConv->hConvPartner; - pConv = pConvTable; - pConv += (USHORT)hOwner; - } - HWND hWndClient = pConv->hWndPartner; - HWND hWndServer = pConv->hWndThis; -#if 0 && defined( OV_DEBUG ) - String aDebStr("DdePostAdvise: Server:"); - aDebStr += (ULONG)hWndServer; - aDebStr += " Client:"; - aDebStr += (ULONG)hWndClient; - WRITELOG((char*)(const char*)aDebStr) -#endif - DDESTRUCT* pOutDDEData; - if ( pTrans->nType & XTYPF_NODATA ) - { - // Warm link - ////WRITELOG("DdePostAdvise:Warm link found") - pOutDDEData = MakeDDEObject( hWndClient, hszItem, - DDE_FNODATA, pTrans->nFormat, 0, 0 ); - } - else - { - // Hot link - ////WRITELOG("DdePostAdvise:Hot link found") - pOutDDEData = Callback( XTYP_ADVREQ, - pTrans->nFormat, hOwner, hszTopic, - hszItem, (HDDEDATA)0, 1, 0 ); - } - if( pOutDDEData ) - { - // todo: FACK_REQ in Out-Data setzen, wenn pTrans->nType & XTYPF_ACKREQ - ////WRITELOG("DdePostAdvise:Sending data/notification") - BOOL bSuccess = MyWinDdePostMsg( hWndClient, - hWndServer,WM_DDE_DATA, pOutDDEData, DDEPM_RETRY); - if( bSuccess ) - { - // auf Acknowledge des Partners warten ? - if( pTrans->nType & XTYPF_ACKREQ ) - { - pTrans->nConvst = XST_ADVDATASENT; - // Impl. ist falsch! => korrekt: XST_ADVDATAACKRCVD - WaitTransState(pTrans, nCurTrans, - XST_UNADVACKRCVD, 0); - } - } - else - { - ////WRITELOG("DdePostAdvise:PostMsg failed") - nLastErrInstance = DMLERR_POSTMSG_FAILED; - } - } - else - { - ////WRITELOG("DdePostAdvise:No data to send") - } - } - } - } - nCurTrans++; - pTrans++; - } - ////WRITELOG("DdePostAdvise:End") - return TRUE; -} - -BOOL ImpDdeMgr::DdeEnableCallback( HCONV hConv, USHORT wCmd) -{ - return FALSE; -} - -// Rueckgabe: 0==Service nicht registriert; sonst Pointer auf Service-Eintrag -ImpService* ImpDdeMgr::GetService( HSZ hszService ) -{ - ImpService* pPtr = pServices; - if( !pPtr || !hszService ) - return 0; - for( ULONG nIdx = 0; nIdx < nServiceCount; nIdx++, pPtr++ ) - { - if(( hszService == pPtr->hBaseServName ) || - ( hszService == pPtr->hInstServName ) ) - return pPtr; - } - return 0; -} - - -// legt Service in Service-Tabelle ab. Tabelle wird ggf. expandiert -ImpService* ImpDdeMgr::PutService( HSZ hszService ) -{ - if( !pServices ) - { - DBG_ASSERT(nServiceCount==0,"DDE:Bad ServiceCount"); - pServices = new ImpService[ DDEMLSERVICETABLE_INISIZE ]; - memset( pServices, 0, DDEMLSERVICETABLE_INISIZE* sizeof(ImpService)); - nServiceCount = DDEMLSERVICETABLE_INISIZE; - } - ImpService* pPtr = pServices; - USHORT nCurPos = 0; - while( pPtr ) - { - if( pPtr->hBaseServName == 0 ) - break; - nCurPos++; - if( nCurPos < nServiceCount ) - pPtr++; - else - pPtr = 0; - } - if( !pPtr ) - { - // Tabelle vergroessern - pPtr = new ImpService[ nServiceCount + DDEMLSERVICETABLE_INISIZE ]; - memset( pPtr, 0, DDEMLSERVICETABLE_INISIZE* sizeof(ImpService)); - memcpy( pPtr, pServices, nServiceCount * sizeof(ImpService) ); -#ifdef DBG_UTIL - memset( pServices, 0, nServiceCount * sizeof(ImpService) ); -#endif - delete pServices; - pServices = pPtr; - pPtr += nServiceCount; // zeigt auf erste neue Position - nServiceCount += DDEMLSERVICETABLE_INISIZE; - } - DBG_ASSERT(pPtr->hBaseServName==0,"DDE:Service not empty"); - DBG_ASSERT(pPtr->hInstServName==0,"DDE:Service not empty"); - - DdeKeepStringHandle( hszService ); - - USHORT nStrLen = (USHORT)DdeQueryString( hszService, 0, 0, 0); - char* pBuf = new char[ nStrLen + 1 ]; - DdeQueryString(hszService, pBuf, nStrLen, 850 /* CodePage*/ ); - pBuf[ nStrLen ] = 0; - String aStr( (ULONG)hWndServer ); - aStr += pBuf; - HSZ hszInstServ = DdeCreateStringHandle( (PSZ)(const char*)pBuf, 850 ); - delete [] pBuf; - - pPtr->hBaseServName = hszService; - pPtr->hInstServName = hszInstServ; - return pPtr; -} - -void ImpDdeMgr::BroadcastService( ImpService* pService, BOOL bRegistered ) -{ - DBG_ASSERT(pService,"DDE:No Service"); - if( !pService ) - return; - MPARAM aMp1 = (MPARAM)(pService->hBaseServName); - MPARAM aMp2 = (MPARAM)(pService->hInstServName); - ULONG nMsg; - if( bRegistered ) - nMsg = WM_DDEML_REGISTER; - else - nMsg = WM_DDEML_UNREGISTER; - - HWND* pPtr = pAppTable; - for( USHORT nPos = 0; nPos < pData->nMaxAppCount; nPos++, pPtr++ ) - { - HWND hWndCurWin = *pPtr; - if ( hWndCurWin && hWndCurWin != hWndServer ) - WinSendMsg( hWndCurWin, nMsg, aMp1, aMp2 ); - } -} - -HDDEDATA ImpDdeMgr::DdeNameService( HSZ hszService, USHORT afCmd ) -{ - HDDEDATA hRet = (HDDEDATA)1; - - if( afCmd & DNS_FILTERON ) - bServFilterOn = TRUE; - else if( afCmd & DNS_FILTEROFF ) - bServFilterOn = FALSE; - ImpService* pService = GetService( hszService ); - BOOL bRegister = (BOOL)(afCmd & DNS_REGISTER); - if( bRegister ) - { - if( !pService ) - { - pService = PutService( hszService ); - BroadcastService( pService, TRUE ); - } - } - else - { - if( pService ) - { - BroadcastService( pService, FALSE ); - DdeFreeStringHandle( pService->hBaseServName ); - pService->hBaseServName = 0; - DdeFreeStringHandle( pService->hInstServName ); - pService->hInstServName = 0; - } - hRet = (HDDEDATA)0; // Service nicht gefunden - } - return hRet; -} - - -// static -HDDEDATA ImpDdeMgr::DdeClientTransaction(void* pDdeData, ULONG cbData, - HCONV hConv, HSZ hszItem, USHORT nFormat, USHORT nType, - ULONG nTimeout, ULONG* pResult) -{ - //WRITELOG("DdeClientTransaction:Start") - -#if 0 && defined(OV_DEBUG) - if( nType == XTYP_REQUEST ) - { - WRITELOG("Start XTYP_REQUEST"); - WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, - "Start XTYP_REQUEST","DdeClientTransaction", - HWND_DESKTOP,MB_OK); - } -#endif - - if( pResult ) - *pResult = 0; - - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if ( !pData ) - { - ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED; - return (HDDEDATA)0; - } - - BOOL bIsDdeHandle = (BOOL)(pDdeData && cbData==0xffffffff); - BOOL bAppOwnsHandle = (BOOL)( bIsDdeHandle && - (((DDESTRUCT*)pDdeData)->fsStatus & IMP_HDATAAPPOWNED) ); - - BOOL bNoData = (BOOL)(nType & XTYPF_NODATA)!=0; - BOOL bAckReq = (BOOL)(nType & XTYPF_ACKREQ)!=0; - USHORT nTypeFlags = nType & XTYPF_MASK; - nType &= (~XTYPF_MASK); - - BOOL bSync = (BOOL)( nTimeout != TIMEOUT_ASYNC ) != 0; - if( nType == XTYP_ADVSTART ) - bSync = TRUE; - - // Mapping transaction -> OS/2-Message - USHORT nTimeoutErr, nMsg; - switch ( nType ) - { - case XTYP_ADVSTART: - nMsg = WM_DDE_ADVISE; - nTimeoutErr = DMLERR_ADVACKTIMEOUT; -{ - nTimeout = 60000; -#if 0 && defined(OV_DEBUG) - char aBuf[ 128 ]; - ImpDdeMgr::DdeQueryString( hszItem,aBuf,127,850); - String aXXStr("Establishing hotlink "); - aXXStr += aBuf; - WRITELOG((char*)aXXStr.GetStr()); -#endif - -} - break; - - case XTYP_ADVSTOP: - nMsg = WM_DDE_UNADVISE; - nTimeoutErr = DMLERR_UNADVACKTIMEOUT; - break; - - case XTYP_REQUEST: - nMsg = WM_DDE_REQUEST; - nTimeoutErr = DMLERR_DATAACKTIMEOUT; - break; - - case XTYP_POKE: - nMsg = WM_DDE_POKE; - nTimeoutErr = DMLERR_POKEACKTIMEOUT; - break; - - case XTYP_EXECUTE: - nMsg = WM_DDE_EXECUTE; - nTimeoutErr = DMLERR_EXECACKTIMEOUT; - break; - - default: - nMsg = 0; - } - if(!hConv || (USHORT)hConv>= pData->nMaxConvCount || !nType || !nMsg || - (nType != XTYP_EXECUTE && (!hszItem || !nFormat)) ) - { - WRITELOG("DdeClientTransaction:Invalid parameter") - ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER; - if( bIsDdeHandle && !bAppOwnsHandle ) - DdeFreeDataHandle( (HDDEDATA)pDdeData ); - return (HDDEDATA)0; - } - - // ueber den Conversation handle das ImpDdeMgr-Objekt holen - ImpHCONV* pConv = GetConvTable( pData ); - pConv += (USHORT)hConv; - ImpConvWndData* pObj = - (ImpConvWndData*)WinQueryWindowULong( pConv->hWndThis, 0 ); - ImpDdeMgr* pThis = pObj->pThis; - - if( bSync && pThis->bInSyncTrans ) - { - WRITELOG("DdeClientTransaction:Already in sync. transaction") - ImpDdeMgr::nLastErrInstance = DMLERR_REENTRANCY; - if( bIsDdeHandle && !bAppOwnsHandle ) - DdeFreeDataHandle( (HDDEDATA)pDdeData ); - return (HDDEDATA)0; - } - - Transaction* pTrans; - - BOOL bReqOnAdvLoop = FALSE; - ULONG nTransId = GetTransaction( pData, hConv, hszItem, nFormat ); - if( nTransId ) - { - // WRITELOG("DdeClientTransaction:Transaction found") - pTrans = GetTransTable( pData ); - pTrans += (USHORT)nTransId; - USHORT nTransType = pTrans->nType; - nTransType &= (~XTYPF_MASK); - if( (nType != XTYP_REQUEST && nTransType == nType) || - // wird Advise-Loop schon zum requesten missbraucht ? - (nType == XTYP_REQUEST && - nTransType == XTYP_ADVREQ && - pTrans->nConvst == XST_WAITING_REQDATA)) - { - // dieser Kanal ist dicht! - WRITELOG("DdeClientTransaction:Transaction already used") - ImpDdeMgr::nLastErrInstance = DMLERR_REENTRANCY; - if( bIsDdeHandle && !bAppOwnsHandle ) - DdeFreeDataHandle( (HDDEDATA)pDdeData ); - return (HDDEDATA)0; - } - else if( nTransType == XTYP_ADVREQ ) - { - switch( nType ) - { - case XTYP_ADVSTOP: - //WRITELOG("DdeClientTransaction:Stopping advise trans") - pTrans->nType = XTYP_ADVSTOP; - break; - - case XTYP_ADVSTART: - //WRITELOG("DdeClientTransaction:Adj. Advise-Params") - pTrans->nType = XTYP_ADVREQ; - if( bNoData ) - pTrans->nType |= XTYPF_NODATA; - if( bAckReq ) - pTrans->nType |= XTYPF_ACKREQ; - if( pResult ) - *pResult = nTransId; - return (HDDEDATA)TRUE; - - case XTYP_REQUEST: - // WRITELOG("DdeClientTransaction:Using adv trans for req") - // nConvst wird unten auf XST_WAITING_REQDATA gesetzt - bReqOnAdvLoop = TRUE; - break; - - default: - WRITELOG("DdeClientTransaction:Invalid parameter") - ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER; - if( bIsDdeHandle && !bAppOwnsHandle ) - DdeFreeDataHandle( (HDDEDATA)pDdeData ); - return (HDDEDATA)FALSE; - } - } - } - else - { - // WRITELOG("DdeClientTransaction:Creating transaction") - nTransId = CreateTransaction(pData, hConv, hszItem, nFormat, nType); - } - - pTrans = GetTransTable( pData ); - pTrans += (USHORT)nTransId; - pTrans->nConvst = XST_WAITING_ACK; - if( nType == XTYP_REQUEST ) - pTrans->nConvst = XST_WAITING_REQDATA; - - HWND hWndServer = pConv->hWndPartner; - HWND hWndClient = pConv->hWndThis; - - HDDEDATA pOutDDEData; - if( bIsDdeHandle ) - { - if( bAppOwnsHandle ) - { - // wir muessen leider leider duplizieren, da uns OS/2 - // keine Chance laesst, diesen Status im Datenobjekt - // zu versenken. - ////WRITELOG("DdeClientTransaction:Copying handle") - HDDEDATA pNew; - HDDEDATA pData = (HDDEDATA)pDdeData; - if( !(MyDosAllocSharedMem((PPVOID)&pNew, NULL, pData->cbData, - PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE | OBJ_ANY, - "MakeDDEObject"))) - { - memcpy( pNew, pData, pData->cbData ); - pOutDDEData = pNew; - } - else - { - WRITELOG("DdeClientTransaction:No Memory") - ImpDdeMgr::nLastErrInstance = DMLERR_LOW_MEMORY; - return (HDDEDATA)0; - } - } - else - pOutDDEData = (HDDEDATA)pDdeData; - } - else - pOutDDEData=MakeDDEObject(hWndServer,hszItem,0,nFormat,pDdeData,cbData); - - pOutDDEData->fsStatus |= nTypeFlags; - - HDDEDATA pDDEInData = 0; - if( bSync ) - { - if( nType != XTYP_REQUEST ) - pOutDDEData->fsStatus |= DDE_FACKREQ; - - // WRITELOG("DdeClientTransaction:Starting sync. trans.") - pThis->hSyncResponseData = (HDDEDATA)0; - pThis->nSyncResponseMsg = 0; - pThis->bInSyncTrans = TRUE; - pThis->nSyncTransId = nTransId; - pThis->bSyncAbandonTrans = FALSE; - - if ( !MyWinDdePostMsg( hWndServer, hWndClient, nMsg, pOutDDEData, - DDEPM_RETRY) ) - { - WRITELOG("DdeClientTransaction:PostMsg failed") - nLastErrInstance = DMLERR_POSTMSG_FAILED; - if( !bReqOnAdvLoop ) - FreeTransaction( pData, nTransId ); - else - { - DBG_ASSERT(pTrans->nType==XTYP_ADVREQ,"DDE:Error!") - pTrans->nConvst = 0; - } - return FALSE; - } - HAB hAB = WinQueryAnchorBlock( hWndClient ); - ULONG nDummyTimer = WinStartTimer( hAB, 0, 0, 50 ); - ULONG nTimeoutId = TID_USERMAX - nTransId; - WinStartTimer( hAB, hWndClient, nTimeoutId, nTimeout ); - QMSG aQueueMsg; - BOOL bLoop = TRUE; - while( bLoop ) - { - if( pThis->nSyncResponseMsg ) - bLoop = FALSE; - else - { - if( WinGetMsg(hAB,&aQueueMsg,0,0,0 )) - { - WinDispatchMsg( hAB, &aQueueMsg ); - } - else - bLoop = FALSE; - } - } - - WinStopTimer( hAB, hWndClient, nTimeoutId ); - WinStopTimer( hAB, 0, nDummyTimer ); - - // - // Der Speicherblock pOutDDEData muss vom Server geloescht worden sein! - // Ueberlegen: Nochmal loeschen, falls Server buggy ist, ansonsten - // platzt uns bald der Adressraum! - // - if( !pThis->nSyncResponseMsg ) - { - // unsere App wurde beendet - ////WRITELOG("DdeClientTransaction:App terminated") - return 0; - } - pDDEInData = pThis->hSyncResponseData; - nMsg = pThis->nSyncResponseMsg; - pThis->hSyncResponseData= 0; - pThis->nSyncResponseMsg = 0; - pThis->bInSyncTrans = FALSE; - pThis->nSyncTransId = 0; - if( !pDDEInData && nMsg != WM_TIMER ) - { - DBG_ASSERT(0,"Dde:No data!"); - WRITELOG("DdeClientTransaction: No Data!") - return (HDDEDATA)0; - } - switch( nMsg ) - { - case WM_TIMER: - WRITELOG("DdeClientTransaction:Timeout!") - nLastErrInstance = nTimeoutErr; - if( bReqOnAdvLoop ) - // auf normalen Loop-Betrieb zurueckschalten - pTrans->nConvst = XST_WAITING_ADVDATA; - break; - - case WM_DDE_ACK: - { - // WRITELOG("DdeClientTransaction:Ack received") - BOOL bPositive = (BOOL)(pDDEInData->fsStatus & DDE_FACK); - MyDosFreeMem( pDDEInData,"DdeClientTransaction" ); - pDDEInData = (HDDEDATA)bPositive; - if( nType == XTYP_ADVSTART && pDDEInData ) - { - -#if 0 && defined(OV_DEBUG) - char aBuf[ 128 ]; - ImpDdeMgr::DdeQueryString( pTrans->hszItem,aBuf,128,850); - String aXXStr("Hotlink "); -#endif - - if( bPositive ) - { - pTrans->nType = XTYP_ADVREQ; - // Hot/Warmlink, Ack - pTrans->nType |= nTypeFlags; - // XST_WAITING_ACK ==> XST_WAITING_ADVDATA - pTrans->nConvst = XST_WAITING_ADVDATA; - -#if 0 && defined(OV_DEBUG) - aXXStr += "established "; - aXXStr += aBuf; -#endif - - } - -#if 0 && defined(OV_DEBUG) - else - { - aXXStr += "failed "; - aXXStr += aBuf; - } - WRITELOG((char*)aXXStr.GetStr()); -#endif - - } - } - break; - - case WM_DDE_DATA: - // WRITELOG("DdeClientTransaction:Data received") - // WRITEDATA(pDDEInData) - if( bReqOnAdvLoop ) - { - DBG_ASSERT(pTrans->nConvst==XST_WAITING_REQDATA,"DDE:Bad state"); - DBG_ASSERT(pTrans->nType==XTYP_ADVREQ,"DDE:Bad state"); - // auf Loop-Betrieb umschalten - pTrans->nConvst = XST_WAITING_ADVDATA; - } - break; - - default: - WRITELOG("DdeClientTransaction:Unexpected msg") - MyDosFreeMem( pDDEInData,"DdeClientTransaction" ); - pDDEInData = 0; - } - pThis->bSyncAbandonTrans = FALSE; - pThis->bInSyncTrans = FALSE; - if( pThis->bSyncAbandonTrans && bReqOnAdvLoop ) - pThis->DdeAbandonTransaction( hConv, nTransId ); - } - else - { - // WRITELOG("DdeClientTransaction:Starting async. trans.") - pDDEInData = (HDDEDATA)MyWinDdePostMsg( hWndServer, hWndClient, nMsg, - pOutDDEData, DDEPM_RETRY); - if( !pDDEInData ) - { - WRITELOG("DdeClientTransaction:PostMsg failed") - nLastErrInstance = DMLERR_POSTMSG_FAILED; - if( !bReqOnAdvLoop ) - FreeTransaction( pData, nTransId ); - else - { - DBG_ASSERT(pTrans->nType==XTYP_ADVREQ,"DDE:Error!") - pTrans->nConvst = 0; - } - } - else - { - // WRITELOG("DdeClientTransaction:Async trans. success") - if( pResult ) - *pResult = nTransId; - } - } -#if 0 && defined( OV_DEBUG ) - if( nType == XTYP_REQUEST ) - { - WRITELOG("End XTYP_REQUEST"); - WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, - "End XTYP_REQUEST","DdeClientTransaction", - HWND_DESKTOP,MB_OK); - } -#endif - //WRITELOG("DdeClientTransaction:End") - //WRITESTATUS("DdeClientTransaction:End") - return pDDEInData; -} - -MRESULT ImpDdeMgr::DdeRegister( ImpWndProcParams* pParams ) -{ - MRESULT nRet = (MRESULT)0; - if ( !(nTransactFilter & CBF_SKIP_REGISTRATIONS) ) - { - HSZ hSBaseName = (HSZ)pParams->nPar1; - HSZ hIBaseName = (HSZ)pParams->nPar2; - nRet=(MRESULT)Callback(XTYP_REGISTER,0,0,hSBaseName,hIBaseName,0,0,0); - } - return nRet; -} - -MRESULT ImpDdeMgr::DdeUnregister( ImpWndProcParams* pParams ) -{ - MRESULT nRet = (MRESULT)0; - if ( !(nTransactFilter & CBF_SKIP_UNREGISTRATIONS) ) - { - HSZ hSBaseName = (HSZ)pParams->nPar1; - HSZ hIBaseName = (HSZ)pParams->nPar2; - nRet=(MRESULT)Callback(XTYP_UNREGISTER,0,0,hSBaseName,hIBaseName,0,0,0); - } - return nRet; -} - -MRESULT ImpDdeMgr::DdeTimeout( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeTimeout:Received") - if( nSyncResponseMsg ) - { - ////WRITELOG("DdeTimeout:Trans already processed->ignoring timeout") - return (MRESULT)1; - } - ULONG nTimerId = (ULONG)pParams->nPar1; - ULONG nTransId = TID_USERMAX - nTimerId; - Transaction* pTrans = pTransTable; - pTrans += (USHORT)nTransId; - if( nTransId < 1 || nTransId >= pData->nMaxTransCount || - pTrans->hConvOwner == 0 ) - { - DBG_ASSERT(0,"DdeTimeout:Invalid TransactionId"); - return (MRESULT)1; - } - if( bInSyncTrans && nTransId == nSyncTransId ) - { - USHORT nTempType = pTrans->nType; - nTempType &= (~XTYPF_MASK); - // advise-loops koennen nur innerhalb synchroner - // requests timeouts bekommen. die transaktion wird - // in diesem fall nicht geloescht. - if( nTempType != (XTYP_ADVREQ & (~XTYPF_NOBLOCK) )) - { - ////WRITELOG("DdeTimeout:Freeing transaction") - FreeTransaction( pData, nTransId ); - } - nSyncResponseMsg = WM_TIMER; -#if 0 && defined( OV_DEBUG ) - String aMsg("DdeTimeout:Transaction="); - aMsg += nTransId; - WRITELOG((char*)(const char*)aMsg) -#endif - } - else - { - ////WRITELOG("DdeTimeout:Async transaction timed out") - pTrans->nConvst = XST_TIMEOUT; - } - return (MRESULT)1; -} - - - -MRESULT ImpDdeMgr::DdeTerminate( ImpWndProcParams* pParams ) -{ - WRITELOG("DdeTerminate:Received") - HWND hWndThis = pParams->hWndReceiver; - HWND hWndPartner = (HWND)(pParams->nPar1); - - HCONV hConv = GetConvHandle( pData, hWndThis, hWndPartner ); -#if 0 && defined( OV_DEBUG ) - String strDebug("DdeTerminate:ConvHandle="); - strDebug += (USHORT)hConv; - WRITELOG((char*)(const char*)strDebug) -#endif - ImpHCONV* pConv = pConvTable + (USHORT)hConv; - if( hConv ) - { - // warten wir auf ein DDE_TERMINATE Acknowledge ? - if( pConv->nStatus & ST_TERMINATED ) - { - ////WRITELOG("DdeTerminate:TERMINATE-Ack received") - pConv->nStatus |= ST_TERMACKREC; - return (MRESULT)0; // DdeDisconnect raeumt jetzt auf - } - - // sind wir Server?, wenn ja: die App benachrichtigen, - // dass die Advise loops gestoppt wurden und die - // Transaktionen loeschen - - // OV 26.07.96: Die das TERMINATE empfangende App muss - // die Transaction-Tabelle abraeumen, egal ob Server oder Client!! - // Es muessen alle Trans geloescht werden, die als Owner den - // Client oder den Server haben! - // if( !(pConv->nStatus & ST_CLIENT ) ) - SendUnadvises( hConv, 0, FALSE ); // alle Formate & nicht loeschen - SendUnadvises( pConv->hConvPartner, 0, FALSE ); - - // wir werden von draussen gekillt - if ( !(nTransactFilter & CBF_SKIP_DISCONNECTS) ) - { - Callback( XTYP_DISCONNECT, 0, hConv, 0, 0, 0, - 0, (ULONG)IsSameInstance(hWndPartner)); - } - - // kann unsere Partner-App DDEML ? - if( !(pConv->hConvPartner) ) - { - // nein, deshalb Transaktionstabelle selbst loeschen - ////WRITELOG("DdeTerminate:Freeing transactions") - FreeTransactions( pData, hConv ); - } - } - else - nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED; - -#if 0 && defined(OV_DEBUG) - if( !WinIsWindow(0,hWndPartner)) - { - WRITELOG("DdeTerminate:hWndPartner not valid") - } - if(!WinIsWindow(0,hWndThis)) - { - WRITELOG("DdeTerminate:hWndThis not valid") - } -#endif - - if( hConv ) - { - // hWndThis nicht loeschen, da wir den Handle noch fuer - // das Acknowledge brauchen - ////WRITELOG("DdeTerminate:Freeing conversation") - FreeConvHandle( pData, hConv, FALSE ); - } - - ////WRITELOG("DdeTerminate:Acknowledging DDE_TERMINATE") - -#ifdef OV_DEBUG - DBG_ASSERT(WinIsWindow( 0, hWndThis ),"hWndThis not valid"); -#endif - - if( !WinDdePostMsg( hWndPartner, hWndThis, WM_DDE_TERMINATE, 0, DDEPM_RETRY )) - { - ////WRITELOG("DdeTerminate:Acknowledging DDE_TERMINATE failed") - } - // jetzt hWndThis loeschen - DestroyConversationWnd( hWndThis ); - - return (MRESULT)0; -} - - -/* - Zuordnung des Conversationhandles: - - Verbindungsaufbau: - Client: DdeInitiate( HWNDClient ) - Server: Post( WM_DDE_INITIATEACK( HWNDServer )) - Client: CreateConvHandle( HWNDClient, HWNDServer ) - - Datenaustausch: - Server: Post(WM_DDE_ACK( HWNDSender )) - Client: GetConvHandle( HWNDClient, HWNDSender ) -*/ - -MRESULT ImpDdeMgr::ConvWndProc( HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2 ) -{ - ImpWndProcParams aParams; - - MRESULT nRet = (MRESULT)0; - aParams.hWndReceiver= hWnd; - aParams.nPar1 = nPar1; - aParams.nPar2 = nPar2; - - switch( nMsg ) - { - -#ifdef DBG_UTIL - case WM_DDE_INITIATE : - DBG_ASSERT(0,"dde:unexpected msg"); - nRet = (MRESULT)TRUE; - break; -#endif - - case WM_DDE_INITIATEACK : nRet = DdeInitiateAck(&aParams); break; - case WM_DDE_ACK : nRet = DdeAck( &aParams ); break; - case WM_DDE_ADVISE : nRet = DdeAdvise( &aParams ); break; - case WM_DDE_DATA : nRet = DdeData( &aParams ); break; - case WM_DDE_EXECUTE : nRet = DdeExecute( &aParams ); break; - case WM_DDE_POKE : nRet = DdePoke( &aParams ); break; - case WM_DDE_REQUEST : nRet = DdeRequest( &aParams ); break; - case WM_DDE_TERMINATE : nRet = DdeTerminate( &aParams ); break; - case WM_DDE_UNADVISE : nRet = DdeUnadvise( &aParams ); break; - case WM_TIMER : nRet = DdeTimeout( &aParams ); break; - } - return nRet; -} - -MRESULT ImpDdeMgr::SrvWndProc( HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2 ) -{ - MRESULT nRet = (MRESULT)0; - - ImpWndProcParams aParams; - aParams.hWndReceiver= hWnd; - aParams.nPar1 = nPar1; - aParams.nPar2 = nPar2; - - switch( nMsg ) - { -#ifdef DBG_UTIL - case WM_DDE_ACK : - case WM_DDE_ADVISE : - case WM_DDE_EXECUTE : - case WM_DDE_POKE : - case WM_DDE_REQUEST : - case WM_DDE_UNADVISE : - case WM_DDE_DATA : - case WM_DDE_INITIATEACK : - DBG_ASSERT(0,"dde:unexpected msg"); - nRet = (MRESULT)TRUE; - break; -#endif - - case WM_DDE_TERMINATE : - break; // DDE_INITIATE wurde im DDE_INITIATEACK terminiert - - // ein Client will was von uns - case WM_DDE_INITIATE : - nRet = DdeInitiate( &aParams ); - break; - - // eine ddeml-faehige App. hat einen Service (typ. AppName) [de]reg. - case WM_DDEML_REGISTER : - nRet = DdeRegister( &aParams ); - break; - - case WM_DDEML_UNREGISTER : - nRet = DdeUnregister( &aParams ); - break; - }; - return nRet; -} - - -MRESULT ImpDdeMgr::DdeAck( ImpWndProcParams* pParams ) -{ - //WRITELOG("DdeAck:Start") - HSZ hszItem; - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - if( pInDDEData ) - { - BOOL bPositive = (BOOL)(pInDDEData->fsStatus & DDE_FACK ) != 0; - BOOL bBusy = bPositive ? FALSE : (BOOL)(pInDDEData->fsStatus & DDE_FBUSY ) != 0; - BOOL bNotProcessed = (BOOL)(pInDDEData->fsStatus & DDE_NOTPROCESSED ) != 0; -#if 0 && defined( OV_DEBUG ) - String aDebStr("DdeAck:Received "); - if( bPositive ) - aDebStr += "(positive)"; - else - aDebStr += "(negative)"; - if( bBusy ) - aDebStr += "(busy)"; - if( bNotProcessed ) - aDebStr += "(not processed)"; - WRITELOG((char*)(const char*)aDebStr) -#endif - // ein DDE_ACK niemals bestaetigen (um endlosschleifen zu vermeiden) - pInDDEData->fsStatus &= (~DDE_FACKREQ); - } - else - { - //WRITELOG("DdeAck:Received (no data!)") - return (MRESULT)0; - } - - HCONV hConv = CheckIncoming(pParams, 0, hszItem); -#ifdef OV_DEBUG - if( !hConv ) - { - WRITELOG("DdeAck:HCONV not found") - } -#endif - ULONG nTransId=GetTransaction(pData,hConv,hszItem,pInDDEData->usFormat); - if( !nTransId ) - { - WRITELOG("DdeAck:Transaction not found") - MyDosFreeMem( pInDDEData,"DdeAck" ); - return (MRESULT)0; - } - - BOOL bThisIsSync = (BOOL)( bInSyncTrans && nTransId == nSyncTransId ); -#if 0 && defined( OV_DEBUG ) - if( bThisIsSync) - WRITELOG("DdeAck: sync transaction") - else - WRITELOG("DdeAck: async transaction") -#endif - // pruefen, ob die Transaktion abgeschlossen ist. - Transaction* pTrans = pTransTable; - pTrans += (USHORT)nTransId; - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - - if( pTrans->nConvst == XST_UNADVSENT ) - { - //WRITELOG("DdeAck:Unadvise-Ack received") - pTrans->nConvst = XST_UNADVACKRCVD; - MyDosFreeMem( pInDDEData,"DdeAck" ); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; - } - if( pTrans->nConvst == XST_ADVDATASENT ) - { - //WRITELOG("DdeAck:AdvData-Ack received") - pTrans->nConvst = XST_ADVDATAACKRCVD; - MyDosFreeMem( pInDDEData,"DdeAck" ); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; - } - - USHORT nType = pTrans->nType; - nType &= (~XTYPF_MASK); - // beginn einer advise-loop oder request auf advise-loop ? - // wenn ja: transaktion nicht loeschen - BOOL bFinished = (BOOL)(nType != XTYP_ADVSTART && - nType != (XTYP_ADVREQ & (~XTYPF_NOBLOCK)) ); - if( bFinished ) - { - if( !bThisIsSync ) - { - ////WRITELOG("DdeAck:Transaction completed") - Callback( XTYP_XACT_COMPLETE, pInDDEData->usFormat, hConv, - pConv->hszTopic, hszItem, (HDDEDATA)0, nTransId, 0 ); - } - ////WRITELOG("DdeAck:Freeing transaction") - FreeTransaction( pData, nTransId ); - } - - if( bThisIsSync ) - { - hSyncResponseData = pInDDEData; - nSyncResponseMsg = WM_DDE_ACK; - } - else - { - MyDosFreeMem( pInDDEData,"DdeAck" ); - } - - DdeFreeStringHandle( hszItem ); - - return (MRESULT)0; -} - - -USHORT ImpDdeMgr::SendUnadvises(HCONV hConvServer,USHORT nFormat,BOOL bFree) -{ - USHORT nTransFound = 0; - BOOL bCallApp = (BOOL)(!(nTransactFilter & CBF_FAIL_ADVISES)); -#if 0 && defined( OV_DEBUG ) - String aStr("Unadvising transactions for HCONV="); - aStr += (ULONG)hConvServer; - aStr += " CallApp:"; aStr += (USHORT)bCallApp; - WRITELOG((char*)aStr.GetStr()) -#endif - - - // wenn wir weder loeschen noch die App benachrichtigen sollen, - // koennen wir gleich wieder returnen - if( !hConvServer || ( !bFree && !bCallApp ) ) - return 0; - - ImpHCONV* pConvSrv = pConvTable; - pConvSrv += (USHORT)hConvServer; - HSZ hszTopic = pConvSrv->hszTopic; - - Transaction* pTrans = pTransTable; - pTrans++; - USHORT nCurTransId = 1; - USHORT nCurTransactions = pData->nCurTransCount; - while( nCurTransactions && nCurTransId < pData->nMaxTransCount ) - { - if( pTrans->hConvOwner ) - nCurTransactions--; - if( pTrans->hConvOwner == hConvServer && - (pTrans->nType & XTYP_ADVREQ) ) - { - if( !nFormat || (nFormat == pTrans->nFormat) ) - { - nTransFound++; - if( bCallApp ) - { - //WRITELOG("SendUnadvises:Notifying App") - Callback( XTYP_ADVSTOP, pTrans->nFormat, hConvServer, - hszTopic, pTrans->hszItem, 0,0,0 ); - } - if( bFree ) - FreeTransaction( pData, (ULONG)nCurTransId ); - } - } - nCurTransId++; - pTrans++; - } - return nTransFound; -} - - - -HCONV ImpDdeMgr::CheckIncoming( ImpWndProcParams* pParams, ULONG nTransMask, - HSZ& rhszItem ) -{ -// ////WRITELOG("CheckIncoming") - rhszItem = 0; - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - if( !pInDDEData ) - { - // ////WRITELOG("CheckIncoming:PDDESTRUCT==0") - return (HCONV)0; - } - - HWND hWndThis = pParams->hWndReceiver; - HWND hWndClient = (HWND)pParams->nPar1; - - BOOL bReject = (BOOL)(nTransactFilter & nTransMask); - HCONV hConv; - if( !bReject ) - hConv = GetConvHandle( pData, hWndThis, hWndClient ); - if ( bReject || !hConv ) - return (HCONV)0; - - rhszItem = DdeCreateStringHandle( - ((char*)(pInDDEData)+pInDDEData->offszItemName), 850 ); - - // ////WRITELOG("CheckIncoming:OK"); - return hConv; -} - - -MRESULT ImpDdeMgr::DdeAdvise( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeAdvise:Received") - HSZ hszItem; - HCONV hConv = CheckIncoming(pParams, CBF_FAIL_ADVISES, hszItem); - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - HWND hWndThis = pParams->hWndReceiver; - HWND hWndClient = (HWND)pParams->nPar1; - if( !hConv ) - { - ////WRITELOG("DdeAdvise:Conversation not found") - pInDDEData->fsStatus &= (~DDE_FACK); - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; - } - - Transaction* pTrans = pTransTable; - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - - // existiert schon ein Link auf Topic/Item/Format-Vektor ? - - ULONG nTransId=GetTransaction(pData,hConv,hszItem,pInDDEData->usFormat); - if( nTransId ) - { - ////WRITELOG("DdeAdvise:Transaction already exists") - pTrans += (USHORT)nTransId; - // ist es eine AdviseLoop ? - USHORT nTempType = pTrans->nType; - nTempType &= (~XTYPF_MASK); - if( nTempType == XTYP_ADVREQ ) - { - // Flags der laufenden Advise-Loop aktualisieren - ////WRITELOG("DdeAdvise:Adjusting Advise-Params") - pTrans->nType = XTYP_ADVREQ; - if( pInDDEData->fsStatus & DDE_FNODATA ) - pTrans->nType |= XTYPF_NODATA; - if( pInDDEData->fsStatus & DDE_FACKREQ ) - pTrans->nType |= XTYPF_ACKREQ; - pInDDEData->fsStatus |= DDE_FACK; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; - } - else if( nTempType != XTYP_ADVSTART ) - { - ////WRITELOG("DdeAdvise:Not a advise transaction") - pInDDEData->fsStatus &= (~DDE_FACK); - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; - } - } - - if( !nTransId ) - { - ////WRITELOG("DdeAdvise:Creating Transaction") - ////WRITESTATUS("DdeAdvise:Creating Transaction") - nTransId = CreateTransaction( pData, hConv, hszItem, - pInDDEData->usFormat, XTYP_ADVREQ ); - ////WRITESTATUS("DdeAdvise:Created Transaction") - } - if( nTransId ) - { - pTrans = pTransTable; - pTrans += (USHORT)nTransId; - if( pInDDEData->fsStatus & DDE_FNODATA ) - pTrans->nType |= XTYPF_NODATA; - if( pInDDEData->fsStatus & DDE_FACKREQ ) - pTrans->nType |= XTYPF_ACKREQ; - } - else - { - ////WRITELOG("DdeAdvise:Cannot create Transaction") - pInDDEData->fsStatus &= (~DDE_FACK); - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; - } - - ////WRITELOG("DdeAdvise:Calling Server") - - if ( Callback( XTYP_ADVSTART, pInDDEData->usFormat, - hConv, pConv->hszTopic, hszItem, (HDDEDATA)0, 0, 0 ) ) - { - // - // ServerApp erlaubt AdviseLoop - // - ////WRITELOG("DdeAdvise:Advise loop established") - pInDDEData->fsStatus |= DDE_FACK; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - else - { - ////WRITELOG("DdeAdvise:Advise loop not established") - FreeTransaction( pData, nTransId ); - pInDDEData->fsStatus &= (~DDE_FACK); // DDE_FNOTPROCESSED; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - ////WRITESTATUS("DdeAdvise:End") - ////WRITELOG("DdeAdvise:End") - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; -} - -MRESULT ImpDdeMgr::DdeData( ImpWndProcParams* pParams ) -{ - WRITELOG("DdeData:Received") - HSZ hszItem; - HCONV hConv = CheckIncoming(pParams, 0, hszItem); - HWND hWndThis = pParams->hWndReceiver; - HWND hWndClient = (HWND)pParams->nPar1; - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); -#if 0 && defined( OV_DEBUG ) - { - String aStr("DdeData Address:"); - aStr += (ULONG)pInDDEData; - WRITELOG((char*)aStr.GetStr()) - } -#endif - - BOOL bSendAck; - if( pInDDEData && (pInDDEData->fsStatus & DDE_FACKREQ )) - { - WRITELOG("DdeData: Ackn requested") - bSendAck = TRUE; - } - else - { - WRITELOG("DdeData: Ackn not requested") - bSendAck = FALSE; - } - - ULONG nTransId = GetTransaction(pData,hConv,hszItem,pInDDEData->usFormat); - if( !nTransId ) - { - WRITELOG("DdeData:Transaction not found") - WRITEDATA(pInDDEData) - if( bSendAck ) - { - WRITELOG("DdeData: Posting Ackn") - pInDDEData->fsStatus &= (~DDE_FACK); // NOTPROCESSED; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - else - { - MyDosFreeMem( pInDDEData,"DdeData" ); - } - return (MRESULT)0; - } - -#if 0 && defined( OV_DEBUG ) - if( pInDDEData ) - { - WRITEDATA(pInDDEData) - } -#endif - - BOOL bThisIsSync = (BOOL)( bInSyncTrans && nTransId == nSyncTransId ); - - // pruefen, ob die Transaktion abgeschlossen ist. - Transaction* pTrans = pTransTable; - pTrans += (USHORT)nTransId; - - if( pTrans->nConvst == XST_WAITING_ACK ) - { - // dieser Fall kann eintreten, wenn ein Server innerhalb - // einer WM_DDE_ADVISE-Msg. oder bevor beim Client das - // Ack eintrifft, Advise-Daten sendet. - WRITELOG("DdeData:Ignoring unexpected data") - if( bSendAck ) - { - WRITELOG("DdeData: Posting Ackn") - pInDDEData->fsStatus &= (~DDE_FACK); // NOTPROCESSED; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - else - { - MyDosFreeMem( pInDDEData,"DdeData" ); - } - return (MRESULT)0; - } - - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - - USHORT nType = pTrans->nType; - nType &= (~XTYPF_MASK); - BOOL bNotAdviseLoop = (BOOL)(nType != (XTYP_ADVREQ & (~XTYPF_NOBLOCK))); - if( !bThisIsSync ) - { - // WRITELOG("DdeData:Is async transaction") - if( bNotAdviseLoop ) - { - // WRITELOG("DdeData:Transaction completed -> calling client") - Callback( XTYP_XACT_COMPLETE, pInDDEData->usFormat, hConv, - pConv->hszTopic, hszItem, pInDDEData, nTransId, 0 ); - // WRITELOG("DdeData:Freeing transaction") - FreeTransaction( pData, nTransId ); - } - else - { - WRITELOG("DdeData:Advise-Loop -> calling client") - HDDEDATA pToSend = pInDDEData; - if( pTrans->nType & XTYPF_NODATA ) - { - pToSend = 0; - // WRITELOG("DdeData:Is warm link") - } - Callback( XTYP_ADVDATA, pInDDEData->usFormat, hConv, - pConv->hszTopic, hszItem, pToSend, nTransId, 0 ); - } - if( bSendAck ) - { - WRITELOG("DdeData: Posting Ackn") - pInDDEData->fsStatus = DDE_FACK; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - else - MyDosFreeMem( pInDDEData,"DdeData" ); - } - else // synchrone Transaktion (Datenhandle nicht freigeben!) - { - // WRITELOG("DdeData:Is sync transaction") - hSyncResponseData = pInDDEData; - nSyncResponseMsg = WM_DDE_DATA; - if( bSendAck ) - { - pInDDEData->fsStatus |= DDE_FACK; - WRITELOG("DdeData: Posting Ackn") - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData, - DDEPM_RETRY | DDEPM_NOFREE ); - } - } - - DdeFreeStringHandle( hszItem ); - // WRITELOG("DdeData:End") - return (MRESULT)0; -} - -MRESULT ImpDdeMgr::DdeExecute( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeExecute:Received") - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - HSZ hszItem; - HCONV hConv = CheckIncoming(pParams, 0, hszItem); - BOOL bSuccess = FALSE; - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - if ( hConv && !(nTransactFilter & CBF_FAIL_EXECUTES) && pInDDEData ) - { - if ( Callback( XTYP_EXECUTE, pInDDEData->usFormat, hConv, - pConv->hszTopic, hszItem, pInDDEData, 0, 0 ) - == (DDESTRUCT*)DDE_FACK ) - bSuccess = TRUE; - } - else - { - ////WRITELOG("DdeExecute:Not processed") - } - if( pInDDEData ) - { - if( bSuccess ) - pInDDEData->fsStatus |= DDE_FACK; - else - pInDDEData->fsStatus &= (~DDE_FACK); - MyWinDdePostMsg( pConv->hWndPartner, pConv->hWndThis, WM_DDE_ACK, - pInDDEData, DDEPM_RETRY ); - } - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; -} - -HCONV ImpDdeMgr::ConnectWithClient( HWND hWndClient, - HSZ hszPartner, HSZ hszService, HSZ hszTopic, BOOL bSameInst, - DDEINIT* pDDEData, CONVCONTEXT* pCC ) -{ - ////WRITELOG("ConnectWithClient:Start") - HWND hWndSrv = CreateConversationWnd(); - IncConversationWndRefCount( hWndSrv ); - HCONV hConv = CreateConvHandle( pData, pidThis, hWndSrv, hWndClient, - hszPartner, hszService, hszTopic ); - if(!hConv ) - return 0; - BOOL bFreeDdeData = FALSE; - if( !pDDEData ) - { - bFreeDdeData = TRUE; - pDDEData = CreateDDEInitData( hWndClient,hszService,hszTopic, pCC ); - PID pid; TID tid; - WinQueryWindowProcess( hWndClient, &pid, &tid ); - DosGiveSharedMem( pDDEData, pid, PAG_READ | PAG_WRITE); - } - HAB hAB = WinQueryAnchorBlock( hWndSrv ); - WinGetLastError( hAB ); // fehlercode zuruecksetzen - WinSendMsg(hWndClient,WM_DDE_INITIATEACK,(MPARAM)hWndSrv,(MPARAM)pDDEData); - if( WinGetLastError( hAB ) ) - { - // ////WRITELOG("DdeConnectWithClient:Client died") - if( bFreeDdeData ) - { - MyDosFreeMem( pDDEData,"ConnectWithClient" ); - } - FreeConvHandle( pData, hConv ); - return (HCONV)0; - } - - if( !(nTransactFilter & CBF_SKIP_CONNECT_CONFIRMS) ) - { - Callback( XTYP_CONNECT_CONFIRM, 0, hConv, hszTopic, hszService, - 0, 0, (ULONG)bSameInst ); - } - - if( bFreeDdeData ) - { - MyDosFreeMem( pDDEData,"ConnectWithClient" ); - } - // HCONV der PartnerApp suchen & bei uns eintragen - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - pConv->hConvPartner = GetConvHandle( pData, hWndClient, hWndSrv ); -#if 0 && defined(OV_DEBUG) - if( !pConv->hConvPartner ) - { - WRITELOG("DdeConnectWithClient:Partner not found") - } -#endif - pConv->nStatus = ST_CONNECTED; - //WRITESTATUS("Server:Connected with client") - //WRITELOG("ConnectWithClient:End") - return hConv; -} - -MRESULT ImpDdeMgr::DdeInitiate( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeInitiate:Received") - HWND hWndClient = (HWND)(pParams->nPar1); -// BOOL bSameInst = IsSameInstance( hWndClient ); - BOOL bSameInst = (BOOL)(hWndClient==hWndServer); - DDEINIT* pDDEData = (DDEINIT*)pParams->nPar2; - - if ( ( nTransactFilter & (CBF_FAIL_CONNECTIONS | APPCMD_CLIENTONLY)) || - (( nTransactFilter & CBF_FAIL_SELFCONNECTIONS) && bSameInst ) - ) - { - MyDosFreeMem( pDDEData,"DdeInitiate" ); - return (MRESULT)FALSE; // narda - } - - HSZ hszService = (HSZ)0; - if( *(pDDEData->pszAppName) != '\0' ) - { - hszService = DdeCreateStringHandle( pDDEData->pszAppName, 850 ); - ////WRITELOG(pDDEData->pszAppName); - } - HSZ hszTopic = (HSZ)0; - if( *(pDDEData->pszTopic) != '\0' ) - { - hszTopic = DdeCreateStringHandle( pDDEData->pszTopic, 850 ); - ////WRITELOG(pDDEData->pszTopic); - } - HSZ hszPartner = GetAppName( hWndClient ); - - // nur weitermachen, wenn Service registriert oder - // Service-Name-Filtering ausgeschaltet. - if( !bServFilterOn || GetService(hszService) ) - { - // XTYP_CONNECT-Transaktionen erfolgen nur mit - // Services & Topics ungleich 0! - if( hszService && hszTopic ) - { - if( IsConvHandleAvailable(pData) && Callback( XTYP_CONNECT, - 0, 0, hszTopic,hszService, 0, 0, (ULONG)bSameInst)) - { - // App erlaubt Verbindung mit Client - ConnectWithClient( hWndClient, hszPartner, - hszService, hszTopic, bSameInst, pDDEData ); - } - } - else - { - // ** Wildcard-Connect ** - ////WRITELOG("DdeInitiate:Wildconnect") - // vom Server eine Liste aller Service/Topic-Paare anfordern - CONVCONTEXT* pCC=(CONVCONTEXT*)(pDDEData+pDDEData->offConvContext); - DDESTRUCT* hList = Callback( XTYP_WILDCONNECT, 0, (HCONV)0, - hszTopic,hszService, (HDDEDATA)0, (ULONG)pCC, (ULONG)bSameInst ); - if( hList ) - { - HSZPAIR* pPairs = (HSZPAIR*)((char*)hList+hList->offabData); - while( pPairs->hszSvc ) - { - ////WRITELOG("DdeInitiate:Wildconnect.Connecting") - ConnectWithClient( hWndClient, hszPartner, - pPairs->hszSvc, pPairs->hszTopic, bSameInst, 0, pCC); - // Stringhandles gehoeren der App! (nicht free-en) - pPairs++; - } - DdeFreeDataHandle( hList ); - } - } - } -#if 0 && defined(OV_DEBUG) - else - { - WRITELOG("DdeInitiate:Service filtered") - } -#endif - DdeFreeStringHandle( hszTopic ); - DdeFreeStringHandle( hszService ); - DdeFreeStringHandle( hszPartner ); - MyDosFreeMem( pDDEData,"DdeInitiate" ); - ////WRITELOG("DdeInitiate:End") - return (MRESULT)TRUE; -} - -MRESULT ImpDdeMgr::DdeInitiateAck( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeInitiateAck:Received") - DDEINIT* pDDEData = (DDEINIT*)(pParams->nPar2); - - if( !bListConnect && hCurConv ) - { - ////WRITELOG("DdeInitiateAck:Already connected") - MyDosFreeMem( pDDEData,"DdeInitiateAck" ); - WinPostMsg( hWndServer, WM_DDE_TERMINATE, (MPARAM)hWndServer, 0 ); - return (MRESULT)FALSE; - } - - HWND hWndThis = pParams->hWndReceiver; - // Referenz-Count unseres Client-Windows inkrementieren - IncConversationWndRefCount( hWndThis ); - - HWND hWndSrv = (HWND)(pParams->nPar1); - HSZ hszService = DdeCreateStringHandle( pDDEData->pszAppName, 850 ); - HSZ hszTopic = DdeCreateStringHandle( pDDEData->pszTopic, 850 ); - HSZ hszPartnerApp = GetAppName( hWndSrv ); - - hCurConv = CreateConvHandle( pData, pidThis, hWndThis, hWndSrv, - hszPartnerApp, hszService, hszTopic, 0 ); - - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hCurConv; - - // HCONV der PartnerApp suchen & bei uns eintragen - pConv->hConvPartner = GetConvHandle( pData, hWndSrv, hWndThis ); - // nicht asserten, da ja non-ddeml-Partner moeglich - // DBG_ASSERT(pConv->hConvPartner,"DDE:Partner not found"); - pConv->nStatus = ST_CONNECTED | ST_CLIENT; - - if( bListConnect ) - { - ////WRITELOG("DdeInitiateAck:ListConnect/Connecting hConvs") - // Status setzen & verketten - pConv->hConvList = hCurListId; - pConv->nPrevHCONV = nPrevConv; - pConv->nStatus |= ST_INLIST; - if( nPrevConv ) - { - pConv = pConvTable; - pConv += nPrevConv; - pConv->nNextHCONV = (USHORT)hCurConv; - } - nPrevConv = (USHORT)hCurConv; - } - - DdeFreeStringHandle( hszService ); - DdeFreeStringHandle( hszTopic ); - DdeFreeStringHandle( hszPartnerApp ); - MyDosFreeMem( pDDEData,"DdeInitiateAck" ); - ////WRITESTATUS("After DdeInitiateAck") - ////WRITELOG("DdeInitiateAck:End") - return (MRESULT)TRUE; -} - -MRESULT ImpDdeMgr::DdePoke( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdePoke:Received") - HSZ hszItem = 0; - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - HCONV hConv = CheckIncoming( pParams, CBF_FAIL_REQUESTS, hszItem ); - BOOL bSuccess =FALSE; - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - if ( hConv && !(nTransactFilter & CBF_FAIL_POKES) && pInDDEData ) - { - if( Callback( XTYP_POKE, pInDDEData->usFormat, hConv, - pConv->hszTopic, hszItem, pInDDEData, 0, 0 ) - == (DDESTRUCT*)DDE_FACK ) - bSuccess = TRUE; - } -#if 0 && defined( OV_DEBUG ) - else - { - WRITELOG("DdePoke:Not processed") - } -#endif - if( pInDDEData ) - { - if( bSuccess ) - pInDDEData->fsStatus |= DDE_FACK; - else - pInDDEData->fsStatus &= (~DDE_FACK); - - MyWinDdePostMsg( pConv->hWndPartner, pConv->hWndThis, WM_DDE_ACK, - pInDDEData, DDEPM_RETRY ); - } - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; -} - -MRESULT ImpDdeMgr::DdeRequest( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeRequest:Received") - HSZ hszItem = 0; - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - if( pInDDEData ) - // ist fuer Requests nicht definiert - pInDDEData->fsStatus = 0; - HCONV hConv = CheckIncoming( pParams, CBF_FAIL_REQUESTS, hszItem ); - HWND hWndThis = pParams->hWndReceiver; - HWND hWndClient = (HWND)pParams->nPar1; - if( hConv ) - { - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - - DDESTRUCT* pOutDDEData = Callback( XTYP_REQUEST, pInDDEData->usFormat, - hConv, pConv->hszTopic, hszItem, (HDDEDATA)0, 0, 0 ); - - if ( !pOutDDEData ) - { - ////WRITELOG("DdeRequest:Not processed") - pInDDEData->fsStatus &= (~DDE_FACK); - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - else - { - ////WRITELOG("DdeRequest:Success") - MyDosFreeMem( pInDDEData,"DdeRequest" ); - pOutDDEData->fsStatus |= DDE_FRESPONSE; - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_DATA,pOutDDEData,DDEPM_RETRY); - } - } - else - { - pInDDEData->fsStatus &= (~DDE_FACK); - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - } - - DdeFreeStringHandle( hszItem ); - ////WRITELOG("DdeRequest:End") - return (MRESULT)0; -} - - -MRESULT ImpDdeMgr::DdeUnadvise( ImpWndProcParams* pParams ) -{ - ////WRITELOG("DdeUnadvise:Received") - - HSZ hszItem; - HCONV hConv = CheckIncoming( pParams, 0, hszItem ); - DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2); - HWND hWndThis = pParams->hWndReceiver; - HWND hWndClient = (HWND)pParams->nPar1; - USHORT nClosedTransactions = 0; - if( hConv ) - { - USHORT nFormat = pInDDEData->usFormat; - // alle Transaktionen des HCONVs loeschen ? - if( !hszItem ) - { - // App benachrichtigen & Transaktionen loeschen - nClosedTransactions = SendUnadvises( hConv, nFormat, TRUE ); - } - else - { - ULONG nTransId = GetTransaction(pData, hConv, hszItem, nFormat); - if( nTransId ) - { - ////WRITELOG("DdeUnadvise:Transaction found") - Transaction* pTrans = pTransTable; - pTrans += (USHORT)nTransId; - ImpHCONV* pConv = pConvTable; - pConv += (USHORT)hConv; - nClosedTransactions = 1; - if( !(nTransactFilter & CBF_FAIL_ADVISES) ) - Callback( XTYP_ADVSTOP, nFormat, hConv, - pConv->hszTopic, hszItem, 0, 0, 0 ); - if( !pConv->hConvPartner ) - FreeTransaction( pData, nTransId ); - } -#if defined(OV_DEBUG) - else - { - WRITELOG("DdeUnadvise:Transaction not found") - } -#endif - } - } -#if defined(OV_DEBUG) - else - { - WRITELOG("DdeUnadvise:Conversation not found") - } -#endif - - if( !nClosedTransactions ) - pInDDEData->fsStatus &= (~DDE_FACK); - else - pInDDEData->fsStatus |= DDE_FACK; - - MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY); - DdeFreeStringHandle( hszItem ); - return (MRESULT)0; -} - -BOOL ImpDdeMgr::WaitTransState( Transaction* pTrans, ULONG nTransId, - USHORT nNewState, ULONG nTimeout ) -{ - ////WRITELOG("WaitTransState:Start") - ImpHCONV* pConv = pConvTable; - pConv += pTrans->hConvOwner; - HAB hAB = WinQueryAnchorBlock( pConv->hWndThis ); - ULONG nTimerId = WinStartTimer( hAB, 0, 0, 50 ); - QMSG aQueueMsg; - -// while( WinGetMsg( hAB, &aQueueMsg, 0, 0, 0 ) && -// WinIsWindow( hAB, pConv->hWndPartner) && -// pTrans->nConvst != nNewState ) -// { -// WinDispatchMsg( hAB, &aQueueMsg ); -// } - - BOOL bContinue = TRUE; - while( bContinue ) - { - if( WinGetMsg( hAB, &aQueueMsg, 0, 0, 0 )) - { - WinDispatchMsg( hAB, &aQueueMsg ); - if( (!WinIsWindow( hAB, pConv->hWndPartner)) || - (pTrans->nConvst == nNewState) ) - { - bContinue = FALSE; - } - } - else - bContinue = FALSE; - } - - WinStopTimer( hAB, 0, nTimerId ); - ////WRITELOG("WaitTransState:End") - return TRUE; -} - - - - diff --git a/svl/source/svdde/ddeml2.cxx b/svl/source/svdde/ddeml2.cxx deleted file mode 100644 index 7de4602d12ff..000000000000 --- a/svl/source/svdde/ddeml2.cxx +++ /dev/null @@ -1,1011 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svl.hxx" - -#define INCL_DOS -#include <stdlib.h> - -#include "ddemlimp.hxx" -#define LOGFILE -#define STATUSFILE -#define DDEDATAFILE -#include "ddemldeb.hxx" - -#if defined (OS2) && defined (__BORLANDC__) -#pragma option -w-par -#endif - - -// ************************************************************************ -// Hilfsfunktionen Speicherverwaltung -// ************************************************************************ - -// -// AllocAtomName -// - -PSZ ImpDdeMgr::AllocAtomName( ATOM hString, ULONG& rBufLen ) -{ - HATOMTBL hAtomTable = WinQuerySystemAtomTable(); - ULONG nLen = WinQueryAtomLength( hAtomTable, hString ); - nLen++; - PSZ pBuf = 0; - if ( !MyDosAllocMem( (PPVOID)&pBuf, nLen, PAG_READ|PAG_WRITE|PAG_COMMIT | OBJ_ANY,"Atom" ) ) - { - WinQueryAtomName( hAtomTable, hString, pBuf, nLen ); - rBufLen = nLen; - } - return pBuf; -} - - -// -// MakeDDEObject -// - -PDDESTRUCT ImpDdeMgr::MakeDDEObject( HWND hwnd, ATOM hItemName, - USHORT fsStatus, USHORT usFormat, PVOID pabData, ULONG usDataLen ) -{ - PDDESTRUCT pddes = 0; - ULONG usItemLen; - PULONG pulSharedObj; - //WRITELOG("MakeDDEObject: Start") - - PSZ pItemName = 0; - if( hItemName != NULL ) - pItemName = AllocAtomName( hItemName, usItemLen ); - else - usItemLen = 1; - - ULONG nTotalSize = sizeof(DDESTRUCT) + usItemLen + usDataLen; - - if( !(MyDosAllocSharedMem((PPVOID)&pulSharedObj, NULL, - nTotalSize, - PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE | OBJ_GIVEABLE | OBJ_ANY, - "MakeDDEObject"))) - { - pddes = (PDDESTRUCT) pulSharedObj; - // siehe "Glenn Puchtel, DDE for OS/2" p.60 - pddes->cbData = (ULONG)usDataLen; - pddes->fsStatus = fsStatus; - pddes->usFormat = usFormat; - pddes->offszItemName = sizeof( DDESTRUCT ); - if( (usDataLen) && (pabData != NULL ) ) - pddes->offabData = sizeof(DDESTRUCT) + usItemLen; - else - pddes->offabData = 0; - - if( pItemName != NULL ) - memcpy(DDES_PSZITEMNAME(pddes), pItemName, usItemLen ); - else - *(DDES_PSZITEMNAME(pddes)) = '\0'; - - if( pabData != NULL ) - memcpy( DDES_PABDATA(pddes), pabData, usDataLen ); - } - - if ( pItemName ) - { - MyDosFreeMem( pItemName,"MakeDDEObject" ); - } - return pddes; -} - -// -// AllocNamedSharedMem -// - -APIRET ImpDdeMgr::AllocNamedSharedMem( PPVOID ppBaseAddress, PSZ pName, - ULONG nElementSize, ULONG nElementCount ) -{ - ULONG nObjSize = (ULONG)(nElementSize * nElementCount ); - nObjSize += sizeof( ULONG ); // fuer ElementCount am Anfang des Blocks - - *ppBaseAddress = 0; - APIRET nRet = MyDosAllocSharedMem( ppBaseAddress, pName, nObjSize, - PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_ANY, - "AllocNamedSharedMem" ); - if ( !nRet ) - { - memset( *ppBaseAddress, 0, nObjSize ); - ULONG* pULONG = (ULONG*)*ppBaseAddress; - *pULONG = nObjSize; - } - return nRet; -} - -void ImpDdeMgr::CreateServerWnd() -{ - hWndServer = WinCreateWindow( HWND_DESKTOP, WC_FRAME, "DDEServer", 0, - 0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 ); - WinSetWindowULong( hWndServer, 0, (ULONG)this ); - WinSubclassWindow( hWndServer, ::ServerWndProc ); - TID tidDummy; - WinQueryWindowProcess( hWndServer, &pidThis, &tidDummy ); -} - -void ImpDdeMgr::DestroyServerWnd() -{ - WinDestroyWindow( hWndServer ); - hWndServer = NULLHANDLE; -} - -HWND ImpDdeMgr::CreateConversationWnd() -{ - HWND hWnd = WinCreateWindow( HWND_OBJECT, WC_FRAME, "DDEConvWnd", 0, - 0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 ); - if ( hWnd ) - { - ImpConvWndData* pWndData = new ImpConvWndData; - pWndData->pThis = this; - pWndData->nRefCount = 0; - WinSetWindowULong( hWnd, 0, (ULONG)pWndData ); - WinSubclassWindow( hWnd, ::ConvWndProc ); -#if 0 && defined( OV_DEBUG ) - String aStr("ConvWnd created:"); - aStr += (ULONG)hWnd; - WRITELOG((char*)aStr.GetStr()) -#endif - } - else - nLastErrInstance = DMLERR_SYS_ERROR; - - return hWnd; -} - -// static -void ImpDdeMgr::DestroyConversationWnd( HWND hWnd ) -{ - ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 ); - if( pObj ) - { - pObj->nRefCount--; - if( pObj->nRefCount == 0 - // auch Windows mit Refcount vonm loeschen, da dieser in initial - // auf 0 gesetzt wird - || pObj->nRefCount == (USHORT)-1 ) - { - delete pObj; - WinDestroyWindow( hWnd ); -#if 0 && defined( OV_DEBUG ) - String aStr("ConvWnd destroyed:"); - aStr += (ULONG)hWnd; - WRITELOG((char*)aStr.GetStr()) -#endif - } - else - { -#if 0 && defined( OV_DEBUG ) - String aStr("ConvWnd not destroyed (Refcount="); - aStr += pObj->nRefCount; - aStr += ") "; aStr += (ULONG)hWnd; - WRITELOG((char*)aStr.GetStr()) -#endif - } - } -#if defined( OV_DEBUG ) - else - { - WRITELOG("DestroyCnvWnd:Already destroyed/No win data/Partner died") - } -#endif -} - -// static -USHORT ImpDdeMgr::GetConversationWndRefCount( HWND hWnd ) -{ - ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 ); - DBG_ASSERT(pObj,"Dde:ConvWnd has no data"); - if( pObj ) - return pObj->nRefCount; - return 0; -} - -// static -USHORT ImpDdeMgr::IncConversationWndRefCount( HWND hWnd ) -{ -#if 0 && defined( OV_DEBUG ) - String aStr("IncConversationWndRefCount "); - aStr += (ULONG)hWnd; - WRITELOG((char*)aStr.GetStr()) -#endif - ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 ); - DBG_ASSERT(pObj,"Dde:ConvWnd has no data"); - if( pObj ) - { - pObj->nRefCount++; - return pObj->nRefCount; - } - return 0; -} - -ImpDdeMgrData* ImpDdeMgr::InitAll() -{ - ImpDdeMgrData* pBase = 0; - // nur dann neu anlegen, wenn die Tabelle nicht existiert - APIRET nRet=DosGetNamedSharedMem((PPVOID)&pBase,DDEMLDATA,PAG_READ| PAG_WRITE); - if ( nRet ) - { - if ( nRet == 2 ) // ERROR_FILE_NOT_FOUND ) - { - // DDECONVERSATIONCOUNT=4096 - USHORT nConvTransCount = 128; - PSZ pResult; - nRet = DosScanEnv( "SOMAXDDECONN", (const char**)&pResult ); - if( !nRet ) - { - int nTemp = 0; - nTemp = atoi( pResult ); - nTemp++; // der nullte Eintrag wird nicht benutzt - if( nTemp > 128 ) - nConvTransCount = (USHORT)nTemp; - } - ULONG nSize = sizeof(ImpDdeMgrData); - nSize += sizeof(ImpHCONV) * nConvTransCount; - nSize += sizeof(Transaction) * nConvTransCount; - nSize += sizeof(HWND) * DDEMLAPPCOUNT; - - nRet = ImpDdeMgr::AllocNamedSharedMem( (PPVOID)&pBase, - DDEMLDATA, nSize, 1 ); - if ( !nRet ) - { - pBase->nTotalSize = nSize; - ULONG nAppTable = (ULONG)&(pBase->aAppTable); - ULONG nCharBase = (ULONG)pBase; - pBase->nOffsAppTable = nAppTable - nCharBase; - pBase->nOffsConvTable = pBase->nOffsAppTable; - pBase->nOffsConvTable += sizeof(HWND) * DDEMLAPPCOUNT; - pBase->nOffsTransTable = pBase->nOffsConvTable; - pBase->nOffsTransTable += sizeof(ImpHCONV) * nConvTransCount; - - pBase->nMaxAppCount = DDEMLAPPCOUNT; - pBase->nMaxConvCount = nConvTransCount; - pBase->nMaxTransCount = nConvTransCount; - } - } - } - - if( pBase ) - { - pConvTable = ImpDdeMgr::GetConvTable( pBase ); - pTransTable = ImpDdeMgr::GetTransTable( pBase ); - pAppTable = ImpDdeMgr::GetAppTable( pBase ); - } - - memset( &aDefaultContext, 0, sizeof(CONVCONTEXT) ); - aDefaultContext.cb = sizeof(CONVCONTEXT); - aDefaultContext.idCountry = 49; // ?? - aDefaultContext.usCodepage = 850; // ?? - - return pBase; -} - -// static -HCONV ImpDdeMgr::CreateConvHandle( ImpDdeMgrData* pData, - PID pidOwner, - HWND hWndMe, HWND hWndPartner, - HSZ hszPartner, HSZ hszServiceReq, HSZ hszTopic, - HCONV hPrevHCONV ) -{ - DBG_ASSERT(pData,"DDE:Invalid data"); - if( !pData ) - return (HCONV)0; - - ImpHCONV* pPtr = ImpDdeMgr::GetConvTable( pData ); - USHORT nCount = pData->nMaxConvCount; - pPtr++; - nCount--; // ersten Handle (NULLHANDLE) ueberspringen - USHORT nIdx = 1; - DBG_ASSERT(pPtr,"No ConvTable"); - if( !pPtr ) - return (HCONV)0; - - while( nCount && pPtr->hWndThis != (HWND)NULL ) - { - nCount--; - pPtr++; - nIdx++; - } - if( !nCount ) - return (HCONV)0; - - DdeKeepStringHandle( hszPartner ); - DdeKeepStringHandle( hszServiceReq ); - DdeKeepStringHandle( hszTopic ); - pPtr->hszPartner = hszPartner; - pPtr->hszServiceReq = hszServiceReq; - pPtr->hszTopic = hszTopic; - - pPtr->hWndThis = hWndMe; - pPtr->hWndPartner = hWndPartner; - pPtr->pidOwner = pidOwner; - pPtr->hConvPartner = (HCONV)0; - pPtr->nPrevHCONV = (USHORT)hPrevHCONV; - pPtr->nNextHCONV = 0; - pPtr->nStatus = ST_CONNECTED; - - pData->nCurConvCount++; - - return (HCONV)nIdx; -} - -// static -void ImpDdeMgr::FreeConvHandle( ImpDdeMgrData* pBase, HCONV hConv, - BOOL bDestroyHWndThis ) -{ - DBG_ASSERT(pBase,"DDE:No data"); -#if 0 && defined( OV_DEBUG ) - String aStr("FreeConvHandle: Start "); - aStr += (ULONG)hConv; - aStr += " Destroy: "; aStr += (USHORT)bDestroyHWndThis; - WRITELOG((char*)aStr.GetStr()); - WRITESTATUS("FreeConvHandle: Start"); -#endif - if( !pBase ) - { - WRITELOG("FreeConvHandle: FAIL"); - return; - } - DBG_ASSERT(hConv&&hConv<pBase->nMaxConvCount,"DDE:Invalid Conv-Handle"); - if( hConv && hConv < pBase->nMaxConvCount ) - { - ImpHCONV* pTable = ImpDdeMgr::GetConvTable( pBase ); - ImpHCONV* pPtr = pTable + (USHORT)hConv; - if( pPtr->nStatus & ST_INLIST ) - { - // Verkettung umsetzen - USHORT nPrev = pPtr->nPrevHCONV; - USHORT nNext = pPtr->nNextHCONV; - if( nPrev ) - { - pPtr = pTable + nPrev; - pPtr->nNextHCONV = nNext; - } - if( nNext ) - { - pPtr = pTable + nNext; - pPtr->nPrevHCONV = nPrev; - } - pPtr = pTable + (USHORT)hConv; - } - - DdeFreeStringHandle( pPtr->hszPartner ); - DdeFreeStringHandle( pPtr->hszServiceReq ); - DdeFreeStringHandle( pPtr->hszTopic ); - if( bDestroyHWndThis ) - DestroyConversationWnd( pPtr->hWndThis ); - memset( pPtr, 0, sizeof(ImpHCONV) ); - DBG_ASSERT(pBase->nCurConvCount,"Dde:Invalid Trans. count"); - pBase->nCurConvCount--; - } -#if defined(OV_DEBUG) - else - { - WRITELOG("FreeConvHandle: FAIL"); - } -#endif - //WRITELOG("FreeConvHandle: END"); - //WRITESTATUS("FreeConvHandle: End"); -} - -// static -HCONV ImpDdeMgr::IsConvHandleAvailable( ImpDdeMgrData* pBase ) -{ - DBG_ASSERT(pBase,"DDE:No data"); - if( !pBase ) - return 0; - - ImpHCONV* pPtr = ImpDdeMgr::GetConvTable( pBase ); - USHORT nCurPos = pBase->nMaxConvCount - 1; - pPtr += nCurPos; // von hinten aufrollen - while( nCurPos >= 1 ) - { - if( pPtr->hWndThis == 0 ) - return TRUE; - pPtr--; - nCurPos--; - } - return FALSE; -} - -// static -HCONV ImpDdeMgr::GetConvHandle( ImpDdeMgrData* pBase, HWND hWndThis, - HWND hWndPartner ) -{ - DBG_ASSERT(pBase,"DDE:No data"); - if( !pBase ) - return 0; - ImpHCONV* pPtr = ImpDdeMgr::GetConvTable( pBase ); - USHORT nCurPos = 1; - pPtr++; // ersten Handle ueberspringen - USHORT nCurConvCount = pBase->nCurConvCount; - while( nCurConvCount && nCurPos < pBase->nMaxConvCount ) - { - if( pPtr->hWndThis ) - { - if(pPtr->hWndThis == hWndThis && pPtr->hWndPartner == hWndPartner) - return (HCONV)nCurPos; - nCurConvCount--; - if( !nCurConvCount ) - return (HCONV)0; - } - nCurPos++; - pPtr++; - } - return (HCONV)0; -} - - - -// static -ULONG ImpDdeMgr::CreateTransaction( ImpDdeMgrData* pBase, HCONV hOwner, - HSZ hszItem, USHORT nFormat, USHORT nTransactionType ) -{ - DBG_ASSERT(pBase,"DDE:No Data"); - DBG_ASSERT(hOwner!=0,"DDE:No Owner"); - - if( pBase && hOwner ) - { - Transaction* pPtr = ImpDdeMgr::GetTransTable( pBase ); - DBG_ASSERT(pPtr->hConvOwner==0,"DDE:Data corrupted"); - USHORT nId = 1; - pPtr++; - while( nId < pBase->nMaxTransCount ) - { - if( pPtr->hConvOwner == (HCONV)0 ) - { - pPtr->hConvOwner = hOwner; - DdeKeepStringHandle( hszItem ); - pPtr->hszItem = hszItem; - pPtr->nType = nTransactionType; - pPtr->nConvst = XST_CONNECTED; - pPtr->nFormat = nFormat; - pBase->nCurTransCount++; - return (ULONG)nId; - } - nId++; - pPtr++; - } - } - return 0; -} - -// static -void ImpDdeMgr::FreeTransaction( ImpDdeMgrData* pBase, ULONG nTransId ) -{ - DBG_ASSERT(pBase,"DDE:No Data"); - if( !pBase ) - return; - - DBG_ASSERT(nTransId<pBase->nMaxTransCount,"DDE:Invalid TransactionId"); - if( nTransId >= pBase->nMaxTransCount ) - return; - - Transaction* pPtr = ImpDdeMgr::GetTransTable( pBase ); - pPtr += nTransId; - DBG_ASSERT(pPtr->hConvOwner!=0,"DDE:TransId has no owner"); - if( pPtr->hConvOwner ) - { - //WRITELOG("Freeing transaction"); - DdeFreeStringHandle( pPtr->hszItem ); - memset( pPtr, 0, sizeof(Transaction) ); - DBG_ASSERT(pBase->nCurTransCount,"Dde:Invalid Trans. count"); - pBase->nCurTransCount--; - } -} - -// static -ULONG ImpDdeMgr::GetTransaction( ImpDdeMgrData* pBase, - HCONV hOwner, HSZ hszItem, USHORT nFormat ) -{ - DBG_ASSERT(pBase,"DDE:No Data"); - if( !pBase || !hOwner ) - return 0; - - Transaction* pTrans = ImpDdeMgr::GetTransTable( pBase ); - DBG_ASSERT(pTrans,"DDE:No TransactionTable"); - if( !pTrans ) - return 0; - pTrans++; // NULLHANDLE ueberspringen - - ImpHCONV* pConv = ImpDdeMgr::GetConvTable( pBase ); - pConv += (USHORT)hOwner; - HCONV hConvPartner = pConv->hConvPartner; - - USHORT nCurTransCount = pBase->nCurTransCount; - for( USHORT nTrans=1; nTrans< pBase->nMaxTransCount; nTrans++, pTrans++ ) - { - if( pTrans->hConvOwner ) - { - if(( pTrans->hConvOwner == hOwner || - pTrans->hConvOwner == hConvPartner) && - pTrans->nFormat == nFormat && - pTrans->hszItem == hszItem ) - { - // gefunden! - return (ULONG)nTrans; - } - nCurTransCount--; - if( !nCurTransCount ) - return 0; - } - } - return 0; // narda -} - -// static -HSZ ImpDdeMgr::DdeCreateStringHandle( PSZ pszString, int iCodePage) -{ - if( !pszString || *pszString == '\0' ) - return (HSZ)0; - // Atom-Table beachtet Gross/Kleinschreibung, DDEML aber nicht - - // OV 12.4.96: Services,Topics,Items case-sensitiv!!! - // (Grosskundenanforderung (Reuter-DDE)) - //strlwr( pszString ); - //*pszString = (char)toupper(*pszString); - - HATOMTBL hAtomTable = WinQuerySystemAtomTable(); - ATOM aAtom = WinAddAtom( hAtomTable, pszString ); - return (HSZ)aAtom; -} - -// static -ULONG ImpDdeMgr::DdeQueryString( HSZ hszStr, PSZ pszStr, ULONG cchMax, int iCodePage) -{ - HATOMTBL hAtomTable = WinQuerySystemAtomTable(); - if ( !pszStr ) - return WinQueryAtomLength( hAtomTable, (ATOM)hszStr); - else - { - *pszStr = 0; - return WinQueryAtomName( hAtomTable, (ATOM)hszStr, pszStr, cchMax ); - } -} - -// static -BOOL ImpDdeMgr::DdeFreeStringHandle( HSZ hsz ) -{ - if( !hsz ) - return FALSE; - ATOM aResult = WinDeleteAtom( WinQuerySystemAtomTable(),(ATOM)hsz ); - return (BOOL)(aResult==0); -} - -// static -BOOL ImpDdeMgr::DdeKeepStringHandle( HSZ hsz ) -{ - if( !hsz ) - return TRUE; - HATOMTBL hAtomTable = WinQuerySystemAtomTable(); -#ifdef DBG_UTIL - ULONG nUsageCount=WinQueryAtomUsage(hAtomTable,(ATOM)hsz); -#endif - ULONG nAtom = 0xFFFF0000; - ULONG nPar = (ULONG)hsz; - nAtom |= nPar; - ATOM aAtom = WinAddAtom( hAtomTable, (PSZ)nAtom ); -#ifdef DBG_UTIL - if ( aAtom ) - DBG_ASSERT(WinQueryAtomUsage(hAtomTable,(ATOM)hsz)==nUsageCount+1,"Keep failed"); -#endif - return (BOOL)(aAtom!=0); -} - - -// static -int ImpDdeMgr::DdeCmpStringHandles(HSZ hsz1, HSZ hsz2) -{ - if ( hsz1 == hsz2 ) - return 0; - if ( hsz1 < hsz2 ) - return -1; - return 1; -} - -HDDEDATA ImpDdeMgr::DdeCreateDataHandle( void* pSrc, ULONG cb, - ULONG cbOff, HSZ hszItem, USHORT wFmt, USHORT afCmd) -{ - char* pData = (char*)pSrc; - pData += cbOff; - USHORT nStatus; - if( afCmd & HDATA_APPOWNED ) - nStatus = IMP_HDATAAPPOWNED; - else - nStatus = 0; - PDDESTRUCT hData=MakeDDEObject(0,(ATOM)hszItem,nStatus,wFmt,pData,cb); -// WRITEDATA(hData) - if ( !hData ) - ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER; - return (HDDEDATA)hData; -} - -// static -BYTE* ImpDdeMgr::DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize) -{ - BYTE* pRet = 0; - *pcbDataSize = 0; - if ( hData ) - { - pRet = (BYTE*)hData; - pRet += hData->offabData; - ULONG nLen = hData->cbData; - // nLen -= hData->offabData; - *pcbDataSize = nLen; - } - else - ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER; - return pRet; -} - -// static -BOOL ImpDdeMgr::DdeUnaccessData(HDDEDATA hData) -{ - return TRUE; // nothing to do for us -} - -// static -BOOL ImpDdeMgr::DdeFreeDataHandle(HDDEDATA hData) -{ - DdeUnaccessData( hData ); - MyDosFreeMem( (PSZ)hData, "DdeFreeDataHandle" ); - return TRUE; -} - -// static -HDDEDATA ImpDdeMgr::DdeAddData(HDDEDATA hData,void* pSrc,ULONG cb,ULONG cbOff) -{ - return (HDDEDATA)0; -} - -// static -ULONG ImpDdeMgr::DdeGetData(HDDEDATA hData,void* pDst,ULONG cbMax,ULONG cbOff) -{ - return 0; -} - -BOOL ImpDdeMgr::DisconnectAll() -{ - //WRITESTATUS("Before DisconnectAll()") - USHORT nCurConvCount = pData->nCurConvCount; - if( !nCurConvCount ) - return TRUE; - - BOOL bRet = TRUE; - ImpHCONV* pPtr = pConvTable; - pPtr++; - - for( USHORT nPos=1; nPos < pData->nMaxConvCount; nPos++, pPtr++ ) - { - if( pPtr->hWndThis ) - { - if( !DdeDisconnect( (HCONV)nPos ) ) - bRet = FALSE; - nCurConvCount--; - if( !nCurConvCount ) - break; - } - } - //WRITESTATUS("After DisconnectAll()") - return bRet; -} - -// static -void ImpDdeMgr::FreeTransactions( ImpDdeMgrData* pData,HWND hWndThis, - HWND hWndPartner ) -{ - USHORT nCurTransCount = pData->nCurTransCount; - if( !nCurTransCount ) - return; - - Transaction* pTrans = GetTransTable( pData ); - ImpHCONV* pConvTable = GetConvTable( pData ); - pTrans++; - for( USHORT nPos=1; nPos < pData->nMaxTransCount; nPos++, pTrans++ ) - { - if( pTrans->hConvOwner ) - { - ImpHCONV* pConv = pConvTable + (USHORT)(pTrans->hConvOwner); - if((pConv->hWndThis==hWndThis&& pConv->hWndPartner==hWndPartner)|| - (pConv->hWndThis==hWndPartner && pConv->hWndPartner==hWndThis)) - { - FreeTransaction( pData, (ULONG)nPos ); - } - nCurTransCount--; - if( !nCurTransCount ) - return; - } - } -} - -// static -void ImpDdeMgr::FreeTransactions( ImpDdeMgrData* pData, HCONV hConvOwner ) -{ - USHORT nCurTransCount = pData->nCurTransCount; - if( !nCurTransCount ) - return; - - Transaction* pTrans = GetTransTable( pData ); -// ImpHCONV* pConvTable = GetConvTable( pData ); - pTrans++; - for( USHORT nPos=1; nPos < pData->nMaxTransCount; nPos++, pTrans++ ) - { - if( pTrans->hConvOwner == hConvOwner ) - { - FreeTransaction( pData, (ULONG)nPos ); - nCurTransCount--; - if( !nCurTransCount ) - return; - } - } -} - -// static -void ImpDdeMgr::FreeConversations( ImpDdeMgrData* pData, HWND hWndThis, - HWND hWndPartner ) -{ - USHORT nCurCount = pData->nCurConvCount; - if( !nCurCount ) - return; - - ImpHCONV* pPtr = GetConvTable( pData ); - pPtr++; - for( USHORT nPos=1; nPos < pData->nMaxConvCount; nPos++, pPtr++ ) - { - if( pPtr->hWndThis ) - { - if( hWndThis && pPtr->hWndPartner==hWndPartner ) - FreeConvHandle( pData, (HCONV)nPos ); - nCurCount--; - if( !nCurCount ) - return; - } - } -} - - -BOOL ImpDdeMgr::OwnsConversationHandles() -{ - //WRITESTATUS("OwnsConversationHandles()"); -#if 0 && defined( OV_DEBUG ) - String aStr("OwnsConversationHandles Server:"); - aStr += (ULONG)hWndServer; - WRITELOG((char*)aStr.GetStr()) -#endif - ImpHCONV* pPtr = GetConvTable( pData ); - for( USHORT nCur = 1; nCur < pData->nMaxConvCount; nCur++, pPtr++ ) - { - if( pPtr->hWndThis && pPtr->pidOwner == pidThis ) - { - //WRITELOG("OwnsConversationHandles: TRUE"); - return TRUE; - } - } - // WRITELOG("OwnsConversationHandles: FALSE"); - return FALSE; -} - - - -// ********************************************************************* -// ********************************************************************* -// ********************************************************************* - -USHORT DdeInitialize(ULONG* pidInst, PFNCALLBACK pfnCallback, - ULONG afCmd, ULONG ulRes) -{ - if( (*pidInst)!=0 ) - { - // Reinitialize wird noch nicht unterstuetzt - DBG_ASSERT(0,"DDEML:Reinitialize not supported"); - return DMLERR_INVALIDPARAMETER; - } - - ImpDdeMgr* pMgr = new ImpDdeMgr; - *pidInst = (ULONG)pMgr; - return pMgr->DdeInitialize( pfnCallback, afCmd ); -} - -BOOL DdeUninitialize(ULONG idInst) -{ - if( !idInst ) - return FALSE; - ImpDdeMgr* pMgr = (ImpDdeMgr*)idInst; - // nur loeschen, wenn wir nicht mehr benutzt werden! - if( !pMgr->OwnsConversationHandles() ) - { - WRITELOG("DdeUninitialize: TRUE"); - delete pMgr; - return TRUE; - } - WRITELOG("DdeUninitialize: FALSE"); - return FALSE; -} - - -HCONVLIST DdeConnectList(ULONG idInst, HSZ hszService, HSZ hszTopic, - HCONVLIST hConvList, CONVCONTEXT* pCC) -{ - if( !idInst ) - return 0; - return ((ImpDdeMgr*)idInst)->DdeConnectList(hszService,hszTopic, - hConvList, pCC ); -} - -HCONV DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev) -{ - return ImpDdeMgr::DdeQueryNextServer( hConvList, hConvPrev ); -} - -BOOL DdeDisconnectList(HCONVLIST hConvList) -{ - return ImpDdeMgr::DdeDisconnectList( hConvList ); -} - -HCONV DdeConnect(ULONG idInst, HSZ hszService, HSZ hszTopic, - CONVCONTEXT* pCC) -{ - if( !idInst ) - return 0; - return ((ImpDdeMgr*)idInst)->DdeConnect( hszService, hszTopic, pCC ); -} - -BOOL DdeDisconnect(HCONV hConv) -{ - return ImpDdeMgr::DdeDisconnect( hConv ); -} - -HCONV DdeReconnect(HCONV hConv) -{ - return ImpDdeMgr::DdeReconnect( hConv ); -} - - -USHORT DdeQueryConvInfo(HCONV hConv, ULONG idTransact, CONVINFO* pCI ) -{ - return ImpDdeMgr::DdeQueryConvInfo( hConv, idTransact, pCI ); -} - -BOOL DdeSetUserHandle(HCONV hConv, ULONG id, ULONG hUser) -{ - return ImpDdeMgr::DdeSetUserHandle( hConv, id, hUser ); -} - -BOOL DdeAbandonTransaction(ULONG idInst, HCONV hConv, ULONG idTransaction) -{ - if( !idInst ) - return FALSE; - return ((ImpDdeMgr*)idInst)->DdeAbandonTransaction(hConv,idTransaction); -} - -BOOL DdePostAdvise(ULONG idInst, HSZ hszTopic, HSZ hszItem) -{ - if( !idInst ) - return FALSE; - return ((ImpDdeMgr*)idInst)->DdePostAdvise( hszTopic, hszItem ); -} - -BOOL DdeEnableCallback(ULONG idInst, HCONV hConv, USHORT wCmd) -{ - if( !idInst ) - return FALSE; - return ((ImpDdeMgr*)idInst)->DdeEnableCallback( hConv, wCmd ); -} - -HDDEDATA DdeClientTransaction(void* pData, ULONG cbData, - HCONV hConv, HSZ hszItem, USHORT wFmt, USHORT wType, - ULONG dwTimeout, ULONG* pdwResult) -{ - return ImpDdeMgr::DdeClientTransaction( pData, cbData, - hConv, hszItem, wFmt, wType, dwTimeout, pdwResult ); -} - -HDDEDATA DdeCreateDataHandle(ULONG idInst, void* pSrc, ULONG cb, - ULONG cbOff, HSZ hszItem, USHORT wFmt, USHORT afCmd) -{ - if( !idInst ) - return 0; - return ((ImpDdeMgr*)idInst)->DdeCreateDataHandle( pSrc, cb, - cbOff, hszItem, wFmt, afCmd ); -} - -HDDEDATA DdeAddData(HDDEDATA hData, void* pSrc, ULONG cb, ULONG cbOff) -{ - return ImpDdeMgr::DdeAddData( hData, pSrc, cb, cbOff ); -} - -ULONG DdeGetData(HDDEDATA hData, void* pDst, ULONG cbMax, ULONG cbOff) -{ - return ImpDdeMgr::DdeGetData( hData, pDst, cbMax, cbOff ); -} - -BYTE* DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize) -{ - return ImpDdeMgr::DdeAccessData( hData, pcbDataSize ); -} - -BOOL DdeUnaccessData(HDDEDATA hData) -{ - return ImpDdeMgr::DdeUnaccessData( hData ); -} - -BOOL DdeFreeDataHandle(HDDEDATA hData) -{ - return ImpDdeMgr::DdeFreeDataHandle( hData ); -} - -USHORT DdeGetLastError(ULONG idInst) -{ - if( !idInst ) - return DMLERR_DLL_NOT_INITIALIZED; - return ((ImpDdeMgr*)idInst)->DdeGetLastError(); -} - -HSZ DdeCreateStringHandle(ULONG idInst, PSZ pszString,int iCodePage ) -{ - if( !idInst ) - return 0; - return ((ImpDdeMgr*)idInst)->DdeCreateStringHandle(pszString,iCodePage); -} - -ULONG DdeQueryString( ULONG idInst, HSZ hsz, PSZ pBuf, - ULONG cchMax, int iCodePage ) -{ - if( !idInst ) - return 0; - return ((ImpDdeMgr*)idInst)->DdeQueryString( hsz,pBuf,cchMax,iCodePage); -} - -BOOL DdeFreeStringHandle( ULONG idInst, HSZ hsz) -{ - if( !idInst ) - return FALSE; - return ((ImpDdeMgr*)idInst)->DdeFreeStringHandle( hsz ); -} - -BOOL DdeKeepStringHandle( ULONG idInst, HSZ hsz ) -{ - if( !idInst ) - return FALSE; - return ((ImpDdeMgr*)idInst)->DdeKeepStringHandle( hsz ); -} - -int DdeCmpStringHandles(HSZ hsz1, HSZ hsz2) -{ - return ImpDdeMgr::DdeCmpStringHandles( hsz1, hsz2 ); -} - -HDDEDATA DdeNameService( ULONG idInst, HSZ hsz1, HSZ hszRes, USHORT afCmd ) -{ - if( !idInst ) - return 0; - return ((ImpDdeMgr*)idInst)->DdeNameService( hsz1, afCmd ); -} - - diff --git a/svl/source/svdde/ddemldeb.cxx b/svl/source/svdde/ddemldeb.cxx deleted file mode 100644 index f921e93d2e9c..000000000000 --- a/svl/source/svdde/ddemldeb.cxx +++ /dev/null @@ -1,280 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svl.hxx" - -#include "ddemlimp.hxx" - -#ifdef OV_DEBUG -#include <svgen.hxx> -#endif - -#if defined(OV_DEBUG) - -void ImpAddHSZ( HSZ hszString, String& rStr ) -{ - char aBuf[ 128 ]; - ImpDdeMgr::DdeQueryString( hszString,aBuf,sizeof(aBuf),850); - rStr += " (\""; rStr += aBuf; rStr += "\","; - HATOMTBL hAtomTable = WinQuerySystemAtomTable(); - ULONG nRefCount = 0; - if( hszString ) - nRefCount = WinQueryAtomUsage(hAtomTable, (ATOM)hszString ); - rStr += nRefCount; rStr += ')'; -} - - -void ImpWriteDdeStatus(char* aFilename, char* pAppContext) -{ - char aBuf[ 128 ]; - USHORT nCtr; - HWND* pAppPtr; - ImpHCONV* pConvPtr; - Transaction* pTransPtr; - - ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData(); - if( !pData ) - return; - SvFileStream aStrm(aFilename, STREAM_READWRITE ); - String aLine; - aStrm.Seek( STREAM_SEEK_TO_END ); - aStrm << endl; - aStrm.WriteLine("********************** DDEML-Log ***********************"); - aStrm << endl; - if( pAppContext ) - { - aLine = Application::GetAppName(); - aLine += ':'; - aLine += "App-Context:"; aLine += pAppContext; - aStrm.WriteLine( aLine ); aStrm << endl; - } - aStrm.WriteLine("----------------- ImpDdeMgrData -------------------"); - aStrm << endl; - aLine= "TotalSize :"; aLine+= pData->nTotalSize; aStrm.WriteLine(aLine); - aLine= "nOffsAppTable :"; aLine+= pData->nOffsAppTable; aStrm.WriteLine(aLine); - aLine= "nOffsConvTable :"; aLine+= pData->nOffsConvTable; aStrm.WriteLine(aLine); - aLine= "nOffsTransTable:"; aLine+= pData->nOffsTransTable; aStrm.WriteLine(aLine); - aLine= "nMaxAppCount :"; aLine+= pData->nMaxAppCount; aStrm.WriteLine(aLine); - aLine= "nMaxConvCount :"; aLine+= pData->nMaxConvCount; aStrm.WriteLine(aLine); - aLine= "nMaxTransCount :"; aLine+= pData->nMaxTransCount; aStrm.WriteLine(aLine); - aLine= "nLastErr :"; aLine+= pData->nLastErr; aStrm.WriteLine(aLine); - aLine= "nCurConvCount :"; aLine+= pData->nCurConvCount; aStrm.WriteLine(aLine); - aLine= "nCurTransCount :"; aLine+= pData->nCurTransCount; aStrm.WriteLine(aLine); - aStrm << endl; - aStrm.WriteLine("---------- Registered DDEML-Applications -----------"); - aStrm << endl; - pAppPtr = ImpDdeMgr::GetAppTable( pData ); - for( nCtr = 0; nCtr < pData->nMaxAppCount; nCtr++, pAppPtr++ ) - { - if( *pAppPtr ) - { - aLine = "App."; aLine += nCtr; aLine += " HWND:"; - aLine += (ULONG)*pAppPtr; aStrm.WriteLine(aLine); - } - } - - aStrm << endl; - aStrm.WriteLine("-------------- Conversation handles ----------------"); - aStrm << endl; - - USHORT nCurCount = pData->nCurConvCount; - - if( nCurCount ) - { - pConvPtr = ImpDdeMgr::GetConvTable( pData ); - for( nCtr = 0; nCtr < pData->nMaxConvCount; nCtr++, pConvPtr++ ) - { - if( pConvPtr->hWndThis ) - { - aLine = "HCONV:"; aLine += nCtr; - aLine += " HCONVpartner: "; aLine += (USHORT)pConvPtr->hConvPartner; - if( !pConvPtr->hConvPartner ) aLine += "(Non-DDEML-App)"; - aLine += " hszPartner: "; aLine += (USHORT)pConvPtr->hszPartner; - ImpAddHSZ( pConvPtr->hszPartner, aLine ); - aStrm.WriteLine( aLine ); - - aLine = "hszService: "; aLine += (USHORT)pConvPtr->hszServiceReq; - ImpAddHSZ( pConvPtr->hszServiceReq, aLine ); - aLine += " hszTopic: "; aLine += (USHORT)pConvPtr->hszTopic; - ImpAddHSZ( pConvPtr->hszTopic, aLine ); - aStrm.WriteLine( aLine ); - - aLine= "Status: "; aLine+= pConvPtr->nStatus; - if( pConvPtr->nStatus & ST_CLIENT ) aLine += " (Client)"; - if( pConvPtr->nStatus & ST_INLIST ) aLine += " (Inlist)"; - aStrm.WriteLine(aLine); - - aLine = "pidOwner: "; aLine += (ULONG)pConvPtr->pidOwner; - aStrm.WriteLine( aLine ); - aLine = "hWndThis: "; aLine += (ULONG)pConvPtr->hWndThis; - aStrm.WriteLine( aLine ); - aLine = "hWndPartner: "; aLine += (ULONG)pConvPtr->hWndPartner; - aStrm.WriteLine( aLine ); - - aLine = "hConvList: "; aLine += (ULONG)pConvPtr->hConvList; - aLine += " Prev: "; aLine += pConvPtr->nPrevHCONV; - aLine += " Next: "; aLine += pConvPtr->nNextHCONV; - aStrm.WriteLine( aLine ); - aStrm.WriteLine("----------------------------------------------------"); - - nCurCount--; - if( !nCurCount ) - break; - } - } - } - - aStrm.WriteLine("----------------- Transaction Ids ------------------"); - - nCurCount = pData->nCurTransCount; - if( nCurCount ) - { - pTransPtr = ImpDdeMgr::GetTransTable( pData ); - for( nCtr = 0; nCtr < pData->nMaxTransCount; nCtr++, pTransPtr++ ) - { - - if( pTransPtr->hConvOwner ) - { - aLine = "TransactionId:"; aLine += nCtr; - aLine += " hConvOwner: "; aLine += (USHORT)pTransPtr->hConvOwner; - aStrm.WriteLine( aLine ); - aLine = "Item: "; aLine += (USHORT)pTransPtr->hszItem; - ImpAddHSZ( pTransPtr->hszItem, aLine ); - aLine += " Format: "; aLine += pTransPtr->nFormat; - aStrm.WriteLine( aLine ); - aLine = "TransactionType: "; aLine += pTransPtr->nType; - aLine += " Convst: "; aLine += pTransPtr->nConvst; - aLine += " LastErr: "; aLine += pTransPtr->nLastError; - aLine += " Userhandle: "; aLine += pTransPtr->nUser; - aStrm.WriteLine( aLine ); - aStrm.WriteLine("--------------------------------------------------"); - - nCurCount--; - if( !nCurCount ) - break; - } - } - } - aStrm << endl; - aStrm.WriteLine("******************* End of DDEML-Log *******************"); -} - -void ImpWriteDdeData(char* aFilename, DDESTRUCT* pData) -{ - char aBuf[ 128 ]; - USHORT nCtr; - SvFileStream aStrm(aFilename, STREAM_READWRITE ); - aStrm.Seek( STREAM_SEEK_TO_END ); - String aLine; - aStrm << endl; - aLine = "cbData:"; aLine += pData->cbData; aStrm.WriteLine( aLine ); - aLine = "fsStatus:"; aLine += pData->fsStatus; aStrm.WriteLine( aLine ); - aLine = "usFormat:"; aLine += pData->usFormat; aStrm.WriteLine( aLine ); - aLine = "ItemName:"; aLine += (char*)((char*)pData+pData->offszItemName); - aStrm.WriteLine( aLine ); - aLine = "offabData:"; aLine += pData->offabData; aStrm.WriteLine(aLine); - char* pBuf = (char*)pData+pData->offabData; - USHORT nLen = pData->cbData; // - pData->offabData; - while( nLen ) - { - aStrm << *pBuf; - nLen--; - pBuf++; - } - aStrm << endl; -} - -void ImpWriteLogFile(char* pFilename, char* pStr) -{ - SvFileStream aStrm(pFilename, STREAM_READWRITE ); - aStrm.Seek( STREAM_SEEK_TO_END ); - String aStr( Application::GetAppName() ); - aStr += ':'; aStr += pStr; - aStrm.WriteLine( (char*)aStr.GetStr() ); -} - -#else - -void ImpWriteDdeStatus(char*, char* ) {} -void ImpWriteDdeData(char*, DDESTRUCT*) {} -void ImpWriteLogFile(char*, char*) {} - -#endif - -APIRET MyDosAllocSharedMem(void** ppBaseAddress, char* pszName, unsigned long ulObjectSize, - unsigned long ulFlags, char* pContextStr ) -{ - APIRET nRet = DosAllocSharedMem(ppBaseAddress,pszName,ulObjectSize,ulFlags ); -#if 0 && defined(OV_DEBUG) && defined(LOGFILE) - String aStr("DosAllocSharedMem:"); - aStr += pContextStr; - aStr += ": "; - aStr += ulObjectSize; - aStr += " ("; - aStr += (ULONG)*((char**)ppBaseAddress); - aStr += ')'; - ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr() ); -#endif - return nRet; -} - -APIRET MyDosAllocMem(void** ppBaseAddress, unsigned long ulObjectSize, - unsigned long ulFlags, char* pContextStr ) -{ - APIRET nRet = DosAllocMem(ppBaseAddress, ulObjectSize,ulFlags ); -#if 0 && defined(OV_DEBUG) && defined(LOGFILE) - String aStr("DosAllocMem:"); - aStr += pContextStr; - aStr += ": "; - aStr += ulObjectSize; - aStr += " ("; - aStr += (ULONG)*((char**)ppBaseAddress); - aStr += ')'; - ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr() ); -#endif - return nRet; -} - - -APIRET MyDosFreeMem( void* pBaseAddress, char* pContextStr ) -{ - APIRET nRet = DosFreeMem( pBaseAddress ); -#if 0 && defined(OV_DEBUG) && defined(LOGFILE) - String aStr("DosFreeMem:"); - aStr += pContextStr; - aStr += ": "; - aStr += (ULONG)pBaseAddress; - ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr()); -#endif - return nRet; -} - - - - - diff --git a/svl/source/svdde/ddemldeb.hxx b/svl/source/svdde/ddemldeb.hxx deleted file mode 100644 index 8654bbd3ca65..000000000000 --- a/svl/source/svdde/ddemldeb.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if defined(OV_DEBUG) - -void ImpWriteLogFile(char*,char*); -void ImpAddHSZ( HSZ, String& ); -void ImpWriteDdeStatus(char*, char* ); -void ImpWriteDdeData(char*, DDESTRUCT*); - -#ifdef LOGFILE -#define WRITELOG(aString) ImpWriteLogFile("\\ddeml.log",aString); -#else -#define WRITELOG(bla) -#endif -#ifdef STATUSFILE -#define WRITESTATUS(aContext) ImpWriteDdeStatus("\\ddeml.sts",aContext); -#else -#define WRITESTATUS(bla) -#endif -#ifdef DDEDATAFILE -#define WRITEDATA(data) ImpWriteDdeData("\\ddeml.dat",data); -#else -#define WRITEDATA(bla) -#endif - -#else - -#define WRITELOG(bla) -#define WRITESTATUS(bla) -#define WRITEDATA(bla) - -#endif - -APIRET MyDosAllocSharedMem(void** ppBaseAddress, char* pszName, unsigned long ulObjectSize, - unsigned long ulFlags, char* pContextStr ); - -APIRET MyDosAllocMem(void** ppBaseAddress, unsigned long ulObjectSize, - unsigned long ulFlags, char* pContextStr ); - -APIRET MyDosFreeMem( void* pBaseAddress, char* pContextStr ); - diff --git a/svl/source/svdde/ddemlimp.hxx b/svl/source/svdde/ddemlimp.hxx deleted file mode 100644 index 28c4bf248bbe..000000000000 --- a/svl/source/svdde/ddemlimp.hxx +++ /dev/null @@ -1,433 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _DDEMLIMP_HXX -#define _DDEMLIMP_HXX - - -#include <string.h> -#include <ctype.h> -#include "ddemlos2.h" - -#define DDEMLSERVICETABLE_INISIZE 8 - -// Bezeichner der systemglobalen DDEML-Tabelle -#define DDEMLDATA "\\SHAREMEM\\OV_DDEML.DAT" - -// vorlaeufig konstante Tabellengroessen -#define CONVTABLECOUNT 2048 /* max count conversations */ -#define TRANSTABLECOUNT 2048 /* transactions */ -#define DDEMLAPPCOUNT 16 /* max count simultaniously running */ - /* ddeml (StarDivision) applications */ - -#define ST_TERMACKREC 0x8000 /* wird im Conversationhandle gesetzt, */ - /* wenn die Partner-App DDE_TERMINATE */ - /* bestaetigt hat */ - -#define XST_TIMEOUT 17 /* Trans. hat Timeout ueberschritten */ -#define XST_WAITING_ACK 18 /* Trans. wartet auf Acknowledge */ -#define XST_WAITING_ADVDATA 19 /* Trans. wartet auf Advise-Daten */ -#define XST_WAITING_REQDATA 20 /* Trans. wartet auf angeforderte Daten */ - - -/* User-Flags DDESTRUCT */ -#define IMP_HDATAAPPOWNED 0x8000 - -#define CONVLISTNAME "DdeConvListId" - -#define XTYPF_MASK (XTYPF_NOBLOCK | XTYPF_NODATA | XTYPF_ACKREQ) - -// -// DDEML-Messages; werden nur an registrierte DDEML-Apps gesendet -// - -// Msg: WM_DDEML_REGISTER -// Empfaenger: wird allen DDEML-Applikationen nach Registrierung -// eines neuen Services gesendet -// Params: nPar1: hszBaseServName -// nPar2: hszInstServName -#define WM_DDEML_REGISTER WM_USER+1 - -// Msg: WM_DDEML_UNREGISTER -// Empfaenger: wird allen DDEML-Applikationen nach Deregistrierung -// eines Services gesendet -// Params: nPar1: hszBaseServName -// nPar2: hszInstServName -#define WM_DDEML_UNREGISTER WM_USER+2 - -// -// -// - -struct ImpHCONV -{ - HCONV hConvPartner; - HSZ hszPartner; // Name of partner application - HSZ hszServiceReq; // Service name - HSZ hszTopic; // Topic name - USHORT nStatus; // ST_* of conversation - HCONVLIST hConvList; // ConvListId , wenn in ConvList - CONVCONTEXT aConvContext; // Conversation context - - // private - HWND hWndThis; // 0 == Handle not used - HWND hWndPartner; - PID pidOwner; // PID des DdeManagers, der - // den Conv-Handle erzeugt hat. - USHORT nPrevHCONV; // 0 == no previous hConv or not in list - USHORT nNextHCONV; // 0 == no next hconv or not in list -}; - -struct Transaction -{ - HSZ hszItem; // Item name - USHORT nFormat; // Data format - USHORT nType; // Transaction type (XTYP_*) - // XTYP_ADVREQ [|XTYPF_NODATA] == Advise-Loop - // [|XTYPF_ACKREQ] - // XTYP_EXECUTE == laufendes Execute - // XTYP_REQUEST - // XTYP_POKE - // XTYP_ADVSTOP - // XTYP_ADVSTART - USHORT nConvst; // Conversation state (XST_*) - // 0 == idle - // XST_REQSENT (fuer XTYP_ADVREQ) - // XST_TIMEOUT (fuer alle Typen!) - // XST_WAITING (alle ausser XTYP_ADVREQ) - USHORT nLastError; // last err in transaction - ULONG nUser; // Userhandle - // private - HCONV hConvOwner; // 0 == Transaction not used -}; - - -struct ImpWndProcParams -{ - HWND hWndReceiver; - MPARAM nPar1; - MPARAM nPar2; -}; - -struct ImpService -{ - HSZ hBaseServName; // Basis-Name des Service - HSZ hInstServName; // Basis-Name + DDEML-Server-HWND der App -}; - -class ImpDdeMgr; - -// Daten eines Conversation-Windows -struct ImpConvWndData -{ - ImpDdeMgr* pThis; - USHORT nRefCount; // Zahl Conversations auf diesem Window -}; - - -// systemglobale Daten der Library (liegen in named shared memory) -struct ImpDdeMgrData -{ - ULONG nTotalSize; - ULONG nOffsAppTable; - ULONG nOffsConvTable; - ULONG nOffsTransTable; - USHORT nMaxAppCount; - USHORT nMaxConvCount; - USHORT nMaxTransCount; - USHORT nLastErr; - USHORT nReserved; - USHORT nCurTransCount; - USHORT nCurConvCount; - HWND aAppTable[ 1 ]; // fuer Broadcast-Messages - ImpHCONV aConvTable[ 1 ]; - Transaction aTransTable[ 1 ]; -}; - - - -class ImpDdeMgr -{ - friend MRESULT EXPENTRY ConvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2); - friend MRESULT EXPENTRY ServerWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2); - friend void ImpWriteDdeStatus(char*,char*); - friend void ImpAddHSZ( HSZ, String& ); - - static PSZ AllocAtomName( ATOM hString, ULONG& rBufLen ); - static PDDESTRUCT MakeDDEObject( HWND hwnd, ATOM hItemName, - USHORT fsStatus, USHORT usFormat, PVOID pabData, ULONG usDataLen ); - static APIRET AllocNamedSharedMem( PPVOID ppBaseAddress, PSZ pName, - ULONG nElementSize, ULONG nElementCount ); - - HWND hWndServer; - PID pidThis; - PFNCALLBACK pCallback; - ULONG nTransactFilter; - CONVCONTEXT aDefaultContext; - ImpDdeMgrData* pData; - ImpService* pServices; - USHORT nServiceCount; - - ImpHCONV* pConvTable; // liegt in pData (nicht deleten!) - Transaction* pTransTable; // liegt in pData (nicht deleten!) - HWND* pAppTable; // liegt in pData (nicht deleten!) - - static ImpHCONV* GetConvTable( ImpDdeMgrData* ); - static Transaction* GetTransTable( ImpDdeMgrData* ); - static HWND* GetAppTable( ImpDdeMgrData* ); - - - static HWND NextFrameWin( HENUM hEnum ); - void CreateServerWnd(); - void DestroyServerWnd(); - HWND CreateConversationWnd(); - // Fktn. duerfen nur fuer HCONVs aufgerufen werden, die - // in der eigenen Applikation erzeugt wurden - static void DestroyConversationWnd( HWND hWndConv ); - static USHORT GetConversationWndRefCount( HWND hWndConv ); - static USHORT IncConversationWndRefCount( HWND hWndConv ); - - MRESULT SrvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2); - MRESULT ConvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2); - void RegisterDDEMLApp(); - void UnregisterDDEMLApp(); - void CleanUp(); - ImpDdeMgrData* InitAll(); - static BOOL MyWinDdePostMsg( HWND, HWND, USHORT, PDDESTRUCT, ULONG ); - void MyInitiateDde( HWND hWndServer, HWND hWndClient, - HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC ); - DDEINIT* CreateDDEInitData( HWND hWndDest, HSZ hszService, - HSZ hszTopic, CONVCONTEXT* pCC ); - // wenn pDDEData==0, muss pCC gesetzt sein - HCONV ConnectWithClient( HWND hWndClient, HSZ hszPartner, - HSZ hszService, HSZ hszTopic, BOOL bSameInst, - DDEINIT* pDDEData, CONVCONTEXT* pCC = 0); - - HCONV CheckIncoming( ImpWndProcParams*, ULONG nTransMask, - HSZ& rhszItem ); - // fuer Serverbetrieb. Ruft Callback-Fkt fuer alle offenen Advises - // auf, deren Owner der uebergebene HCONV ist. - // bFreeTransactions==TRUE: loescht die Transaktionen - // gibt Anzahl der getrennten Transaktionen zurueck - USHORT SendUnadvises( HCONV hConv, - USHORT nFormat, // 0==alle - BOOL bFreeTransactions ); - - BOOL WaitTransState( - Transaction* pTrans, ULONG nTransId, - USHORT nNewState, - ULONG nTimeout ); - - // DDEML ruft Callback mit XTYP_CONNECT-Transaction nur auf, - // wenn die App den angeforderten Service registriert hat - // Standardeinstellung: TRUE - BOOL bServFilterOn; - - // Fehlercode muss noch systemglobal werden (Atom o. ae.) - static USHORT nLastErrInstance; // wenn 0, dann gilt globaler Fehlercode - - static ImpDdeMgrData* AccessMgrData(); - - static HCONV CreateConvHandle( ImpDdeMgrData* pBase, - PID pidOwner, - HWND hWndThis, HWND hWndPartner, - HSZ hszPartner, HSZ hszServiceReq, HSZ hszTopic, - HCONV hPrevHCONV = 0 ); - - static HCONV IsConvHandleAvailable( ImpDdeMgrData* pBase ); - static HCONV GetConvHandle( ImpDdeMgrData* pBase, - HWND hWndThis, HWND hWndPartner ); - static void FreeConvHandle( ImpDdeMgrData*, HCONV, - BOOL bDestroyHWndThis = TRUE ); - - static ULONG CreateTransaction( ImpDdeMgrData* pBase, - HCONV hOwner, HSZ hszItem, USHORT nFormat, - USHORT nTransactionType ); - static ULONG GetTransaction( ImpDdeMgrData* pBase, - HCONV hOwner, HSZ hszItem, USHORT nFormat ); - - static void FreeTransaction( ImpDdeMgrData*, ULONG nTransId ); - - BOOL DisconnectAll(); - // Transaktionen muessen _vor_ den Konversationen geloescht werden! - static void FreeTransactions( ImpDdeMgrData*, HWND hWndThis, - HWND hWndPartner ); - static void FreeTransactions( ImpDdeMgrData*, HCONV hConvOwner ); - - static void FreeConversations( ImpDdeMgrData*,HWND hWndThis, - HWND hWndPartner ); - - ImpService* GetService( HSZ hszService ); - ImpService* PutService( HSZ hszService ); - void BroadcastService( ImpService*, BOOL bRegistered ); - - // rh: Startposition(!) & gefundener Handle - static ImpHCONV* GetFirstServer( ImpDdeMgrData*, HCONVLIST, HCONV& rh); - static ImpHCONV* GetLastServer( ImpDdeMgrData*, HCONVLIST, HCONV& ); - static BOOL CheckConvListId( HCONVLIST hConvListId ); - - BOOL IsSameInstance( HWND hWnd ); - HSZ GetAppName( HWND hWnd ); - - - // Transactions - MRESULT DdeAck( ImpWndProcParams* pParams ); - MRESULT DdeAdvise( ImpWndProcParams* pParams ); - MRESULT DdeData( ImpWndProcParams* pParams ); - MRESULT DdeExecute( ImpWndProcParams* pParams ); - MRESULT DdeInitiate( ImpWndProcParams* pParams ); - MRESULT DdeInitiateAck( ImpWndProcParams* pParams ); - MRESULT DdePoke( ImpWndProcParams* pParams ); - MRESULT DdeRequest( ImpWndProcParams* pParams ); - MRESULT DdeTerminate( ImpWndProcParams* pParams ); - MRESULT DdeUnadvise( ImpWndProcParams* pParams ); - MRESULT DdeRegister( ImpWndProcParams* pParams ); - MRESULT DdeUnregister( ImpWndProcParams* pParams ); - MRESULT DdeTimeout( ImpWndProcParams* pParams ); - - HDDEDATA Callback( - USHORT nTransactionType, - USHORT nClipboardFormat, - HCONV hConversationHandle, - HSZ hsz1, - HSZ hsz2, - HDDEDATA hData, - ULONG nData1, - ULONG nData2 ); - - HCONV DdeConnectImp( HSZ hszService,HSZ hszTopic,CONVCONTEXT* pCC); - - // connection data - HCONV hCurConv; // wird im DdeInitiateAck gesetzt - HCONVLIST hCurListId; // fuer DdeConnectList - USHORT nPrevConv; // .... "" .... - BOOL bListConnect; - - // synchr. transaction data - BOOL bInSyncTrans; - ULONG nSyncTransId; - HDDEDATA hSyncResponseData; - ULONG nSyncResponseMsg; // WM_DDE_ACK, WM_DDE_DATA, WM_TIMER - // TRUE==nach Ende der synchronen Transaktion eine evtl. benutzte - // asynchrone Transaktion beenden (typisch synchroner Request auf - // Advise-Loop) - BOOL bSyncAbandonTrans; - -public: - ImpDdeMgr(); - ~ImpDdeMgr(); - - USHORT DdeInitialize( PFNCALLBACK pCallbackProc, ULONG nTransactionFilter ); - USHORT DdeGetLastError(); - - HCONV DdeConnect( HSZ hszService, HSZ hszTopic, CONVCONTEXT* ); - HCONVLIST DdeConnectList( HSZ hszService, HSZ hszTopic, - HCONVLIST hConvList, CONVCONTEXT* ); - static BOOL DdeDisconnect( HCONV hConv ); - static BOOL DdeDisconnectList( HCONVLIST hConvList ); - static HCONV DdeReconnect(HCONV hConv); - static HCONV DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev); - static USHORT DdeQueryConvInfo(HCONV hConv, ULONG idTrans,CONVINFO* pCI); - static BOOL DdeSetUserHandle(HCONV hConv, ULONG id, ULONG hUser); - BOOL DdeAbandonTransaction( HCONV hConv, ULONG idTransaction); - - BOOL DdePostAdvise( HSZ hszTopic, HSZ hszItem); - BOOL DdeEnableCallback( HCONV hConv, USHORT wCmd); - - HDDEDATA DdeNameService( HSZ hszService, USHORT afCmd); - - static HDDEDATA DdeClientTransaction(void* pData, ULONG cbData, - HCONV hConv, HSZ hszItem, USHORT wFmt, USHORT wType, - ULONG dwTimeout, ULONG* pdwResult); - - // Data handles - - HDDEDATA DdeCreateDataHandle( void* pSrc, ULONG cb, ULONG cbOff, - HSZ hszItem, USHORT wFmt, USHORT afCmd); - static BYTE* DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize); - static BOOL DdeUnaccessData(HDDEDATA hData); - static BOOL DdeFreeDataHandle(HDDEDATA hData); - static HDDEDATA DdeAddData(HDDEDATA hData,void* pSrc,ULONG cb,ULONG cbOff); - static ULONG DdeGetData(HDDEDATA hData,void* pDst,ULONG cbMax,ULONG cbOff); - - // String handles - - static HSZ DdeCreateStringHandle( PSZ pStr, int iCodePage); - static ULONG DdeQueryString(HSZ hsz,PSZ pStr,ULONG cchMax,int iCPage); - static BOOL DdeFreeStringHandle( HSZ hsz ); - static BOOL DdeKeepStringHandle( HSZ hsz ); - static int DdeCmpStringHandles(HSZ hsz1, HSZ hsz2); - - // mit dieser Funktion kann geprueft werden, ob eine - // Applikation schon eine DDEML-Instanz angelegt hat. - // Die aktuelle Impl. unterstuetzt nur eine DDEML-Instanz - // pro Applikation (wg. synchroner Transaktionen) - static ImpDdeMgr* GetImpDdeMgrInstance( HWND hWnd ); - - // gibt TRUE zurueck, wenn mind. ein lebender HCONV - // von diesem DdeMgr erzeugt wurde - BOOL OwnsConversationHandles(); -}; - -// static -inline ImpHCONV* ImpDdeMgr::GetConvTable( ImpDdeMgrData* pData ) -{ - ImpHCONV* pRet; - if( pData ) - pRet = (ImpHCONV*)((ULONG)(pData) + pData->nOffsConvTable); - else - pRet = 0; - return pRet; -} - -// static -inline Transaction* ImpDdeMgr::GetTransTable( ImpDdeMgrData* pData ) -{ - Transaction* pRet; - if( pData ) - pRet = (Transaction*)((ULONG)(pData) + pData->nOffsTransTable); - else - pRet = 0; - return pRet; -} - -// static -inline HWND* ImpDdeMgr::GetAppTable( ImpDdeMgrData* pData ) -{ - HWND* pRet; - if( pData ) - pRet = (HWND*)((ULONG)(pData) + pData->nOffsAppTable); - else - pRet = 0; - return pRet; -} - - - - -#endif - diff --git a/svl/source/svdde/ddemlos2.h b/svl/source/svdde/ddemlos2.h deleted file mode 100644 index bdd31e470bcd..000000000000 --- a/svl/source/svdde/ddemlos2.h +++ /dev/null @@ -1,374 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _DDEML_H -#define _DDEML_H - -#define INCL_OS2 -#define INCL_WIN - -#include <tools/svpm.h> -#include <tools/solar.h> -#include <tools/debug.hxx> -#include <tools/stream.hxx> - -typedef LHANDLE HSTR; - -#ifndef CALLBACK -#define CALLBACK -#endif - - -typedef ULONG HCONVLIST; -typedef ULONG HCONV; -typedef ATOM HSZ; -typedef DDESTRUCT* HDDEDATA; - -struct CONVINFO -{ - USHORT nSize; // sizeof(CONVINFO) - ULONG nUser; // Userhandle - HCONV hConvPartner; // - HSZ hszPartner; // Name der Partnerapp - HSZ hszServiceReq; // Name des angeforderten Services - HSZ hszTopic; // -- " -- Topics - HSZ hszItem; // -- " -- Items - USHORT nFormat; // Datenformat der akt. Transaktion - USHORT nType; // Typ der akt. Transaktion (XTYP_*) - USHORT nStatus; // ST_* der Konversation - USHORT nConvst; // XST_* der akt. Transaktion - USHORT nLastError; // letzter Fehler der Transaktion - HCONVLIST hConvList; // ConvListId , wenn in ConvList - CONVCONTEXT aConvCtxt; // conversation context -}; - -/* the following structure is for use with XTYP_WILDCONNECT processing. */ - -struct HSZPAIR -{ - HSZ hszSvc; - HSZ hszTopic; -}; -typedef HSZPAIR *PHSZPAIR; - -/***** conversation states (usState) *****/ - -#define XST_NULL 0 /* quiescent states */ -#define XST_INCOMPLETE 1 -#define XST_CONNECTED 2 -#define XST_INIT1 3 /* mid-initiation states */ -#define XST_INIT2 4 -#define XST_REQSENT 5 /* active conversation states */ -#define XST_DATARCVD 6 -#define XST_POKESENT 7 -#define XST_POKEACKRCVD 8 -#define XST_EXECSENT 9 -#define XST_EXECACKRCVD 10 -#define XST_ADVSENT 11 -#define XST_UNADVSENT 12 -#define XST_ADVACKRCVD 13 -#define XST_UNADVACKRCVD 14 -#define XST_ADVDATASENT 15 -#define XST_ADVDATAACKRCVD 16 - -/* used in LOWORD(dwData1) of XTYP_ADVREQ callbacks... */ -#define CADV_LATEACK 0xFFFF - -/***** conversation status bits (fsStatus) *****/ - -#define ST_CONNECTED 0x0001 -#define ST_ADVISE 0x0002 -#define ST_ISLOCAL 0x0004 -#define ST_BLOCKED 0x0008 -#define ST_CLIENT 0x0010 -#define ST_TERMINATED 0x0020 -#define ST_INLIST 0x0040 -#define ST_BLOCKNEXT 0x0080 -#define ST_ISSELF 0x0100 - - -/* DDE constants for wStatus field */ - -//#define DDE_FACK 0x8000 -//#define DDE_FBUSY 0x4000 -//#define DDE_FDEFERUPD 0x4000 -//#define DDE_FACKREQ 0x8000 -//#define DDE_FRELEASE 0x2000 -//#define DDE_FREQUESTED 0x1000 -//#define DDE_FACKRESERVED 0x3ff0 -//#define DDE_FADVRESERVED 0x3fff -//#define DDE_FDATRESERVED 0x4fff -//#define DDE_FPOKRESERVED 0xdfff -//#define DDE_FAPPSTATUS 0x00ff -#define DDE_FNOTPROCESSED 0x0000 - -/***** message filter hook types *****/ - -#define MSGF_DDEMGR 0x8001 - -/***** codepage constants ****/ - -#define CP_WINANSI 1004 /* default codepage for windows & old DDE convs. */ - -/***** transaction types *****/ - -#define XTYPF_NOBLOCK 0x0002 /* CBR_BLOCK will not work */ -#define XTYPF_NODATA 0x0004 /* DDE_FDEFERUPD */ -#define XTYPF_ACKREQ 0x0008 /* DDE_FACKREQ */ - -#define XCLASS_MASK 0xFC00 -#define XCLASS_BOOL 0x1000 -#define XCLASS_DATA 0x2000 -#define XCLASS_FLAGS 0x4000 -#define XCLASS_NOTIFICATION 0x8000 - -#define XTYP_ERROR (0x0000 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK ) -#define XTYP_ADVDATA (0x0010 | XCLASS_FLAGS ) -#define XTYP_ADVREQ (0x0020 | XCLASS_DATA | XTYPF_NOBLOCK ) -#define XTYP_ADVSTART (0x0030 | XCLASS_BOOL ) -#define XTYP_ADVSTOP (0x0040 | XCLASS_NOTIFICATION) -#define XTYP_EXECUTE (0x0050 | XCLASS_FLAGS ) -#define XTYP_CONNECT (0x0060 | XCLASS_BOOL | XTYPF_NOBLOCK) -#define XTYP_CONNECT_CONFIRM (0x0070 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK) -#define XTYP_XACT_COMPLETE (0x0080 | XCLASS_NOTIFICATION ) -#define XTYP_POKE (0x0090 | XCLASS_FLAGS ) -#define XTYP_REGISTER (0x00A0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK) -#define XTYP_REQUEST (0x00B0 | XCLASS_DATA ) -#define XTYP_DISCONNECT (0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK) -#define XTYP_UNREGISTER (0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK) -#define XTYP_WILDCONNECT (0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK) - -#define XTYP_MASK 0x00F0 -#define XTYP_SHIFT 4 /* shift to turn XTYP_ into an index */ - -/***** Timeout constants *****/ - -#define TIMEOUT_ASYNC -1L - -/***** Transaction ID constants *****/ - -#define QID_SYNC -1L - -/****** public strings used in DDE ******/ - -#define SZDDESYS_TOPIC "System" -#define SZDDESYS_ITEM_TOPICS "Topics" -#define SZDDESYS_ITEM_SYSITEMS "SysItems" -#define SZDDESYS_ITEM_RTNMSG "ReturnMessage" -#define SZDDESYS_ITEM_STATUS "Status" -#define SZDDESYS_ITEM_FORMATS "Formats" -#define SZDDESYS_ITEM_HELP "Help" -#define SZDDE_ITEM_ITEMLIST "TopicItemList" - - -/****** API entry points ******/ - -typedef HDDEDATA CALLBACK FNCALLBACK(USHORT wType, USHORT wFmt, HCONV hConv, - HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG dwData1, ULONG dwData2); -typedef FNCALLBACK* PFNCALLBACK; - -#define CBR_BLOCK 0xffffffffL - -/* DLL registration functions */ - -USHORT DdeInitialize(ULONG* pidInst, PFNCALLBACK pfnCallback, - ULONG afCmd, ULONG ulRes); - -/* - * Callback filter flags for use with standard apps. - */ - -#define CBF_FAIL_SELFCONNECTIONS 0x00001000 -#define CBF_FAIL_CONNECTIONS 0x00002000 -#define CBF_FAIL_ADVISES 0x00004000 -#define CBF_FAIL_EXECUTES 0x00008000 -#define CBF_FAIL_POKES 0x00010000 -#define CBF_FAIL_REQUESTS 0x00020000 -#define CBF_FAIL_ALLSVRXACTIONS 0x0003f000 - -#define CBF_SKIP_CONNECT_CONFIRMS 0x00040000 -#define CBF_SKIP_REGISTRATIONS 0x00080000 -#define CBF_SKIP_UNREGISTRATIONS 0x00100000 -#define CBF_SKIP_DISCONNECTS 0x00200000 -#define CBF_SKIP_ALLNOTIFICATIONS 0x003c0000 - -/* - * Application command flags - */ -#define APPCMD_CLIENTONLY 0x00000010L -#define APPCMD_FILTERINITS 0x00000020L -#define APPCMD_MASK 0x00000FF0L - -/* - * Application classification flags - */ -#define APPCLASS_STANDARD 0x00000000L -#define APPCLASS_MASK 0x0000000FL - - -BOOL DdeUninitialize(ULONG idInst); - -/* conversation enumeration functions */ - -HCONVLIST DdeConnectList(ULONG idInst, HSZ hszService, HSZ hszTopic, - HCONVLIST hConvList, CONVCONTEXT* pCC); -HCONV DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev); -BOOL DdeDisconnectList(HCONVLIST hConvList); - -/* conversation control functions */ - -HCONV DdeConnect(ULONG idInst, HSZ hszService, HSZ hszTopic, - CONVCONTEXT* pCC); -BOOL DdeDisconnect(HCONV hConv); -HCONV DdeReconnect(HCONV hConv); - -USHORT DdeQueryConvInfo(HCONV hConv, ULONG idTransaction, CONVINFO* pConvInfo); -BOOL DdeSetUserHandle(HCONV hConv, ULONG id, ULONG hUser); - -BOOL DdeAbandonTransaction(ULONG idInst, HCONV hConv, ULONG idTransaction); - - -/* app server interface functions */ - -BOOL DdePostAdvise(ULONG idInst, HSZ hszTopic, HSZ hszItem); -BOOL DdeEnableCallback(ULONG idInst, HCONV hConv, USHORT wCmd); - -#define EC_ENABLEALL 0 -#define EC_ENABLEONE ST_BLOCKNEXT -#define EC_DISABLE ST_BLOCKED -#define EC_QUERYWAITING 2 - -HDDEDATA DdeNameService(ULONG idInst, HSZ hsz1, HSZ hsz2, USHORT afCmd); - -#define DNS_REGISTER 0x0001 -#define DNS_UNREGISTER 0x0002 -#define DNS_FILTERON 0x0004 -#define DNS_FILTEROFF 0x0008 - -/* app client interface functions */ - -HDDEDATA DdeClientTransaction(void* pData, ULONG cbData, - HCONV hConv, HSZ hszItem, USHORT wFmt, USHORT wType, - ULONG dwTimeout, ULONG* pdwResult); - -/* data transfer functions */ - -HDDEDATA DdeCreateDataHandle(ULONG idInst, void* pSrc, ULONG cb, - ULONG cbOff, HSZ hszItem, USHORT wFmt, USHORT afCmd); -// HDDEDATA DdeAddData(HDDEDATA hData, void* pSrc, ULONG cb, ULONG cbOff); -ULONG DdeGetData(HDDEDATA hData, void* pDst, ULONG cbMax, ULONG cbOff); -BYTE* DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize); -BOOL DdeUnaccessData(HDDEDATA hData); -BOOL DdeFreeDataHandle(HDDEDATA hData); - -#define HDATA_APPOWNED 0x0001 - -USHORT DdeGetLastError(ULONG idInst); - -#define DMLERR_NO_ERROR 0 /* must be 0 */ - -#define DMLERR_FIRST 0x4000 - -#define DMLERR_ADVACKTIMEOUT 0x4000 -#define DMLERR_BUSY 0x4001 -#define DMLERR_DATAACKTIMEOUT 0x4002 -#define DMLERR_DLL_NOT_INITIALIZED 0x4003 -#define DMLERR_DLL_USAGE 0x4004 -#define DMLERR_EXECACKTIMEOUT 0x4005 -#define DMLERR_INVALIDPARAMETER 0x4006 -#define DMLERR_LOW_MEMORY 0x4007 -#define DMLERR_MEMORY_ERROR 0x4008 -#define DMLERR_NOTPROCESSED 0x4009 -#define DMLERR_NO_CONV_ESTABLISHED 0x400a -#define DMLERR_POKEACKTIMEOUT 0x400b -#define DMLERR_POSTMSG_FAILED 0x400c -#define DMLERR_REENTRANCY 0x400d -#define DMLERR_SERVER_DIED 0x400e -#define DMLERR_SYS_ERROR 0x400f -#define DMLERR_UNADVACKTIMEOUT 0x4010 -#define DMLERR_UNFOUND_QUEUE_ID 0x4011 - -#define DMLERR_LAST 0x4011 - -HSZ DdeCreateStringHandle(ULONG idInst, PSZ pStr, int iCodePage); -ULONG DdeQueryString(ULONG idInst, HSZ hsz, PSZ pStr, ULONG cchMax, - int iCodePage); -BOOL DdeFreeStringHandle(ULONG idInst, HSZ hsz); -BOOL DdeKeepStringHandle(ULONG idInst, HSZ hsz); -int DdeCmpStringHandles(HSZ hsz1, HSZ hsz2); - - - -/* von OS/2 nicht unterstuetzte Win3.1 Clipboard-Formate */ - -#define CF_NOTSUPPORTED_BASE 0xff00 - -#ifndef CF_DIB -#define CF_DIB CF_NOTSUPPORTED_BASE+1 -#endif - -#ifndef CF_DIF -#define CF_DIF CF_NOTSUPPORTED_BASE+2 -#endif - -#ifndef CF_DSPMETAFILEPICT -#define CF_DSPMETAFILEPICT CF_NOTSUPPORTED_BASE+3 -#endif - -#ifndef CF_METAFILEPICT -#define CF_METAFILEPICT CF_NOTSUPPORTED_BASE+4 -#endif - -#ifndef CF_OEMTEXT -#define CF_OEMTEXT CF_NOTSUPPORTED_BASE+5 -#endif - -#ifndef CF_OWNERDISPLAY -#define CF_OWNERDISPLAY CF_NOTSUPPORTED_BASE+6 -#endif - -#ifndef CF_PENDATA -#define CF_PENDATA CF_NOTSUPPORTED_BASE+7 -#endif - -#ifndef CF_RIFF -#define CF_RIFF CF_NOTSUPPORTED_BASE+8 -#endif - -#ifndef CF_SYLK -#define CF_SYLK CF_NOTSUPPORTED_BASE+9 -#endif - -#ifndef CF_TIFF -#define CF_TIFF CF_NOTSUPPORTED_BASE+10 -#endif - -#ifndef CF_WAVE -#define CF_WAVE CF_NOTSUPPORTED_BASE+11 -#endif - - -#endif /* _DDEML_HXX */ diff --git a/svl/source/svdde/ddestrg.cxx b/svl/source/svdde/ddestrg.cxx index 4f0e2464a276..007c9f56c544 100644 --- a/svl/source/svdde/ddestrg.cxx +++ b/svl/source/svdde/ddestrg.cxx @@ -33,10 +33,6 @@ #include "ddeimp.hxx" #include <svl/svdde.hxx> -#if defined( WIN ) && defined( MSC ) -#pragma code_seg( "SVDDE_MISC_CODE" ) -#endif - // --- DdeString::DdeString() -------------------------------------- DdeString::DdeString( DWORD hDdeInst, const sal_Unicode* p ) : diff --git a/svl/source/svdde/makefile.mk b/svl/source/svdde/makefile.mk deleted file mode 100644 index d7f0a790486b..000000000000 --- a/svl/source/svdde/makefile.mk +++ /dev/null @@ -1,60 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org 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 version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - - -.IF "$(GUIBASE)"=="WIN" - -PRJ=..$/.. - -PRJNAME=svl -TARGET=svdde - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/svl.pmk - -# --- Files -------------------------------------------------------- - - -SLOFILES= $(SLO)$/ddecli.obj \ - $(SLO)$/ddesvr.obj \ - $(SLO)$/ddedata.obj \ - $(SLO)$/ddestrg.obj \ - $(SLO)$/ddewrap.obj \ - $(SLO)$/ddeinf.obj - -# --- Targets ------------------------------------------------------- - -.INCLUDE : target.mk - -.ELSE -dummy: - @echo GUI == "$(GUI)" - nothing to do - -.ENDIF - |