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
23 #include "msado15_backcompat.h"
25 #include "wine/debug.h"
26 #include "wine/heap.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 heap_free( command
->text
);
91 static HRESULT WINAPI
command_GetTypeInfoCount( _Command
*iface
, UINT
*count
)
93 FIXME( "%p, %p\n", iface
, count
);
97 static HRESULT WINAPI
command_GetTypeInfo( _Command
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
99 FIXME( "%p, %u, %u, %p\n", iface
, index
, lcid
, info
);
103 static HRESULT WINAPI
command_GetIDsOfNames( _Command
*iface
, REFIID riid
, LPOLESTR
*names
, UINT count
,
104 LCID lcid
, DISPID
*dispid
)
106 FIXME( "%p, %s, %p, %u, %u, %p\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
110 static HRESULT WINAPI
command_Invoke( _Command
*iface
, DISPID member
, REFIID riid
, LCID lcid
, WORD flags
,
111 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
113 FIXME( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", iface
, member
, debugstr_guid(riid
), lcid
, flags
, params
,
114 result
, excep_info
, arg_err
);
118 static HRESULT WINAPI
command_get_Properties( _Command
*iface
, Properties
**props
)
120 FIXME( "%p, %p\n", iface
, props
);
124 static HRESULT WINAPI
command_get_ActiveConnection( _Command
*iface
, _Connection
**connection
)
126 struct command
*command
= impl_from_Command( iface
);
127 TRACE( "%p, %p\n", iface
, connection
);
129 *connection
= command
->connection
;
130 if (command
->connection
) _Connection_AddRef(command
->connection
);
134 static HRESULT WINAPI
command_putref_ActiveConnection( _Command
*iface
, _Connection
*connection
)
136 struct command
*command
= impl_from_Command( iface
);
137 TRACE( "%p, %p\n", iface
, connection
);
139 if (command
->connection
) _Connection_Release(command
->connection
);
140 command
->connection
= connection
;
141 if (command
->connection
) _Connection_AddRef(command
->connection
);
145 static HRESULT WINAPI
command_put_ActiveConnection( _Command
*iface
, VARIANT connection
)
147 FIXME( "%p, %s\n", iface
, debugstr_variant(&connection
) );
151 static HRESULT WINAPI
command_get_CommandText( _Command
*iface
, BSTR
*text
)
153 struct command
*command
= impl_from_Command( iface
);
154 BSTR cmd_text
= NULL
;
156 TRACE( "%p, %p\n", command
, text
);
158 if (command
->text
&& !(cmd_text
= SysAllocString( command
->text
))) return E_OUTOFMEMORY
;
163 static HRESULT WINAPI
command_put_CommandText( _Command
*iface
, BSTR text
)
165 struct command
*command
= impl_from_Command( iface
);
166 WCHAR
*source
= NULL
;
168 TRACE( "%p, %s\n", command
, debugstr_w( text
) );
170 if (text
&& !(source
= strdupW( text
))) return E_OUTOFMEMORY
;
171 heap_free( command
->text
);
172 command
->text
= source
;
176 static HRESULT WINAPI
command_get_CommandTimeout( _Command
*iface
, LONG
*timeout
)
178 FIXME( "%p, %p\n", iface
, timeout
);
182 static HRESULT WINAPI
command_put_CommandTimeout( _Command
*iface
, LONG timeout
)
184 FIXME( "%p, %d\n", iface
, timeout
);
188 static HRESULT WINAPI
command_get_Prepared( _Command
*iface
, VARIANT_BOOL
*prepared
)
190 FIXME( "%p, %p\n", iface
, prepared
);
194 static HRESULT WINAPI
command_put_Prepared( _Command
*iface
, VARIANT_BOOL prepared
)
196 FIXME( "%p, %d\n", iface
, prepared
);
200 static HRESULT WINAPI
command_Execute( _Command
*iface
, VARIANT
*affected
, VARIANT
*parameters
,
201 LONG options
, _Recordset
**recordset
)
203 FIXME( "%p, %p, %p, %d, %p\n", iface
, affected
, parameters
, options
, recordset
);
207 static HRESULT WINAPI
command_CreateParameter( _Command
*iface
, BSTR name
, DataTypeEnum type
,
208 ParameterDirectionEnum direction
, LONG size
, VARIANT value
,
209 _Parameter
**parameter
)
211 FIXME( "%p, %s, %d, %d, %d, %p\n", iface
, debugstr_w(name
), type
, direction
, size
, parameter
);
215 static HRESULT WINAPI
command_get_Parameters( _Command
*iface
, Parameters
**parameters
)
217 FIXME( "%p, %p\n", iface
, parameters
);
221 static HRESULT WINAPI
command_put_CommandType( _Command
*iface
, CommandTypeEnum type
)
223 struct command
*command
= impl_from_Command( iface
);
225 TRACE( "%p, %d\n", iface
, type
);
229 case adCmdUnspecified
:
233 case adCmdStoredProc
:
235 case adCmdTableDirect
:
236 command
->type
= type
;
240 return MAKE_ADO_HRESULT( adErrInvalidArgument
);
243 static HRESULT WINAPI
command_get_CommandType( _Command
*iface
, CommandTypeEnum
*type
)
245 struct command
*command
= impl_from_Command( iface
);
247 TRACE( "%p, %p\n", iface
, type
);
249 *type
= command
->type
;
253 static HRESULT WINAPI
command_get_Name(_Command
*iface
, BSTR
*name
)
255 FIXME( "%p, %p\n", iface
, name
);
259 static HRESULT WINAPI
command_put_Name( _Command
*iface
, BSTR name
)
261 FIXME( "%p, %s\n", iface
, debugstr_w(name
) );
265 static HRESULT WINAPI
command_get_State( _Command
*iface
, LONG
*state
)
267 FIXME( "%p, %p\n", iface
, state
);
271 static HRESULT WINAPI
command_Cancel( _Command
*iface
)
273 FIXME( "%p\n", iface
);
277 static HRESULT WINAPI
command_putref_CommandStream( _Command
*iface
, IUnknown
*stream
)
279 FIXME( "%p, %p\n", iface
, stream
);
283 static HRESULT WINAPI
command_get_CommandStream( _Command
*iface
, VARIANT
*stream
)
285 FIXME( "%p, %p\n", iface
, stream
);
289 static HRESULT WINAPI
command_put_Dialect( _Command
*iface
, BSTR dialect
)
291 FIXME( "%p, %s\n", iface
, debugstr_w(dialect
) );
295 static HRESULT WINAPI
command_get_Dialect( _Command
*iface
, BSTR
*dialect
)
297 FIXME( "%p, %p\n", iface
, dialect
);
301 static HRESULT WINAPI
command_put_NamedParameters( _Command
*iface
, VARIANT_BOOL parameters
)
303 FIXME( "%p, %d\n", iface
, parameters
);
307 static HRESULT WINAPI
command_get_NamedParameters( _Command
*iface
, VARIANT_BOOL
*parameters
)
309 FIXME( "%p, %p\n", iface
, parameters
);
313 static const struct _CommandVtbl command_vtbl
=
315 command_QueryInterface
,
318 command_GetTypeInfoCount
,
320 command_GetIDsOfNames
,
322 command_get_Properties
,
323 command_get_ActiveConnection
,
324 command_putref_ActiveConnection
,
325 command_put_ActiveConnection
,
326 command_get_CommandText
,
327 command_put_CommandText
,
328 command_get_CommandTimeout
,
329 command_put_CommandTimeout
,
330 command_get_Prepared
,
331 command_put_Prepared
,
333 command_CreateParameter
,
334 command_get_Parameters
,
335 command_put_CommandType
,
336 command_get_CommandType
,
341 command_putref_CommandStream
,
342 command_get_CommandStream
,
345 command_put_NamedParameters
,
346 command_get_NamedParameters
349 HRESULT
Command_create( void **obj
)
351 struct command
*command
;
353 if (!(command
= heap_alloc( sizeof(*command
) ))) return E_OUTOFMEMORY
;
354 command
->Command_iface
.lpVtbl
= &command_vtbl
;
355 command
->type
= adCmdUnknown
;
356 command
->text
= NULL
;
357 command
->connection
= NULL
;
360 *obj
= &command
->Command_iface
;
361 TRACE( "returning iface %p\n", *obj
);