Author: janderwald Date: Tue Sep 9 09:29:25 2008 New Revision: 36084
URL: http://svn.reactos.org/svn/reactos?rev=36084&view=rev Log: - Implement INetCfgComponent_RaisePropertyUi
Modified: trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c trunk/reactos/dll/win32/netcfgx/netcfg_iface.c trunk/reactos/dll/win32/netcfgx/precomp.h
Modified: trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/inetcfgco... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c [iso-8859-1] Tue Sep 9 09:29:25 2008 @@ -6,6 +6,8 @@ const INetCfgComponent * lpVtbl; LONG ref; NetCfgComponentItem * pItem; + INetCfgComponentPropertyUi * pProperty; + INetCfg * pNCfg; }INetCfgComponentImpl;
typedef struct @@ -14,6 +16,7 @@ LONG ref; NetCfgComponentItem * pCurrent; NetCfgComponentItem * pHead; + INetCfg * pNCfg; }IEnumNetCfgComponentImpl;
@@ -312,6 +315,103 @@ return E_FAIL; }
+ +HRESULT +CreateNotificationObject( + INetCfgComponentImpl * This, + INetCfgComponent * iface, + IUnknown *pUnk, + INetCfgComponentPropertyUi ** pOut) +{ + WCHAR szName[150]; + HKEY hKey; + DWORD dwSize, dwType; + GUID CLSID_NotifyObject; + LPOLESTR pStr; + INetCfgComponentPropertyUi * pNCCPU; + INetCfgComponentControl * pNCCC; + HRESULT hr; + LONG lRet; + CLSID ClassGUID, InstanceGUID; + + wcscpy(szName,L"SYSTEM\CurrentControlSet\Control\Network\"); + + /* get the Class GUID */ + hr = INetCfgComponent_GetClassGuid(iface, &ClassGUID); + if (FAILED(hr)) + return hr; + + hr = StringFromCLSID(&ClassGUID, &pStr); + if (FAILED(hr)) + return hr; + + wcscat(szName, pStr); + CoTaskMemFree(pStr); + wcscat(szName, L"\"); + + /* get the Class GUID */ + hr = INetCfgComponent_GetInstanceGuid(iface, &InstanceGUID); + if (FAILED(hr)) + return hr; + + hr = StringFromCLSID(&InstanceGUID, &pStr); + if (FAILED(hr)) + return hr; + + wcscat(szName, pStr); + CoTaskMemFree(pStr); + wcscat(szName, L"\NDI"); + + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) + return E_FAIL; + + dwSize = sizeof(szName); + lRet = RegQueryValueExW(hKey, L"ClsID", NULL, &dwType, (LPBYTE)szName, &dwSize); + RegCloseKey(hKey); + + if (lRet != ERROR_SUCCESS && dwType != REG_SZ) + return E_FAIL; + + hr = CLSIDFromString(szName, &CLSID_NotifyObject); + if (FAILED(hr)) + return E_FAIL; + + hr = CoCreateInstance(&CLSID_NotifyObject, NULL, CLSCTX_INPROC_SERVER, &IID_INetCfgComponentPropertyUi, (LPVOID*)&pNCCPU); + if (FAILED(hr)) + return E_FAIL; + + hr = INetCfgComponentPropertyUi_QueryInterface(pNCCPU, &IID_INetCfgComponentControl, (LPVOID*)&pNCCC); + if (FAILED(hr)) + { + INetCfgComponentPropertyUi_Release(pNCCPU); + return hr; + } + + hr = INetCfgComponentPropertyUi_QueryPropertyUi(pNCCPU, pUnk); + if (FAILED(hr)) + { + INetCfgComponentPropertyUi_Release(pNCCPU); + return hr; + } + + hr = INetCfgComponentControl_Initialize(pNCCC, iface, This->pNCfg, FALSE); + if (FAILED(hr)) + { + INetCfgComponentControl_Release(pNCCC); + INetCfgComponentPropertyUi_Release(pNCCPU); + return hr; + } + + hr = INetCfgComponentPropertyUi_SetContext(pNCCPU, pUnk); + if (FAILED(hr)) + { + INetCfgComponentPropertyUi_Release(pNCCPU); + return hr; + } + *pOut = pNCCPU; + return S_OK; +} + HRESULT STDCALL INetCfgComponent_fnRaisePropertyUi( @@ -320,8 +420,46 @@ IN DWORD dwFlags, IN IUnknown *pUnk) { - - return E_NOTIMPL; + HRESULT hr; + DWORD dwDefPages; + UINT Pages; + PROPSHEETHEADERW pinfo; + HPROPSHEETPAGE * hppages; + INT_PTR iResult; + INetCfgComponentImpl * This = (INetCfgComponentImpl*)iface; + + if (!This->pProperty) + { + hr = CreateNotificationObject(This,iface, pUnk, &This->pProperty); + if (FAILED(hr)) + return hr; + } + + dwDefPages = 1; + hr = INetCfgComponentPropertyUi_MergePropPages(This->pProperty, &dwDefPages, (BYTE**)&hppages, &Pages, hwndParent, NULL); + if (FAILED(hr)) + { + return hr; + } + ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW)); + pinfo.dwSize = sizeof(PROPSHEETHEADERW); + pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW; + pinfo.u3.phpage = hppages; + pinfo.hwndParent = hwndParent; + pinfo.pszCaption = This->pItem->szDisplayName; + + iResult = PropertySheetW(&pinfo); + CoTaskMemFree(hppages); + if (iResult < 0) + { + INetCfgComponentPropertyUi_CancelProperties(This->pProperty); + return E_ABORT; + } + else + { + INetCfgComponentPropertyUi_ApplyProperties(This->pProperty); + return S_OK; + } } static const INetCfgComponentVtbl vt_NetCfgComponent = { @@ -344,7 +482,7 @@
HRESULT STDCALL -INetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem) +INetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem, INetCfg * pNCfg) { INetCfgComponentImpl *This;
@@ -357,7 +495,9 @@
This->ref = 1; This->lpVtbl = (const INetCfgComponent*)&vt_NetCfgComponent; + This->pProperty = NULL; This->pItem = pItem; + This->pNCfg = pNCfg;
if (!SUCCEEDED (INetCfgComponent_QueryInterface ((INetCfgComponent*)This, riid, ppv))) { @@ -441,7 +581,7 @@ if (!This->pCurrent) return S_FALSE;
- hr = INetCfgComponent_Constructor (NULL, &IID_INetCfgComponent, (LPVOID*)rgelt, This->pCurrent); + hr = INetCfgComponent_Constructor (NULL, &IID_INetCfgComponent, (LPVOID*)rgelt, This->pCurrent, This->pNCfg); if (SUCCEEDED(hr)) { This->pCurrent = This->pCurrent->pNext; @@ -504,7 +644,7 @@
HRESULT STDCALL -IEnumNetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem) +IEnumNetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem, INetCfg * pNCfg) { IEnumNetCfgComponentImpl *This;
@@ -519,6 +659,7 @@ This->lpVtbl = (const IEnumNetCfgComponent*)&vt_EnumNetCfgComponent; This->pCurrent = pItem; This->pHead = pItem; + This->pNCfg = pNCfg;
if (!SUCCEEDED (IEnumNetCfgComponent_QueryInterface ((INetCfgComponent*)This, riid, ppv))) {
Modified: trunk/reactos/dll/win32/netcfgx/netcfg_iface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfg_if... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/netcfg_iface.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/netcfg_iface.c [iso-8859-1] Tue Sep 9 09:29:25 2008 @@ -425,13 +425,14 @@ FindNetworkComponent( NetCfgComponentItem * pHead, LPCWSTR pszwComponentId, - INetCfgComponent **pComponent) + INetCfgComponent **pComponent, + INetCfg * iface) { while(pHead) { if (!wcsicmp(pHead->szId, pszwComponentId)) { - return INetCfgComponent_Constructor(NULL, &IID_INetCfgComponent, (LPVOID*)pComponent, pHead); + return INetCfgComponent_Constructor(NULL, &IID_INetCfgComponent, (LPVOID*)pComponent, pHead, iface); } pHead = pHead->pNext; } @@ -586,13 +587,13 @@ return NETCFG_E_NOT_INITIALIZED;
if (IsEqualGUID(&GUID_DEVCLASS_NET, pguidClass)) - return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pNet); + return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pNet, iface); else if (IsEqualGUID(&GUID_DEVCLASS_NETCLIENT, pguidClass)) - return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pClient); + return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pClient, iface); else if (IsEqualGUID(&GUID_DEVCLASS_NETSERVICE, pguidClass)) - return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pService); + return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pService, iface); else if (IsEqualGUID(&GUID_DEVCLASS_NETTRANS, pguidClass)) - return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pProtocol); + return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pProtocol, iface); else return E_NOINTERFACE; } @@ -611,15 +612,15 @@ if (!This->bInitialized) return NETCFG_E_NOT_INITIALIZED;
- hr = FindNetworkComponent(This->pClient, pszwComponentId, pComponent); + hr = FindNetworkComponent(This->pClient, pszwComponentId, pComponent, iface); if (hr == S_OK) return hr;
- hr = FindNetworkComponent(This->pService, pszwComponentId, pComponent); + hr = FindNetworkComponent(This->pService, pszwComponentId, pComponent, iface); if (hr == S_OK) return hr;
- hr = FindNetworkComponent(This->pProtocol, pszwComponentId, pComponent); + hr = FindNetworkComponent(This->pProtocol, pszwComponentId, pComponent, iface); if (hr == S_OK) return hr;
Modified: trunk/reactos/dll/win32/netcfgx/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/precomp.h... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/precomp.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/precomp.h [iso-8859-1] Tue Sep 9 09:29:25 2008 @@ -11,6 +11,7 @@ #include <stdio.h> #include <iphlpapi.h> #include <olectl.h> +#include <netcfgn.h>
typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); typedef struct { @@ -43,7 +44,7 @@ extern HINSTANCE netcfgx_hInstance;
/* inetcfgcomp_iface.c */ -HRESULT STDCALL INetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem); -HRESULT STDCALL IEnumNetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem); +HRESULT STDCALL INetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem,INetCfg * iface); +HRESULT STDCALL IEnumNetCfgComponent_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv, NetCfgComponentItem * pItem, INetCfg * iface);
#endif