2003-07-01 06:30:30 +02:00
|
|
|
/*
|
|
|
|
* IParseDisplayName implementation for DEVENUM.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Shearman
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-01 06:30:30 +02:00
|
|
|
*
|
|
|
|
* NOTES ON THIS FILE:
|
|
|
|
* - Implements IParseDisplayName interface which creates a moniker
|
|
|
|
* from a string in a special format
|
|
|
|
*/
|
|
|
|
#include "devenum_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI devenum_parser_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppv)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
|
|
|
|
|
2012-04-03 00:22:12 +02:00
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IParseDisplayName))
|
|
|
|
{
|
2012-04-03 00:22:12 +02:00
|
|
|
*ppv = iface;
|
|
|
|
IParseDisplayName_AddRef(iface);
|
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2010-01-11 23:47:51 +01:00
|
|
|
FIXME("- no interface IID: %s\n", debugstr_guid(riid));
|
2012-04-03 00:22:12 +02:00
|
|
|
*ppv = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI devenum_parser_AddRef(IParseDisplayName *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
return 2; /* non-heap based object */
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI devenum_parser_Release(IParseDisplayName *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
return 1; /* non-heap based object */
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI devenum_parser_ParseDisplayName(IParseDisplayName *iface,
|
2018-03-07 03:57:09 +01:00
|
|
|
IBindCtx *pbc, LPOLESTR name, ULONG *eaten, IMoniker **ret)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:43 +02:00
|
|
|
struct moniker *moniker;
|
2018-03-07 03:57:09 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2018-03-07 03:57:08 +01:00
|
|
|
enum device_type type;
|
2020-04-11 17:49:43 +02:00
|
|
|
GUID class, clsid;
|
2003-12-30 22:52:45 +01:00
|
|
|
|
2018-03-07 03:57:09 +01:00
|
|
|
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(name), eaten, ret);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-03-07 03:57:09 +01:00
|
|
|
*ret = NULL;
|
|
|
|
if (eaten)
|
2020-05-14 00:03:09 +02:00
|
|
|
*eaten = wcslen(name);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2019-05-31 08:49:22 +02:00
|
|
|
name = wcschr(name, ':') + 1;
|
2018-03-07 03:57:09 +01:00
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
if (!wcsncmp(name, L"sw:", 3))
|
2018-03-07 03:57:08 +01:00
|
|
|
{
|
|
|
|
type = DEVICE_FILTER;
|
2018-03-07 03:57:09 +01:00
|
|
|
name += 3;
|
2018-03-07 03:57:08 +01:00
|
|
|
}
|
2020-05-14 00:03:09 +02:00
|
|
|
else if (!wcsncmp(name, L"cm:", 3))
|
2018-03-07 03:57:08 +01:00
|
|
|
{
|
|
|
|
type = DEVICE_CODEC;
|
2018-03-07 03:57:09 +01:00
|
|
|
name += 3;
|
2018-03-07 03:57:08 +01:00
|
|
|
}
|
2020-05-14 00:03:09 +02:00
|
|
|
else if (!wcsncmp(name, L"dmo:", 4))
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
|
|
|
type = DEVICE_DMO;
|
|
|
|
name += 4;
|
|
|
|
}
|
2018-03-07 03:57:08 +01:00
|
|
|
else
|
|
|
|
{
|
2018-03-07 03:57:09 +01:00
|
|
|
FIXME("unhandled device type %s\n", debugstr_w(name));
|
2018-03-07 03:57:08 +01:00
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
|
2018-06-25 00:20:29 +02:00
|
|
|
if (type == DEVICE_DMO)
|
2018-03-07 03:57:09 +01:00
|
|
|
{
|
2018-06-25 00:20:29 +02:00
|
|
|
lstrcpynW(buffer, name, CHARS_IN_GUID);
|
2020-04-11 17:49:43 +02:00
|
|
|
if (FAILED(CLSIDFromString(buffer, &clsid)))
|
2018-06-25 00:20:29 +02:00
|
|
|
return MK_E_SYNTAX;
|
|
|
|
|
|
|
|
lstrcpynW(buffer, name + CHARS_IN_GUID - 1, CHARS_IN_GUID);
|
2020-04-11 17:49:43 +02:00
|
|
|
if (FAILED(CLSIDFromString(buffer, &class)))
|
2018-06-25 00:20:29 +02:00
|
|
|
return MK_E_SYNTAX;
|
2020-04-11 17:49:43 +02:00
|
|
|
|
|
|
|
moniker = dmo_moniker_create(class, clsid);
|
2018-03-07 03:57:09 +01:00
|
|
|
}
|
2018-06-25 00:20:29 +02:00
|
|
|
else
|
2018-03-07 03:57:09 +01:00
|
|
|
{
|
2018-06-25 00:20:29 +02:00
|
|
|
lstrcpynW(buffer, name, CHARS_IN_GUID);
|
|
|
|
if (CLSIDFromString(buffer, &class) == S_OK)
|
|
|
|
{
|
|
|
|
name += CHARS_IN_GUID;
|
2020-04-11 17:49:43 +02:00
|
|
|
if (type == DEVICE_FILTER)
|
|
|
|
moniker = filter_moniker_create(&class, name);
|
|
|
|
else
|
|
|
|
moniker = codec_moniker_create(&class, name);
|
2018-06-25 00:20:29 +02:00
|
|
|
}
|
2020-04-11 17:49:43 +02:00
|
|
|
else
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
2020-04-11 17:49:43 +02:00
|
|
|
if (type == DEVICE_FILTER)
|
|
|
|
moniker = filter_moniker_create(NULL, name);
|
|
|
|
else
|
|
|
|
moniker = codec_moniker_create(NULL, name);
|
2018-06-25 00:20:29 +02:00
|
|
|
}
|
2018-03-07 03:57:09 +01:00
|
|
|
}
|
2018-06-25 00:20:29 +02:00
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
if (!moniker)
|
|
|
|
return E_OUTOFMEMORY;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
*ret = &moniker->IMoniker_iface;
|
2018-03-07 03:57:09 +01:00
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* IParseDisplayName_Vtbl
|
|
|
|
*/
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IParseDisplayNameVtbl IParseDisplayName_Vtbl =
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:40 +02:00
|
|
|
devenum_parser_QueryInterface,
|
|
|
|
devenum_parser_AddRef,
|
|
|
|
devenum_parser_Release,
|
|
|
|
devenum_parser_ParseDisplayName,
|
2003-07-01 06:30:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The one instance of this class */
|
2020-04-11 17:49:40 +02:00
|
|
|
IParseDisplayName devenum_parser = { &IParseDisplayName_Vtbl };
|