- Implement applying / canceling changes on close

- Temporary disable storing the TcpFilter settings

svn path=/trunk/; revision=37035
This commit is contained in:
Johannes Anderwald 2008-10-28 09:06:24 +00:00
parent 31e02ce543
commit dfbb281b3a
4 changed files with 80 additions and 24 deletions

View file

@ -7,7 +7,6 @@ typedef struct
LONG ref;
NetCfgComponentItem * pItem;
INetCfgComponentPropertyUi * pProperty;
INetCfgComponentControl * pNCCC;
INetCfg * pNCfg;
}INetCfgComponentImpl;
@ -20,8 +19,6 @@ typedef struct
INetCfg * pNCfg;
}IEnumNetCfgComponentImpl;
HRESULT
STDCALL
INetCfgComponent_fnQueryInterface(
@ -43,7 +40,6 @@ INetCfgComponent_fnQueryInterface(
return E_NOINTERFACE;
}
ULONG
STDCALL
INetCfgComponent_fnAddRef(
@ -420,7 +416,7 @@ CreateNotificationObject(
return hr;
}
This->pProperty = pNCCPU;
This->pNCCC = pNCCC;
This->pItem->pNCCC = pNCCC;
return S_OK;
}
@ -467,20 +463,14 @@ INetCfgComponent_fnRaisePropertyUi(
pinfo.pszCaption = This->pItem->szDisplayName;
iResult = PropertySheetW(&pinfo);
CoTaskMemFree(hppages);
if (iResult < 0)
if (iResult > 0)
{
//FIXME
INetCfgComponentControl_CancelChanges(This->pNCCC);
return E_ABORT;
}
else
{
//FIXME
INetCfgComponentControl_ApplyRegistryChanges(This->pNCCC);
/* indicate that settings should be stored */
This->pItem->bChanged = TRUE;
return S_OK;
}
return S_FALSE;
}
static const INetCfgComponentVtbl vt_NetCfgComponent =
{

View file

@ -533,6 +533,56 @@ INetCfg_fnInitialize(
return S_OK;
}
VOID
ApplyOrCancelChanges(
NetCfgComponentItem *pHead,
const CLSID * lpClassGUID,
BOOL bApply)
{
HKEY hKey;
WCHAR szName[200];
LPOLESTR pszGuid;
while(pHead)
{
if (pHead->bChanged)
{
if (IsEqualGUID(lpClassGUID, &GUID_DEVCLASS_NET))
{
if (bApply)
{
if (StringFromCLSID(&pHead->InstanceId, &pszGuid) == NOERROR)
{
swprintf(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\%s", pszGuid);
CoTaskMemFree(pszGuid);
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pHead->szDisplayName, (wcslen(pHead->szDisplayName)+1) * sizeof(WCHAR));
RegCloseKey(hKey);
}
}
}
}
else if (pHead->pNCCC)
{
if (bApply)
{
INetCfgComponentControl_ApplyRegistryChanges(pHead->pNCCC);
//FIXME
// implement INetCfgPnpReconfigCallback and pass it to
//INetCfgComponentControl_ApplyPnpChanges(pHead->pNCCC, NULL);
}
else
{
INetCfgComponentControl_CancelChanges(pHead->pNCCC);
}
}
}
pHead = pHead->pNext;
}
}
HRESULT
STDCALL
INetCfg_fnUninitialize(
@ -557,8 +607,12 @@ INetCfg_fnApply(
if (!This->bInitialized)
return NETCFG_E_NOT_INITIALIZED;
ApplyOrCancelChanges(This->pNet, &GUID_DEVCLASS_NET, TRUE);
ApplyOrCancelChanges(This->pClient, &GUID_DEVCLASS_NETCLIENT, TRUE);
ApplyOrCancelChanges(This->pService, &GUID_DEVCLASS_NETSERVICE, TRUE);
ApplyOrCancelChanges(This->pProtocol, &GUID_DEVCLASS_NETTRANS, TRUE);
return E_NOTIMPL;
return S_OK;
}
HRESULT
@ -571,7 +625,11 @@ INetCfg_fnCancel(
if (!This->bInitialized)
return NETCFG_E_NOT_INITIALIZED;
return E_NOTIMPL;
ApplyOrCancelChanges(This->pClient, &GUID_DEVCLASS_NETCLIENT, FALSE);
ApplyOrCancelChanges(This->pService, &GUID_DEVCLASS_NETSERVICE, FALSE);
ApplyOrCancelChanges(This->pProtocol, &GUID_DEVCLASS_NETTRANS, FALSE);
return S_OK;
}
HRESULT

View file

@ -34,6 +34,7 @@ typedef struct tagNetCfgComponentItem
ULONG Status; //Y
BOOL bChanged; //Y
struct tagNetCfgComponentItem * pNext;
INetCfgComponentControl * pNCCC;
}NetCfgComponentItem;
/* netcfg_iface.c */

View file

@ -3129,22 +3129,29 @@ INetCfgComponentControl_fnApplyRegistryChanges(
RegSetValueExW(hKey, L"Domain", 0, REG_SZ, (LPBYTE)This->pCurrentConfig->pDNS->szDomain,
(wcslen(This->pCurrentConfig->pDNS->szDomain)+1) * sizeof(WCHAR));
}
#if 0
if (This->pCurrentConfig->pFilter)
{
RegSetValueExW(hKey, L"TCPAllowedPorts", 0, REG_MULTI_SZ,
if (This->pCurrentConfig->pFilter->szTCPAllowedPorts)
{
RegSetValueExW(hKey, L"TCPAllowedPorts", 0, REG_MULTI_SZ,
(LPBYTE)This->pCurrentConfig->pFilter->szTCPAllowedPorts,
This->pCurrentConfig->pFilter->TCPSize);
RegSetValueExW(hKey, L"UDPAllowedPorts", 0, REG_MULTI_SZ,
}
if (This->pCurrentConfig->pFilter->szUDPAllowedPorts)
{
RegSetValueExW(hKey, L"UDPAllowedPorts", 0, REG_MULTI_SZ,
(LPBYTE)This->pCurrentConfig->pFilter->szUDPAllowedPorts,
This->pCurrentConfig->pFilter->UDPSize);
RegSetValueExW(hKey, L"RawIPAllowedProtocols", 0, REG_MULTI_SZ,
}
if (This->pCurrentConfig->pFilter->szRawIPAllowedProtocols)
{
RegSetValueExW(hKey, L"RawIPAllowedProtocols", 0, REG_MULTI_SZ,
(LPBYTE)This->pCurrentConfig->pFilter->szRawIPAllowedProtocols,
This->pCurrentConfig->pFilter->IPSize);
}
}
#endif
RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD, (LPBYTE)&This->pCurrentConfig->DhcpEnabled, sizeof(DWORD));
if (This->pCurrentConfig->DhcpEnabled)
{