Commit e8efc1e6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ieframe: Added IConnectionPoint::EnumConnections implementation.

parent 9f62d217
......@@ -109,8 +109,6 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo
return CONNECT_E_NOCONNECTION;
}
#undef impl_from_IConnectionPointContainer
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
{
ConnectionPointContainer_QueryInterface,
......@@ -130,6 +128,120 @@ static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *ifac
return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
}
typedef struct {
IEnumConnections IEnumConnections_iface;
LONG ref;
ConnectionPoint *cp;
DWORD iter;
} EnumConnections;
static inline EnumConnections *impl_from_IEnumConnections(IEnumConnections *iface)
{
return CONTAINING_RECORD(iface, EnumConnections, IEnumConnections_iface);
}
static HRESULT WINAPI EnumConnections_QueryInterface(IEnumConnections *iface, REFIID riid, void **ppv)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = &This->IEnumConnections_iface;
}else if(IsEqualGUID(&IID_IEnumConnections, riid)) {
TRACE("(%p)->(IID_IEnumConnections %p)\n", This, ppv);
*ppv = &This->IEnumConnections_iface;
}else {
WARN("Unsupported interface %s\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI EnumConnections_AddRef(IEnumConnections *iface)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI EnumConnections_Release(IEnumConnections *iface)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
IConnectionPoint_Release(&This->cp->IConnectionPoint_iface);
heap_free(This);
}
return ref;
}
static HRESULT WINAPI EnumConnections_Next(IEnumConnections *iface, ULONG cConnections, CONNECTDATA *pgcd, ULONG *pcFetched)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
ULONG cnt = 0;
TRACE("(%p)->(%u %p %p)\n", This, cConnections, pgcd, pcFetched);
while(cConnections--) {
while(This->iter < This->cp->sinks_size && !This->cp->sinks[This->iter])
This->iter++;
if(This->iter == This->cp->sinks_size)
break;
pgcd[cnt].pUnk = (IUnknown*)This->cp->sinks[This->iter];
pgcd[cnt].dwCookie = cnt+1;
This->iter++;
cnt++;
}
if(pcFetched)
*pcFetched = cnt;
return cnt ? S_OK : S_FALSE;
}
static HRESULT WINAPI EnumConnections_Skip(IEnumConnections *iface, ULONG cConnections)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
FIXME("(%p)->(%u)\n", This, cConnections);
return E_NOTIMPL;
}
static HRESULT WINAPI EnumConnections_Reset(IEnumConnections *iface)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI EnumConnections_Clone(IEnumConnections *iface, IEnumConnections **ppEnum)
{
EnumConnections *This = impl_from_IEnumConnections(iface);
FIXME("(%p)->(%p)\n", This, ppEnum);
return E_NOTIMPL;
}
static const IEnumConnectionsVtbl EnumConnectionsVtbl = {
EnumConnections_QueryInterface,
EnumConnections_AddRef,
EnumConnections_Release,
EnumConnections_Next,
EnumConnections_Skip,
EnumConnections_Reset,
EnumConnections_Clone
};
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
REFIID riid, LPVOID *ppv)
{
......@@ -245,8 +357,23 @@ static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
IEnumConnections **ppEnum)
{
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
FIXME("(%p)->(%p)\n", This, ppEnum);
return E_NOTIMPL;
EnumConnections *ret;
TRACE("(%p)->(%p)\n", This, ppEnum);
ret = heap_alloc(sizeof(*ret));
if(!ret)
return E_OUTOFMEMORY;
ret->IEnumConnections_iface.lpVtbl = &EnumConnectionsVtbl;
ret->ref = 1;
ret->iter = 0;
IConnectionPoint_AddRef(&This->IConnectionPoint_iface);
ret->cp = This;
*ppEnum = &ret->IEnumConnections_iface;
return S_OK;
}
static const IConnectionPointVtbl ConnectionPointVtbl =
......
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