Removed some uses of the non-standard ICOM_THIS macro.
[wine/multimedia.git] / dlls / dxdiagn / container.c
blob04348c0d39a33776453adac8ea953328cdb7bf1d
1 /*
2 * IDxDiagContainer Implementation
3 *
4 * Copyright 2004 Raphael Junqueira
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "dxdiag_private.h"
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
29 /* IDxDiagContainer IUnknown parts follow: */
30 HRESULT WINAPI IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface, REFIID riid, LPVOID *ppobj)
32 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
34 if (IsEqualGUID(riid, &IID_IUnknown)
35 || IsEqualGUID(riid, &IID_IDxDiagContainer)) {
36 IDxDiagContainerImpl_AddRef(iface);
37 *ppobj = This;
38 return S_OK;
41 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
42 return E_NOINTERFACE;
45 ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface) {
46 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
47 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
48 return ++(This->ref);
51 ULONG WINAPI IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface) {
52 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
53 ULONG ref = --This->ref;
54 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
55 if (ref == 0) {
56 HeapFree(GetProcessHeap(), 0, This);
58 return ref;
61 /* IDxDiagContainer Interface follow: */
62 HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfChildContainers(PDXDIAGCONTAINER iface, DWORD* pdwCount) {
63 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
64 TRACE("(%p)\n", iface);
65 if (NULL == pdwCount) {
66 return E_INVALIDARG;
68 *pdwCount = This->nSubContainers;
69 return S_OK;
72 HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) {
73 IDxDiagContainerImpl_SubContainer* p = NULL;
74 DWORD i = 0;
75 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
77 TRACE("(%p, %lu, %s, %lu)\n", iface, dwIndex, debugstr_w(pwszContainer), cchContainer);
79 if (NULL == pwszContainer) {
80 return E_INVALIDARG;
82 if (256 > cchContainer) {
83 return DXDIAG_E_INSUFFICIENT_BUFFER;
86 p = This->subContainers;
87 while (NULL != p) {
88 if (dwIndex == i) {
89 if (cchContainer <= strlenW(p->contName)) {
90 return DXDIAG_E_INSUFFICIENT_BUFFER;
92 lstrcpynW(pwszContainer, p->contName, cchContainer);
93 return S_OK;
95 p = p->next;
96 ++i;
98 return E_INVALIDARG;
101 HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
102 IDxDiagContainerImpl_SubContainer* p = NULL;
103 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
105 FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszContainer), ppInstance);
107 if (NULL == ppInstance || NULL == pwszContainer) {
108 return E_INVALIDARG;
111 p = This->subContainers;
112 while (NULL != p) {
113 if (0 == lstrcmpW(p->contName, pwszContainer)) {
114 IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)p, &IID_IDxDiagContainer, (void**) ppInstance);
115 return S_OK;
117 p = p->next;
120 return E_INVALIDARG;
123 HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER iface, DWORD* pdwCount) {
124 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
125 FIXME("(%p, %p): stub\n", iface, pdwCount);
126 return S_OK;
129 HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) {
130 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
131 FIXME("(%p, %lu, %s, %lu): stub\n", iface, dwIndex, debugstr_w(pwszPropName), cchPropName);
132 return S_OK;
135 HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pvarProp) {
136 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
137 FIXME("(%p, %s, %p): stub\n", iface, debugstr_w(pwszPropName), pvarProp);
138 return S_OK;
142 IDxDiagContainerVtbl DxDiagContainer_Vtbl =
144 IDxDiagContainerImpl_QueryInterface,
145 IDxDiagContainerImpl_AddRef,
146 IDxDiagContainerImpl_Release,
147 IDxDiagContainerImpl_GetNumberOfChildContainers,
148 IDxDiagContainerImpl_EnumChildContainerNames,
149 IDxDiagContainerImpl_GetChildContainer,
150 IDxDiagContainerImpl_GetNumberOfProps,
151 IDxDiagContainerImpl_EnumPropNames,
152 IDxDiagContainerImpl_GetProp
156 HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj) {
157 IDxDiagContainerImpl* container;
159 TRACE("(%p, %p)\n", debugstr_guid(riid), ppobj);
161 container = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl));
162 if (NULL == container) {
163 *ppobj = NULL;
164 return E_OUTOFMEMORY;
166 container->lpVtbl = &DxDiagContainer_Vtbl;
167 container->ref = 0; /* will be inited with QueryInterface */
168 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj);