Commit 00aca147 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

hlink: Better handle the IBrowseContext parameter in IHlink::Navigate().

Query it for an IHlinkTarget object. Also, use ShellExecute() only if the parameter is NULL. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 46aba956
...@@ -486,26 +486,34 @@ static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc, ...@@ -486,26 +486,34 @@ static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc,
if (SUCCEEDED(r)) if (SUCCEEDED(r))
{ {
IBindCtx *bcxt; IBindCtx *bcxt = NULL;
IUnknown *unk = NULL; IUnknown *unk = NULL;
IHlinkTarget *target; IHlinkTarget *target;
if (phbc)
{
r = IHlinkBrowseContext_GetObject(phbc, mon, TRUE, &unk);
if (r == S_FALSE)
{
CreateBindCtx(0, &bcxt); CreateBindCtx(0, &bcxt);
RegisterBindStatusCallback(bcxt, pbsc, NULL, 0); RegisterBindStatusCallback(bcxt, pbsc, NULL, 0);
r = IMoniker_BindToObject(mon, bcxt, NULL, &IID_IUnknown, (void**)&unk); r = IMoniker_BindToObject(mon, bcxt, NULL, &IID_IUnknown, (void**)&unk);
}
if (r == S_OK) if (r == S_OK)
{ {
r = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&target); r = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void **)&target);
IUnknown_Release(unk); IUnknown_Release(unk);
} }
if (r == S_OK) if (r == S_OK)
{ {
IHlinkTarget_SetBrowseContext(target, phbc); if (bcxt) IHlinkTarget_SetBrowseContext(target, phbc);
r = IHlinkTarget_Navigate(target, grfHLNF, This->Location); r = IHlinkTarget_Navigate(target, grfHLNF, This->Location);
IHlinkTarget_Release(target); IHlinkTarget_Release(target);
} }
RevokeBindStatusCallback(bcxt, pbsc);
if (bcxt) IBindCtx_Release(bcxt);
}
else else
{ {
static const WCHAR szOpen[] = {'o','p','e','n',0}; static const WCHAR szOpen[] = {'o','p','e','n',0};
...@@ -516,12 +524,9 @@ static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc, ...@@ -516,12 +524,9 @@ static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc,
{ {
ShellExecuteW(NULL, szOpen, target, NULL, NULL, SW_SHOW); ShellExecuteW(NULL, szOpen, target, NULL, NULL, SW_SHOW);
CoTaskMemFree(target); CoTaskMemFree(target);
r = DRAGDROP_S_DROP;
} }
} }
RevokeBindStatusCallback(bcxt, pbsc);
IBindCtx_Release(bcxt);
IMoniker_Release(mon); IMoniker_Release(mon);
} }
......
...@@ -73,6 +73,7 @@ DEFINE_EXPECT(HBC_QueryInterface_IUnknown); ...@@ -73,6 +73,7 @@ DEFINE_EXPECT(HBC_QueryInterface_IUnknown);
DEFINE_EXPECT(HBC_GetObject); DEFINE_EXPECT(HBC_GetObject);
DEFINE_EXPECT(HBC_UpdateHlink); DEFINE_EXPECT(HBC_UpdateHlink);
DEFINE_EXPECT(HT_QueryInterface_IHlinkTarget);
DEFINE_EXPECT(HT_SetBrowseContext); DEFINE_EXPECT(HT_SetBrowseContext);
DEFINE_EXPECT(HT_GetBrowseContext); DEFINE_EXPECT(HT_GetBrowseContext);
DEFINE_EXPECT(HT_Navigate); DEFINE_EXPECT(HT_Navigate);
...@@ -868,6 +869,8 @@ static HRESULT WINAPI HlinkBrowseContext_Register(IHlinkBrowseContext *iface, ...@@ -868,6 +869,8 @@ static HRESULT WINAPI HlinkBrowseContext_Register(IHlinkBrowseContext *iface,
return E_NOTIMPL; return E_NOTIMPL;
} }
static IUnknown *HBC_object;
static IMoniker Moniker; static IMoniker Moniker;
static HRESULT WINAPI HlinkBrowseContext_GetObject(IHlinkBrowseContext *iface, static HRESULT WINAPI HlinkBrowseContext_GetObject(IHlinkBrowseContext *iface,
IMoniker *pimk, BOOL fBindIfRootRegistered, IUnknown **ppiunk) IMoniker *pimk, BOOL fBindIfRootRegistered, IUnknown **ppiunk)
...@@ -884,8 +887,9 @@ static HRESULT WINAPI HlinkBrowseContext_GetObject(IHlinkBrowseContext *iface, ...@@ -884,8 +887,9 @@ static HRESULT WINAPI HlinkBrowseContext_GetObject(IHlinkBrowseContext *iface,
IBindCtx_Release(bctx); IBindCtx_Release(bctx);
ok(fBindIfRootRegistered == 1, "fBindIfRootRegistered = %x\n", fBindIfRootRegistered); ok(fBindIfRootRegistered == 1, "fBindIfRootRegistered = %x\n", fBindIfRootRegistered);
*ppiunk = NULL;
return S_FALSE; *ppiunk = HBC_object;
return HBC_object ? S_OK : S_FALSE;
} }
static HRESULT WINAPI HlinkBrowseContext_Revoke(IHlinkBrowseContext *iface, DWORD dwRegister) static HRESULT WINAPI HlinkBrowseContext_Revoke(IHlinkBrowseContext *iface, DWORD dwRegister)
...@@ -995,6 +999,7 @@ static IHlinkBrowseContext HlinkBrowseContext = { &HlinkBrowseContextVtbl }; ...@@ -995,6 +999,7 @@ static IHlinkBrowseContext HlinkBrowseContext = { &HlinkBrowseContextVtbl };
static HRESULT WINAPI HlinkTarget_QueryInterface(IHlinkTarget *iface, REFIID riid, void **ppv) static HRESULT WINAPI HlinkTarget_QueryInterface(IHlinkTarget *iface, REFIID riid, void **ppv)
{ {
if(IsEqualGUID(&IID_IHlinkTarget, riid)) { if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
CHECK_EXPECT(HT_QueryInterface_IHlinkTarget);
*ppv = iface; *ppv = iface;
return S_OK; return S_OK;
} }
...@@ -2188,6 +2193,8 @@ static void test_Hlink_Navigate(void) ...@@ -2188,6 +2193,8 @@ static void test_Hlink_Navigate(void)
ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres); ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
_bctx = pbc; _bctx = pbc;
HBC_object = NULL;
SET_EXPECT(Reduce); SET_EXPECT(Reduce);
SET_EXPECT(Enum); SET_EXPECT(Enum);
SET_EXPECT(IsSystemMoniker); SET_EXPECT(IsSystemMoniker);
...@@ -2205,6 +2212,7 @@ static void test_Hlink_Navigate(void) ...@@ -2205,6 +2212,7 @@ static void test_Hlink_Navigate(void)
SET_EXPECT(HBC_GetObject); SET_EXPECT(HBC_GetObject);
SET_EXPECT(Reduce); SET_EXPECT(Reduce);
SET_EXPECT(BindToObject); SET_EXPECT(BindToObject);
SET_EXPECT(HT_QueryInterface_IHlinkTarget);
SET_EXPECT(HT_GetBrowseContext); SET_EXPECT(HT_GetBrowseContext);
SET_EXPECT(HT_SetBrowseContext); SET_EXPECT(HT_SetBrowseContext);
SET_EXPECT(HBC_QueryInterface_IHlinkHistory); SET_EXPECT(HBC_QueryInterface_IHlinkHistory);
...@@ -2213,36 +2221,65 @@ static void test_Hlink_Navigate(void) ...@@ -2213,36 +2221,65 @@ static void test_Hlink_Navigate(void)
hres = IHlink_Navigate(hlink, 0, pbc, NULL, &HlinkBrowseContext); hres = IHlink_Navigate(hlink, 0, pbc, NULL, &HlinkBrowseContext);
ok(hres == S_OK, "Navigate failed: %08x\n", hres); ok(hres == S_OK, "Navigate failed: %08x\n", hres);
CHECK_CALLED(IsSystemMoniker); CHECK_CALLED(IsSystemMoniker);
todo_wine CHECK_CALLED(GetDisplayName); CHECK_CALLED(GetDisplayName);
todo_wine CHECK_CALLED(HBC_GetObject); CHECK_CALLED(HBC_GetObject);
todo_wine CHECK_CALLED(Reduce); todo_wine CHECK_CALLED(Reduce);
CHECK_CALLED(BindToObject); CHECK_CALLED(BindToObject);
CHECK_CALLED(HT_QueryInterface_IHlinkTarget);
todo_wine CHECK_CALLED(HT_GetBrowseContext); todo_wine CHECK_CALLED(HT_GetBrowseContext);
CHECK_CALLED(HT_SetBrowseContext); CHECK_CALLED(HT_SetBrowseContext);
todo_wine CHECK_CALLED(HBC_QueryInterface_IHlinkHistory); todo_wine CHECK_CALLED(HBC_QueryInterface_IHlinkHistory);
CHECK_CALLED(HT_Navigate); CHECK_CALLED(HT_Navigate);
todo_wine CHECK_CALLED(HT_GetFriendlyName); todo_wine CHECK_CALLED(HT_GetFriendlyName);
/* Test with valid return from HlinkBrowseContext::GetObject */
HBC_object = (IUnknown *)&HlinkTarget;
SET_EXPECT(IsSystemMoniker);
SET_EXPECT(GetDisplayName);
SET_EXPECT(HBC_GetObject);
SET_EXPECT(HT_QueryInterface_IHlinkTarget);
SET_EXPECT(HT_Navigate);
SET_EXPECT(HT_GetFriendlyName);
hres = IHlink_Navigate(hlink, 0, pbc, NULL, &HlinkBrowseContext);
ok(hres == S_OK, "Navigate failed: %08x\n", hres);
CHECK_CALLED(IsSystemMoniker);
CHECK_CALLED(GetDisplayName);
CHECK_CALLED(HBC_GetObject);
CHECK_CALLED(HT_QueryInterface_IHlinkTarget);
CHECK_CALLED(HT_Navigate);
todo_wine CHECK_CALLED(HT_GetFriendlyName);
HBC_object = NULL;
if (0) { /* these currently open a browser window on wine */ if (0) { /* these currently open a browser window on wine */
/* Test from string */ /* Test from string */
SET_EXPECT(HBC_GetObject); SET_EXPECT(HBC_GetObject);
hres = HlinkNavigateToStringReference(winehq_404W, NULL, NULL, 0, NULL, 0, pbc, NULL, &HlinkBrowseContext); hres = HlinkNavigateToStringReference(winehq_404W, NULL, NULL, 0, NULL, 0, pbc, NULL, &HlinkBrowseContext);
todo_wine ok(hres == INET_E_OBJECT_NOT_FOUND, "Expected INET_E_OBJECT_NOT_FOUND, got %08x\n", hres); todo_wine ok(hres == INET_E_OBJECT_NOT_FOUND, "Expected INET_E_OBJECT_NOT_FOUND, got %08x\n", hres);
todo_wine CHECK_CALLED(HBC_GetObject); CHECK_CALLED(HBC_GetObject);
/* MSDN claims browse context and bind context can't be null, but they can */ /* MSDN claims browse context and bind context can't be null, but they can */
SET_EXPECT(HBC_GetObject); SET_EXPECT(HBC_GetObject);
hres = HlinkNavigateToStringReference(winehq_404W, NULL, NULL, 0, NULL, 0, NULL, NULL, &HlinkBrowseContext); hres = HlinkNavigateToStringReference(winehq_404W, NULL, NULL, 0, NULL, 0, NULL, NULL, &HlinkBrowseContext);
todo_wine ok(hres == INET_E_OBJECT_NOT_FOUND, "Expected INET_E_OBJECT_NOT_FOUND, got %08x\n", hres); todo_wine ok(hres == INET_E_OBJECT_NOT_FOUND, "Expected INET_E_OBJECT_NOT_FOUND, got %08x\n", hres);
todo_wine CHECK_CALLED(HBC_GetObject); CHECK_CALLED(HBC_GetObject);
} }
/* these open a browser window, so mark them interactive only */ /* these open a browser window, so mark them interactive only */
if (winetest_interactive) if (winetest_interactive)
{ {
/* both parameters null */ /* both parameters null */
SET_EXPECT(IsSystemMoniker);
SET_EXPECT(GetDisplayName);
hres = IHlink_Navigate(hlink, 0, NULL, NULL, NULL);
ok(hres == DRAGDROP_S_DROP, "Expected DRAGDROP_S_DROP, got %08x\n", hres);
CHECK_CALLED(IsSystemMoniker);
CHECK_CALLED(GetDisplayName);
/* same, from string */
hres = HlinkNavigateToStringReference(winehq_404W, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL); hres = HlinkNavigateToStringReference(winehq_404W, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
todo_wine ok(hres == DRAGDROP_S_DROP, "Expected DRAGDROP_S_DROP, got %08x\n", hres); ok(hres == DRAGDROP_S_DROP, "Expected DRAGDROP_S_DROP, got %08x\n", hres);
/* try basic test with valid URL */ /* try basic test with valid URL */
SET_EXPECT(HBC_GetObject); SET_EXPECT(HBC_GetObject);
...@@ -2252,7 +2289,7 @@ if (0) { /* these currently open a browser window on wine */ ...@@ -2252,7 +2289,7 @@ if (0) { /* these currently open a browser window on wine */
SET_EXPECT(HBC_QueryInterface_IUnknown); SET_EXPECT(HBC_QueryInterface_IUnknown);
hres = HlinkNavigateToStringReference(winehq_urlW, NULL, NULL, 0, NULL, 0, pbc, NULL, &HlinkBrowseContext); hres = HlinkNavigateToStringReference(winehq_urlW, NULL, NULL, 0, NULL, 0, pbc, NULL, &HlinkBrowseContext);
ok(hres == S_OK, "Expected S_OK, got %08x\n", hres); ok(hres == S_OK, "Expected S_OK, got %08x\n", hres);
todo_wine CHECK_CALLED(HBC_GetObject); CHECK_CALLED(HBC_GetObject);
todo_wine CHECK_CALLED(HBC_QueryInterface_IHlinkHistory); todo_wine CHECK_CALLED(HBC_QueryInterface_IHlinkHistory);
todo_wine CHECK_CALLED(HBC_QueryInterface_IMarshal); todo_wine CHECK_CALLED(HBC_QueryInterface_IMarshal);
todo_wine CHECK_CALLED(HBC_QueryInterface_IdentityUnmarshal); todo_wine CHECK_CALLED(HBC_QueryInterface_IdentityUnmarshal);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment