2 * IDxDiagProvider Implementation
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
23 #include "dxdiag_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
28 /* IDxDiagProvider IUnknown parts follow: */
29 HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID riid, LPVOID *ppobj)
31 ICOM_THIS(IDxDiagProviderImpl,iface);
33 if (IsEqualGUID(riid, &IID_IUnknown)
34 || IsEqualGUID(riid, &IID_IDxDiagProvider)) {
35 IDxDiagProviderImpl_AddRef(iface);
40 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
44 ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) {
45 ICOM_THIS(IDxDiagProviderImpl,iface);
46 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
50 ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) {
51 ICOM_THIS(IDxDiagProviderImpl,iface);
52 ULONG ref = --This->ref;
53 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
55 HeapFree(GetProcessHeap(), 0, This);
60 /* IDxDiagProvider Interface follow: */
61 HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS* pParams) {
62 ICOM_THIS(IDxDiagProviderImpl, iface);
63 TRACE("(%p,%p)\n", iface, pParams);
65 if (NULL == pParams) {
68 if (pParams->dwSize != sizeof(DXDIAG_INIT_PARAMS)) {
73 memcpy(&This->params, pParams, pParams->dwSize);
77 HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
79 ICOM_THIS(IDxDiagProviderImpl, iface);
80 TRACE("(%p,%p)\n", iface, ppInstance);
82 if (NULL == ppInstance) {
85 if (FALSE == This->init) {
86 return E_INVALIDARG; /* should be E_CO_UNINITIALIZED */
88 if (NULL == This->pRootContainer) {
89 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &This->pRootContainer);
94 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance);
97 IDxDiagProviderVtbl DxDiagProvider_Vtbl =
99 IDxDiagProviderImpl_QueryInterface,
100 IDxDiagProviderImpl_AddRef,
101 IDxDiagProviderImpl_Release,
102 IDxDiagProviderImpl_Initialize,
103 IDxDiagProviderImpl_GetRootContainer
106 HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
107 IDxDiagProviderImpl* provider;
109 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
111 provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
112 if (NULL == provider) {
114 return E_OUTOFMEMORY;
116 provider->lpVtbl = &DxDiagProvider_Vtbl;
117 provider->ref = 0; /* will be inited with QueryInterface */
118 return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER)provider, riid, ppobj);