Release 5.0-rc1.
[wine.git] / dlls / msado15 / connection.c
blob73b225628c2b02c5edde22ce57c51d319fd3b7b4
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 "objbase.h"
24 #include "msado15_backcompat.h"
26 #include "wine/debug.h"
27 #include "wine/heap.h"
29 #include "msado15_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
33 struct connection
35 _Connection Connection_iface;
36 ISupportErrorInfo ISupportErrorInfo_iface;
37 LONG refs;
38 ObjectStateEnum state;
39 LONG timeout;
42 static inline struct connection *impl_from_Connection( _Connection *iface )
44 return CONTAINING_RECORD( iface, struct connection, Connection_iface );
47 static inline struct connection *impl_from_ISupportErrorInfo( ISupportErrorInfo *iface )
49 return CONTAINING_RECORD( iface, struct connection, ISupportErrorInfo_iface );
52 static ULONG WINAPI connection_AddRef( _Connection *iface )
54 struct connection *connection = impl_from_Connection( iface );
55 return InterlockedIncrement( &connection->refs );
58 static ULONG WINAPI connection_Release( _Connection *iface )
60 struct connection *connection = impl_from_Connection( iface );
61 LONG refs = InterlockedDecrement( &connection->refs );
62 if (!refs)
64 TRACE( "destroying %p\n", connection );
65 heap_free( connection );
67 return refs;
70 static HRESULT WINAPI connection_QueryInterface( _Connection *iface, REFIID riid, void **obj )
72 struct connection *connection = impl_from_Connection( iface );
73 TRACE( "%p, %s, %p\n", connection, debugstr_guid(riid), obj );
75 if (IsEqualGUID( riid, &IID__Connection ) || IsEqualGUID( riid, &IID_IDispatch ) ||
76 IsEqualGUID( riid, &IID_IUnknown ))
78 *obj = iface;
80 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
82 *obj = &connection->ISupportErrorInfo_iface;
84 else
86 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
87 return E_NOINTERFACE;
89 connection_AddRef( iface );
90 return S_OK;
93 static HRESULT WINAPI connection_GetTypeInfoCount( _Connection *iface, UINT *count )
95 FIXME( "%p, %p\n", iface, count );
96 return E_NOTIMPL;
99 static HRESULT WINAPI connection_GetTypeInfo( _Connection *iface, UINT index, LCID lcid, ITypeInfo **info )
101 FIXME( "%p, %u, %u, %p\n", iface, index, lcid, info );
102 return E_NOTIMPL;
105 static HRESULT WINAPI connection_GetIDsOfNames( _Connection *iface, REFIID riid, LPOLESTR *names, UINT count,
106 LCID lcid, DISPID *dispid )
108 FIXME( "%p, %s, %p, %u, %u, %p\n", iface, debugstr_guid(riid), names, count, lcid, dispid );
109 return E_NOTIMPL;
112 static HRESULT WINAPI connection_Invoke( _Connection *iface, DISPID member, REFIID riid, LCID lcid, WORD flags,
113 DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err )
115 FIXME( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", iface, member, debugstr_guid(riid), lcid, flags, params,
116 result, excep_info, arg_err );
117 return E_NOTIMPL;
120 static HRESULT WINAPI connection_get_Properties( _Connection *iface, Properties **obj )
122 FIXME( "%p, %p\n", iface, obj );
123 return E_NOTIMPL;
126 static HRESULT WINAPI connection_get_ConnectionString( _Connection *iface, BSTR *str )
128 FIXME( "%p, %p\n", iface, str );
129 return E_NOTIMPL;
132 static HRESULT WINAPI connection_put_ConnectionString( _Connection *iface, BSTR str )
134 FIXME( "%p, %s\n", iface, debugstr_w(str) );
135 return E_NOTIMPL;
138 static HRESULT WINAPI connection_get_CommandTimeout( _Connection *iface, LONG *timeout )
140 struct connection *connection = impl_from_Connection( iface );
141 TRACE( "%p, %p\n", connection, timeout );
142 *timeout = connection->timeout;
143 return S_OK;
146 static HRESULT WINAPI connection_put_CommandTimeout( _Connection *iface, LONG timeout )
148 struct connection *connection = impl_from_Connection( iface );
149 TRACE( "%p, %d\n", connection, timeout );
150 connection->timeout = timeout;
151 return S_OK;
154 static HRESULT WINAPI connection_get_ConnectionTimeout( _Connection *iface, LONG *timeout )
156 FIXME( "%p, %p\n", iface, timeout );
157 return E_NOTIMPL;
160 static HRESULT WINAPI connection_put_ConnectionTimeout( _Connection *iface, LONG timeout )
162 FIXME( "%p, %d\n", iface, timeout );
163 return E_NOTIMPL;
166 static HRESULT WINAPI connection_get_Version( _Connection *iface, BSTR *str )
168 FIXME( "%p, %p\n", iface, str );
169 return E_NOTIMPL;
172 static HRESULT WINAPI connection_Close( _Connection *iface )
174 FIXME( "%p\n", iface );
175 return E_NOTIMPL;
178 static HRESULT WINAPI connection_Execute( _Connection *iface, BSTR command, VARIANT *records_affected,
179 LONG options, _Recordset **record_set )
181 FIXME( "%p, %s, %p, %08x, %p\n", iface, debugstr_w(command), records_affected, options, record_set );
182 return E_NOTIMPL;
185 static HRESULT WINAPI connection_BeginTrans( _Connection *iface, LONG *transaction_level )
187 FIXME( "%p, %p\n", iface, transaction_level );
188 return E_NOTIMPL;
191 static HRESULT WINAPI connection_CommitTrans( _Connection *iface )
193 FIXME( "%p\n", iface );
194 return E_NOTIMPL;
197 static HRESULT WINAPI connection_RollbackTrans( _Connection *iface )
199 FIXME( "%p\n", iface );
200 return E_NOTIMPL;
203 static HRESULT WINAPI connection_Open( _Connection *iface, BSTR connect_str, BSTR userid, BSTR password,
204 LONG options )
206 FIXME( "%p, %s, %s, %p, %08x\n", iface, debugstr_w(connect_str), debugstr_w(userid),
207 password, options );
208 return E_NOTIMPL;
211 static HRESULT WINAPI connection_get_Errors( _Connection *iface, Errors **obj )
213 FIXME( "%p, %p\n", iface, obj );
214 return E_NOTIMPL;
217 static HRESULT WINAPI connection_get_DefaultDatabase( _Connection *iface, BSTR *str )
219 FIXME( "%p, %p\n", iface, str );
220 return E_NOTIMPL;
223 static HRESULT WINAPI connection_put_DefaultDatabase( _Connection *iface, BSTR str )
225 FIXME( "%p, %s\n", iface, debugstr_w(str) );
226 return E_NOTIMPL;
229 static HRESULT WINAPI connection_get_IsolationLevel( _Connection *iface, IsolationLevelEnum *level )
231 FIXME( "%p, %p\n", iface, level );
232 return E_NOTIMPL;
235 static HRESULT WINAPI connection_put_IsolationLevel( _Connection *iface, IsolationLevelEnum level )
237 FIXME( "%p, %d\n", iface, level );
238 return E_NOTIMPL;
241 static HRESULT WINAPI connection_get_Attributes( _Connection *iface, LONG *attr )
243 FIXME( "%p, %p\n", iface, attr );
244 return E_NOTIMPL;
247 static HRESULT WINAPI connection_put_Attributes( _Connection *iface, LONG attr )
249 FIXME( "%p, %d\n", iface, attr );
250 return E_NOTIMPL;
253 static HRESULT WINAPI connection_get_CursorLocation( _Connection *iface, CursorLocationEnum *cursor_loc )
255 FIXME( "%p, %p\n", iface, cursor_loc );
256 return E_NOTIMPL;
259 static HRESULT WINAPI connection_put_CursorLocation( _Connection *iface, CursorLocationEnum cursor_loc )
261 FIXME( "%p, %u\n", iface, cursor_loc );
262 return E_NOTIMPL;
265 static HRESULT WINAPI connection_get_Mode( _Connection *iface, ConnectModeEnum *mode )
267 FIXME( "%p, %p\n", iface, mode );
268 return E_NOTIMPL;
271 static HRESULT WINAPI connection_put_Mode( _Connection *iface, ConnectModeEnum mode )
273 FIXME( "%p, %u\n", iface, mode );
274 return E_NOTIMPL;
277 static HRESULT WINAPI connection_get_Provider( _Connection *iface, BSTR *str )
279 FIXME( "%p, %p\n", iface, str );
280 return E_NOTIMPL;
283 static HRESULT WINAPI connection_put_Provider( _Connection *iface, BSTR str )
285 FIXME( "%p, %s\n", iface, debugstr_w(str) );
286 return E_NOTIMPL;
289 static HRESULT WINAPI connection_get_State( _Connection *iface, LONG *state )
291 struct connection *connection = impl_from_Connection( iface );
292 TRACE( "%p, %p\n", connection, state );
293 *state = connection->state;
294 return S_OK;
297 static HRESULT WINAPI connection_OpenSchema( _Connection *iface, SchemaEnum schema, VARIANT restrictions,
298 VARIANT schema_id, _Recordset **record_set )
300 FIXME( "%p, %d, %s, %s, %p\n", iface, schema, debugstr_variant(&restrictions),
301 debugstr_variant(&schema_id), record_set );
302 return E_NOTIMPL;
305 static HRESULT WINAPI connection_Cancel( _Connection *iface )
307 FIXME( "%p\n", iface );
308 return E_NOTIMPL;
311 static const struct _ConnectionVtbl connection_vtbl =
313 connection_QueryInterface,
314 connection_AddRef,
315 connection_Release,
316 connection_GetTypeInfoCount,
317 connection_GetTypeInfo,
318 connection_GetIDsOfNames,
319 connection_Invoke,
320 connection_get_Properties,
321 connection_get_ConnectionString,
322 connection_put_ConnectionString,
323 connection_get_CommandTimeout,
324 connection_put_CommandTimeout,
325 connection_get_ConnectionTimeout,
326 connection_put_ConnectionTimeout,
327 connection_get_Version,
328 connection_Close,
329 connection_Execute,
330 connection_BeginTrans,
331 connection_CommitTrans,
332 connection_RollbackTrans,
333 connection_Open,
334 connection_get_Errors,
335 connection_get_DefaultDatabase,
336 connection_put_DefaultDatabase,
337 connection_get_IsolationLevel,
338 connection_put_IsolationLevel,
339 connection_get_Attributes,
340 connection_put_Attributes,
341 connection_get_CursorLocation,
342 connection_put_CursorLocation,
343 connection_get_Mode,
344 connection_put_Mode,
345 connection_get_Provider,
346 connection_put_Provider,
347 connection_get_State,
348 connection_OpenSchema,
349 connection_Cancel
352 static HRESULT WINAPI supporterror_QueryInterface( ISupportErrorInfo *iface, REFIID riid, void **obj )
354 struct connection *connection = impl_from_ISupportErrorInfo( iface );
355 return connection_QueryInterface( &connection->Connection_iface, riid, obj );
358 static ULONG WINAPI supporterror_AddRef( ISupportErrorInfo *iface )
360 struct connection *connection = impl_from_ISupportErrorInfo( iface );
361 return connection_AddRef( &connection->Connection_iface );
364 static ULONG WINAPI supporterror_Release( ISupportErrorInfo *iface )
366 struct connection *connection = impl_from_ISupportErrorInfo( iface );
367 return connection_Release( &connection->Connection_iface );
370 static HRESULT WINAPI supporterror_InterfaceSupportsErrorInfo( ISupportErrorInfo *iface, REFIID riid )
372 struct connection *connection = impl_from_ISupportErrorInfo( iface );
373 FIXME( "%p, %s\n", connection, debugstr_guid(riid) );
374 return S_FALSE;
377 static const struct ISupportErrorInfoVtbl support_error_vtbl =
379 supporterror_QueryInterface,
380 supporterror_AddRef,
381 supporterror_Release,
382 supporterror_InterfaceSupportsErrorInfo
385 HRESULT Connection_create( void **obj )
387 struct connection *connection;
389 if (!(connection = heap_alloc( sizeof(*connection) ))) return E_OUTOFMEMORY;
390 connection->Connection_iface.lpVtbl = &connection_vtbl;
391 connection->ISupportErrorInfo_iface.lpVtbl = &support_error_vtbl;
392 connection->refs = 1;
393 connection->state = adStateClosed;
394 connection->timeout = 30;
396 *obj = &connection->Connection_iface;
397 TRACE( "returning iface %p\n", *obj );
398 return S_OK;