From a6b9f6570b4cb4a425f91d4694e6b027f12cc8b7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 14 Nov 2018 15:57:47 +0300 Subject: hContact, MODULENAME -> g_plugin --- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 38 ++++++++++++------------- plugins/BuddyExpectator/src/options.cpp | 12 ++++---- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'plugins/BuddyExpectator/src') diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index 3d4d799d6d..2760f7c387 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -68,14 +68,14 @@ CMPlugin::CMPlugin() : time_t getLastSeen(MCONTACT hContact) { - return db_get_dw(hContact, MODULENAME, "LastSeen", db_get_dw(hContact, MODULENAME, "CreationTime", (DWORD)-1)); + return g_plugin.getDword(hContact, "LastSeen", g_plugin.getDword(hContact, "CreationTime", (DWORD)-1)); } void setLastSeen(MCONTACT hContact) { - db_set_dw(hContact, MODULENAME, "LastSeen", (DWORD)time(0)); - if (db_get_b(hContact, MODULENAME, "StillAbsentNotified", 0)) - db_set_b(hContact, MODULENAME, "StillAbsentNotified", 0); + g_plugin.setDword(hContact, "LastSeen", (DWORD)time(0)); + if (g_plugin.getByte(hContact, "StillAbsentNotified", 0)) + g_plugin.setByte(hContact, "StillAbsentNotified", 0); } time_t getLastInputMsg(MCONTACT hContact) @@ -223,7 +223,7 @@ bool isContactGoneFor(MCONTACT hContact, int days) if (options.hideInactive) if (daysSinceMessage >= options.iSilencePeriod) - if (!db_get_b(hContact, "CList", "Hidden", 0) && !db_get_b(hContact, MODULENAME, "NeverHide", 0)) { + if (!db_get_b(hContact, "CList", "Hidden", 0) && !g_plugin.getByte(hContact, "NeverHide", 0)) { POPUPDATAT_V2 ppd = { 0 }; ppd.cbSize = sizeof(ppd); ppd.lchContact = hContact; @@ -411,12 +411,12 @@ int onIconsChanged(WPARAM, LPARAM) */ INT_PTR MenuMissYouClick(WPARAM hContact, LPARAM) { - if (db_get_b(hContact, MODULENAME, "MissYou", 0)) { - db_set_b(hContact, MODULENAME, "MissYou", 0); + if (g_plugin.getByte(hContact, "MissYou", 0)) { + g_plugin.setByte(hContact, "MissYou", 0); ExtraIcon_Clear(hExtraIcon, hContact); } else { - db_set_b(hContact, MODULENAME, "MissYou", 1); + g_plugin.setByte(hContact, "MissYou", 1); ExtraIcon_SetIconByName(hExtraIcon, hContact, "enabled_icon"); } @@ -432,7 +432,7 @@ int onPrebuildContactMenu(WPARAM hContact, LPARAM) if (!proto) return 0; - if (db_get_b(hContact, MODULENAME, "MissYou", 0)) + if (g_plugin.getByte(hContact, "MissYou", 0)) Menu_ModifyItem(hContactMenu, LPGENW("Disable Miss You"), iconList[1].hIcolib); else Menu_ModifyItem(hContactMenu, LPGENW("Enable Miss You"), iconList[2].hIcolib); @@ -443,7 +443,7 @@ int onPrebuildContactMenu(WPARAM hContact, LPARAM) int onExtraImageApplying(WPARAM hContact, LPARAM) { - if (db_get_b(hContact, MODULENAME, "MissYou", 0)) + if (g_plugin.getByte(hContact, "MissYou", 0)) ExtraIcon_SetIconByName(hExtraIcon, hContact, "enabled_icon"); return 0; @@ -473,10 +473,10 @@ int SettingChanged(WPARAM hContact, LPARAM lParam) return 0; // Last status - db_set_dw(hContact, MODULENAME, "LastStatus", prevStatus); + g_plugin.setDword(hContact, "LastStatus", prevStatus); if (prevStatus == ID_STATUS_OFFLINE) { - if (db_get_b(hContact, MODULENAME, "MissYou", 0)) { + if (g_plugin.getByte(hContact, "MissYou", 0)) { // Display Popup POPUPDATAT_V2 ppd = { 0 }; ppd.cbSize = sizeof(ppd); @@ -508,12 +508,12 @@ int SettingChanged(WPARAM hContact, LPARAM lParam) return 0; } - if (db_get_dw(hContact, MODULENAME, "LastSeen", (DWORD)-1) == (DWORD)-1 && options.notifyFirstOnline) { + if (g_plugin.getDword(hContact, "LastSeen", (DWORD)-1) == (DWORD)-1 && options.notifyFirstOnline) { ReturnNotify(hContact, TranslateT("has gone online for the first time.")); setLastSeen(hContact); } - unsigned int AbsencePeriod = db_get_dw(hContact, MODULENAME, "iAbsencePeriod", options.iAbsencePeriod); + unsigned int AbsencePeriod = g_plugin.getDword(hContact, "iAbsencePeriod", options.iAbsencePeriod); if (isContactGoneFor(hContact, AbsencePeriod)) { wchar_t* message = TranslateT("has returned after a long absence."); wchar_t tmpBuf[251] = { 0 }; @@ -544,9 +544,9 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) { for (auto &hContact : Contacts()) { char *proto = GetContactProto(hContact); - if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULENAME, "StillAbsentNotified", 0) == 0)) + if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (g_plugin.getByte(hContact, "StillAbsentNotified", 0) == 0)) { - db_set_b(hContact, MODULENAME, "StillAbsentNotified", 1); + g_plugin.setByte(hContact, "StillAbsentNotified", 1); Skin_PlaySound("buddyExpectatorStillAbsent"); wchar_t* message = TranslateT("has not returned after a long absence."); @@ -635,7 +635,7 @@ int ModulesLoaded(WPARAM, LPARAM) int ContactAdded(WPARAM hContact, LPARAM) { - db_set_dw(hContact, MODULENAME, "CreationTime", (DWORD)time(0)); + g_plugin.setDword(hContact, "CreationTime", (DWORD)time(0)); return 0; } @@ -664,8 +664,8 @@ int CMPlugin::Load() // ensure all contacts are timestamped DWORD current_time = (DWORD)time(0); for (auto &hContact : Contacts()) - if (!db_get_dw(hContact, MODULENAME, "CreationTime")) - db_set_dw(hContact, MODULENAME, "CreationTime", current_time); + if (!g_plugin.getDword(hContact, "CreationTime")) + g_plugin.setDword(hContact, "CreationTime", current_time); g_plugin.registerIcon("BuddyExpectator", iconList); diff --git a/plugins/BuddyExpectator/src/options.cpp b/plugins/BuddyExpectator/src/options.cpp index aeac064fb6..4655dcfef6 100644 --- a/plugins/BuddyExpectator/src/options.cpp +++ b/plugins/BuddyExpectator/src/options.cpp @@ -247,8 +247,8 @@ static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, // clear all notified settings for (auto &hContact : Contacts()) - if (db_get_b(hContact, MODULENAME, "StillAbsentNotified", 0)) - db_set_b(hContact, MODULENAME, "StillAbsentNotified", 0); + if (g_plugin.getByte(hContact, "StillAbsentNotified", 0)) + g_plugin.setByte(hContact, "StillAbsentNotified", 0); // restart timer & run check KillTimer(nullptr, timer_id); @@ -504,10 +504,10 @@ INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lpar MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lparam)->lParam; if (hContact) { - db_set_dw(hContact, MODULENAME, "iAbsencePeriod", GetDlgItemInt(hdlg, IDC_EDITABSENCE, nullptr, FALSE)); - db_set_b(hContact, MODULENAME, "MissYou", (IsDlgButtonChecked(hdlg, IDC_CHECK_MISSYOU) == BST_CHECKED) ? 1 : 0); - db_set_b(hContact, MODULENAME, "MissYouNotifyAlways", (IsDlgButtonChecked(hdlg, IDC_CHECK_NOTIFYALWAYS) == BST_CHECKED) ? 1 : 0); - db_set_b(hContact, MODULENAME, "NeverHide", (IsDlgButtonChecked(hdlg, IDC_CHECK_NEVERHIDE) == BST_CHECKED) ? 1 : 0); + g_plugin.setDword(hContact, "iAbsencePeriod", GetDlgItemInt(hdlg, IDC_EDITABSENCE, nullptr, FALSE)); + g_plugin.setByte(hContact, "MissYou", (IsDlgButtonChecked(hdlg, IDC_CHECK_MISSYOU) == BST_CHECKED) ? 1 : 0); + g_plugin.setByte(hContact, "MissYouNotifyAlways", (IsDlgButtonChecked(hdlg, IDC_CHECK_NOTIFYALWAYS) == BST_CHECKED) ? 1 : 0); + g_plugin.setByte(hContact, "NeverHide", (IsDlgButtonChecked(hdlg, IDC_CHECK_NEVERHIDE) == BST_CHECKED) ? 1 : 0); } break; } -- cgit v1.2.3