2010-01-21 11:53:25 +00:00
|
|
|
/*
|
|
|
|
* Row and rowset servers / proxies.
|
|
|
|
*
|
|
|
|
* Copyright 2010 Huw Davies
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "oleauto.h"
|
|
|
|
#include "oledb.h"
|
|
|
|
|
|
|
|
#include "row_server.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(oledb);
|
|
|
|
|
2010-02-02 12:07:12 +00:00
|
|
|
|
|
|
|
typedef struct
|
2010-01-21 11:53:25 +00:00
|
|
|
{
|
2010-02-02 12:07:12 +00:00
|
|
|
const IWineRowServerVtbl *vtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
CLSID class;
|
|
|
|
IMarshal *marshal;
|
|
|
|
IUnknown *inner_unk;
|
|
|
|
} server;
|
|
|
|
|
|
|
|
static inline server *impl_from_IWineRowServer(IWineRowServer *iface)
|
|
|
|
{
|
|
|
|
return (server *)((char*)iface - FIELD_OFFSET(server, vtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI server_QueryInterface(IWineRowServer *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
server *This = impl_from_IWineRowServer(iface);
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
2010-01-21 11:53:25 +00:00
|
|
|
*obj = NULL;
|
2010-02-02 12:07:12 +00:00
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IWineRowServer))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!IsEqualIID(riid, &IID_IMarshal)) /* We use standard marshalling */
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IWineRowServer_AddRef(iface);
|
|
|
|
return S_OK;
|
2010-01-21 11:53:25 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 12:07:12 +00:00
|
|
|
static ULONG WINAPI server_AddRef(IWineRowServer *iface)
|
|
|
|
{
|
|
|
|
server *This = impl_from_IWineRowServer(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI server_Release(IWineRowServer *iface)
|
2010-01-21 11:53:25 +00:00
|
|
|
{
|
2010-02-02 12:07:12 +00:00
|
|
|
server *This = impl_from_IWineRowServer(iface);
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if(ref == 0)
|
|
|
|
{
|
|
|
|
IMarshal_Release(This->marshal);
|
|
|
|
if(This->inner_unk) IUnknown_Release(This->inner_unk);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI server_SetInnerUnk(IWineRowServer *iface, IUnknown *inner)
|
|
|
|
{
|
|
|
|
server *This = impl_from_IWineRowServer(iface);
|
|
|
|
|
|
|
|
if(This->inner_unk) IUnknown_Release(This->inner_unk);
|
|
|
|
|
|
|
|
if(inner) IUnknown_AddRef(inner);
|
|
|
|
This->inner_unk = inner;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI server_GetMarshal(IWineRowServer *iface, IMarshal **marshal)
|
|
|
|
{
|
|
|
|
server *This = impl_from_IWineRowServer(iface);
|
|
|
|
|
|
|
|
IMarshal_AddRef(This->marshal);
|
|
|
|
*marshal = This->marshal;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IWineRowServerVtbl server_vtbl =
|
|
|
|
{
|
|
|
|
server_QueryInterface,
|
|
|
|
server_AddRef,
|
|
|
|
server_Release,
|
|
|
|
server_SetInnerUnk,
|
|
|
|
server_GetMarshal
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_server(IUnknown *outer, const CLSID *class, void **obj)
|
|
|
|
{
|
|
|
|
server *server;
|
|
|
|
TRACE("(%p, %s, %p)\n", outer, debugstr_guid(class), obj);
|
|
|
|
|
2010-01-21 11:53:25 +00:00
|
|
|
*obj = NULL;
|
2010-02-02 12:07:12 +00:00
|
|
|
|
|
|
|
server = HeapAlloc(GetProcessHeap(), 0, sizeof(*server));
|
|
|
|
if(!server) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
server->vtbl = &server_vtbl;
|
|
|
|
server->ref = 1;
|
|
|
|
server->class = *class;
|
|
|
|
server->inner_unk = NULL;
|
|
|
|
if(IsEqualGUID(class, &CLSID_wine_row_server))
|
|
|
|
create_row_marshal((IUnknown*)server, (void**)&server->marshal);
|
|
|
|
else if(IsEqualGUID(class, &CLSID_wine_rowset_server))
|
|
|
|
create_rowset_marshal((IUnknown*)server, (void**)&server->marshal);
|
|
|
|
else
|
|
|
|
ERR("create_server called with class %s\n", debugstr_guid(class));
|
|
|
|
|
|
|
|
*obj = server;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT create_row_server(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
return create_server(outer, &CLSID_wine_row_server, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT create_rowset_server(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
return create_server(outer, &CLSID_wine_rowset_server, obj);
|
2010-01-21 11:53:25 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 16:35:43 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IRowVtbl *row_vtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IWineRowServer *server;
|
|
|
|
} row_proxy;
|
|
|
|
|
|
|
|
static inline row_proxy *impl_from_IRow(IRow *iface)
|
|
|
|
{
|
|
|
|
return (row_proxy *)((char*)iface - FIELD_OFFSET(row_proxy, row_vtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI row_QueryInterface(IRow *iface, REFIID iid, void **obj)
|
|
|
|
{
|
|
|
|
row_proxy *This = impl_from_IRow(iface);
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(iid), obj);
|
|
|
|
|
|
|
|
if(IsEqualIID(iid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(iid, &IID_IRow))
|
|
|
|
{
|
|
|
|
*obj = &This->row_vtbl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IRow_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI row_AddRef(IRow *iface)
|
|
|
|
{
|
|
|
|
row_proxy *This = impl_from_IRow(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI row_Release(IRow *iface)
|
|
|
|
{
|
|
|
|
row_proxy *This = impl_from_IRow(iface);
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if(ref == 0)
|
|
|
|
{
|
|
|
|
if(This->server) IWineRowServer_Release(This->server);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI row_GetColumns(IRow* iface, DBORDINAL cColumns, DBCOLUMNACCESS rgColumns[])
|
|
|
|
{
|
|
|
|
row_proxy *This = impl_from_IRow(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d, %p): stub\n", This, cColumns, rgColumns);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI row_GetSourceRowset(IRow* iface, REFIID riid, IUnknown **ppRowset,
|
|
|
|
HROW *phRow)
|
|
|
|
{
|
|
|
|
row_proxy *This = impl_from_IRow(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %p, %p): stub\n", This, debugstr_guid(riid), ppRowset, phRow);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI row_Open(IRow* iface, IUnknown *pUnkOuter,
|
|
|
|
DBID *pColumnID, REFGUID rguidColumnType,
|
|
|
|
DWORD dwBindFlags, REFIID riid, IUnknown **ppUnk)
|
|
|
|
{
|
|
|
|
row_proxy *This = impl_from_IRow(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p, %p, %s, %08x, %s, %p): stub\n", This, pUnkOuter, pColumnID, debugstr_guid(rguidColumnType),
|
|
|
|
dwBindFlags, debugstr_guid(riid), ppUnk);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IRowVtbl row_vtbl =
|
|
|
|
{
|
|
|
|
row_QueryInterface,
|
|
|
|
row_AddRef,
|
|
|
|
row_Release,
|
|
|
|
row_GetColumns,
|
|
|
|
row_GetSourceRowset,
|
|
|
|
row_Open
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_row_proxy(IWineRowServer *server, IUnknown **obj)
|
|
|
|
{
|
|
|
|
row_proxy *proxy;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", server, obj);
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
proxy = HeapAlloc(GetProcessHeap(), 0, sizeof(*proxy));
|
|
|
|
if(!proxy) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
proxy->row_vtbl = &row_vtbl;
|
|
|
|
proxy->ref = 1;
|
|
|
|
IWineRowServer_AddRef(server);
|
|
|
|
proxy->server = server;
|
|
|
|
|
|
|
|
*obj = (IUnknown*)&proxy->row_vtbl;
|
|
|
|
TRACE("returing %p\n", *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-02 16:49:47 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IRowsetVtbl *rowset_vtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IWineRowServer *server;
|
|
|
|
} rowset_proxy;
|
|
|
|
|
|
|
|
static inline rowset_proxy *impl_from_IRowset(IRowset *iface)
|
|
|
|
{
|
|
|
|
return (rowset_proxy *)((char*)iface - FIELD_OFFSET(rowset_proxy, rowset_vtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_QueryInterface(IRowset *iface, REFIID iid, void **obj)
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(iid), obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if(IsEqualIID(iid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(iid, &IID_IRowset))
|
|
|
|
{
|
|
|
|
*obj = &This->rowset_vtbl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IRowset_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowset_AddRef(IRowset *iface)
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowset_Release(IRowset *iface)
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if(ref == 0)
|
|
|
|
{
|
|
|
|
if(This->server) IWineRowServer_Release(This->server);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_AddRefRows(IRowset *iface, DBCOUNTITEM cRows, const HROW rghRows[],
|
|
|
|
DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[])
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d, %p, %p, %p): stub\n", This, cRows, rghRows, rgRefCounts, rgRowStatus);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_GetData(IRowset *iface, HROW hRow, HACCESSOR hAccessor, void *pData)
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%lx, %lx, %p): stub\n", This, hRow, hAccessor, pData);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_GetNextRows(IRowset *iface, HCHAPTER hReserved, DBROWOFFSET lRowsOffset,
|
|
|
|
DBROWCOUNT cRows, DBCOUNTITEM *pcRowObtained, HROW **prghRows)
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%08lx, %d, %d, %p, %p): stub\n", This, hReserved, lRowsOffset, cRows, pcRowObtained, prghRows);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_ReleaseRows(IRowset *iface, DBCOUNTITEM cRows, const HROW rghRows[],
|
|
|
|
DBROWOPTIONS rgRowOptions[], DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[])
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d, %p, %p, %p, %p): stub\n", This, cRows, rghRows, rgRowOptions, rgRefCounts, rgRowStatus);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_RestartPosition(IRowset* iface, HCHAPTER hReserved)
|
|
|
|
{
|
|
|
|
rowset_proxy *This = impl_from_IRowset(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%lx): stub\n", This, hReserved);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IRowsetVtbl rowset_vtbl =
|
|
|
|
{
|
|
|
|
rowset_QueryInterface,
|
|
|
|
rowset_AddRef,
|
|
|
|
rowset_Release,
|
|
|
|
rowset_AddRefRows,
|
|
|
|
rowset_GetData,
|
|
|
|
rowset_GetNextRows,
|
|
|
|
rowset_ReleaseRows,
|
|
|
|
rowset_RestartPosition
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_rowset_proxy(IWineRowServer *server, IUnknown **obj)
|
|
|
|
{
|
|
|
|
rowset_proxy *proxy;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", server, obj);
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
proxy = HeapAlloc(GetProcessHeap(), 0, sizeof(*proxy));
|
|
|
|
if(!proxy) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
proxy->rowset_vtbl = &rowset_vtbl;
|
|
|
|
proxy->ref = 1;
|
|
|
|
IWineRowServer_AddRef(server);
|
|
|
|
proxy->server = server;
|
|
|
|
|
|
|
|
*obj = (IUnknown *)&proxy->rowset_vtbl;
|
|
|
|
TRACE("returing %p\n", *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-02 16:35:43 +00:00
|
|
|
static HRESULT create_proxy(IWineRowServer *server, const CLSID *class, IUnknown **obj)
|
2010-02-02 13:36:25 +00:00
|
|
|
{
|
|
|
|
*obj = NULL;
|
2010-02-02 16:35:43 +00:00
|
|
|
|
|
|
|
if(IsEqualGUID(class, &CLSID_wine_row_proxy))
|
|
|
|
return create_row_proxy(server, obj);
|
2010-02-02 16:49:47 +00:00
|
|
|
else if(IsEqualGUID(class, &CLSID_wine_rowset_proxy))
|
|
|
|
return create_rowset_proxy(server, obj);
|
2010-02-02 16:35:43 +00:00
|
|
|
else
|
|
|
|
FIXME("Unhandled proxy class %s\n", debugstr_guid(class));
|
2010-02-02 13:36:25 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-02-02 11:52:51 +00:00
|
|
|
/* Marshal impl */
|
|
|
|
|
|
|
|
typedef struct
|
2010-01-21 11:53:25 +00:00
|
|
|
{
|
2010-02-02 11:52:51 +00:00
|
|
|
const IMarshalVtbl *marshal_vtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
CLSID unmarshal_class;
|
|
|
|
IUnknown *outer;
|
|
|
|
} marshal;
|
|
|
|
|
|
|
|
static inline marshal *impl_from_IMarshal(IMarshal *iface)
|
|
|
|
{
|
|
|
|
return (marshal *)((char*)iface - FIELD_OFFSET(marshal, marshal_vtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI marshal_QueryInterface(IMarshal *iface, REFIID iid, void **obj)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(iid), obj);
|
|
|
|
|
|
|
|
if(IsEqualIID(iid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(iid, &IID_IMarshal))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(iid));
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMarshal_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI marshal_AddRef(IMarshal *iface)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI marshal_Release(IMarshal *iface)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if(ref == 0)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI marshal_GetUnmarshalClass(IMarshal *iface, REFIID iid, void *obj,
|
|
|
|
DWORD dwDestContext, void *pvDestContext,
|
|
|
|
DWORD mshlflags, CLSID *clsid)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
2010-02-02 13:36:25 +00:00
|
|
|
TRACE("(%p)->(%s, %p, %08x, %p, %08x, %p)\n", This, debugstr_guid(iid), obj, dwDestContext,
|
2010-02-02 11:52:51 +00:00
|
|
|
pvDestContext, mshlflags, clsid);
|
|
|
|
|
2010-02-02 13:36:25 +00:00
|
|
|
*clsid = This->unmarshal_class;
|
|
|
|
return S_OK;
|
2010-01-21 11:53:25 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 11:52:51 +00:00
|
|
|
static HRESULT WINAPI marshal_GetMarshalSizeMax(IMarshal *iface, REFIID iid, void *obj,
|
|
|
|
DWORD dwDestContext, void *pvDestContext,
|
|
|
|
DWORD mshlflags, DWORD *size)
|
2010-01-21 11:53:25 +00:00
|
|
|
{
|
2010-02-02 11:52:51 +00:00
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
2010-02-02 13:36:25 +00:00
|
|
|
TRACE("(%p)->(%s, %p, %08x, %p, %08x, %p)\n", This, debugstr_guid(iid), obj, dwDestContext,
|
2010-02-02 11:52:51 +00:00
|
|
|
pvDestContext, mshlflags, size);
|
|
|
|
|
2010-02-02 13:36:25 +00:00
|
|
|
return CoGetMarshalSizeMax(size, &IID_IWineRowServer, This->outer, dwDestContext, pvDestContext,
|
|
|
|
mshlflags);
|
2010-02-02 11:52:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI marshal_MarshalInterface(IMarshal *iface, IStream *stream, REFIID iid,
|
|
|
|
void *obj, DWORD dwDestContext, void *pvDestContext,
|
|
|
|
DWORD mshlflags)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
2010-02-02 13:36:25 +00:00
|
|
|
TRACE("(%p)->(%p, %s, %p, %08x, %p, %08x)\n", This, stream, debugstr_guid(iid), obj, dwDestContext,
|
2010-02-02 11:52:51 +00:00
|
|
|
pvDestContext, mshlflags);
|
|
|
|
|
2010-02-02 13:36:25 +00:00
|
|
|
return CoMarshalInterface(stream, &IID_IWineRowServer, This->outer, dwDestContext, pvDestContext, mshlflags);
|
2010-02-02 11:52:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI marshal_UnmarshalInterface(IMarshal *iface, IStream *stream,
|
|
|
|
REFIID iid, void **obj)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
2010-02-02 13:36:25 +00:00
|
|
|
HRESULT hr;
|
|
|
|
IWineRowServer *server;
|
|
|
|
IUnknown *proxy;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %s, %p)\n", This, stream, debugstr_guid(iid), obj);
|
2010-01-21 11:53:25 +00:00
|
|
|
*obj = NULL;
|
2010-02-02 11:52:51 +00:00
|
|
|
|
2010-02-02 13:36:25 +00:00
|
|
|
hr = CoUnmarshalInterface(stream, &IID_IWineRowServer, (void**)&server);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = create_proxy(server, &This->unmarshal_class, &proxy);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(proxy, iid, obj);
|
|
|
|
IUnknown_Release(proxy);
|
|
|
|
}
|
|
|
|
IWineRowServer_Release(server);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("returing %p\n", *obj);
|
|
|
|
return hr;
|
2010-01-21 11:53:25 +00:00
|
|
|
}
|
2010-02-02 11:52:51 +00:00
|
|
|
|
|
|
|
static HRESULT WINAPI marshal_ReleaseMarshalData(IMarshal *iface, IStream *stream)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
2010-02-02 13:36:25 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, stream);
|
|
|
|
return CoReleaseMarshalData(stream);
|
2010-02-02 11:52:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI marshal_DisconnectObject(IMarshal *iface, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
marshal *This = impl_from_IMarshal(iface);
|
|
|
|
FIXME("(%p)->(%08x)\n", This, dwReserved);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMarshalVtbl marshal_vtbl =
|
|
|
|
{
|
|
|
|
marshal_QueryInterface,
|
|
|
|
marshal_AddRef,
|
|
|
|
marshal_Release,
|
|
|
|
marshal_GetUnmarshalClass,
|
|
|
|
marshal_GetMarshalSizeMax,
|
|
|
|
marshal_MarshalInterface,
|
|
|
|
marshal_UnmarshalInterface,
|
|
|
|
marshal_ReleaseMarshalData,
|
|
|
|
marshal_DisconnectObject
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_marshal(IUnknown *outer, const CLSID *class, void **obj)
|
|
|
|
{
|
|
|
|
marshal *marshal;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", outer, obj);
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
marshal = HeapAlloc(GetProcessHeap(), 0, sizeof(*marshal));
|
|
|
|
if(!marshal) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
marshal->unmarshal_class = *class;
|
|
|
|
marshal->outer = outer; /* don't ref outer unk */
|
|
|
|
marshal->marshal_vtbl = &marshal_vtbl;
|
|
|
|
marshal->ref = 1;
|
|
|
|
|
|
|
|
*obj = &marshal->marshal_vtbl;
|
|
|
|
TRACE("returing %p\n", *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT create_row_marshal(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", outer, obj);
|
|
|
|
return create_marshal(outer, &CLSID_wine_row_proxy, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT create_rowset_marshal(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", outer, obj);
|
|
|
|
return create_marshal(outer, &CLSID_wine_rowset_proxy, obj);
|
|
|
|
}
|