1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ddeml2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
37 #include "ddemlimp.hxx"
41 #include "ddemldeb.hxx"
43 #if defined (OS2) && defined (__BORLANDC__)
48 // ************************************************************************
49 // Hilfsfunktionen Speicherverwaltung
50 // ************************************************************************
56 PSZ
ImpDdeMgr::AllocAtomName( ATOM hString
, ULONG
& rBufLen
)
58 HATOMTBL hAtomTable
= WinQuerySystemAtomTable();
59 ULONG nLen
= WinQueryAtomLength( hAtomTable
, hString
);
62 if ( !MyDosAllocMem( (PPVOID
)&pBuf
, nLen
, PAG_READ
|PAG_WRITE
|PAG_COMMIT
| OBJ_ANY
,"Atom" ) )
64 WinQueryAtomName( hAtomTable
, hString
, pBuf
, nLen
);
75 PDDESTRUCT
ImpDdeMgr::MakeDDEObject( HWND hwnd
, ATOM hItemName
,
76 USHORT fsStatus
, USHORT usFormat
, PVOID pabData
, ULONG usDataLen
)
81 //WRITELOG("MakeDDEObject: Start")
84 if( hItemName
!= NULL
)
85 pItemName
= AllocAtomName( hItemName
, usItemLen
);
89 ULONG nTotalSize
= sizeof(DDESTRUCT
) + usItemLen
+ usDataLen
;
91 if( !(MyDosAllocSharedMem((PPVOID
)&pulSharedObj
, NULL
,
93 PAG_COMMIT
| PAG_READ
| PAG_WRITE
| OBJ_GETTABLE
| OBJ_GIVEABLE
| OBJ_ANY
,
96 pddes
= (PDDESTRUCT
) pulSharedObj
;
97 // siehe "Glenn Puchtel, DDE for OS/2" p.60
98 pddes
->cbData
= (ULONG
)usDataLen
;
99 pddes
->fsStatus
= fsStatus
;
100 pddes
->usFormat
= usFormat
;
101 pddes
->offszItemName
= sizeof( DDESTRUCT
);
102 if( (usDataLen
) && (pabData
!= NULL
) )
103 pddes
->offabData
= sizeof(DDESTRUCT
) + usItemLen
;
105 pddes
->offabData
= 0;
107 if( pItemName
!= NULL
)
108 memcpy(DDES_PSZITEMNAME(pddes
), pItemName
, usItemLen
);
110 *(DDES_PSZITEMNAME(pddes
)) = '\0';
112 if( pabData
!= NULL
)
113 memcpy( DDES_PABDATA(pddes
), pabData
, usDataLen
);
118 MyDosFreeMem( pItemName
,"MakeDDEObject" );
124 // AllocNamedSharedMem
127 APIRET
ImpDdeMgr::AllocNamedSharedMem( PPVOID ppBaseAddress
, PSZ pName
,
128 ULONG nElementSize
, ULONG nElementCount
)
130 ULONG nObjSize
= (ULONG
)(nElementSize
* nElementCount
);
131 nObjSize
+= sizeof( ULONG
); // fuer ElementCount am Anfang des Blocks
134 APIRET nRet
= MyDosAllocSharedMem( ppBaseAddress
, pName
, nObjSize
,
135 PAG_READ
| PAG_WRITE
| PAG_COMMIT
| OBJ_ANY
,
136 "AllocNamedSharedMem" );
139 memset( *ppBaseAddress
, 0, nObjSize
);
140 ULONG
* pULONG
= (ULONG
*)*ppBaseAddress
;
146 void ImpDdeMgr::CreateServerWnd()
148 hWndServer
= WinCreateWindow( HWND_DESKTOP
, WC_FRAME
, "DDEServer", 0,
149 0,0,0,0, HWND_DESKTOP
, HWND_BOTTOM
, 0, 0, 0 );
150 WinSetWindowULong( hWndServer
, 0, (ULONG
)this );
151 WinSubclassWindow( hWndServer
, ::ServerWndProc
);
153 WinQueryWindowProcess( hWndServer
, &pidThis
, &tidDummy
);
156 void ImpDdeMgr::DestroyServerWnd()
158 WinDestroyWindow( hWndServer
);
159 hWndServer
= NULLHANDLE
;
162 HWND
ImpDdeMgr::CreateConversationWnd()
164 HWND hWnd
= WinCreateWindow( HWND_OBJECT
, WC_FRAME
, "DDEConvWnd", 0,
165 0,0,0,0, HWND_DESKTOP
, HWND_BOTTOM
, 0, 0, 0 );
168 ImpConvWndData
* pWndData
= new ImpConvWndData
;
169 pWndData
->pThis
= this;
170 pWndData
->nRefCount
= 0;
171 WinSetWindowULong( hWnd
, 0, (ULONG
)pWndData
);
172 WinSubclassWindow( hWnd
, ::ConvWndProc
);
173 #if 0 && defined( OV_DEBUG )
174 String
aStr("ConvWnd created:");
176 WRITELOG((char*)aStr
.GetStr())
180 nLastErrInstance
= DMLERR_SYS_ERROR
;
186 void ImpDdeMgr::DestroyConversationWnd( HWND hWnd
)
188 ImpConvWndData
* pObj
= (ImpConvWndData
*)WinQueryWindowULong( hWnd
, 0 );
192 if( pObj
->nRefCount
== 0
193 // auch Windows mit Refcount vonm loeschen, da dieser in initial
194 // auf 0 gesetzt wird
195 || pObj
->nRefCount
== (USHORT
)-1 )
198 WinDestroyWindow( hWnd
);
199 #if 0 && defined( OV_DEBUG )
200 String
aStr("ConvWnd destroyed:");
202 WRITELOG((char*)aStr
.GetStr())
207 #if 0 && defined( OV_DEBUG )
208 String
aStr("ConvWnd not destroyed (Refcount=");
209 aStr
+= pObj
->nRefCount
;
210 aStr
+= ") "; aStr
+= (ULONG
)hWnd
;
211 WRITELOG((char*)aStr
.GetStr())
215 #if defined( OV_DEBUG )
218 WRITELOG("DestroyCnvWnd:Already destroyed/No win data/Partner died")
224 USHORT
ImpDdeMgr::GetConversationWndRefCount( HWND hWnd
)
226 ImpConvWndData
* pObj
= (ImpConvWndData
*)WinQueryWindowULong( hWnd
, 0 );
227 DBG_ASSERT(pObj
,"Dde:ConvWnd has no data");
229 return pObj
->nRefCount
;
234 USHORT
ImpDdeMgr::IncConversationWndRefCount( HWND hWnd
)
236 #if 0 && defined( OV_DEBUG )
237 String
aStr("IncConversationWndRefCount ");
239 WRITELOG((char*)aStr
.GetStr())
241 ImpConvWndData
* pObj
= (ImpConvWndData
*)WinQueryWindowULong( hWnd
, 0 );
242 DBG_ASSERT(pObj
,"Dde:ConvWnd has no data");
246 return pObj
->nRefCount
;
251 ImpDdeMgrData
* ImpDdeMgr::InitAll()
253 ImpDdeMgrData
* pBase
= 0;
254 // nur dann neu anlegen, wenn die Tabelle nicht existiert
255 APIRET nRet
=DosGetNamedSharedMem((PPVOID
)&pBase
,DDEMLDATA
,PAG_READ
| PAG_WRITE
);
258 if ( nRet
== 2 ) // ERROR_FILE_NOT_FOUND )
260 // DDECONVERSATIONCOUNT=4096
261 USHORT nConvTransCount
= 128;
263 nRet
= DosScanEnv( "SOMAXDDECONN", (const char**)&pResult
);
267 nTemp
= atoi( pResult
);
268 nTemp
++; // der nullte Eintrag wird nicht benutzt
270 nConvTransCount
= (USHORT
)nTemp
;
272 ULONG nSize
= sizeof(ImpDdeMgrData
);
273 nSize
+= sizeof(ImpHCONV
) * nConvTransCount
;
274 nSize
+= sizeof(Transaction
) * nConvTransCount
;
275 nSize
+= sizeof(HWND
) * DDEMLAPPCOUNT
;
277 nRet
= ImpDdeMgr::AllocNamedSharedMem( (PPVOID
)&pBase
,
278 DDEMLDATA
, nSize
, 1 );
281 pBase
->nTotalSize
= nSize
;
282 ULONG nAppTable
= (ULONG
)&(pBase
->aAppTable
);
283 ULONG nCharBase
= (ULONG
)pBase
;
284 pBase
->nOffsAppTable
= nAppTable
- nCharBase
;
285 pBase
->nOffsConvTable
= pBase
->nOffsAppTable
;
286 pBase
->nOffsConvTable
+= sizeof(HWND
) * DDEMLAPPCOUNT
;
287 pBase
->nOffsTransTable
= pBase
->nOffsConvTable
;
288 pBase
->nOffsTransTable
+= sizeof(ImpHCONV
) * nConvTransCount
;
290 pBase
->nMaxAppCount
= DDEMLAPPCOUNT
;
291 pBase
->nMaxConvCount
= nConvTransCount
;
292 pBase
->nMaxTransCount
= nConvTransCount
;
299 pConvTable
= ImpDdeMgr::GetConvTable( pBase
);
300 pTransTable
= ImpDdeMgr::GetTransTable( pBase
);
301 pAppTable
= ImpDdeMgr::GetAppTable( pBase
);
304 memset( &aDefaultContext
, 0, sizeof(CONVCONTEXT
) );
305 aDefaultContext
.cb
= sizeof(CONVCONTEXT
);
306 aDefaultContext
.idCountry
= 49; // ??
307 aDefaultContext
.usCodepage
= 850; // ??
313 HCONV
ImpDdeMgr::CreateConvHandle( ImpDdeMgrData
* pData
,
315 HWND hWndMe
, HWND hWndPartner
,
316 HSZ hszPartner
, HSZ hszServiceReq
, HSZ hszTopic
,
319 DBG_ASSERT(pData
,"DDE:Invalid data");
323 ImpHCONV
* pPtr
= ImpDdeMgr::GetConvTable( pData
);
324 USHORT nCount
= pData
->nMaxConvCount
;
326 nCount
--; // ersten Handle (NULLHANDLE) ueberspringen
328 DBG_ASSERT(pPtr
,"No ConvTable");
332 while( nCount
&& pPtr
->hWndThis
!= (HWND
)NULL
)
341 DdeKeepStringHandle( hszPartner
);
342 DdeKeepStringHandle( hszServiceReq
);
343 DdeKeepStringHandle( hszTopic
);
344 pPtr
->hszPartner
= hszPartner
;
345 pPtr
->hszServiceReq
= hszServiceReq
;
346 pPtr
->hszTopic
= hszTopic
;
348 pPtr
->hWndThis
= hWndMe
;
349 pPtr
->hWndPartner
= hWndPartner
;
350 pPtr
->pidOwner
= pidOwner
;
351 pPtr
->hConvPartner
= (HCONV
)0;
352 pPtr
->nPrevHCONV
= (USHORT
)hPrevHCONV
;
353 pPtr
->nNextHCONV
= 0;
354 pPtr
->nStatus
= ST_CONNECTED
;
356 pData
->nCurConvCount
++;
362 void ImpDdeMgr::FreeConvHandle( ImpDdeMgrData
* pBase
, HCONV hConv
,
363 BOOL bDestroyHWndThis
)
365 DBG_ASSERT(pBase
,"DDE:No data");
366 #if 0 && defined( OV_DEBUG )
367 String
aStr("FreeConvHandle: Start ");
368 aStr
+= (ULONG
)hConv
;
369 aStr
+= " Destroy: "; aStr
+= (USHORT
)bDestroyHWndThis
;
370 WRITELOG((char*)aStr
.GetStr());
371 WRITESTATUS("FreeConvHandle: Start");
375 WRITELOG("FreeConvHandle: FAIL");
378 DBG_ASSERT(hConv
&&hConv
<pBase
->nMaxConvCount
,"DDE:Invalid Conv-Handle");
379 if( hConv
&& hConv
< pBase
->nMaxConvCount
)
381 ImpHCONV
* pTable
= ImpDdeMgr::GetConvTable( pBase
);
382 ImpHCONV
* pPtr
= pTable
+ (USHORT
)hConv
;
383 if( pPtr
->nStatus
& ST_INLIST
)
385 // Verkettung umsetzen
386 USHORT nPrev
= pPtr
->nPrevHCONV
;
387 USHORT nNext
= pPtr
->nNextHCONV
;
390 pPtr
= pTable
+ nPrev
;
391 pPtr
->nNextHCONV
= nNext
;
395 pPtr
= pTable
+ nNext
;
396 pPtr
->nPrevHCONV
= nPrev
;
398 pPtr
= pTable
+ (USHORT
)hConv
;
401 DdeFreeStringHandle( pPtr
->hszPartner
);
402 DdeFreeStringHandle( pPtr
->hszServiceReq
);
403 DdeFreeStringHandle( pPtr
->hszTopic
);
404 if( bDestroyHWndThis
)
405 DestroyConversationWnd( pPtr
->hWndThis
);
406 memset( pPtr
, 0, sizeof(ImpHCONV
) );
407 DBG_ASSERT(pBase
->nCurConvCount
,"Dde:Invalid Trans. count");
408 pBase
->nCurConvCount
--;
410 #if defined(OV_DEBUG)
413 WRITELOG("FreeConvHandle: FAIL");
416 //WRITELOG("FreeConvHandle: END");
417 //WRITESTATUS("FreeConvHandle: End");
421 HCONV
ImpDdeMgr::IsConvHandleAvailable( ImpDdeMgrData
* pBase
)
423 DBG_ASSERT(pBase
,"DDE:No data");
427 ImpHCONV
* pPtr
= ImpDdeMgr::GetConvTable( pBase
);
428 USHORT nCurPos
= pBase
->nMaxConvCount
- 1;
429 pPtr
+= nCurPos
; // von hinten aufrollen
430 while( nCurPos
>= 1 )
432 if( pPtr
->hWndThis
== 0 )
441 HCONV
ImpDdeMgr::GetConvHandle( ImpDdeMgrData
* pBase
, HWND hWndThis
,
444 DBG_ASSERT(pBase
,"DDE:No data");
447 ImpHCONV
* pPtr
= ImpDdeMgr::GetConvTable( pBase
);
449 pPtr
++; // ersten Handle ueberspringen
450 USHORT nCurConvCount
= pBase
->nCurConvCount
;
451 while( nCurConvCount
&& nCurPos
< pBase
->nMaxConvCount
)
455 if(pPtr
->hWndThis
== hWndThis
&& pPtr
->hWndPartner
== hWndPartner
)
456 return (HCONV
)nCurPos
;
470 ULONG
ImpDdeMgr::CreateTransaction( ImpDdeMgrData
* pBase
, HCONV hOwner
,
471 HSZ hszItem
, USHORT nFormat
, USHORT nTransactionType
)
473 DBG_ASSERT(pBase
,"DDE:No Data");
474 DBG_ASSERT(hOwner
!=0,"DDE:No Owner");
476 if( pBase
&& hOwner
)
478 Transaction
* pPtr
= ImpDdeMgr::GetTransTable( pBase
);
479 DBG_ASSERT(pPtr
->hConvOwner
==0,"DDE:Data corrupted");
482 while( nId
< pBase
->nMaxTransCount
)
484 if( pPtr
->hConvOwner
== (HCONV
)0 )
486 pPtr
->hConvOwner
= hOwner
;
487 DdeKeepStringHandle( hszItem
);
488 pPtr
->hszItem
= hszItem
;
489 pPtr
->nType
= nTransactionType
;
490 pPtr
->nConvst
= XST_CONNECTED
;
491 pPtr
->nFormat
= nFormat
;
492 pBase
->nCurTransCount
++;
503 void ImpDdeMgr::FreeTransaction( ImpDdeMgrData
* pBase
, ULONG nTransId
)
505 DBG_ASSERT(pBase
,"DDE:No Data");
509 DBG_ASSERT(nTransId
<pBase
->nMaxTransCount
,"DDE:Invalid TransactionId");
510 if( nTransId
>= pBase
->nMaxTransCount
)
513 Transaction
* pPtr
= ImpDdeMgr::GetTransTable( pBase
);
515 DBG_ASSERT(pPtr
->hConvOwner
!=0,"DDE:TransId has no owner");
516 if( pPtr
->hConvOwner
)
518 //WRITELOG("Freeing transaction");
519 DdeFreeStringHandle( pPtr
->hszItem
);
520 memset( pPtr
, 0, sizeof(Transaction
) );
521 DBG_ASSERT(pBase
->nCurTransCount
,"Dde:Invalid Trans. count");
522 pBase
->nCurTransCount
--;
527 ULONG
ImpDdeMgr::GetTransaction( ImpDdeMgrData
* pBase
,
528 HCONV hOwner
, HSZ hszItem
, USHORT nFormat
)
530 DBG_ASSERT(pBase
,"DDE:No Data");
531 if( !pBase
|| !hOwner
)
534 Transaction
* pTrans
= ImpDdeMgr::GetTransTable( pBase
);
535 DBG_ASSERT(pTrans
,"DDE:No TransactionTable");
538 pTrans
++; // NULLHANDLE ueberspringen
540 ImpHCONV
* pConv
= ImpDdeMgr::GetConvTable( pBase
);
541 pConv
+= (USHORT
)hOwner
;
542 HCONV hConvPartner
= pConv
->hConvPartner
;
544 USHORT nCurTransCount
= pBase
->nCurTransCount
;
545 for( USHORT nTrans
=1; nTrans
< pBase
->nMaxTransCount
; nTrans
++, pTrans
++ )
547 if( pTrans
->hConvOwner
)
549 if(( pTrans
->hConvOwner
== hOwner
||
550 pTrans
->hConvOwner
== hConvPartner
) &&
551 pTrans
->nFormat
== nFormat
&&
552 pTrans
->hszItem
== hszItem
)
555 return (ULONG
)nTrans
;
558 if( !nCurTransCount
)
566 HSZ
ImpDdeMgr::DdeCreateStringHandle( PSZ pszString
, int iCodePage
)
568 if( !pszString
|| *pszString
== '\0' )
570 // Atom-Table beachtet Gross/Kleinschreibung, DDEML aber nicht
572 // OV 12.4.96: Services,Topics,Items case-sensitiv!!!
573 // (Grosskundenanforderung (Reuter-DDE))
574 //strlwr( pszString );
575 //*pszString = (char)toupper(*pszString);
577 HATOMTBL hAtomTable
= WinQuerySystemAtomTable();
578 ATOM aAtom
= WinAddAtom( hAtomTable
, pszString
);
583 ULONG
ImpDdeMgr::DdeQueryString( HSZ hszStr
, PSZ pszStr
, ULONG cchMax
, int iCodePage
)
585 HATOMTBL hAtomTable
= WinQuerySystemAtomTable();
587 return WinQueryAtomLength( hAtomTable
, (ATOM
)hszStr
);
591 return WinQueryAtomName( hAtomTable
, (ATOM
)hszStr
, pszStr
, cchMax
);
596 BOOL
ImpDdeMgr::DdeFreeStringHandle( HSZ hsz
)
600 ATOM aResult
= WinDeleteAtom( WinQuerySystemAtomTable(),(ATOM
)hsz
);
601 return (BOOL
)(aResult
==0);
605 BOOL
ImpDdeMgr::DdeKeepStringHandle( HSZ hsz
)
609 HATOMTBL hAtomTable
= WinQuerySystemAtomTable();
611 ULONG nUsageCount
=WinQueryAtomUsage(hAtomTable
,(ATOM
)hsz
);
613 ULONG nAtom
= 0xFFFF0000;
614 ULONG nPar
= (ULONG
)hsz
;
616 ATOM aAtom
= WinAddAtom( hAtomTable
, (PSZ
)nAtom
);
619 DBG_ASSERT(WinQueryAtomUsage(hAtomTable
,(ATOM
)hsz
)==nUsageCount
+1,"Keep failed");
621 return (BOOL
)(aAtom
!=0);
626 int ImpDdeMgr::DdeCmpStringHandles(HSZ hsz1
, HSZ hsz2
)
635 HDDEDATA
ImpDdeMgr::DdeCreateDataHandle( void* pSrc
, ULONG cb
,
636 ULONG cbOff
, HSZ hszItem
, USHORT wFmt
, USHORT afCmd
)
638 char* pData
= (char*)pSrc
;
641 if( afCmd
& HDATA_APPOWNED
)
642 nStatus
= IMP_HDATAAPPOWNED
;
645 PDDESTRUCT hData
=MakeDDEObject(0,(ATOM
)hszItem
,nStatus
,wFmt
,pData
,cb
);
648 ImpDdeMgr::nLastErrInstance
= DMLERR_INVALIDPARAMETER
;
649 return (HDDEDATA
)hData
;
653 BYTE
* ImpDdeMgr::DdeAccessData(HDDEDATA hData
, ULONG
* pcbDataSize
)
660 pRet
+= hData
->offabData
;
661 ULONG nLen
= hData
->cbData
;
662 // nLen -= hData->offabData;
666 ImpDdeMgr::nLastErrInstance
= DMLERR_INVALIDPARAMETER
;
671 BOOL
ImpDdeMgr::DdeUnaccessData(HDDEDATA hData
)
673 return TRUE
; // nothing to do for us
677 BOOL
ImpDdeMgr::DdeFreeDataHandle(HDDEDATA hData
)
679 DdeUnaccessData( hData
);
680 MyDosFreeMem( (PSZ
)hData
, "DdeFreeDataHandle" );
685 HDDEDATA
ImpDdeMgr::DdeAddData(HDDEDATA hData
,void* pSrc
,ULONG cb
,ULONG cbOff
)
691 ULONG
ImpDdeMgr::DdeGetData(HDDEDATA hData
,void* pDst
,ULONG cbMax
,ULONG cbOff
)
696 BOOL
ImpDdeMgr::DisconnectAll()
698 //WRITESTATUS("Before DisconnectAll()")
699 USHORT nCurConvCount
= pData
->nCurConvCount
;
704 ImpHCONV
* pPtr
= pConvTable
;
707 for( USHORT nPos
=1; nPos
< pData
->nMaxConvCount
; nPos
++, pPtr
++ )
711 if( !DdeDisconnect( (HCONV
)nPos
) )
718 //WRITESTATUS("After DisconnectAll()")
723 void ImpDdeMgr::FreeTransactions( ImpDdeMgrData
* pData
,HWND hWndThis
,
726 USHORT nCurTransCount
= pData
->nCurTransCount
;
727 if( !nCurTransCount
)
730 Transaction
* pTrans
= GetTransTable( pData
);
731 ImpHCONV
* pConvTable
= GetConvTable( pData
);
733 for( USHORT nPos
=1; nPos
< pData
->nMaxTransCount
; nPos
++, pTrans
++ )
735 if( pTrans
->hConvOwner
)
737 ImpHCONV
* pConv
= pConvTable
+ (USHORT
)(pTrans
->hConvOwner
);
738 if((pConv
->hWndThis
==hWndThis
&& pConv
->hWndPartner
==hWndPartner
)||
739 (pConv
->hWndThis
==hWndPartner
&& pConv
->hWndPartner
==hWndThis
))
741 FreeTransaction( pData
, (ULONG
)nPos
);
744 if( !nCurTransCount
)
751 void ImpDdeMgr::FreeTransactions( ImpDdeMgrData
* pData
, HCONV hConvOwner
)
753 USHORT nCurTransCount
= pData
->nCurTransCount
;
754 if( !nCurTransCount
)
757 Transaction
* pTrans
= GetTransTable( pData
);
758 // ImpHCONV* pConvTable = GetConvTable( pData );
760 for( USHORT nPos
=1; nPos
< pData
->nMaxTransCount
; nPos
++, pTrans
++ )
762 if( pTrans
->hConvOwner
== hConvOwner
)
764 FreeTransaction( pData
, (ULONG
)nPos
);
766 if( !nCurTransCount
)
773 void ImpDdeMgr::FreeConversations( ImpDdeMgrData
* pData
, HWND hWndThis
,
776 USHORT nCurCount
= pData
->nCurConvCount
;
780 ImpHCONV
* pPtr
= GetConvTable( pData
);
782 for( USHORT nPos
=1; nPos
< pData
->nMaxConvCount
; nPos
++, pPtr
++ )
786 if( hWndThis
&& pPtr
->hWndPartner
==hWndPartner
)
787 FreeConvHandle( pData
, (HCONV
)nPos
);
796 BOOL
ImpDdeMgr::OwnsConversationHandles()
798 //WRITESTATUS("OwnsConversationHandles()");
799 #if 0 && defined( OV_DEBUG )
800 String
aStr("OwnsConversationHandles Server:");
801 aStr
+= (ULONG
)hWndServer
;
802 WRITELOG((char*)aStr
.GetStr())
804 ImpHCONV
* pPtr
= GetConvTable( pData
);
805 for( USHORT nCur
= 1; nCur
< pData
->nMaxConvCount
; nCur
++, pPtr
++ )
807 if( pPtr
->hWndThis
&& pPtr
->pidOwner
== pidThis
)
809 //WRITELOG("OwnsConversationHandles: TRUE");
813 // WRITELOG("OwnsConversationHandles: FALSE");
819 // *********************************************************************
820 // *********************************************************************
821 // *********************************************************************
823 USHORT
DdeInitialize(ULONG
* pidInst
, PFNCALLBACK pfnCallback
,
824 ULONG afCmd
, ULONG ulRes
)
828 // Reinitialize wird noch nicht unterstuetzt
829 DBG_ASSERT(0,"DDEML:Reinitialize not supported");
830 return DMLERR_INVALIDPARAMETER
;
833 ImpDdeMgr
* pMgr
= new ImpDdeMgr
;
834 *pidInst
= (ULONG
)pMgr
;
835 return pMgr
->DdeInitialize( pfnCallback
, afCmd
);
838 BOOL
DdeUninitialize(ULONG idInst
)
842 ImpDdeMgr
* pMgr
= (ImpDdeMgr
*)idInst
;
843 // nur loeschen, wenn wir nicht mehr benutzt werden!
844 if( !pMgr
->OwnsConversationHandles() )
846 WRITELOG("DdeUninitialize: TRUE");
850 WRITELOG("DdeUninitialize: FALSE");
855 HCONVLIST
DdeConnectList(ULONG idInst
, HSZ hszService
, HSZ hszTopic
,
856 HCONVLIST hConvList
, CONVCONTEXT
* pCC
)
860 return ((ImpDdeMgr
*)idInst
)->DdeConnectList(hszService
,hszTopic
,
864 HCONV
DdeQueryNextServer(HCONVLIST hConvList
, HCONV hConvPrev
)
866 return ImpDdeMgr::DdeQueryNextServer( hConvList
, hConvPrev
);
869 BOOL
DdeDisconnectList(HCONVLIST hConvList
)
871 return ImpDdeMgr::DdeDisconnectList( hConvList
);
874 HCONV
DdeConnect(ULONG idInst
, HSZ hszService
, HSZ hszTopic
,
879 return ((ImpDdeMgr
*)idInst
)->DdeConnect( hszService
, hszTopic
, pCC
);
882 BOOL
DdeDisconnect(HCONV hConv
)
884 return ImpDdeMgr::DdeDisconnect( hConv
);
887 HCONV
DdeReconnect(HCONV hConv
)
889 return ImpDdeMgr::DdeReconnect( hConv
);
893 USHORT
DdeQueryConvInfo(HCONV hConv
, ULONG idTransact
, CONVINFO
* pCI
)
895 return ImpDdeMgr::DdeQueryConvInfo( hConv
, idTransact
, pCI
);
898 BOOL
DdeSetUserHandle(HCONV hConv
, ULONG id
, ULONG hUser
)
900 return ImpDdeMgr::DdeSetUserHandle( hConv
, id
, hUser
);
903 BOOL
DdeAbandonTransaction(ULONG idInst
, HCONV hConv
, ULONG idTransaction
)
907 return ((ImpDdeMgr
*)idInst
)->DdeAbandonTransaction(hConv
,idTransaction
);
910 BOOL
DdePostAdvise(ULONG idInst
, HSZ hszTopic
, HSZ hszItem
)
914 return ((ImpDdeMgr
*)idInst
)->DdePostAdvise( hszTopic
, hszItem
);
917 BOOL
DdeEnableCallback(ULONG idInst
, HCONV hConv
, USHORT wCmd
)
921 return ((ImpDdeMgr
*)idInst
)->DdeEnableCallback( hConv
, wCmd
);
924 HDDEDATA
DdeClientTransaction(void* pData
, ULONG cbData
,
925 HCONV hConv
, HSZ hszItem
, USHORT wFmt
, USHORT wType
,
926 ULONG dwTimeout
, ULONG
* pdwResult
)
928 return ImpDdeMgr::DdeClientTransaction( pData
, cbData
,
929 hConv
, hszItem
, wFmt
, wType
, dwTimeout
, pdwResult
);
932 HDDEDATA
DdeCreateDataHandle(ULONG idInst
, void* pSrc
, ULONG cb
,
933 ULONG cbOff
, HSZ hszItem
, USHORT wFmt
, USHORT afCmd
)
937 return ((ImpDdeMgr
*)idInst
)->DdeCreateDataHandle( pSrc
, cb
,
938 cbOff
, hszItem
, wFmt
, afCmd
);
941 HDDEDATA
DdeAddData(HDDEDATA hData
, void* pSrc
, ULONG cb
, ULONG cbOff
)
943 return ImpDdeMgr::DdeAddData( hData
, pSrc
, cb
, cbOff
);
946 ULONG
DdeGetData(HDDEDATA hData
, void* pDst
, ULONG cbMax
, ULONG cbOff
)
948 return ImpDdeMgr::DdeGetData( hData
, pDst
, cbMax
, cbOff
);
951 BYTE
* DdeAccessData(HDDEDATA hData
, ULONG
* pcbDataSize
)
953 return ImpDdeMgr::DdeAccessData( hData
, pcbDataSize
);
956 BOOL
DdeUnaccessData(HDDEDATA hData
)
958 return ImpDdeMgr::DdeUnaccessData( hData
);
961 BOOL
DdeFreeDataHandle(HDDEDATA hData
)
963 return ImpDdeMgr::DdeFreeDataHandle( hData
);
966 USHORT
DdeGetLastError(ULONG idInst
)
969 return DMLERR_DLL_NOT_INITIALIZED
;
970 return ((ImpDdeMgr
*)idInst
)->DdeGetLastError();
973 HSZ
DdeCreateStringHandle(ULONG idInst
, PSZ pszString
,int iCodePage
)
977 return ((ImpDdeMgr
*)idInst
)->DdeCreateStringHandle(pszString
,iCodePage
);
980 ULONG
DdeQueryString( ULONG idInst
, HSZ hsz
, PSZ pBuf
,
981 ULONG cchMax
, int iCodePage
)
985 return ((ImpDdeMgr
*)idInst
)->DdeQueryString( hsz
,pBuf
,cchMax
,iCodePage
);
988 BOOL
DdeFreeStringHandle( ULONG idInst
, HSZ hsz
)
992 return ((ImpDdeMgr
*)idInst
)->DdeFreeStringHandle( hsz
);
995 BOOL
DdeKeepStringHandle( ULONG idInst
, HSZ hsz
)
999 return ((ImpDdeMgr
*)idInst
)->DdeKeepStringHandle( hsz
);
1002 int DdeCmpStringHandles(HSZ hsz1
, HSZ hsz2
)
1004 return ImpDdeMgr::DdeCmpStringHandles( hsz1
, hsz2
);
1007 HDDEDATA
DdeNameService( ULONG idInst
, HSZ hsz1
, HSZ hszRes
, USHORT afCmd
)
1011 return ((ImpDdeMgr
*)idInst
)->DdeNameService( hsz1
, afCmd
);