Commit d8fcf75d authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

propsys: Add stub InMemoryPropertyStore implementation.

parent f37bbdc1
MODULE = propsys.dll
IMPORTLIB = propsys
IMPORTS = ole32 oleaut32
IMPORTS = ole32 oleaut32 uuid
C_SRCS = \
propstore.c \
propsys_main.c \
propvar.c
......
/*
* standard IPropertyStore implementation
*
* Copyright 2012 Vincent Povirk for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "rpcproxy.h"
#include "propsys.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "propsys_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(propsys);
typedef struct {
IPropertyStoreCache IPropertyStoreCache_iface;
LONG ref;
} PropertyStore;
static inline PropertyStore *impl_from_IPropertyStoreCache(IPropertyStoreCache *iface)
{
return CONTAINING_RECORD(iface, PropertyStore, IPropertyStoreCache_iface);
}
static HRESULT WINAPI PropertyStore_QueryInterface(IPropertyStoreCache *iface, REFIID iid,
void **ppv)
{
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IPropertyStore, iid) ||
IsEqualIID(&IID_IPropertyStoreCache, iid))
{
*ppv = &This->IPropertyStoreCache_iface;
}
else
{
FIXME("No interface for %s\n", debugstr_guid(iid));
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI PropertyStore_AddRef(IPropertyStoreCache *iface)
{
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI PropertyStore_Release(IPropertyStoreCache *iface)
{
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
static HRESULT WINAPI PropertyStore_GetCount(IPropertyStoreCache *iface,
DWORD *cProps)
{
FIXME("%p,%p: stub\n", iface, cProps);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_GetAt(IPropertyStoreCache *iface,
DWORD iProp, PROPERTYKEY *pkey)
{
FIXME("%p,%d,%p: stub\n", iface, iProp, pkey);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_GetValue(IPropertyStoreCache *iface,
REFPROPERTYKEY key, PROPVARIANT *pv)
{
FIXME("%p,%p,%p: stub\n", iface, key, pv);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_SetValue(IPropertyStoreCache *iface,
REFPROPERTYKEY key, REFPROPVARIANT propvar)
{
FIXME("%p,%p,%p: stub\n", iface, key, propvar);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_Commit(IPropertyStoreCache *iface)
{
FIXME("%p: stub\n", iface);
return S_OK;
}
static HRESULT WINAPI PropertyStore_GetState(IPropertyStoreCache *iface,
REFPROPERTYKEY key, PSC_STATE *pstate)
{
FIXME("%p,%p,%p: stub\n", iface, key, pstate);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_GetValueAndState(IPropertyStoreCache *iface,
REFPROPERTYKEY key, PROPVARIANT *ppropvar, PSC_STATE *pstate)
{
FIXME("%p,%p,%p,%p: stub\n", iface, key, ppropvar, pstate);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_SetState(IPropertyStoreCache *iface,
REFPROPERTYKEY key, PSC_STATE pstate)
{
FIXME("%p,%p,%d: stub\n", iface, key, pstate);
return E_NOTIMPL;
}
static HRESULT WINAPI PropertyStore_SetValueAndState(IPropertyStoreCache *iface,
REFPROPERTYKEY key, const PROPVARIANT *ppropvar, PSC_STATE state)
{
FIXME("%p,%p,%p,%d: stub\n", iface, key, ppropvar, state);
return E_NOTIMPL;
}
static const IPropertyStoreCacheVtbl PropertyStore_Vtbl = {
PropertyStore_QueryInterface,
PropertyStore_AddRef,
PropertyStore_Release,
PropertyStore_GetCount,
PropertyStore_GetAt,
PropertyStore_GetValue,
PropertyStore_SetValue,
PropertyStore_Commit,
PropertyStore_GetState,
PropertyStore_GetValueAndState,
PropertyStore_SetState,
PropertyStore_SetValueAndState
};
HRESULT PropertyStore_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
{
PropertyStore *This;
HRESULT ret;
TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
*ppv = NULL;
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(PropertyStore));
if (!This) return E_OUTOFMEMORY;
This->IPropertyStoreCache_iface.lpVtbl = &PropertyStore_Vtbl;
This->ref = 1;
ret = IPropertyStoreCache_QueryInterface(&This->IPropertyStoreCache_iface, iid, ppv);
IPropertyStoreCache_Release(&This->IPropertyStoreCache_iface);
return ret;
}
......@@ -23,8 +23,8 @@
@ stub ClearPropVariantArray
@ stub ClearVariantArray
@ stub DllCanUnloadNow
@ stub DllGetClassObject
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
@ stub InitPropVariantFromBooleanVector
......
......@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "config.h"
#include <stdarg.h>
......@@ -31,6 +32,8 @@
#include "wine/debug.h"
#include "wine/unicode.h"
#include "propsys_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(propsys);
static HINSTANCE propsys_hInstance;
......@@ -66,6 +69,80 @@ HRESULT WINAPI DllUnregisterServer(void)
return __wine_unregister_resources( propsys_hInstance );
}
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
*ppv = iface;
}else if(IsEqualGUID(&IID_IClassFactory, riid)) {
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
*ppv = iface;
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
}
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
{
TRACE("(%p)\n", iface);
return 2;
}
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
{
TRACE("(%p)\n", iface);
return 1;
}
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
{
TRACE("(%p)->(%x)\n", iface, fLock);
return S_OK;
}
static HRESULT WINAPI InMemoryPropertyStoreFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
REFIID riid, void **ppv)
{
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
return PropertyStore_CreateInstance(outer, riid, ppv);
}
static const IClassFactoryVtbl InMemoryPropertyStoreFactoryVtbl = {
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
InMemoryPropertyStoreFactory_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory InMemoryPropertyStoreFactory = { &InMemoryPropertyStoreFactoryVtbl };
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
if(IsEqualGUID(&CLSID_InMemoryPropertyStore, rclsid)) {
TRACE("(CLSID_InMemoryPropertyStore %s %p)\n", debugstr_guid(riid), ppv);
return IClassFactory_QueryInterface(&InMemoryPropertyStoreFactory, riid, ppv);
}
FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
HRESULT WINAPI DllCanUnloadNow(void)
{
return S_FALSE;
}
HRESULT WINAPI PSRegisterPropertySchema(PCWSTR path)
{
FIXME("%s stub\n", debugstr_w(path));
......
/*
* propsys private definitions
*
* Copyright 2012 Vincent Povirk for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
HRESULT PropertyStore_CreateInstance(IUnknown *outer, REFIID riid, void **ppv) DECLSPEC_HIDDEN;
......@@ -46,7 +46,7 @@ static void test_inmemorystore(void)
hr = CoCreateInstance(&CLSID_InMemoryPropertyStore, NULL, CLSCTX_INPROC_SERVER,
&IID_IPropertyStoreCache, (void**)&propcache);
todo_wine ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
if (FAILED(hr))
{
......@@ -55,11 +55,11 @@ static void test_inmemorystore(void)
}
hr = IPropertyStoreCache_GetCount(propcache, NULL);
ok(hr == E_POINTER, "GetCount failed, hr=%x\n", hr);
todo_wine ok(hr == E_POINTER, "GetCount failed, hr=%x\n", hr);
hr = IPropertyStoreCache_GetCount(propcache, &count);
ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
ok(count == 0, "GetCount returned %i, expected 0\n", count);
todo_wine ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
todo_wine ok(count == 0, "GetCount returned %i, expected 0\n", count);
hr = IPropertyStoreCache_Commit(propcache);
ok(hr == S_OK, "Commit failed, hr=%x\n", hr);
......@@ -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);
ok(hr == E_INVALIDARG, "GetAt failed, hr=%x\n", hr);
todo_wine ok(hr == E_INVALIDARG, "GetAt failed, hr=%x\n", hr);
pkey.fmtid = PKEY_WineTest;
pkey.pid = 4;
......@@ -88,18 +88,18 @@ static void test_inmemorystore(void)
}
hr = IPropertyStoreCache_SetValue(propcache, &pkey, &propvar);
ok(hr == S_OK, "SetValue failed, hr=%x\n", hr);
todo_wine ok(hr == S_OK, "SetValue failed, hr=%x\n", hr);
hr = IPropertyStoreCache_GetCount(propcache, &count);
ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
ok(count == 1, "GetCount returned %i, expected 0\n", count);
todo_wine ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
todo_wine ok(count == 1, "GetCount returned %i, expected 0\n", count);
memset(&pkey, 0, sizeof(pkey));
hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey);
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);
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);
pkey.fmtid = PKEY_WineTest;
pkey.pid = 4;
......@@ -114,12 +114,12 @@ static void test_inmemorystore(void)
}
hr = IPropertyStoreCache_GetValue(propcache, &pkey, NULL);
ok(hr == E_POINTER, "GetValue failed, hr=%x\n", hr);
todo_wine ok(hr == E_POINTER, "GetValue failed, hr=%x\n", hr);
hr = IPropertyStoreCache_GetValue(propcache, &pkey, &propvar);
ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
ok(propvar.u.lVal == 12345, "expected 12345, got %d\n", propvar.u.lVal);
todo_wine ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
todo_wine ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
todo_wine ok(propvar.u.lVal == 12345, "expected 12345, got %d\n", propvar.u.lVal);
pkey.fmtid = PKEY_WineTest;
pkey.pid = 10;
......@@ -127,24 +127,24 @@ static void test_inmemorystore(void)
/* Get information for field that isn't set yet */
propvar.vt = VT_I2;
hr = IPropertyStoreCache_GetValue(propcache, &pkey, &propvar);
ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
ok(propvar.vt == VT_EMPTY, "expected VT_EMPTY, got %d\n", propvar.vt);
todo_wine ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
todo_wine ok(propvar.vt == VT_EMPTY, "expected VT_EMPTY, got %d\n", propvar.vt);
state = 0xdeadbeef;
hr = IPropertyStoreCache_GetState(propcache, &pkey, &state);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetState failed, hr=%x\n", hr);
ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
todo_wine ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetState failed, hr=%x\n", hr);
todo_wine ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
propvar.vt = VT_I2;
state = 0xdeadbeef;
hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &state);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetValueAndState failed, hr=%x\n", hr);
ok(propvar.vt == VT_EMPTY, "expected VT_EMPTY, got %d\n", propvar.vt);
ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
todo_wine ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetValueAndState failed, hr=%x\n", hr);
todo_wine ok(propvar.vt == VT_EMPTY, "expected VT_EMPTY, got %d\n", propvar.vt);
todo_wine ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
/* Set state on an unset field */
hr = IPropertyStoreCache_SetState(propcache, &pkey, PSC_NORMAL);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "SetState failed, hr=%x\n", hr);
todo_wine ok(hr == TYPE_E_ELEMENTNOTFOUND, "SetState failed, hr=%x\n", hr);
/* Manipulate state on already set field */
pkey.fmtid = PKEY_WineTest;
......@@ -152,29 +152,29 @@ static void test_inmemorystore(void)
state = 0xdeadbeef;
hr = IPropertyStoreCache_GetState(propcache, &pkey, &state);
ok(hr == S_OK, "GetState failed, hr=%x\n", hr);
ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
todo_wine ok(hr == S_OK, "GetState failed, hr=%x\n", hr);
todo_wine ok(state == PSC_NORMAL, "expected PSC_NORMAL, got %d\n", state);
hr = IPropertyStoreCache_SetState(propcache, &pkey, 10);
ok(hr == S_OK, "SetState failed, hr=%x\n", hr);
todo_wine ok(hr == S_OK, "SetState failed, hr=%x\n", hr);
state = 0xdeadbeef;
hr = IPropertyStoreCache_GetState(propcache, &pkey, &state);
ok(hr == S_OK, "GetState failed, hr=%x\n", hr);
ok(state == 10, "expected 10, got %d\n", state);
todo_wine ok(hr == S_OK, "GetState failed, hr=%x\n", hr);
todo_wine ok(state == 10, "expected 10, got %d\n", state);
propvar.vt = VT_I4;
propvar.u.lVal = 12346;
hr = IPropertyStoreCache_SetValueAndState(propcache, &pkey, &propvar, 5);
ok(hr == S_OK, "SetValueAndState failed, hr=%x\n", hr);
todo_wine ok(hr == S_OK, "SetValueAndState failed, hr=%x\n", hr);
memset(&propvar, 0, sizeof(propvar));
state = 0xdeadbeef;
hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &state);
ok(hr == S_OK, "GetValueAndState failed, hr=%x\n", hr);
ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
ok(propvar.u.lVal == 12346, "expected 12346, got %d\n", propvar.vt);
ok(state == 5, "expected 5, got %d\n", state);
todo_wine ok(hr == S_OK, "GetValueAndState failed, hr=%x\n", hr);
todo_wine ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
todo_wine ok(propvar.u.lVal == 12346, "expected 12346, got %d\n", propvar.vt);
todo_wine ok(state == 5, "expected 5, got %d\n", state);
/* Set new field with state */
pkey.fmtid = PKEY_WineTest;
......@@ -183,15 +183,15 @@ static void test_inmemorystore(void)
propvar.vt = VT_I4;
propvar.u.lVal = 12347;
hr = IPropertyStoreCache_SetValueAndState(propcache, &pkey, &propvar, PSC_DIRTY);
ok(hr == S_OK, "SetValueAndState failed, hr=%x\n", hr);
todo_wine ok(hr == S_OK, "SetValueAndState failed, hr=%x\n", hr);
memset(&propvar, 0, sizeof(propvar));
state = 0xdeadbeef;
hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &state);
ok(hr == S_OK, "GetValueAndState failed, hr=%x\n", hr);
ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
ok(propvar.u.lVal == 12347, "expected 12347, got %d\n", propvar.vt);
ok(state == PSC_DIRTY, "expected PSC_DIRTY, got %d\n", state);
todo_wine ok(hr == S_OK, "GetValueAndState failed, hr=%x\n", hr);
todo_wine ok(propvar.vt == VT_I4, "expected VT_I4, got %d\n", propvar.vt);
todo_wine ok(propvar.u.lVal == 12347, "expected 12347, got %d\n", propvar.vt);
todo_wine ok(state == PSC_DIRTY, "expected PSC_DIRTY, got %d\n", state);
IPropertyStoreCache_Release(propcache);
}
......
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