gdi32/tests: Mark tests failing randomly on Windows as flaky.
[wine.git] / dlls / devenum / parsedisplayname.c
blob477f2f3d11e3f9dca9c78c5f6e494961749e597b
1 /*
2 * IParseDisplayName implementation for DEVENUM.dll
4 * Copyright (C) 2002 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * NOTES ON THIS FILE:
21 * - Implements IParseDisplayName interface which creates a moniker
22 * from a string in a special format
24 #include "devenum_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(devenum);
30 static HRESULT WINAPI devenum_parser_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppv)
32 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
34 if (!ppv)
35 return E_POINTER;
37 if (IsEqualGUID(riid, &IID_IUnknown) ||
38 IsEqualGUID(riid, &IID_IParseDisplayName))
40 *ppv = iface;
41 IParseDisplayName_AddRef(iface);
42 return S_OK;
45 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
46 *ppv = NULL;
47 return E_NOINTERFACE;
50 static ULONG WINAPI devenum_parser_AddRef(IParseDisplayName *iface)
52 TRACE("\n");
54 return 2; /* non-heap based object */
57 static ULONG WINAPI devenum_parser_Release(IParseDisplayName *iface)
59 TRACE("\n");
61 return 1; /* non-heap based object */
64 static HRESULT WINAPI devenum_parser_ParseDisplayName(IParseDisplayName *iface,
65 IBindCtx *pbc, LPOLESTR name, ULONG *eaten, IMoniker **ret)
67 struct moniker *moniker;
68 WCHAR buffer[MAX_PATH];
69 enum device_type type;
70 GUID class, clsid;
72 TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(name), eaten, ret);
74 *ret = NULL;
75 if (eaten)
76 *eaten = wcslen(name);
78 name = wcschr(name, ':') + 1;
80 if (!wcsncmp(name, L"sw:", 3))
82 type = DEVICE_FILTER;
83 name += 3;
85 else if (!wcsncmp(name, L"cm:", 3))
87 type = DEVICE_CODEC;
88 name += 3;
90 else if (!wcsncmp(name, L"dmo:", 4))
92 type = DEVICE_DMO;
93 name += 4;
95 else
97 FIXME("unhandled device type %s\n", debugstr_w(name));
98 return MK_E_SYNTAX;
101 if (type == DEVICE_DMO)
103 lstrcpynW(buffer, name, CHARS_IN_GUID);
104 if (FAILED(CLSIDFromString(buffer, &clsid)))
105 return MK_E_SYNTAX;
107 lstrcpynW(buffer, name + CHARS_IN_GUID - 1, CHARS_IN_GUID);
108 if (FAILED(CLSIDFromString(buffer, &class)))
109 return MK_E_SYNTAX;
111 moniker = dmo_moniker_create(class, clsid);
113 else
115 lstrcpynW(buffer, name, CHARS_IN_GUID);
116 if (CLSIDFromString(buffer, &class) == S_OK)
118 name += CHARS_IN_GUID;
119 if (type == DEVICE_FILTER)
120 moniker = filter_moniker_create(&class, name);
121 else
122 moniker = codec_moniker_create(&class, name);
124 else
126 if (type == DEVICE_FILTER)
127 moniker = filter_moniker_create(NULL, name);
128 else
129 moniker = codec_moniker_create(NULL, name);
133 if (!moniker)
134 return E_OUTOFMEMORY;
136 *ret = &moniker->IMoniker_iface;
137 return S_OK;
140 /**********************************************************************
141 * IParseDisplayName_Vtbl
143 static const IParseDisplayNameVtbl IParseDisplayName_Vtbl =
145 devenum_parser_QueryInterface,
146 devenum_parser_AddRef,
147 devenum_parser_Release,
148 devenum_parser_ParseDisplayName,
151 /* The one instance of this class */
152 IParseDisplayName devenum_parser = { &IParseDisplayName_Vtbl };