sapi: Add stub SpResourceManager object.

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2020-11-12 11:28:07 +01:00 committed by Alexandre Julliard
parent 04cf431735
commit cf49617c1a
7 changed files with 258 additions and 0 deletions

View File

@ -6,6 +6,7 @@ EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \
automation.c \
main.c \
resource.c \
stream.c \
token.c \
tts.c

View File

@ -107,6 +107,7 @@ static const struct IClassFactoryVtbl class_factory_vtbl =
static struct class_factory data_key_cf = { { &class_factory_vtbl }, data_key_create };
static struct class_factory file_stream_cf = { { &class_factory_vtbl }, file_stream_create };
static struct class_factory resource_mgr_cf = { { &class_factory_vtbl }, resource_manager_create };
static struct class_factory speech_stream_cf = { { &class_factory_vtbl }, speech_stream_create };
static struct class_factory speech_voice_cf = { { &class_factory_vtbl }, speech_voice_create };
static struct class_factory token_category_cf = { { &class_factory_vtbl }, token_category_create };
@ -132,6 +133,8 @@ HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj )
cf = &token_enum_cf.IClassFactory_iface;
else if (IsEqualCLSID( clsid, &CLSID_SpObjectToken ))
cf = &token_cf.IClassFactory_iface;
else if (IsEqualCLSID( clsid, &CLSID_SpResourceManager ))
cf = &resource_mgr_cf.IClassFactory_iface;
else if (IsEqualCLSID( clsid, &CLSID_SpStream ))
cf = &speech_stream_cf.IClassFactory_iface;
else if (IsEqualCLSID( clsid, &CLSID_SpVoice ))

140
dlls/sapi/resource.c Normal file
View File

@ -0,0 +1,140 @@
/*
* Speech API (SAPI) resource manager implementation.
*
* Copyright 2020 Gijs Vermeulen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "sapiddk.h"
#include "wine/debug.h"
#include "sapi_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(sapi);
struct resource_manager
{
ISpResourceManager ISpResourceManager_iface;
LONG ref;
};
static inline struct resource_manager *impl_from_ISpResourceManager(ISpResourceManager *iface)
{
return CONTAINING_RECORD(iface, struct resource_manager, ISpResourceManager_iface);
}
static HRESULT WINAPI resource_manager_QueryInterface(ISpResourceManager *iface, REFIID iid, void **obj)
{
struct resource_manager *This = impl_from_ISpResourceManager(iface);
TRACE("(%p, %s, %p).\n", iface, debugstr_guid(iid), obj);
if (IsEqualIID(iid, &IID_IUnknown) ||
IsEqualIID(iid, &IID_ISpResourceManager))
*obj = &This->ISpResourceManager_iface;
else
{
*obj = NULL;
FIXME("interface %s not implemented.\n", debugstr_guid(iid));
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown *)*obj);
return S_OK;
}
static ULONG WINAPI resource_manager_AddRef(ISpResourceManager *iface)
{
struct resource_manager *This = impl_from_ISpResourceManager(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p): ref=%u.\n", iface, ref);
return ref;
}
static ULONG WINAPI resource_manager_Release(ISpResourceManager *iface)
{
struct resource_manager *This = impl_from_ISpResourceManager(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ref=%u.\n", iface, ref);
if (!ref)
{
heap_free(This);
}
return ref;
}
static HRESULT WINAPI resource_manager_QueryService(ISpResourceManager *iface, REFGUID guid, REFIID iid,
void **obj)
{
FIXME("(%p, %s, %s, %p): stub.\n", iface, debugstr_guid(guid), debugstr_guid(iid), obj);
return E_NOTIMPL;
}
static HRESULT WINAPI resource_manager_SetObject(ISpResourceManager *iface, REFGUID guid, IUnknown *obj)
{
FIXME("(%p, %s, %p): stub.\n", iface, debugstr_guid(guid), obj);
return E_NOTIMPL;
}
static HRESULT WINAPI resource_manager_GetObject(ISpResourceManager *iface, REFGUID guid, REFCLSID clsid, REFIID iid,
BOOL release, void **obj)
{
FIXME("(%p, %s, %s, %s, %d, %p): stub.\n", iface, debugstr_guid(guid), debugstr_guid(clsid), debugstr_guid(iid),
release, obj);
return E_NOTIMPL;
}
const static ISpResourceManagerVtbl resource_manager_vtbl =
{
resource_manager_QueryInterface,
resource_manager_AddRef,
resource_manager_Release,
resource_manager_QueryService,
resource_manager_SetObject,
resource_manager_GetObject
};
HRESULT resource_manager_create(IUnknown *outer, REFIID iid, void **obj)
{
struct resource_manager *This = heap_alloc(sizeof(*This));
HRESULT hr;
if (!This) return E_OUTOFMEMORY;
This->ISpResourceManager_iface.lpVtbl = &resource_manager_vtbl;
This->ref = 1;
hr = ISpResourceManager_QueryInterface(&This->ISpResourceManager_iface, iid, obj);
ISpResourceManager_Release(&This->ISpResourceManager_iface);
return hr;
}

View File

@ -22,6 +22,7 @@
HRESULT data_key_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
HRESULT file_stream_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
HRESULT resource_manager_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
HRESULT speech_stream_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
HRESULT speech_voice_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
HRESULT token_category_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;

View File

@ -3,6 +3,7 @@ IMPORTS = ole32 user32 advapi32
C_SRCS = \
automation.c \
resource.c \
stream.c \
token.c \
tts.c

View File

@ -0,0 +1,80 @@
/*
* Speech API (SAPI) resource manager tests.
*
* Copyright 2020 Gijs Vermeulen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "sapiddk.h"
#include "sperror.h"
#include "wine/test.h"
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
static void _expect_ref(IUnknown *obj, ULONG ref, int line)
{
ULONG rc;
IUnknown_AddRef(obj);
rc = IUnknown_Release(obj);
ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref);
}
static void test_interfaces(void)
{
ISpResourceManager *resource_manager, *resource_manager2;
IDispatch *dispatch;
IUnknown *unk;
HRESULT hr;
hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpResourceManager, (void **)&resource_manager);
ok(hr == S_OK, "Failed to create ISpeechVoice interface: %#x.\n", hr);
EXPECT_REF(resource_manager, 1);
hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpResourceManager, (void **)&resource_manager2);
ok(hr == S_OK, "Failed to create ISpeechVoice interface: %#x.\n", hr);
todo_wine ok(resource_manager2 == resource_manager, "Expected managers to match.\n");
todo_wine EXPECT_REF(resource_manager2, 2);
todo_wine EXPECT_REF(resource_manager, 2);
if (resource_manager2 == resource_manager) ISpResourceManager_Release(resource_manager2);
EXPECT_REF(resource_manager, 1);
hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Failed to create IUnknown interface: %#x.\n", hr);
todo_wine ok(unk == (IUnknown *)resource_manager, "Expected unk to match existing manager.\n");
todo_wine EXPECT_REF(unk, 2);
todo_wine EXPECT_REF(resource_manager, 2);
if (unk == (IUnknown *)resource_manager) IUnknown_Release(unk);
EXPECT_REF(resource_manager, 1);
hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER,
&IID_IDispatch, (void **)&dispatch);
ok(hr == E_NOINTERFACE, "Succeeded to create IDispatch interface: %#x.\n", hr);
ok(!dispatch, "Expected NULL dispatch, got %p.", dispatch);
ISpResourceManager_Release(resource_manager);
}
START_TEST(resource)
{
CoInitialize(NULL);
test_interfaces();
CoUninitialize();
}

View File

@ -651,6 +651,24 @@ interface IEnumSpObjectTokens : IUnknown
HRESULT GetCount([out] ULONG *pCount);
}
[
object,
uuid(93384e18-5014-43d5-adbb-a78e055926bd),
helpstring("ISpResourceManager"),
pointer_default(unique),
restricted
]
interface ISpResourceManager : IServiceProvider
{
HRESULT SetObject([in] REFGUID guidServiceId,
[in] IUnknown *pUnkObject);
HRESULT GetObject([in] REFGUID guidServiceId,
[in] REFCLSID ObjectCLSID,
[in] REFIID ObjectIID,
[in] BOOL fReleaseWhenLastExternalRefReleased,
[out, iid_is(ObjectIID)] void** ppObject);
}
[
object,
uuid(1a5c0354-b621-4b5a-8791-d306ed379e53),
@ -1077,6 +1095,20 @@ library SpeechLib
[default] interface ISpDataKey;
}
[
uuid(96749373-3391-11d2-9ee3-00c04f797396),
helpstring("Resource Manager"),
progid("SAPI.SpResourceManager.1"),
vi_progid("SAPI.SpResourceManager"),
threading(both),
restricted,
hidden
]
coclass SpResourceManager
{
[default] interface ISpResourceManager;
};
[
uuid(3bee4890-4fe9-4a37-8c1e-5e7e12791c1f)
]