From f8f908565329574b4b9b3dc1be32d291aab6c1e1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 Nov 2018 22:49:26 +0300 Subject: FavContacts -> g_plugin --- plugins/FavContacts/src/favlist.h | 4 +-- plugins/FavContacts/src/main.cpp | 2 +- plugins/FavContacts/src/menu.cpp | 4 +-- plugins/FavContacts/src/options.cpp | 64 ++++++++++++++++++------------------ plugins/FavContacts/src/services.cpp | 24 +++++++------- plugins/FavContacts/src/stdafx.h | 2 ++ 6 files changed, 52 insertions(+), 48 deletions(-) (limited to 'plugins/FavContacts') diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h index 6581193ec9..c0bfb91a8d 100644 --- a/plugins/FavContacts/src/favlist.h +++ b/plugins/FavContacts/src/favlist.h @@ -112,7 +112,7 @@ public: nGroups = 1; for (auto &hContact : Contacts()) - if (db_get_b(hContact, "FavContacts", "IsFavourite", 0)) + if (g_plugin.getByte(hContact, "IsFavourite", 0)) addContact(hContact, true); int nRecent = 0; @@ -121,7 +121,7 @@ public: if (!hContact) break; - if (!db_get_b(hContact, "FavContacts", "IsFavourite", 0)) + if (!g_plugin.getByte(hContact, "IsFavourite", 0)) nRecent += addContact(hContact, false); } } diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index ca6cbdb0c5..fa0159d435 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -50,7 +50,7 @@ static PLUGININFOEX pluginInfoEx = { }; CMPlugin::CMPlugin() : - PLUGIN("FavContacts", pluginInfoEx) + PLUGIN(MODULENAME, pluginInfoEx) {} ///////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp index 2885c42007..086d303557 100644 --- a/plugins/FavContacts/src/menu.cpp +++ b/plugins/FavContacts/src/menu.cpp @@ -257,7 +257,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = nullp lpdis->rcItem.left += 20; - if (options->wMaxRecent && db_get_b(hContact, "FavContacts", "IsFavourite", 0)) { + if (options->wMaxRecent && g_plugin.getByte(hContact, "IsFavourite")) { DrawIconEx(hdcTemp, lpdis->rcItem.right - 18, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, IcoLib_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, nullptr, DI_NORMAL); lpdis->rcItem.right -= 20; @@ -498,7 +498,7 @@ int ShowMenu(bool centered) szMenu.cy = max(szMenu.cy, szColumn.cy); szColumn.cx = szColumn.cy = 0; - int maxWidth = GetSystemMetrics(SM_CXSCREEN) * db_get_b(0, "FavContacts", "MenuWidth", 66) / 100; + int maxWidth = GetSystemMetrics(SM_CXSCREEN) * g_plugin.getByte("MenuWidth", 66) / 100; if (szMenu.cx > maxWidth) { g_widthMultiplier = (float)maxWidth / szMenu.cx; szMenu.cx *= g_widthMultiplier; diff --git a/plugins/FavContacts/src/options.cpp b/plugins/FavContacts/src/options.cpp index 1d341ddabe..af7034e7dd 100644 --- a/plugins/FavContacts/src/options.cpp +++ b/plugins/FavContacts/src/options.cpp @@ -22,36 +22,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void LoadOptions() { - g_Options.bSecondLine = db_get_b(0, "FavContacts", "SecondLine", 1); - g_Options.bAvatars = db_get_b(0, "FavContacts", "Avatars", 1); - g_Options.bAvatarBorder = db_get_b(0, "FavContacts", "AvatarBorder", 0); - g_Options.wAvatarRadius = db_get_w(0, "FavContacts", "AvatarRadius", 3); - g_Options.bNoTransparentBorder = db_get_b(0, "FavContacts", "NoTransparentBorder", - !db_get_b(0, "FavContacts", "AvatarBorderTransparent", 1)); - g_Options.bSysColors = db_get_b(0, "FavContacts", "SysColors", 0); - g_Options.bCenterHotkey = db_get_b(0, "FavContacts", "CenterHotkey", 1); - g_Options.bUseGroups = db_get_b(0, "FavContacts", "UseGroups", 0); - g_Options.bUseColumns = db_get_b(0, "FavContacts", "UseColumns", 1); - g_Options.bRightAvatars = db_get_b(0, "FavContacts", "RightAvatars", 0); - g_Options.bDimIdle = db_get_b(0, "FavContacts", "DimIdle", 1); - - g_Options.wMaxRecent = db_get_b(0, "FavContacts", "MaxRecent", 10); + g_Options.bSecondLine = g_plugin.getByte("SecondLine", 1); + g_Options.bAvatars = g_plugin.getByte("Avatars", 1); + g_Options.bAvatarBorder = g_plugin.getByte("AvatarBorder", 0); + g_Options.wAvatarRadius = g_plugin.getWord("AvatarRadius", 3); + g_Options.bNoTransparentBorder = g_plugin.getByte("NoTransparentBorder", + !g_plugin.getByte("AvatarBorderTransparent", 1)); + g_Options.bSysColors = g_plugin.getByte("SysColors", 0); + g_Options.bCenterHotkey = g_plugin.getByte("CenterHotkey", 1); + g_Options.bUseGroups = g_plugin.getByte("UseGroups", 0); + g_Options.bUseColumns = g_plugin.getByte("UseColumns", 1); + g_Options.bRightAvatars = g_plugin.getByte("RightAvatars", 0); + g_Options.bDimIdle = g_plugin.getByte("DimIdle", 1); + + g_Options.wMaxRecent = g_plugin.getByte("MaxRecent", 10); } static void sttSaveOptions() { - db_set_b(0, "FavContacts", "SecondLine", g_Options.bSecondLine); - db_set_b(0, "FavContacts", "Avatars", g_Options.bAvatars); - db_set_b(0, "FavContacts", "AvatarBorder", g_Options.bAvatarBorder); - db_set_w(0, "FavContacts", "AvatarRadius", g_Options.wAvatarRadius); - db_set_b(0, "FavContacts", "NoTransparentBorder", g_Options.bNoTransparentBorder); - db_set_b(0, "FavContacts", "SysColors", g_Options.bSysColors); - db_set_b(0, "FavContacts", "CenterHotkey", g_Options.bCenterHotkey); - db_set_b(0, "FavContacts", "UseGroups", g_Options.bUseGroups); - db_set_b(0, "FavContacts", "UseColumns", g_Options.bUseColumns); - db_set_b(0, "FavContacts", "RightAvatars", g_Options.bRightAvatars); - db_set_b(0, "FavContacts", "DimIdle", g_Options.bDimIdle); - db_set_w(0, "FavContacts", "MaxRecent", g_Options.wMaxRecent); + g_plugin.setByte("SecondLine", g_Options.bSecondLine); + g_plugin.setByte("Avatars", g_Options.bAvatars); + g_plugin.setByte("AvatarBorder", g_Options.bAvatarBorder); + g_plugin.setWord("AvatarRadius", g_Options.wAvatarRadius); + g_plugin.setByte("NoTransparentBorder", g_Options.bNoTransparentBorder); + g_plugin.setByte("SysColors", g_Options.bSysColors); + g_plugin.setByte("CenterHotkey", g_Options.bCenterHotkey); + g_plugin.setByte("UseGroups", g_Options.bUseGroups); + g_plugin.setByte("UseColumns", g_Options.bUseColumns); + g_plugin.setByte("RightAvatars", g_Options.bRightAvatars); + g_plugin.setByte("DimIdle", g_Options.bDimIdle); + g_plugin.setWord("MaxRecent", g_Options.wMaxRecent); } static void sttResetListOptions(HWND hwndList) @@ -94,7 +94,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA for (auto &hContact : Contacts()) SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), - db_get_b(hContact, "FavContacts", "IsFavourite", 0)); + g_plugin.getByte(hContact, "IsFavourite")); } bInitialized = true; @@ -210,9 +210,10 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA for (auto &hContact : Contacts()) { BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK, SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0); - if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0)) - db_set_b(hContact, "FavContacts", "IsFavourite", fav); - if (fav) CallService(MS_AV_GETAVATARBITMAP, hContact, 0); + if (fav != g_plugin.getByte(hContact, "IsFavourite")) + g_plugin.setByte(hContact, "IsFavourite", fav); + if (fav) + CallService(MS_AV_GETAVATARBITMAP, hContact, 0); } } else if (((LPNMHDR)lParam)->idFrom == IDC_CLIST) { @@ -227,8 +228,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA iSelection = (INT_PTR)((NMCLISTCONTROL *)lParam)->hItem; for (auto &hContact : Contacts()) { if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) { - SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection, - db_get_b(hContact, "FavContacts", "IsFavourite", 0)); + SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection, g_plugin.getByte(hContact, "IsFavourite")); break; } } diff --git a/plugins/FavContacts/src/services.cpp b/plugins/FavContacts/src/services.cpp index 8137add545..70418fd155 100644 --- a/plugins/FavContacts/src/services.cpp +++ b/plugins/FavContacts/src/services.cpp @@ -51,9 +51,9 @@ int ProcessSrmmEvent(WPARAM, LPARAM lParam) hDialogsList = WindowList_Create(); WindowList_Add(hDialogsList, event->hwndWindow, event->hContact); - BYTE fav = db_get_b(event->hContact, "FavContacts", "IsFavourite", 0); + BYTE fav = g_plugin.getByte(event->hContact, "IsFavourite"); StatusIconData sid = {}; - sid.szModule = "FavContacts"; + sid.szModule = MODULENAME; sid.flags = fav ? 0 : MBF_DISABLED; Srmm_ModifyIcon(event->hContact, &sid); @@ -82,18 +82,20 @@ int ProcessSrmmEvent(WPARAM, LPARAM lParam) int ProcessSrmmIconClick(WPARAM hContact, LPARAM lParam) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if (mir_strcmp(sicd->szModule, "FavContacts")) return 0; + if (mir_strcmp(sicd->szModule, MODULENAME)) + return 0; if (!hContact) return 0; if (sicd->flags & MBCF_RIGHTBUTTON) { - BYTE fav = !db_get_b(hContact, "FavContacts", "IsFavourite", 0); - db_set_b(hContact, "FavContacts", "IsFavourite", fav); - if (fav) CallService(MS_AV_GETAVATARBITMAP, hContact, 0); + BYTE fav = !g_plugin.getByte(hContact, "IsFavourite"); + g_plugin.setByte(hContact, "IsFavourite", fav); + if (fav) + CallService(MS_AV_GETAVATARBITMAP, hContact, 0); StatusIconData sid = {}; - sid.szModule = "FavContacts"; + sid.szModule = MODULENAME; sid.flags = fav ? 0 : MBF_DISABLED; Srmm_ModifyIcon(hContact, &sid); } @@ -147,7 +149,7 @@ int ProcessModulesLoaded(WPARAM, LPARAM) HookEvent(ME_TTB_MODULELOADED, ProcessTBLoaded); StatusIconData sid = {}; - sid.szModule = "FavContacts"; + sid.szModule = MODULENAME; sid.szTooltip = LPGEN("Favorite Contacts"); sid.hIcon = IcoLib_GetIconByHandle(iconList[0].hIcolib); sid.hIconDisabled = IcoLib_GetIconByHandle(iconList[1].hIcolib); @@ -160,7 +162,7 @@ int ProcessModulesLoaded(WPARAM, LPARAM) FontIDW fontid = {}; wcsncpy_s(fontid.group, LPGENW("Favorite Contacts"), _TRUNCATE); - strncpy_s(fontid.dbSettingsGroup, "FavContacts", _TRUNCATE); + strncpy_s(fontid.dbSettingsGroup, MODULENAME, _TRUNCATE); wcsncpy_s(fontid.backgroundGroup, LPGENW("Favorite Contacts"), _TRUNCATE); fontid.flags = FIDF_DEFAULTVALID; fontid.deffontsettings.charset = DEFAULT_CHARSET; @@ -200,7 +202,7 @@ int ProcessModulesLoaded(WPARAM, LPARAM) ColourIDW colourid = {}; wcsncpy_s(colourid.group, LPGENW("Favorite Contacts"), _TRUNCATE); - strncpy_s(colourid.dbSettingsGroup, "FavContacts", _TRUNCATE); + strncpy_s(colourid.dbSettingsGroup, MODULENAME, _TRUNCATE); wcsncpy_s(colourid.name, LPGENW("Background"), _TRUNCATE); strncpy_s(colourid.setting, "BackColour", _TRUNCATE); @@ -228,7 +230,7 @@ int ProcessModulesLoaded(WPARAM, LPARAM) if (ServiceExists(MS_AV_GETAVATARBITMAP)) { for (auto &hContact : Contacts()) - if (db_get_b(hContact, "FavContacts", "IsFavourite", 0)) + if (g_plugin.getByte(hContact, "IsFavourite")) CallService(MS_AV_GETAVATARBITMAP, hContact, 0); } diff --git a/plugins/FavContacts/src/stdafx.h b/plugins/FavContacts/src/stdafx.h index 8c08062ec9..84b456665c 100644 --- a/plugins/FavContacts/src/stdafx.h +++ b/plugins/FavContacts/src/stdafx.h @@ -49,6 +49,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#define MODULENAME "FavContacts" + struct CMPlugin : public PLUGIN { CMPlugin(); -- cgit v1.2.3