1*c2c66affSColin Finck /* 2*c2c66affSColin Finck * ReactOS Explorer 3*c2c66affSColin Finck * 4*c2c66affSColin Finck * Copyright 2009 Andrew Hill <ash77 at domain reactos.org> 5*c2c66affSColin Finck * 6*c2c66affSColin Finck * This library is free software; you can redistribute it and/or 7*c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public 8*c2c66affSColin Finck * License as published by the Free Software Foundation; either 9*c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version. 10*c2c66affSColin Finck * 11*c2c66affSColin Finck * This library is distributed in the hope that it will be useful, 12*c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14*c2c66affSColin Finck * Lesser General Public License for more details. 15*c2c66affSColin Finck * 16*c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public 17*c2c66affSColin Finck * License along with this library; if not, write to the Free Software 18*c2c66affSColin Finck * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19*c2c66affSColin Finck */ 20*c2c66affSColin Finck 21*c2c66affSColin Finck #pragma once 22*c2c66affSColin Finck 23*c2c66affSColin Finck template<class T> 24*c2c66affSColin Finck class IProfferServiceImpl : public IProfferService 25*c2c66affSColin Finck { 26*c2c66affSColin Finck public: ProfferService(REFGUID rguidService,IServiceProvider * psp,DWORD * pdwCookie)27*c2c66affSColin Finck STDMETHODIMP ProfferService(REFGUID rguidService, IServiceProvider *psp, DWORD *pdwCookie) 28*c2c66affSColin Finck { 29*c2c66affSColin Finck return E_NOTIMPL; 30*c2c66affSColin Finck } 31*c2c66affSColin Finck RevokeService(DWORD dwCookie)32*c2c66affSColin Finck STDMETHODIMP RevokeService(DWORD dwCookie) 33*c2c66affSColin Finck { 34*c2c66affSColin Finck return E_NOTIMPL; 35*c2c66affSColin Finck } 36*c2c66affSColin Finck QueryService(REFGUID guidService,REFIID riid,void ** ppvObject)37*c2c66affSColin Finck HRESULT QueryService(REFGUID guidService, REFIID riid, void **ppvObject) 38*c2c66affSColin Finck { 39*c2c66affSColin Finck return E_FAIL; 40*c2c66affSColin Finck } 41*c2c66affSColin Finck }; 42*c2c66affSColin Finck 43*c2c66affSColin Finck /* 44*c2c66affSColin Finck This subclass corrects a problem with the ATL IConnectionPointImpl. 45*c2c66affSColin Finck IConnectionPointImpl queries for the exact interface that is published, but at least one 46*c2c66affSColin Finck implementor of IConnectionPoint (CShellBrowser) advertises DIID_DWebBrowserEvents, 47*c2c66affSColin Finck but fires events to IDispatch. 48*c2c66affSColin Finck */ 49*c2c66affSColin Finck template<class T, const IID *piid, class CDV = CComDynamicUnkArray> 50*c2c66affSColin Finck class MyIConnectionPointImpl : public IConnectionPointImpl<T, piid, CDV> 51*c2c66affSColin Finck { 52*c2c66affSColin Finck public: Advise(IUnknown * pUnkSink,DWORD * pdwCookie)53*c2c66affSColin Finck STDMETHODIMP Advise(IUnknown *pUnkSink, DWORD *pdwCookie) 54*c2c66affSColin Finck { 55*c2c66affSColin Finck IConnectionPointImpl<T, piid, CDV> *pThisCPImpl; 56*c2c66affSColin Finck T *pThis; 57*c2c66affSColin Finck IUnknown *adviseSink; 58*c2c66affSColin Finck DWORD newCookie; 59*c2c66affSColin Finck HRESULT hResult; 60*c2c66affSColin Finck 61*c2c66affSColin Finck pThis = static_cast<T *>(this); 62*c2c66affSColin Finck pThisCPImpl = static_cast<IConnectionPointImpl<T, piid, CDV> *>(this); 63*c2c66affSColin Finck if (pdwCookie != NULL) 64*c2c66affSColin Finck *pdwCookie = 0; 65*c2c66affSColin Finck if (pUnkSink == NULL || pdwCookie == NULL) 66*c2c66affSColin Finck return E_POINTER; 67*c2c66affSColin Finck hResult = pUnkSink->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&adviseSink)); 68*c2c66affSColin Finck if (FAILED(hResult)) 69*c2c66affSColin Finck { 70*c2c66affSColin Finck if (hResult == E_NOINTERFACE) 71*c2c66affSColin Finck return CONNECT_E_CANNOTCONNECT; 72*c2c66affSColin Finck return hResult; 73*c2c66affSColin Finck } 74*c2c66affSColin Finck pThis->Lock(); 75*c2c66affSColin Finck newCookie = pThisCPImpl->m_vec.Add(adviseSink); 76*c2c66affSColin Finck pThis->Unlock(); 77*c2c66affSColin Finck *pdwCookie = newCookie; 78*c2c66affSColin Finck if (newCookie != 0) 79*c2c66affSColin Finck hResult = S_OK; 80*c2c66affSColin Finck else 81*c2c66affSColin Finck { 82*c2c66affSColin Finck adviseSink->Release(); 83*c2c66affSColin Finck hResult = CONNECT_E_ADVISELIMIT; 84*c2c66affSColin Finck } 85*c2c66affSColin Finck return hResult; 86*c2c66affSColin Finck } 87*c2c66affSColin Finck }; 88