Nikolay Sivov : explorer: Added IDispatch support for ShellBrowserWindow instance.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 4 07:58:53 CDT 2015
Module: wine
Branch: master
Commit: 58775c878ae7907812824628c5320f9a0239fdd7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=58775c878ae7907812824628c5320f9a0239fdd7
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Apr 30 09:13:27 2015 +0300
explorer: Added IDispatch support for ShellBrowserWindow instance.
---
dlls/shell32/tests/shelldispatch.c | 8 +--
programs/explorer/Makefile.in | 2 +-
programs/explorer/desktop.c | 110 ++++++++++++++++++++++++++++++++-----
3 files changed, 101 insertions(+), 19 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index 7c705d4..14e04c8 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -524,21 +524,19 @@ todo_wine {
/* IDispatch-related tests */
count = 10;
hr = IDispatch_GetTypeInfoCount(disp, &count);
-todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(count == 1, "got %u\n", count);
-}
+
hr = IDispatch_GetTypeInfo(disp, 0, LOCALE_SYSTEM_DEFAULT, &typeinfo);
-todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
-if (hr == S_OK) {
+
hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&typeattr->guid, &IID_IWebBrowser2), "type guid %s\n", wine_dbgstr_guid(&typeattr->guid));
ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr);
ITypeInfo_Release(typeinfo);
-}
+
/* IWebBrowser2 */
hr = IDispatch_QueryInterface(disp, &IID_IWebBrowser2, (void**)&wb);
ok(hr == S_OK, "got 0x%08x\n", hr);
diff --git a/programs/explorer/Makefile.in b/programs/explorer/Makefile.in
index b32b869..a06887c 100644
--- a/programs/explorer/Makefile.in
+++ b/programs/explorer/Makefile.in
@@ -1,7 +1,7 @@
MODULE = explorer.exe
APPMODE = -mwindows -municode
IMPORTS = rpcrt4 user32 gdi32 advapi32
-DELAYIMPORTS = comctl32 shell32 ole32 shlwapi
+DELAYIMPORTS = comctl32 shell32 oleaut32 ole32 shlwapi
C_SRCS = \
appbar.c \
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 3f899e4..b83d772 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -65,6 +65,66 @@ static int desktop_width, launcher_size, launchers_per_row;
static struct launcher **launchers;
static unsigned int nb_launchers, nb_allocated;
+static REFIID tid_ids[] =
+{
+ &IID_NULL,
+ &IID_IWebBrowser2
+};
+
+typedef enum
+{
+ NULL_tid,
+ IWebBrowser2_tid,
+ LAST_tid
+} tid_t;
+
+static ITypeLib *typelib;
+static ITypeInfo *typeinfos[LAST_tid];
+
+static HRESULT load_typelib(void)
+{
+ HRESULT hres;
+ ITypeLib *tl;
+
+ hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
+ if (FAILED(hres))
+ {
+ ERR("LoadRegTypeLib failed: %08x\n", hres);
+ return hres;
+ }
+
+ if (InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
+ ITypeLib_Release(tl);
+ return hres;
+}
+
+static HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
+{
+ HRESULT hres;
+
+ if (!typelib)
+ hres = load_typelib();
+ if (!typelib)
+ return hres;
+
+ if (!typeinfos[tid]) {
+ ITypeInfo *ti;
+
+ hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
+ if (FAILED(hres)) {
+ ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
+ return hres;
+ }
+
+ if (InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
+ ITypeInfo_Release(ti);
+ }
+
+ *typeinfo = typeinfos[tid];
+ ITypeInfo_AddRef(*typeinfo);
+ return S_OK;
+}
+
struct shellwindows
{
IShellWindows IShellWindows_iface;
@@ -1246,19 +1306,17 @@ static ULONG WINAPI webbrowser_Release(IWebBrowser2 *iface)
static HRESULT WINAPI webbrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
{
struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
-
- FIXME("(%p)->(%p): stub\n", This, pctinfo);
-
- *pctinfo = 0;
- return E_NOTIMPL;
+ TRACE("(%p)->(%p)\n", This, pctinfo);
+ *pctinfo = 1;
+ return S_OK;
}
static HRESULT WINAPI webbrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
LPTYPEINFO *ppTInfo)
{
struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
- FIXME("(%p)->(%d %d %p): stub\n", This, iTInfo, lcid, ppTInfo);
- return E_NOTIMPL;
+ TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
+ return get_typeinfo(IWebBrowser2_tid, ppTInfo);
}
static HRESULT WINAPI webbrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
@@ -1266,20 +1324,46 @@ static HRESULT WINAPI webbrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
LCID lcid, DISPID *rgDispId)
{
struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
- FIXME("(%p)->(%s %p %d %d %p): stub\n", This, debugstr_guid(riid), rgszNames, cNames,
+ ITypeInfo *typeinfo;
+ HRESULT hr;
+
+ TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
lcid, rgDispId);
- return E_NOTIMPL;
+
+ if(!rgszNames || cNames == 0 || !rgDispId)
+ return E_INVALIDARG;
+
+ hr = get_typeinfo(IWebBrowser2_tid, &typeinfo);
+ if (SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
+ ITypeInfo_Release(typeinfo);
+ }
+
+ return hr;
}
static HRESULT WINAPI webbrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS *pDispParams, VARIANT *pVarResult,
- EXCEPINFO *pExepInfo, UINT *puArgErr)
+ EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
- FIXME("(%p)->(%d %s %d %08x %p %p %p %p): stub\n", This, dispIdMember, debugstr_guid(riid),
- lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
- return E_NOTIMPL;
+ ITypeInfo *typeinfo;
+ HRESULT hr;
+
+ TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
+ lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+
+ hr = get_typeinfo(IWebBrowser2_tid, &typeinfo);
+ if (SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags,
+ pDispParams, pVarResult, pExcepInfo, puArgErr);
+ ITypeInfo_Release(typeinfo);
+ }
+
+ return hr;
}
/* IWebBrowser methods */
More information about the wine-cvs
mailing list