From ba40bbfcbf41d1e7f96e96493334f7ba75a696c5 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 25 Mar 2013 17:44:31 +0400 Subject: [PATCH] hlink: Implement IHlinkBrowseContext_GetHlink(). --- dlls/hlink/browse_ctx.c | 41 +++++++++++++++++++++++++++-------- dlls/hlink/tests/browse_ctx.c | 7 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/dlls/hlink/browse_ctx.c b/dlls/hlink/browse_ctx.c index 0bfc0610615..48a20cb1ce9 100644 --- a/dlls/hlink/browse_ctx.c +++ b/dlls/hlink/browse_ctx.c @@ -234,20 +234,43 @@ static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface, return E_NOTIMPL; } -static HRESULT WINAPI IHlinkBC_GetHlink( IHlinkBrowseContext* iface, - ULONG uHLID, IHlink** ppihl) +static HRESULT WINAPI IHlinkBC_GetHlink(IHlinkBrowseContext* iface, ULONG hlid, IHlink **ret) { - HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface); + HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface); + struct link_entry *link; + struct list *entry; - TRACE("(%p)->(%x %p)\n", This, uHLID, ppihl); + TRACE("(%p)->(0x%x %p)\n", This, hlid, ret); - if(uHLID != HLID_CURRENT) { - FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID); - return E_NOTIMPL; + switch (hlid) + { + case HLID_PREVIOUS: + entry = list_prev(&This->links, &This->current->entry); + break; + case HLID_NEXT: + entry = list_next(&This->links, &This->current->entry); + break; + case HLID_CURRENT: + entry = &This->current->entry; + break; + case HLID_STACKBOTTOM: + entry = list_tail(&This->links); + break; + case HLID_STACKTOP: + entry = list_head(&This->links); + break; + default: + WARN("unknown id 0x%x\n", hlid); + entry = NULL; } - *ppihl = This->current->link; - IHlink_AddRef(*ppihl); + if (!entry) + return E_FAIL; + + link = LIST_ENTRY(entry, struct link_entry, entry); + + *ret = link->link; + IHlink_AddRef(*ret); return S_OK; } diff --git a/dlls/hlink/tests/browse_ctx.c b/dlls/hlink/tests/browse_ctx.c index df801ab44a4..40d132b4c8a 100644 --- a/dlls/hlink/tests/browse_ctx.c +++ b/dlls/hlink/tests/browse_ctx.c @@ -56,6 +56,13 @@ static void test_SetInitialHlink(void) hres = IHlinkBrowseContext_SetInitialHlink(bc, dummy, five, NULL); ok(hres == CO_E_ALREADYINITIALIZED, "got 0x%08x\n", hres); + /* there's only one */ + hres = IHlinkBrowseContext_GetHlink(bc, HLID_PREVIOUS, &found_hlink); + ok(hres == E_FAIL, "got 0x%08x\n", hres); + + hres = IHlinkBrowseContext_GetHlink(bc, HLID_NEXT, &found_hlink); + ok(hres == E_FAIL, "got 0x%08x\n", hres); + hres = IHlinkBrowseContext_GetHlink(bc, HLID_CURRENT, &found_hlink); ok(hres == S_OK, "GetHlink failed: 0x%08x\n", hres);