From 8a74e7495ce5ad39de4f5c25121a84d35df90c36 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 May 2018 15:08:48 +0300 Subject: CMPlugin to receive a reference to PLUGININFOEX --- plugins/Ping/src/log.cpp | 8 +++--- plugins/Ping/src/menu.cpp | 4 +-- plugins/Ping/src/options.cpp | 64 ++++++++++++++++++++--------------------- plugins/Ping/src/ping.cpp | 62 ++++++++++++++++++++------------------- plugins/Ping/src/pinggraph.cpp | 32 ++++++++++----------- plugins/Ping/src/pinglist.cpp | 4 +-- plugins/Ping/src/pingthread.cpp | 46 ++++++++++++++--------------- plugins/Ping/src/rawping.cpp | 22 +++++++------- plugins/Ping/src/stdafx.h | 6 ++-- plugins/Ping/src/utils.cpp | 22 +++++++------- 10 files changed, 136 insertions(+), 134 deletions(-) (limited to 'plugins/Ping/src') diff --git a/plugins/Ping/src/log.cpp b/plugins/Ping/src/log.cpp index 20782c2c17..6c183f40bf 100644 --- a/plugins/Ping/src/log.cpp +++ b/plugins/Ping/src/log.cpp @@ -3,7 +3,7 @@ INT_PTR Log(WPARAM wParam, LPARAM) { wchar_t buf[1024], tbuf[512], dbuf[512]; - CallService(PLUG "/GetLogFilename", (WPARAM)1024, (LPARAM)buf); + CallService(MODULENAME "/GetLogFilename", (WPARAM)1024, (LPARAM)buf); //char TBcapt[255]; SYSTEMTIME systime; @@ -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, PLUG, "LogFilename", &dbv)) { + if (db_get_ws(0, MODULENAME, "LogFilename", &dbv)) { Profile_GetPathW(wParam, filename); mir_wstrncat(filename, L"\\ping_log.txt", wParam - mir_wstrlen(filename)); } @@ -47,13 +47,13 @@ INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam) { } INT_PTR SetLogFilename(WPARAM, LPARAM lParam) { - db_set_ws(0, PLUG, "LogFilename", (wchar_t *)lParam); + db_set_ws(0, MODULENAME, "LogFilename", (wchar_t *)lParam); return 0; } INT_PTR ViewLogData(WPARAM wParam, LPARAM) { wchar_t buf[MAX_PATH]; - CallService(PLUG "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)buf); + CallService(MODULENAME "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)buf); return (INT_PTR)ShellExecute((HWND)wParam, L"edit", buf, L"", L"", SW_SHOW); } diff --git a/plugins/Ping/src/menu.cpp b/plugins/Ping/src/menu.cpp index 3f2a0bd198..b3f286a246 100644 --- a/plugins/Ping/src/menu.cpp +++ b/plugins/Ping/src/menu.cpp @@ -15,13 +15,13 @@ void InitMenus() mi.position = 2000060000; mi.hIcolibItem = hIconResponding; mi.name.w = LPGENW("Enable all pings"); - mi.pszService = PLUG "/EnableAll"; + mi.pszService = MODULENAME "/EnableAll"; Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x1dac6ea6, 0x116e, 0x41a3, 0xa6, 0xe8, 0x42, 0xdf, 0xf7, 0x27, 0xc4, 0x7c); mi.position = 2000060001; mi.hIcolibItem = hIconDisabled; mi.name.w = LPGENW("Disable all pings"); - mi.pszService = PLUG "/DisableAll"; + mi.pszService = MODULENAME "/DisableAll"; Menu_AddMainMenuItem(&mi); } diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp index e1c880cd87..5be6572852 100644 --- a/plugins/Ping/src/options.cpp +++ b/plugins/Ping/src/options.cpp @@ -77,7 +77,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_BTN_VIEWLOG: - CallService(PLUG "/ViewLogData", 0, 0); + CallService(MODULENAME "/ViewLogData", 0, 0); break; case IDC_BTN_LOGBROWSE: { @@ -150,7 +150,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA RefreshWindow(0, 0); - if (options.logging) CallService(PLUG "/Log", (WPARAM)L"options changed", 0); + if (options.logging) CallService(MODULENAME "/Log", (WPARAM)L"options changed", 0); if (hWakeEvent) SetEvent(hWakeEvent); return TRUE; } @@ -482,8 +482,8 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { - CallService(PLUG "/SetAndSavePingList", (WPARAM)&temp_list, 0); - CallService(PLUG "/GetPingList", 0, (LPARAM)&temp_list); + CallService(MODULENAME "/SetAndSavePingList", (WPARAM)&temp_list, 0); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&temp_list); // the following will be affected due to list rebuild event //if(hWakeEvent) SetEvent(hWakeEvent); return TRUE; @@ -515,50 +515,50 @@ int PingOptInit(WPARAM wParam, LPARAM) } void LoadOptions() { - options.ping_period = db_get_dw(NULL, PLUG, "PingPeriod", DEFAULT_PING_PERIOD); + options.ping_period = db_get_dw(NULL, MODULENAME, "PingPeriod", DEFAULT_PING_PERIOD); - options.ping_timeout = db_get_dw(NULL, PLUG, "PingTimeout", DEFAULT_PING_TIMEOUT); - CallService(PLUG "/SetPingTimeout", (WPARAM)options.ping_timeout, 0); - options.show_popup = (db_get_b(NULL, PLUG, "ShowPopup", DEFAULT_SHOW_POPUP ? 1 : 0) == 1); - options.show_popup2 = (db_get_b(NULL, PLUG, "ShowPopup2", DEFAULT_SHOW_POPUP2 ? 1 : 0) == 1); - options.block_reps = (db_get_b(NULL, PLUG, "BlockReps", DEFAULT_BLOCK_REPS ? 1 : 0) == 1); - options.logging = (db_get_b(NULL, PLUG, "LoggingEnabled", DEFAULT_LOGGING_ENABLED ? 1 : 0) == 1); + options.ping_timeout = db_get_dw(NULL, MODULENAME, "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.no_test_icon = (db_get_b(NULL, PLUG, "NoTestStatus", DEFAULT_NO_TEST_ICON ? 1 : 0) == 1); + options.no_test_icon = (db_get_b(NULL, MODULENAME, "NoTestStatus", DEFAULT_NO_TEST_ICON ? 1 : 0) == 1); - options.indent = db_get_w(NULL, PLUG, "Indent", 0); - options.row_height = db_get_w(NULL, PLUG, "RowHeight", GetSystemMetrics(SM_CYSMICON)); + options.indent = db_get_w(NULL, MODULENAME, "Indent", 0); + options.row_height = db_get_w(NULL, MODULENAME, "RowHeight", GetSystemMetrics(SM_CYSMICON)); - options.retries = db_get_dw(NULL, PLUG, "Retries", 0); + options.retries = db_get_dw(NULL, MODULENAME, "Retries", 0); - CallService(PLUG "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename); + 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, PLUG, "AttachToClist", DEFAULT_ATTACH_TO_CLIST ? 1 : 0) == 1); - options.log_csv = (db_get_b(NULL, PLUG, "LogCSV", 0) == 1); + 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); } void SaveOptions() { - db_set_dw(NULL, PLUG, "PingPeriod", options.ping_period); - db_set_dw(NULL, PLUG, "PingTimeout", options.ping_timeout); - CallService(PLUG "/SetPingTimeout", (WPARAM)options.ping_timeout, 0); - db_set_b(NULL, PLUG, "ShowPopup", options.show_popup ? 1 : 0); - db_set_b(NULL, PLUG, "ShowPopup2", options.show_popup2 ? 1 : 0); - db_set_b(NULL, PLUG, "BlockReps", options.block_reps ? 1 : 0); - db_set_b(NULL, PLUG, "LoggingEnabled", options.logging ? 1 : 0); + db_set_dw(NULL, MODULENAME, "PingPeriod", options.ping_period); + db_set_dw(NULL, MODULENAME, "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); - db_set_b(NULL, PLUG, "NoTestStatus", options.no_test_icon ? 1 : 0); + db_set_b(NULL, MODULENAME, "NoTestStatus", options.no_test_icon ? 1 : 0); - db_set_w(NULL, PLUG, "Indent", options.indent); - db_set_w(NULL, PLUG, "RowHeight", options.row_height); + db_set_w(NULL, MODULENAME, "Indent", options.indent); + db_set_w(NULL, MODULENAME, "RowHeight", options.row_height); - db_set_dw(NULL, PLUG, "Retries", (DWORD)options.retries); + db_set_dw(NULL, MODULENAME, "Retries", (DWORD)options.retries); - CallService(PLUG "/SetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename); + CallService(MODULENAME "/SetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename); ICMP::get_instance()->set_timeout(options.ping_timeout * 1000); - db_set_b(NULL, PLUG, "AttachToClist", options.attach_to_clist ? 1 : 0); - db_set_b(NULL, PLUG, "LogCSV", options.log_csv ? 1 : 0); + db_set_b(NULL, MODULENAME, "AttachToClist", options.attach_to_clist ? 1 : 0); + db_set_b(NULL, MODULENAME, "LogCSV", options.log_csv ? 1 : 0); } diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp index 01d99dedd4..cc40dbce37 100644 --- a/plugins/Ping/src/ping.cpp +++ b/plugins/Ping/src/ping.cpp @@ -11,7 +11,7 @@ bool use_raw_ping = true; ///////////////////////////////////////////////////////////////////////////////////////// -PLUGININFOEX pluginInfo = +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -25,9 +25,13 @@ PLUGININFOEX pluginInfo = { 0x760ea901, 0xc0c2, 0x446c, { 0x80, 0x29, 0x94, 0xc3, 0xbc, 0x47, 0xc4, 0x5e } } }; +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - return &pluginInfo; + return &pluginInfoEx; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -35,31 +39,31 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) static void CreatePluginServices() { // general - CreateServiceFunction(PLUG "/Ping", PluginPing); - CreateServiceFunction(PLUG "/DblClick", DblClick); + CreateServiceFunction(MODULENAME "/Ping", PluginPing); + CreateServiceFunction(MODULENAME "/DblClick", DblClick); // list - CreateServiceFunction(PLUG "/ClearPingList", ClearPingList); - CreateServiceFunction(PLUG "/GetPingList", GetPingList); - CreateServiceFunction(PLUG "/SetPingList", SetPingList); - CreateServiceFunction(PLUG "/SetAndSavePingList", SetAndSavePingList); - CreateServiceFunction(PLUG "/LoadPingList", LoadPingList); - CreateServiceFunction(PLUG "/SavePingList", SavePingList); + CreateServiceFunction(MODULENAME "/ClearPingList", ClearPingList); + CreateServiceFunction(MODULENAME "/GetPingList", GetPingList); + CreateServiceFunction(MODULENAME "/SetPingList", SetPingList); + CreateServiceFunction(MODULENAME "/SetAndSavePingList", SetAndSavePingList); + CreateServiceFunction(MODULENAME "/LoadPingList", LoadPingList); + CreateServiceFunction(MODULENAME "/SavePingList", SavePingList); - reload_event_handle = CreateHookableEvent(PLUG "/ListReload"); + reload_event_handle = CreateHookableEvent(MODULENAME "/ListReload"); //log - CreateServiceFunction(PLUG "/Log", Log); - CreateServiceFunction(PLUG "/ViewLogData", ViewLogData); - CreateServiceFunction(PLUG "/GetLogFilename", GetLogFilename); - CreateServiceFunction(PLUG "/SetLogFilename", SetLogFilename); + CreateServiceFunction(MODULENAME "/Log", Log); + CreateServiceFunction(MODULENAME "/ViewLogData", ViewLogData); + CreateServiceFunction(MODULENAME "/GetLogFilename", GetLogFilename); + CreateServiceFunction(MODULENAME "/SetLogFilename", SetLogFilename); // menu - CreateServiceFunction(PLUG "/DisableAll", PingDisableAll); - CreateServiceFunction(PLUG "/EnableAll", PingEnableAll); - CreateServiceFunction(PLUG "/ToggleEnabled", ToggleEnabled); - CreateServiceFunction(PLUG "/ShowGraph", ShowGraph); - CreateServiceFunction(PLUG "/Edit", EditContact); + CreateServiceFunction(MODULENAME "/DisableAll", PingDisableAll); + CreateServiceFunction(MODULENAME "/EnableAll", PingEnableAll); + CreateServiceFunction(MODULENAME "/ToggleEnabled", ToggleEnabled); + CreateServiceFunction(MODULENAME "/ShowGraph", ShowGraph); + CreateServiceFunction(MODULENAME "/Edit", EditContact); } @@ -82,7 +86,7 @@ static int OnShutdown(WPARAM, LPARAM) static int OnModulesLoaded(WPARAM, LPARAM) { NETLIBUSER nl_user = {}; - nl_user.szSettingsModule = PLUG; + nl_user.szSettingsModule = MODULENAME; nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; nl_user.szDescriptiveName.w = TranslateT("Ping Plugin"); hNetlibUser = Netlib_RegisterUser(&nl_user); @@ -90,23 +94,23 @@ static int OnModulesLoaded(WPARAM, LPARAM) InitUtils(); InitMenus(); - hFillListEvent = HookEvent(PLUG "/ListReload", FillList); + hFillListEvent = HookEvent(MODULENAME "/ListReload", FillList); - if (!db_get_b(0, PLUG, "PingPlugImport", 0)) { + if (!db_get_b(0, MODULENAME, "PingPlugImport", 0)) { if (db_get_dw(0, "PingPlug", "NumEntries", 0)) { import_ping_addresses(); - db_set_b(0, PLUG, "PingPlugImport", 1); + db_set_b(0, MODULENAME, "PingPlugImport", 1); } } InitList(); - CallService(PLUG "/LoadPingList", 0, 0); + CallService(MODULENAME "/LoadPingList", 0, 0); graphs_init(); if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"start", 0); + CallService(MODULENAME "/Log", (WPARAM)L"start", 0); return 0; } @@ -121,11 +125,11 @@ static IconItem iconList[] = extern "C" __declspec(dllexport) int Load(void) { - mir_getLP(&pluginInfo); + mir_getLP(&pluginInfoEx); pcli = Clist_GetInterface(); use_raw_ping = false; - db_set_b(0, PLUG, "UsingRawSockets", (BYTE)use_raw_ping); + db_set_b(0, MODULENAME, "UsingRawSockets", (BYTE)use_raw_ping); DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0); hWakeEvent = CreateEvent(nullptr, FALSE, FALSE, L"Local\\ThreadWaitEvent"); @@ -156,7 +160,7 @@ extern "C" __declspec(dllexport) int Unload(void) CloseHandle(mainThread); if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"stop", 0); + CallService(MODULENAME "/Log", (WPARAM)L"stop", 0); return 0; } diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp index b9efbc01e8..254e175eb2 100644 --- a/plugins/Ping/src/pinggraph.cpp +++ b/plugins/Ping/src/pinggraph.cpp @@ -232,7 +232,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { char buff[30]; mir_snprintf(buff, "pinggraphwnd%d", wd->item_id); - Utils_SaveWindowPosition(hwnd, 0, PLUG, buff); + Utils_SaveWindowPosition(hwnd, 0, MODULENAME, buff); } } break; @@ -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, PLUG, buff, 0); + db_set_dw(0, MODULENAME, 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, PLUG, buff, 0); + HWND hGraphWnd = (HWND)db_get_dw(0, MODULENAME, buff, 0); if (hGraphWnd) { ShowWindow(hGraphWnd, SW_SHOW); SetWindowPos(hGraphWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); @@ -272,7 +272,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) { wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); wndclass.lpszMenuName = nullptr; - wndclass.lpszClassName = _A2W(PLUG) L"GraphWindow"; + wndclass.lpszClassName = _A2W(MODULENAME) L"GraphWindow"; RegisterClass(&wndclass); wchar_t title[256]; @@ -283,7 +283,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) { } HWND parent = nullptr; - hGraphWnd = CreateWindowEx(0, _A2W(PLUG) L"GraphWindow", title, + hGraphWnd = CreateWindowEx(0, _A2W(MODULENAME) L"GraphWindow", title, (WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN) & ~CS_VREDRAW & ~CS_HREDRAW, 0, 0, 800, 600, parent, nullptr, g_plugin.getInst(), nullptr); @@ -291,15 +291,15 @@ 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, PLUG, "ShowGridLines", 0) ? true : false; - wd->show_stat = db_get_b(0, PLUG, "ShowStats", 1) ? true : false; + wd->show_grid = db_get_b(0, MODULENAME, "ShowGridLines", 0) ? true : false; + wd->show_stat = db_get_b(0, MODULENAME, "ShowStats", 1) ? true : false; - db_set_dw(0, PLUG, buff, (UINT_PTR)hGraphWnd); + db_set_dw(0, MODULENAME, buff, (UINT_PTR)hGraphWnd); SetWindowLongPtr(hGraphWnd, GWLP_USERDATA, (LONG_PTR)wd); mir_snprintf(buff, "pinggraphwnd%d", wd->item_id); - Utils_RestoreWindowPosition(hGraphWnd, 0, PLUG, buff); + Utils_RestoreWindowPosition(hGraphWnd, 0, MODULENAME, buff); if (!IsWindowVisible(hGraphWnd)) ShowWindow(hGraphWnd, SW_SHOW); @@ -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, PLUG, buff, 0)) { + if (hwnd = (HWND)db_get_dw(0, MODULENAME, buff, 0)) { DestroyWindow(hwnd); - db_set_dw(0, PLUG, buff, 0); + db_set_dw(0, MODULENAME, buff, 0); mir_snprintf(buff, "WindowWasOpen%d", i); - db_set_b(0, PLUG, buff, 1); + db_set_b(0, MODULENAME, buff, 1); } } } @@ -328,13 +328,13 @@ void graphs_cleanup() { void graphs_init() { PINGLIST pl; char buff[64]; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + 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, PLUG, buff, 0); + db_set_dw(0, MODULENAME, buff, 0); mir_snprintf(buff, "WindowWasOpen%d", i->item_id); // restore windows that were open on shutdown - if (db_get_b(0, PLUG, buff, 0)) { - db_set_b(0, PLUG, buff, 0); + if (db_get_b(0, MODULENAME, buff, 0)) { + db_set_b(0, MODULENAME, 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 92e094e74b..d0edc89823 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, PLUG, "NextID", NextID); + db_set_dw(0, MODULENAME, "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, PLUG, "NextID", NextID); + db_set_dw(0, MODULENAME, "NextID", NextID); } return true; diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index 077dfa855b..7551747378 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -66,7 +66,7 @@ void SetProtoStatus(wchar_t *pszLabel, char *pszProto, int if_status, int new_st if (options.logging) { wchar_t buf[1024]; mir_snwprintf(buf, TranslateT("%s - setting status of protocol '%S' (%d)"), pszLabel, pszProto, new_status); - CallService(PLUG "/Log", (WPARAM)buf, 0); + CallService(MODULENAME "/Log", (WPARAM)buf, 0); } CallProtoService(pszProto, PS_SETSTATUS, new_status, 0); } @@ -135,7 +135,7 @@ void __cdecl sttCheckStatusThreadProc(void*) InvalidateRect(list_hwnd, nullptr, FALSE); } - CallService(PLUG "/Ping", 0, (LPARAM)&pa); + CallService(MODULENAME "/Ping", 0, (LPARAM)&pa); if (get_thread_finished()) break; if (get_list_changed()) break; @@ -190,7 +190,7 @@ void __cdecl sttCheckStatusThreadProc(void*) if (pa.miss_count == -1 - options.retries && options.logging) { wchar_t buf[512]; mir_snwprintf(buf, TranslateT("%s - reply, %d"), pa.pszLabel, pa.round_trip_time); - CallService(PLUG "/Log", (WPARAM)buf, 0); + CallService(MODULENAME "/Log", (WPARAM)buf, 0); } SetProtoStatus(pa.pszLabel, pa.pszProto, pa.get_status, pa.set_status); } @@ -204,7 +204,7 @@ void __cdecl sttCheckStatusThreadProc(void*) if (pa.miss_count == 1 + options.retries && options.logging) { wchar_t buf[512]; mir_snwprintf(buf, TranslateT("%s - timeout"), pa.pszLabel); - CallService(PLUG "/Log", (WPARAM)buf, 0); + CallService(MODULENAME "/Log", (WPARAM)buf, 0); } } @@ -253,10 +253,10 @@ int FillList(WPARAM, LPARAM) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"ping address list reload", 0); + CallService(MODULENAME "/Log", (WPARAM)L"ping address list reload", 0); PINGLIST pl; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); SendMessage(list_hwnd, WM_SETREDRAW, FALSE, 0); { @@ -369,7 +369,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, PLUG, "FontCol", GetSysColor(COLOR_WINDOWTEXT)); + tcol = db_get_dw(NULL, MODULENAME, "FontCol", GetSysColor(COLOR_WINDOWTEXT)); SetTextColor(dis->hDC, tcol); } @@ -615,7 +615,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } } if (found) - CallService(PLUG "/ShowGraph", (WPARAM)itemData.item_id, (LPARAM)itemData.pszLabel); + CallService(MODULENAME "/ShowGraph", (WPARAM)itemData.item_id, (LPARAM)itemData.pszLabel); } } return TRUE; @@ -631,7 +631,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mir_cslock lck(data_list_cs); if (count >= 0 && count < (int)data_list.size()) { PINGADDRESS itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0); - CallService(PLUG "/ToggleEnabled", (WPARAM)itemData.item_id, 0); + CallService(MODULENAME "/ToggleEnabled", (WPARAM)itemData.item_id, 0); } } } @@ -656,7 +656,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (Edit(hwnd, itemData)) { mir_cslock lck(data_list_cs); *temp = itemData; - CallService(PLUG "/SetAndSavePingList", (WPARAM)&data_list, 0); + CallService(MODULENAME "/SetAndSavePingList", (WPARAM)&data_list, 0); } } } @@ -664,11 +664,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return TRUE; case ID_MENU_DISABLEALLPINGS: - CallService(PLUG "/DisableAll", 0, 0); + CallService(MODULENAME "/DisableAll", 0, 0); return TRUE; case ID_MENU_ENABLEALLPINGS: - CallService(PLUG "/EnableAll", 0, 0); + CallService(MODULENAME "/EnableAll", 0, 0); return TRUE; case ID_MENU_OPTIONS: @@ -691,14 +691,14 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (pItemData) { DWORD item_id = pItemData->item_id; - int wake = CallService(PLUG "/DblClick", (WPARAM)item_id, 0); + int wake = CallService(MODULENAME "/DblClick", (WPARAM)item_id, 0); InvalidateRect(list_hwnd, nullptr, FALSE); if (wake) SetEvent(hWakeEvent); if (options.logging) { wchar_t buf[1024]; mir_snwprintf(buf, L"%s - %s", pItemData->pszLabel, (wake ? TranslateT("enabled") : TranslateT("double clicked"))); - CallService(PLUG "/Log", (WPARAM)buf, 0); + CallService(MODULENAME "/Log", (WPARAM)buf, 0); } } } @@ -730,7 +730,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_DESTROY: if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - Utils_SaveWindowPosition(hwnd, 0, PLUG, "main_window"); + Utils_SaveWindowPosition(hwnd, 0, MODULENAME, "main_window"); } KillTimer(hwnd, TIMER_ID); @@ -742,7 +742,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_CLOSE: if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - Utils_SaveWindowPosition(hwnd, 0, PLUG, "main_window"); + Utils_SaveWindowPosition(hwnd, 0, MODULENAME, "main_window"); ShowWindow(hwnd, SW_HIDE); return 0; } @@ -855,14 +855,14 @@ void InitList() wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); wndclass.lpszMenuName = nullptr; - wndclass.lpszClassName = _A2W(PLUG) L"WindowClass"; + wndclass.lpszClassName = _A2W(MODULENAME) L"WindowClass"; RegisterClass(&wndclass); if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - hpwnd = CreateWindow(_A2W(PLUG) L"WindowClass", L"Ping", (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN), 0, 0, 0, 0, hwnd_clist, nullptr, g_plugin.getInst(), nullptr); + hpwnd = CreateWindow(_A2W(MODULENAME) L"WindowClass", L"Ping", (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN), 0, 0, 0, 0, hwnd_clist, nullptr, g_plugin.getInst(), nullptr); CLISTFrame frame = { 0 }; - frame.name = PLUG; + frame.name = MODULENAME; frame.cbSize = sizeof(CLISTFrame); frame.hWnd = hpwnd; frame.align = alBottom; @@ -873,13 +873,13 @@ void InitList() frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&frame, 0); } else { - hpwnd = CreateWindowEx(WS_EX_TOOLWINDOW, _A2W(PLUG) L"WindowClass", L"Ping", + hpwnd = CreateWindowEx(WS_EX_TOOLWINDOW, _A2W(MODULENAME) L"WindowClass", L"Ping", (WS_POPUPWINDOW | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN), 0, 0, 400, 300, hwnd_clist, nullptr, g_plugin.getInst(), nullptr); - Utils_RestoreWindowPosition(hpwnd, 0, PLUG, "main_window"); + Utils_RestoreWindowPosition(hpwnd, 0, MODULENAME, "main_window"); - CreateServiceFunction(PLUG "/ShowWindow", PingPlugShowWindow); + CreateServiceFunction(MODULENAME "/ShowWindow", PingPlugShowWindow); CMenuItem mi; mi.root = Menu_CreateRoot(MO_MAIN, LPGENW("Ping"), 1000200001); @@ -889,7 +889,7 @@ void InitList() mi.flags = CMIF_UNICODE; mi.position = 3000320001; mi.name.w = LPGENW("Show/Hide &Ping Window"); - mi.pszService = PLUG "/ShowWindow"; + mi.pszService = MODULENAME "/ShowWindow"; Menu_AddMainMenuItem(&mi); if (options.attach_to_clist) AttachToClist(true); diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp index c5b2c0c2e8..7e66a7450e 100644 --- a/plugins/Ping/src/rawping.cpp +++ b/plugins/Ping/src/rawping.cpp @@ -95,7 +95,7 @@ extern int raw_ping(char *host, int timeout) } else { // Not a recognized hostname either! - if (options.logging) CallService(PLUG "/Log", (WPARAM)L"rawping error: unrecognised host", 0); + if (options.logging) CallService(MODULENAME "/Log", (WPARAM)L"rawping error: unrecognised host", 0); return -1; } } @@ -119,7 +119,7 @@ extern int raw_ping(char *host, int timeout) // send packet int bwrote = sendto(sd, (char*)packet, sizeof(ICMPHeader), 0, (sockaddr*)&dest, sizeof(dest)); if (bwrote == SOCKET_ERROR) { - if (options.logging) CallService(PLUG "/Log", (WPARAM)L"rawping error: unable to send", 0); + if (options.logging) CallService(MODULENAME "/Log", (WPARAM)L"rawping error: unable to send", 0); return -1; } @@ -151,39 +151,39 @@ extern int raw_ping(char *host, int timeout) if (bread == SOCKET_ERROR) { if (WSAGetLastError() != WSAETIMEDOUT) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: socket error...cycling", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: socket error...cycling", 0); } continue; } if (reply_header->proto != ICMP_PROTO) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: packet not ICMP...cycling", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: packet not ICMP...cycling", 0); continue; } if (reply_header->tos != 0) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: TOS not 0...cycling", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: TOS not 0...cycling", 0); continue; } reply = (ICMPHeader *)(recv_buff + reply_header->h_len * 4); if ((unsigned)bread < reply_header->h_len * 4 + sizeof(ICMPHeader)) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: short header", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: short header", 0); continue; } if (reply->id != (USHORT)GetCurrentProcessId()) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: wrong ID...cycling", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: wrong ID...cycling", 0); continue; } if (reply->type != PT_ICMP_ECHO_REPLY && reply->type != PT_ICMP_SOURCE_QUENCH) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: wrong type...cycling", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: wrong type...cycling", 0); continue; } @@ -191,14 +191,14 @@ extern int raw_ping(char *host, int timeout) //if(reply->seq > seq_no) return -1; if (reply->seq != seq_no) { if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: wrong sequence number...cycling", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: wrong sequence number...cycling", 0); continue; } if (reply->type == PT_ICMP_SOURCE_QUENCH) { char buff[1024]; mir_snprintf(buff, Translate("Host %s requests that you reduce the amount of traffic you are sending."), host); - MessageBoxA(nullptr, buff, Translate(PLUG " Warning"), MB_OK | MB_ICONWARNING); + MessageBoxA(nullptr, buff, Translate(MODULENAME " Warning"), MB_OK | MB_ICONWARNING); } if (use_hi_res) { @@ -210,7 +210,7 @@ extern int raw_ping(char *host, int timeout) return current_time - send_time; } if (options.logging) - CallService(PLUG "/Log", (WPARAM)L"rawping error: timeout", 0); + CallService(MODULENAME "/Log", (WPARAM)L"rawping error: timeout", 0); return -1; } diff --git a/plugins/Ping/src/stdafx.h b/plugins/Ping/src/stdafx.h index 3e1c99c68f..d2abecce00 100644 --- a/plugins/Ping/src/stdafx.h +++ b/plugins/Ping/src/stdafx.h @@ -40,7 +40,7 @@ #define MAX_HISTORY (1440) // 12 hrs at 30 sec intervals -#define PLUG "PING" +#define MODULENAME "PING" #define DEFAULT_PING_PERIOD 30 #define DEFAULT_PING_TIMEOUT 2 @@ -56,9 +56,7 @@ struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(PLUG) - {} + CMPlugin(); }; typedef struct { diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp index 59e0c6b5fd..9e4361538e 100644 --- a/plugins/Ping/src/utils.cpp +++ b/plugins/Ping/src/utils.cpp @@ -51,7 +51,7 @@ void __stdcall ShowPopup(wchar_t *line1, wchar_t *line2, int flags) QueueUserAPC(sttMainThreadCallback, mainThread, (ULONG_PTR)ppd); } else{ - MessageBox(nullptr, line2, _A2W(PLUG) L" Message", MB_OK | MB_ICONINFORMATION); + MessageBox(nullptr, line2, _A2W(MODULENAME) L" Message", MB_OK | MB_ICONINFORMATION); return; } } @@ -136,24 +136,24 @@ INT_PTR PluginPing(WPARAM, LPARAM lParam) INT_PTR PingDisableAll(WPARAM, LPARAM) { PINGLIST pl; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); for (pinglist_it i = pl.begin(); i != pl.end(); ++i) { i->status = PS_DISABLED; i->miss_count = 0; } - CallService(PLUG "/SetPingList", (WPARAM)&pl, 0); + CallService(MODULENAME "/SetPingList", (WPARAM)&pl, 0); return 0; } INT_PTR PingEnableAll(WPARAM, LPARAM) { PINGLIST pl; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); for (pinglist_it i = pl.begin(); i != pl.end(); ++i) { if (i->status == PS_DISABLED) { i->status = PS_NOTRESPONDING; } } - CallService(PLUG "/SetPingList", (WPARAM)&pl, 0); + CallService(MODULENAME "/SetPingList", (WPARAM)&pl, 0); return 0; } @@ -161,7 +161,7 @@ INT_PTR PingEnableAll(WPARAM, LPARAM) { INT_PTR ToggleEnabled(WPARAM wParam, LPARAM) { int retval = 0; PINGLIST pl; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); for (pinglist_it i = pl.begin(); i != pl.end(); ++i) { if (i->item_id == (DWORD)wParam) { @@ -174,7 +174,7 @@ INT_PTR ToggleEnabled(WPARAM wParam, LPARAM) { } } } - CallService(PLUG "/SetPingList", (WPARAM)&pl, 0); + CallService(MODULENAME "/SetPingList", (WPARAM)&pl, 0); return 0; } @@ -183,7 +183,7 @@ INT_PTR EditContact(WPARAM wParam, LPARAM) PINGLIST pl; HWND hwndList = pcli->hwndContactList; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); for (pinglist_it i = pl.begin(); i != pl.end(); ++i) { if (i->item_id == (DWORD)wParam) { @@ -192,7 +192,7 @@ INT_PTR EditContact(WPARAM wParam, LPARAM) if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) { *i = add_edit_addr; - CallService(PLUG "/SetAndSavePingList", (WPARAM)&pl, 0); + CallService(MODULENAME "/SetAndSavePingList", (WPARAM)&pl, 0); return 0; } } @@ -202,14 +202,14 @@ INT_PTR EditContact(WPARAM wParam, LPARAM) INT_PTR DblClick(WPARAM wParam, LPARAM) { PINGLIST pl; - CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); + CallService(MODULENAME "/GetPingList", 0, (LPARAM)&pl); for (pinglist_it i = pl.begin(); i != pl.end(); ++i) { if (i->item_id == (DWORD)wParam) { if (mir_wstrlen(i->pszCommand)) { ShellExecute(nullptr, L"open", i->pszCommand, i->pszParams, nullptr, SW_SHOW); } else { - return CallService(PLUG "/ToggleEnabled", wParam, 0); + return CallService(MODULENAME "/ToggleEnabled", wParam, 0); } } } -- cgit v1.2.3