2 * Copyright 2019 Alistair Leslie-Hughes
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"
28 #include "msado15_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msado15
);
34 _Command Command_iface
;
38 _Connection
*connection
;
41 static inline struct command
*impl_from_Command( _Command
*iface
)
43 return CONTAINING_RECORD( iface
, struct command
, Command_iface
);
46 static HRESULT WINAPI
command_QueryInterface( _Command
*iface
, REFIID riid
, void **obj
)
48 TRACE( "%p, %s, %p\n", iface
, debugstr_guid(riid
), obj
);
52 if (IsEqualIID(riid
, &IID_IUnknown
) ||
53 IsEqualIID(riid
, &IID_IDispatch
) ||
54 IsEqualIID(riid
, &IID__ADO
) ||
55 IsEqualIID(riid
, &IID_Command15
) ||
56 IsEqualIID(riid
, &IID_Command25
) ||
57 IsEqualIID(riid
, &IID__Command
))
63 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
67 _Command_AddRef( iface
);
71 static ULONG WINAPI
command_AddRef( _Command
*iface
)
73 struct command
*command
= impl_from_Command( iface
);
74 return InterlockedIncrement( &command
->ref
);
77 static ULONG WINAPI
command_Release( _Command
*iface
)
79 struct command
*command
= impl_from_Command( iface
);
80 LONG ref
= InterlockedDecrement( &command
->ref
);
83 TRACE( "destroying %p\n", command
);
84 if (command
->connection
) _Connection_Release(command
->connection
);
85 free( command
->text
);
91 static HRESULT WINAPI
command_GetTypeInfoCount( _Command
*iface
, UINT
*count
)
93 struct command
*command
= impl_from_Command( iface
);
94 TRACE( "%p, %p\n", command
, count
);
99 static HRESULT WINAPI
command_GetTypeInfo( _Command
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
101 struct command
*command
= impl_from_Command( iface
);
102 TRACE( "%p, %u, %lu, %p\n", command
, index
, lcid
, info
);
103 return get_typeinfo(Command_tid
, info
);
106 static HRESULT WINAPI
command_GetIDsOfNames( _Command
*iface
, REFIID riid
, LPOLESTR
*names
, UINT count
,
107 LCID lcid
, DISPID
*dispid
)
109 struct command
*command
= impl_from_Command( iface
);
113 TRACE( "%p, %s, %p, %u, %lu, %p\n", command
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
115 hr
= get_typeinfo(Command_tid
, &typeinfo
);
118 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, names
, count
, dispid
);
119 ITypeInfo_Release(typeinfo
);
125 static HRESULT WINAPI
command_Invoke( _Command
*iface
, DISPID member
, REFIID riid
, LCID lcid
, WORD flags
,
126 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
128 struct command
*command
= impl_from_Command( iface
);
132 TRACE( "%p, %ld, %s, %ld, %d, %p, %p, %p, %p\n", command
, member
, debugstr_guid(riid
), lcid
, flags
, params
,
133 result
, excep_info
, arg_err
);
135 hr
= get_typeinfo(Command_tid
, &typeinfo
);
138 hr
= ITypeInfo_Invoke(typeinfo
, &command
->Command_iface
, member
, flags
, params
,
139 result
, excep_info
, arg_err
);
140 ITypeInfo_Release(typeinfo
);
146 static HRESULT WINAPI
command_get_Properties( _Command
*iface
, Properties
**props
)
148 FIXME( "%p, %p\n", iface
, props
);
152 static HRESULT WINAPI
command_get_ActiveConnection( _Command
*iface
, _Connection
**connection
)
154 struct command
*command
= impl_from_Command( iface
);
155 TRACE( "%p, %p\n", iface
, connection
);
157 *connection
= command
->connection
;
158 if (command
->connection
) _Connection_AddRef(command
->connection
);
162 static HRESULT WINAPI
command_putref_ActiveConnection( _Command
*iface
, _Connection
*connection
)
164 struct command
*command
= impl_from_Command( iface
);
165 TRACE( "%p, %p\n", iface
, connection
);
167 if (command
->connection
) _Connection_Release(command
->connection
);
168 command
->connection
= connection
;
169 if (command
->connection
) _Connection_AddRef(command
->connection
);
173 static HRESULT WINAPI
command_put_ActiveConnection( _Command
*iface
, VARIANT connection
)
175 FIXME( "%p, %s\n", iface
, debugstr_variant(&connection
) );
179 static HRESULT WINAPI
command_get_CommandText( _Command
*iface
, BSTR
*text
)
181 struct command
*command
= impl_from_Command( iface
);
182 BSTR cmd_text
= NULL
;
184 TRACE( "%p, %p\n", command
, text
);
186 if (command
->text
&& !(cmd_text
= SysAllocString( command
->text
))) return E_OUTOFMEMORY
;
191 static HRESULT WINAPI
command_put_CommandText( _Command
*iface
, BSTR text
)
193 struct command
*command
= impl_from_Command( iface
);
194 WCHAR
*source
= NULL
;
196 TRACE( "%p, %s\n", command
, debugstr_w( text
) );
198 if (text
&& !(source
= wcsdup( text
))) return E_OUTOFMEMORY
;
199 free( command
->text
);
200 command
->text
= source
;
204 static HRESULT WINAPI
command_get_CommandTimeout( _Command
*iface
, LONG
*timeout
)
206 FIXME( "%p, %p\n", iface
, timeout
);
210 static HRESULT WINAPI
command_put_CommandTimeout( _Command
*iface
, LONG timeout
)
212 FIXME( "%p, %ld\n", iface
, timeout
);
216 static HRESULT WINAPI
command_get_Prepared( _Command
*iface
, VARIANT_BOOL
*prepared
)
218 FIXME( "%p, %p\n", iface
, prepared
);
222 static HRESULT WINAPI
command_put_Prepared( _Command
*iface
, VARIANT_BOOL prepared
)
224 FIXME( "%p, %d\n", iface
, prepared
);
228 static HRESULT WINAPI
command_Execute( _Command
*iface
, VARIANT
*affected
, VARIANT
*parameters
,
229 LONG options
, _Recordset
**recordset
)
231 FIXME( "%p, %p, %p, %ld, %p\n", iface
, affected
, parameters
, options
, recordset
);
235 static HRESULT WINAPI
command_CreateParameter( _Command
*iface
, BSTR name
, DataTypeEnum type
,
236 ParameterDirectionEnum direction
, ADO_LONGPTR size
, VARIANT value
,
237 _Parameter
**parameter
)
239 FIXME( "%p, %s, %d, %d, %Id, %p\n", iface
, debugstr_w(name
), type
, direction
, size
, parameter
);
243 static HRESULT WINAPI
command_get_Parameters( _Command
*iface
, Parameters
**parameters
)
245 FIXME( "%p, %p\n", iface
, parameters
);
249 static HRESULT WINAPI
command_put_CommandType( _Command
*iface
, CommandTypeEnum type
)
251 struct command
*command
= impl_from_Command( iface
);
253 TRACE( "%p, %d\n", iface
, type
);
257 case adCmdUnspecified
:
261 case adCmdStoredProc
:
263 case adCmdTableDirect
:
264 command
->type
= type
;
268 return MAKE_ADO_HRESULT( adErrInvalidArgument
);
271 static HRESULT WINAPI
command_get_CommandType( _Command
*iface
, CommandTypeEnum
*type
)
273 struct command
*command
= impl_from_Command( iface
);
275 TRACE( "%p, %p\n", iface
, type
);
277 *type
= command
->type
;
281 static HRESULT WINAPI
command_get_Name(_Command
*iface
, BSTR
*name
)
283 FIXME( "%p, %p\n", iface
, name
);
287 static HRESULT WINAPI
command_put_Name( _Command
*iface
, BSTR name
)
289 FIXME( "%p, %s\n", iface
, debugstr_w(name
) );
293 static HRESULT WINAPI
command_get_State( _Command
*iface
, LONG
*state
)
295 FIXME( "%p, %p\n", iface
, state
);
299 static HRESULT WINAPI
command_Cancel( _Command
*iface
)
301 FIXME( "%p\n", iface
);
305 static HRESULT WINAPI
command_putref_CommandStream( _Command
*iface
, IUnknown
*stream
)
307 FIXME( "%p, %p\n", iface
, stream
);
311 static HRESULT WINAPI
command_get_CommandStream( _Command
*iface
, VARIANT
*stream
)
313 FIXME( "%p, %p\n", iface
, stream
);
317 static HRESULT WINAPI
command_put_Dialect( _Command
*iface
, BSTR dialect
)
319 FIXME( "%p, %s\n", iface
, debugstr_w(dialect
) );
323 static HRESULT WINAPI
command_get_Dialect( _Command
*iface
, BSTR
*dialect
)
325 FIXME( "%p, %p\n", iface
, dialect
);
329 static HRESULT WINAPI
command_put_NamedParameters( _Command
*iface
, VARIANT_BOOL parameters
)
331 FIXME( "%p, %d\n", iface
, parameters
);
335 static HRESULT WINAPI
command_get_NamedParameters( _Command
*iface
, VARIANT_BOOL
*parameters
)
337 FIXME( "%p, %p\n", iface
, parameters
);
341 static const struct _CommandVtbl command_vtbl
=
343 command_QueryInterface
,
346 command_GetTypeInfoCount
,
348 command_GetIDsOfNames
,
350 command_get_Properties
,
351 command_get_ActiveConnection
,
352 command_putref_ActiveConnection
,
353 command_put_ActiveConnection
,
354 command_get_CommandText
,
355 command_put_CommandText
,
356 command_get_CommandTimeout
,
357 command_put_CommandTimeout
,
358 command_get_Prepared
,
359 command_put_Prepared
,
361 command_CreateParameter
,
362 command_get_Parameters
,
363 command_put_CommandType
,
364 command_get_CommandType
,
369 command_putref_CommandStream
,
370 command_get_CommandStream
,
373 command_put_NamedParameters
,
374 command_get_NamedParameters
377 HRESULT
Command_create( void **obj
)
379 struct command
*command
;
381 if (!(command
= malloc( sizeof(*command
) ))) return E_OUTOFMEMORY
;
382 command
->Command_iface
.lpVtbl
= &command_vtbl
;
383 command
->type
= adCmdUnknown
;
384 command
->text
= NULL
;
385 command
->connection
= NULL
;
388 *obj
= &command
->Command_iface
;
389 TRACE( "returning iface %p\n", *obj
);