include: Add event trace flags and guid to evntrace.h.
[wine.git] / dlls / ieframe / ieframe_main.c
blobc6eaa845167efe6b8de079de3f99f23c0b0fb9c8
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 static ITypeLib *typelib;
33 static ITypeInfo *typeinfos[LAST_tid];
35 static REFIID tid_ids[] = {
36 #define XIID(iface) &IID_ ## iface,
37 #define XCLSID(class) &CLSID_ ## class,
38 TID_LIST
39 #undef XIID
40 #undef XCLSID
43 static HRESULT load_typelib(void)
45 HRESULT hres;
46 ITypeLib *tl;
48 hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &tl);
49 if(FAILED(hres)) {
50 ERR("LoadRegTypeLib failed: %08x\n", hres);
51 return hres;
54 if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
55 ITypeLib_Release(tl);
56 return hres;
59 HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
61 HRESULT hres;
63 if(!typelib)
64 hres = load_typelib();
65 if(!typelib)
66 return hres;
68 if(!typeinfos[tid]) {
69 ITypeInfo *ti;
71 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
72 if(FAILED(hres)) {
73 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
74 return hres;
77 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
78 ITypeInfo_Release(ti);
81 *typeinfo = typeinfos[tid];
82 return S_OK;
85 static void release_typelib(void)
87 unsigned i;
89 if(!typelib)
90 return;
92 for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++) {
93 if(typeinfos[i])
94 ITypeInfo_Release(typeinfos[i]);
97 ITypeLib_Release(typelib);
100 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
102 *ppv = NULL;
104 if(IsEqualGUID(&IID_IUnknown, riid)) {
105 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
106 *ppv = iface;
107 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
108 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
109 *ppv = iface;
112 if(*ppv) {
113 IUnknown_AddRef((IUnknown*)*ppv);
114 return S_OK;
117 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
118 return E_NOINTERFACE;
121 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
123 TRACE("(%p)\n", iface);
124 return 2;
127 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
129 TRACE("(%p)\n", iface);
130 return 1;
133 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
135 TRACE("(%p)->(%x)\n", iface, fLock);
136 return S_OK;
139 static const IClassFactoryVtbl WebBrowserFactoryVtbl = {
140 ClassFactory_QueryInterface,
141 ClassFactory_AddRef,
142 ClassFactory_Release,
143 WebBrowser_Create,
144 ClassFactory_LockServer
147 static IClassFactory WebBrowserFactory = { &WebBrowserFactoryVtbl };
149 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl = {
150 ClassFactory_QueryInterface,
151 ClassFactory_AddRef,
152 ClassFactory_Release,
153 WebBrowserV1_Create,
154 ClassFactory_LockServer
157 static IClassFactory WebBrowserV1Factory = { &WebBrowserV1FactoryVtbl };
159 static const IClassFactoryVtbl InternetShortcutFactoryVtbl = {
160 ClassFactory_QueryInterface,
161 ClassFactory_AddRef,
162 ClassFactory_Release,
163 InternetShortcut_Create,
164 ClassFactory_LockServer
167 static IClassFactory InternetShortcutFactory = { &InternetShortcutFactoryVtbl };
169 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl = {
170 ClassFactory_QueryInterface,
171 ClassFactory_AddRef,
172 ClassFactory_Release,
173 CUrlHistory_Create,
174 ClassFactory_LockServer
177 static IClassFactory CUrlHistoryFactory = { &CUrlHistoryFactoryVtbl };
179 /******************************************************************
180 * DllMain (ieframe.@)
182 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
184 TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
186 switch(fdwReason)
188 case DLL_WINE_PREATTACH:
189 return FALSE; /* prefer native version */
190 case DLL_PROCESS_ATTACH:
191 ieframe_instance = hInstDLL;
192 register_iewindow_class();
193 DisableThreadLibraryCalls(ieframe_instance);
194 break;
195 case DLL_PROCESS_DETACH:
196 if (lpv) break;
197 unregister_iewindow_class();
198 release_typelib();
201 return TRUE;
204 /***********************************************************************
205 * DllGetClassObject (ieframe.@)
207 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
209 if(IsEqualGUID(&CLSID_WebBrowser, rclsid)) {
210 TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid), ppv);
211 return IClassFactory_QueryInterface(&WebBrowserFactory, riid, ppv);
214 if(IsEqualGUID(&CLSID_WebBrowser_V1, rclsid)) {
215 TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid), ppv);
216 return IClassFactory_QueryInterface(&WebBrowserV1Factory, riid, ppv);
219 if(IsEqualGUID(rclsid, &CLSID_InternetShortcut)) {
220 TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid), ppv);
221 return IClassFactory_QueryInterface(&InternetShortcutFactory, riid, ppv);
224 if(IsEqualGUID(&CLSID_CUrlHistory, rclsid)) {
225 TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid), ppv);
226 return IClassFactory_QueryInterface(&CUrlHistoryFactory, riid, ppv);
229 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
230 return CLASS_E_CLASSNOTAVAILABLE;
233 static const IClassFactoryVtbl InternetExplorerFactoryVtbl = {
234 ClassFactory_QueryInterface,
235 ClassFactory_AddRef,
236 ClassFactory_Release,
237 InternetExplorer_Create,
238 ClassFactory_LockServer
241 static IClassFactory InternetExplorerFactory = { &InternetExplorerFactoryVtbl };
243 HRESULT register_class_object(BOOL do_reg)
245 HRESULT hres;
247 static DWORD cookie;
249 if(do_reg) {
250 hres = CoRegisterClassObject(&CLSID_InternetExplorer,
251 (IUnknown*)&InternetExplorerFactory, CLSCTX_SERVER,
252 REGCLS_MULTIPLEUSE|REGCLS_SUSPENDED, &cookie);
253 if (FAILED(hres)) {
254 ERR("failed to register object %08x\n", hres);
255 return hres;
258 hres = CoResumeClassObjects();
259 if(SUCCEEDED(hres))
260 return hres;
262 ERR("failed to resume object %08x\n", hres);
265 return CoRevokeClassObject(cookie);
268 /***********************************************************************
269 * DllCanUnloadNow (ieframe.@)
271 HRESULT WINAPI DllCanUnloadNow(void)
273 TRACE("()\n");
274 return module_ref ? S_FALSE : S_OK;
277 /***********************************************************************
278 * DllRegisterServer (ieframe.@)
280 HRESULT WINAPI DllRegisterServer(void)
282 TRACE("()\n");
283 return __wine_register_resources(ieframe_instance);
286 /***********************************************************************
287 * DllUnregisterServer (ieframe.@)
289 HRESULT WINAPI DllUnregisterServer(void)
291 TRACE("()\n");
292 return __wine_unregister_resources(ieframe_instance);
295 /***********************************************************************
296 * IEGetWriteableHKCU (ieframe.@)
298 HRESULT WINAPI IEGetWriteableHKCU(HKEY *pkey)
300 FIXME("(%p) stub\n", pkey);
301 return E_NOTIMPL;