Author: janderwald
Date: Tue Oct 28 04:06:24 2008
New Revision: 37035
URL: 
http://svn.reactos.org/svn/reactos?rev=37035&view=rev
Log:
- Implement applying / canceling changes on close
- Temporary disable storing the TcpFilter settings
Modified:
    trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c
    trunk/reactos/dll/win32/netcfgx/netcfg_iface.c
    trunk/reactos/dll/win32/netcfgx/precomp.h
    trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c
Modified: trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/inetcfgc…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c [iso-8859-1] Tue Oct 28 04:06:24
2008
@@ -7,7 +7,6 @@
     LONG  ref;
     NetCfgComponentItem * pItem;
     INetCfgComponentPropertyUi * pProperty;
-    INetCfgComponentControl * pNCCC;
     INetCfg * pNCfg;
 }INetCfgComponentImpl;
@@ -20,8 +19,6 @@
     INetCfg * pNCfg;
 }IEnumNetCfgComponentImpl;
-
-
 HRESULT
 STDCALL
 INetCfgComponent_fnQueryInterface(
@@ -42,7 +39,6 @@
     return E_NOINTERFACE;
 }
-
 ULONG
 STDCALL
@@ -420,7 +416,7 @@
         return hr;
     }
     This->pProperty = pNCCPU;
-    This->pNCCC = pNCCC;
+    This->pItem->pNCCC = pNCCC;
     return S_OK;
 }
@@ -467,20 +463,14 @@
     pinfo.pszCaption = This->pItem->szDisplayName;
     iResult = PropertySheetW(&pinfo);
-
     CoTaskMemFree(hppages);
-    if (iResult < 0)
-    {
-        //FIXME
-        INetCfgComponentControl_CancelChanges(This->pNCCC);
-        return E_ABORT;
-    }
-    else
-    {
-        //FIXME
-        INetCfgComponentControl_ApplyRegistryChanges(This->pNCCC);
+    if (iResult > 0)
+    {
+        /* indicate that settings should be stored */
+        This->pItem->bChanged = TRUE;
         return S_OK;
     }
+    return S_FALSE;
 }
 static const INetCfgComponentVtbl vt_NetCfgComponent =
 {
Modified: trunk/reactos/dll/win32/netcfgx/netcfg_iface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfg_i…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/netcfg_iface.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/netcfg_iface.c [iso-8859-1] Tue Oct 28 04:06:24 2008
@@ -533,6 +533,56 @@
     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 @@
     if (!This->bInitialized)
         return NETCFG_E_NOT_INITIALIZED;
-
-    return E_NOTIMPL;
+    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 S_OK;
 }
 HRESULT
@@ -571,7 +625,11 @@
     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
Modified: trunk/reactos/dll/win32/netcfgx/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/precomp.…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/precomp.h [iso-8859-1] Tue Oct 28 04:06:24 2008
@@ -34,6 +34,7 @@
     ULONG Status;               //Y
     BOOL bChanged;              //Y
     struct tagNetCfgComponentItem * pNext;
+    INetCfgComponentControl * pNCCC;
 }NetCfgComponentItem;
 /* netcfg_iface.c */
Modified: trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/tcpipcon…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c [iso-8859-1] Tue Oct 28 04:06:24
2008
@@ -3129,22 +3129,29 @@
             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)
         {