oledb32: Add IErrorInfo Support
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Fri Jun 14 05:12:58 CDT 2013
Hi,
Changelog:
oledb32: Add IErrorInfo Support
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 55923ff743f9f3b40dbd9e764b1bf43fd05e875c Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 14 Jun 2013 10:23:43 +1000
Subject: [PATCH] Add IErrorInfo Support
To: wine-patches <wine-patches at winehq.org>
---
dlls/oledb32/Makefile.in | 1 +
dlls/oledb32/errorinfo.c | 200 +++++++++++++++++++++++++++++++++++++++
dlls/oledb32/main.c | 8 ++
dlls/oledb32/oledb32_classes.idl | 11 +++
dlls/oledb32/oledb_private.h | 1 +
dlls/oledb32/tests/database.c | 26 +++++
6 files changed, 247 insertions(+)
create mode 100644 dlls/oledb32/errorinfo.c
diff --git a/dlls/oledb32/Makefile.in b/dlls/oledb32/Makefile.in
index 71e352b..2da63ad 100644
--- a/dlls/oledb32/Makefile.in
+++ b/dlls/oledb32/Makefile.in
@@ -5,6 +5,7 @@ IMPORTS = uuid oleaut32 ole32 user32 advapi32
C_SRCS = \
convert.c \
datainit.c \
+ errorinfo.c \
main.c
IDL_I_SRCS = convert.idl
diff --git a/dlls/oledb32/errorinfo.c b/dlls/oledb32/errorinfo.c
new file mode 100644
index 0000000..00f2dfc
--- /dev/null
+++ b/dlls/oledb32/errorinfo.c
@@ -0,0 +1,200 @@
+/* OLE DB ErrorInfo
+ *
+ * Copyright 2013 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>
+#include <string.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "oleauto.h"
+#include "winerror.h"
+
+#include "wine/unicode.h"
+#include "oledb_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(oledb);
+
+typedef struct ErrorInfoImpl
+{
+ IErrorInfo IErrorInfo_iface;
+ LONG ref;
+
+ GUID m_Guid;
+ WCHAR *source;
+ WCHAR *description;
+ WCHAR *help_file;
+ DWORD m_dwHelpContext;
+} ErrorInfoImpl;
+
+static inline ErrorInfoImpl *impl_from_IErrorInfo( IErrorInfo *iface )
+{
+ return CONTAINING_RECORD(iface, ErrorInfoImpl, IErrorInfo_iface);
+}
+
+static HRESULT WINAPI IErrorInfoImpl_QueryInterface(IErrorInfo* iface, REFIID riid, void **ppvoid)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+ TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid),ppvoid);
+
+ *ppvoid = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IErrorInfo))
+ {
+ *ppvoid = &This->IErrorInfo_iface;
+ }
+
+ if(*ppvoid)
+ {
+ IUnknown_AddRef( (IUnknown*)*ppvoid );
+ TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
+ return S_OK;
+ }
+ TRACE("-- Interface: E_NOINTERFACE\n");
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IErrorInfoImpl_AddRef(IErrorInfo* iface)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+ TRACE("(%p)->(count=%u)\n",This,This->ref);
+ return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo* iface)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p)->(count=%u)\n",This,ref+1);
+
+ if (!ref)
+ {
+ TRACE("-- destroying IErrorInfo(%p)\n",This);
+
+ HeapFree(GetProcessHeap(), 0, This->source);
+ HeapFree(GetProcessHeap(), 0, This->description);
+ HeapFree(GetProcessHeap(), 0, This->help_file);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+static HRESULT WINAPI IErrorInfoImpl_GetGUID(IErrorInfo* iface, GUID * pGUID)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+
+ TRACE("(%p)->(count=%u)\n",This,This->ref);
+
+ if(!pGUID )
+ return E_INVALIDARG;
+ *pGUID = This->m_Guid;
+ return S_OK;
+}
+
+static HRESULT WINAPI IErrorInfoImpl_GetSource(IErrorInfo* iface, BSTR *pBstrSource)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+
+ TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
+
+ if (pBstrSource == NULL)
+ return E_INVALIDARG;
+ *pBstrSource = SysAllocString(This->source);
+ return S_OK;
+}
+
+static HRESULT WINAPI IErrorInfoImpl_GetDescription(IErrorInfo* iface, BSTR *pBstrDescription)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+
+ TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
+
+ if (pBstrDescription == NULL)
+ return E_INVALIDARG;
+ *pBstrDescription = SysAllocString(This->description);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(IErrorInfo* iface, BSTR *pBstrHelpFile)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+
+ TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
+ if (pBstrHelpFile == NULL)
+ return E_INVALIDARG;
+ *pBstrHelpFile = SysAllocString(This->help_file);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI IErrorInfoImpl_GetHelpContext(IErrorInfo* iface, DWORD *pdwHelpContext)
+{
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
+
+ TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
+
+ if (pdwHelpContext == NULL)
+ return E_INVALIDARG;
+ *pdwHelpContext = This->m_dwHelpContext;
+
+ return S_OK;
+}
+
+static const IErrorInfoVtbl ErrorInfoVtbl =
+{
+ IErrorInfoImpl_QueryInterface,
+ IErrorInfoImpl_AddRef,
+ IErrorInfoImpl_Release,
+ IErrorInfoImpl_GetGUID,
+ IErrorInfoImpl_GetSource,
+ IErrorInfoImpl_GetDescription,
+ IErrorInfoImpl_GetHelpFile,
+ IErrorInfoImpl_GetHelpContext
+};
+
+
+HRESULT create_error_info(IUnknown *outer, void **obj)
+{
+ ErrorInfoImpl *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->IErrorInfo_iface.lpVtbl = &ErrorInfoVtbl;
+ This->ref = 1;
+ This->source = NULL;
+ This->description = NULL;
+ This->help_file = NULL;
+ This->m_dwHelpContext = 0;
+
+ *obj = &This->IErrorInfo_iface;
+
+ return S_OK;
+}
diff --git a/dlls/oledb32/main.c b/dlls/oledb32/main.c
index 88556b9..838e6d1 100644
--- a/dlls/oledb32/main.c
+++ b/dlls/oledb32/main.c
@@ -40,6 +40,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(oledb);
static HINSTANCE instance;
+DEFINE_GUID(CSLID_MSDAER, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
+
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID lpv)
{
switch(reason)
@@ -126,6 +128,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 };
/******************************************************************
* DllGetClassObject
@@ -144,6 +147,11 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
*obj = &oledb_datainit_cf;
return S_OK;
}
+ else if ( IsEqualCLSID (rclsid, &CSLID_MSDAER) )
+ {
+ *obj = &oledb_errorinfo_cf;
+ return S_OK;
+ }
return CLASS_E_CLASSNOTAVAILABLE;
}
diff --git a/dlls/oledb32/oledb32_classes.idl b/dlls/oledb32/oledb32_classes.idl
index 0ffb7e4..a154b57 100644
--- a/dlls/oledb32/oledb32_classes.idl
+++ b/dlls/oledb32/oledb32_classes.idl
@@ -30,3 +30,14 @@ coclass OLEDB_CONVERSIONLIBRARY
interface IDataConvert;
interface IDCInfo;
}
+
+[
+ helpstring("OLE DB Error Collection Service"),
+ threading(both),
+ progid("MSDAER.1"),
+ vi_progid("MSDAER"),
+ uuid(C8B522CF-5CF3-11CE-ADE5-00AA0044773D)
+]
+coclass OLEDB_MSDAER
+{
+}
diff --git a/dlls/oledb32/oledb_private.h b/dlls/oledb32/oledb_private.h
index ad5d67f..3497369 100644
--- a/dlls/oledb32/oledb_private.h
+++ b/dlls/oledb32/oledb_private.h
@@ -19,3 +19,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;
diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c
index 518bba7..b053804 100644
--- a/dlls/oledb32/tests/database.c
+++ b/dlls/oledb32/tests/database.c
@@ -28,9 +28,12 @@
#include "msdadc.h"
#include "msdasc.h"
#include "shlobj.h"
+#include "initguid.h"
#include "wine/test.h"
+DEFINE_GUID(CSLID_MSDAER, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
+
static void test_GetDataSource(WCHAR *initstring)
{
IDataInitialize *datainit = NULL;
@@ -113,11 +116,34 @@ static void test_database(void)
test_GetDataSource(initstring_default);
}
+static void test_errorinfo(void)
+{
+ HRESULT hr;
+ IUnknown *unk = NULL;
+
+ hr = CoCreateInstance(&CSLID_MSDAER, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(void**)&unk);
+ ok(hr == S_OK, "got %08x\n", hr);
+ if(hr == S_OK)
+ {
+ IErrorInfo *errorinfo;
+
+ hr = IUnknown_QueryInterface(unk, &IID_IErrorInfo, (void**)&errorinfo);
+ ok(hr == S_OK, "got %08x\n", hr);
+ if(hr == S_OK)
+ {
+ IErrorInfo_Release(errorinfo);
+ }
+
+ IUnknown_Release(unk);
+ }
+}
+
START_TEST(database)
{
OleInitialize(NULL);
test_database();
+ test_errorinfo();
OleUninitialize();
}
--
1.8.1.2
More information about the wine-patches
mailing list