Commit 37d27c38 authored by Andrey Turkin's avatar Andrey Turkin Committed by Alexandre Julliard

ole32: Add IContextCallback interface to context object.

parent ba48d378
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "objbase.h" #include "objbase.h"
#include "ole2.h" #include "ole2.h"
#include "ole2ver.h" #include "ole2ver.h"
#include "ctxtcall.h"
#include "compobj_private.h" #include "compobj_private.h"
...@@ -3703,19 +3704,37 @@ HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *pChann ...@@ -3703,19 +3704,37 @@ HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *pChann
typedef struct Context typedef struct Context
{ {
const IComThreadingInfoVtbl *lpVtbl; const IComThreadingInfoVtbl *lpVtbl;
const IContextCallbackVtbl *lpCallbackVtbl;
LONG refs; LONG refs;
APTTYPE apttype; APTTYPE apttype;
} Context; } Context;
static HRESULT WINAPI Context_QueryInterface(IComThreadingInfo *iface, REFIID riid, LPVOID *ppv) static inline Context *impl_from_IComThreadingInfo( IComThreadingInfo *iface )
{
return (Context *)((char*)iface - FIELD_OFFSET(Context, lpVtbl));
}
static inline Context *impl_from_IContextCallback( IContextCallback *iface )
{
return (Context *)((char*)iface - FIELD_OFFSET(Context, lpCallbackVtbl));
}
static HRESULT Context_QueryInterface(Context *iface, REFIID riid, LPVOID *ppv)
{ {
*ppv = NULL; *ppv = NULL;
if (IsEqualIID(riid, &IID_IComThreadingInfo) || if (IsEqualIID(riid, &IID_IComThreadingInfo) ||
IsEqualIID(riid, &IID_IUnknown)) IsEqualIID(riid, &IID_IUnknown))
{ {
*ppv = iface; *ppv = &iface->lpVtbl;
IUnknown_AddRef(iface); } else if (IsEqualIID(riid, &IID_IContextCallback))
{
*ppv = &iface->lpCallbackVtbl;
}
if (*ppv)
{
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK; return S_OK;
} }
...@@ -3723,24 +3742,40 @@ static HRESULT WINAPI Context_QueryInterface(IComThreadingInfo *iface, REFIID ri ...@@ -3723,24 +3742,40 @@ static HRESULT WINAPI Context_QueryInterface(IComThreadingInfo *iface, REFIID ri
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI Context_AddRef(IComThreadingInfo *iface) static ULONG Context_AddRef(Context *This)
{ {
Context *This = (Context *)iface;
return InterlockedIncrement(&This->refs); return InterlockedIncrement(&This->refs);
} }
static ULONG WINAPI Context_Release(IComThreadingInfo *iface) static ULONG Context_Release(Context *This)
{ {
Context *This = (Context *)iface;
ULONG refs = InterlockedDecrement(&This->refs); ULONG refs = InterlockedDecrement(&This->refs);
if (!refs) if (!refs)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return refs; return refs;
} }
static HRESULT WINAPI Context_GetCurrentApartmentType(IComThreadingInfo *iface, APTTYPE *apttype) static HRESULT WINAPI Context_CTI_QueryInterface(IComThreadingInfo *iface, REFIID riid, LPVOID *ppv)
{
Context *This = impl_from_IComThreadingInfo(iface);
return Context_QueryInterface(This, riid, ppv);
}
static ULONG WINAPI Context_CTI_AddRef(IComThreadingInfo *iface)
{
Context *This = impl_from_IComThreadingInfo(iface);
return Context_AddRef(This);
}
static ULONG WINAPI Context_CTI_Release(IComThreadingInfo *iface)
{
Context *This = impl_from_IComThreadingInfo(iface);
return Context_Release(This);
}
static HRESULT WINAPI Context_CTI_GetCurrentApartmentType(IComThreadingInfo *iface, APTTYPE *apttype)
{ {
Context *This = (Context *)iface; Context *This = impl_from_IComThreadingInfo(iface);
TRACE("(%p)\n", apttype); TRACE("(%p)\n", apttype);
...@@ -3748,9 +3783,9 @@ static HRESULT WINAPI Context_GetCurrentApartmentType(IComThreadingInfo *iface, ...@@ -3748,9 +3783,9 @@ static HRESULT WINAPI Context_GetCurrentApartmentType(IComThreadingInfo *iface,
return S_OK; return S_OK;
} }
static HRESULT WINAPI Context_GetCurrentThreadType(IComThreadingInfo *iface, THDTYPE *thdtype) static HRESULT WINAPI Context_CTI_GetCurrentThreadType(IComThreadingInfo *iface, THDTYPE *thdtype)
{ {
Context *This = (Context *)iface; Context *This = impl_from_IComThreadingInfo(iface);
TRACE("(%p)\n", thdtype); TRACE("(%p)\n", thdtype);
...@@ -3767,13 +3802,13 @@ static HRESULT WINAPI Context_GetCurrentThreadType(IComThreadingInfo *iface, THD ...@@ -3767,13 +3802,13 @@ static HRESULT WINAPI Context_GetCurrentThreadType(IComThreadingInfo *iface, THD
return S_OK; return S_OK;
} }
static HRESULT WINAPI Context_GetCurrentLogicalThreadId(IComThreadingInfo *iface, GUID *logical_thread_id) static HRESULT WINAPI Context_CTI_GetCurrentLogicalThreadId(IComThreadingInfo *iface, GUID *logical_thread_id)
{ {
FIXME("(%p): stub\n", logical_thread_id); FIXME("(%p): stub\n", logical_thread_id);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI Context_SetCurrentLogicalThreadId(IComThreadingInfo *iface, REFGUID logical_thread_id) static HRESULT WINAPI Context_CTI_SetCurrentLogicalThreadId(IComThreadingInfo *iface, REFGUID logical_thread_id)
{ {
FIXME("(%s): stub\n", debugstr_guid(logical_thread_id)); FIXME("(%s): stub\n", debugstr_guid(logical_thread_id));
return E_NOTIMPL; return E_NOTIMPL;
...@@ -3781,15 +3816,51 @@ static HRESULT WINAPI Context_SetCurrentLogicalThreadId(IComThreadingInfo *iface ...@@ -3781,15 +3816,51 @@ static HRESULT WINAPI Context_SetCurrentLogicalThreadId(IComThreadingInfo *iface
static const IComThreadingInfoVtbl Context_Threading_Vtbl = static const IComThreadingInfoVtbl Context_Threading_Vtbl =
{ {
Context_QueryInterface, Context_CTI_QueryInterface,
Context_AddRef, Context_CTI_AddRef,
Context_Release, Context_CTI_Release,
Context_GetCurrentApartmentType, Context_CTI_GetCurrentApartmentType,
Context_GetCurrentThreadType, Context_CTI_GetCurrentThreadType,
Context_GetCurrentLogicalThreadId, Context_CTI_GetCurrentLogicalThreadId,
Context_SetCurrentLogicalThreadId Context_CTI_SetCurrentLogicalThreadId
}; };
static HRESULT WINAPI Context_CC_QueryInterface(IContextCallback *iface, REFIID riid, LPVOID *ppv)
{
Context *This = impl_from_IContextCallback(iface);
return Context_QueryInterface(This, riid, ppv);
}
static ULONG WINAPI Context_CC_AddRef(IContextCallback *iface)
{
Context *This = impl_from_IContextCallback(iface);
return Context_AddRef(This);
}
static ULONG WINAPI Context_CC_Release(IContextCallback *iface)
{
Context *This = impl_from_IContextCallback(iface);
return Context_Release(This);
}
static HRESULT WINAPI Context_CC_ContextCallback(IContextCallback *iface, PFNCONTEXTCALL pCallback,
ComCallData *param, REFIID riid, int method, IUnknown *punk)
{
Context *This = impl_from_IContextCallback(iface);
FIXME("(%p/%p)->(%p, %p, %s, %d, %p)\n", This, iface, pCallback, param, debugstr_guid(riid), method, punk);
return E_NOTIMPL;
}
static const IContextCallbackVtbl Context_Callback_Vtbl =
{
Context_CC_QueryInterface,
Context_CC_AddRef,
Context_CC_Release,
Context_CC_ContextCallback
};
/*********************************************************************** /***********************************************************************
* CoGetObjectContext [OLE32.@] * CoGetObjectContext [OLE32.@]
* *
...@@ -3823,6 +3894,7 @@ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv) ...@@ -3823,6 +3894,7 @@ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
context->lpVtbl = &Context_Threading_Vtbl; context->lpVtbl = &Context_Threading_Vtbl;
context->lpCallbackVtbl = &Context_Callback_Vtbl;
context->refs = 1; context->refs = 1;
if (apt->multi_threaded) if (apt->multi_threaded)
context->apttype = APTTYPE_MTA; context->apttype = APTTYPE_MTA;
......
...@@ -1001,9 +1001,7 @@ static void test_CoGetObjectContext(void) ...@@ -1001,9 +1001,7 @@ static void test_CoGetObjectContext(void)
ok(refs == 0, "pComThreadingInfo should have 0 refs instead of %d refs\n", refs); ok(refs == 0, "pComThreadingInfo should have 0 refs instead of %d refs\n", refs);
hr = pCoGetObjectContext(&IID_IContextCallback, (void **)&pContextCallback); hr = pCoGetObjectContext(&IID_IContextCallback, (void **)&pContextCallback);
todo_wine {
ok_ole_success(hr, "CoGetObjectContext(ContextCallback)"); ok_ole_success(hr, "CoGetObjectContext(ContextCallback)");
}
if (hr == S_OK) if (hr == S_OK)
{ {
...@@ -1030,9 +1028,7 @@ static void test_CoGetObjectContext(void) ...@@ -1030,9 +1028,7 @@ static void test_CoGetObjectContext(void)
ok(refs == 0, "pComThreadingInfo should have 0 refs instead of %d refs\n", refs); ok(refs == 0, "pComThreadingInfo should have 0 refs instead of %d refs\n", refs);
hr = pCoGetObjectContext(&IID_IContextCallback, (void **)&pContextCallback); hr = pCoGetObjectContext(&IID_IContextCallback, (void **)&pContextCallback);
todo_wine {
ok_ole_success(hr, "CoGetObjectContext(ContextCallback)"); ok_ole_success(hr, "CoGetObjectContext(ContextCallback)");
}
if (hr == S_OK) if (hr == S_OK)
{ {
......
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