Module: wine Branch: master Commit: a4b5ccfc29a12a6217645095c9c34231e983bb9c URL: http://source.winehq.org/git/wine.git/?a=commit;h=a4b5ccfc29a12a6217645095c9...
Author: Andrew Eikum aeikum@codeweavers.com Date: Tue Oct 20 16:33:27 2009 -0500
hlink: Use HLINKSETF flags in Hlink::fnSetMonikerReference.
---
dlls/hlink/hlink_main.c | 4 +- dlls/hlink/link.c | 37 +++++++++++------- dlls/hlink/tests/hlink.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/navigate.c | 2 +- 4 files changed, 124 insertions(+), 17 deletions(-)
diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c index 213506e..0e2ce90 100644 --- a/dlls/hlink/hlink_main.c +++ b/dlls/hlink/hlink_main.c @@ -84,7 +84,7 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation, if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData); if (pimkTrgt) - IHlink_SetMonikerReference(hl, 0, pimkTrgt, pwzLocation); + IHlink_SetMonikerReference(hl, HLINKSETF_LOCATION | HLINKSETF_TARGET, pimkTrgt, pwzLocation);
*ppvObj = hl;
@@ -140,7 +140,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, return r; }
- IHlink_SetMonikerReference(hl, 0, pTgtMk, pwzLocation); + IHlink_SetMonikerReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION, pTgtMk, pwzLocation); IMoniker_Release(pTgtMk);
IHlink_SetStringReference(hl, HLINKSETF_TARGET, pwzTarget, NULL); diff --git a/dlls/hlink/link.c b/dlls/hlink/link.c index 689317d..30530ca 100644 --- a/dlls/hlink/link.c +++ b/dlls/hlink/link.c @@ -206,24 +206,33 @@ static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface, { HlinkImpl *This = (HlinkImpl*)iface;
- FIXME("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, + TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, debugstr_w(pwzLocation));
- if (This->Moniker) - IMoniker_Release(This->Moniker); + if(rfHLSETF == 0) + return E_INVALIDARG; + if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION))) + return rfHLSETF;
- This->Moniker = pmkTarget; - if (This->Moniker) - { - LPOLESTR display_name; - IMoniker_AddRef(This->Moniker); - IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name); - This->absolute = display_name && strchrW(display_name, ':'); - CoTaskMemFree(display_name); + if(rfHLSETF & HLINKSETF_TARGET){ + if (This->Moniker) + IMoniker_Release(This->Moniker); + + This->Moniker = pmkTarget; + if (This->Moniker) + { + LPOLESTR display_name; + IMoniker_AddRef(This->Moniker); + IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name); + This->absolute = display_name && strchrW(display_name, ':'); + CoTaskMemFree(display_name); + } }
- heap_free(This->Location); - This->Location = hlink_strdupW( pwzLocation ); + if(rfHLSETF & HLINKSETF_LOCATION){ + heap_free(This->Location); + This->Location = hlink_strdupW( pwzLocation ); + }
return S_OK; } diff --git a/dlls/hlink/tests/hlink.c b/dlls/hlink/tests/hlink.c index 9e920d9..cea70b5 100644 --- a/dlls/hlink/tests/hlink.c +++ b/dlls/hlink/tests/hlink.c @@ -1016,6 +1016,103 @@ static void test_HlinkResolveMonikerForData(void) IBindCtx_Release(bctx); }
+static void test_HlinkGetSetMonikerReference(void) +{ + IMoniker *found_trgt, *dummy, *dummy2; + IHlink *hlink; + HRESULT hres; + const WCHAR one[] = {'1',0}; + const WCHAR two[] = {'2',0}; + const WCHAR name[] = {'a',0}; + WCHAR *found_loc; + + /* create two dummy monikers to use as targets */ + hres = CreateItemMoniker(one, one, &dummy); + ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres); + + hres = CreateItemMoniker(two, two, &dummy2); + ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres); + + /* create a new hlink: target => dummy, location => one */ + hres = HlinkCreateFromMoniker(dummy, one, name, NULL, 0, NULL, &IID_IHlink, (void**)&hlink); + ok(hres == S_OK, "HlinkCreateFromMoniker failed: 0x%08x\n", hres); + + /* validate the target and location */ + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(hres == S_OK, "IHlink_GetMonikerReference failed: 0x%08x\n", hres); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* set location => two */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_LOCATION, dummy2, two); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, two) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* set target => dummy2 */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET, dummy2, one); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy2, "Found target should've been %p, was: %p\n", dummy2, found_trgt); + ok(lstrcmpW(found_loc, two) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* set target => dummy, location => one */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, dummy, one); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* no HLINKSETF flags */ + hres = IHlink_SetMonikerReference(hlink, 0, dummy2, two); + ok(hres == E_INVALIDARG, "IHlink_SetMonikerReference should've failed with E_INVALIDARG (0x%08x), failed with 0x%08x\n", E_INVALIDARG, hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* invalid HLINKSETF flags */ + hres = IHlink_SetMonikerReference(hlink, 12, dummy2, two); + ok(hres == 12, "IHlink_SetMonikerReference should've failed with 0x%08x, failed with 0x%08x\n", 12, hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* valid & invalid HLINKSETF flags */ + hres = IHlink_SetMonikerReference(hlink, 12 | HLINKSETF_TARGET, dummy2, two); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy2, "Found target should've been %p, was: %p\n", dummy2, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + + /* NULL args */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, NULL, NULL); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == NULL, "Found target should've been %p, was: %p\n", NULL, found_trgt); + ok(found_loc == NULL, "Found location should've been %s, was: %s\n", wine_dbgstr_w(NULL), wine_dbgstr_w(found_loc)); + if(found_trgt) + IMoniker_Release(found_trgt); + + IHlink_Release(hlink); + IMoniker_Release(dummy2); + IMoniker_Release(dummy); +} + START_TEST(hlink) { CoInitialize(NULL); @@ -1027,6 +1124,7 @@ START_TEST(hlink) test_HlinkCreateExtensionServices(); test_HlinkParseDisplayName(); test_HlinkResolveMonikerForData(); + test_HlinkGetSetMonikerReference();
CoUninitialize(); } diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index 92d95fc..951b04d 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -1202,7 +1202,7 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, hres = CreateURLMoniker(NULL, url, &mon);
if(SUCCEEDED(hres)) { - IHlink_SetMonikerReference(hlink, 0, mon, NULL); + IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET, mon, NULL);
if(hlnf & HLNF_OPENINNEWWINDOW) { static const WCHAR wszBlank[] = {'_','b','l','a','n','k',0};