From 6297ba3dcbb6e96c12193d30d471d9479e38e19a Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 1 Aug 2013 07:48:13 +0400 Subject: [PATCH] oledb32: Stub for IRowPosition. --- dlls/oledb32/Makefile.in | 3 +- dlls/oledb32/main.c | 6 ++ dlls/oledb32/oledb32_classes.idl | 12 +++ dlls/oledb32/oledb_private.h | 1 + dlls/oledb32/rowpos.c | 155 +++++++++++++++++++++++++++++++ dlls/oledb32/tests/database.c | 15 +++ include/msdaguid.h | 1 + 7 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 dlls/oledb32/rowpos.c diff --git a/dlls/oledb32/Makefile.in b/dlls/oledb32/Makefile.in index 2da63ad8b4e..b019bdb9376 100644 --- a/dlls/oledb32/Makefile.in +++ b/dlls/oledb32/Makefile.in @@ -6,7 +6,8 @@ C_SRCS = \ convert.c \ datainit.c \ errorinfo.c \ - main.c + main.c \ + rowpos.c IDL_I_SRCS = convert.idl diff --git a/dlls/oledb32/main.c b/dlls/oledb32/main.c index 838e6d112b5..d101316b79e 100644 --- a/dlls/oledb32/main.c +++ b/dlls/oledb32/main.c @@ -129,6 +129,7 @@ static const IClassFactoryVtbl CF_Vtbl = static cf oledb_convert_cf = { { &CF_Vtbl }, create_oledb_convert }; static cf oledb_datainit_cf = { { &CF_Vtbl }, create_data_init }; static cf oledb_errorinfo_cf = { { &CF_Vtbl }, create_error_info }; +static cf oledb_rowpos_cf = { { &CF_Vtbl }, create_oledb_rowpos }; /****************************************************************** * DllGetClassObject @@ -152,6 +153,11 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj) *obj = &oledb_errorinfo_cf; return S_OK; } + else if ( IsEqualCLSID (rclsid, &CLSID_OLEDB_ROWPOSITIONLIBRARY) ) + { + *obj = &oledb_rowpos_cf; + return S_OK; + } return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/dlls/oledb32/oledb32_classes.idl b/dlls/oledb32/oledb32_classes.idl index a154b5746d1..e4b1e22baf3 100644 --- a/dlls/oledb32/oledb32_classes.idl +++ b/dlls/oledb32/oledb32_classes.idl @@ -41,3 +41,15 @@ coclass OLEDB_CONVERSIONLIBRARY coclass OLEDB_MSDAER { } + +[ + helpstring("OLE DB Row Position Library"), + threading(both), + progid("RowPosition.RowPosition.1"), + vi_progid("RowPosition.RowPosition"), + uuid(2048eee6-7fa2-11d0-9e6a-00a0c9138c29) +] +coclass OLEDB_ROWPOSITIONLIBRARY +{ + interface IRowPosition; +} diff --git a/dlls/oledb32/oledb_private.h b/dlls/oledb32/oledb_private.h index 349736947e7..3ff8d1d9ca3 100644 --- a/dlls/oledb32/oledb_private.h +++ b/dlls/oledb32/oledb_private.h @@ -20,3 +20,4 @@ HRESULT create_oledb_convert(IUnknown *outer, void **obj) DECLSPEC_HIDDEN; HRESULT create_data_init(IUnknown *outer, void **obj) DECLSPEC_HIDDEN; HRESULT create_error_info(IUnknown *outer, void **obj) DECLSPEC_HIDDEN; +HRESULT create_oledb_rowpos(IUnknown *outer, void **obj) DECLSPEC_HIDDEN; diff --git a/dlls/oledb32/rowpos.c b/dlls/oledb32/rowpos.c new file mode 100644 index 00000000000..c7581b731cb --- /dev/null +++ b/dlls/oledb32/rowpos.c @@ -0,0 +1,155 @@ +/* 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" + +#include "oledb.h" + +#include "oledb_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(oledb); + +typedef struct +{ + IRowPosition IRowPosition_iface; + LONG ref; +} rowpos; + +static inline rowpos *impl_from_IRowPosition(IRowPosition *iface) +{ + return CONTAINING_RECORD(iface, rowpos, IRowPosition_iface); +} + +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; + } + 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) + HeapFree(GetProcessHeap(), 0, This); + + return ref; +} + +static HRESULT WINAPI rowpos_ClearRowPosition(IRowPosition* iface) +{ + rowpos *This = impl_from_IRowPosition(iface); + FIXME("(%p): stub\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI rowpos_GetRowPosition(IRowPosition *iface, HCHAPTER *chapter, + HROW *row, DBPOSITIONFLAGS *flags) +{ + rowpos *This = impl_from_IRowPosition(iface); + FIXME("(%p)->(%p %p %p): stub\n", This, chapter, row, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI rowpos_GetRowset(IRowPosition *iface, REFIID riid, IUnknown **rowset) +{ + rowpos *This = impl_from_IRowPosition(iface); + FIXME("(%p)->(%s %p): stub\n", This, debugstr_guid(riid), rowset); + return E_NOTIMPL; +} + +static HRESULT WINAPI rowpos_Initialize(IRowPosition *iface, IUnknown *rowset) +{ + rowpos *This = impl_from_IRowPosition(iface); + FIXME("(%p)->(%p): stub\n", This, rowset); + return E_NOTIMPL; +} + +static HRESULT WINAPI rowpos_SetRowPosition(IRowPosition *iface, HCHAPTER chapter, + HROW row, DBPOSITIONFLAGS flags) +{ + rowpos *This = impl_from_IRowPosition(iface); + FIXME("(%p)->(%lx %lx %d): stub\n", This, chapter, row, flags); + return E_NOTIMPL; +} + +static const struct IRowPositionVtbl rowpos_vtbl = +{ + rowpos_QueryInterface, + rowpos_AddRef, + rowpos_Release, + rowpos_ClearRowPosition, + rowpos_GetRowPosition, + rowpos_GetRowset, + rowpos_Initialize, + rowpos_SetRowPosition +}; + +HRESULT create_oledb_rowpos(IUnknown *outer, void **obj) +{ + rowpos *This; + + TRACE("(%p, %p)\n", outer, obj); + + *obj = NULL; + + if(outer) return CLASS_E_NOAGGREGATION; + + This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); + if(!This) return E_OUTOFMEMORY; + + This->IRowPosition_iface.lpVtbl = &rowpos_vtbl; + This->ref = 1; + + *obj = &This->IRowPosition_iface; + + return S_OK; +} diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c index 840bb2a05b0..d54d546f184 100644 --- a/dlls/oledb32/tests/database.c +++ b/dlls/oledb32/tests/database.c @@ -28,6 +28,7 @@ #include "msdadc.h" #include "msdasc.h" #include "shlobj.h" +#include "msdaguid.h" #include "initguid.h" #include "wine/test.h" @@ -185,6 +186,17 @@ static void test_initializationstring(void) } } +static void test_rowposition(void) +{ + IRowPosition *rowpos; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IRowPosition, (void**)&rowpos); + ok(hr == S_OK, "got %08x\n", hr); + + IRowPosition_Release(rowpos); +} + START_TEST(database) { OleInitialize(NULL); @@ -193,5 +205,8 @@ START_TEST(database) test_errorinfo(); test_initializationstring(); + /* row position */ + test_rowposition(); + OleUninitialize(); } diff --git a/include/msdaguid.h b/include/msdaguid.h index 7ee9b56a126..d86ac232818 100644 --- a/include/msdaguid.h +++ b/include/msdaguid.h @@ -22,5 +22,6 @@ DEFINE_GUID(CLSID_EXTENDEDERRORINFO, 0xc8b522cf, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d); DEFINE_GUID(CLSID_OLEDB_ENUMERATOR, 0xc8b522d0, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d); DEFINE_GUID(CLSID_OLEDB_CONVERSIONLIBRARY, 0xc8b522d1, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d); +DEFINE_GUID(CLSID_OLEDB_ROWPOSITIONLIBRARY,0x2048eee6, 0x7fa2, 0x11d0, 0x9e, 0x6a, 0x00, 0xa0, 0xc9, 0x13, 0x8c, 0x29); #endif /*__WINE_MSDAGUID_H */