summaryrefslogtreecommitdiff
path: root/plugins/Ping
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-17 20:53:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-17 20:53:02 +0300
commit067a48827e8bae1bc595f3268e18996314843396 (patch)
treed51ae1287c40f08f291f5578b2dccf69f902cc97 /plugins/Ping
parent7639f72273189df60566755c0d5f1e4ab7201b67 (diff)
OpenFolder, PackUpdater, PasteIt, Ping, QuickMessages, QuickReplies, Sessions, TranslitSwitcher => CMPlugin
Diffstat (limited to 'plugins/Ping')
-rw-r--r--plugins/Ping/src/options.cpp6
-rw-r--r--plugins/Ping/src/ping.cpp39
-rw-r--r--plugins/Ping/src/pinggraph.cpp8
-rw-r--r--plugins/Ping/src/pingthread.cpp10
-rw-r--r--plugins/Ping/src/stdafx.h10
-rw-r--r--plugins/Ping/src/utils.cpp2
6 files changed, 38 insertions, 37 deletions
diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp
index 3909b2ce6c..e1c880cd87 100644
--- a/plugins/Ping/src/options.cpp
+++ b/plugins/Ping/src/options.cpp
@@ -276,7 +276,7 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
bool Edit(HWND hwnd, PINGADDRESS &addr)
{
add_edit_addr = addr;
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK)
+ if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK)
{
addr = add_edit_addr;
return true;
@@ -360,7 +360,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
add_edit_addr.item_id = 0;
add_edit_addr.index = (int)temp_list.size();
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
+ if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
{
temp_list.push_back(add_edit_addr);
@@ -497,7 +497,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int PingOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szGroup.w = LPGENW("Network");
odp.szTitle.w = LPGENW("Ping");
diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp
index 42112e98bc..1e9a7de001 100644
--- a/plugins/Ping/src/ping.cpp
+++ b/plugins/Ping/src/ping.cpp
@@ -1,7 +1,7 @@
#include "stdafx.h"
CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
+CMPlugin g_plugin;
int hLangpack = 0;
HNETLIBUSER hNetlibUser = nullptr;
@@ -9,8 +9,10 @@ HANDLE hFillListEvent = nullptr;
bool use_raw_ping = true;
-// plugin stuff
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -23,18 +25,14 @@ PLUGININFOEX pluginInfo = {
{ 0x760ea901, 0xc0c2, 0x446c, { 0x80, 0x29, 0x94, 0xc3, 0xbc, 0x47, 0xc4, 0x5e } }
};
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
-void CreatePluginServices()
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void CreatePluginServices()
{
// general
CreateServiceFunction(PLUG "/Ping", PluginPing);
@@ -65,7 +63,8 @@ void CreatePluginServices()
}
-int OnShutdown(WPARAM, LPARAM) {
+static int OnShutdown(WPARAM, LPARAM)
+{
graphs_cleanup();
UnhookEvent(hFillListEvent);
@@ -80,17 +79,15 @@ int OnShutdown(WPARAM, LPARAM) {
return 0;
}
-int OnModulesLoaded(WPARAM, LPARAM)
+static int OnModulesLoaded(WPARAM, LPARAM)
{
NETLIBUSER nl_user = {};
nl_user.szSettingsModule = PLUG;
nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nl_user.szDescriptiveName.w = TranslateT("Ping Plugin");
-
hNetlibUser = Netlib_RegisterUser(&nl_user);
InitUtils();
-
InitMenus();
hFillListEvent = HookEvent(PLUG "/ListReload", FillList);
@@ -108,7 +105,8 @@ int OnModulesLoaded(WPARAM, LPARAM)
graphs_init();
- if (options.logging) CallService(PLUG "/Log", (WPARAM)L"start", 0);
+ if (options.logging)
+ CallService(PLUG "/Log", (WPARAM)L"start", 0);
return 0;
}
@@ -141,25 +139,24 @@ extern "C" __declspec(dllexport) int Load(void)
Skin_AddSound("PingReply", LPGENW("Ping"), LPGENW("Reply"));
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
-
HookEvent(ME_OPT_INITIALISE, PingOptInit);
-
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
-
- Icon_Register(hInst, LPGEN("Ping"), iconList, _countof(iconList));
-
HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
+ Icon_Register(g_plugin.getInst(), LPGEN("Ping"), iconList, _countof(iconList));
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
SavePingList(0, 0);
CloseHandle(mainThread);
- if (options.logging) CallService(PLUG "/Log", (WPARAM)L"stop", 0);
+ if (options.logging)
+ CallService(PLUG "/Log", (WPARAM)L"stop", 0);
return 0;
}
diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp
index 554c740c61..b9efbc01e8 100644
--- a/plugins/Ping/src/pinggraph.cpp
+++ b/plugins/Ping/src/pinggraph.cpp
@@ -45,11 +45,11 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
WindowData *wd = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (wd->hwnd_chk_grid == nullptr) {
- wd->hwnd_chk_grid = CreateWindow(L"BUTTON", TranslateT("Show grid lines"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr);
+ wd->hwnd_chk_grid = CreateWindow(L"BUTTON", TranslateT("Show grid lines"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr);
SendMessage(wd->hwnd_chk_grid, BM_SETCHECK, wd->show_grid ? BST_CHECKED : BST_UNCHECKED, 0);
}
if (wd->hwnd_chk_stat == nullptr) {
- wd->hwnd_chk_stat = CreateWindow(L"BUTTON", TranslateT("Show stats"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr);
+ wd->hwnd_chk_stat = CreateWindow(L"BUTTON", TranslateT("Show stats"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr);
SendMessage(wd->hwnd_chk_stat, BM_SETCHECK, wd->show_stat ? BST_CHECKED : BST_UNCHECKED, 0);
}
KillTimer(hwnd, ID_REPAINT_TIMER);
@@ -267,7 +267,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) {
wndclass.lpfnWndProc = GraphWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = hIconResponding;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
@@ -285,7 +285,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) {
HWND parent = nullptr;
hGraphWnd = CreateWindowEx(0, _A2W(PLUG) L"GraphWindow", title,
(WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN) & ~CS_VREDRAW & ~CS_HREDRAW,
- 0, 0, 800, 600, parent, nullptr, hInst, nullptr);
+ 0, 0, 800, 600, parent, nullptr, g_plugin.getInst(), nullptr);
WindowData *wd = new WindowData;
wd->item_id = (DWORD)wParam; // wParam is destination id
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index 6bac84f199..077dfa855b 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -418,7 +418,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
context_point = lParam;
context_point_valid = true;
InvalidateRect(list_hwnd, nullptr, FALSE);
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)),
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1)),
submenu = GetSubMenu(menu, 0);
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
@@ -474,7 +474,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
list_hwnd = CreateWindow(L"LISTBOX", L"",
//(WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT| LBS_STANDARD | WS_CLIPCHILDREN | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY)
(WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY)
- & ~WS_BORDER, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr);
+ & ~WS_BORDER, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr);
if (db_get_b(NULL, "CList", "Transparent", 0)) {
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
@@ -850,7 +850,7 @@ void InitList()
wndclass.lpfnWndProc = FrameWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = hIconResponding;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
@@ -859,7 +859,7 @@ void InitList()
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, hInst, nullptr);
+ 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);
CLISTFrame frame = { 0 };
frame.name = PLUG;
@@ -875,7 +875,7 @@ void InitList()
else {
hpwnd = CreateWindowEx(WS_EX_TOOLWINDOW, _A2W(PLUG) L"WindowClass", L"Ping",
(WS_POPUPWINDOW | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN),
- 0, 0, 400, 300, hwnd_clist, nullptr, hInst, nullptr);
+ 0, 0, 400, 300, hwnd_clist, nullptr, g_plugin.getInst(), nullptr);
Utils_RestoreWindowPosition(hpwnd, 0, PLUG, "main_window");
diff --git a/plugins/Ping/src/stdafx.h b/plugins/Ping/src/stdafx.h
index 14049e295f..3e1c99c68f 100644
--- a/plugins/Ping/src/stdafx.h
+++ b/plugins/Ping/src/stdafx.h
@@ -12,7 +12,6 @@
#include <Icmpapi.h>
#include <list>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_options.h>
#include <m_langpack.h>
@@ -55,6 +54,12 @@
#define MAX_PINGADDRESS_STRING_LENGTH 256
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PLUG)
+ {}
+};
typedef struct {
int ping_period, ping_timeout;
@@ -105,13 +110,12 @@ struct PINGADDRESS {
};
#include "options.h"
+
typedef Map<DWORD, HistoryList> HistoryMap;
typedef std::list<PINGADDRESS> PINGLIST;
typedef std::list<PINGADDRESS>::iterator pinglist_it;
-
extern HNETLIBUSER hNetlibUser;
-extern HINSTANCE hInst;
extern bool use_raw_ping;
diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp
index cf900a3ffa..59e0c6b5fd 100644
--- a/plugins/Ping/src/utils.cpp
+++ b/plugins/Ping/src/utils.cpp
@@ -189,7 +189,7 @@ INT_PTR EditContact(WPARAM wParam, LPARAM)
add_edit_addr = *i;
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) {
+ if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) {
*i = add_edit_addr;
CallService(PLUG "/SetAndSavePingList", (WPARAM)&pl, 0);