msado15: Add IConnectionPointContainer stub to _Connection.
[wine.git] / dlls / msado15 / connection.c
blob8ed39a3a518461da33255234b27fc6fff8d12b8b
1 /*
2 * Copyright 2019 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #define COBJMACROS
23 #include "initguid.h"
24 #include "ocidl.h"
25 #include "objbase.h"
26 #include "msado15_backcompat.h"
28 #include "wine/debug.h"
29 #include "wine/heap.h"
31 #include "msado15_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
35 struct connection
37 _Connection Connection_iface;
38 ISupportErrorInfo ISupportErrorInfo_iface;
39 IConnectionPointContainer IConnectionPointContainer_iface;
40 LONG refs;
41 ObjectStateEnum state;
42 LONG timeout;
43 WCHAR *datasource;
46 static inline struct connection *impl_from_Connection( _Connection *iface )
48 return CONTAINING_RECORD( iface, struct connection, Connection_iface );
51 static inline struct connection *impl_from_ISupportErrorInfo( ISupportErrorInfo *iface )
53 return CONTAINING_RECORD( iface, struct connection, ISupportErrorInfo_iface );
56 static inline struct connection *impl_from_IConnectionPointContainer( IConnectionPointContainer *iface )
58 return CONTAINING_RECORD( iface, struct connection, IConnectionPointContainer_iface );
61 static ULONG WINAPI connection_AddRef( _Connection *iface )
63 struct connection *connection = impl_from_Connection( iface );
64 return InterlockedIncrement( &connection->refs );
67 static ULONG WINAPI connection_Release( _Connection *iface )
69 struct connection *connection = impl_from_Connection( iface );
70 LONG refs = InterlockedDecrement( &connection->refs );
71 if (!refs)
73 TRACE( "destroying %p\n", connection );
74 heap_free( connection->datasource );
75 heap_free( connection );
77 return refs;
80 static HRESULT WINAPI connection_QueryInterface( _Connection *iface, REFIID riid, void **obj )
82 struct connection *connection = impl_from_Connection( iface );
83 TRACE( "%p, %s, %p\n", connection, debugstr_guid(riid), obj );
85 if (IsEqualGUID( riid, &IID__Connection ) || IsEqualGUID( riid, &IID_IDispatch ) ||
86 IsEqualGUID( riid, &IID_IUnknown ))
88 *obj = iface;
90 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
92 *obj = &connection->ISupportErrorInfo_iface;
94 else if (IsEqualGUID( riid, &IID_IConnectionPointContainer ))
96 *obj = &connection->IConnectionPointContainer_iface;
98 else
100 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
101 return E_NOINTERFACE;
103 connection_AddRef( iface );
104 return S_OK;
107 static HRESULT WINAPI connection_GetTypeInfoCount( _Connection *iface, UINT *count )
109 FIXME( "%p, %p\n", iface, count );
110 return E_NOTIMPL;
113 static HRESULT WINAPI connection_GetTypeInfo( _Connection *iface, UINT index, LCID lcid, ITypeInfo **info )
115 FIXME( "%p, %u, %u, %p\n", iface, index, lcid, info );
116 return E_NOTIMPL;
119 static HRESULT WINAPI connection_GetIDsOfNames( _Connection *iface, REFIID riid, LPOLESTR *names, UINT count,
120 LCID lcid, DISPID *dispid )
122 FIXME( "%p, %s, %p, %u, %u, %p\n", iface, debugstr_guid(riid), names, count, lcid, dispid );
123 return E_NOTIMPL;
126 static HRESULT WINAPI connection_Invoke( _Connection *iface, DISPID member, REFIID riid, LCID lcid, WORD flags,
127 DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err )
129 FIXME( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", iface, member, debugstr_guid(riid), lcid, flags, params,
130 result, excep_info, arg_err );
131 return E_NOTIMPL;
134 static HRESULT WINAPI connection_get_Properties( _Connection *iface, Properties **obj )
136 FIXME( "%p, %p\n", iface, obj );
137 return E_NOTIMPL;
140 static HRESULT WINAPI connection_get_ConnectionString( _Connection *iface, BSTR *str )
142 struct connection *connection = impl_from_Connection( iface );
143 BSTR source = NULL;
145 TRACE( "%p, %p\n", connection, str );
147 if (connection->datasource && !(source = SysAllocString( connection->datasource ))) return E_OUTOFMEMORY;
148 *str = source;
149 return S_OK;
152 static HRESULT WINAPI connection_put_ConnectionString( _Connection *iface, BSTR str )
154 struct connection *connection = impl_from_Connection( iface );
155 WCHAR *source = NULL;
157 TRACE( "%p, %s\n", connection, debugstr_w( !wcsstr( str, L"Password" ) ? L"<hidden>" : str ) );
159 if (str && !(source = strdupW( str ))) return E_OUTOFMEMORY;
160 heap_free( connection->datasource );
161 connection->datasource = source;
162 return S_OK;
165 static HRESULT WINAPI connection_get_CommandTimeout( _Connection *iface, LONG *timeout )
167 struct connection *connection = impl_from_Connection( iface );
168 TRACE( "%p, %p\n", connection, timeout );
169 *timeout = connection->timeout;
170 return S_OK;
173 static HRESULT WINAPI connection_put_CommandTimeout( _Connection *iface, LONG timeout )
175 struct connection *connection = impl_from_Connection( iface );
176 TRACE( "%p, %d\n", connection, timeout );
177 connection->timeout = timeout;
178 return S_OK;
181 static HRESULT WINAPI connection_get_ConnectionTimeout( _Connection *iface, LONG *timeout )
183 FIXME( "%p, %p\n", iface, timeout );
184 return E_NOTIMPL;
187 static HRESULT WINAPI connection_put_ConnectionTimeout( _Connection *iface, LONG timeout )
189 FIXME( "%p, %d\n", iface, timeout );
190 return E_NOTIMPL;
193 static HRESULT WINAPI connection_get_Version( _Connection *iface, BSTR *str )
195 FIXME( "%p, %p\n", iface, str );
196 return E_NOTIMPL;
199 static HRESULT WINAPI connection_Close( _Connection *iface )
201 FIXME( "%p\n", iface );
202 return E_NOTIMPL;
205 static HRESULT WINAPI connection_Execute( _Connection *iface, BSTR command, VARIANT *records_affected,
206 LONG options, _Recordset **record_set )
208 FIXME( "%p, %s, %p, %08x, %p\n", iface, debugstr_w(command), records_affected, options, record_set );
209 return E_NOTIMPL;
212 static HRESULT WINAPI connection_BeginTrans( _Connection *iface, LONG *transaction_level )
214 FIXME( "%p, %p\n", iface, transaction_level );
215 return E_NOTIMPL;
218 static HRESULT WINAPI connection_CommitTrans( _Connection *iface )
220 FIXME( "%p\n", iface );
221 return E_NOTIMPL;
224 static HRESULT WINAPI connection_RollbackTrans( _Connection *iface )
226 FIXME( "%p\n", iface );
227 return E_NOTIMPL;
230 static HRESULT WINAPI connection_Open( _Connection *iface, BSTR connect_str, BSTR userid, BSTR password,
231 LONG options )
233 FIXME( "%p, %s, %s, %p, %08x\n", iface, debugstr_w(connect_str), debugstr_w(userid),
234 password, options );
235 return E_NOTIMPL;
238 static HRESULT WINAPI connection_get_Errors( _Connection *iface, Errors **obj )
240 FIXME( "%p, %p\n", iface, obj );
241 return E_NOTIMPL;
244 static HRESULT WINAPI connection_get_DefaultDatabase( _Connection *iface, BSTR *str )
246 FIXME( "%p, %p\n", iface, str );
247 return E_NOTIMPL;
250 static HRESULT WINAPI connection_put_DefaultDatabase( _Connection *iface, BSTR str )
252 FIXME( "%p, %s\n", iface, debugstr_w(str) );
253 return E_NOTIMPL;
256 static HRESULT WINAPI connection_get_IsolationLevel( _Connection *iface, IsolationLevelEnum *level )
258 FIXME( "%p, %p\n", iface, level );
259 return E_NOTIMPL;
262 static HRESULT WINAPI connection_put_IsolationLevel( _Connection *iface, IsolationLevelEnum level )
264 FIXME( "%p, %d\n", iface, level );
265 return E_NOTIMPL;
268 static HRESULT WINAPI connection_get_Attributes( _Connection *iface, LONG *attr )
270 FIXME( "%p, %p\n", iface, attr );
271 return E_NOTIMPL;
274 static HRESULT WINAPI connection_put_Attributes( _Connection *iface, LONG attr )
276 FIXME( "%p, %d\n", iface, attr );
277 return E_NOTIMPL;
280 static HRESULT WINAPI connection_get_CursorLocation( _Connection *iface, CursorLocationEnum *cursor_loc )
282 FIXME( "%p, %p\n", iface, cursor_loc );
283 return E_NOTIMPL;
286 static HRESULT WINAPI connection_put_CursorLocation( _Connection *iface, CursorLocationEnum cursor_loc )
288 FIXME( "%p, %u\n", iface, cursor_loc );
289 return E_NOTIMPL;
292 static HRESULT WINAPI connection_get_Mode( _Connection *iface, ConnectModeEnum *mode )
294 FIXME( "%p, %p\n", iface, mode );
295 return E_NOTIMPL;
298 static HRESULT WINAPI connection_put_Mode( _Connection *iface, ConnectModeEnum mode )
300 FIXME( "%p, %u\n", iface, mode );
301 return E_NOTIMPL;
304 static HRESULT WINAPI connection_get_Provider( _Connection *iface, BSTR *str )
306 FIXME( "%p, %p\n", iface, str );
307 return E_NOTIMPL;
310 static HRESULT WINAPI connection_put_Provider( _Connection *iface, BSTR str )
312 FIXME( "%p, %s\n", iface, debugstr_w(str) );
313 return E_NOTIMPL;
316 static HRESULT WINAPI connection_get_State( _Connection *iface, LONG *state )
318 struct connection *connection = impl_from_Connection( iface );
319 TRACE( "%p, %p\n", connection, state );
320 *state = connection->state;
321 return S_OK;
324 static HRESULT WINAPI connection_OpenSchema( _Connection *iface, SchemaEnum schema, VARIANT restrictions,
325 VARIANT schema_id, _Recordset **record_set )
327 FIXME( "%p, %d, %s, %s, %p\n", iface, schema, debugstr_variant(&restrictions),
328 debugstr_variant(&schema_id), record_set );
329 return E_NOTIMPL;
332 static HRESULT WINAPI connection_Cancel( _Connection *iface )
334 FIXME( "%p\n", iface );
335 return E_NOTIMPL;
338 static const struct _ConnectionVtbl connection_vtbl =
340 connection_QueryInterface,
341 connection_AddRef,
342 connection_Release,
343 connection_GetTypeInfoCount,
344 connection_GetTypeInfo,
345 connection_GetIDsOfNames,
346 connection_Invoke,
347 connection_get_Properties,
348 connection_get_ConnectionString,
349 connection_put_ConnectionString,
350 connection_get_CommandTimeout,
351 connection_put_CommandTimeout,
352 connection_get_ConnectionTimeout,
353 connection_put_ConnectionTimeout,
354 connection_get_Version,
355 connection_Close,
356 connection_Execute,
357 connection_BeginTrans,
358 connection_CommitTrans,
359 connection_RollbackTrans,
360 connection_Open,
361 connection_get_Errors,
362 connection_get_DefaultDatabase,
363 connection_put_DefaultDatabase,
364 connection_get_IsolationLevel,
365 connection_put_IsolationLevel,
366 connection_get_Attributes,
367 connection_put_Attributes,
368 connection_get_CursorLocation,
369 connection_put_CursorLocation,
370 connection_get_Mode,
371 connection_put_Mode,
372 connection_get_Provider,
373 connection_put_Provider,
374 connection_get_State,
375 connection_OpenSchema,
376 connection_Cancel
379 static HRESULT WINAPI supporterror_QueryInterface( ISupportErrorInfo *iface, REFIID riid, void **obj )
381 struct connection *connection = impl_from_ISupportErrorInfo( iface );
382 return connection_QueryInterface( &connection->Connection_iface, riid, obj );
385 static ULONG WINAPI supporterror_AddRef( ISupportErrorInfo *iface )
387 struct connection *connection = impl_from_ISupportErrorInfo( iface );
388 return connection_AddRef( &connection->Connection_iface );
391 static ULONG WINAPI supporterror_Release( ISupportErrorInfo *iface )
393 struct connection *connection = impl_from_ISupportErrorInfo( iface );
394 return connection_Release( &connection->Connection_iface );
397 static HRESULT WINAPI supporterror_InterfaceSupportsErrorInfo( ISupportErrorInfo *iface, REFIID riid )
399 struct connection *connection = impl_from_ISupportErrorInfo( iface );
400 FIXME( "%p, %s\n", connection, debugstr_guid(riid) );
401 return S_FALSE;
404 static const struct ISupportErrorInfoVtbl support_error_vtbl =
406 supporterror_QueryInterface,
407 supporterror_AddRef,
408 supporterror_Release,
409 supporterror_InterfaceSupportsErrorInfo
412 static HRESULT WINAPI connpointcontainer_QueryInterface( IConnectionPointContainer *iface,
413 REFIID riid, void **obj )
415 struct connection *connection = impl_from_IConnectionPointContainer( iface );
416 return connection_QueryInterface( &connection->Connection_iface, riid, obj );
419 static ULONG WINAPI connpointcontainer_AddRef( IConnectionPointContainer *iface )
421 struct connection *connection = impl_from_IConnectionPointContainer( iface );
422 return connection_AddRef( &connection->Connection_iface );
425 static ULONG WINAPI connpointcontainer_Release( IConnectionPointContainer *iface )
427 struct connection *connection = impl_from_IConnectionPointContainer( iface );
428 return connection_Release( &connection->Connection_iface );
431 static HRESULT WINAPI connpointcontainer_EnumConnectionPoints( IConnectionPointContainer *iface,
432 IEnumConnectionPoints **points )
434 struct connection *connection = impl_from_IConnectionPointContainer( iface );
435 FIXME( "%p, %p\n", connection, points );
436 return E_NOTIMPL;
439 static HRESULT WINAPI connpointcontainer_FindConnectionPoint( IConnectionPointContainer *iface,
440 REFIID riid, IConnectionPoint **point )
442 struct connection *connection = impl_from_IConnectionPointContainer( iface );
443 FIXME( "%p, %s, %p\n", connection, debugstr_guid( riid ), point );
444 return E_NOTIMPL;
447 static const struct IConnectionPointContainerVtbl connpointcontainer_vtbl =
449 connpointcontainer_QueryInterface,
450 connpointcontainer_AddRef,
451 connpointcontainer_Release,
452 connpointcontainer_EnumConnectionPoints,
453 connpointcontainer_FindConnectionPoint
456 HRESULT Connection_create( void **obj )
458 struct connection *connection;
460 if (!(connection = heap_alloc( sizeof(*connection) ))) return E_OUTOFMEMORY;
461 connection->Connection_iface.lpVtbl = &connection_vtbl;
462 connection->ISupportErrorInfo_iface.lpVtbl = &support_error_vtbl;
463 connection->IConnectionPointContainer_iface.lpVtbl = &connpointcontainer_vtbl;
464 connection->refs = 1;
465 connection->state = adStateClosed;
466 connection->timeout = 30;
467 connection->datasource = NULL;
469 *obj = &connection->Connection_iface;
470 TRACE( "returning iface %p\n", *obj );
471 return S_OK;