win32u: Implement NtGdiIcmBrushInfo and use it instead of __wine_get_brush_bitmap_info.
[wine.git] / dlls / windows.media.speech / listconstraint.c
blob555f3b214e1251eb3d7c80d61452c1e36ff569a3
1 /* WinRT Windows.Media.SpeechRecognition implementation
3 * Copyright 2022 Bernhard Kölbl
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "private.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(speech);
28 * SpeechRecognitionListConstraint
32 struct list_constraint
34 ISpeechRecognitionListConstraint ISpeechRecognitionListConstraint_iface;
35 ISpeechRecognitionConstraint ISpeechRecognitionConstraint_iface;
36 LONG ref;
38 BOOLEAN enabled;
39 IVector_HSTRING *commands;
44 * ISpeechRecognitionListConstraint
48 static inline struct list_constraint *impl_from_ISpeechRecognitionListConstraint( ISpeechRecognitionListConstraint *iface )
50 return CONTAINING_RECORD(iface, struct list_constraint, ISpeechRecognitionListConstraint_iface);
53 static HRESULT WINAPI list_constraint_QueryInterface( ISpeechRecognitionListConstraint *iface, REFIID iid, void **out )
55 struct list_constraint *impl = impl_from_ISpeechRecognitionListConstraint(iface);
57 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
59 if (IsEqualGUID(iid, &IID_IUnknown) ||
60 IsEqualGUID(iid, &IID_IInspectable) ||
61 IsEqualGUID(iid, &IID_IAgileObject) ||
62 IsEqualGUID(iid, &IID_ISpeechRecognitionListConstraint))
64 IInspectable_AddRef((*out = &impl->ISpeechRecognitionListConstraint_iface));
65 return S_OK;
68 if (IsEqualGUID(iid, &IID_ISpeechRecognitionConstraint))
70 IInspectable_AddRef((*out = &impl->ISpeechRecognitionConstraint_iface));
71 return S_OK;
74 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
75 *out = NULL;
76 return E_NOINTERFACE;
79 static ULONG WINAPI list_constraint_AddRef( ISpeechRecognitionListConstraint *iface )
81 struct list_constraint *impl = impl_from_ISpeechRecognitionListConstraint(iface);
82 ULONG ref = InterlockedIncrement(&impl->ref);
83 TRACE("iface %p, ref %lu.\n", iface, ref);
84 return ref;
87 static ULONG WINAPI list_constraint_Release( ISpeechRecognitionListConstraint *iface )
89 struct list_constraint *impl = impl_from_ISpeechRecognitionListConstraint(iface);
91 ULONG ref = InterlockedDecrement(&impl->ref);
92 TRACE("iface %p, ref %lu.\n", iface, ref);
94 if (!ref)
96 IVector_HSTRING_Release(impl->commands);
97 free(impl);
100 return ref;
103 static HRESULT WINAPI list_constraint_GetIids( ISpeechRecognitionListConstraint *iface, ULONG *iid_count, IID **iids )
105 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
106 return E_NOTIMPL;
109 static HRESULT WINAPI list_constraint_GetRuntimeClassName( ISpeechRecognitionListConstraint *iface, HSTRING *class_name )
111 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
112 return E_NOTIMPL;
115 static HRESULT WINAPI list_constraint_GetTrustLevel( ISpeechRecognitionListConstraint *iface, TrustLevel *trust_level )
117 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
118 return E_NOTIMPL;
121 static HRESULT WINAPI list_constraint_get_Commands( ISpeechRecognitionListConstraint *iface, IVector_HSTRING **value )
123 struct list_constraint *impl = impl_from_ISpeechRecognitionListConstraint(iface);
124 IIterable_HSTRING *iterable;
125 HRESULT hr;
127 TRACE("iface %p, value %p.\n", iface, value);
129 hr = IVector_HSTRING_QueryInterface(impl->commands, &IID_IIterable_HSTRING, (void **)&iterable);
130 if (FAILED(hr)) return hr;
132 hr = vector_hstring_create_copy(iterable, value);
133 IIterable_HSTRING_Release(iterable);
135 return hr;
138 static const struct ISpeechRecognitionListConstraintVtbl speech_recognition_list_constraint_vtbl =
140 /* IUnknown methods */
141 list_constraint_QueryInterface,
142 list_constraint_AddRef,
143 list_constraint_Release,
144 /* IInspectable methods */
145 list_constraint_GetIids,
146 list_constraint_GetRuntimeClassName,
147 list_constraint_GetTrustLevel,
148 /* ISpeechRecognitionListConstraint methods */
149 list_constraint_get_Commands,
154 * ISpeechRecognitionConstraint
158 DEFINE_IINSPECTABLE(constraint, ISpeechRecognitionConstraint, struct list_constraint, ISpeechRecognitionListConstraint_iface)
160 static HRESULT WINAPI constraint_get_IsEnabled( ISpeechRecognitionConstraint *iface, BOOLEAN *value )
162 struct list_constraint *impl = impl_from_ISpeechRecognitionConstraint(iface);
163 TRACE("iface %p, value %p.\n", iface, value);
164 *value = impl->enabled;
165 return S_OK;
168 static HRESULT WINAPI constraint_put_IsEnabled( ISpeechRecognitionConstraint *iface, BOOLEAN value )
170 struct list_constraint *impl = impl_from_ISpeechRecognitionConstraint(iface);
171 TRACE("iface %p, value %u.\n", iface, value);
172 impl->enabled = value;
173 return S_OK;
176 static HRESULT WINAPI constraint_get_Tag( ISpeechRecognitionConstraint *iface, HSTRING *value )
178 FIXME("iface %p, value %p stub!\n", iface, value);
179 return E_NOTIMPL;
182 static HRESULT WINAPI constraint_put_Tag( ISpeechRecognitionConstraint *iface, HSTRING value )
184 FIXME("iface %p, value %p stub!\n", iface, value);
185 return E_NOTIMPL;
188 static HRESULT WINAPI constraint_get_Type( ISpeechRecognitionConstraint *iface, SpeechRecognitionConstraintType *value )
190 FIXME("iface %p, value %p stub!\n", iface, value);
191 return E_NOTIMPL;
194 static HRESULT WINAPI constraint_get_Probability( ISpeechRecognitionConstraint *iface, SpeechRecognitionConstraintProbability *value )
196 FIXME("iface %p, value %p stub!\n", iface, value);
197 return E_NOTIMPL;
200 static HRESULT WINAPI constraint_put_Probability( ISpeechRecognitionConstraint *iface, SpeechRecognitionConstraintProbability value )
202 FIXME("iface %p, value %u stub!\n", iface, value);
203 return E_NOTIMPL;
206 static const struct ISpeechRecognitionConstraintVtbl speech_recognition_constraint_vtbl =
208 /* IUnknown methods */
209 constraint_QueryInterface,
210 constraint_AddRef,
211 constraint_Release,
212 /* IInspectable methods */
213 constraint_GetIids,
214 constraint_GetRuntimeClassName,
215 constraint_GetTrustLevel,
216 /* ISpeechRecognitionConstraint methods */
217 constraint_get_IsEnabled,
218 constraint_put_IsEnabled,
219 constraint_get_Tag,
220 constraint_put_Tag,
221 constraint_get_Type,
222 constraint_get_Probability,
223 constraint_put_Probability,
228 * Statics for SpeechRecognitionListConstraint
232 struct listconstraint_statics
234 IActivationFactory IActivationFactory_iface;
235 ISpeechRecognitionListConstraintFactory ISpeechRecognitionListConstraintFactory_iface;
236 LONG ref;
241 * IActivationFactory
245 static inline struct listconstraint_statics *impl_from_IActivationFactory( IActivationFactory *iface )
247 return CONTAINING_RECORD(iface, struct listconstraint_statics, IActivationFactory_iface);
250 static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
252 struct listconstraint_statics *impl = impl_from_IActivationFactory(iface);
254 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
256 if (IsEqualGUID(iid, &IID_IUnknown) ||
257 IsEqualGUID(iid, &IID_IInspectable) ||
258 IsEqualGUID(iid, &IID_IAgileObject) ||
259 IsEqualGUID(iid, &IID_IActivationFactory))
261 IInspectable_AddRef((*out = &impl->IActivationFactory_iface));
262 return S_OK;
265 if (IsEqualGUID(iid, &IID_ISpeechRecognitionListConstraintFactory))
267 IInspectable_AddRef((*out = &impl->ISpeechRecognitionListConstraintFactory_iface));
268 return S_OK;
271 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
272 *out = NULL;
273 return E_NOINTERFACE;
276 static ULONG WINAPI factory_AddRef( IActivationFactory *iface )
278 struct listconstraint_statics *impl = impl_from_IActivationFactory(iface);
279 ULONG ref = InterlockedIncrement(&impl->ref);
280 TRACE("iface %p, ref %lu.\n", iface, ref);
281 return ref;
284 static ULONG WINAPI factory_Release( IActivationFactory *iface )
286 struct listconstraint_statics *impl = impl_from_IActivationFactory(iface);
287 ULONG ref = InterlockedDecrement(&impl->ref);
288 TRACE("iface %p, ref %lu.\n", iface, ref);
289 return ref;
292 static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids )
294 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
295 return E_NOTIMPL;
298 static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name )
300 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
301 return E_NOTIMPL;
304 static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level )
306 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
307 return E_NOTIMPL;
310 static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance )
312 TRACE("iface %p, instance %p\n", iface, instance);
313 return E_NOTIMPL;
316 static const struct IActivationFactoryVtbl activation_factory_vtbl =
318 /* IUnknown methods */
319 factory_QueryInterface,
320 factory_AddRef,
321 factory_Release,
322 /* IInspectable methods */
323 factory_GetIids,
324 factory_GetRuntimeClassName,
325 factory_GetTrustLevel,
326 /* IActivationFactory methods */
327 factory_ActivateInstance,
332 * ISpeechRecognitionListConstraintFactory
336 DEFINE_IINSPECTABLE(constraint_factory, ISpeechRecognitionListConstraintFactory, struct listconstraint_statics, IActivationFactory_iface)
338 static HRESULT WINAPI constraint_factory_Create( ISpeechRecognitionListConstraintFactory *iface,
339 IIterable_HSTRING *commands,
340 ISpeechRecognitionListConstraint** listconstraint )
342 TRACE("iface %p, commands %p, listconstraint %p.\n", iface, commands, listconstraint);
343 return ISpeechRecognitionListConstraintFactory_CreateWithTag(iface, commands, NULL, listconstraint);
346 static HRESULT WINAPI constraint_factory_CreateWithTag( ISpeechRecognitionListConstraintFactory *iface,
347 IIterable_HSTRING *commands,
348 HSTRING tag,
349 ISpeechRecognitionListConstraint** listconstraint )
351 struct list_constraint *impl;
352 HRESULT hr;
354 TRACE("iface %p, commands %p, tag %p, listconstraint %p.\n", iface, commands, tag, listconstraint);
356 *listconstraint = NULL;
358 if (!commands)
359 return E_POINTER;
361 if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY;
362 if (FAILED(hr = vector_hstring_create_copy(commands, &impl->commands))) goto error;
364 impl->ISpeechRecognitionListConstraint_iface.lpVtbl = &speech_recognition_list_constraint_vtbl;
365 impl->ISpeechRecognitionConstraint_iface.lpVtbl = &speech_recognition_constraint_vtbl;
366 impl->ref = 1;
368 TRACE("created SpeechRecognitionListConstraint %p.\n", impl);
370 *listconstraint = &impl->ISpeechRecognitionListConstraint_iface;
371 return S_OK;
373 error:
374 if (impl->commands) IVector_HSTRING_Release(impl->commands);
375 free(impl);
376 return hr;
379 static const struct ISpeechRecognitionListConstraintFactoryVtbl speech_recognition_list_constraint_factory_vtbl =
381 /* IUnknown methods */
382 constraint_factory_QueryInterface,
383 constraint_factory_AddRef,
384 constraint_factory_Release,
385 /* IInspectable methods */
386 constraint_factory_GetIids,
387 constraint_factory_GetRuntimeClassName,
388 constraint_factory_GetTrustLevel,
389 /* ISpeechRecognitionListConstraintFactory methods */
390 constraint_factory_Create,
391 constraint_factory_CreateWithTag,
396 * ActivationFactory instances
400 static struct listconstraint_statics listconstraint_statics =
402 .IActivationFactory_iface = {&activation_factory_vtbl},
403 .ISpeechRecognitionListConstraintFactory_iface = {&speech_recognition_list_constraint_factory_vtbl},
404 .ref = 1
407 IActivationFactory *listconstraint_factory = &listconstraint_statics.IActivationFactory_iface;