xref: /reactos/dll/win32/ieframe/classinfo.c (revision c2c66aff)
1 /*
2  * Implementation of IProvideClassInfo interfaces for WebBrowser control
3  *
4  * Copyright 2001 John R. Sheets (for CodeWeavers)
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #include "ieframe.h"
22 
23 /**********************************************************************
24  * Implement the IProvideClassInfo2 interface
25  */
26 
27 static inline WebBrowser *impl_from_IProvideClassInfo2(IProvideClassInfo2 *iface)
28 {
29     return CONTAINING_RECORD(iface, WebBrowser, IProvideClassInfo2_iface);
30 }
31 
32 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo2 *iface,
33         REFIID riid, LPVOID *ppobj)
34 {
35     WebBrowser *This = impl_from_IProvideClassInfo2(iface);
36     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
37 }
38 
39 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo2 *iface)
40 {
41     WebBrowser *This = impl_from_IProvideClassInfo2(iface);
42     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
43 }
44 
45 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo2 *iface)
46 {
47     WebBrowser *This = impl_from_IProvideClassInfo2(iface);
48     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
49 }
50 
51 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo2 *iface, ITypeInfo **ppTI)
52 {
53     WebBrowser *This = impl_from_IProvideClassInfo2(iface);
54     HRESULT hres;
55 
56     TRACE("(%p)->(%p)\n", This, ppTI);
57 
58     hres = get_typeinfo(This->version > 1 ? WebBrowser_tid : WebBrowser_V1_tid, ppTI);
59     if(FAILED(hres))
60         return hres;
61 
62     ITypeInfo_AddRef(*ppTI);
63     return S_OK;
64 }
65 
66 static HRESULT WINAPI ProvideClassInfo_GetGUID(IProvideClassInfo2 *iface,
67         DWORD dwGuidKind, GUID *pGUID)
68 {
69     WebBrowser *This = impl_from_IProvideClassInfo2(iface);
70 
71     TRACE("(%p)->(%d %p)\n", This, dwGuidKind, pGUID);
72 
73     if(!pGUID)
74         return E_POINTER;
75 
76     if (dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID) {
77         WARN("Wrong GUID type: %d\n", dwGuidKind);
78         *pGUID = IID_NULL;
79         return E_FAIL;
80     }
81 
82     memcpy(pGUID, This->version == 1 ? &DIID_DWebBrowserEvents : &DIID_DWebBrowserEvents2,
83            sizeof(GUID));
84     return S_OK;
85 }
86 
87 static const IProvideClassInfo2Vtbl ProvideClassInfoVtbl =
88 {
89     ProvideClassInfo_QueryInterface,
90     ProvideClassInfo_AddRef,
91     ProvideClassInfo_Release,
92     ProvideClassInfo_GetClassInfo,
93     ProvideClassInfo_GetGUID
94 };
95 
96 void WebBrowser_ClassInfo_Init(WebBrowser *This)
97 {
98     This->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfoVtbl;
99 }
100