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 ITypeLib
*typelib
;
58 static ITypeInfo
*typeinfos
[LAST_tid
];
60 static REFIID tid_ids
[] = {
61 #define XIID(iface) &IID_ ## iface,
62 #define XCLSID(class) &CLSID_ ## class,
68 static HRESULT
load_typelib(void)
73 hres
= LoadRegTypeLib(&LIBID_SHDocVw
, 1, 1, LOCALE_SYSTEM_DEFAULT
, &tl
);
75 ERR("LoadRegTypeLib failed: %08x\n", hres
);
79 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
84 HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
)
89 hres
= load_typelib();
96 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
98 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hres
);
102 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
103 ITypeInfo_Release(ti
);
106 *typeinfo
= typeinfos
[tid
];
110 static void release_typelib(void)
117 for(i
=0; i
< sizeof(typeinfos
)/sizeof(*typeinfos
); i
++) {
119 ITypeInfo_Release(typeinfos
[i
]);
122 ITypeLib_Release(typelib
);
125 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
129 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
130 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
132 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
133 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
138 IUnknown_AddRef((IUnknown
*)*ppv
);
142 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
143 return E_NOINTERFACE
;
146 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
148 TRACE("(%p)\n", iface
);
152 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
154 TRACE("(%p)\n", iface
);
158 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
160 TRACE("(%p)->(%x)\n", iface
, fLock
);
164 static const IClassFactoryVtbl WebBrowserFactoryVtbl
= {
165 ClassFactory_QueryInterface
,
167 ClassFactory_Release
,
169 ClassFactory_LockServer
172 static IClassFactory WebBrowserFactory
= { &WebBrowserFactoryVtbl
};
174 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl
= {
175 ClassFactory_QueryInterface
,
177 ClassFactory_Release
,
179 ClassFactory_LockServer
182 static IClassFactory WebBrowserV1Factory
= { &WebBrowserV1FactoryVtbl
};
184 static const IClassFactoryVtbl InternetShortcutFactoryVtbl
= {
185 ClassFactory_QueryInterface
,
187 ClassFactory_Release
,
188 InternetShortcut_Create
,
189 ClassFactory_LockServer
192 static IClassFactory InternetShortcutFactory
= { &InternetShortcutFactoryVtbl
};
194 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl
= {
195 ClassFactory_QueryInterface
,
197 ClassFactory_Release
,
199 ClassFactory_LockServer
202 static IClassFactory CUrlHistoryFactory
= { &CUrlHistoryFactoryVtbl
};
204 static const IClassFactoryVtbl TaskbarListFactoryVtbl
= {
205 ClassFactory_QueryInterface
,
207 ClassFactory_Release
,
209 ClassFactory_LockServer
212 static IClassFactory TaskbarListFactory
= { &TaskbarListFactoryVtbl
};
214 /******************************************************************
215 * DllMain (ieframe.@)
217 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
219 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
223 case DLL_WINE_PREATTACH
:
224 return FALSE
; /* prefer native version */
225 case DLL_PROCESS_ATTACH
:
226 ieframe_instance
= hInstDLL
;
227 register_iewindow_class();
228 DisableThreadLibraryCalls(ieframe_instance
);
230 case DLL_PROCESS_DETACH
:
231 unregister_iewindow_class();
238 /***********************************************************************
239 * DllGetClassObject (ieframe.@)
241 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
243 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)) {
244 TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid
), ppv
);
245 return IClassFactory_QueryInterface(&WebBrowserFactory
, riid
, ppv
);
248 if(IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)) {
249 TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid
), ppv
);
250 return IClassFactory_QueryInterface(&WebBrowserV1Factory
, riid
, ppv
);
254 if(IsEqualGUID(rclsid
, &CLSID_InternetShortcut
)) {
255 TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid
), ppv
);
256 return IClassFactory_QueryInterface(&InternetShortcutFactory
, riid
, ppv
);
259 if(IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)) {
260 TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid
), ppv
);
261 return IClassFactory_QueryInterface(&CUrlHistoryFactory
, riid
, ppv
);
264 if(IsEqualGUID(&CLSID_TaskbarList
, rclsid
)) {
265 TRACE("(CLSID_TaskbarList %s %p)\n", debugstr_guid(riid
), ppv
);
266 return IClassFactory_QueryInterface(&TaskbarListFactory
, riid
, ppv
);
270 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
271 return CLASS_E_CLASSNOTAVAILABLE
;
274 static const IClassFactoryVtbl InternetExplorerFactoryVtbl
= {
275 ClassFactory_QueryInterface
,
277 ClassFactory_Release
,
278 InternetExplorer_Create
,
279 ClassFactory_LockServer
282 static IClassFactory InternetExplorerFactory
= { &InternetExplorerFactoryVtbl
};
284 HRESULT
register_class_object(BOOL do_reg
)
291 hres
= CoRegisterClassObject(&CLSID_InternetExplorer
,
292 (IUnknown
*)&InternetExplorerFactory
, CLSCTX_SERVER
,
293 REGCLS_MULTIPLEUSE
|REGCLS_SUSPENDED
, &cookie
);
295 ERR("failed to register object %08x\n", hres
);
299 hres
= CoResumeClassObjects();
303 ERR("failed to resume object %08x\n", hres
);
306 return CoRevokeClassObject(cookie
);
309 /***********************************************************************
310 * DllCanUnloadNow (ieframe.@)
312 HRESULT WINAPI
DllCanUnloadNow(void)
315 return module_ref
? S_FALSE
: S_OK
;
318 /***********************************************************************
319 * DllRegisterServer (ieframe.@)
321 HRESULT WINAPI
DllRegisterServer(void)
324 return __wine_register_resources(ieframe_instance
);
327 /***********************************************************************
328 * DllUnregisterServer (ieframe.@)
330 HRESULT WINAPI
DllUnregisterServer(void)
333 return __wine_unregister_resources(ieframe_instance
);
336 /***********************************************************************
337 * IEGetWriteableHKCU (ieframe.@)
339 HRESULT WINAPI
IEGetWriteableHKCU(HKEY
*pkey
)
341 FIXME("(%p) stub\n", pkey
);