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/Ping/src/log.cpp | 4 ++-- plugins/Ping/src/options.cpp | 48 ++++++++++++++++++++--------------------- plugins/Ping/src/ping.cpp | 6 +++--- plugins/Ping/src/pinggraph.cpp | 22 +++++++++---------- plugins/Ping/src/pinglist.cpp | 4 ++-- plugins/Ping/src/pingthread.cpp | 30 +++++++++++++------------- 6 files changed, 57 insertions(+), 57 deletions(-) (limited to 'plugins/Ping/src') diff --git a/plugins/Ping/src/log.cpp b/plugins/Ping/src/log.cpp index 2ac0f8db41..b084eb1f7f 100644 --- a/plugins/Ping/src/log.cpp +++ b/plugins/Ping/src/log.cpp @@ -32,7 +32,7 @@ INT_PTR Log(WPARAM wParam, LPARAM) { INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; wchar_t *filename = (wchar_t *)lParam; - if (db_get_ws(0, MODULENAME, "LogFilename", &dbv)) { + if (g_plugin.getWString("LogFilename", &dbv)) { Profile_GetPathW(wParam, filename); mir_wstrncat(filename, L"\\ping_log.txt", wParam - mir_wstrlen(filename)); } @@ -47,7 +47,7 @@ INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam) { } INT_PTR SetLogFilename(WPARAM, LPARAM lParam) { - db_set_ws(0, MODULENAME, "LogFilename", (wchar_t *)lParam); + g_plugin.setWString("LogFilename", (wchar_t *)lParam); return 0; } diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp index c6bac11d8d..71e62e2a9b 100644 --- a/plugins/Ping/src/options.cpp +++ b/plugins/Ping/src/options.cpp @@ -514,50 +514,50 @@ int PingOptInit(WPARAM wParam, LPARAM) } void LoadOptions() { - options.ping_period = db_get_dw(NULL, MODULENAME, "PingPeriod", DEFAULT_PING_PERIOD); + options.ping_period = g_plugin.getDword("PingPeriod", DEFAULT_PING_PERIOD); - options.ping_timeout = db_get_dw(NULL, MODULENAME, "PingTimeout", DEFAULT_PING_TIMEOUT); + options.ping_timeout = g_plugin.getDword("PingTimeout", DEFAULT_PING_TIMEOUT); CallService(MODULENAME "/SetPingTimeout", (WPARAM)options.ping_timeout, 0); - options.show_popup = (db_get_b(NULL, MODULENAME, "ShowPopup", DEFAULT_SHOW_POPUP ? 1 : 0) == 1); - options.show_popup2 = (db_get_b(NULL, MODULENAME, "ShowPopup2", DEFAULT_SHOW_POPUP2 ? 1 : 0) == 1); - options.block_reps = (db_get_b(NULL, MODULENAME, "BlockReps", DEFAULT_BLOCK_REPS ? 1 : 0) == 1); - options.logging = (db_get_b(NULL, MODULENAME, "LoggingEnabled", DEFAULT_LOGGING_ENABLED ? 1 : 0) == 1); + options.show_popup = (g_plugin.getByte("ShowPopup", DEFAULT_SHOW_POPUP ? 1 : 0) == 1); + options.show_popup2 = (g_plugin.getByte("ShowPopup2", DEFAULT_SHOW_POPUP2 ? 1 : 0) == 1); + options.block_reps = (g_plugin.getByte("BlockReps", DEFAULT_BLOCK_REPS ? 1 : 0) == 1); + options.logging = (g_plugin.getByte("LoggingEnabled", DEFAULT_LOGGING_ENABLED ? 1 : 0) == 1); - options.no_test_icon = (db_get_b(NULL, MODULENAME, "NoTestStatus", DEFAULT_NO_TEST_ICON ? 1 : 0) == 1); + options.no_test_icon = (g_plugin.getByte("NoTestStatus", DEFAULT_NO_TEST_ICON ? 1 : 0) == 1); - options.indent = db_get_w(NULL, MODULENAME, "Indent", 0); - options.row_height = db_get_w(NULL, MODULENAME, "RowHeight", GetSystemMetrics(SM_CYSMICON)); + options.indent = g_plugin.getWord("Indent", 0); + options.row_height = g_plugin.getWord("RowHeight", GetSystemMetrics(SM_CYSMICON)); - options.retries = db_get_dw(NULL, MODULENAME, "Retries", 0); + options.retries = g_plugin.getDword("Retries", 0); CallService(MODULENAME "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename); ICMP::get_instance()->set_timeout(options.ping_timeout * 1000); - options.attach_to_clist = (db_get_b(NULL, MODULENAME, "AttachToClist", DEFAULT_ATTACH_TO_CLIST ? 1 : 0) == 1); - options.log_csv = (db_get_b(NULL, MODULENAME, "LogCSV", 0) == 1); + options.attach_to_clist = (g_plugin.getByte("AttachToClist", DEFAULT_ATTACH_TO_CLIST ? 1 : 0) == 1); + options.log_csv = (g_plugin.getByte("LogCSV", 0) == 1); } void SaveOptions() { - db_set_dw(NULL, MODULENAME, "PingPeriod", options.ping_period); - db_set_dw(NULL, MODULENAME, "PingTimeout", options.ping_timeout); + g_plugin.setDword("PingPeriod", options.ping_period); + g_plugin.setDword("PingTimeout", options.ping_timeout); CallService(MODULENAME "/SetPingTimeout", (WPARAM)options.ping_timeout, 0); - db_set_b(NULL, MODULENAME, "ShowPopup", options.show_popup ? 1 : 0); - db_set_b(NULL, MODULENAME, "ShowPopup2", options.show_popup2 ? 1 : 0); - db_set_b(NULL, MODULENAME, "BlockReps", options.block_reps ? 1 : 0); - db_set_b(NULL, MODULENAME, "LoggingEnabled", options.logging ? 1 : 0); + g_plugin.setByte("ShowPopup", options.show_popup ? 1 : 0); + g_plugin.setByte("ShowPopup2", options.show_popup2 ? 1 : 0); + g_plugin.setByte("BlockReps", options.block_reps ? 1 : 0); + g_plugin.setByte("LoggingEnabled", options.logging ? 1 : 0); - db_set_b(NULL, MODULENAME, "NoTestStatus", options.no_test_icon ? 1 : 0); + g_plugin.setByte("NoTestStatus", options.no_test_icon ? 1 : 0); - db_set_w(NULL, MODULENAME, "Indent", options.indent); - db_set_w(NULL, MODULENAME, "RowHeight", options.row_height); + g_plugin.setWord("Indent", options.indent); + g_plugin.setWord("RowHeight", options.row_height); - db_set_dw(NULL, MODULENAME, "Retries", (DWORD)options.retries); + g_plugin.setDword("Retries", (DWORD)options.retries); CallService(MODULENAME "/SetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename); ICMP::get_instance()->set_timeout(options.ping_timeout * 1000); - db_set_b(NULL, MODULENAME, "AttachToClist", options.attach_to_clist ? 1 : 0); - db_set_b(NULL, MODULENAME, "LogCSV", options.log_csv ? 1 : 0); + g_plugin.setByte("AttachToClist", options.attach_to_clist ? 1 : 0); + g_plugin.setByte("LogCSV", options.log_csv ? 1 : 0); } diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp index da44e3ac1a..af99d9c4a9 100644 --- a/plugins/Ping/src/ping.cpp +++ b/plugins/Ping/src/ping.cpp @@ -89,10 +89,10 @@ static int OnModulesLoaded(WPARAM, LPARAM) hFillListEvent = HookEvent(MODULENAME "/ListReload", FillList); - if (!db_get_b(0, MODULENAME, "PingPlugImport", 0)) { + if (!g_plugin.getByte("PingPlugImport", 0)) { if (db_get_dw(0, "PingPlug", "NumEntries", 0)) { import_ping_addresses(); - db_set_b(0, MODULENAME, "PingPlugImport", 1); + g_plugin.setByte("PingPlugImport", 1); } } @@ -119,7 +119,7 @@ static IconItem iconList[] = int CMPlugin::Load() { use_raw_ping = false; - db_set_b(0, MODULENAME, "UsingRawSockets", (BYTE)use_raw_ping); + g_plugin.setByte("UsingRawSockets", (BYTE)use_raw_ping); hWakeEvent = CreateEvent(nullptr, FALSE, FALSE, L"Local\\ThreadWaitEvent"); diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp index 254e175eb2..9731a9ecd5 100644 --- a/plugins/Ping/src/pinggraph.cpp +++ b/plugins/Ping/src/pinggraph.cpp @@ -242,7 +242,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { char buff[30]; mir_snprintf(buff, "WindowHandle%d", wd->item_id); - db_set_dw(0, MODULENAME, buff, 0); + g_plugin.setDword(buff, 0); } delete wd; } @@ -255,7 +255,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) { char buff[30]; mir_snprintf(buff, "WindowHandle%d", (DWORD)wParam); - HWND hGraphWnd = (HWND)db_get_dw(0, MODULENAME, buff, 0); + HWND hGraphWnd = (HWND)g_plugin.getDword(buff, 0); if (hGraphWnd) { ShowWindow(hGraphWnd, SW_SHOW); SetWindowPos(hGraphWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); @@ -291,10 +291,10 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) { wd->item_id = (DWORD)wParam; // wParam is destination id wd->hwnd_chk_grid = nullptr; wd->hwnd_chk_stat = nullptr; - wd->show_grid = db_get_b(0, MODULENAME, "ShowGridLines", 0) ? true : false; - wd->show_stat = db_get_b(0, MODULENAME, "ShowStats", 1) ? true : false; + wd->show_grid = g_plugin.getByte("ShowGridLines", 0) ? true : false; + wd->show_stat = g_plugin.getByte("ShowStats", 1) ? true : false; - db_set_dw(0, MODULENAME, buff, (UINT_PTR)hGraphWnd); + g_plugin.setDword(buff, (UINT_PTR)hGraphWnd); SetWindowLongPtr(hGraphWnd, GWLP_USERDATA, (LONG_PTR)wd); @@ -315,11 +315,11 @@ void graphs_cleanup() { for (int i = 0; i < list_size; i++) { mir_snprintf(buff, "WindowHandle%d", i); - if (hwnd = (HWND)db_get_dw(0, MODULENAME, buff, 0)) { + if (hwnd = (HWND)g_plugin.getDword(buff, 0)) { DestroyWindow(hwnd); - db_set_dw(0, MODULENAME, buff, 0); + g_plugin.setDword(buff, 0); mir_snprintf(buff, "WindowWasOpen%d", i); - db_set_b(0, MODULENAME, buff, 1); + g_plugin.setByte(buff, 1); } } } @@ -331,10 +331,10 @@ void graphs_init() { CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); for (pinglist_it i = pl.begin(); i != pl.end(); ++i) { mir_snprintf(buff, "WindowHandle%d", i->item_id); // clean up from possible crash - db_set_dw(0, MODULENAME, buff, 0); + g_plugin.setDword(buff, 0); mir_snprintf(buff, "WindowWasOpen%d", i->item_id); // restore windows that were open on shutdown - if (db_get_b(0, MODULENAME, buff, 0)) { - db_set_b(0, MODULENAME, buff, 0); + if (g_plugin.getByte(buff, 0)) { + g_plugin.setByte(buff, 0); ShowGraph((WPARAM)i->item_id, (LPARAM)i->pszLabel); } } diff --git a/plugins/Ping/src/pinglist.cpp b/plugins/Ping/src/pinglist.cpp index 33c7f34388..485aabe51f 100644 --- a/plugins/Ping/src/pinglist.cpp +++ b/plugins/Ping/src/pinglist.cpp @@ -59,7 +59,7 @@ void write_ping_address(PINGADDRESS &i) if (i.item_id == 0) { i.item_id = NextID++; - db_set_dw(0, MODULENAME, "NextID", NextID); + g_plugin.setDword("NextID", NextID); } db_set_dw(0, buff, "Id", i.item_id); @@ -162,7 +162,7 @@ bool read_ping_address(PINGADDRESS &pa) { pa.index = index; if (pa.item_id >= NextID) { NextID = pa.item_id + 1; - db_set_dw(0, MODULENAME, "NextID", NextID); + g_plugin.setDword("NextID", NextID); } return true; diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index f17298f6e1..7eff156372 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -356,11 +356,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if ((dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS) || (context_point_valid && (x >= dis->rcItem.left && x <= dis->rcItem.right) && (y >= dis->rcItem.top && y <= dis->rcItem.bottom))) { - tcol = db_get_dw(NULL, "CLC", "SelBkColour", GetSysColor(COLOR_HIGHLIGHT)); + tcol = db_get_dw(0, "CLC", "SelBkColour", GetSysColor(COLOR_HIGHLIGHT)); SetBkColor(dis->hDC, tcol); FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol))); - tcol = db_get_dw(NULL, "CLC", "SelTextColour", GetSysColor(COLOR_HIGHLIGHTTEXT)); + tcol = db_get_dw(0, "CLC", "SelTextColour", GetSysColor(COLOR_HIGHLIGHTTEXT)); SetTextColor(dis->hDC, tcol); } else { @@ -368,7 +368,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar SetBkColor(dis->hDC, tcol); FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol))); - tcol = db_get_dw(NULL, MODULENAME, "FontCol", GetSysColor(COLOR_WINDOWTEXT)); + tcol = g_plugin.getDword("FontCol", GetSysColor(COLOR_WINDOWTEXT)); SetTextColor(dis->hDC, tcol); } @@ -475,7 +475,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY) & ~WS_BORDER, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr); - if (db_get_b(NULL, "CList", "Transparent", 0)) { + if (db_get_b(0, "CList", "Transparent", 0)) { if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { } @@ -484,7 +484,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); #endif #ifdef LWA_ALPHA - SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(0, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); #endif } } @@ -499,15 +499,15 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_ACTIVATE: if (wParam == WA_INACTIVE) { if ((HWND)wParam != hwnd) - if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) + if (db_get_b(0, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) if (transparentFocus) SetTimer(hwnd, TM_AUTOALPHA, 250, nullptr); } else { - if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) { + if (db_get_b(0, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) { KillTimer(hwnd, TM_AUTOALPHA); #ifdef LWA_ALPHA - SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(0, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); #endif transparentFocus = 1; } @@ -515,10 +515,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return DefWindowProc(hwnd, msg, wParam, lParam); case WM_SETCURSOR: - if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) { + if (db_get_b(0, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) { if (!transparentFocus && GetForegroundWindow() != hwnd) { #ifdef LWA_ALPHA - SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(0, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); #endif transparentFocus = 1; SetTimer(hwnd, TM_AUTOALPHA, 250, nullptr); @@ -545,8 +545,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (inwnd != transparentFocus) { //change transparentFocus = inwnd; #ifdef LWA_ALPHA - if (transparentFocus) SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); - else SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA); + if (transparentFocus) SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(0, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA); + else SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(0, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA); #endif } if (!transparentFocus) KillTimer(hwnd, TM_AUTOALPHA); @@ -559,7 +559,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar static int noRecurse = 0; if (lParam) break; if (noRecurse) break; - if (!db_get_b(NULL, "CLUI", "FadeInOut", 0)) + if (!db_get_b(0, "CLUI", "FadeInOut", 0)) break; #ifdef WS_EX_LAYERED if (GetWindowLongPtr(hwnd, GWL_EXSTYLE)&WS_EX_LAYERED) { @@ -567,7 +567,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar int sourceAlpha, destAlpha; if (wParam) { sourceAlpha = 0; - destAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT); + destAlpha = (BYTE)db_get_b(0, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT); #ifdef LWA_ALPHA SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_ALPHA); #endif @@ -576,7 +576,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar noRecurse = 0; } else { - sourceAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT); + sourceAlpha = (BYTE)db_get_b(0, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT); destAlpha = 0; } for (startTick = GetTickCount();;) { -- cgit v1.2.3