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"
27 #include "wine/heap.h"
29 #include "msado15_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msado15
);
35 _Command Command_iface
;
39 _Connection
*connection
;
42 static inline struct command
*impl_from_Command( _Command
*iface
)
44 return CONTAINING_RECORD( iface
, struct command
, Command_iface
);
47 static HRESULT WINAPI
command_QueryInterface( _Command
*iface
, REFIID riid
, void **obj
)
49 TRACE( "%p, %s, %p\n", iface
, debugstr_guid(riid
), obj
);
53 if (IsEqualIID(riid
, &IID_IUnknown
) ||
54 IsEqualIID(riid
, &IID_IDispatch
) ||
55 IsEqualIID(riid
, &IID__ADO
) ||
56 IsEqualIID(riid
, &IID_Command15
) ||
57 IsEqualIID(riid
, &IID_Command25
) ||
58 IsEqualIID(riid
, &IID__Command
))
64 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
68 _Command_AddRef( iface
);
72 static ULONG WINAPI
command_AddRef( _Command
*iface
)
74 struct command
*command
= impl_from_Command( iface
);
75 return InterlockedIncrement( &command
->ref
);
78 static ULONG WINAPI
command_Release( _Command
*iface
)
80 struct command
*command
= impl_from_Command( iface
);
81 LONG ref
= InterlockedDecrement( &command
->ref
);
84 TRACE( "destroying %p\n", command
);
85 if (command
->connection
) _Connection_Release(command
->connection
);
86 heap_free( command
->text
);
92 static HRESULT WINAPI
command_GetTypeInfoCount( _Command
*iface
, UINT
*count
)
94 struct command
*command
= impl_from_Command( iface
);
95 TRACE( "%p, %p\n", command
, count
);
100 static HRESULT WINAPI
command_GetTypeInfo( _Command
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
102 struct command
*command
= impl_from_Command( iface
);
103 TRACE( "%p, %u, %lu, %p\n", command
, index
, lcid
, info
);
104 return get_typeinfo(Command_tid
, info
);
107 static HRESULT WINAPI
command_GetIDsOfNames( _Command
*iface
, REFIID riid
, LPOLESTR
*names
, UINT count
,
108 LCID lcid
, DISPID
*dispid
)
110 struct command
*command
= impl_from_Command( iface
);
114 TRACE( "%p, %s, %p, %u, %lu, %p\n", command
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
116 hr
= get_typeinfo(Command_tid
, &typeinfo
);
119 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, names
, count
, dispid
);
120 ITypeInfo_Release(typeinfo
);
126 static HRESULT WINAPI
command_Invoke( _Command
*iface
, DISPID member
, REFIID riid
, LCID lcid
, WORD flags
,
127 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
129 struct command
*command
= impl_from_Command( iface
);
133 TRACE( "%p, %ld, %s, %ld, %d, %p, %p, %p, %p\n", command
, member
, debugstr_guid(riid
), lcid
, flags
, params
,
134 result
, excep_info
, arg_err
);
136 hr
= get_typeinfo(Command_tid
, &typeinfo
);
139 hr
= ITypeInfo_Invoke(typeinfo
, &command
->Command_iface
, member
, flags
, params
,
140 result
, excep_info
, arg_err
);
141 ITypeInfo_Release(typeinfo
);
147 static HRESULT WINAPI
command_get_Properties( _Command
*iface
, Properties
**props
)
149 FIXME( "%p, %p\n", iface
, props
);
153 static HRESULT WINAPI
command_get_ActiveConnection( _Command
*iface
, _Connection
**connection
)
155 struct command
*command
= impl_from_Command( iface
);
156 TRACE( "%p, %p\n", iface
, connection
);
158 *connection
= command
->connection
;
159 if (command
->connection
) _Connection_AddRef(command
->connection
);
163 static HRESULT WINAPI
command_putref_ActiveConnection( _Command
*iface
, _Connection
*connection
)
165 struct command
*command
= impl_from_Command( iface
);
166 TRACE( "%p, %p\n", iface
, connection
);
168 if (command
->connection
) _Connection_Release(command
->connection
);
169 command
->connection
= connection
;
170 if (command
->connection
) _Connection_AddRef(command
->connection
);
174 static HRESULT WINAPI
command_put_ActiveConnection( _Command
*iface
, VARIANT connection
)
176 FIXME( "%p, %s\n", iface
, debugstr_variant(&connection
) );
180 static HRESULT WINAPI
command_get_CommandText( _Command
*iface
, BSTR
*text
)
182 struct command
*command
= impl_from_Command( iface
);
183 BSTR cmd_text
= NULL
;
185 TRACE( "%p, %p\n", command
, text
);
187 if (command
->text
&& !(cmd_text
= SysAllocString( command
->text
))) return E_OUTOFMEMORY
;
192 static HRESULT WINAPI
command_put_CommandText( _Command
*iface
, BSTR text
)
194 struct command
*command
= impl_from_Command( iface
);
195 WCHAR
*source
= NULL
;
197 TRACE( "%p, %s\n", command
, debugstr_w( text
) );
199 if (text
&& !(source
= strdupW( text
))) return E_OUTOFMEMORY
;
200 heap_free( command
->text
);
201 command
->text
= source
;
205 static HRESULT WINAPI
command_get_CommandTimeout( _Command
*iface
, LONG
*timeout
)
207 FIXME( "%p, %p\n", iface
, timeout
);
211 static HRESULT WINAPI
command_put_CommandTimeout( _Command
*iface
, LONG timeout
)
213 FIXME( "%p, %ld\n", iface
, timeout
);
217 static HRESULT WINAPI
command_get_Prepared( _Command
*iface
, VARIANT_BOOL
*prepared
)
219 FIXME( "%p, %p\n", iface
, prepared
);
223 static HRESULT WINAPI
command_put_Prepared( _Command
*iface
, VARIANT_BOOL prepared
)
225 FIXME( "%p, %d\n", iface
, prepared
);
229 static HRESULT WINAPI
command_Execute( _Command
*iface
, VARIANT
*affected
, VARIANT
*parameters
,
230 LONG options
, _Recordset
**recordset
)
232 FIXME( "%p, %p, %p, %ld, %p\n", iface
, affected
, parameters
, options
, recordset
);
236 static HRESULT WINAPI
command_CreateParameter( _Command
*iface
, BSTR name
, DataTypeEnum type
,
237 ParameterDirectionEnum direction
, ADO_LONGPTR size
, VARIANT value
,
238 _Parameter
**parameter
)
240 FIXME( "%p, %s, %d, %d, %Id, %p\n", iface
, debugstr_w(name
), type
, direction
, size
, parameter
);
244 static HRESULT WINAPI
command_get_Parameters( _Command
*iface
, Parameters
**parameters
)
246 FIXME( "%p, %p\n", iface
, parameters
);
250 static HRESULT WINAPI
command_put_CommandType( _Command
*iface
, CommandTypeEnum type
)
252 struct command
*command
= impl_from_Command( iface
);
254 TRACE( "%p, %d\n", iface
, type
);
258 case adCmdUnspecified
:
262 case adCmdStoredProc
:
264 case adCmdTableDirect
:
265 command
->type
= type
;
269 return MAKE_ADO_HRESULT( adErrInvalidArgument
);
272 static HRESULT WINAPI
command_get_CommandType( _Command
*iface
, CommandTypeEnum
*type
)
274 struct command
*command
= impl_from_Command( iface
);
276 TRACE( "%p, %p\n", iface
, type
);
278 *type
= command
->type
;
282 static HRESULT WINAPI
command_get_Name(_Command
*iface
, BSTR
*name
)
284 FIXME( "%p, %p\n", iface
, name
);
288 static HRESULT WINAPI
command_put_Name( _Command
*iface
, BSTR name
)
290 FIXME( "%p, %s\n", iface
, debugstr_w(name
) );
294 static HRESULT WINAPI
command_get_State( _Command
*iface
, LONG
*state
)
296 FIXME( "%p, %p\n", iface
, state
);
300 static HRESULT WINAPI
command_Cancel( _Command
*iface
)
302 FIXME( "%p\n", iface
);
306 static HRESULT WINAPI
command_putref_CommandStream( _Command
*iface
, IUnknown
*stream
)
308 FIXME( "%p, %p\n", iface
, stream
);
312 static HRESULT WINAPI
command_get_CommandStream( _Command
*iface
, VARIANT
*stream
)
314 FIXME( "%p, %p\n", iface
, stream
);
318 static HRESULT WINAPI
command_put_Dialect( _Command
*iface
, BSTR dialect
)
320 FIXME( "%p, %s\n", iface
, debugstr_w(dialect
) );
324 static HRESULT WINAPI
command_get_Dialect( _Command
*iface
, BSTR
*dialect
)
326 FIXME( "%p, %p\n", iface
, dialect
);
330 static HRESULT WINAPI
command_put_NamedParameters( _Command
*iface
, VARIANT_BOOL parameters
)
332 FIXME( "%p, %d\n", iface
, parameters
);
336 static HRESULT WINAPI
command_get_NamedParameters( _Command
*iface
, VARIANT_BOOL
*parameters
)
338 FIXME( "%p, %p\n", iface
, parameters
);
342 static const struct _CommandVtbl command_vtbl
=
344 command_QueryInterface
,
347 command_GetTypeInfoCount
,
349 command_GetIDsOfNames
,
351 command_get_Properties
,
352 command_get_ActiveConnection
,
353 command_putref_ActiveConnection
,
354 command_put_ActiveConnection
,
355 command_get_CommandText
,
356 command_put_CommandText
,
357 command_get_CommandTimeout
,
358 command_put_CommandTimeout
,
359 command_get_Prepared
,
360 command_put_Prepared
,
362 command_CreateParameter
,
363 command_get_Parameters
,
364 command_put_CommandType
,
365 command_get_CommandType
,
370 command_putref_CommandStream
,
371 command_get_CommandStream
,
374 command_put_NamedParameters
,
375 command_get_NamedParameters
378 HRESULT
Command_create( void **obj
)
380 struct command
*command
;
382 if (!(command
= heap_alloc( sizeof(*command
) ))) return E_OUTOFMEMORY
;
383 command
->Command_iface
.lpVtbl
= &command_vtbl
;
384 command
->type
= adCmdUnknown
;
385 command
->text
= NULL
;
386 command
->connection
= NULL
;
389 *obj
= &command
->Command_iface
;
390 TRACE( "returning iface %p\n", *obj
);