msscript.ocx: Keep script host running as long as any script module is alive.
[wine.git] / dlls / msado15 / command.c
blobeb7b3a035eb74f0acd67535e24be92138b81d3dd
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 "msado15_backcompat.h"
25 #include "wine/debug.h"
26 #include "wine/heap.h"
28 #include "msado15_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
32 struct command
34 _Command Command_iface;
35 LONG ref;
36 CommandTypeEnum type;
37 BSTR text;
40 static inline struct command *impl_from_Command( _Command *iface )
42 return CONTAINING_RECORD( iface, struct command, Command_iface );
45 static HRESULT WINAPI command_QueryInterface( _Command *iface, REFIID riid, void **obj )
47 TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), obj );
49 *obj = NULL;
51 if (IsEqualIID(riid, &IID_IUnknown) ||
52 IsEqualIID(riid, &IID_IDispatch) ||
53 IsEqualIID(riid, &IID__ADO) ||
54 IsEqualIID(riid, &IID_Command15) ||
55 IsEqualIID(riid, &IID_Command25) ||
56 IsEqualIID(riid, &IID__Command))
58 *obj = iface;
60 else
62 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
63 return E_NOINTERFACE;
66 _Command_AddRef( iface );
67 return S_OK;
70 static ULONG WINAPI command_AddRef( _Command *iface )
72 struct command *command = impl_from_Command( iface );
73 return InterlockedIncrement( &command->ref );
76 static ULONG WINAPI command_Release( _Command *iface )
78 struct command *command = impl_from_Command( iface );
79 LONG ref = InterlockedDecrement( &command->ref );
80 if (!ref)
82 TRACE( "destroying %p\n", command );
83 heap_free( command->text );
84 heap_free( command );
86 return ref;
89 static HRESULT WINAPI command_GetTypeInfoCount( _Command *iface, UINT *count )
91 FIXME( "%p, %p\n", iface, count );
92 return E_NOTIMPL;
95 static HRESULT WINAPI command_GetTypeInfo( _Command *iface, UINT index, LCID lcid, ITypeInfo **info )
97 FIXME( "%p, %u, %u, %p\n", iface, index, lcid, info );
98 return E_NOTIMPL;
101 static HRESULT WINAPI command_GetIDsOfNames( _Command *iface, REFIID riid, LPOLESTR *names, UINT count,
102 LCID lcid, DISPID *dispid )
104 FIXME( "%p, %s, %p, %u, %u, %p\n", iface, debugstr_guid(riid), names, count, lcid, dispid );
105 return E_NOTIMPL;
108 static HRESULT WINAPI command_Invoke( _Command *iface, DISPID member, REFIID riid, LCID lcid, WORD flags,
109 DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err )
111 FIXME( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", iface, member, debugstr_guid(riid), lcid, flags, params,
112 result, excep_info, arg_err );
113 return E_NOTIMPL;
116 static HRESULT WINAPI command_get_Properties( _Command *iface, Properties **props )
118 FIXME( "%p, %p\n", iface, props );
119 return E_NOTIMPL;
122 static HRESULT WINAPI command_get_ActiveConnection( _Command *iface, _Connection **connection )
124 FIXME( "%p, %p\n", iface, connection );
125 return E_NOTIMPL;
128 static HRESULT WINAPI command_putref_ActiveConnection( _Command *iface, _Connection *connection )
130 FIXME( "%p, %p\n", iface, connection );
131 return E_NOTIMPL;
134 static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT connection )
136 FIXME( "%p, %s\n", iface, debugstr_variant(&connection) );
137 return E_NOTIMPL;
140 static HRESULT WINAPI command_get_CommandText( _Command *iface, BSTR *text )
142 struct command *command = impl_from_Command( iface );
143 BSTR cmd_text = NULL;
145 TRACE( "%p, %p\n", command, text );
147 if (command->text && !(cmd_text = SysAllocString( command->text ))) return E_OUTOFMEMORY;
148 *text = cmd_text;
149 return S_OK;
152 static HRESULT WINAPI command_put_CommandText( _Command *iface, BSTR text )
154 struct command *command = impl_from_Command( iface );
155 WCHAR *source = NULL;
157 TRACE( "%p, %s\n", command, debugstr_w( text ) );
159 if (text && !(source = strdupW( text ))) return E_OUTOFMEMORY;
160 heap_free( command->text );
161 command->text = source;
162 return S_OK;
165 static HRESULT WINAPI command_get_CommandTimeout( _Command *iface, LONG *timeout )
167 FIXME( "%p, %p\n", iface, timeout );
168 return E_NOTIMPL;
171 static HRESULT WINAPI command_put_CommandTimeout( _Command *iface, LONG timeout )
173 FIXME( "%p, %d\n", iface, timeout );
174 return E_NOTIMPL;
177 static HRESULT WINAPI command_get_Prepared( _Command *iface, VARIANT_BOOL *prepared )
179 FIXME( "%p, %p\n", iface, prepared );
180 return E_NOTIMPL;
183 static HRESULT WINAPI command_put_Prepared( _Command *iface, VARIANT_BOOL prepared )
185 FIXME( "%p, %d\n", iface, prepared );
186 return E_NOTIMPL;
189 static HRESULT WINAPI command_Execute( _Command *iface, VARIANT *affected, VARIANT *parameters,
190 LONG options, _Recordset **recordset )
192 FIXME( "%p, %p, %p, %d, %p\n", iface, affected, parameters, options, recordset );
193 return E_NOTIMPL;
196 static HRESULT WINAPI command_CreateParameter( _Command *iface, BSTR name, DataTypeEnum type,
197 ParameterDirectionEnum direction, LONG size, VARIANT value,
198 _Parameter **parameter )
200 FIXME( "%p, %s, %d, %d, %d, %p\n", iface, debugstr_w(name), type, direction, size, parameter );
201 return E_NOTIMPL;
204 static HRESULT WINAPI command_get_Parameters( _Command *iface, Parameters **parameters )
206 FIXME( "%p, %p\n", iface, parameters );
207 return E_NOTIMPL;
210 static HRESULT WINAPI command_put_CommandType( _Command *iface, CommandTypeEnum type )
212 struct command *command = impl_from_Command( iface );
214 TRACE( "%p, %d\n", iface, type );
216 switch (type)
218 case adCmdUnspecified:
219 case adCmdUnknown:
220 case adCmdText:
221 case adCmdTable:
222 case adCmdStoredProc:
223 case adCmdFile:
224 case adCmdTableDirect:
225 command->type = type;
226 return S_OK;
229 return MAKE_ADO_HRESULT( adErrInvalidArgument );
232 static HRESULT WINAPI command_get_CommandType( _Command *iface, CommandTypeEnum *type )
234 struct command *command = impl_from_Command( iface );
236 TRACE( "%p, %p\n", iface, type );
238 *type = command->type;
239 return S_OK;
242 static HRESULT WINAPI command_get_Name(_Command *iface, BSTR *name)
244 FIXME( "%p, %p\n", iface, name );
245 return E_NOTIMPL;
248 static HRESULT WINAPI command_put_Name( _Command *iface, BSTR name )
250 FIXME( "%p, %s\n", iface, debugstr_w(name) );
251 return E_NOTIMPL;
254 static HRESULT WINAPI command_get_State( _Command *iface, LONG *state )
256 FIXME( "%p, %p\n", iface, state );
257 return E_NOTIMPL;
260 static HRESULT WINAPI command_Cancel( _Command *iface )
262 FIXME( "%p\n", iface );
263 return E_NOTIMPL;
266 static HRESULT WINAPI command_putref_CommandStream( _Command *iface, IUnknown *stream )
268 FIXME( "%p, %p\n", iface, stream );
269 return E_NOTIMPL;
272 static HRESULT WINAPI command_get_CommandStream( _Command *iface, VARIANT *stream )
274 FIXME( "%p, %p\n", iface, stream );
275 return E_NOTIMPL;
278 static HRESULT WINAPI command_put_Dialect( _Command *iface, BSTR dialect )
280 FIXME( "%p, %s\n", iface, debugstr_w(dialect) );
281 return E_NOTIMPL;
284 static HRESULT WINAPI command_get_Dialect( _Command *iface, BSTR *dialect )
286 FIXME( "%p, %p\n", iface, dialect );
287 return E_NOTIMPL;
290 static HRESULT WINAPI command_put_NamedParameters( _Command *iface, VARIANT_BOOL parameters )
292 FIXME( "%p, %d\n", iface, parameters );
293 return E_NOTIMPL;
296 static HRESULT WINAPI command_get_NamedParameters( _Command *iface, VARIANT_BOOL *parameters )
298 FIXME( "%p, %p\n", iface, parameters );
299 return E_NOTIMPL;
302 static const struct _CommandVtbl command_vtbl =
304 command_QueryInterface,
305 command_AddRef,
306 command_Release,
307 command_GetTypeInfoCount,
308 command_GetTypeInfo,
309 command_GetIDsOfNames,
310 command_Invoke,
311 command_get_Properties,
312 command_get_ActiveConnection,
313 command_putref_ActiveConnection,
314 command_put_ActiveConnection,
315 command_get_CommandText,
316 command_put_CommandText,
317 command_get_CommandTimeout,
318 command_put_CommandTimeout,
319 command_get_Prepared,
320 command_put_Prepared,
321 command_Execute,
322 command_CreateParameter,
323 command_get_Parameters,
324 command_put_CommandType,
325 command_get_CommandType,
326 command_get_Name,
327 command_put_Name,
328 command_get_State,
329 command_Cancel,
330 command_putref_CommandStream,
331 command_get_CommandStream,
332 command_put_Dialect,
333 command_get_Dialect,
334 command_put_NamedParameters,
335 command_get_NamedParameters
338 HRESULT Command_create( void **obj )
340 struct command *command;
342 if (!(command = heap_alloc( sizeof(*command) ))) return E_OUTOFMEMORY;
343 command->Command_iface.lpVtbl = &command_vtbl;
344 command->type = adCmdUnknown;
345 command->text = NULL;
346 command->ref = 1;
348 *obj = &command->Command_iface;
349 TRACE( "returning iface %p\n", *obj );
350 return S_OK;