devenum: Pass moniker fields to moniker_create().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4994ba2123
commit
8cabd4785f
|
@ -68,7 +68,9 @@ struct moniker
|
|||
};
|
||||
};
|
||||
|
||||
struct moniker *moniker_create(void) DECLSPEC_HIDDEN;
|
||||
struct moniker *dmo_moniker_create(const GUID class, const GUID clsid) DECLSPEC_HIDDEN;
|
||||
struct moniker *codec_moniker_create(const GUID *class, const WCHAR *name) DECLSPEC_HIDDEN;
|
||||
struct moniker *filter_moniker_create(const GUID *class, const WCHAR *name) DECLSPEC_HIDDEN;
|
||||
HRESULT enum_moniker_create(REFCLSID class, IEnumMoniker **enum_mon) DECLSPEC_HIDDEN;
|
||||
|
||||
extern ICreateDevEnum devenum_factory DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -768,7 +768,7 @@ static const IMonikerVtbl IMoniker_Vtbl =
|
|||
moniker_IsSystemMoniker,
|
||||
};
|
||||
|
||||
struct moniker *moniker_create(void)
|
||||
struct moniker *filter_moniker_create(const GUID *class, const WCHAR *name)
|
||||
{
|
||||
struct moniker *object;
|
||||
|
||||
|
@ -777,6 +777,49 @@ struct moniker *moniker_create(void)
|
|||
|
||||
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
|
||||
object->ref = 1;
|
||||
object->type = DEVICE_FILTER;
|
||||
if (class)
|
||||
object->class = *class;
|
||||
object->has_class = !!class;
|
||||
object->name = wcsdup(name);
|
||||
|
||||
DEVENUM_LockModule();
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
struct moniker *codec_moniker_create(const GUID *class, const WCHAR *name)
|
||||
{
|
||||
struct moniker *object;
|
||||
|
||||
if (!(object = calloc(1, sizeof(*object))))
|
||||
return NULL;
|
||||
|
||||
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
|
||||
object->ref = 1;
|
||||
object->type = DEVICE_CODEC;
|
||||
if (class)
|
||||
object->class = *class;
|
||||
object->has_class = !!class;
|
||||
object->name = wcsdup(name);
|
||||
|
||||
DEVENUM_LockModule();
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
struct moniker *dmo_moniker_create(const GUID class, const GUID clsid)
|
||||
{
|
||||
struct moniker *object;
|
||||
|
||||
if (!(object = calloc(1, sizeof(*object))))
|
||||
return NULL;
|
||||
|
||||
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
|
||||
object->ref = 1;
|
||||
object->type = DEVICE_DMO;
|
||||
object->class = class;
|
||||
object->clsid = clsid;
|
||||
|
||||
DEVENUM_LockModule();
|
||||
|
||||
|
@ -842,11 +885,11 @@ static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG celt, IMonike
|
|||
{
|
||||
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
||||
WCHAR buffer[MAX_PATH + 1];
|
||||
struct moniker *pMoniker;
|
||||
struct moniker *moniker;
|
||||
LONG res;
|
||||
ULONG fetched = 0;
|
||||
CLSID clsid;
|
||||
HRESULT hr;
|
||||
GUID clsid;
|
||||
HKEY hkey;
|
||||
|
||||
TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
|
||||
|
@ -858,14 +901,7 @@ static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG celt, IMonike
|
|||
/* try DMOs */
|
||||
if ((hr = IEnumDMO_Next(This->dmo_enum, 1, &clsid, NULL, NULL)) == S_OK)
|
||||
{
|
||||
if (!(pMoniker = moniker_create()))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
pMoniker->type = DEVICE_DMO;
|
||||
pMoniker->clsid = clsid;
|
||||
|
||||
StringFromGUID2(&clsid, buffer, CHARS_IN_GUID);
|
||||
StringFromGUID2(&This->class, buffer + CHARS_IN_GUID - 1, CHARS_IN_GUID);
|
||||
moniker = dmo_moniker_create(This->class, clsid);
|
||||
}
|
||||
/* try DirectShow filters */
|
||||
else if (!(res = RegEnumKeyW(This->sw_key, This->sw_index, buffer, ARRAY_SIZE(buffer))))
|
||||
|
@ -874,17 +910,7 @@ static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG celt, IMonike
|
|||
if ((res = RegOpenKeyExW(This->sw_key, buffer, 0, KEY_QUERY_VALUE, &hkey)))
|
||||
break;
|
||||
|
||||
if (!(pMoniker = moniker_create()))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
pMoniker->type = DEVICE_FILTER;
|
||||
|
||||
if (!(pMoniker->name = CoTaskMemAlloc((lstrlenW(buffer) + 1) * sizeof(WCHAR))))
|
||||
{
|
||||
IMoniker_Release(&pMoniker->IMoniker_iface);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
lstrcpyW(pMoniker->name, buffer);
|
||||
moniker = filter_moniker_create(&This->class, buffer);
|
||||
}
|
||||
/* then try codecs */
|
||||
else if (!(res = RegEnumKeyW(This->cm_key, This->cm_index, buffer, ARRAY_SIZE(buffer))))
|
||||
|
@ -894,26 +920,15 @@ static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG celt, IMonike
|
|||
if ((res = RegOpenKeyExW(This->cm_key, buffer, 0, KEY_QUERY_VALUE, &hkey)))
|
||||
break;
|
||||
|
||||
if (!(pMoniker = moniker_create()))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
pMoniker->type = DEVICE_CODEC;
|
||||
|
||||
if (!(pMoniker->name = CoTaskMemAlloc((lstrlenW(buffer) + 1) * sizeof(WCHAR))))
|
||||
{
|
||||
IMoniker_Release(&pMoniker->IMoniker_iface);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
lstrcpyW(pMoniker->name, buffer);
|
||||
moniker = codec_moniker_create(&This->class, buffer);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
pMoniker->has_class = TRUE;
|
||||
pMoniker->class = This->class;
|
||||
if (!moniker)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
rgelt[fetched] = &pMoniker->IMoniker_iface;
|
||||
fetched++;
|
||||
rgelt[fetched++] = &moniker->IMoniker_iface;
|
||||
}
|
||||
|
||||
TRACE("-- fetched %d\n", fetched);
|
||||
|
|
|
@ -68,10 +68,10 @@ static ULONG WINAPI devenum_parser_Release(IParseDisplayName *iface)
|
|||
static HRESULT WINAPI devenum_parser_ParseDisplayName(IParseDisplayName *iface,
|
||||
IBindCtx *pbc, LPOLESTR name, ULONG *eaten, IMoniker **ret)
|
||||
{
|
||||
struct moniker *moniker;
|
||||
WCHAR buffer[MAX_PATH];
|
||||
enum device_type type;
|
||||
struct moniker *mon;
|
||||
CLSID class;
|
||||
GUID class, clsid;
|
||||
|
||||
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(name), eaten, ret);
|
||||
|
||||
|
@ -102,47 +102,42 @@ static HRESULT WINAPI devenum_parser_ParseDisplayName(IParseDisplayName *iface,
|
|||
return MK_E_SYNTAX;
|
||||
}
|
||||
|
||||
if (!(mon = moniker_create()))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (type == DEVICE_DMO)
|
||||
{
|
||||
lstrcpynW(buffer, name, CHARS_IN_GUID);
|
||||
if (FAILED(CLSIDFromString(buffer, &mon->clsid)))
|
||||
{
|
||||
IMoniker_Release(&mon->IMoniker_iface);
|
||||
if (FAILED(CLSIDFromString(buffer, &clsid)))
|
||||
return MK_E_SYNTAX;
|
||||
}
|
||||
|
||||
lstrcpynW(buffer, name + CHARS_IN_GUID - 1, CHARS_IN_GUID);
|
||||
if (FAILED(CLSIDFromString(buffer, &mon->class)))
|
||||
{
|
||||
IMoniker_Release(&mon->IMoniker_iface);
|
||||
if (FAILED(CLSIDFromString(buffer, &class)))
|
||||
return MK_E_SYNTAX;
|
||||
}
|
||||
|
||||
moniker = dmo_moniker_create(class, clsid);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpynW(buffer, name, CHARS_IN_GUID);
|
||||
if (CLSIDFromString(buffer, &class) == S_OK)
|
||||
{
|
||||
mon->has_class = TRUE;
|
||||
mon->class = class;
|
||||
name += CHARS_IN_GUID;
|
||||
if (type == DEVICE_FILTER)
|
||||
moniker = filter_moniker_create(&class, name);
|
||||
else
|
||||
moniker = codec_moniker_create(&class, name);
|
||||
}
|
||||
|
||||
if (!(mon->name = CoTaskMemAlloc((lstrlenW(name) + 1) * sizeof(WCHAR))))
|
||||
else
|
||||
{
|
||||
IMoniker_Release(&mon->IMoniker_iface);
|
||||
if (type == DEVICE_FILTER)
|
||||
moniker = filter_moniker_create(NULL, name);
|
||||
else
|
||||
moniker = codec_moniker_create(NULL, name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!moniker)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
lstrcpyW(mon->name, name);
|
||||
}
|
||||
|
||||
mon->type = type;
|
||||
|
||||
*ret = &mon->IMoniker_iface;
|
||||
|
||||
*ret = &moniker->IMoniker_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue