Module: wine Branch: master Commit: 0ba11e8970697ff32684fcc716565dd395d7c5ee URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ba11e8970697ff32684fcc716...
Author: Vincent Povirk vincent@codeweavers.com Date: Tue May 22 15:34:25 2012 -0500
propsys: Implement IPropertyStore::GetAt.
---
dlls/propsys/propstore.c | 47 ++++++++++++++++++++++++++++++++++++++- dlls/propsys/tests/propstore.c | 8 +++--- 2 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/dlls/propsys/propstore.c b/dlls/propsys/propstore.c index b89eb76..a57bb2e 100644 --- a/dlls/propsys/propstore.c +++ b/dlls/propsys/propstore.c @@ -156,8 +156,51 @@ static HRESULT WINAPI PropertyStore_GetCount(IPropertyStoreCache *iface, static HRESULT WINAPI PropertyStore_GetAt(IPropertyStoreCache *iface, DWORD iProp, PROPERTYKEY *pkey) { - FIXME("%p,%d,%p: stub\n", iface, iProp, pkey); - return E_NOTIMPL; + PropertyStore *This = impl_from_IPropertyStoreCache(iface); + propstore_format *format=NULL, *format_candidate; + propstore_value *value; + HRESULT hr; + + TRACE("%p,%d,%p\n", iface, iProp, pkey); + + if (!pkey) + return E_POINTER; + + EnterCriticalSection(&This->lock); + + LIST_FOR_EACH_ENTRY(format_candidate, &This->formats, propstore_format, entry) + { + if (format_candidate->count > iProp) + { + format = format_candidate; + pkey->fmtid = format->fmtid; + break; + } + + iProp -= format_candidate->count; + } + + if (format) + { + LIST_FOR_EACH_ENTRY(value, &format->values, propstore_value, entry) + { + if (iProp == 0) + { + pkey->pid = value->pid; + break; + } + + iProp--; + } + + hr = S_OK; + } + else + hr = E_INVALIDARG; + + LeaveCriticalSection(&This->lock); + + return hr; }
static HRESULT PropertyStore_LookupValue(PropertyStore *This, REFPROPERTYKEY key, diff --git a/dlls/propsys/tests/propstore.c b/dlls/propsys/tests/propstore.c index 6ca67e9..7915b96 100644 --- a/dlls/propsys/tests/propstore.c +++ b/dlls/propsys/tests/propstore.c @@ -68,7 +68,7 @@ static void test_inmemorystore(void) ok(hr == S_OK, "Commit failed, hr=%x\n", hr);
hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey); - todo_wine ok(hr == E_INVALIDARG, "GetAt failed, hr=%x\n", hr); + ok(hr == E_INVALIDARG, "GetAt failed, hr=%x\n", hr);
pkey.fmtid = PKEY_WineTest; pkey.pid = 4; @@ -97,9 +97,9 @@ static void test_inmemorystore(void) memset(&pkey, 0, sizeof(pkey));
hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey); - todo_wine ok(hr == S_OK, "GetAt failed, hr=%x\n", hr); - todo_wine ok(IsEqualGUID(&pkey.fmtid, &PKEY_WineTest), "got wrong pkey\n"); - todo_wine ok(pkey.pid == 4, "got pid of %i, expected 4\n", pkey.pid); + ok(hr == S_OK, "GetAt failed, hr=%x\n", hr); + ok(IsEqualGUID(&pkey.fmtid, &PKEY_WineTest), "got wrong pkey\n"); + ok(pkey.pid == 4, "got pid of %i, expected 4\n", pkey.pid);
pkey.fmtid = PKEY_WineTest; pkey.pid = 4;