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
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
;
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
));
68 if (IsEqualGUID(iid
, &IID_ISpeechRecognitionConstraint
))
70 IInspectable_AddRef((*out
= &impl
->ISpeechRecognitionConstraint_iface
));
74 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
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
);
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
);
96 IVector_HSTRING_Release(impl
->commands
);
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
);
109 static HRESULT WINAPI
list_constraint_GetRuntimeClassName( ISpeechRecognitionListConstraint
*iface
, HSTRING
*class_name
)
111 FIXME("iface %p, class_name %p stub!\n", iface
, class_name
);
115 static HRESULT WINAPI
list_constraint_GetTrustLevel( ISpeechRecognitionListConstraint
*iface
, TrustLevel
*trust_level
)
117 FIXME("iface %p, trust_level %p stub!\n", iface
, trust_level
);
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
;
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
);
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
;
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
;
176 static HRESULT WINAPI
constraint_get_Tag( ISpeechRecognitionConstraint
*iface
, HSTRING
*value
)
178 FIXME("iface %p, value %p stub!\n", iface
, value
);
182 static HRESULT WINAPI
constraint_put_Tag( ISpeechRecognitionConstraint
*iface
, HSTRING value
)
184 FIXME("iface %p, value %p stub!\n", iface
, value
);
188 static HRESULT WINAPI
constraint_get_Type( ISpeechRecognitionConstraint
*iface
, SpeechRecognitionConstraintType
*value
)
190 FIXME("iface %p, value %p stub!\n", iface
, value
);
194 static HRESULT WINAPI
constraint_get_Probability( ISpeechRecognitionConstraint
*iface
, SpeechRecognitionConstraintProbability
*value
)
196 FIXME("iface %p, value %p stub!\n", iface
, value
);
200 static HRESULT WINAPI
constraint_put_Probability( ISpeechRecognitionConstraint
*iface
, SpeechRecognitionConstraintProbability value
)
202 FIXME("iface %p, value %u stub!\n", iface
, value
);
206 static const struct ISpeechRecognitionConstraintVtbl speech_recognition_constraint_vtbl
=
208 /* IUnknown methods */
209 constraint_QueryInterface
,
212 /* IInspectable methods */
214 constraint_GetRuntimeClassName
,
215 constraint_GetTrustLevel
,
216 /* ISpeechRecognitionConstraint methods */
217 constraint_get_IsEnabled
,
218 constraint_put_IsEnabled
,
222 constraint_get_Probability
,
223 constraint_put_Probability
,
228 * Statics for SpeechRecognitionListConstraint
232 struct listconstraint_statics
234 IActivationFactory IActivationFactory_iface
;
235 ISpeechRecognitionListConstraintFactory ISpeechRecognitionListConstraintFactory_iface
;
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
));
265 if (IsEqualGUID(iid
, &IID_ISpeechRecognitionListConstraintFactory
))
267 IInspectable_AddRef((*out
= &impl
->ISpeechRecognitionListConstraintFactory_iface
));
271 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
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
);
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
);
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
);
298 static HRESULT WINAPI
factory_GetRuntimeClassName( IActivationFactory
*iface
, HSTRING
*class_name
)
300 FIXME("iface %p, class_name %p stub!\n", iface
, class_name
);
304 static HRESULT WINAPI
factory_GetTrustLevel( IActivationFactory
*iface
, TrustLevel
*trust_level
)
306 FIXME("iface %p, trust_level %p stub!\n", iface
, trust_level
);
310 static HRESULT WINAPI
factory_ActivateInstance( IActivationFactory
*iface
, IInspectable
**instance
)
312 TRACE("iface %p, instance %p\n", iface
, instance
);
316 static const struct IActivationFactoryVtbl activation_factory_vtbl
=
318 /* IUnknown methods */
319 factory_QueryInterface
,
322 /* IInspectable methods */
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
,
349 ISpeechRecognitionListConstraint
** listconstraint
)
351 struct list_constraint
*impl
;
354 TRACE("iface %p, commands %p, tag %p, listconstraint %p.\n", iface
, commands
, tag
, listconstraint
);
356 *listconstraint
= NULL
;
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
;
368 TRACE("created SpeechRecognitionListConstraint %p.\n", impl
);
370 *listconstraint
= &impl
->ISpeechRecognitionListConstraint_iface
;
374 if (impl
->commands
) IVector_HSTRING_Release(impl
->commands
);
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
},
407 IActivationFactory
*listconstraint_factory
= &listconstraint_statics
.IActivationFactory_iface
;