summaryrefslogtreecommitdiff
path: root/protocols/Weather
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 /protocols/Weather
parentb5c43418ddb50192686929bac0a6b3190aa6b600 (diff)
popup control moved from main menu to Options - Popups - Enabled items
Diffstat (limited to 'protocols/Weather')
-rw-r--r--protocols/Weather/res/popup.icobin1150 -> 0 bytes
-rw-r--r--protocols/Weather/res/popup_no.icobin1150 -> 0 bytes
-rw-r--r--protocols/Weather/res/resource.rc2
-rw-r--r--protocols/Weather/src/resource.h2
-rw-r--r--protocols/Weather/src/stdafx.h4
-rw-r--r--protocols/Weather/src/weather.cpp12
-rw-r--r--protocols/Weather/src/weather_opt.cpp2
-rw-r--r--protocols/Weather/src/weather_popup.cpp8
-rw-r--r--protocols/Weather/src/weather_svcs.cpp30
9 files changed, 12 insertions, 48 deletions
diff --git a/protocols/Weather/res/popup.ico b/protocols/Weather/res/popup.ico
deleted file mode 100644
index 5b3fe4e65b..0000000000
--- a/protocols/Weather/res/popup.ico
+++ /dev/null
Binary files differ
diff --git a/protocols/Weather/res/popup_no.ico b/protocols/Weather/res/popup_no.ico
deleted file mode 100644
index 2b298a96ea..0000000000
--- a/protocols/Weather/res/popup_no.ico
+++ /dev/null
Binary files differ
diff --git a/protocols/Weather/res/resource.rc b/protocols/Weather/res/resource.rc
index 7b17f8e87f..40e7d2a957 100644
--- a/protocols/Weather/res/resource.rc
+++ b/protocols/Weather/res/resource.rc
@@ -380,8 +380,6 @@ IDI_S ICON "brief.ico"
IDI_LOG ICON "log.ico"
IDI_EDIT ICON "edit.ico"
IDI_MAP ICON "map.ico"
-IDI_POPUP ICON "popup.ico"
-IDI_NOPOPUP ICON "popup_no.ico"
IDI_UPDATE2 ICON "update2.ico"
IDI_DISABLED ICON "disabled.ico"
diff --git a/protocols/Weather/src/resource.h b/protocols/Weather/src/resource.h
index eecba58268..67e9006fb3 100644
--- a/protocols/Weather/src/resource.h
+++ b/protocols/Weather/src/resource.h
@@ -15,8 +15,6 @@
#define IDI_S 211
#define IDI_MAP 212
#define IDR_PMENU 213
-#define IDI_POPUP 214
-#define IDI_NOPOPUP 215
#define IDD_TEXTOPT 216
#define IDD_BRIEF 217
#define IDD_SETUP 218
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h
index 0c462e8a6f..ea25f3f28c 100644
--- a/protocols/Weather/src/stdafx.h
+++ b/protocols/Weather/src/stdafx.h
@@ -205,7 +205,6 @@ struct MYOPTIONS
uint8_t DisCondIcon;
// popup options
- uint8_t UsePopup;
uint8_t UpdatePopup;
uint8_t AlertPopup;
uint8_t PopupOnChange;
@@ -526,7 +525,8 @@ struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
- HINSTANCE hIconsDll;
+ HINSTANCE hIconsDll = nullptr;
+ CMOption<bool> bPopups;
int Load() override;
int Unload() override;
diff --git a/protocols/Weather/src/weather.cpp b/protocols/Weather/src/weather.cpp
index 259426957b..f5e6bb2e7b 100644
--- a/protocols/Weather/src/weather.cpp
+++ b/protocols/Weather/src/weather.cpp
@@ -77,7 +77,8 @@ static const PLUGININFOEX pluginInfoEx =
};
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bPopups(MODULENAME, "UsePopup", true)
{
opt.NoProtoCondition = g_plugin.getByte("NoStatus", true);
RegisterProtocol((opt.NoProtoCondition) ? PROTOTYPE_VIRTUAL : PROTOTYPE_PROTOCOL);
@@ -151,8 +152,6 @@ static IconItem iconList[] =
{ LPGEN("View Complete"), "read", IDI_READ },
{ LPGEN("Weather Update"), "update", IDI_UPDATE },
{ LPGEN("Weather Map"), "map", IDI_MAP },
- { LPGEN("Popup"), "popup", IDI_POPUP },
- { LPGEN("No Popup"), "nopopup", IDI_NOPOPUP },
{ LPGEN("Edit Settings"), "edit", IDI_EDIT },
};
@@ -198,8 +197,11 @@ int CMPlugin::Load()
InitServices();
// add sound event
- g_plugin.addSound("weatherupdated", _A2W(MODULENAME), LPGENW("Condition Changed"));
- g_plugin.addSound("weatheralert", _A2W(MODULENAME), LPGENW("Alert Issued"));
+ addSound("weatherupdated", _A2W(MODULENAME), LPGENW("Condition Changed"));
+ addSound("weatheralert", _A2W(MODULENAME), LPGENW("Alert Issued"));
+
+ // popup initialization
+ addPopupOption(LPGEN("Weather notifications"), bPopups);
// window needed for popup commands
wchar_t SvcFunc[100];
diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp
index 9dd186f751..c4b42ede5c 100644
--- a/protocols/Weather/src/weather_opt.cpp
+++ b/protocols/Weather/src/weather_opt.cpp
@@ -108,7 +108,6 @@ void LoadOptions(void)
opt.DisCondIcon = g_plugin.getByte("DisableConditionIcon", false);
// popup options
- opt.UsePopup = g_plugin.getByte("UsePopUp", true);
opt.UpdatePopup = g_plugin.getByte("UpdatePopup", true);
opt.AlertPopup = g_plugin.getByte("AlertPopup", true);
opt.PopupOnChange = g_plugin.getByte("PopUpOnChange", true);
@@ -161,7 +160,6 @@ void SaveOptions(void)
g_plugin.setByte("DisableConditionIcon", (uint8_t)opt.DisCondIcon);
// popup options
- g_plugin.setByte("UsePopUp", (uint8_t)opt.UsePopup);
g_plugin.setByte("UpdatePopup", (uint8_t)opt.UpdatePopup);
g_plugin.setByte("AlertPopup", (uint8_t)opt.AlertPopup);
g_plugin.setByte("PopUpOnChange", (uint8_t)opt.PopupOnChange);
diff --git a/protocols/Weather/src/weather_popup.cpp b/protocols/Weather/src/weather_popup.cpp
index e6276167f7..992db0a69a 100644
--- a/protocols/Weather/src/weather_popup.cpp
+++ b/protocols/Weather/src/weather_popup.cpp
@@ -37,7 +37,7 @@ static MCONTACT hPopupContact;
// Type can either be SM_WARNING, SM_NOTIFY, or SM_WEATHERALERT
int WeatherError(WPARAM wParam, LPARAM lParam)
{
- if (!opt.UsePopup)
+ if (!g_plugin.bPopups)
return 0;
wchar_t* tszMsg = (wchar_t*)wParam;
@@ -125,7 +125,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
int WeatherPopup(WPARAM hContact, LPARAM lParam)
{
// determine if the popup should display or not
- if (opt.UsePopup && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) && !g_plugin.getByte(hContact, "DPopUp")) {
+ if (g_plugin.bPopups && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) && !g_plugin.getByte(hContact, "DPopUp")) {
WEATHERINFO winfo = LoadWeatherInfo(hContact);
// setup the popup
@@ -235,7 +235,6 @@ void ReadPopupOpt(HWND hdlg)
// other options
opt.UseWinColors = (uint8_t)IsDlgButtonChecked(hdlg, IDC_USEWINCOLORS);
- opt.UsePopup = (uint8_t)IsDlgButtonChecked(hdlg, IDC_E);
opt.UpdatePopup = (uint8_t)IsDlgButtonChecked(hdlg, IDC_POP1);
opt.AlertPopup = (uint8_t)IsDlgButtonChecked(hdlg, IDC_POP2);
opt.PopupOnChange = (uint8_t)IsDlgButtonChecked(hdlg, IDC_CH);
@@ -268,7 +267,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
DestroyMenu(hMenu);
// other options
- CheckDlgButton(hdlg, IDC_E, opt.UsePopup ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_E, g_plugin.bPopups ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_POP2, opt.AlertPopup ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange ? BST_CHECKED : BST_UNCHECKED);
@@ -435,7 +434,6 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
// save the options, and update main menu
SaveOptions();
- UpdatePopupMenu(opt.UsePopup);
return TRUE;
}
break;
diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp
index 113669d968..7a7dff321c 100644
--- a/protocols/Weather/src/weather_svcs.cpp
+++ b/protocols/Weather/src/weather_svcs.cpp
@@ -26,7 +26,6 @@ building/changing the weather menu items.
#include "stdafx.h"
-static HGENMENU hEnableDisablePopupMenu;
static HGENMENU hEnableDisableMenu;
extern VARSW g_pwszIconsName;
@@ -302,18 +301,6 @@ void UpdateMenu(BOOL State)
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, !State ? TTBST_PUSHED : 0);
}
-void UpdatePopupMenu(BOOL State)
-{
- // update option setting
- opt.UsePopup = State;
- g_plugin.setByte("UsePopup", (uint8_t)opt.UsePopup);
-
- if (State) // to enable popup
- Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Disable &weather notification"), g_plugin.getIconHandle(IDI_POPUP));
- else // to disable popup
- Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Enable &weather notification"), g_plugin.getIconHandle(IDI_NOPOPUP));
-}
-
// update the weather auto-update menu item when click on it
INT_PTR EnableDisableCmd(WPARAM wParam, LPARAM lParam)
{
@@ -321,13 +308,6 @@ INT_PTR EnableDisableCmd(WPARAM wParam, LPARAM lParam)
return 0;
}
-// update the weather popup menu item when click on it
-INT_PTR MenuitemNotifyCmd(WPARAM, LPARAM)
-{
- UpdatePopupMenu(!opt.UsePopup);
- return 0;
-}
-
// adding weather contact menus
// copied and modified form "modified MSN Protocol"
void AddMenuItems(void)
@@ -420,16 +400,6 @@ void AddMenuItems(void)
mi.pszService = MS_WEATHER_REFRESHALL;
Menu_AddMainMenuItem(&mi);
- SET_UID(mi, 0xdc5411cb, 0xb7c7, 0x443b, 0x88, 0x5a, 0x90, 0x24, 0x43, 0xde, 0x54, 0x3e);
- CreateServiceFunction(MODULENAME "/PopupMenu", MenuitemNotifyCmd);
- mi.name.a = LPGEN("Weather Notification");
- mi.hIcolibItem = g_plugin.getIconHandle(IDI_POPUP);
- mi.position = 0;
- mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0);
- mi.pszService = MODULENAME "/PopupMenu";
- hEnableDisablePopupMenu = Menu_AddMainMenuItem(&mi);
- UpdatePopupMenu(opt.UsePopup);
-
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
SET_UID(mi, 0xe193fe9b, 0xf6ad, 0x41ac, 0x95, 0x29, 0x45, 0x4, 0x44, 0xb1, 0xeb, 0x5d);
mi.pszService = "Weather/mwin_menu";