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
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
);
35 _Connection Connection_iface
;
36 ISupportErrorInfo ISupportErrorInfo_iface
;
38 ObjectStateEnum state
;
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
);
64 TRACE( "destroying %p\n", connection
);
65 heap_free( connection
);
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
))
80 else if(IsEqualGUID( riid
, &IID_ISupportErrorInfo
))
82 *obj
= &connection
->ISupportErrorInfo_iface
;
86 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
89 connection_AddRef( iface
);
93 static HRESULT WINAPI
connection_GetTypeInfoCount( _Connection
*iface
, UINT
*count
)
95 FIXME( "%p, %p\n", iface
, count
);
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
);
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
);
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
);
120 static HRESULT WINAPI
connection_get_Properties( _Connection
*iface
, Properties
**obj
)
122 FIXME( "%p, %p\n", iface
, obj
);
126 static HRESULT WINAPI
connection_get_ConnectionString( _Connection
*iface
, BSTR
*str
)
128 FIXME( "%p, %p\n", iface
, str
);
132 static HRESULT WINAPI
connection_put_ConnectionString( _Connection
*iface
, BSTR str
)
134 FIXME( "%p, %s\n", iface
, debugstr_w(str
) );
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
;
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
;
154 static HRESULT WINAPI
connection_get_ConnectionTimeout( _Connection
*iface
, LONG
*timeout
)
156 FIXME( "%p, %p\n", iface
, timeout
);
160 static HRESULT WINAPI
connection_put_ConnectionTimeout( _Connection
*iface
, LONG timeout
)
162 FIXME( "%p, %d\n", iface
, timeout
);
166 static HRESULT WINAPI
connection_get_Version( _Connection
*iface
, BSTR
*str
)
168 FIXME( "%p, %p\n", iface
, str
);
172 static HRESULT WINAPI
connection_Close( _Connection
*iface
)
174 FIXME( "%p\n", iface
);
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
);
185 static HRESULT WINAPI
connection_BeginTrans( _Connection
*iface
, LONG
*transaction_level
)
187 FIXME( "%p, %p\n", iface
, transaction_level
);
191 static HRESULT WINAPI
connection_CommitTrans( _Connection
*iface
)
193 FIXME( "%p\n", iface
);
197 static HRESULT WINAPI
connection_RollbackTrans( _Connection
*iface
)
199 FIXME( "%p\n", iface
);
203 static HRESULT WINAPI
connection_Open( _Connection
*iface
, BSTR connect_str
, BSTR userid
, BSTR password
,
206 FIXME( "%p, %s, %s, %p, %08x\n", iface
, debugstr_w(connect_str
), debugstr_w(userid
),
211 static HRESULT WINAPI
connection_get_Errors( _Connection
*iface
, Errors
**obj
)
213 FIXME( "%p, %p\n", iface
, obj
);
217 static HRESULT WINAPI
connection_get_DefaultDatabase( _Connection
*iface
, BSTR
*str
)
219 FIXME( "%p, %p\n", iface
, str
);
223 static HRESULT WINAPI
connection_put_DefaultDatabase( _Connection
*iface
, BSTR str
)
225 FIXME( "%p, %s\n", iface
, debugstr_w(str
) );
229 static HRESULT WINAPI
connection_get_IsolationLevel( _Connection
*iface
, IsolationLevelEnum
*level
)
231 FIXME( "%p, %p\n", iface
, level
);
235 static HRESULT WINAPI
connection_put_IsolationLevel( _Connection
*iface
, IsolationLevelEnum level
)
237 FIXME( "%p, %d\n", iface
, level
);
241 static HRESULT WINAPI
connection_get_Attributes( _Connection
*iface
, LONG
*attr
)
243 FIXME( "%p, %p\n", iface
, attr
);
247 static HRESULT WINAPI
connection_put_Attributes( _Connection
*iface
, LONG attr
)
249 FIXME( "%p, %d\n", iface
, attr
);
253 static HRESULT WINAPI
connection_get_CursorLocation( _Connection
*iface
, CursorLocationEnum
*cursor_loc
)
255 FIXME( "%p, %p\n", iface
, cursor_loc
);
259 static HRESULT WINAPI
connection_put_CursorLocation( _Connection
*iface
, CursorLocationEnum cursor_loc
)
261 FIXME( "%p, %u\n", iface
, cursor_loc
);
265 static HRESULT WINAPI
connection_get_Mode( _Connection
*iface
, ConnectModeEnum
*mode
)
267 FIXME( "%p, %p\n", iface
, mode
);
271 static HRESULT WINAPI
connection_put_Mode( _Connection
*iface
, ConnectModeEnum mode
)
273 FIXME( "%p, %u\n", iface
, mode
);
277 static HRESULT WINAPI
connection_get_Provider( _Connection
*iface
, BSTR
*str
)
279 FIXME( "%p, %p\n", iface
, str
);
283 static HRESULT WINAPI
connection_put_Provider( _Connection
*iface
, BSTR str
)
285 FIXME( "%p, %s\n", iface
, debugstr_w(str
) );
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
;
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
);
305 static HRESULT WINAPI
connection_Cancel( _Connection
*iface
)
307 FIXME( "%p\n", iface
);
311 static const struct _ConnectionVtbl connection_vtbl
=
313 connection_QueryInterface
,
316 connection_GetTypeInfoCount
,
317 connection_GetTypeInfo
,
318 connection_GetIDsOfNames
,
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
,
330 connection_BeginTrans
,
331 connection_CommitTrans
,
332 connection_RollbackTrans
,
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
,
345 connection_get_Provider
,
346 connection_put_Provider
,
347 connection_get_State
,
348 connection_OpenSchema
,
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
) );
377 static const struct ISupportErrorInfoVtbl support_error_vtbl
=
379 supporterror_QueryInterface
,
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
);