1 /* WinRT Windows.Media.Speech implementation
3 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
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
25 #include "winstring.h"
26 #include "wine/debug.h"
30 #include "activation.h"
32 #define WIDL_using_Windows_Foundation
33 #define WIDL_using_Windows_Foundation_Collections
34 #include "windows.foundation.h"
35 #define WIDL_using_Windows_Media_SpeechSynthesis
36 #include "windows.media.speechsynthesis.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(speech
);
40 static const char *debugstr_hstring(HSTRING hstr
)
44 if (hstr
&& !((ULONG_PTR
)hstr
>> 16)) return "(invalid)";
45 str
= WindowsGetStringRawBuffer(hstr
, &len
);
46 return wine_dbgstr_wn(str
, len
);
49 struct voice_information_vector
51 IVectorView_VoiceInformation IVectorView_VoiceInformation_iface
;
55 static inline struct voice_information_vector
*impl_from_IVectorView_VoiceInformation(IVectorView_VoiceInformation
*iface
)
57 return CONTAINING_RECORD(iface
, struct voice_information_vector
, IVectorView_VoiceInformation_iface
);
60 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_QueryInterface(
61 IVectorView_VoiceInformation
*iface
, REFIID iid
, void **out
)
63 TRACE("iface %p, iid %s, out %p stub!\n", iface
, debugstr_guid(iid
), out
);
65 if (IsEqualGUID(iid
, &IID_IUnknown
) ||
66 IsEqualGUID(iid
, &IID_IInspectable
) ||
67 IsEqualGUID(iid
, &IID_IVectorView_VoiceInformation
))
69 IUnknown_AddRef(iface
);
74 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
79 static ULONG STDMETHODCALLTYPE
vector_view_voice_information_AddRef(
80 IVectorView_VoiceInformation
*iface
)
82 struct voice_information_vector
*impl
= impl_from_IVectorView_VoiceInformation(iface
);
83 ULONG ref
= InterlockedIncrement(&impl
->ref
);
84 TRACE("iface %p, ref %u.\n", iface
, ref
);
88 static ULONG STDMETHODCALLTYPE
vector_view_voice_information_Release(
89 IVectorView_VoiceInformation
*iface
)
91 struct voice_information_vector
*impl
= impl_from_IVectorView_VoiceInformation(iface
);
92 ULONG ref
= InterlockedDecrement(&impl
->ref
);
93 TRACE("iface %p, ref %u.\n", iface
, ref
);
97 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_GetIids(
98 IVectorView_VoiceInformation
*iface
, ULONG
*iid_count
, IID
**iids
)
100 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
104 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_GetRuntimeClassName(
105 IVectorView_VoiceInformation
*iface
, HSTRING
*class_name
)
107 FIXME("iface %p, class_name %p stub!\n", iface
, class_name
);
111 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_GetTrustLevel(
112 IVectorView_VoiceInformation
*iface
, TrustLevel
*trust_level
)
114 FIXME("iface %p, trust_level %p stub!\n", iface
, trust_level
);
118 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_GetAt(
119 IVectorView_VoiceInformation
*iface
, UINT32 index
, IVoiceInformation
**value
)
121 FIXME("iface %p, index %#x, value %p stub!\n", iface
, index
, value
);
126 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_get_Size(
127 IVectorView_VoiceInformation
*iface
, UINT32
*value
)
129 FIXME("iface %p, value %p stub!\n", iface
, value
);
134 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_IndexOf(
135 IVectorView_VoiceInformation
*iface
, IVoiceInformation
*element
, UINT32
*index
, BOOLEAN
*found
)
137 FIXME("iface %p, element %p, index %p, found %p stub!\n", iface
, element
, index
, found
);
143 static HRESULT STDMETHODCALLTYPE
vector_view_voice_information_GetMany(
144 IVectorView_VoiceInformation
*iface
, UINT32 start_index
,
145 UINT32 items_size
, IVoiceInformation
**items
, UINT
*value
)
147 FIXME("iface %p, start_index %#x, items %p, value %p stub!\n", iface
, start_index
, items
, value
);
152 static const struct IVectorView_VoiceInformationVtbl vector_view_voice_information_vtbl
=
154 vector_view_voice_information_QueryInterface
,
155 vector_view_voice_information_AddRef
,
156 vector_view_voice_information_Release
,
157 /* IInspectable methods */
158 vector_view_voice_information_GetIids
,
159 vector_view_voice_information_GetRuntimeClassName
,
160 vector_view_voice_information_GetTrustLevel
,
161 /* IVectorView<VoiceInformation> methods */
162 vector_view_voice_information_GetAt
,
163 vector_view_voice_information_get_Size
,
164 vector_view_voice_information_IndexOf
,
165 vector_view_voice_information_GetMany
,
168 static struct voice_information_vector all_voices
=
170 {&vector_view_voice_information_vtbl
},
174 struct windows_media_speech
176 IActivationFactory IActivationFactory_iface
;
177 IInstalledVoicesStatic IInstalledVoicesStatic_iface
;
181 static inline struct windows_media_speech
*impl_from_IActivationFactory(IActivationFactory
*iface
)
183 return CONTAINING_RECORD(iface
, struct windows_media_speech
, IActivationFactory_iface
);
186 static inline struct windows_media_speech
*impl_from_IInstalledVoicesStatic(IInstalledVoicesStatic
*iface
)
188 return CONTAINING_RECORD(iface
, struct windows_media_speech
, IInstalledVoicesStatic_iface
);
191 static HRESULT STDMETHODCALLTYPE
windows_media_speech_QueryInterface(
192 IActivationFactory
*iface
, REFIID iid
, void **out
)
194 struct windows_media_speech
*impl
= impl_from_IActivationFactory(iface
);
196 TRACE("iface %p, iid %s, out %p stub!\n", iface
, debugstr_guid(iid
), out
);
198 if (IsEqualGUID(iid
, &IID_IUnknown
) ||
199 IsEqualGUID(iid
, &IID_IInspectable
) ||
200 IsEqualGUID(iid
, &IID_IAgileObject
) ||
201 IsEqualGUID(iid
, &IID_IActivationFactory
))
203 IUnknown_AddRef(iface
);
208 if (IsEqualGUID(iid
, &IID_IInstalledVoicesStatic
))
210 IUnknown_AddRef(iface
);
211 *out
= &impl
->IInstalledVoicesStatic_iface
;
215 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
217 return E_NOINTERFACE
;
220 static ULONG STDMETHODCALLTYPE
windows_media_speech_AddRef(
221 IActivationFactory
*iface
)
223 struct windows_media_speech
*impl
= impl_from_IActivationFactory(iface
);
224 ULONG ref
= InterlockedIncrement(&impl
->ref
);
225 TRACE("iface %p, ref %u.\n", iface
, ref
);
229 static ULONG STDMETHODCALLTYPE
windows_media_speech_Release(
230 IActivationFactory
*iface
)
232 struct windows_media_speech
*impl
= impl_from_IActivationFactory(iface
);
233 ULONG ref
= InterlockedDecrement(&impl
->ref
);
234 TRACE("iface %p, ref %u.\n", iface
, ref
);
238 static HRESULT STDMETHODCALLTYPE
windows_media_speech_GetIids(
239 IActivationFactory
*iface
, ULONG
*iid_count
, IID
**iids
)
241 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
245 static HRESULT STDMETHODCALLTYPE
windows_media_speech_GetRuntimeClassName(
246 IActivationFactory
*iface
, HSTRING
*class_name
)
248 FIXME("iface %p, class_name %p stub!\n", iface
, class_name
);
252 static HRESULT STDMETHODCALLTYPE
windows_media_speech_GetTrustLevel(
253 IActivationFactory
*iface
, TrustLevel
*trust_level
)
255 FIXME("iface %p, trust_level %p stub!\n", iface
, trust_level
);
259 static HRESULT STDMETHODCALLTYPE
windows_media_speech_ActivateInstance(
260 IActivationFactory
*iface
, IInspectable
**instance
)
262 FIXME("iface %p, instance %p stub!\n", iface
, instance
);
266 static const struct IActivationFactoryVtbl activation_factory_vtbl
=
268 windows_media_speech_QueryInterface
,
269 windows_media_speech_AddRef
,
270 windows_media_speech_Release
,
271 /* IInspectable methods */
272 windows_media_speech_GetIids
,
273 windows_media_speech_GetRuntimeClassName
,
274 windows_media_speech_GetTrustLevel
,
275 /* IActivationFactory methods */
276 windows_media_speech_ActivateInstance
,
279 static HRESULT STDMETHODCALLTYPE
installed_voices_static_QueryInterface(
280 IInstalledVoicesStatic
*iface
, REFIID iid
, void **out
)
282 struct windows_media_speech
*impl
= impl_from_IInstalledVoicesStatic(iface
);
283 return windows_media_speech_QueryInterface(&impl
->IActivationFactory_iface
, iid
, out
);
286 static ULONG STDMETHODCALLTYPE
installed_voices_static_AddRef(
287 IInstalledVoicesStatic
*iface
)
289 struct windows_media_speech
*impl
= impl_from_IInstalledVoicesStatic(iface
);
290 return windows_media_speech_AddRef(&impl
->IActivationFactory_iface
);
293 static ULONG STDMETHODCALLTYPE
installed_voices_static_Release(
294 IInstalledVoicesStatic
*iface
)
296 struct windows_media_speech
*impl
= impl_from_IInstalledVoicesStatic(iface
);
297 return windows_media_speech_Release(&impl
->IActivationFactory_iface
);
300 static HRESULT STDMETHODCALLTYPE
installed_voices_static_GetIids(
301 IInstalledVoicesStatic
*iface
, ULONG
*iid_count
, IID
**iids
)
303 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
307 static HRESULT STDMETHODCALLTYPE
installed_voices_static_GetRuntimeClassName(
308 IInstalledVoicesStatic
*iface
, HSTRING
*class_name
)
310 FIXME("iface %p, class_name %p stub!\n", iface
, class_name
);
314 static HRESULT STDMETHODCALLTYPE
installed_voices_static_GetTrustLevel(
315 IInstalledVoicesStatic
*iface
, TrustLevel
*trust_level
)
317 FIXME("iface %p, trust_level %p stub!\n", iface
, trust_level
);
321 static HRESULT STDMETHODCALLTYPE
installed_voices_static_get_AllVoices(
322 IInstalledVoicesStatic
*iface
, IVectorView_VoiceInformation
**value
)
324 TRACE("iface %p, value %p.\n", iface
, value
);
325 *value
= &all_voices
.IVectorView_VoiceInformation_iface
;
326 IVectorView_VoiceInformation_AddRef(*value
);
330 static HRESULT STDMETHODCALLTYPE
installed_voices_static_get_DefaultVoice(
331 IInstalledVoicesStatic
*iface
, IVoiceInformation
**value
)
333 FIXME("iface %p, value %p stub!\n", iface
, value
);
337 static const struct IInstalledVoicesStaticVtbl installed_voices_static_vtbl
=
339 installed_voices_static_QueryInterface
,
340 installed_voices_static_AddRef
,
341 installed_voices_static_Release
,
342 /* IInspectable methods */
343 installed_voices_static_GetIids
,
344 installed_voices_static_GetRuntimeClassName
,
345 installed_voices_static_GetTrustLevel
,
346 /* IInstalledVoicesStatic methods */
347 installed_voices_static_get_AllVoices
,
348 installed_voices_static_get_DefaultVoice
,
351 static struct windows_media_speech windows_media_speech
=
353 {&activation_factory_vtbl
},
354 {&installed_voices_static_vtbl
},
358 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID riid
, void **out
)
360 FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid
), debugstr_guid(riid
), out
);
361 return CLASS_E_CLASSNOTAVAILABLE
;
364 HRESULT WINAPI
DllGetActivationFactory(HSTRING classid
, IActivationFactory
**factory
)
366 TRACE("classid %s, factory %p.\n", debugstr_hstring(classid
), factory
);
367 *factory
= &windows_media_speech
.IActivationFactory_iface
;
368 IUnknown_AddRef(*factory
);