mirror of
https://github.com/reactos/wine.git
synced 2025-02-23 22:40:55 +00:00
dxdiagn: Transition to the information tree by making IDxDiagContainer view the information tree.
This commit is contained in:
parent
6ffcfe58c9
commit
a9d1f1bb4f
@ -81,13 +81,13 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfChildContainers(PDXDIAGCON
|
||||
if (NULL == pdwCount) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
*pdwCount = This->nSubContainers;
|
||||
*pdwCount = This->cont->nSubContainers;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) {
|
||||
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
||||
IDxDiagContainerImpl_SubContainer *p;
|
||||
IDxDiagContainerImpl_Container *p;
|
||||
DWORD i = 0;
|
||||
|
||||
TRACE("(%p, %u, %p, %u)\n", iface, dwIndex, pwszContainer, cchContainer);
|
||||
@ -96,7 +96,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAI
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(p, &This->subContainers, IDxDiagContainerImpl_SubContainer, entry)
|
||||
LIST_FOR_EACH_ENTRY(p, &This->cont->subContainers, IDxDiagContainerImpl_Container, entry)
|
||||
{
|
||||
if (dwIndex == i) {
|
||||
TRACE("Found container name %s, copying string\n", debugstr_w(p->contName));
|
||||
@ -112,14 +112,13 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAI
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
static HRESULT IDxDiagContainerImpl_GetChildContainerInternal(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
|
||||
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
||||
IDxDiagContainerImpl_SubContainer *p;
|
||||
static HRESULT IDxDiagContainerImpl_GetChildContainerInternal(IDxDiagContainerImpl_Container *cont, LPCWSTR pwszContainer, IDxDiagContainerImpl_Container **subcont) {
|
||||
IDxDiagContainerImpl_Container *p;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(p, &This->subContainers, IDxDiagContainerImpl_SubContainer, entry)
|
||||
LIST_FOR_EACH_ENTRY(p, &cont->subContainers, IDxDiagContainerImpl_Container, entry)
|
||||
{
|
||||
if (0 == lstrcmpW(p->contName, pwszContainer)) {
|
||||
*ppInstance = p->pCont;
|
||||
*subcont = p;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
@ -127,9 +126,9 @@ static HRESULT IDxDiagContainerImpl_GetChildContainerInternal(PDXDIAGCONTAINER i
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
|
||||
static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer **ppInstance) {
|
||||
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
||||
IDxDiagContainer* pContainer = (PDXDIAGCONTAINER)This;
|
||||
IDxDiagContainerImpl_Container *pContainer = This->cont;
|
||||
LPWSTR tmp, orig_tmp;
|
||||
INT tmp_len;
|
||||
WCHAR* cur;
|
||||
@ -154,7 +153,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER if
|
||||
if (!*(cur + 1)) break; /* Account for a lone terminating period, as in "cont1.cont2.". */
|
||||
TRACE("Trying to get parent container %s\n", debugstr_w(tmp));
|
||||
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer);
|
||||
if (FAILED(hr) || NULL == pContainer)
|
||||
if (FAILED(hr))
|
||||
goto on_error;
|
||||
cur++; /* go after '.' (just replaced by \0) */
|
||||
tmp = cur;
|
||||
@ -162,10 +161,11 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER if
|
||||
}
|
||||
|
||||
TRACE("Trying to get container %s\n", debugstr_w(tmp));
|
||||
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, ppInstance);
|
||||
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer);
|
||||
if (SUCCEEDED(hr)) {
|
||||
TRACE("Succeeded in getting the container instance\n");
|
||||
IDxDiagContainerImpl_AddRef(*ppInstance);
|
||||
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, pContainer, This->pProv, (void **)ppInstance);
|
||||
if (SUCCEEDED(hr))
|
||||
TRACE("Succeeded in getting the container instance\n");
|
||||
}
|
||||
|
||||
on_error:
|
||||
@ -179,7 +179,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER ifa
|
||||
if (NULL == pdwCount) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
*pdwCount = This->nProperties;
|
||||
*pdwCount = This->cont->nProperties;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface,
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(p, &This->properties, IDxDiagContainerImpl_Property, entry)
|
||||
LIST_FOR_EACH_ENTRY(p, &This->cont->properties, IDxDiagContainerImpl_Property, entry)
|
||||
{
|
||||
if (dwIndex == i) {
|
||||
TRACE("Found property name %s, copying string\n", debugstr_w(p->propName));
|
||||
@ -219,7 +219,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWS
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(p, &This->properties, IDxDiagContainerImpl_Property, entry)
|
||||
LIST_FOR_EACH_ENTRY(p, &This->cont->properties, IDxDiagContainerImpl_Property, entry)
|
||||
{
|
||||
if (0 == lstrcmpW(p->propName, pwszPropName)) {
|
||||
HRESULT hr = VariantClear(pvarProp);
|
||||
@ -233,63 +233,6 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWS
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp) {
|
||||
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
||||
IDxDiagContainerImpl_Property *pNew;
|
||||
|
||||
TRACE("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pVarProp);
|
||||
|
||||
if (NULL == pVarProp || NULL == pwszPropName) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
pNew = HeapAlloc(GetProcessHeap(), 0, sizeof(IDxDiagContainerImpl_Property));
|
||||
if (NULL == pNew) {
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
pNew->propName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pwszPropName) + 1) * sizeof(WCHAR));
|
||||
if (NULL == pNew->propName) {
|
||||
HeapFree(GetProcessHeap(), 0, pNew);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
lstrcpyW(pNew->propName, pwszPropName);
|
||||
VariantInit(&pNew->vProp);
|
||||
VariantCopy(&pNew->vProp, pVarProp);
|
||||
|
||||
list_add_tail(&This->properties, &pNew->entry);
|
||||
++This->nProperties;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont) {
|
||||
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
||||
IDxDiagContainerImpl_SubContainer *pNew;
|
||||
|
||||
TRACE("(%p, %s, %p)\n", iface, debugstr_w(pszContName), pSubCont);
|
||||
|
||||
if (NULL == pSubCont || NULL == pszContName) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
pNew = HeapAlloc(GetProcessHeap(), 0, sizeof(IDxDiagContainerImpl_SubContainer));
|
||||
if (NULL == pNew) {
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
pNew->contName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pszContName) + 1) * sizeof(WCHAR));
|
||||
if (NULL == pNew->contName) {
|
||||
HeapFree(GetProcessHeap(), 0, pNew);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
lstrcpyW(pNew->contName, pszContName);
|
||||
pNew->pCont = pSubCont;
|
||||
|
||||
list_add_tail(&This->subContainers, &pNew->entry);
|
||||
++This->nSubContainers;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IDxDiagContainerVtbl DxDiagContainer_Vtbl =
|
||||
{
|
||||
IDxDiagContainerImpl_QueryInterface,
|
||||
@ -304,21 +247,20 @@ static const IDxDiagContainerVtbl DxDiagContainer_Vtbl =
|
||||
};
|
||||
|
||||
|
||||
HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, IDxDiagProvider *pProv, LPVOID *ppobj) {
|
||||
HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, IDxDiagContainerImpl_Container *cont, IDxDiagProvider *pProv, LPVOID *ppobj) {
|
||||
IDxDiagContainerImpl* container;
|
||||
|
||||
TRACE("(%p, %p)\n", debugstr_guid(riid), ppobj);
|
||||
|
||||
container = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl));
|
||||
container = HeapAlloc(GetProcessHeap(), 0, sizeof(IDxDiagContainerImpl));
|
||||
if (NULL == container) {
|
||||
*ppobj = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
container->lpVtbl = &DxDiagContainer_Vtbl;
|
||||
container->ref = 0; /* will be inited with QueryInterface */
|
||||
container->cont = cont;
|
||||
container->pProv = pProv;
|
||||
IDxDiagProvider_AddRef(pProv);
|
||||
list_init(&container->properties);
|
||||
list_init(&container->subContainers);
|
||||
return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj);
|
||||
}
|
||||
|
@ -33,16 +33,7 @@
|
||||
/* DXDiag Interfaces: */
|
||||
typedef struct IDxDiagProviderImpl IDxDiagProviderImpl;
|
||||
typedef struct IDxDiagContainerImpl IDxDiagContainerImpl;
|
||||
|
||||
typedef struct IDxDiagContainerImpl_Container {
|
||||
struct list entry;
|
||||
WCHAR *contName;
|
||||
|
||||
struct list subContainers;
|
||||
DWORD nSubContainers;
|
||||
struct list properties;
|
||||
DWORD nProperties;
|
||||
} IDxDiagContainerImpl_Container;
|
||||
typedef struct IDxDiagContainerImpl_Container IDxDiagContainerImpl_Container;
|
||||
|
||||
/* ---------------- */
|
||||
/* IDxDiagProvider */
|
||||
@ -65,11 +56,15 @@ struct IDxDiagProviderImpl {
|
||||
/* IDxDiagContainer */
|
||||
/* ---------------- */
|
||||
|
||||
typedef struct IDxDiagContainerImpl_SubContainer {
|
||||
struct IDxDiagContainerImpl_Container {
|
||||
struct list entry;
|
||||
WCHAR *contName;
|
||||
IDxDiagContainer *pCont;
|
||||
} IDxDiagContainerImpl_SubContainer;
|
||||
|
||||
struct list subContainers;
|
||||
DWORD nSubContainers;
|
||||
struct list properties;
|
||||
DWORD nProperties;
|
||||
};
|
||||
|
||||
typedef struct IDxDiagContainerImpl_Property {
|
||||
struct list entry;
|
||||
@ -86,18 +81,12 @@ struct IDxDiagContainerImpl {
|
||||
const IDxDiagContainerVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
/* IDxDiagContainer fields */
|
||||
struct list properties;
|
||||
struct list subContainers;
|
||||
DWORD nProperties;
|
||||
DWORD nSubContainers;
|
||||
IDxDiagContainerImpl_Container *cont;
|
||||
IDxDiagProvider *pProv;
|
||||
};
|
||||
|
||||
/* IUnknown: */
|
||||
extern HRESULT WINAPI IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface, REFIID riid, LPVOID *ppobj);
|
||||
/** Internal */
|
||||
extern HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp);
|
||||
extern HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont);
|
||||
|
||||
/**
|
||||
* factories
|
||||
@ -105,7 +94,7 @@ extern HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER if
|
||||
extern HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
|
||||
|
||||
/** internal factory */
|
||||
extern HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, IDxDiagProvider *, LPVOID *ppobj);
|
||||
extern HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, IDxDiagContainerImpl_Container *cont, IDxDiagProvider *pProv, LPVOID *ppobj);
|
||||
|
||||
/**********************************************************************
|
||||
* Dll lifetime tracking declaration for dxdiagn.dll
|
||||
|
@ -41,8 +41,6 @@
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
|
||||
|
||||
static HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont, IDxDiagProvider *pProv);
|
||||
|
||||
static HRESULT build_information_tree(IDxDiagContainerImpl_Container **pinfo_root);
|
||||
static void free_information_tree(IDxDiagContainerImpl_Container *node);
|
||||
|
||||
@ -120,9 +118,7 @@ static HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDI
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
|
||||
HRESULT hr;
|
||||
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
|
||||
IDxDiagContainer *root;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppInstance);
|
||||
|
||||
@ -130,14 +126,8 @@ static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface
|
||||
return CO_E_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (IDxDiagProvider *)This, (void **)&root);
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
DXDiag_InitRootDXDiagContainer(root, (IDxDiagProvider *)This);
|
||||
|
||||
return IDxDiagContainerImpl_QueryInterface(root, &IID_IDxDiagContainer, (void **)ppInstance);
|
||||
return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, This->info_root,
|
||||
(IDxDiagProvider *)This, (void **)ppInstance);
|
||||
}
|
||||
|
||||
static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
|
||||
@ -195,56 +185,6 @@ static void get_display_device_id(WCHAR *szIdentifierBuffer)
|
||||
FreeLibrary(d3d9_handle);
|
||||
}
|
||||
|
||||
static HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont, IDxDiagProvider *pProv) {
|
||||
static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
|
||||
static const WCHAR DxDiag_DisplayDevices[] = {'D','x','D','i','a','g','_','D','i','s','p','l','a','y','D','e','v','i','c','e','s',0};
|
||||
static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
|
||||
static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
|
||||
static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
|
||||
static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
|
||||
static const WCHAR DxDiag_SystemDevices[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','D','e','v','i','c','e','s',0};
|
||||
static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
|
||||
static const WCHAR DxDiag_DirectShowFilters[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','h','o','w','F','i','l','t','e','r','s',0};
|
||||
static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
|
||||
|
||||
const WCHAR *containers[] =
|
||||
{
|
||||
DxDiag_SystemInfo,
|
||||
DxDiag_DisplayDevices,
|
||||
DxDiag_DirectSound,
|
||||
DxDiag_DirectMusic,
|
||||
DxDiag_DirectInput,
|
||||
DxDiag_DirectPlay,
|
||||
DxDiag_SystemDevices,
|
||||
DxDiag_DirectXFiles,
|
||||
DxDiag_DirectShowFilters,
|
||||
DxDiag_LogicalDisks,
|
||||
};
|
||||
|
||||
size_t index;
|
||||
|
||||
TRACE("(%p)\n", pRootCont);
|
||||
|
||||
for (index = 0; index < sizeof(containers)/sizeof(containers[0]); index++)
|
||||
{
|
||||
IDxDiagContainer* pSubCont;
|
||||
HRESULT hr;
|
||||
|
||||
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, pProv, (void**) &pSubCont);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, containers[index], pSubCont);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
IDxDiagContainer_Release(pSubCont);
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void free_property_information(IDxDiagContainerImpl_Property *prop)
|
||||
{
|
||||
VariantClear(&prop->vProp);
|
||||
|
@ -280,7 +280,7 @@ static void test_GetChildContainer(void)
|
||||
ok(hr == S_OK,
|
||||
"Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
todo_wine ok(ptr != child, "Expected the two pointers (%p vs. %p) to be unequal\n", child, ptr);
|
||||
ok(ptr != child, "Expected the two pointers (%p vs. %p) to be unequal\n", child, ptr);
|
||||
|
||||
IDxDiagContainer_Release(ptr);
|
||||
IDxDiagContainer_Release(child);
|
||||
|
Loading…
x
Reference in New Issue
Block a user