msado15: Implement Dispatch functions in _Connection.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=16676
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2021-02-26 19:02:21 +11:00 committed by Alexandre Julliard
parent 5b836d1725
commit 079a963a27
3 changed files with 95 additions and 9 deletions

View File

@ -156,29 +156,57 @@ static HRESULT WINAPI connection_QueryInterface( _Connection *iface, REFIID riid
static HRESULT WINAPI connection_GetTypeInfoCount( _Connection *iface, UINT *count )
{
FIXME( "%p, %p\n", iface, count );
return E_NOTIMPL;
struct connection *connection = impl_from_Connection( iface );
TRACE( "%p, %p\n", connection, count );
*count = 1;
return S_OK;
}
static HRESULT WINAPI connection_GetTypeInfo( _Connection *iface, UINT index, LCID lcid, ITypeInfo **info )
{
FIXME( "%p, %u, %u, %p\n", iface, index, lcid, info );
return E_NOTIMPL;
struct connection *connection = impl_from_Connection( iface );
TRACE( "%p, %u, %u, %p\n", connection, index, lcid, info );
return get_typeinfo(Connection_tid, info);
}
static HRESULT WINAPI connection_GetIDsOfNames( _Connection *iface, REFIID riid, LPOLESTR *names, UINT count,
LCID lcid, DISPID *dispid )
{
FIXME( "%p, %s, %p, %u, %u, %p\n", iface, debugstr_guid(riid), names, count, lcid, dispid );
return E_NOTIMPL;
struct connection *connection = impl_from_Connection( iface );
HRESULT hr;
ITypeInfo *typeinfo;
TRACE( "%p, %s, %p, %u, %u, %p\n", connection, debugstr_guid(riid), names, count, lcid, dispid );
hr = get_typeinfo(Connection_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI connection_Invoke( _Connection *iface, DISPID member, REFIID riid, LCID lcid, WORD flags,
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err )
{
FIXME( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", iface, member, debugstr_guid(riid), lcid, flags, params,
result, excep_info, arg_err );
return E_NOTIMPL;
struct connection *connection = impl_from_Connection( iface );
HRESULT hr;
ITypeInfo *typeinfo;
TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", connection, member, debugstr_guid(riid), lcid, flags,
params, result, excep_info, arg_err );
hr = get_typeinfo(Connection_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_Invoke(typeinfo, &connection->Connection_iface, member, flags, params,
result, excep_info, arg_err);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI connection_get_Properties( _Connection *iface, Properties **obj )

View File

@ -174,3 +174,54 @@ HRESULT WINAPI DllUnregisterServer( void )
{
return __wine_unregister_resources( hinstance );
}
static ITypeLib *typelib;
static ITypeInfo *typeinfos[LAST_tid];
static REFIID tid_ids[] = {
&IID__Connection,
};
static HRESULT load_typelib(void)
{
HRESULT hres;
ITypeLib *tl;
if(typelib)
return S_OK;
hres = LoadRegTypeLib(&LIBID_ADODB, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
if(FAILED(hres)) {
ERR("LoadRegTypeLib failed: %08x\n", hres);
return hres;
}
if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
ITypeLib_Release(tl);
return hres;
}
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
{
HRESULT hres;
if (FAILED(hres = load_typelib()))
return hres;
if(!typeinfos[tid]) {
ITypeInfo *ti;
hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
if(FAILED(hres)) {
ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
return hres;
}
if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
ITypeInfo_Release(ti);
}
*typeinfo = typeinfos[tid];
ITypeInfo_AddRef(*typeinfo);
return S_OK;
}

View File

@ -42,4 +42,11 @@ static inline WCHAR *strdupW( const WCHAR *src )
return dst;
}
typedef enum tid_t {
Connection_tid,
LAST_tid
} tid_t;
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
#endif /* _WINE_MSADO15_PRIVATE_H_ */