2013-08-01 05:48:13 +02:00
|
|
|
/* OLE DB Row Position library
|
|
|
|
*
|
|
|
|
* Copyright 2013 Nikolay Sivov
|
|
|
|
*
|
|
|
|
* 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 "windef.h"
|
|
|
|
#include "ole2.h"
|
2013-08-22 12:23:21 +02:00
|
|
|
#include "olectl.h"
|
2013-08-01 05:48:13 +02:00
|
|
|
|
|
|
|
#include "oledb.h"
|
2013-08-01 05:53:48 +02:00
|
|
|
#include "oledberr.h"
|
2013-08-01 05:48:13 +02:00
|
|
|
|
|
|
|
#include "oledb_private.h"
|
|
|
|
#include "wine/debug.h"
|
2018-02-03 00:17:56 +01:00
|
|
|
#include "wine/heap.h"
|
2013-08-01 05:48:13 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(oledb);
|
|
|
|
|
2013-08-02 07:50:29 +02:00
|
|
|
typedef struct rowpos rowpos;
|
2013-08-01 05:48:13 +02:00
|
|
|
typedef struct
|
2013-08-02 07:50:29 +02:00
|
|
|
{
|
|
|
|
IConnectionPoint IConnectionPoint_iface;
|
|
|
|
rowpos *container;
|
2013-08-22 12:33:31 +02:00
|
|
|
IRowPositionChange **sinks;
|
|
|
|
DWORD sinks_size;
|
2013-08-02 07:50:29 +02:00
|
|
|
} rowpos_cp;
|
|
|
|
|
|
|
|
struct rowpos
|
2013-08-01 05:48:13 +02:00
|
|
|
{
|
|
|
|
IRowPosition IRowPosition_iface;
|
2013-08-02 07:44:43 +02:00
|
|
|
IConnectionPointContainer IConnectionPointContainer_iface;
|
2013-08-01 05:48:13 +02:00
|
|
|
LONG ref;
|
2013-08-01 05:53:48 +02:00
|
|
|
|
|
|
|
IRowset *rowset;
|
2013-08-26 06:47:28 +02:00
|
|
|
IChapteredRowset *chrst;
|
2013-08-23 08:33:59 +02:00
|
|
|
HROW row;
|
|
|
|
HCHAPTER chapter;
|
|
|
|
DBPOSITIONFLAGS flags;
|
2013-08-26 06:47:28 +02:00
|
|
|
BOOL cleared;
|
2013-08-02 07:50:29 +02:00
|
|
|
rowpos_cp cp;
|
|
|
|
};
|
2013-08-01 05:48:13 +02:00
|
|
|
|
2013-08-22 12:33:31 +02:00
|
|
|
static void rowposchange_cp_destroy(rowpos_cp*);
|
|
|
|
|
2013-08-01 05:48:13 +02:00
|
|
|
static inline rowpos *impl_from_IRowPosition(IRowPosition *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, rowpos, IRowPosition_iface);
|
|
|
|
}
|
|
|
|
|
2013-08-02 07:44:43 +02:00
|
|
|
static inline rowpos *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, rowpos, IConnectionPointContainer_iface);
|
|
|
|
}
|
|
|
|
|
2013-08-02 07:50:29 +02:00
|
|
|
static inline rowpos_cp *impl_from_IConnectionPoint(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, rowpos_cp, IConnectionPoint_iface);
|
|
|
|
}
|
|
|
|
|
2013-08-23 08:33:09 +02:00
|
|
|
static HRESULT rowpos_fireevent(rowpos *rp, DBREASON reason, DBEVENTPHASE phase)
|
|
|
|
{
|
2013-08-26 06:47:28 +02:00
|
|
|
BOOL cant_deny = phase == DBEVENTPHASE_FAILEDTODO || phase == DBEVENTPHASE_SYNCHAFTER;
|
2013-08-23 08:33:09 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for (i = 0; i < rp->cp.sinks_size; i++)
|
|
|
|
if (rp->cp.sinks[i])
|
|
|
|
{
|
2013-08-26 06:47:28 +02:00
|
|
|
hr = IRowPositionChange_OnRowPositionChange(rp->cp.sinks[i], reason, phase, cant_deny);
|
2013-08-23 08:33:09 +02:00
|
|
|
if (phase == DBEVENTPHASE_FAILEDTODO) return DB_E_CANCELED;
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2013-08-23 08:33:59 +02:00
|
|
|
static void rowpos_clearposition(rowpos *rp)
|
|
|
|
{
|
2013-08-26 06:47:28 +02:00
|
|
|
if (!rp->cleared)
|
|
|
|
{
|
|
|
|
if (rp->rowset)
|
|
|
|
IRowset_ReleaseRows(rp->rowset, 1, &rp->row, NULL, NULL, NULL);
|
|
|
|
if (rp->chrst)
|
|
|
|
IChapteredRowset_ReleaseChapter(rp->chrst, rp->chapter, NULL);
|
|
|
|
}
|
|
|
|
|
2013-08-23 08:33:59 +02:00
|
|
|
rp->row = DB_NULL_HROW;
|
|
|
|
rp->chapter = DB_NULL_HCHAPTER;
|
|
|
|
rp->flags = DBPOSITION_NOROW;
|
|
|
|
}
|
|
|
|
|
2013-08-01 05:48:13 +02:00
|
|
|
static HRESULT WINAPI rowpos_QueryInterface(IRowPosition* iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IRowPosition))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
}
|
2013-08-02 07:44:43 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IConnectionPointContainer))
|
|
|
|
{
|
|
|
|
*obj = &This->IConnectionPointContainer_iface;
|
|
|
|
}
|
2013-08-01 05:48:13 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IRowPosition_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowpos_AddRef(IRowPosition* iface)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowpos_Release(IRowPosition* iface)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
|
|
|
if (ref == 0)
|
2013-08-01 05:53:48 +02:00
|
|
|
{
|
|
|
|
if (This->rowset) IRowset_Release(This->rowset);
|
2013-08-26 06:47:28 +02:00
|
|
|
if (This->chrst) IChapteredRowset_Release(This->chrst);
|
2013-08-22 12:33:31 +02:00
|
|
|
rowposchange_cp_destroy(&This->cp);
|
2013-08-02 07:50:29 +02:00
|
|
|
heap_free(This);
|
2013-08-01 05:53:48 +02:00
|
|
|
}
|
2013-08-01 05:48:13 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_ClearRowPosition(IRowPosition* iface)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
2013-08-23 08:33:09 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (!This->rowset) return E_UNEXPECTED;
|
|
|
|
|
|
|
|
hr = rowpos_fireevent(This, DBREASON_ROWPOSITION_CLEARED, DBEVENTPHASE_OKTODO);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return rowpos_fireevent(This, DBREASON_ROWPOSITION_CLEARED, DBEVENTPHASE_FAILEDTODO);
|
|
|
|
|
|
|
|
hr = rowpos_fireevent(This, DBREASON_ROWPOSITION_CLEARED, DBEVENTPHASE_ABOUTTODO);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return rowpos_fireevent(This, DBREASON_ROWPOSITION_CLEARED, DBEVENTPHASE_FAILEDTODO);
|
|
|
|
|
2013-08-23 08:33:59 +02:00
|
|
|
rowpos_clearposition(This);
|
2013-08-26 06:47:28 +02:00
|
|
|
This->cleared = TRUE;
|
2013-08-23 08:33:09 +02:00
|
|
|
return S_OK;
|
2013-08-01 05:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_GetRowPosition(IRowPosition *iface, HCHAPTER *chapter,
|
|
|
|
HROW *row, DBPOSITIONFLAGS *flags)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
2013-08-23 08:33:59 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, chapter, row, flags);
|
|
|
|
|
|
|
|
*chapter = This->chapter;
|
|
|
|
*row = This->row;
|
|
|
|
*flags = This->flags;
|
|
|
|
|
|
|
|
if (!This->rowset) return E_UNEXPECTED;
|
|
|
|
|
|
|
|
return S_OK;
|
2013-08-01 05:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_GetRowset(IRowPosition *iface, REFIID riid, IUnknown **rowset)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
2013-08-23 08:33:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), rowset);
|
|
|
|
|
|
|
|
if (!This->rowset) return E_UNEXPECTED;
|
|
|
|
return IRowset_QueryInterface(This->rowset, riid, (void**)rowset);
|
2013-08-01 05:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_Initialize(IRowPosition *iface, IUnknown *rowset)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
2013-08-26 06:47:28 +02:00
|
|
|
HRESULT hr;
|
2013-08-01 05:53:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, rowset);
|
|
|
|
|
|
|
|
if (This->rowset) return DB_E_ALREADYINITIALIZED;
|
|
|
|
|
2013-08-26 06:47:28 +02:00
|
|
|
hr = IUnknown_QueryInterface(rowset, &IID_IRowset, (void**)&This->rowset);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
/* this one is optional */
|
|
|
|
IUnknown_QueryInterface(rowset, &IID_IChapteredRowset, (void**)&This->chrst);
|
|
|
|
return S_OK;
|
2013-08-01 05:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_SetRowPosition(IRowPosition *iface, HCHAPTER chapter,
|
|
|
|
HROW row, DBPOSITIONFLAGS flags)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IRowPosition(iface);
|
2013-08-26 06:47:28 +02:00
|
|
|
DBREASON reason;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%lx %lx %d)\n", This, chapter, row, flags);
|
|
|
|
|
|
|
|
if (!This->cleared) return E_UNEXPECTED;
|
|
|
|
|
|
|
|
hr = IRowset_AddRefRows(This->rowset, 1, &row, NULL, NULL);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
if (This->chrst)
|
|
|
|
{
|
|
|
|
hr = IChapteredRowset_AddRefChapter(This->chrst, chapter, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IRowset_ReleaseRows(This->rowset, 1, &row, NULL, NULL, NULL);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
reason = This->chrst ? DBREASON_ROWPOSITION_CHAPTERCHANGED : DBREASON_ROWPOSITION_CHANGED;
|
|
|
|
hr = rowpos_fireevent(This, reason, DBEVENTPHASE_SYNCHAFTER);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
IRowset_ReleaseRows(This->rowset, 1, &row, NULL, NULL, NULL);
|
|
|
|
if (This->chrst)
|
|
|
|
IChapteredRowset_ReleaseChapter(This->chrst, chapter, NULL);
|
|
|
|
return rowpos_fireevent(This, reason, DBEVENTPHASE_FAILEDTODO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rowpos_fireevent(This, reason, DBEVENTPHASE_DIDEVENT);
|
|
|
|
|
|
|
|
/* previously set chapter and row are released with ClearRowPosition() */
|
|
|
|
This->chapter = chapter;
|
|
|
|
This->row = row;
|
|
|
|
This->flags = flags;
|
|
|
|
This->cleared = FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
2013-08-01 05:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IRowPositionVtbl rowpos_vtbl =
|
|
|
|
{
|
|
|
|
rowpos_QueryInterface,
|
|
|
|
rowpos_AddRef,
|
|
|
|
rowpos_Release,
|
|
|
|
rowpos_ClearRowPosition,
|
|
|
|
rowpos_GetRowPosition,
|
|
|
|
rowpos_GetRowset,
|
|
|
|
rowpos_Initialize,
|
|
|
|
rowpos_SetRowPosition
|
|
|
|
};
|
|
|
|
|
2013-08-02 07:44:43 +02:00
|
|
|
static HRESULT WINAPI cpc_QueryInterface(IConnectionPointContainer *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IConnectionPointContainer(iface);
|
|
|
|
return IRowPosition_QueryInterface(&This->IRowPosition_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI cpc_AddRef(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IConnectionPointContainer(iface);
|
|
|
|
return IRowPosition_AddRef(&This->IRowPosition_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI cpc_Release(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IConnectionPointContainer(iface);
|
|
|
|
return IRowPosition_Release(&This->IRowPosition_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI cpc_EnumConnectionPoints(IConnectionPointContainer *iface, IEnumConnectionPoints **enum_points)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IConnectionPointContainer(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, enum_points);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI cpc_FindConnectionPoint(IConnectionPointContainer *iface, REFIID riid, IConnectionPoint **point)
|
|
|
|
{
|
|
|
|
rowpos *This = impl_from_IConnectionPointContainer(iface);
|
2013-08-22 12:23:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), point);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IRowPositionChange))
|
|
|
|
{
|
|
|
|
*point = &This->cp.IConnectionPoint_iface;
|
|
|
|
IConnectionPoint_AddRef(*point);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("unsupported riid %s\n", debugstr_guid(riid));
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
}
|
2013-08-02 07:44:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IConnectionPointContainerVtbl rowpos_cpc_vtbl =
|
|
|
|
{
|
|
|
|
cpc_QueryInterface,
|
|
|
|
cpc_AddRef,
|
|
|
|
cpc_Release,
|
|
|
|
cpc_EnumConnectionPoints,
|
|
|
|
cpc_FindConnectionPoint
|
|
|
|
};
|
|
|
|
|
2013-08-02 07:50:29 +02:00
|
|
|
static HRESULT WINAPI rowpos_cp_QueryInterface(IConnectionPoint *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_QueryInterface(&This->container->IConnectionPointContainer_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowpos_cp_AddRef(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_AddRef(&This->container->IConnectionPointContainer_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowpos_cp_Release(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_Release(&This->container->IConnectionPointContainer_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_cp_GetConnectionInterface(IConnectionPoint *iface, IID *iid)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, iid);
|
|
|
|
|
|
|
|
if (!iid) return E_POINTER;
|
|
|
|
|
|
|
|
*iid = IID_IRowPositionChange;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_cp_GetConnectionPointContainer(IConnectionPoint *iface, IConnectionPointContainer **container)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, container);
|
|
|
|
|
|
|
|
if (!container) return E_POINTER;
|
|
|
|
|
|
|
|
*container = &This->container->IConnectionPointContainer_iface;
|
|
|
|
IConnectionPointContainer_AddRef(*container);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-22 12:33:31 +02:00
|
|
|
static HRESULT WINAPI rowpos_cp_Advise(IConnectionPoint *iface, IUnknown *unksink, DWORD *cookie)
|
2013-08-02 07:50:29 +02:00
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
2013-08-22 12:33:31 +02:00
|
|
|
IRowPositionChange *sink;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, unksink, cookie);
|
|
|
|
|
2013-08-23 08:33:09 +02:00
|
|
|
if (!cookie) return E_POINTER;
|
|
|
|
|
2013-08-22 12:33:31 +02:00
|
|
|
hr = IUnknown_QueryInterface(unksink, &IID_IRowPositionChange, (void**)&sink);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FIXME("sink doesn't support IRowPositionChange\n");
|
|
|
|
return CONNECT_E_CANNOTCONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->sinks)
|
|
|
|
{
|
|
|
|
for (i = 0; i < This->sinks_size; i++)
|
|
|
|
{
|
|
|
|
if (!This->sinks[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == This->sinks_size)
|
|
|
|
{
|
|
|
|
This->sinks_size *= 2;
|
|
|
|
This->sinks = heap_realloc_zero(This->sinks, This->sinks_size*sizeof(*This->sinks));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->sinks_size = 10;
|
|
|
|
This->sinks = heap_alloc_zero(This->sinks_size*sizeof(*This->sinks));
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->sinks[i] = sink;
|
2019-02-21 20:35:39 +01:00
|
|
|
*cookie = i + 1;
|
2013-08-22 12:33:31 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2013-08-02 07:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_cp_Unadvise(IConnectionPoint *iface, DWORD cookie)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
2013-08-22 12:33:31 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, cookie);
|
|
|
|
|
|
|
|
if (!cookie || cookie > This->sinks_size || !This->sinks[cookie-1])
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
IRowPositionChange_Release(This->sinks[cookie-1]);
|
|
|
|
This->sinks[cookie-1] = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2013-08-02 07:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowpos_cp_EnumConnections(IConnectionPoint *iface, IEnumConnections **enum_c)
|
|
|
|
{
|
|
|
|
rowpos_cp *This = impl_from_IConnectionPoint(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, enum_c);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IConnectionPointVtbl rowpos_cp_vtbl =
|
|
|
|
{
|
|
|
|
rowpos_cp_QueryInterface,
|
|
|
|
rowpos_cp_AddRef,
|
|
|
|
rowpos_cp_Release,
|
|
|
|
rowpos_cp_GetConnectionInterface,
|
|
|
|
rowpos_cp_GetConnectionPointContainer,
|
|
|
|
rowpos_cp_Advise,
|
|
|
|
rowpos_cp_Unadvise,
|
|
|
|
rowpos_cp_EnumConnections
|
|
|
|
};
|
|
|
|
|
|
|
|
static void rowposchange_cp_init(rowpos_cp *cp, rowpos *container)
|
|
|
|
{
|
|
|
|
cp->IConnectionPoint_iface.lpVtbl = &rowpos_cp_vtbl;
|
|
|
|
cp->container = container;
|
2013-08-22 12:33:31 +02:00
|
|
|
cp->sinks = NULL;
|
|
|
|
cp->sinks_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rowposchange_cp_destroy(rowpos_cp *cp)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
for (i = 0; i < cp->sinks_size; i++)
|
|
|
|
{
|
|
|
|
if (cp->sinks[i])
|
|
|
|
IRowPositionChange_Release(cp->sinks[i]);
|
|
|
|
}
|
|
|
|
heap_free(cp->sinks);
|
2013-08-02 07:50:29 +02:00
|
|
|
}
|
|
|
|
|
2013-08-01 05:48:13 +02:00
|
|
|
HRESULT create_oledb_rowpos(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
rowpos *This;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", outer, obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if(outer) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2013-08-02 07:50:29 +02:00
|
|
|
This = heap_alloc(sizeof(*This));
|
2013-08-01 05:48:13 +02:00
|
|
|
if(!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IRowPosition_iface.lpVtbl = &rowpos_vtbl;
|
2013-08-02 07:44:43 +02:00
|
|
|
This->IConnectionPointContainer_iface.lpVtbl = &rowpos_cpc_vtbl;
|
2013-08-01 05:48:13 +02:00
|
|
|
This->ref = 1;
|
2013-08-01 05:53:48 +02:00
|
|
|
This->rowset = NULL;
|
2013-08-26 06:47:28 +02:00
|
|
|
This->chrst = NULL;
|
|
|
|
This->cleared = FALSE;
|
2013-08-23 08:33:59 +02:00
|
|
|
rowpos_clearposition(This);
|
2013-08-02 07:50:29 +02:00
|
|
|
rowposchange_cp_init(&This->cp, This);
|
2013-08-01 05:48:13 +02:00
|
|
|
|
|
|
|
*obj = &This->IRowPosition_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|