2 * Copyright 2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
30 HINSTANCE ieframe_instance;
32 const char *debugstr_variant(const VARIANT *v)
43 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
45 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
47 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
49 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
51 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
53 return wine_dbg_sprintf("{vt %d}", V_VT(v));
57 static ITypeInfo *wb_typeinfo = NULL;
59 HRESULT get_typeinfo(ITypeInfo **typeinfo)
65 *typeinfo = wb_typeinfo;
69 hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &typelib);
71 ERR("LoadRegTypeLib failed: %08x\n", hres);
75 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IWebBrowser2, &wb_typeinfo);
76 ITypeLib_Release(typelib);
78 *typeinfo = wb_typeinfo;
82 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
86 if(IsEqualGUID(&IID_IUnknown, riid)) {
87 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
89 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
90 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
95 IUnknown_AddRef((IUnknown*)*ppv);
99 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
100 return E_NOINTERFACE;
103 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
105 TRACE("(%p)\n", iface);
109 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
111 TRACE("(%p)\n", iface);
115 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
117 TRACE("(%p)->(%x)\n", iface, fLock);
121 static const IClassFactoryVtbl WebBrowserFactoryVtbl = {
122 ClassFactory_QueryInterface,
124 ClassFactory_Release,
126 ClassFactory_LockServer
129 static IClassFactory WebBrowserFactory = { &WebBrowserFactoryVtbl };
131 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl = {
132 ClassFactory_QueryInterface,
134 ClassFactory_Release,
136 ClassFactory_LockServer
139 static IClassFactory WebBrowserV1Factory = { &WebBrowserV1FactoryVtbl };
141 static const IClassFactoryVtbl InternetShortcutFactoryVtbl = {
142 ClassFactory_QueryInterface,
144 ClassFactory_Release,
145 InternetShortcut_Create,
146 ClassFactory_LockServer
149 static IClassFactory InternetShortcutFactory = { &InternetShortcutFactoryVtbl };
151 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl = {
152 ClassFactory_QueryInterface,
154 ClassFactory_Release,
156 ClassFactory_LockServer
159 static IClassFactory CUrlHistoryFactory = { &CUrlHistoryFactoryVtbl };
161 static const IClassFactoryVtbl TaskbarListFactoryVtbl = {
162 ClassFactory_QueryInterface,
164 ClassFactory_Release,
166 ClassFactory_LockServer
169 static IClassFactory TaskbarListFactory = { &TaskbarListFactoryVtbl };
171 /******************************************************************
172 * DllMain (ieframe.@)
174 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
176 TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
180 case DLL_WINE_PREATTACH:
181 return FALSE; /* prefer native version */
182 case DLL_PROCESS_ATTACH:
183 ieframe_instance = hInstDLL;
184 register_iewindow_class();
185 DisableThreadLibraryCalls(ieframe_instance);
187 case DLL_PROCESS_DETACH:
188 unregister_iewindow_class();
190 ITypeInfo_Release(wb_typeinfo);
196 /***********************************************************************
197 * DllGetClassObject (ieframe.@)
199 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
201 if(IsEqualGUID(&CLSID_WebBrowser, rclsid)) {
202 TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid), ppv);
203 return IClassFactory_QueryInterface(&WebBrowserFactory, riid, ppv);
206 if(IsEqualGUID(&CLSID_WebBrowser_V1, rclsid)) {
207 TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid), ppv);
208 return IClassFactory_QueryInterface(&WebBrowserV1Factory, riid, ppv);
212 if(IsEqualGUID(rclsid, &CLSID_InternetShortcut)) {
213 TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid), ppv);
214 return IClassFactory_QueryInterface(&InternetShortcutFactory, riid, ppv);
217 if(IsEqualGUID(&CLSID_CUrlHistory, rclsid)) {
218 TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid), ppv);
219 return IClassFactory_QueryInterface(&CUrlHistoryFactory, riid, ppv);
222 if(IsEqualGUID(&CLSID_TaskbarList, rclsid)) {
223 TRACE("(CLSID_TaskbarList %s %p)\n", debugstr_guid(riid), ppv);
224 return IClassFactory_QueryInterface(&TaskbarListFactory, riid, ppv);
228 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
229 return CLASS_E_CLASSNOTAVAILABLE;
232 static const IClassFactoryVtbl InternetExplorerFactoryVtbl = {
233 ClassFactory_QueryInterface,
235 ClassFactory_Release,
236 InternetExplorer_Create,
237 ClassFactory_LockServer
240 static IClassFactory InternetExplorerFactory = { &InternetExplorerFactoryVtbl };
242 HRESULT register_class_object(BOOL do_reg)
249 hres = CoRegisterClassObject(&CLSID_InternetExplorer,
250 (IUnknown*)&InternetExplorerFactory, CLSCTX_SERVER,
251 REGCLS_MULTIPLEUSE|REGCLS_SUSPENDED, &cookie);
253 ERR("failed to register object %08x\n", hres);
257 hres = CoResumeClassObjects();
261 ERR("failed to resume object %08x\n", hres);
264 return CoRevokeClassObject(cookie);
267 /***********************************************************************
268 * DllCanUnloadNow (ieframe.@)
270 HRESULT WINAPI DllCanUnloadNow(void)
273 return module_ref ? S_FALSE : S_OK;
276 /***********************************************************************
277 * DllRegisterServer (ieframe.@)
279 HRESULT WINAPI DllRegisterServer(void)
282 return __wine_register_resources(ieframe_instance);
285 /***********************************************************************
286 * DllUnregisterServer (ieframe.@)
288 HRESULT WINAPI DllUnregisterServer(void)
291 return __wine_unregister_resources(ieframe_instance);
294 /***********************************************************************
295 * IEGetWriteableHKCU (ieframe.@)
297 HRESULT WINAPI IEGetWriteableHKCU(HKEY *pkey)
299 FIXME("(%p) stub\n", pkey);