ReactOS 0.4.15-dev-7906-g1b85a5f
parsedisplayname.c
Go to the documentation of this file.
1/*
2 * IParseDisplayName implementation for DEVENUM.dll
3 *
4 * Copyright (C) 2002 Robert Shearman
5 *
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.
10 *
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.
15 *
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
19 *
20 * NOTES ON THIS FILE:
21 * - Implements IParseDisplayName interface which creates a moniker
22 * from a string in a special format
23 */
24#include "devenum_private.h"
25
26#include "wine/debug.h"
27
29
31 REFIID riid, void **ppv)
32{
33 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
34
35 if (!ppv)
36 return E_POINTER;
37
40 {
41 *ppv = iface;
42 IParseDisplayName_AddRef(iface);
43 return S_OK;
44 }
45
46 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
47 *ppv = NULL;
48 return E_NOINTERFACE;
49}
50
52{
53 TRACE("\n");
54
56
57 return 2; /* non-heap based object */
58}
59
61{
62 TRACE("\n");
63
65
66 return 1; /* non-heap based object */
67}
68
69/**********************************************************************
70 * DEVENUM_IParseDisplayName_ParseDisplayName
71 *
72 * Creates a moniker referenced to by the display string argument
73 *
74 * POSSIBLE BUGS:
75 * Might not handle more complicated strings properly (ie anything
76 * not in "@device:sw:{CLSID1}<filter name or CLSID>" format
77 */
79 IBindCtx *pbc, LPOLESTR name, ULONG *eaten, IMoniker **ret)
80{
82 enum device_type type;
83 MediaCatMoniker *mon;
84 CLSID class;
85
86 TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(name), eaten, ret);
87
88 *ret = NULL;
89 if (eaten)
90 *eaten = lstrlenW(name);
91
92 name = wcschr(name, ':') + 1;
93
94 if (!wcsncmp(name, swW, 3))
95 {
97 name += 3;
98 }
99 else if (!wcsncmp(name, cmW, 3))
100 {
102 name += 3;
103 }
104 else if (!wcsncmp(name, dmoW, 4))
105 {
107 name += 4;
108 }
109 else
110 {
111 FIXME("unhandled device type %s\n", debugstr_w(name));
112 return MK_E_SYNTAX;
113 }
114
116 return E_OUTOFMEMORY;
117
118 if (type == DEVICE_DMO)
119 {
121 if (FAILED(CLSIDFromString(buffer, &mon->clsid)))
122 {
123 IMoniker_Release(&mon->IMoniker_iface);
124 return MK_E_SYNTAX;
125 }
126
128 if (FAILED(CLSIDFromString(buffer, &mon->class)))
129 {
130 IMoniker_Release(&mon->IMoniker_iface);
131 return MK_E_SYNTAX;
132 }
133 }
134 else
135 {
137 if (CLSIDFromString(buffer, &class) == S_OK)
138 {
139 mon->has_class = TRUE;
140 mon->class = class;
142 }
143
144 if (!(mon->name = CoTaskMemAlloc((lstrlenW(name) + 1) * sizeof(WCHAR))))
145 {
146 IMoniker_Release(&mon->IMoniker_iface);
147 return E_OUTOFMEMORY;
148 }
149 lstrcpyW(mon->name, name);
150 }
151
152 mon->type = type;
153
154 *ret = &mon->IMoniker_iface;
155
156 return S_OK;
157}
158
159/**********************************************************************
160 * IParseDisplayName_Vtbl
161 */
162static const IParseDisplayNameVtbl IParseDisplayName_Vtbl =
163{
168};
169
170/* The one instance of this class */
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:111
#define CHARS_IN_GUID
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const WCHAR cmW[]
static const WCHAR dmoW[]
static const WCHAR swW[]
static void DEVENUM_UnlockModule(void)
device_type
@ DEVICE_FILTER
@ DEVICE_DMO
@ DEVICE_CODEC
static void DEVENUM_LockModule(void)
MediaCatMoniker * DEVENUM_IMediaCatMoniker_Construct(void) DECLSPEC_HIDDEN
Definition: mediacatenum.c:786
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define wcschr
Definition: compat.h:17
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
static LPOLESTR
Definition: stg_prop.c:27
const GUID IID_IParseDisplayName
static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(IParseDisplayName *iface, IBindCtx *pbc, LPOLESTR name, ULONG *eaten, IMoniker **ret)
static ULONG WINAPI DEVENUM_IParseDisplayName_Release(IParseDisplayName *iface)
IParseDisplayName DEVENUM_ParseDisplayName
static const IParseDisplayNameVtbl IParseDisplayName_Vtbl
static ULONG WINAPI DEVENUM_IParseDisplayName_AddRef(IParseDisplayName *iface)
static HRESULT WINAPI DEVENUM_IParseDisplayName_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppv)
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define TRACE(s)
Definition: solgame.cpp:4
IMoniker IMoniker_iface
enum device_type type
Definition: name.c:39
uint32_t ULONG
Definition: typedefs.h:59
int ret
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define MK_E_SYNTAX
Definition: winerror.h:2785
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180