Commit 8f8212b8 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: Add support for IDBInitialize interface in IDataInitialize.

parent be246e31
......@@ -47,6 +47,110 @@ static inline datainit *impl_from_IDataInitialize(IDataInitialize *iface)
return CONTAINING_RECORD(iface, datainit, IDataInitialize_iface);
}
typedef struct
{
IDBInitialize IDBInitialize_iface;
LONG ref;
} dbinit;
static inline dbinit *impl_from_IDBInitialize(IDBInitialize *iface)
{
return CONTAINING_RECORD(iface, dbinit, IDBInitialize_iface);
}
static HRESULT WINAPI dbinit_QueryInterface(IDBInitialize *iface, REFIID riid, void **obj)
{
dbinit *This = impl_from_IDBInitialize(iface);
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
*obj = NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IDBInitialize))
{
*obj = iface;
}
else
{
FIXME("interface %s not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
IDBInitialize_AddRef(iface);
return S_OK;
}
static ULONG WINAPI dbinit_AddRef(IDBInitialize *iface)
{
dbinit *This = impl_from_IDBInitialize(iface);
TRACE("(%p)\n", This);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI dbinit_Release(IDBInitialize *iface)
{
dbinit *This = impl_from_IDBInitialize(iface);
LONG ref;
TRACE("(%p)\n", This);
ref = InterlockedDecrement(&This->ref);
if(ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI dbinit_Initialize(IDBInitialize *iface)
{
dbinit *This = impl_from_IDBInitialize(iface);
FIXME("(%p) stub\n", This);
return S_OK;
}
static HRESULT WINAPI dbinit_Uninitialize(IDBInitialize *iface)
{
dbinit *This = impl_from_IDBInitialize(iface);
FIXME("(%p) stub\n", This);
return S_OK;
}
static const IDBInitializeVtbl dbinit_vtbl =
{
dbinit_QueryInterface,
dbinit_AddRef,
dbinit_Release,
dbinit_Initialize,
dbinit_Uninitialize
};
static HRESULT create_db_init(void **obj)
{
dbinit *This;
TRACE("()\n");
*obj = NULL;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if(!This) return E_OUTOFMEMORY;
This->IDBInitialize_iface.lpVtbl = &dbinit_vtbl;
This->ref = 1;
*obj = &This->IDBInitialize_iface;
return S_OK;
}
static HRESULT WINAPI datainit_QueryInterface(IDataInitialize *iface, REFIID riid, void **obj)
{
datainit *This = impl_from_IDataInitialize(iface);
......@@ -102,6 +206,11 @@ static HRESULT WINAPI datainit_GetDataSource(IDataInitialize *iface, IUnknown *p
FIXME("(%p)->(%p %d %s %s %p)\n", This, pUnkOuter, dwClsCtx, debugstr_w(pwszInitializationString),
debugstr_guid(riid), ppDataSource);
if(IsEqualIID(riid, &IID_IDBInitialize))
{
return create_db_init( (LPVOID*)ppDataSource);
}
return E_NOTIMPL;
}
......
TESTDLL = oledb32.dll
IMPORTS = oleaut32 ole32 user32 gdi32 advapi32
IMPORTS = uuid oleaut32 ole32 user32 gdi32 advapi32
C_SRCS = \
convert.c \
database.c \
marshal.c
IDL_I_SRCS = convert.idl
......
......@@ -35,7 +35,6 @@
#include "wine/test.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static void test_dcinfo(void)
{
......
/* OLEDB Database tests
*
* Copyright 2012 Alistair Leslie-Hughes
*
* 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>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "msdadc.h"
#include "msdasc.h"
#include "wine/test.h"
void test_database(void)
{
HRESULT hr;
IDBInitialize *dbinit = NULL;
IDataInitialize *datainit = NULL;
hr = CoCreateInstance(&CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, &IID_IDataInitialize,(void**)&datainit);
if(FAILED(hr))
{
win_skip("Unable to load oledb library\n");
return;
}
hr = IDataInitialize_GetDataSource(datainit, NULL, CLSCTX_INPROC_SERVER, NULL, &IID_IDBInitialize, (IUnknown **)&dbinit);
ok(hr == S_OK, "got %08x\n", hr);
if(SUCCEEDED(hr))
{
IDBProperties *props = NULL;
hr = IDBInitialize_QueryInterface(dbinit, &IID_IDBProperties, (void**)&props);
todo_wine ok(hr == S_OK, "got %08x\n", hr);
if(SUCCEEDED(hr))
{
IDBProperties_Release(props);
}
IDBInitialize_Release(dbinit);
}
IDataInitialize_Release(datainit);
}
START_TEST(database)
{
OleInitialize(NULL);
test_database();
OleUninitialize();
}
......@@ -27,7 +27,6 @@
#include "windef.h"
#include "winbase.h"
#include "initguid.h"
#include "objbase.h"
#include "oledb.h"
......
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