* Implement <autoregister>
[reactos.git] / reactos / lib / shdocvw / classinfo.c
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include <stdarg.h>
22 #include <string.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "shdocvw.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
30
31 /**********************************************************************
32 * Implement the IProvideClassInfo2 interface
33 */
34
35 #define CLASSINFO_THIS(iface) DEFINE_THIS(WebBrowser, ProvideClassInfo, iface)
36
37 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo2 *iface,
38 REFIID riid, LPVOID *ppobj)
39 {
40 WebBrowser *This = CLASSINFO_THIS(iface);
41 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
42 }
43
44 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo2 *iface)
45 {
46 WebBrowser *This = CLASSINFO_THIS(iface);
47 return IWebBrowser_AddRef(WEBBROWSER(This));
48 }
49
50 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo2 *iface)
51 {
52 WebBrowser *This = CLASSINFO_THIS(iface);
53 return IWebBrowser_Release(WEBBROWSER(This));
54 }
55
56 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo2 *iface, LPTYPEINFO *ppTI)
57 {
58 WebBrowser *This = CLASSINFO_THIS(iface);
59 FIXME("(%p)->(%p)\n", This, ppTI);
60 return E_NOTIMPL;
61 }
62
63 /* Get the IID for generic default event callbacks. This IID will
64 * in theory be used to later query for an IConnectionPoint to connect
65 * an event sink (callback implementation in the OLE control site)
66 * to this control.
67 */
68 static HRESULT WINAPI ProvideClassInfo_GetGUID(IProvideClassInfo2 *iface,
69 DWORD dwGuidKind, GUID *pGUID)
70 {
71 WebBrowser *This = CLASSINFO_THIS(iface);
72
73 FIXME("(%p)->(%ld %p)\n", This, dwGuidKind, pGUID);
74
75 if (dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID)
76 {
77 FIXME ("Requested unsupported GUID type: %ld\n", dwGuidKind);
78 return E_FAIL; /* Is there a better return type here? */
79 }
80
81 /* FIXME: Returning IPropertyNotifySink interface, but should really
82 * return a more generic event set (???) dispinterface.
83 * However, this hack, allows a control site to return with success
84 * (MFC's COleControlSite falls back to older IProvideClassInfo interface
85 * if GetGUID() fails to return a non-NULL GUID).
86 */
87 memcpy(pGUID, &IID_IPropertyNotifySink, sizeof(GUID));
88 FIXME("Wrongly returning IPropertyNotifySink interface %s\n",
89 debugstr_guid(pGUID));
90
91 return S_OK;
92 }
93
94 #undef CLASSINFO_THIS
95
96 static const IProvideClassInfo2Vtbl ProvideClassInfoVtbl =
97 {
98 ProvideClassInfo_QueryInterface,
99 ProvideClassInfo_AddRef,
100 ProvideClassInfo_Release,
101 ProvideClassInfo_GetClassInfo,
102 ProvideClassInfo_GetGUID
103 };
104
105 void WebBrowser_ClassInfo_Init(WebBrowser *This)
106 {
107 This->lpProvideClassInfoVtbl = &ProvideClassInfoVtbl;
108 }