[NETSHELL] Read, write and display the 'Notify me when this connection...' option...
authorEric Kohl <eric.kohl@reactos.org>
Sun, 23 Sep 2018 21:31:00 +0000 (23:31 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 23 Sep 2018 21:31:00 +0000 (23:31 +0200)
dll/shellext/netshell/connectmanager.cpp
dll/shellext/netshell/lanconnectui.cpp

index 1376c24..8b33b59 100644 (file)
@@ -239,7 +239,7 @@ CNetConnection::GetProperties(NETCON_PROPERTIES **ppProps)
     HKEY hKey;
     LPOLESTR pStr;
     WCHAR szName[140];
-    DWORD dwShowIcon, dwType, dwSize;
+    DWORD dwShowIcon, dwNotifyDisconnect, dwType, dwSize;
     NETCON_PROPERTIES * pProperties;
     HRESULT hr;
 
@@ -288,6 +288,16 @@ CNetConnection::GetProperties(NETCON_PROPERTIES **ppProps)
                 else
                     pProperties->dwCharacter &= ~NCCF_SHOW_ICON;
             }
+
+            dwSize = sizeof(dwNotifyDisconnect);
+            if (RegQueryValueExW(hKey, L"IpCheckingEnabled", NULL, &dwType, (LPBYTE)&dwNotifyDisconnect, &dwSize) == ERROR_SUCCESS && dwType == REG_DWORD)
+            {
+                if (dwNotifyDisconnect)
+                    pProperties->dwCharacter |= NCCF_NOTIFY_DISCONNECTED;
+                else
+                    pProperties->dwCharacter &= ~NCCF_NOTIFY_DISCONNECTED;
+            }
+
             dwSize = sizeof(szName);
             if (RegQueryValueExW(hKey, L"Name", NULL, &dwType, (LPBYTE)szName, &dwSize) == ERROR_SUCCESS)
             {
@@ -503,7 +513,7 @@ NormalizeOperStatus(
 BOOL
 CNetConnectionManager::EnumerateINetConnections()
 {
-    DWORD dwSize, dwResult, dwIndex, dwAdapterIndex, dwShowIcon;
+    DWORD dwSize, dwResult, dwIndex, dwAdapterIndex, dwShowIcon, dwNotifyDisconnect;
     MIB_IFTABLE *pIfTable;
     MIB_IFROW IfEntry;
     IP_ADAPTER_INFO * pAdapterInfo;
@@ -641,6 +651,12 @@ CNetConnectionManager::EnumerateINetConnections()
                 if (dwShowIcon)
                     pNew->Props.dwCharacter |= NCCF_SHOW_ICON;
             }
+            dwSize = sizeof(dwNotifyDisconnect);
+            if (RegQueryValueExW(hSubKey, L"IpCheckingEnabled", NULL, NULL, (LPBYTE)&dwNotifyDisconnect, &dwSize) == ERROR_SUCCESS)
+            {
+                if (dwNotifyDisconnect)
+                    pNew->Props.dwCharacter |= NCCF_NOTIFY_DISCONNECTED;
+            }
             RegCloseKey(hSubKey);
         }
 
index b5ef94b..6d1037f 100644 (file)
@@ -350,7 +350,7 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
     PNET_ITEM pItem;
     CNetConnectionPropertyUi * This;
     LPPSHNOTIFY lppsn;
-    DWORD dwShowIcon;
+    DWORD dwShowIcon, dwNotifyDisconnect;
     HRESULT hr;
     WCHAR szKey[200];
     LPOLESTR pStr;
@@ -382,6 +382,10 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
                 else
                     dwShowIcon = 0;
 
+                if (SendDlgItemMessageW(hwndDlg, IDC_NOTIFYNOCONNECTION, BM_GETCHECK, 0, 0) == BST_CHECKED)
+                    dwNotifyDisconnect = 1;
+                else
+                    dwNotifyDisconnect = 0;
 
                 if (StringFromCLSID((CLSID)This->m_pProperties->guidId, &pStr) == ERROR_SUCCESS)
                 {
@@ -390,6 +394,7 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
                     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_WRITE, &hKey) == ERROR_SUCCESS)
                     {
                         RegSetValueExW(hKey, L"ShowIcon", 0, REG_DWORD, (LPBYTE)&dwShowIcon, sizeof(DWORD));
+                        RegSetValueExW(hKey, L"IpCheckingEnabled", 0, REG_DWORD, (LPBYTE)&dwNotifyDisconnect, sizeof(DWORD));
                         RegCloseKey(hKey);
                     }
                 }