dinput: Enumerate user format object forwards.
[wine.git] / dlls / msado15 / command.c
blobb796dd0a8a4b5947058a824bc5cdfcc5427c9775
1 /*
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
18 #include <stdarg.h>
19 #include "windef.h"
20 #include "winbase.h"
21 #define COBJMACROS
22 #include "objbase.h"
23 #include "msdasc.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 command
35 _Command Command_iface;
36 LONG ref;
37 CommandTypeEnum type;
38 BSTR text;
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 );
51 *obj = NULL;
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))
60 *obj = iface;
62 else
64 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
65 return E_NOINTERFACE;
68 _Command_AddRef( iface );
69 return S_OK;
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 );
82 if (!ref)
84 TRACE( "destroying %p\n", command );
85 if (command->connection) _Connection_Release(command->connection);
86 heap_free( command->text );
87 heap_free( command );
89 return ref;
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 );
96 *count = 1;
97 return S_OK;
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 );
111 HRESULT hr;
112 ITypeInfo *typeinfo;
114 TRACE( "%p, %s, %p, %u, %lu, %p\n", command, debugstr_guid(riid), names, count, lcid, dispid );
116 hr = get_typeinfo(Command_tid, &typeinfo);
117 if(SUCCEEDED(hr))
119 hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid);
120 ITypeInfo_Release(typeinfo);
123 return hr;
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 );
130 HRESULT hr;
131 ITypeInfo *typeinfo;
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);
137 if(SUCCEEDED(hr))
139 hr = ITypeInfo_Invoke(typeinfo, &command->Command_iface, member, flags, params,
140 result, excep_info, arg_err);
141 ITypeInfo_Release(typeinfo);
144 return hr;
147 static HRESULT WINAPI command_get_Properties( _Command *iface, Properties **props )
149 FIXME( "%p, %p\n", iface, props );
150 return E_NOTIMPL;
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);
160 return S_OK;
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);
171 return S_OK;
174 static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT connection )
176 FIXME( "%p, %s\n", iface, debugstr_variant(&connection) );
177 return E_NOTIMPL;
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;
188 *text = cmd_text;
189 return S_OK;
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;
202 return S_OK;
205 static HRESULT WINAPI command_get_CommandTimeout( _Command *iface, LONG *timeout )
207 FIXME( "%p, %p\n", iface, timeout );
208 return E_NOTIMPL;
211 static HRESULT WINAPI command_put_CommandTimeout( _Command *iface, LONG timeout )
213 FIXME( "%p, %ld\n", iface, timeout );
214 return E_NOTIMPL;
217 static HRESULT WINAPI command_get_Prepared( _Command *iface, VARIANT_BOOL *prepared )
219 FIXME( "%p, %p\n", iface, prepared );
220 return E_NOTIMPL;
223 static HRESULT WINAPI command_put_Prepared( _Command *iface, VARIANT_BOOL prepared )
225 FIXME( "%p, %d\n", iface, prepared );
226 return E_NOTIMPL;
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 );
233 return E_NOTIMPL;
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 );
241 return E_NOTIMPL;
244 static HRESULT WINAPI command_get_Parameters( _Command *iface, Parameters **parameters )
246 FIXME( "%p, %p\n", iface, parameters );
247 return E_NOTIMPL;
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 );
256 switch (type)
258 case adCmdUnspecified:
259 case adCmdUnknown:
260 case adCmdText:
261 case adCmdTable:
262 case adCmdStoredProc:
263 case adCmdFile:
264 case adCmdTableDirect:
265 command->type = type;
266 return S_OK;
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;
279 return S_OK;
282 static HRESULT WINAPI command_get_Name(_Command *iface, BSTR *name)
284 FIXME( "%p, %p\n", iface, name );
285 return E_NOTIMPL;
288 static HRESULT WINAPI command_put_Name( _Command *iface, BSTR name )
290 FIXME( "%p, %s\n", iface, debugstr_w(name) );
291 return E_NOTIMPL;
294 static HRESULT WINAPI command_get_State( _Command *iface, LONG *state )
296 FIXME( "%p, %p\n", iface, state );
297 return E_NOTIMPL;
300 static HRESULT WINAPI command_Cancel( _Command *iface )
302 FIXME( "%p\n", iface );
303 return E_NOTIMPL;
306 static HRESULT WINAPI command_putref_CommandStream( _Command *iface, IUnknown *stream )
308 FIXME( "%p, %p\n", iface, stream );
309 return E_NOTIMPL;
312 static HRESULT WINAPI command_get_CommandStream( _Command *iface, VARIANT *stream )
314 FIXME( "%p, %p\n", iface, stream );
315 return E_NOTIMPL;
318 static HRESULT WINAPI command_put_Dialect( _Command *iface, BSTR dialect )
320 FIXME( "%p, %s\n", iface, debugstr_w(dialect) );
321 return E_NOTIMPL;
324 static HRESULT WINAPI command_get_Dialect( _Command *iface, BSTR *dialect )
326 FIXME( "%p, %p\n", iface, dialect );
327 return E_NOTIMPL;
330 static HRESULT WINAPI command_put_NamedParameters( _Command *iface, VARIANT_BOOL parameters )
332 FIXME( "%p, %d\n", iface, parameters );
333 return E_NOTIMPL;
336 static HRESULT WINAPI command_get_NamedParameters( _Command *iface, VARIANT_BOOL *parameters )
338 FIXME( "%p, %p\n", iface, parameters );
339 return E_NOTIMPL;
342 static const struct _CommandVtbl command_vtbl =
344 command_QueryInterface,
345 command_AddRef,
346 command_Release,
347 command_GetTypeInfoCount,
348 command_GetTypeInfo,
349 command_GetIDsOfNames,
350 command_Invoke,
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,
361 command_Execute,
362 command_CreateParameter,
363 command_get_Parameters,
364 command_put_CommandType,
365 command_get_CommandType,
366 command_get_Name,
367 command_put_Name,
368 command_get_State,
369 command_Cancel,
370 command_putref_CommandStream,
371 command_get_CommandStream,
372 command_put_Dialect,
373 command_get_Dialect,
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;
387 command->ref = 1;
389 *obj = &command->Command_iface;
390 TRACE( "returning iface %p\n", *obj );
391 return S_OK;