[browseui, shell32, explorer_new, include]
[reactos.git] / reactos / dll / win32 / browseui / newatlinterfaces.h
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 #ifndef _newatlinteraces_h
22 #define _newatlinteraces_h
23
24 template<class T>
25 class IProfferServiceImpl : public IProfferService
26 {
27 public:
28 STDMETHODIMP ProfferService(REFGUID rguidService, IServiceProvider *psp, DWORD *pdwCookie)
29 {
30 return E_NOTIMPL;
31 }
32
33 STDMETHODIMP RevokeService(DWORD dwCookie)
34 {
35 return E_NOTIMPL;
36 }
37
38 HRESULT QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
39 {
40 return E_FAIL;
41 }
42 };
43
44 /*
45 This subclass corrects a problem with the ATL IConnectionPointImpl.
46 IConnectionPointImpl queries for the exact interface that is published, but at least one
47 implementor of IConnectionPoint (CShellBrowser) advertises DIID_DWebBrowserEvents,
48 but fires events to IDispatch.
49 */
50 template<class T, const IID *piid, class CDV = CComDynamicUnkArray>
51 class MyIConnectionPointImpl : public IConnectionPointImpl<T, piid, CDV>
52 {
53 public:
54 STDMETHODIMP Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
55 {
56 IConnectionPointImpl<T, piid, CDV> *pThisCPImpl;
57 T *pThis;
58 IUnknown *adviseSink;
59 DWORD newCookie;
60 HRESULT hResult;
61
62 pThis = static_cast<T *>(this);
63 pThisCPImpl = static_cast<IConnectionPointImpl<T, piid, CDV> *>(this);
64 if (pdwCookie != NULL)
65 *pdwCookie = 0;
66 if (pUnkSink == NULL || pdwCookie == NULL)
67 return E_POINTER;
68 hResult = pUnkSink->QueryInterface(IID_IDispatch, (void **)&adviseSink);
69 if (FAILED(hResult))
70 {
71 if (hResult == E_NOINTERFACE)
72 return CONNECT_E_CANNOTCONNECT;
73 return hResult;
74 }
75 pThis->Lock();
76 newCookie = pThisCPImpl->m_vec.Add(adviseSink);
77 pThis->Unlock();
78 *pdwCookie = newCookie;
79 if (newCookie != 0)
80 hResult = S_OK;
81 else
82 {
83 adviseSink->Release();
84 hResult = CONNECT_E_ADVISELIMIT;
85 }
86 return hResult;
87 }
88 };
89
90 #endif // _newatlinteraces_h