From 53fe3e46177d17b4941610de19f5cc6210700cb4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 Nov 2018 21:44:56 +0300 Subject: db_* functions replaced with g_plugin calls --- plugins/NewsAggregator/Src/Menus.cpp | 4 ++-- plugins/NewsAggregator/Src/Services.cpp | 12 ++++++------ plugins/NewsAggregator/Src/Update.cpp | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'plugins/NewsAggregator/Src') diff --git a/plugins/NewsAggregator/Src/Menus.cpp b/plugins/NewsAggregator/Src/Menus.cpp index 8623ec52c4..9459f9697c 100644 --- a/plugins/NewsAggregator/Src/Menus.cpp +++ b/plugins/NewsAggregator/Src/Menus.cpp @@ -30,7 +30,7 @@ void InitMenu() SET_UID(mi, 0x3ec91864, 0xefa7, 0x4994, 0xb7, 0x75, 0x6c, 0x96, 0xcb, 0x29, 0x2f, 0x93); mi.position = 10100001; - if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1)) + if (g_plugin.getByte("AutoUpdate", 1)) mi.name.w = LPGENW("Auto Update Enabled"); else mi.name.w = LPGENW("Auto Update Disabled"); @@ -79,5 +79,5 @@ void InitMenu() mi.pszService = MS_NEWSAGGREGATOR_CHANGEFEED; hService2[6] = Menu_AddContactMenuItem(&mi, MODULENAME); - Menu_ModifyItem(hService2[0], nullptr, GetIconHandle(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? "enabled" : "disabled")); + Menu_ModifyItem(hService2[0], nullptr, GetIconHandle(g_plugin.getByte("AutoUpdate", 1) ? "enabled" : "disabled")); } diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index 852f316517..3dc61421d1 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -37,7 +37,7 @@ int NewsAggrInit(WPARAM, LPARAM) mir_wstrncpy(tszRoot, VARSW(L"%miranda_userdata%\\Avatars\\" _A2W(DEFAULT_AVATARS_FOLDER)), _countof(tszRoot)); for (auto &hContact : Contacts(MODULENAME)) { - if (!db_get_b(NULL, MODULENAME, "StartupRetrieve", 1)) + if (!g_plugin.getByte("StartupRetrieve", 1)) db_set_dw(hContact, MODULENAME, "LastCheck", time(0)); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE); } @@ -209,7 +209,7 @@ INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam) // otherwise, cached avatar is used if ((wParam & GAIF_FORCE) && db_get_dw(pai->hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME)) UpdateListAdd(pai->hContact); - if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) != 0 && !ThreadRunning) + if (g_plugin.getByte("AutoUpdate", 1) != 0 && !ThreadRunning) mir_forkthread(UpdateThreadProc, (void *)TRUE); wchar_t *ptszImageURL = db_get_wsa(pai->hContact, MODULENAME, "ImageURL"); @@ -239,14 +239,14 @@ void UpdateMenu(bool State) Menu_ModifyItem(hService2[0], LPGENW("Auto Update Disabled"), GetIconHandle("disabled")); CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, State ? TTBST_PUSHED : 0); - db_set_b(NULL, MODULENAME, "AutoUpdate", !State); + g_plugin.setByte("AutoUpdate", !State); } // update the newsaggregator auto-update menu item when click on it INT_PTR EnableDisable(WPARAM, LPARAM) { - UpdateMenu(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) != 0); - NewsAggrSetStatus(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE, 0); + UpdateMenu(g_plugin.getByte("AutoUpdate", 1) != 0); + NewsAggrSetStatus(g_plugin.getByte("AutoUpdate", 1) ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE, 0); return 0; } @@ -259,7 +259,7 @@ int OnToolbarLoaded(WPARAM, LPARAM) ttb.pszTooltipDn = LPGEN("Auto Update Disabled"); ttb.hIconHandleUp = GetIconHandle("enabled"); ttb.hIconHandleDn = GetIconHandle("disabled"); - ttb.dwFlags = (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; + ttb.dwFlags = (g_plugin.getByte("AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; hTBButton = g_plugin.addTTB(&ttb); return 0; } diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp index 7809904ad9..cde3ef2686 100644 --- a/plugins/NewsAggregator/Src/Update.cpp +++ b/plugins/NewsAggregator/Src/Update.cpp @@ -33,7 +33,7 @@ void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) for (auto &hContact : Contacts(MODULENAME)) { if (db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME)) { double diff = difftime(time(0), (time_t)db_get_dw(hContact, MODULENAME, "LastCheck", 0)); - if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) { + if (g_plugin.getByte("AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) { UpdateListAdd(hContact); HaveUpdates = TRUE; } @@ -51,8 +51,8 @@ void CALLBACK timerProc2(HWND, UINT, UINT_PTR, DWORD) KillTimer(nullptr, timerId); ThreadRunning = FALSE; - if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) && !Miranda_IsTerminated()) { - if (db_get_b(NULL, MODULENAME, "StartupRetrieve", 1)) + if (g_plugin.getByte("AutoUpdate", 1) && !Miranda_IsTerminated()) { + if (g_plugin.getByte("StartupRetrieve", 1)) CheckAllFeeds(0, 1); timerId = SetTimer(nullptr, 0, 30000, (TIMERPROC)timerProc); } -- cgit v1.2.3