From 0f44b9d4371c4ccac29368352cf9478b7730e13f Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 3 Sep 2009 21:55:01 +0000 Subject: [PATCH] 2009-09-03 23:54 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbwin/axcore.c ! removed the hack I added in previous commit with interface enumeration which was accepting any interface without validation its ID. + added 3-rd parameter to __AXREGISTERHANDLER() as Mindaugas proposed. Now this function has the following syntax: __AXREGISTERHANDLER( , | [, ] ) -> default value for is IID_IDispatch. --- harbour/ChangeLog | 10 ++++++ harbour/contrib/hbwin/axcore.c | 63 +++++++++++++++------------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 019b8313b7..1e5859b852 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-09-03 23:54 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbwin/axcore.c + ! removed the hack I added in previous commit with interface enumeration + which was accepting any interface without validation its ID. + + added 3-rd parameter to __AXREGISTERHANDLER() as Mindaugas proposed. + Now this function has the following syntax: + __AXREGISTERHANDLER( , | + [, ] ) -> + default value for is IID_IDispatch. + 2009-09-03 14:02 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/compiler/hbmain.c ! added missing pFunc initialization in symbol structure. diff --git a/harbour/contrib/hbwin/axcore.c b/harbour/contrib/hbwin/axcore.c index aa167363d1..b984b7f615 100644 --- a/harbour/contrib/hbwin/axcore.c +++ b/harbour/contrib/hbwin/axcore.c @@ -407,51 +407,44 @@ HB_FUNC( __AXREGISTERHANDLER ) /* ( pDisp, bHandler ) --> pSink */ { IConnectionPointContainer* pCPC = NULL; IConnectionPoint* pCP = NULL; - HRESULT lOleError; - IID rriid = IID_IUnknown; + HRESULT lOleError = S_OK; + IID rriid = IID_IDispatch; + const char* cID = hb_parc( 3 ); + + if( cID ) + { + wchar_t* wCLSID = hb_mbtowc( cID ); + lOleError = CLSIDFromString( wCLSID, &rriid ); + hb_xfree( wCLSID ); + } - lOleError = HB_VTBL( pDisp )->QueryInterface( HB_THIS_( pDisp ) HB_ID_REF( IID_IConnectionPointContainer ), ( void** ) ( void* ) &pCPC ); if( lOleError == S_OK ) { - lOleError = HB_VTBL( pCPC )->FindConnectionPoint( HB_THIS_( pCPC ) HB_ID_REF( IID_IDispatch ), &pCP ); - if( lOleError != S_OK ) - { - IEnumConnectionPoints* pEnumCPs = NULL; - - lOleError = HB_VTBL( pCPC )->EnumConnectionPoints( HB_THIS_( pCPC ) &pEnumCPs ); - if( lOleError == S_OK ) - { - for( ;; ) - { - lOleError = HB_VTBL( pEnumCPs )->Next( HB_THIS_( pEnumCPs ) 1, &pCP, NULL ); - if( lOleError != S_OK ) - break; - if( HB_VTBL( pCP )->GetConnectionInterface( HB_THIS_( pCP ) &rriid ) == S_OK ) - break; - rriid = IID_IUnknown; - } - HB_VTBL( pEnumCPs )->Release( HB_THIS( pEnumCPs ) ); - } - } + lOleError = HB_VTBL( pDisp )->QueryInterface( HB_THIS_( pDisp ) HB_ID_REF( IID_IConnectionPointContainer ), ( void** ) ( void* ) &pCPC ); if( lOleError == S_OK ) { - DWORD dwCookie = 0; - ISink * pSink; + lOleError = HB_VTBL( pCPC )->FindConnectionPoint( HB_THIS_( pCPC ) HB_ID_REF( rriid ), &pCP ); - pSink = ( ISink* ) hb_xgrab( sizeof( ISink ) ); /* TODO: GlobalAlloc/Free GMEM_FIXED ??? */ + if( lOleError == S_OK ) + { + DWORD dwCookie = 0; + ISink * pSink; - pSink->lpVtbl = ( IDispatchVtbl * ) &ISink_Vtbl; - pSink->count = 1; /* 1 for Harbour collectible pointer [Mindaugas] */ - pSink->pItemHandler = hb_itemNew( pItemBlock ); - pSink->rriid = rriid; - lOleError = HB_VTBL( pCP )->Advise( HB_THIS_( pCP ) ( IUnknown* ) pSink, &dwCookie ); - pSink->pConnectionPoint = pCP; - pSink->dwCookie = dwCookie; + pSink = ( ISink* ) hb_xgrab( sizeof( ISink ) ); /* TODO: GlobalAlloc/Free GMEM_FIXED ??? */ - hb_oleItemPut( hb_stackReturnItem(), ( IDispatch* ) pDisp ); + pSink->lpVtbl = ( IDispatchVtbl * ) &ISink_Vtbl; + pSink->count = 1; /* 1 for Harbour collectible pointer [Mindaugas] */ + pSink->pItemHandler = hb_itemNew( pItemBlock ); + pSink->rriid = rriid; + lOleError = HB_VTBL( pCP )->Advise( HB_THIS_( pCP ) ( IUnknown* ) pSink, &dwCookie ); + pSink->pConnectionPoint = pCP; + pSink->dwCookie = dwCookie; + + hb_oleItemPut( hb_stackReturnItem(), ( IDispatch* ) pDisp ); + } + HB_VTBL( pCPC )->Release( HB_THIS( pCPC ) ); } - HB_VTBL( pCPC )->Release( HB_THIS( pCPC ) ); } hb_oleSetError( lOleError );