quartz: Free two assert calls from having side effects.
[wine/testsucceed.git] / dlls / ieframe / ieframe_main.c
blobcb810cc6fdada03d6030ec2ce493614bd478791e
1 /*
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
19 #include "ieframe.h"
21 #include "rpcproxy.h"
22 #include "shlguid.h"
23 #include "isguids.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
29 LONG module_ref = 0;
30 HINSTANCE ieframe_instance;
32 const char *debugstr_variant(const VARIANT *v)
34 if(!v)
35 return "(null)";
37 switch(V_VT(v)) {
38 case VT_EMPTY:
39 return "{VT_EMPTY}";
40 case VT_NULL:
41 return "{VT_NULL}";
42 case VT_I4:
43 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
44 case VT_R8:
45 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
46 case VT_BSTR:
47 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
48 case VT_DISPATCH:
49 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
50 case VT_BOOL:
51 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
52 default:
53 return wine_dbg_sprintf("{vt %d}", V_VT(v));
57 static ITypeInfo *wb_typeinfo = NULL;
59 HRESULT get_typeinfo(ITypeInfo **typeinfo)
61 ITypeLib *typelib;
62 HRESULT hres;
64 if(wb_typeinfo) {
65 *typeinfo = wb_typeinfo;
66 return S_OK;
69 hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &typelib);
70 if(FAILED(hres)) {
71 ERR("LoadRegTypeLib failed: %08x\n", hres);
72 return hres;
75 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IWebBrowser2, &wb_typeinfo);
76 ITypeLib_Release(typelib);
78 *typeinfo = wb_typeinfo;
79 return hres;
82 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
84 *ppv = NULL;
86 if(IsEqualGUID(&IID_IUnknown, riid)) {
87 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
88 *ppv = iface;
89 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
90 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
91 *ppv = iface;
94 if(*ppv) {
95 IUnknown_AddRef((IUnknown*)*ppv);
96 return S_OK;
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);
106 return 2;
109 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
111 TRACE("(%p)\n", iface);
112 return 1;
115 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
117 TRACE("(%p)->(%x)\n", iface, fLock);
118 return S_OK;
121 static const IClassFactoryVtbl WebBrowserFactoryVtbl = {
122 ClassFactory_QueryInterface,
123 ClassFactory_AddRef,
124 ClassFactory_Release,
125 WebBrowser_Create,
126 ClassFactory_LockServer
129 static IClassFactory WebBrowserFactory = { &WebBrowserFactoryVtbl };
131 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl = {
132 ClassFactory_QueryInterface,
133 ClassFactory_AddRef,
134 ClassFactory_Release,
135 WebBrowserV1_Create,
136 ClassFactory_LockServer
139 static IClassFactory WebBrowserV1Factory = { &WebBrowserV1FactoryVtbl };
141 static const IClassFactoryVtbl InternetShortcutFactoryVtbl = {
142 ClassFactory_QueryInterface,
143 ClassFactory_AddRef,
144 ClassFactory_Release,
145 InternetShortcut_Create,
146 ClassFactory_LockServer
149 static IClassFactory InternetShortcutFactory = { &InternetShortcutFactoryVtbl };
151 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl = {
152 ClassFactory_QueryInterface,
153 ClassFactory_AddRef,
154 ClassFactory_Release,
155 CUrlHistory_Create,
156 ClassFactory_LockServer
159 static IClassFactory CUrlHistoryFactory = { &CUrlHistoryFactoryVtbl };
161 static const IClassFactoryVtbl TaskbarListFactoryVtbl = {
162 ClassFactory_QueryInterface,
163 ClassFactory_AddRef,
164 ClassFactory_Release,
165 TaskbarList_Create,
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);
178 switch(fdwReason)
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);
186 break;
187 case DLL_PROCESS_DETACH:
188 unregister_iewindow_class();
189 if(wb_typeinfo)
190 ITypeInfo_Release(wb_typeinfo);
193 return TRUE;
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,
234 ClassFactory_AddRef,
235 ClassFactory_Release,
236 InternetExplorer_Create,
237 ClassFactory_LockServer
240 static IClassFactory InternetExplorerFactory = { &InternetExplorerFactoryVtbl };
242 HRESULT register_class_object(BOOL do_reg)
244 HRESULT hres;
246 static DWORD cookie;
248 if(do_reg) {
249 hres = CoRegisterClassObject(&CLSID_InternetExplorer,
250 (IUnknown*)&InternetExplorerFactory, CLSCTX_SERVER,
251 REGCLS_MULTIPLEUSE|REGCLS_SUSPENDED, &cookie);
252 if (FAILED(hres)) {
253 ERR("failed to register object %08x\n", hres);
254 return hres;
257 hres = CoResumeClassObjects();
258 if(SUCCEEDED(hres))
259 return hres;
261 ERR("failed to resume object %08x\n", hres);
264 return CoRevokeClassObject(cookie);
267 /***********************************************************************
268 * DllCanUnloadNow (ieframe.@)
270 HRESULT WINAPI DllCanUnloadNow(void)
272 TRACE("()\n");
273 return module_ref ? S_FALSE : S_OK;
276 /***********************************************************************
277 * DllRegisterServer (ieframe.@)
279 HRESULT WINAPI DllRegisterServer(void)
281 TRACE("()\n");
282 return __wine_register_resources(ieframe_instance);
285 /***********************************************************************
286 * DllUnregisterServer (ieframe.@)
288 HRESULT WINAPI DllUnregisterServer(void)
290 TRACE("()\n");
291 return __wine_unregister_resources(ieframe_instance);
294 /***********************************************************************
295 * IEGetWriteableHKCU (ieframe.@)
297 HRESULT WINAPI IEGetWriteableHKCU(HKEY *pkey)
299 FIXME("(%p) stub\n", pkey);
300 return E_NOTIMPL;