summaryrefslogtreecommitdiff
path: root/plugins/ProxySwitch
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-03-09 16:01:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-03-09 16:01:32 +0300
commitd387ed11456e40f36f359cb3aa9f74a54b8f369b (patch)
tree58b3c950a6f00ee6664e794ec4a385cc3b10cb34 /plugins/ProxySwitch
parentb5c43418ddb50192686929bac0a6b3190aa6b600 (diff)
popup control moved from main menu to Options - Popups - Enabled items
Diffstat (limited to 'plugins/ProxySwitch')
-rw-r--r--plugins/ProxySwitch/src/main.cpp46
-rw-r--r--plugins/ProxySwitch/src/opt.cpp15
-rw-r--r--plugins/ProxySwitch/src/stdafx.h4
3 files changed, 14 insertions, 51 deletions
diff --git a/plugins/ProxySwitch/src/main.cpp b/plugins/ProxySwitch/src/main.cpp
index 5d61c866ed..d8ced5f0fe 100644
--- a/plugins/ProxySwitch/src/main.cpp
+++ b/plugins/ProxySwitch/src/main.cpp
@@ -24,10 +24,11 @@ PLUGININFOEX pluginInfoEx =
};
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bPopups(MODULENAME, "PopupEnabled", true)
+{
+}
-HGENMENU hEnableDisablePopupMenu = 0;
HGENMENU hMenuRoot;
OBJLIST<ACTIVE_CONNECTION> g_arConnections(10, PtrKeySortT);
@@ -42,7 +43,6 @@ wchar_t opt_useProxy[MAX_IPLIST_LENGTH];
wchar_t opt_noProxy[MAX_IPLIST_LENGTH];
wchar_t opt_hideIntf[MAX_IPLIST_LENGTH];
UINT opt_defaultColors;
-UINT opt_popups;
UINT opt_showProxyState;
UINT opt_miranda;
UINT opt_ie;
@@ -55,7 +55,6 @@ COLORREF opt_txtColor;
static HANDLE hEventConnect = NULL;
static HANDLE hEventDisconnect = NULL;
-static HANDLE hSvcPopupSwitch = NULL;
static HANDLE hSvcProxyDisable = NULL;
static HANDLE hSvcProxyEnable = NULL;
static HANDLE hSvcShowMyIP = NULL;
@@ -154,32 +153,6 @@ void UpdateInterfacesMenu(void)
/* ################################################################################ */
-void UpdatePopupMenu(BOOL State)
-{
- if (!hEnableDisablePopupMenu)
- return;
-
- // popup is now disabled
- if (State == FALSE) {
- Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Enable &IP change notification"));
- // mi.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_NOTIF_0));
- }
- else {
- Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Disable &IP change notification"));
- // mi.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_NOTIF_1));
- }
-}
-
-static INT_PTR PopupSwitch(WPARAM, LPARAM)
-{
- opt_popups = !opt_popups;
- UpdatePopupMenu(opt_popups);
- SaveSettings();
- return 0;
-}
-
-/* ################################################################################ */
-
int CMPlugin::Load()
{
char proxy = -1;
@@ -190,6 +163,8 @@ int CMPlugin::Load()
LoadSettings();
+ addPopupOption(LPGEN("IP change notification"), bPopups);
+
Create_NIF_List_Ex(&g_arNIF);
if (opt_ie || opt_miranda || opt_firefox) {
@@ -273,15 +248,6 @@ int Init(WPARAM, LPARAM)
}
UpdateInterfacesMenu();
-
- mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0xC0000000);
- mi.name.w = LPGENW("IP change notification");
- mi.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_LOGO));
- mi.pszService = MS_PROXYSWITCH_POPUPSWITCH;
- hEnableDisablePopupMenu = Menu_AddMainMenuItem(&mi);
- hSvcPopupSwitch = CreateServiceFunction(mi.pszService, PopupSwitch);
-
- UpdatePopupMenu(opt_popups);
return 0;
}
diff --git a/plugins/ProxySwitch/src/opt.cpp b/plugins/ProxySwitch/src/opt.cpp
index 3f9048ce3e..917353ea8f 100644
--- a/plugins/ProxySwitch/src/opt.cpp
+++ b/plugins/ProxySwitch/src/opt.cpp
@@ -45,14 +45,14 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
SetDlgItemText(hdlg, IDC_EDIT_HIDEINTF, opt_hideIntf);
SendDlgItemMessage(hdlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, opt_bgColor);
SendDlgItemMessage(hdlg, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, opt_txtColor);
- CheckDlgButton(hdlg, IDC_CHECK_POPUPS, opt_popups ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_POPUPS, g_plugin.bPopups ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_CHECK_DEFAULTCOLORS, opt_defaultColors ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_CHECK_SHOWPROXYSTATUS, opt_showProxyState ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hdlg, IDC_CHECK_FIREFOX), Firefox_Installed());
- EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOR), opt_popups && !opt_defaultColors);
- EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOR), opt_popups && !opt_defaultColors);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECK_DEFAULTCOLORS), opt_popups);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECK_SHOWPROXYSTATUS), opt_popups);
+ EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOR), g_plugin.bPopups && !opt_defaultColors);
+ EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOR), g_plugin.bPopups && !opt_defaultColors);
+ EnableWindow(GetDlgItem(hdlg, IDC_CHECK_DEFAULTCOLORS), g_plugin.bPopups);
+ EnableWindow(GetDlgItem(hdlg, IDC_CHECK_SHOWPROXYSTATUS), g_plugin.bPopups);
ShowWindow(GetDlgItem(hdlg, IDC_RESTARTREQUIRED), opt_not_restarted ? SW_SHOW : SW_HIDE);
TranslateDialogDefault(hdlg);
opt_startup = FALSE;
@@ -69,13 +69,12 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
opt_ie = IsDlgButtonChecked(hdlg, IDC_CHECK_IE);
opt_firefox = IsDlgButtonChecked(hdlg, IDC_CHECK_FIREFOX);
opt_alwayReconnect = IsDlgButtonChecked(hdlg, IDC_CHECK_ALWAY_RECONNECT);
- opt_popups = IsDlgButtonChecked(hdlg, IDC_CHECK_POPUPS);
+ g_plugin.bPopups = IsDlgButtonChecked(hdlg, IDC_CHECK_POPUPS);
opt_defaultColors = IsDlgButtonChecked(hdlg, IDC_CHECK_DEFAULTCOLORS);
opt_showProxyState = IsDlgButtonChecked(hdlg, IDC_CHECK_SHOWPROXYSTATUS);
opt_bgColor = SendDlgItemMessage(hdlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0);
opt_txtColor = SendDlgItemMessage(hdlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0);
SaveSettings();
- UpdatePopupMenu(opt_popups);
return 1;
}
break;
@@ -161,7 +160,6 @@ void LoadSettings(void)
opt_ie = g_plugin.getByte("ManageIEProxy", FALSE);
opt_firefox = g_plugin.getByte("ManageFirefoxProxy", FALSE) && Firefox_Installed();
opt_alwayReconnect = g_plugin.getByte("AlwaysReconnect", FALSE);
- opt_popups = g_plugin.getByte("PopupEnabled", TRUE);
opt_defaultColors = g_plugin.getByte("PopupDefaultColors", TRUE);
opt_showProxyState = g_plugin.getByte("ShowProxyStatus", TRUE);
opt_bgColor = g_plugin.getDword("PopupBgColor", GetSysColor(COLOR_BTNFACE));
@@ -177,7 +175,6 @@ void SaveSettings(void)
g_plugin.setByte("ManageIEProxy", (uint8_t)opt_ie);
g_plugin.setByte("ManageFirefoxProxy", (uint8_t)opt_firefox);
g_plugin.setByte("AlwaysReconnect", (uint8_t)opt_alwayReconnect);
- g_plugin.setByte("PopupEnabled", (uint8_t)opt_popups);
g_plugin.setByte("PopupDefaultColors", (uint8_t)opt_defaultColors);
g_plugin.setByte("ShowProxyStatus", (uint8_t)opt_showProxyState);
g_plugin.setDword("PopupBgColor", (uint32_t)opt_bgColor);
diff --git a/plugins/ProxySwitch/src/stdafx.h b/plugins/ProxySwitch/src/stdafx.h
index ea19ffdd1a..40d5313fef 100644
--- a/plugins/ProxySwitch/src/stdafx.h
+++ b/plugins/ProxySwitch/src/stdafx.h
@@ -38,6 +38,8 @@ struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
+ CMOption<bool> bPopups;
+
int Load() override;
int Unload() override;
};
@@ -96,7 +98,6 @@ extern wchar_t opt_useProxy[MAX_IPLIST_LENGTH];
extern wchar_t opt_noProxy[MAX_IPLIST_LENGTH];
extern wchar_t opt_hideIntf[MAX_IPLIST_LENGTH];
extern UINT opt_defaultColors;
-extern UINT opt_popups;
extern UINT opt_showProxyState;
extern UINT opt_miranda;
extern UINT opt_ie;
@@ -117,7 +118,6 @@ void PopupMyIPAddrs(const wchar_t *msg);
int OptInit(WPARAM wParam, LPARAM lParam);
int Init(WPARAM wParam, LPARAM lParam);
void UpdateInterfacesMenu(void);
-void UpdatePopupMenu(BOOL State);
/**** Network ******************************************************************************/