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