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 /******************************************************************
205 * DllMain (ieframe.@)
207 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
209 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
213 case DLL_WINE_PREATTACH
:
214 return FALSE
; /* prefer native version */
215 case DLL_PROCESS_ATTACH
:
216 ieframe_instance
= hInstDLL
;
217 register_iewindow_class();
218 DisableThreadLibraryCalls(ieframe_instance
);
220 case DLL_PROCESS_DETACH
:
222 unregister_iewindow_class();
229 /***********************************************************************
230 * DllGetClassObject (ieframe.@)
232 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
234 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)) {
235 TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid
), ppv
);
236 return IClassFactory_QueryInterface(&WebBrowserFactory
, riid
, ppv
);
239 if(IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)) {
240 TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid
), ppv
);
241 return IClassFactory_QueryInterface(&WebBrowserV1Factory
, riid
, ppv
);
244 if(IsEqualGUID(rclsid
, &CLSID_InternetShortcut
)) {
245 TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid
), ppv
);
246 return IClassFactory_QueryInterface(&InternetShortcutFactory
, riid
, ppv
);
249 if(IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)) {
250 TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid
), ppv
);
251 return IClassFactory_QueryInterface(&CUrlHistoryFactory
, riid
, ppv
);
254 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
255 return CLASS_E_CLASSNOTAVAILABLE
;
258 static const IClassFactoryVtbl InternetExplorerFactoryVtbl
= {
259 ClassFactory_QueryInterface
,
261 ClassFactory_Release
,
262 InternetExplorer_Create
,
263 ClassFactory_LockServer
266 static IClassFactory InternetExplorerFactory
= { &InternetExplorerFactoryVtbl
};
268 HRESULT
register_class_object(BOOL do_reg
)
275 hres
= CoRegisterClassObject(&CLSID_InternetExplorer
,
276 (IUnknown
*)&InternetExplorerFactory
, CLSCTX_SERVER
,
277 REGCLS_MULTIPLEUSE
|REGCLS_SUSPENDED
, &cookie
);
279 ERR("failed to register object %08x\n", hres
);
283 hres
= CoResumeClassObjects();
287 ERR("failed to resume object %08x\n", hres
);
290 return CoRevokeClassObject(cookie
);
293 /***********************************************************************
294 * DllCanUnloadNow (ieframe.@)
296 HRESULT WINAPI
DllCanUnloadNow(void)
299 return module_ref
? S_FALSE
: S_OK
;
302 /***********************************************************************
303 * DllRegisterServer (ieframe.@)
305 HRESULT WINAPI
DllRegisterServer(void)
308 return __wine_register_resources(ieframe_instance
);
311 /***********************************************************************
312 * DllUnregisterServer (ieframe.@)
314 HRESULT WINAPI
DllUnregisterServer(void)
317 return __wine_unregister_resources(ieframe_instance
);
320 /***********************************************************************
321 * IEGetWriteableHKCU (ieframe.@)
323 HRESULT WINAPI
IEGetWriteableHKCU(HKEY
*pkey
)
325 FIXME("(%p) stub\n", pkey
);