mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 08:30:21 +00:00

[WINESYNC] propsys/tests: Merge test files. wine commit id d189b55d2ffb038474cb6656dc8743eb34c35a3d by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Add a semi-stub for PSCreatePropertyStoreFromObject(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47958 wine commit id acb2e4fc7a4242c74ac91657edb97bf1e402656a by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Allow only ASCII digits in PSPropertyKeyFromString. wine commit id 6e8c2d836e637e1fbd83c231cfd846ecb9333964 by Jacek Caban <jacek@codeweavers.com> [WINESYNC] propsys/tests: Get rid of strcmp_wa(). wine commit id 2340212ee9c48c731c85bbad8c81ed833458bf15 by Michael Stefaniuc <mstefani@winehq.org> [WINESYNC] propsys: Use wide-char string literals. wine commit id b72440fa2e1016681cbfcebcdc4792b6ced3eb53 by Michael Stefaniuc <mstefani@winehq.org> reduce wine diff and add stuff from previous commit [WINESYNC] propsys: Use --prefer_native instead of DLL_WINE_PREATTACH. wine commit id f99113192ffac37506a905827415d3d21d0ebbf8 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Use nameless unions. wine commit id 1d8e5079f0e53a767a783e5107f57f04c1897951 by Jacek Caban <jacek@codeweavers.com> [WINESYNC] propsys/tests: Use nameless unions. wine commit id 497de3cc19f971808ca4105f52038e61dc818db1 by Jacek Caban <jacek@codeweavers.com> [WINESYNC] winecrt0: Add a default implementation for DllCanUnloadNow(). wine commit id bd6b53740c28c6974300e15f965c12feb0252085 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] winecrt0: Add a default implementation DllRegisterServer()/DllUnregisterServer(). wine commit id 5d82baf9747b7b133cad3be77c0cc9e24cc09582 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Add support for VT_VECTOR|VT_UI1 type in PropVariantCompareEx(). wine commit id e91b05bb5be6fd70a767bea9991e818a49cc5547 by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Fix VT_UI4 comparison, use ulVal instead of uiVal. wine commit id 58eeb1a86433db1104d3a9ccf9ad7435ec81443a by Rémi Bernon <rbernon@codeweavers.com> [WINESYNC] propsys/tests: Add a VT_UI4 test for PropVariantCompareEx(). A test for 58eeb1a86433db1104d3a9ccf9ad7435ec81443a. wine commit id 10359e17ce64f39461a7b7b54f73857e6458d1fb by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys/tests: Avoid "misleading indentation" warnings. wine commit id 7cd6681b3be35cf6c02f056cb5131c90c0674c16 by Fabian Maurer <dark.shadow4@web.de> [WINESYNC] propsys: Enable compilation with long types. wine commit id a9c797e4538a37716e62bb81c3fed3de39561b41 by Eric Pouech <eric.pouech@gmail.com> [WINESYNC] propsys/tests: Enable compilation with long types. wine commit id c1c393595d43bd95390d3ddf86dcbc46bc4f52ba by Eric Pouech <eric.pouech@gmail.com> [WINESYNC] propsys: Implement InitVariantFromFileTime. wine commit id f2b8ccb7b0b22b7b5d661d908f8f8ee02f22647d by Daniel Lehman <dlehman@esri.com> [WINESYNC] propsys/tests: Add some InitVariantFromFileTime tests. wine commit id 083dea7fce4372840ac18176496a7d05dadd5ad8 by Daniel Lehman <dlehman@esri.com> [WINESYNC] propsys: Implement VariantToStringWithDefault. wine commit id bf0f1fdcf80657a42116b79a0953181191cf9221 by Mohamad Al-Jaf <mohamadaljaf@gmail.com> [WINESYNC] propsys/tests: Add VariantToStringWithDefault tests. wine commit id 89aba13dc381dbbda62d1019e1af2af5a589b0cf by Mohamad Al-Jaf <mohamadaljaf@gmail.com> [WINESYNC] include: Add Stg functions declaration in propvarutil.h. wine commit id 0d294ad26544913414277daa164004d731ae6e33 by Biswapriyo Nath <nathbappai@gmail.com> [WINESYNC] propsys: Add InitPropVariantFromStringVector(). wine commit id 3a1146d8e63d7ceff38441fee08f7f7080527020 by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] Remove unused NONAMELESS defines. wine commit id 20afe438320f77d103a96d1d8cd562d0899ebac7 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Partially implement VariantToString(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55708 wine commit id f7ef02bd8f74ea052d61e48cd84b226d8a5867a8 by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Handle VT_I4 type in VariantToString(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55708 wine commit id 001e0543bfd5aea060053af0c76233bb90fbb43b by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Implement PropVariantToUInt32WithDefault. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55713 wine commit id d177709b10ce07ddd234b0e8e00764ae4b1d8488 by Fabian Maurer <dark.shadow4@web.de> [WINESYNC] include: Use proper dllimports for propsys functions. wine commit id f0b2e0d00c86fb04d47467f39e49c587250ffec5 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Remove DECLSPEC_HIDDEN usage. wine commit id e9ff53e098ef3871d692c7b907151cfbb2f0673f by Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Update propsys_private.h [WINESYNC] propsys: Force debug info in critical sections. wine commit id 67bea281cc851eda6a08430c70f6c9e848d3fbe1 by Paul Gofman <pgofman@codeweavers.com> [WINESYNC] include: Fix typos in IID_IPropertyEnumType2 and CLSID_PropertySystem. wine commit id 66e6b61705a66459ed3a9e0cf9457d8b180e4564 by Alfred Agrell <floating@muncher.se> [WINESYNC] propsys: Add stubs for variant conversion functions. wine commit id c21f04f7adaa4a8d0ca2d2659bf9a6facdc168c3 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Add tests for VariantToPropVariant. wine commit id 8877889f2a8e36d22dcad061e6da84476efb3750 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Initially implement VariantToPropVariant. wine commit id 6985637ed59e81e7d1716095a343cc5681082306 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Add tests for PropVariantToVariant. wine commit id 3277de5572b7f6c41ebeeb89f781e378a6a2c2d3 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Test converting clsid to string. wine commit id 7a4f9f83c51883f41ae1363e27700452472ec18f by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Support converting clsid to string for PropVariant. wine commit id 67b097ff46c65d525de6a7f560f019de6828320c by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Initially implement PropVariantToVariant. wine commit id 808b398549350fffc9fc023d637ef8de9e4bba37 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Add PropVariantToBSTR stub. wine commit id 86558a4b83ebf9a0c6e76888a3d0f3fe3e36bf57 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Test PropVariantToBSTR. wine commit id b4ac03f1f622120906a8b6e691caa05f6539c2dd by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Test truncating for PropVariantToString. wine commit id df16802582a56f8076ebbcf9cb6178f65bb8b9b6 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Implement PropVariantToBSTR. wine commit id 66220be403ce5c3634c13da3546f0c19f04059cc by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Use debugstr_variant for the trace in VariantToPropVariant. wine commit id 3517aded4090229dbb11e413bde8349d1eca0be3 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Support converting to BSTR for PropVariantToVariant. wine commit id c33fdc27650045a754a05a8f25e250e6e72c8072 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Fix a test that fails on some Windows versions. wine commit id c09f828f43101cf2dfe11d7e13f1fc6ef4b19853 by Alexandre Julliard <julliard@winehq.org> [WINESYNC]: propsys is now in sync with wine-staging wine-10.0 Co-authored-by: winesync <ros-dev@reactos.org> [PROPSYS] Remove duplicate uuid [PROPSYS] Fix headers/idl file
495 lines
12 KiB
C
495 lines
12 KiB
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 <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
#include "winbase.h"
|
|
#include "objbase.h"
|
|
#include "rpcproxy.h"
|
|
#include "propsys.h"
|
|
#include "wine/debug.h"
|
|
#include "wine/list.h"
|
|
|
|
#include "initguid.h"
|
|
#include "propsys_private.h"
|
|
|
|
DEFINE_GUID(FMTID_NamedProperties, 0xd5cdd505, 0x2e9c, 0x101b, 0x93, 0x97, 0x08, 0x00, 0x2b, 0x2c, 0xf9, 0xae);
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(propsys);
|
|
|
|
typedef struct {
|
|
struct list entry;
|
|
DWORD pid;
|
|
PROPVARIANT propvar;
|
|
PSC_STATE state;
|
|
} propstore_value;
|
|
|
|
typedef struct {
|
|
struct list entry;
|
|
GUID fmtid;
|
|
struct list values; /* list of struct propstore_value */
|
|
DWORD count;
|
|
} propstore_format;
|
|
|
|
typedef struct {
|
|
IPropertyStoreCache IPropertyStoreCache_iface;
|
|
LONG ref;
|
|
CRITICAL_SECTION lock;
|
|
struct list formats; /* list of struct propstore_format */
|
|
} 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=%lu\n", iface, ref);
|
|
|
|
return ref;
|
|
}
|
|
|
|
static void destroy_format(propstore_format *format)
|
|
{
|
|
propstore_value *cursor, *cursor2;
|
|
LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &format->values, propstore_value, entry)
|
|
{
|
|
PropVariantClear(&cursor->propvar);
|
|
HeapFree(GetProcessHeap(), 0, cursor);
|
|
}
|
|
HeapFree(GetProcessHeap(), 0, format);
|
|
}
|
|
|
|
static ULONG WINAPI PropertyStore_Release(IPropertyStoreCache *iface)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
TRACE("(%p) refcount=%lu\n", iface, ref);
|
|
|
|
if (ref == 0)
|
|
{
|
|
propstore_format *cursor, *cursor2;
|
|
This->lock.DebugInfo->Spare[0] = 0;
|
|
DeleteCriticalSection(&This->lock);
|
|
LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->formats, propstore_format, entry)
|
|
destroy_format(cursor);
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
}
|
|
|
|
return ref;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_GetCount(IPropertyStoreCache *iface,
|
|
DWORD *cProps)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_format *format;
|
|
|
|
TRACE("%p,%p\n", iface, cProps);
|
|
|
|
if (!cProps)
|
|
return E_POINTER;
|
|
|
|
*cProps = 0;
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
LIST_FOR_EACH_ENTRY(format, &This->formats, propstore_format, entry)
|
|
*cProps += format->count;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_GetAt(IPropertyStoreCache *iface,
|
|
DWORD iProp, PROPERTYKEY *pkey)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_format *format=NULL, *format_candidate;
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
|
|
TRACE("%p,%ld,%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,
|
|
BOOL insert, propstore_value **result)
|
|
{
|
|
propstore_format *format=NULL, *format_candidate;
|
|
propstore_value *value=NULL, *value_candidate;
|
|
|
|
if (IsEqualGUID(&key->fmtid, &FMTID_NamedProperties))
|
|
{
|
|
/* This is used in the property store format [MS-PROPSTORE]
|
|
* for named values and probably gets special treatment. */
|
|
ERR("don't know how to handle FMTID_NamedProperties\n");
|
|
return E_FAIL;
|
|
}
|
|
|
|
LIST_FOR_EACH_ENTRY(format_candidate, &This->formats, propstore_format, entry)
|
|
{
|
|
if (IsEqualGUID(&format_candidate->fmtid, &key->fmtid))
|
|
{
|
|
format = format_candidate;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!format)
|
|
{
|
|
if (!insert)
|
|
return TYPE_E_ELEMENTNOTFOUND;
|
|
|
|
format = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*format));
|
|
if (!format)
|
|
return E_OUTOFMEMORY;
|
|
|
|
format->fmtid = key->fmtid;
|
|
list_init(&format->values);
|
|
list_add_tail(&This->formats, &format->entry);
|
|
}
|
|
|
|
LIST_FOR_EACH_ENTRY(value_candidate, &format->values, propstore_value, entry)
|
|
{
|
|
if (value_candidate->pid == key->pid)
|
|
{
|
|
value = value_candidate;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!value)
|
|
{
|
|
if (!insert)
|
|
return TYPE_E_ELEMENTNOTFOUND;
|
|
|
|
value = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*value));
|
|
if (!value)
|
|
return E_OUTOFMEMORY;
|
|
|
|
value->pid = key->pid;
|
|
list_add_tail(&format->values, &value->entry);
|
|
format->count++;
|
|
}
|
|
|
|
*result = value;
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_GetValue(IPropertyStoreCache *iface,
|
|
REFPROPERTYKEY key, PROPVARIANT *pv)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
|
|
TRACE("%p,%p,%p\n", iface, key, pv);
|
|
|
|
if (!pv)
|
|
return E_POINTER;
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = PropertyStore_LookupValue(This, key, FALSE, &value);
|
|
|
|
if (SUCCEEDED(hr))
|
|
hr = PropVariantCopy(pv, &value->propvar);
|
|
else if (hr == TYPE_E_ELEMENTNOTFOUND)
|
|
{
|
|
PropVariantInit(pv);
|
|
hr = S_OK;
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
return hr;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_SetValue(IPropertyStoreCache *iface,
|
|
REFPROPERTYKEY key, REFPROPVARIANT propvar)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
PROPVARIANT temp;
|
|
|
|
TRACE("%p,%p,%p\n", iface, key, propvar);
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = PropertyStore_LookupValue(This, key, TRUE, &value);
|
|
|
|
if (SUCCEEDED(hr))
|
|
hr = PropVariantCopy(&temp, propvar);
|
|
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
PropVariantClear(&value->propvar);
|
|
value->propvar = temp;
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
return hr;
|
|
}
|
|
|
|
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)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
|
|
TRACE("%p,%p,%p\n", iface, key, pstate);
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = PropertyStore_LookupValue(This, key, FALSE, &value);
|
|
|
|
if (SUCCEEDED(hr))
|
|
*pstate = value->state;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
if (FAILED(hr))
|
|
*pstate = PSC_NORMAL;
|
|
|
|
return hr;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_GetValueAndState(IPropertyStoreCache *iface,
|
|
REFPROPERTYKEY key, PROPVARIANT *ppropvar, PSC_STATE *pstate)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
|
|
TRACE("%p,%p,%p,%p\n", iface, key, ppropvar, pstate);
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = PropertyStore_LookupValue(This, key, FALSE, &value);
|
|
|
|
if (SUCCEEDED(hr))
|
|
hr = PropVariantCopy(ppropvar, &value->propvar);
|
|
|
|
if (SUCCEEDED(hr))
|
|
*pstate = value->state;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
if (FAILED(hr))
|
|
{
|
|
PropVariantInit(ppropvar);
|
|
*pstate = PSC_NORMAL;
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_SetState(IPropertyStoreCache *iface,
|
|
REFPROPERTYKEY key, PSC_STATE pstate)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
|
|
TRACE("%p,%p,%d\n", iface, key, pstate);
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = PropertyStore_LookupValue(This, key, FALSE, &value);
|
|
|
|
if (SUCCEEDED(hr))
|
|
value->state = pstate;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
return hr;
|
|
}
|
|
|
|
static HRESULT WINAPI PropertyStore_SetValueAndState(IPropertyStoreCache *iface,
|
|
REFPROPERTYKEY key, const PROPVARIANT *ppropvar, PSC_STATE state)
|
|
{
|
|
PropertyStore *This = impl_from_IPropertyStoreCache(iface);
|
|
propstore_value *value;
|
|
HRESULT hr;
|
|
PROPVARIANT temp;
|
|
|
|
TRACE("%p,%p,%p,%d\n", iface, key, ppropvar, state);
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
hr = PropertyStore_LookupValue(This, key, TRUE, &value);
|
|
|
|
if (SUCCEEDED(hr))
|
|
hr = PropVariantCopy(&temp, ppropvar);
|
|
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
PropVariantClear(&value->propvar);
|
|
value->propvar = temp;
|
|
value->state = state;
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
return hr;
|
|
}
|
|
|
|
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;
|
|
#ifdef __REACTOS__
|
|
InitializeCriticalSection(&This->lock);
|
|
#else
|
|
InitializeCriticalSectionEx(&This->lock, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO);
|
|
#endif
|
|
This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PropertyStore.lock");
|
|
list_init(&This->formats);
|
|
|
|
ret = IPropertyStoreCache_QueryInterface(&This->IPropertyStoreCache_iface, iid, ppv);
|
|
IPropertyStoreCache_Release(&This->IPropertyStoreCache_iface);
|
|
|
|
return ret;
|
|
}
|
|
|
|
HRESULT WINAPI PSCreatePropertyStoreFromObject(IUnknown *obj, DWORD access, REFIID riid, void **ret)
|
|
{
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p, %ld, %s, %p)\n", obj, access, debugstr_guid(riid), ret);
|
|
|
|
if (!obj || !ret)
|
|
return E_POINTER;
|
|
|
|
if (IsEqualIID(riid, &IID_IPropertyStore) && SUCCEEDED(hr = IUnknown_QueryInterface(obj, riid, ret)))
|
|
return hr;
|
|
|
|
FIXME("Unimplemented for %s.\n", debugstr_guid(riid));
|
|
return E_NOTIMPL;
|
|
}
|