From 06f988c03397110b08fd04573894ccff53265e6d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 Nov 2018 23:15:40 +0300 Subject: rest of historysweeperlight --- plugins/HistorySweeperLight/src/main.cpp | 20 +++++------ plugins/HistorySweeperLight/src/options.cpp | 56 ++++++++++++++--------------- plugins/HistorySweeperLight/src/stdafx.h | 2 +- 3 files changed, 38 insertions(+), 40 deletions(-) (limited to 'plugins/HistorySweeperLight') diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp index 2f48385696..04c3164429 100644 --- a/plugins/HistorySweeperLight/src/main.cpp +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -42,7 +42,7 @@ static PLUGININFOEX pluginInfoEx = }; CMPlugin::CMPlugin() : - PLUGIN(ModuleName, pluginInfoEx) + PLUGIN(MODULENAME, pluginInfoEx) {} ///////////////////////////////////////////////////////////////////////////////////////// @@ -51,17 +51,17 @@ static int OnIconPressed(WPARAM hContact, LPARAM lParam) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if (!(sicd->flags & MBCF_RIGHTBUTTON) && !mir_strcmp(sicd->szModule, ModuleName) && db_get_b(0, ModuleName, "ChangeInMW", 0)) { + if (!(sicd->flags & MBCF_RIGHTBUTTON) && !mir_strcmp(sicd->szModule, MODULENAME) && g_plugin.getByte("ChangeInMW", 0)) { int nh = sicd->dwId; StatusIconData sid = {}; - sid.szModule = ModuleName; + sid.szModule = MODULENAME; sid.dwId = nh; sid.flags = MBF_HIDDEN; Srmm_ModifyIcon(hContact, &sid); nh = (nh + 1) % 4; - db_set_b(hContact, ModuleName, "SweepHistory", (BYTE)nh); + g_plugin.setByte(hContact, "SweepHistory", (BYTE)nh); sid.dwId = nh; sid.flags = 0; @@ -72,18 +72,18 @@ static int OnIconPressed(WPARAM hContact, LPARAM lParam) static int OnModulesLoaded(WPARAM, LPARAM) { - int sweep = db_get_b(0, ModuleName, "SweepHistory", 0); + int sweep = g_plugin.getByte("SweepHistory", 0); StatusIconData sid = {}; - sid.szModule = ModuleName; + sid.szModule = MODULENAME; sid.hIcon = LoadIconEx("actG"); if (sweep == 0) sid.szTooltip = LPGEN("Keep all events"); else if (sweep == 1) - sid.szTooltip = time_stamp_strings[db_get_b(0, ModuleName, "StartupShutdownOlder", 0)]; + sid.szTooltip = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; else if (sweep == 2) - sid.szTooltip = keep_strings[db_get_b(0, ModuleName, "StartupShutdownKeep", 0)]; + sid.szTooltip = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; else if (sweep == 3) sid.szTooltip = LPGEN("Delete all events"); @@ -92,13 +92,13 @@ static int OnModulesLoaded(WPARAM, LPARAM) sid.dwId = 1; sid.hIcon = LoadIconEx("act1"); - sid.szTooltip = time_stamp_strings[db_get_b(0, ModuleName, "StartupShutdownOlder", 0)]; + sid.szTooltip = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; sid.flags = MBF_HIDDEN; Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 2; sid.hIcon = LoadIconEx("act2"); - sid.szTooltip = keep_strings[db_get_b(0, ModuleName, "StartupShutdownKeep", 0)]; + sid.szTooltip = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; sid.flags = MBF_HIDDEN; Srmm_AddIcon(&sid, &g_plugin); diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp index 1c54372f43..e8fd5fdffa 100644 --- a/plugins/HistorySweeperLight/src/options.cpp +++ b/plugins/HistorySweeperLight/src/options.cpp @@ -56,13 +56,13 @@ static HANDLE hIconLibItem[_countof(iconList)]; void InitIcons(void) { - g_plugin.registerIcon(ModuleName, iconList, ModuleName); + g_plugin.registerIcon(MODULENAME, iconList, MODULENAME); } HICON LoadIconEx(const char* name) { char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", ModuleName, name); + mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); return IcoLib_GetIcon(szSettingName); } @@ -78,7 +78,7 @@ HANDLE GetIconHandle(const char* name) void ReleaseIconEx(const char* name) { char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", ModuleName, name); + mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); IcoLib_Release(szSettingName); } @@ -87,14 +87,14 @@ HANDLE hAllContacts, hSystemHistory; static void ShowAllContactIcons(HWND hwndList) { SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hAllContacts, - MAKELPARAM(0, db_get_b(0, ModuleName, "SweepHistory", 0))); + MAKELPARAM(0, g_plugin.getByte("SweepHistory", 0))); SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hSystemHistory, - MAKELPARAM(0, db_get_b(0, ModuleName, "SweepSHistory", 0))); + MAKELPARAM(0, g_plugin.getByte("SweepSHistory", 0))); for (auto &hContact : Contacts()) { HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0); SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, - MAKELPARAM(0, db_get_b(hContact, ModuleName, "SweepHistory", 0))); + MAKELPARAM(0, g_plugin.getByte(hContact, "SweepHistory"))); } } @@ -127,63 +127,61 @@ void LoadSettings(HWND hwndDlg) SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr); } - SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_SETCURSEL, db_get_b(0, ModuleName, "StartupShutdownOlder", 0), 0); - SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_SETCURSEL, db_get_b(0, ModuleName, "StartupShutdownKeep", 0), 0); + SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_SETCURSEL, g_plugin.getByte("StartupShutdownOlder", 0), 0); + SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_SETCURSEL, g_plugin.getByte("StartupShutdownKeep", 0), 0); - CheckDlgButton(hwndDlg, IDC_UNSAFEMODE, db_get_b(0, ModuleName, "UnsafeMode", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SWEEPONCLOSE, db_get_b(0, ModuleName, "SweepOnClose", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_HISTMW, db_get_b(0, ModuleName, "ChangeInMW", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_UNSAFEMODE, g_plugin.getByte("UnsafeMode", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SWEEPONCLOSE, g_plugin.getByte("SweepOnClose", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_HISTMW, g_plugin.getByte("ChangeInMW", 0) ? BST_CHECKED : BST_UNCHECKED); } void SaveSettings(HWND hwndDlg) { HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); - db_set_b(0, ModuleName, "StartupShutdownOlder", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_GETCURSEL, 0, 0)); - db_set_b(0, ModuleName, "StartupShutdownKeep", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_GETCURSEL, 0, 0)); - db_set_b(0, ModuleName, "UnsafeMode", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UNSAFEMODE)); - db_set_b(0, ModuleName, "SweepOnClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SWEEPONCLOSE)); - db_set_b(0, ModuleName, "ChangeInMW", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HISTMW)); + g_plugin.setByte("StartupShutdownOlder", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_GETCURSEL, 0, 0)); + g_plugin.setByte("StartupShutdownKeep", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_GETCURSEL, 0, 0)); + g_plugin.setByte("UnsafeMode", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UNSAFEMODE)); + g_plugin.setByte("SweepOnClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SWEEPONCLOSE)); + g_plugin.setByte("ChangeInMW", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HISTMW)); - db_set_b(0, ModuleName, "SweepHistory", - (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hAllContacts, 0)); - db_set_b(0, ModuleName, "SweepSHistory", - (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0)); + g_plugin.setByte("SweepHistory", (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hAllContacts, 0)); + g_plugin.setByte("SweepSHistory", (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0)); for (auto &hContact : Contacts()) { HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0); int st = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0); if (st != 0) - db_set_b(hContact, ModuleName, "SweepHistory", (BYTE)st); + g_plugin.setByte(hContact, "SweepHistory", (BYTE)st); else - db_unset(hContact, ModuleName, "SweepHistory"); + g_plugin.delSetting(hContact, "SweepHistory"); } for (auto &it : g_hWindows) SetSrmmIcon(UINT_PTR(it)); // set tooltips - int st = db_get_b(0, ModuleName, "SweepHistory", 0); + int st = g_plugin.getByte("SweepHistory", 0); StatusIconData sid = {}; - sid.szModule = ModuleName; + sid.szModule = MODULENAME; sid.dwId = 0; sid.hIcon = LoadIconEx("actG"); if (st == 0) sid.szTooltip = LPGEN("Keep all events"); - else if (st == 1) sid.szTooltip = LPGEN(time_stamp_strings[db_get_b(0, ModuleName, "StartupShutdownOlder", 0)]); - else if (st == 2) sid.szTooltip = LPGEN(keep_strings[db_get_b(0, ModuleName, "StartupShutdownKeep", 0)]); + else if (st == 1) sid.szTooltip = LPGEN(time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]); + else if (st == 2) sid.szTooltip = LPGEN(keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]); else if (st == 3) sid.szTooltip = LPGEN("Delete all events"); Srmm_ModifyIcon(NULL, &sid); sid.dwId = 1; sid.hIcon = LoadIconEx("act1"); - sid.szTooltip = time_stamp_strings[db_get_b(0, ModuleName, "StartupShutdownOlder", 0)]; + sid.szTooltip = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; Srmm_ModifyIcon(NULL, &sid); sid.dwId = 2; sid.hIcon = LoadIconEx("act2"); - sid.szTooltip = keep_strings[db_get_b(0, ModuleName, "StartupShutdownKeep", 0)]; + sid.szTooltip = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; Srmm_ModifyIcon(NULL, &sid); } @@ -271,7 +269,7 @@ int HSOptInitialise(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = {}; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HISTORYSWEEPER); - odp.szTitle.a = ModuleName; + odp.szTitle.a = MODULENAME; odp.szGroup.a = LPGEN("History"); odp.pfnDlgProc = DlgProcHSOpts; odp.flags = ODPF_BOLDGROUPS; diff --git a/plugins/HistorySweeperLight/src/stdafx.h b/plugins/HistorySweeperLight/src/stdafx.h index 9b680898dd..5172588f6b 100644 --- a/plugins/HistorySweeperLight/src/stdafx.h +++ b/plugins/HistorySweeperLight/src/stdafx.h @@ -42,7 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "version.h" // Plugin name -#define ModuleName "History Sweeper Light" +#define MODULENAME "History Sweeper Light" struct CMPlugin : public PLUGIN { -- cgit v1.2.3