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_ERROR: %08x}", V_ERROR(v
));
55 return wine_dbg_sprintf("{vt %d}", V_VT(v
));
59 static ITypeLib
*typelib
;
60 static ITypeInfo
*typeinfos
[LAST_tid
];
62 static REFIID tid_ids
[] = {
63 #define XIID(iface) &IID_ ## iface,
64 #define XCLSID(class) &CLSID_ ## class,
70 static HRESULT
load_typelib(void)
75 hres
= LoadRegTypeLib(&LIBID_SHDocVw
, 1, 1, LOCALE_SYSTEM_DEFAULT
, &tl
);
77 ERR("LoadRegTypeLib failed: %08x\n", hres
);
81 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
86 HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
)
91 hres
= load_typelib();
98 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
100 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hres
);
104 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
105 ITypeInfo_Release(ti
);
108 *typeinfo
= typeinfos
[tid
];
112 static void release_typelib(void)
119 for(i
=0; i
< sizeof(typeinfos
)/sizeof(*typeinfos
); i
++) {
121 ITypeInfo_Release(typeinfos
[i
]);
124 ITypeLib_Release(typelib
);
127 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
131 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
132 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
134 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
135 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
140 IUnknown_AddRef((IUnknown
*)*ppv
);
144 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
145 return E_NOINTERFACE
;
148 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
150 TRACE("(%p)\n", iface
);
154 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
156 TRACE("(%p)\n", iface
);
160 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
162 TRACE("(%p)->(%x)\n", iface
, fLock
);
166 static const IClassFactoryVtbl WebBrowserFactoryVtbl
= {
167 ClassFactory_QueryInterface
,
169 ClassFactory_Release
,
171 ClassFactory_LockServer
174 static IClassFactory WebBrowserFactory
= { &WebBrowserFactoryVtbl
};
176 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl
= {
177 ClassFactory_QueryInterface
,
179 ClassFactory_Release
,
181 ClassFactory_LockServer
184 static IClassFactory WebBrowserV1Factory
= { &WebBrowserV1FactoryVtbl
};
186 static const IClassFactoryVtbl InternetShortcutFactoryVtbl
= {
187 ClassFactory_QueryInterface
,
189 ClassFactory_Release
,
190 InternetShortcut_Create
,
191 ClassFactory_LockServer
194 static IClassFactory InternetShortcutFactory
= { &InternetShortcutFactoryVtbl
};
196 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl
= {
197 ClassFactory_QueryInterface
,
199 ClassFactory_Release
,
201 ClassFactory_LockServer
204 static IClassFactory CUrlHistoryFactory
= { &CUrlHistoryFactoryVtbl
};
206 /******************************************************************
207 * DllMain (ieframe.@)
209 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
211 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
215 case DLL_WINE_PREATTACH
:
216 return FALSE
; /* prefer native version */
217 case DLL_PROCESS_ATTACH
:
218 ieframe_instance
= hInstDLL
;
219 register_iewindow_class();
220 DisableThreadLibraryCalls(ieframe_instance
);
222 case DLL_PROCESS_DETACH
:
224 unregister_iewindow_class();
231 /***********************************************************************
232 * DllGetClassObject (ieframe.@)
234 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
236 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)) {
237 TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid
), ppv
);
238 return IClassFactory_QueryInterface(&WebBrowserFactory
, riid
, ppv
);
241 if(IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)) {
242 TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid
), ppv
);
243 return IClassFactory_QueryInterface(&WebBrowserV1Factory
, riid
, ppv
);
246 if(IsEqualGUID(rclsid
, &CLSID_InternetShortcut
)) {
247 TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid
), ppv
);
248 return IClassFactory_QueryInterface(&InternetShortcutFactory
, riid
, ppv
);
251 if(IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)) {
252 TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid
), ppv
);
253 return IClassFactory_QueryInterface(&CUrlHistoryFactory
, riid
, ppv
);
256 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
257 return CLASS_E_CLASSNOTAVAILABLE
;
260 static const IClassFactoryVtbl InternetExplorerFactoryVtbl
= {
261 ClassFactory_QueryInterface
,
263 ClassFactory_Release
,
264 InternetExplorer_Create
,
265 ClassFactory_LockServer
268 static IClassFactory InternetExplorerFactory
= { &InternetExplorerFactoryVtbl
};
270 HRESULT
register_class_object(BOOL do_reg
)
277 hres
= CoRegisterClassObject(&CLSID_InternetExplorer
,
278 (IUnknown
*)&InternetExplorerFactory
, CLSCTX_SERVER
,
279 REGCLS_MULTIPLEUSE
|REGCLS_SUSPENDED
, &cookie
);
281 ERR("failed to register object %08x\n", hres
);
285 hres
= CoResumeClassObjects();
289 ERR("failed to resume object %08x\n", hres
);
292 return CoRevokeClassObject(cookie
);
295 /***********************************************************************
296 * DllCanUnloadNow (ieframe.@)
298 HRESULT WINAPI
DllCanUnloadNow(void)
301 return module_ref
? S_FALSE
: S_OK
;
304 /***********************************************************************
305 * DllRegisterServer (ieframe.@)
307 HRESULT WINAPI
DllRegisterServer(void)
310 return __wine_register_resources(ieframe_instance
);
313 /***********************************************************************
314 * DllUnregisterServer (ieframe.@)
316 HRESULT WINAPI
DllUnregisterServer(void)
319 return __wine_unregister_resources(ieframe_instance
);
322 /***********************************************************************
323 * IEGetWriteableHKCU (ieframe.@)
325 HRESULT WINAPI
IEGetWriteableHKCU(HKEY
*pkey
)
327 FIXME("(%p) stub\n", pkey
);