combase: Move IGlobalOptions implementation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-03-31 18:15:50 +03:00 committed by Alexandre Julliard
parent e687f589dc
commit c1cb171315
4 changed files with 162 additions and 111 deletions

View File

@ -429,6 +429,150 @@ static void com_cleanup_tlsdata(void)
NtCurrentTeb()->ReservedForOle = NULL;
}
struct global_options
{
IGlobalOptions IGlobalOptions_iface;
LONG refcount;
};
static inline struct global_options *impl_from_IGlobalOptions(IGlobalOptions *iface)
{
return CONTAINING_RECORD(iface, struct global_options, IGlobalOptions_iface);
}
static HRESULT WINAPI global_options_QueryInterface(IGlobalOptions *iface, REFIID riid, void **ppv)
{
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppv);
if (IsEqualGUID(&IID_IGlobalOptions, riid) || IsEqualGUID(&IID_IUnknown, riid))
{
*ppv = iface;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown *)*ppv);
return S_OK;
}
static ULONG WINAPI global_options_AddRef(IGlobalOptions *iface)
{
struct global_options *options = impl_from_IGlobalOptions(iface);
LONG refcount = InterlockedIncrement(&options->refcount);
TRACE("%p, refcount %d.\n", iface, refcount);
return refcount;
}
static ULONG WINAPI global_options_Release(IGlobalOptions *iface)
{
struct global_options *options = impl_from_IGlobalOptions(iface);
LONG refcount = InterlockedDecrement(&options->refcount);
TRACE("%p, refcount %d.\n", iface, refcount);
if (!refcount)
heap_free(options);
return refcount;
}
static HRESULT WINAPI global_options_Set(IGlobalOptions *iface, GLOBALOPT_PROPERTIES property, ULONG_PTR value)
{
FIXME("%p, %u, %lx.\n", iface, property, value);
return S_OK;
}
static HRESULT WINAPI global_options_Query(IGlobalOptions *iface, GLOBALOPT_PROPERTIES property, ULONG_PTR *value)
{
FIXME("%p, %u, %p.\n", iface, property, value);
return E_NOTIMPL;
}
static const IGlobalOptionsVtbl global_options_vtbl =
{
global_options_QueryInterface,
global_options_AddRef,
global_options_Release,
global_options_Set,
global_options_Query
};
static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
{
*ppv = iface;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
{
return 2;
}
static ULONG WINAPI class_factory_Release(IClassFactory *iface)
{
return 1;
}
static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL fLock)
{
TRACE("%d\n", fLock);
return S_OK;
}
static HRESULT WINAPI global_options_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
struct global_options *object;
HRESULT hr;
TRACE("%p, %s, %p.\n", outer, debugstr_guid(riid), ppv);
if (outer)
return E_INVALIDARG;
if (!(object = heap_alloc(sizeof(*object))))
return E_OUTOFMEMORY;
object->IGlobalOptions_iface.lpVtbl = &global_options_vtbl;
object->refcount = 1;
hr = IGlobalOptions_QueryInterface(&object->IGlobalOptions_iface, riid, ppv);
IGlobalOptions_Release(&object->IGlobalOptions_iface);
return hr;
}
static const IClassFactoryVtbl global_options_factory_vtbl =
{
class_factory_QueryInterface,
class_factory_AddRef,
class_factory_Release,
global_options_CreateInstance,
class_factory_LockServer
};
static IClassFactory global_options_factory = { &global_options_factory_vtbl };
static HRESULT get_builtin_class_factory(REFCLSID rclsid, REFIID riid, void **obj)
{
if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
return IClassFactory_QueryInterface(&global_options_factory, riid, obj);
return E_UNEXPECTED;
}
/***********************************************************************
* FreePropVariantArray (combase.@)
*/
@ -1569,7 +1713,11 @@ static HRESULT com_get_class_object(REFCLSID rclsid, DWORD clscontext,
IsEqualCLSID(rclsid, &CLSID_StdGlobalInterfaceTable))
{
apartment_release(apt);
return Ole32DllGetClassObject(rclsid, riid, obj);
if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
return get_builtin_class_factory(rclsid, riid, obj);
else
return Ole32DllGetClassObject(rclsid, riid, obj);
}
}
@ -3226,3 +3374,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
return TRUE;
}
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
{
TRACE("%s, %s, %p.\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
*obj = NULL;
if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
return IClassFactory_QueryInterface(&global_options_factory, riid, obj);
return CLASS_E_CLASSNOTAVAILABLE;
}

View File

@ -178,7 +178,7 @@
@ stub DcomChannelSetHResult
@ stdcall DllDebugObjectRPCHook(long ptr)
@ stdcall DllGetActivationFactory(ptr ptr)
@ stdcall -private DllGetClassObject(ptr ptr ptr) ole32.DllGetClassObject
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stub EnableHookObject
@ stdcall FreePropVariantArray(long ptr)
@ stub FreePropVariantArrayWorker

View File

@ -924,102 +924,6 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
return CLASS_E_CLASSNOTAVAILABLE;
}
typedef struct {
IGlobalOptions IGlobalOptions_iface;
LONG ref;
} GlobalOptions;
static inline GlobalOptions *impl_from_IGlobalOptions(IGlobalOptions *iface)
{
return CONTAINING_RECORD(iface, GlobalOptions, IGlobalOptions_iface);
}
static HRESULT WINAPI GlobalOptions_QueryInterface(IGlobalOptions *iface, REFIID riid, void **ppv)
{
GlobalOptions *This = impl_from_IGlobalOptions(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
if (IsEqualGUID(&IID_IGlobalOptions, riid) || IsEqualGUID(&IID_IUnknown, riid))
{
*ppv = iface;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI GlobalOptions_AddRef(IGlobalOptions *iface)
{
GlobalOptions *This = impl_from_IGlobalOptions(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI GlobalOptions_Release(IGlobalOptions *iface)
{
GlobalOptions *This = impl_from_IGlobalOptions(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if (!ref)
heap_free(This);
return ref;
}
static HRESULT WINAPI GlobalOptions_Set(IGlobalOptions *iface, GLOBALOPT_PROPERTIES property, ULONG_PTR value)
{
GlobalOptions *This = impl_from_IGlobalOptions(iface);
FIXME("(%p)->(%u %lx)\n", This, property, value);
return S_OK;
}
static HRESULT WINAPI GlobalOptions_Query(IGlobalOptions *iface, GLOBALOPT_PROPERTIES property, ULONG_PTR *value)
{
GlobalOptions *This = impl_from_IGlobalOptions(iface);
FIXME("(%p)->(%u %p)\n", This, property, value);
return E_NOTIMPL;
}
static const IGlobalOptionsVtbl GlobalOptionsVtbl = {
GlobalOptions_QueryInterface,
GlobalOptions_AddRef,
GlobalOptions_Release,
GlobalOptions_Set,
GlobalOptions_Query
};
HRESULT WINAPI GlobalOptions_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
GlobalOptions *global_options;
HRESULT hres;
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
if (outer)
return E_INVALIDARG;
global_options = heap_alloc(sizeof(*global_options));
if (!global_options)
return E_OUTOFMEMORY;
global_options->IGlobalOptions_iface.lpVtbl = &GlobalOptionsVtbl;
global_options->ref = 1;
hres = IGlobalOptions_QueryInterface(&global_options->IGlobalOptions_iface, riid, ppv);
IGlobalOptions_Release(&global_options->IGlobalOptions_iface);
return hres;
}
/***********************************************************************
* DllMain (OLE32.@)
*/

View File

@ -148,17 +148,6 @@ static const IClassFactoryVtbl ComCatCFVtbl =
static IClassFactory ComCatCF = { &ComCatCFVtbl };
static const IClassFactoryVtbl GlobalOptionsCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
GlobalOptions_CreateInstance,
ClassFactory_LockServer
};
IClassFactory GlobalOptionsCF = { &GlobalOptionsCFVtbl };
static const IClassFactoryVtbl GlobalInterfaceTableCFVtbl =
{
ClassFactory_QueryInterface,
@ -230,8 +219,6 @@ HRESULT WINAPI Ole32DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
return IClassFactory_QueryInterface(&GlobalInterfaceTableCF, riid, obj);
else if (IsEqualCLSID(rclsid, &CLSID_ManualResetEvent))
return IClassFactory_QueryInterface(&ManualResetEventCF, riid, obj);
else if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
return IClassFactory_QueryInterface(&GlobalOptionsCF, riid, obj);
else if (IsEqualCLSID(rclsid, &CLSID_InProcFreeMarshaler))
return FTMarshalCF_Create(riid, obj);
else