]> repos.lx-s.de Git - winmute.git/commitdiff
Added new dialog for WiFi detection.
authorAlexander Steinhöfer <kontakt@lx-s.de>
Wed, 13 Apr 2022 13:35:04 +0000 (15:35 +0200)
committerAlexander Steinhöfer <kontakt@lx-s.de>
Wed, 13 Apr 2022 13:35:04 +0000 (15:35 +0200)
WinMute/SettingsDlg.cpp
WinMute/Settings_WifiDlg.cpp [new file with mode: 0644]
WinMute/WMSettings.cpp
WinMute/WMSettings.h
WinMute/WinMute.cpp
WinMute/WinMute.rc
WinMute/WinMute.vcxproj
WinMute/WinMute.vcxproj.filters
WinMute/resource.h

index 0d13d19cdb3ed0942b2183b0c63a875598e7d4f4..931bef86f67bd2614b10f73d5833882a8d634f7d 100644 (file)
@@ -37,6 +37,7 @@ enum SettingsTabsIDs {
    SETTINGS_TAB_GENERAL = 0,
    SETTINGS_TAB_MUTE,
    SETTINGS_TAB_QUIETHOURS,
+   SETTINGS_TAB_WIFI,
    SETTINGS_TAB_COUNT
 };
 
@@ -57,6 +58,7 @@ struct SettingsDlgData {
 extern INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND, UINT, WPARAM, LPARAM);
 extern INT_PTR CALLBACK Settings_GeneralDlgProc(HWND, UINT, WPARAM, LPARAM);
 extern INT_PTR CALLBACK Settings_MuteDlgProc(HWND, UINT, WPARAM, LPARAM);
+extern INT_PTR CALLBACK Settings_GeneralWifiDlgProc(HWND, UINT, WPARAM, LPARAM);
 
 static void InsertTabItem(HWND hTabCtrl, UINT id, const TCHAR* itemName)
 {
@@ -105,6 +107,7 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar
       InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_GENERAL, _T("General"));
       InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_MUTE, _T("Mute"));
       InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_QUIETHOURS, _T("Quiet Hours"));
+      InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_WIFI, _T("WLAN"));
 
       dlgData->hTabs[SETTINGS_TAB_GENERAL] = CreateDialogParam(
          nullptr,
@@ -124,6 +127,12 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar
          dlgData->hTabCtrl,
          Settings_QuietHoursDlgProc,
          reinterpret_cast<LPARAM>(settings));
+      dlgData->hTabs[SETTINGS_TAB_WIFI] = CreateDialogParam(
+         nullptr,
+         MAKEINTRESOURCE(IDD_SETTINGS_WIFI),
+         dlgData->hTabCtrl,
+         Settings_GeneralWifiDlgProc,
+         reinterpret_cast<LPARAM>(settings));
 
       // Init tab pages
       for (int i = 0; i < SETTINGS_TAB_COUNT; ++i) {
diff --git a/WinMute/Settings_WifiDlg.cpp b/WinMute/Settings_WifiDlg.cpp
new file mode 100644 (file)
index 0000000..f0db2a7
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ WinMute
+           Copyright (c) 2022, Alexander Steinhoefer
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+    * Neither the name of the author nor the names of its contributors may
+      be used to endorse or promote products derived from this software
+      without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+#include "common.h"
+
+static constexpr int SSID_MAX_LEN = 32;
+
+struct WiFiData {
+   tstring ssidName;
+};
+
+INT_PTR CALLBACK Settings_GeneralWifiAddDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+   switch (msg) {
+   case WM_INITDIALOG: {
+      HWND hSsid = GetDlgItem(hDlg, IDC_WIFI_NAME);
+      WiFiData* wifiData = reinterpret_cast<WiFiData*>(lParam);
+      if (wifiData == nullptr) {
+         return FALSE;
+      }
+      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(wifiData));
+
+      if (wifiData->ssidName.length() == 0) {
+         if (!SetWindowText(hDlg, _T("Add WiFi network"))) {
+            PrintWindowsError(_T("SetWindowText"), GetLastError());
+            return FALSE;
+         }
+      } else {
+         if (!SetWindowText(hDlg, _T("Edit WiFi network"))
+            || !SetWindowText(
+               GetDlgItem(hDlg, IDC_WIFI_NAME),
+               wifiData->ssidName.c_str())) {
+            PrintWindowsError(_T("SetWindowText"), GetLastError());
+            return FALSE;
+         }
+      }
+      Edit_LimitText(hSsid, SSID_MAX_LEN);
+      if (GetDlgCtrlID(reinterpret_cast<HWND>(wParam)) != IDC_WIFI_NAME) {
+         SetFocus(hSsid);
+         return FALSE;
+      }
+      return TRUE;
+   }
+   case WM_COMMAND:
+      if (LOWORD(wParam) == IDOK) {
+         HWND hSsid = GetDlgItem(hDlg, IDC_WIFI_NAME);
+         int textLen = Edit_GetTextLength(hSsid);
+         if (textLen == 0) {
+            EDITBALLOONTIP ebt;
+            ZeroMemory(&ebt, sizeof(ebt));
+            ebt.cbStruct = sizeof(ebt);
+            ebt.pszText = _T("Please enter a SSID/WIFI name");
+            ebt.pszTitle = _T("SSID Name");
+            ebt.ttiIcon = TTI_WARNING_LARGE;
+            Edit_ShowBalloonTip(hSsid, &ebt);
+         } else {
+            TCHAR ssidBuf[SSID_MAX_LEN + 1];
+            WiFiData* wifiData = reinterpret_cast<WiFiData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+            if (wifiData != nullptr) {
+               Edit_GetText(hSsid, ssidBuf, ARRAY_SIZE(ssidBuf));
+               wifiData->ssidName = ssidBuf;
+               EndDialog(hDlg, 0);
+            } else {
+               EndDialog(hDlg, 1);
+            }  
+         }
+      } else if (LOWORD(wParam) == IDCANCEL) {
+         EndDialog(hDlg, 1);
+      }
+      return FALSE;
+   case WM_CLOSE:
+      EndDialog(hDlg, 1);
+      return TRUE;
+   default:
+      break;
+   }
+   return FALSE;
+}
+
+INT_PTR CALLBACK Settings_GeneralWifiDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+   switch (msg) {
+   case WM_INITDIALOG:
+   {
+      if (IsAppThemed()) {
+         EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB);
+      }
+      WMSettings* settings = reinterpret_cast<WMSettings*>(lParam);
+      assert(settings != nullptr);
+      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
+
+      Button_Enable(GetDlgItem(hDlg, IDC_WIFI_EDIT), FALSE);
+      Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVE), FALSE);
+
+      HWND hList = GetDlgItem(hDlg, IDC_WIFI_LIST);
+      const auto networks = settings->GetWifiNetworks();
+      for (const auto& n : networks) {
+         ListBox_AddString(hList, n.c_str());
+      }
+      Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVEALL),
+                    ListBox_GetCount(hList) > 0);
+      return TRUE;
+   }
+   case WM_COMMAND:
+   {
+      if (LOWORD(wParam) == IDC_WIFI_LIST) {
+         HWND hList = GetDlgItem(hDlg, IDC_WIFI_LIST);
+         if (HIWORD(wParam) == LBN_SELCHANGE || HIWORD(wParam) == LBN_SELCANCEL) {
+            bool entrySelected = (ListBox_GetCurSel(hList) != LB_ERR);
+            Button_Enable(GetDlgItem(hDlg, IDC_WIFI_EDIT), entrySelected);
+            Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVE), entrySelected);
+         } else if (HIWORD(wParam) == LBN_KILLFOCUS) {
+            bool entrySelected = (ListBox_GetCurSel(hList) != LB_ERR);
+            Button_Enable(GetDlgItem(hDlg, IDC_WIFI_EDIT), entrySelected);
+            Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVE), entrySelected);
+         }
+      } else if (LOWORD(wParam) == IDC_WIFI_ADD) {
+         WiFiData wifiData;
+         if (DialogBoxParam(
+               NULL,
+               MAKEINTRESOURCE(IDD_SETTINGS_WIFI_ADD),
+               hDlg,
+               Settings_GeneralWifiAddDlgProc,
+               reinterpret_cast<LPARAM>(&wifiData)) == 0) {
+            ListBox_AddString(
+               GetDlgItem(hDlg, IDC_WIFI_LIST),
+               wifiData.ssidName.c_str());
+            HWND hRemoveAll = GetDlgItem(hDlg, IDC_WIFI_REMOVEALL);
+            if (!IsWindowEnabled(hRemoveAll)) {
+               Button_Enable(hRemoveAll, TRUE);
+            }
+         }
+      } else if (LOWORD(wParam) == IDC_WIFI_EDIT) {
+         HWND hList = GetDlgItem(hDlg, IDC_WIFI_LIST);
+         WPARAM sel = ListBox_GetCurSel(hList);
+         if (sel != LB_ERR) {
+            int len = ListBox_GetTextLen(hList, sel);
+            TCHAR * textBuf = NULL;
+            if (len != LB_ERR) {
+               if ((textBuf = new TCHAR[len + 1]) != NULL) {
+                  ListBox_GetText(hList, sel, textBuf);
+
+                  WiFiData wifiData;
+                  wifiData.ssidName = textBuf;
+                  delete[] textBuf;
+
+                  if (DialogBoxParam(
+                        NULL,
+                        MAKEINTRESOURCE(IDD_SETTINGS_WIFI_ADD),
+                        hDlg,
+                        Settings_GeneralWifiAddDlgProc,
+                        reinterpret_cast<LPARAM>(&wifiData)) == 0) {
+                     ListBox_InsertString(hList, sel, wifiData.ssidName.c_str());
+                     ListBox_DeleteString(hList, sel + 1);
+                  }
+               }
+            }
+         }
+      } else if (LOWORD(wParam) == IDC_WIFI_REMOVE) {
+         HWND hList = GetDlgItem(hDlg, IDC_WIFI_LIST);
+         WPARAM sel = ListBox_GetCurSel(hList);
+         if (sel != LB_ERR) {
+            ListBox_DeleteString(hList, sel);
+            if (ListBox_GetCount(hList) == 0) {
+               Button_Enable(GetDlgItem(hDlg, IDC_WIFI_EDIT), FALSE);
+               Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVE), FALSE);
+               Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVEALL), FALSE);
+            }
+         }
+      } else if (LOWORD(wParam) == IDC_WIFI_REMOVEALL) {
+         ListBox_ResetContent(GetDlgItem(hDlg, IDC_WIFI_LIST));
+         Button_Enable(GetDlgItem(hDlg, IDC_WIFI_EDIT), FALSE);
+         Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVE), FALSE);
+         Button_Enable(GetDlgItem(hDlg, IDC_WIFI_REMOVEALL), FALSE);
+      }
+      return 0;
+   }
+   case WM_SAVESETTINGS: {
+      HWND hList = GetDlgItem(hDlg, IDC_WIFI_LIST);
+      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      DWORD items = ListBox_GetCount(hList);
+      std::vector<tstring> networks;
+      for (DWORD i = 0; i < items; ++i) {
+         TCHAR textBuf[SSID_MAX_LEN + 1];
+         DWORD textLen = ListBox_GetTextLen(hDlg, i);
+         if (textLen < ARRAY_SIZE(textBuf)) {
+            ListBox_GetText(hList, i, textBuf);
+            networks.push_back(textBuf);
+         }
+      }
+      settings->StoreWifiNetworks(networks);
+      return 0;
+   }
+   default:
+      break;
+   }
+   return FALSE;
+}
index 742bca5f06330cb385e2196702f922610338c529..e6bd2325a05e53ab303b859fb56b4018fbeb8066 100644 (file)
@@ -33,8 +33,13 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #include "common.h"
 
-static const LPCWSTR LX_SYSTEMS_SUBKEY = _T("SOFTWARE\\lx-systems\\WinMute");
-static const LPCWSTR LX_SYSTEMS_AUTOSTART_KEY = _T("LX-Systems WinMute");
+static const LPCWSTR LX_SYSTEMS_SUBKEY
+   = _T("SOFTWARE\\lx-systems\\WinMute");
+static const LPCWSTR LX_SYSTEMS_WIFI_SUBKEY
+   = _T("SOFTWARE\\lx-systems\\WinMute\\WifiNetworks");
+
+static const LPCWSTR LX_SYSTEMS_AUTOSTART_KEY
+   = _T("LX-Systems WinMute");
 
 static LPCWSTR KeyToStr(SettingsKey key)
 {
@@ -154,7 +159,8 @@ static bool ReadStringFromRegistry(HKEY hKey, const TCHAR* subKey, tstring& val)
 }
 
 WMSettings::WMSettings() :
-   hRegSettingsKey_(nullptr)
+   hSettingsKey_(nullptr),
+   hWifiKey_(nullptr)
 {
 }
 
@@ -165,7 +171,7 @@ WMSettings::~WMSettings()
 
 bool WMSettings::Init()
 {
-   if (hRegSettingsKey_ == nullptr) {
+   if (hSettingsKey_ == nullptr) {
       DWORD regError = RegCreateKeyEx(
          HKEY_CURRENT_USER,
          LX_SYSTEMS_SUBKEY,
@@ -174,21 +180,41 @@ bool WMSettings::Init()
          0,
          KEY_READ | KEY_WRITE,
          nullptr,
-         &hRegSettingsKey_,
+         &hSettingsKey_,
          nullptr);
       if (regError != ERROR_SUCCESS) {
          PrintWindowsError(_T("RegCreateKeyEx"), regError);
          return false;
       }
    }
+   if (hWifiKey_ == nullptr) {
+      DWORD regError = RegCreateKeyEx(
+         HKEY_CURRENT_USER,
+         LX_SYSTEMS_WIFI_SUBKEY,
+         0,
+         nullptr,
+         0,
+         KEY_READ | KEY_WRITE,
+         nullptr,
+         &hWifiKey_,
+         nullptr);
+      if (regError != ERROR_SUCCESS) {
+         PrintWindowsError(_T("RegCreateKeyEx"), regError);
+         RegCloseKey(hSettingsKey_);
+         hSettingsKey_ = nullptr;
+         return false;
+      }
+   }
 
    return true;
 }
 
 void WMSettings::Unload()
 {
-   RegCloseKey(hRegSettingsKey_);
-   hRegSettingsKey_ = nullptr;
+   RegCloseKey(hSettingsKey_);
+   hSettingsKey_ = nullptr;
+   RegCloseKey(hWifiKey_);
+   hWifiKey_ = nullptr;
 }
 
 HKEY WMSettings::OpenAutostartKey(REGSAM samDesired)
@@ -269,7 +295,7 @@ DWORD WMSettings::QueryValue(SettingsKey key) const
    DWORD value = 0;
    DWORD size = sizeof(DWORD);
    DWORD regError = RegQueryValueEx(
-      hRegSettingsKey_,
+      hSettingsKey_,
       keyStr,
       0,
       nullptr,
@@ -291,7 +317,7 @@ bool WMSettings::SetValue(SettingsKey key, DWORD value)
    assert(keyStr != nullptr);
 
    DWORD regError = RegSetValueEx(
-      hRegSettingsKey_,
+      hSettingsKey_,
       keyStr,
       0,
       REG_DWORD,
@@ -304,3 +330,91 @@ bool WMSettings::SetValue(SettingsKey key, DWORD value)
 
    return true;
 }
+
+bool WMSettings::StoreWifiNetworks(std::vector<tstring>& networks)
+{
+   // Clear all stored keys
+   for (;;) {
+      TCHAR valueName[260] = { 0 };
+      DWORD valueSize = ARRAY_SIZE(valueName);
+      DWORD regError = RegEnumValue(
+         hWifiKey_,
+         0,
+         valueName,
+         &valueSize,
+         NULL,
+         NULL,
+         NULL,
+         NULL);
+      if (regError == ERROR_NO_MORE_ITEMS) {
+         break;
+      } else if (regError != ERROR_SUCCESS) {
+         PrintWindowsError(_T("RegEnumValue"), regError);
+         return false;
+      } else {
+         regError = RegDeleteValue(hWifiKey_, valueName);
+         if (regError != ERROR_SUCCESS) {
+            PrintWindowsError(_T("RegDeleteValue"), regError);
+         }
+      }
+   }
+
+   if (networks.size() > 1) {
+      std::sort(std::begin(networks), std::end(networks));
+   }
+   for (size_t i = 0; i < networks.size(); ++i) {
+      TCHAR valueName[10];
+#ifdef _UNICODE
+      swprintf(valueName, ARRAY_SIZE(valueName), _T("WiFi %03zu"), i + 1);
+#else
+      sprintf_s(valueName, "WiFi %03zu", i + 1);
+#endif
+      const tstring& v = networks[i];
+      DWORD regError = RegSetValueEx(
+         hWifiKey_,
+         valueName,
+         NULL,
+         REG_SZ,
+         reinterpret_cast<const BYTE*>(v.c_str()),
+         static_cast<DWORD>(v.length() + 1) * sizeof(TCHAR));
+      if (regError != ERROR_SUCCESS) {
+         PrintWindowsError(_T("RegSetValueEx"), regError);
+      }
+   }
+
+   return true;
+}
+
+std::vector<tstring> WMSettings::GetWifiNetworks() const
+{
+   std::vector<tstring> networks;
+   for (int valIdx = 0; ; ++valIdx) {
+      TCHAR valueName[260] = { 0 };
+      TCHAR dataBuf[260] = { 0 };
+      DWORD valueSize = ARRAY_SIZE(valueName);
+      DWORD valType = 0;
+      DWORD dataLen = ARRAY_SIZE(dataBuf);
+
+      DWORD regError = RegEnumValue(
+         hWifiKey_,
+         valIdx,
+         valueName,
+         &valueSize,
+         NULL,
+         &valType,
+         reinterpret_cast<BYTE*>(dataBuf),
+         &dataLen);
+      if (regError == ERROR_NO_MORE_ITEMS) {
+         break;
+      } else if (regError != ERROR_SUCCESS) {
+         PrintWindowsError(_T("RegEnumValue"), regError);
+         return {};
+      } else {
+         networks.push_back(dataBuf);
+      }
+   }
+   if (networks.size() > 1) {
+      std::sort(std::begin(networks), std::end(networks));
+   }
+   return networks;
+}
index bd718ddb171769c5cc646e89faf1036cc22f3993..a1b2d5a836a9e4556015cf8657536345fc06f4b6 100644 (file)
@@ -67,11 +67,15 @@ public:
    bool IsAutostartEnabled();
    void EnableAutostart(bool enable);
 
+   bool StoreWifiNetworks(std::vector<tstring>& networks);
+   std::vector<tstring> GetWifiNetworks() const;
+
    DWORD QueryValue(SettingsKey key) const;
    bool  SetValue(SettingsKey key, DWORD value);
 
 private:
-   HKEY hRegSettingsKey_;
+   HKEY hSettingsKey_;
+   HKEY hWifiKey_;
 
    HKEY OpenAutostartKey(REGSAM samDesired);
 };
index 510d024937c02077673dbe073f6babeb853ed625..797f4685ab595d1c3a746ca53f72df99d7a1eb66 100644 (file)
@@ -356,25 +356,36 @@ LRESULT CALLBACK WinMute::WindowProc(
    }
    case WM_COMMAND: {
       switch (LOWORD(wParam)) {
-      case ID_TRAYMENU_INFO:
-         DialogBox(
-            hglobInstance,
-            MAKEINTRESOURCE(IDD_ABOUT),
-            hWnd_,
-            AboutDlgProc);
+      case ID_TRAYMENU_INFO: {
+         static bool dialogOpen = false;
+         if (!dialogOpen) {
+            dialogOpen = true;
+            DialogBox(
+               hglobInstance,
+               MAKEINTRESOURCE(IDD_ABOUT),
+               hWnd_,
+               AboutDlgProc);
+            dialogOpen = false;
+         }
          break;
+      }
       case ID_TRAYMENU_EXIT:
          SendMessage(hWnd, WM_CLOSE, 0, 0);
          break;
       case ID_TRAYMENU_SETTINGS: {
-         if (DialogBoxParam(
-               hglobInstance,
-               MAKEINTRESOURCE(IDD_SETTINGS),
-               hWnd_,
-               SettingsDlgProc,
-               reinterpret_cast<LPARAM>(&settings_)) == 0) {
-            LoadSettings();
-            InitTrayMenu();
+         static bool dialogOpen = false;
+         if (!dialogOpen) {
+            dialogOpen = true;
+            if (DialogBoxParam(
+                  hglobInstance,
+                  MAKEINTRESOURCE(IDD_SETTINGS),
+                  hWnd_,
+                  SettingsDlgProc,
+                  reinterpret_cast<LPARAM>(&settings_)) == 0) {
+               LoadSettings();
+               InitTrayMenu();
+            }
+            dialogOpen = false;
          }
          break;
       }
index f2e42b648229f5df66d0c5adf721221723d18ac2..3b18ff0df7fb4d017346a911da0e28d02c5df923 100644 (file)
@@ -55,10 +55,10 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTI
 CAPTION "About WinMute"
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
+    ICON            IDI_APP,IDC_STATIC,13,7,20,20,SS_CENTERIMAGE
+    LTEXT           "WinMute <VersionNumber>",IDC_ABOUT_TITLE,41,7,193,23
     CONTROL         "",IDC_ABOUT_TAB,"SysTabControl32",0x0,7,34,299,202
     PUSHBUTTON      "OK",IDOK,242,246,64,16
-    LTEXT           "WinMute <VersionNumber>",IDC_ABOUT_TITLE,41,7,193,23
-    ICON            IDI_APP,IDC_STATIC,13,7,20,20,SS_CENTERIMAGE
 END
 
 IDD_SETTINGS DIALOGEX 0, 0, 269, 253
@@ -87,14 +87,14 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
     LTEXT           "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,7,9,232,22
     CONTROL         "Enable Quiet Hours",IDC_ENABLEQUIETHOURS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,31,120,15
+    LTEXT           "Start time:",IDC_STATIC,23,50,43,13
     CONTROL         "",IDC_QUIETHOURS_START,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,73,47,65,18
+    LTEXT           "End time:",IDC_STATIC,24,73,32,16
     CONTROL         "",IDC_QUIETHOURS_END,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,72,71,67,19
     CONTROL         "Force unmute",IDC_FORCEUNMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,94,86,16
+    LTEXT           "If force unmute is enabled, WinMute will unmute your workstation when quiet hours end and not take into account if your workstation was already muted before quiet hours started.",IDC_STATIC,33,111,204,37
     CONTROL         "Show quiet hours notifications",IDC_SHOWNOTIFICATIONS,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,146,180,21
-    LTEXT           "If force unmute is enabled, WinMute will unmute your workstation when quiet hours end and not take into account if your workstation was already muted before quiet hours started.",IDC_STATIC,33,111,204,37
-    LTEXT           "Start time:",IDC_STATIC,23,50,43,13
-    LTEXT           "End time:",IDC_STATIC,24,73,32,16
 END
 
 IDD_ABOUT_LICENSE DIALOGEX 0, 0, 300, 181
@@ -108,11 +108,11 @@ IDD_ABOUT_WINMUTE DIALOGEX 0, 0, 298, 176
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
+    EDITTEXT        IDC_ABOUTTEXT,7,14,182,155,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
     CONTROL         "<a href=""https://lx-s.de"">Author Site: www.lx-s.de</a>",IDC_LINK_HOMEPAGE,
                     "SysLink",WS_TABSTOP,197,14,94,14
     CONTROL         "<a href=""https://github.com/lx-s/WinMute/"">Project Site && Code</a>",IDC_LINK_PROJECT,
                     "SysLink",WS_TABSTOP,197,32,94,14
-    EDITTEXT        IDC_ABOUTTEXT,7,14,182,155,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
     CONTROL         "<a href=""https://github.com/lx-s/WinMute/issues/"">Support</a>",IDC_LINK_TICKETS,
                     "SysLink",WS_TABSTOP,197,49,94,14
 END
@@ -121,6 +121,9 @@ IDD_SETTINGS_MUTE DIALOGEX 0, 0, 242, 205
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
+    GROUPBOX        "General",IDC_STATIC,7,7,228,31
+    CONTROL         "Show mute event notifications",IDC_SHOWNOTIFICATIONS,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,17,219,18
     GROUPBOX        "Mute with volume restore, when...",IDC_STATIC,7,42,228,75
     CONTROL         "... the workstation is locked.",IDC_MUTE_WHEN_WS_LOCKED,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,57,107,10
@@ -132,14 +135,35 @@ BEGIN
     GROUPBOX        "Mute without volume restore, when...",IDC_STATIC,7,121,228,73
     CONTROL         "... the computer shuts down.",IDC_MUTE_WHEN_SHUTDOWN,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,135,110,10
-    CONTROL         "... you log out.",IDC_MUTE_WHEN_LOGOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,163,65,10
     CONTROL         "... the computer goes into sleep/hibernate.",IDC_MUTE_WHEN_SLEEP,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,149,155,10
+    CONTROL         "... you log out.",IDC_MUTE_WHEN_LOGOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,163,65,10
     CONTROL         "... when WinMute is started within a RDP session.",IDC_MUTE_WHEN_RDP_SESSION,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,177,175,10
-    GROUPBOX        "General",IDC_STATIC,7,7,228,31
-    CONTROL         "Show mute event notifications",IDC_SHOWNOTIFICATIONS,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,17,219,18
+END
+
+IDD_SETTINGS_WIFI DIALOGEX 0, 0, 242, 204
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    LTEXT           "WinMute can detect when you are connecting to a particular WiFi Network and mute your PC when it finishes connecting. \nHere you can manage SSIDs of networks that should trigger muting:",IDC_STATIC,7,7,228,35
+    LISTBOX         IDC_WIFI_LIST,7,51,170,123,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+    PUSHBUTTON      "Add",IDC_WIFI_ADD,179,51,56,16
+    PUSHBUTTON      "Edit",IDC_WIFI_EDIT,179,70,56,16
+    PUSHBUTTON      "Remove",IDC_WIFI_REMOVE,179,89,56,16
+    PUSHBUTTON      "Remove all",IDC_WIFI_REMOVEALL,179,109,56,16
+    LTEXT           "Note: This feature is currently experimental",IDC_STATIC,7,182,171,15
+END
+
+IDD_SETTINGS_WIFI_ADD DIALOGEX 0, 0, 201, 62
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Add WiFi"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    DEFPUSHBUTTON   "Save",IDOK,91,41,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,144,41,50,14
+    LTEXT           "SSID/WiFi Name:",IDC_STATIC,7,7,62,14
+    EDITTEXT        IDC_WIFI_NAME,7,20,187,16,ES_AUTOHSCROLL
 END
 
 
@@ -206,6 +230,22 @@ BEGIN
         TOPMARGIN, 7
         BOTTOMMARGIN, 198
     END
+
+    IDD_SETTINGS_WIFI, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 235
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 197
+    END
+
+    IDD_SETTINGS_WIFI_ADD, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 194
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 55
+    END
 END
 #endif    // APSTUDIO_INVOKED
 
@@ -251,6 +291,16 @@ BEGIN
     0
 END
 
+IDD_SETTINGS_WIFI AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
+IDD_SETTINGS_WIFI_ADD AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
 
 /////////////////////////////////////////////////////////////////////////////
 //
index 3ef9618289b23695950a09ae298b3d62815ebc5c..5b9f673bb43d2561252936c753c4d5d722fdbe83 100644 (file)
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
     </ClCompile>
     <ClCompile Include="Settings_MuteDlg.cpp" />
+    <ClCompile Include="Settings_WifiDlg.cpp" />
     <ClCompile Include="WMLog.cpp" />
     <ClCompile Include="MMNotificationClient.cpp" />
     <ClCompile Include="MuteControl.cpp" />
index 427e71c4bcf521c7f0688b146d495264c5d9a02e..ddb2cc9a3abf19d47252cc678671b3aafc7dd579 100644 (file)
     <ClCompile Include="Settings_MuteDlg.cpp">
       <Filter>Source Files\UI\Dialogs\Settings</Filter>
     </ClCompile>
+    <ClCompile Include="Settings_WifiDlg.cpp">
+      <Filter>Source Files\UI\Dialogs\Settings</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 8344d5df146d497085342130991d8c810abde1d1..8155bcaa34c5a901950f61028326bf915034608a 100644 (file)
@@ -15,6 +15,8 @@
 #define IDI_ICON1                       122
 #define IDI_SETTINGS                    122
 #define IDD_SETTINGS_MUTE               123
+#define IDD_SETTINGS_WIFI               127
+#define IDD_SETTINGS_WIFI_ADD           129
 #define IDC_LINK_HOMEPAGE               1001
 #define IDC_LINK_SUPPORT                1002
 #define IDC_LINK_PROJECT                1002
 #define IDC_MUTE_WHEN_SCREENSAVER_STARTS 1021
 #define IDC_MUTE_WHEN_SCREEN_OFF        1022
 #define IDC_MUTE_WHEN_RDP_SESSION       1023
+#define IDC_WIFI_LIST                   1023
 #define IDC_RESTOREVOLUME               1024
+#define IDC_WIFI_ADD                    1024
 #define IDC_MUTE_WHEN_SHUTDOWN          1025
+#define IDC_WIFI_REMOVE                 1025
+#define IDC_WIFI_NAME                   1025
 #define IDC_MUTE_WHEN_LOGOUT            1026
+#define IDC_WIFI_EDIT                   1026
 #define IDC_MUTE_WHEN_SLEEP             1027
+#define IDC_WIFI_REMOVE2                1027
+#define IDC_WIFI_REMOVEALL              1027
 #define ID_TRAYMENU_INFO                40001
 #define ID_TRAYMENU_                    40002
 #define ID_TRAYMENU_MUTEON              40003
@@ -78,9 +87,9 @@
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        127
+#define _APS_NEXT_RESOURCE_VALUE        131
 #define _APS_NEXT_COMMAND_VALUE         40029
-#define _APS_NEXT_CONTROL_VALUE         1023
+#define _APS_NEXT_CONTROL_VALUE         1026
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif