gdiplus: Use wide-char string literals.
[wine.git] / dlls / msado15 / command.c
blobd19108a1a253a0109651ab72b1219d58d02e35bf
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;
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 );
50 *obj = NULL;
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))
59 *obj = iface;
61 else
63 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
64 return E_NOINTERFACE;
67 _Command_AddRef( iface );
68 return S_OK;
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 );
81 if (!ref)
83 TRACE( "destroying %p\n", command );
84 if (command->connection) _Connection_Release(command->connection);
85 heap_free( command->text );
86 heap_free( command );
88 return ref;
91 static HRESULT WINAPI command_GetTypeInfoCount( _Command *iface, UINT *count )
93 FIXME( "%p, %p\n", iface, count );
94 return E_NOTIMPL;
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 );
100 return E_NOTIMPL;
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 );
107 return E_NOTIMPL;
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 );
115 return E_NOTIMPL;
118 static HRESULT WINAPI command_get_Properties( _Command *iface, Properties **props )
120 FIXME( "%p, %p\n", iface, props );
121 return E_NOTIMPL;
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);
131 return S_OK;
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);
142 return S_OK;
145 static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT connection )
147 FIXME( "%p, %s\n", iface, debugstr_variant(&connection) );
148 return E_NOTIMPL;
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;
159 *text = cmd_text;
160 return S_OK;
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;
173 return S_OK;
176 static HRESULT WINAPI command_get_CommandTimeout( _Command *iface, LONG *timeout )
178 FIXME( "%p, %p\n", iface, timeout );
179 return E_NOTIMPL;
182 static HRESULT WINAPI command_put_CommandTimeout( _Command *iface, LONG timeout )
184 FIXME( "%p, %d\n", iface, timeout );
185 return E_NOTIMPL;
188 static HRESULT WINAPI command_get_Prepared( _Command *iface, VARIANT_BOOL *prepared )
190 FIXME( "%p, %p\n", iface, prepared );
191 return E_NOTIMPL;
194 static HRESULT WINAPI command_put_Prepared( _Command *iface, VARIANT_BOOL prepared )
196 FIXME( "%p, %d\n", iface, prepared );
197 return E_NOTIMPL;
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 );
204 return E_NOTIMPL;
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 );
212 return E_NOTIMPL;
215 static HRESULT WINAPI command_get_Parameters( _Command *iface, Parameters **parameters )
217 FIXME( "%p, %p\n", iface, parameters );
218 return E_NOTIMPL;
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 );
227 switch (type)
229 case adCmdUnspecified:
230 case adCmdUnknown:
231 case adCmdText:
232 case adCmdTable:
233 case adCmdStoredProc:
234 case adCmdFile:
235 case adCmdTableDirect:
236 command->type = type;
237 return S_OK;
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;
250 return S_OK;
253 static HRESULT WINAPI command_get_Name(_Command *iface, BSTR *name)
255 FIXME( "%p, %p\n", iface, name );
256 return E_NOTIMPL;
259 static HRESULT WINAPI command_put_Name( _Command *iface, BSTR name )
261 FIXME( "%p, %s\n", iface, debugstr_w(name) );
262 return E_NOTIMPL;
265 static HRESULT WINAPI command_get_State( _Command *iface, LONG *state )
267 FIXME( "%p, %p\n", iface, state );
268 return E_NOTIMPL;
271 static HRESULT WINAPI command_Cancel( _Command *iface )
273 FIXME( "%p\n", iface );
274 return E_NOTIMPL;
277 static HRESULT WINAPI command_putref_CommandStream( _Command *iface, IUnknown *stream )
279 FIXME( "%p, %p\n", iface, stream );
280 return E_NOTIMPL;
283 static HRESULT WINAPI command_get_CommandStream( _Command *iface, VARIANT *stream )
285 FIXME( "%p, %p\n", iface, stream );
286 return E_NOTIMPL;
289 static HRESULT WINAPI command_put_Dialect( _Command *iface, BSTR dialect )
291 FIXME( "%p, %s\n", iface, debugstr_w(dialect) );
292 return E_NOTIMPL;
295 static HRESULT WINAPI command_get_Dialect( _Command *iface, BSTR *dialect )
297 FIXME( "%p, %p\n", iface, dialect );
298 return E_NOTIMPL;
301 static HRESULT WINAPI command_put_NamedParameters( _Command *iface, VARIANT_BOOL parameters )
303 FIXME( "%p, %d\n", iface, parameters );
304 return E_NOTIMPL;
307 static HRESULT WINAPI command_get_NamedParameters( _Command *iface, VARIANT_BOOL *parameters )
309 FIXME( "%p, %p\n", iface, parameters );
310 return E_NOTIMPL;
313 static const struct _CommandVtbl command_vtbl =
315 command_QueryInterface,
316 command_AddRef,
317 command_Release,
318 command_GetTypeInfoCount,
319 command_GetTypeInfo,
320 command_GetIDsOfNames,
321 command_Invoke,
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,
332 command_Execute,
333 command_CreateParameter,
334 command_get_Parameters,
335 command_put_CommandType,
336 command_get_CommandType,
337 command_get_Name,
338 command_put_Name,
339 command_get_State,
340 command_Cancel,
341 command_putref_CommandStream,
342 command_get_CommandStream,
343 command_put_Dialect,
344 command_get_Dialect,
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;
358 command->ref = 1;
360 *obj = &command->Command_iface;
361 TRACE( "returning iface %p\n", *obj );
362 return S_OK;