summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-31 05:07:21 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-31 05:07:21 +0000
commit0ff1d601dfadfd19e286c021fd1288e8b8b4b7c2 (patch)
treeaafe89e4f6870ad528f00e081d31432cdfbb8d32
parent87a314a0f8b3aa138601963c0e98d339997b9d6e (diff)
use yapp api for popup classes
use fontservice for fame background colour add beta changelog url link to svn log use IPHLPAPI.dll if available, and use only one icmp file handle git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@316 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--ping/common.h3
-rw-r--r--ping/icmp.cpp76
-rw-r--r--ping/icmp.h19
-rw-r--r--ping/options.cpp9
-rw-r--r--ping/ping.cpp16
-rw-r--r--ping/ping.rc2
-rw-r--r--ping/pingthread.cpp32
-rw-r--r--ping/rawping.cpp6
-rw-r--r--ping/rawping.h10
-rw-r--r--ping/utils.cpp55
-rw-r--r--ping/utils.h3
11 files changed, 144 insertions, 87 deletions
diff --git a/ping/common.h b/ping/common.h
index 89a8fc9..9360426 100644
--- a/ping/common.h
+++ b/ping/common.h
@@ -40,7 +40,7 @@
#include <statusmodes.h>
#include <m_options.h>
#include <m_langpack.h>
-#include <m_popup.h>
+#include <m_yapp.h>
#include <m_system.h>
#include <m_skin.h>
#include <m_netlib.h>
@@ -70,7 +70,6 @@ typedef struct {
bool no_test_icon;
int row_height;
int indent;
- COLORREF bg_colour;
int retries;
bool attach_to_clist;
bool log_csv;
diff --git a/ping/icmp.cpp b/ping/icmp.cpp
index 356cc34..4dab823 100644
--- a/ping/icmp.cpp
+++ b/ping/icmp.cpp
@@ -1,21 +1,33 @@
#include "common.h"
#include "icmp.h"
-ICMP ICMP::instance;
+char data[] = "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHH";
+#define EXTRA (12)
+ICMP *ICMP::instance = 0;
ICMP::ICMP():
timeout(2000),
functions_loaded(false)
{
- hDLL = LoadLibrary("ICMP.DLL");
- if(!hDLL) return;
-
- pIcmpCreateFile = (pfnHV)GetProcAddress(hDLL, "IcmpCreateFile");
- pIcmpCloseHandle = (pfnBH)GetProcAddress(hDLL, "IcmpCloseHandle");
- pIcmpSendEcho = (pfnDHDPWPipPDD)GetProcAddress(hDLL, "IcmpSendEcho");
- if ((pIcmpCreateFile == 0) || (pIcmpCloseHandle == 0) || (pIcmpSendEcho == 0)) {
- return;
+ hDLL = LoadLibrary("IPHLPAPI.DLL");
+ if(hDLL) {
+ pIcmpCreateFile = (pfnHV)GetProcAddress(hDLL, "IcmpCreateFile");
+ pIcmpCloseHandle = (pfnBH)GetProcAddress(hDLL, "IcmpCloseHandle");
+ pIcmpSendEcho2 = (pfnDHDPWPipPDD)GetProcAddress(hDLL, "IcmpSendEcho2");
}
+ if (hDLL == 0 || pIcmpCreateFile == 0 || pIcmpCloseHandle == 0 || pIcmpSendEcho2 == 0) {
+ hDLL = LoadLibrary("ICMP.DLL");
+ if(hDLL) {
+ pIcmpCreateFile = (pfnHV)GetProcAddress(hDLL, "IcmpCreateFile");
+ pIcmpCloseHandle = (pfnBH)GetProcAddress(hDLL, "IcmpCloseHandle");
+ pIcmpSendEcho2 = (pfnDHDPWPipPDD)GetProcAddress(hDLL, "IcmpSendEcho2");
+ }
+ if (hDLL == 0 || pIcmpCreateFile == 0 || pIcmpCloseHandle == 0 || pIcmpSendEcho2 == 0)
+ return;
+ else
+ DBWriteContactSettingString(0, PLUG, "PingLib", "ICMP.DLL"); // for debugging
+ } else
+ DBWriteContactSettingString(0, PLUG, "PingLib", "IPHLPAPI.DLL"); // for debugging
WSAData wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
@@ -30,6 +42,7 @@ ICMP::ICMP():
return;
}
+ buff = new char[sizeof(ICMP_ECHO_REPLY) + sizeof(data) + EXTRA];
functions_loaded = true;
}
@@ -41,33 +54,25 @@ void ICMP::stop() {
}
ICMP::~ICMP() {
- if(hIP) pIcmpCloseHandle(hIP);
+ if(hIP) stop();
WSACleanup();
if(hDLL)
FreeLibrary(hDLL);
+ delete[] buff;
}
-bool ICMP::ping(char *host, IP_ECHO_REPLY &reply) {
+bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply) {
if(!functions_loaded) return false;
- DWORD address;
- struct in_addr dest;
+ unsigned long address;
HOSTENT *rec;
IP_OPTION_INFORMATION ipoi;
- hIP = pIcmpCreateFile();
- if (hIP == INVALID_HANDLE_VALUE) {
- return false;
- }
-
-
- dest.s_addr = inet_addr(host);
- if (dest.s_addr == INADDR_NONE) {
+ address = inet_addr(host);
+ if (address == INADDR_NONE) {
rec = gethostbyname(host);
- if(rec) address = *(DWORD *)(*rec->h_addr_list);
+ if(rec) address = *(unsigned long *)(*rec->h_addr_list);
else return false;
- } else {
- address = dest.s_addr;
}
ipoi.Ttl = 255;
@@ -78,12 +83,25 @@ bool ICMP::ping(char *host, IP_ECHO_REPLY &reply) {
reply.Status = 0;
- pIcmpSendEcho(hIP, address, (void *)"PINGPONG", 8, &ipoi, &reply, sizeof(reply), timeout);
-
- if(hIP) {
- pIcmpCloseHandle(hIP);
- hIP = 0;
+ //pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), &ipoi, buff, sizeof(ICMP_ECHO_REPLY) + sizeof(data), timeout);
+ if(pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, sizeof(ICMP_ECHO_REPLY) + sizeof(data) + EXTRA, timeout) == 0) {
+ char winmsg[512], msg[1024];
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), 0, winmsg, 512, 0);
+ mir_snprintf(msg, 1024, "Ping error: %s\nICMP_ECHO_REPLY: %d\ndata: %d\ngiven: %d", winmsg, sizeof(ICMP_ECHO_REPLY), sizeof(data), sizeof(ICMP_ECHO_REPLY) + sizeof(data) + EXTRA);
+ PUShowMessage(msg, SM_NOTIFY);
+ return false;
}
+ memcpy(&reply, buff, sizeof(ICMP_ECHO_REPLY));
return (reply.Status == 0);
+}
+
+ICMP *ICMP::get_instance() {
+ if(!instance)
+ instance = new ICMP();
+ return instance;
+}
+
+void ICMP::cleanup() {
+ if(instance) delete instance;
} \ No newline at end of file
diff --git a/ping/icmp.h b/ping/icmp.h
index 902942e..95efc28 100644
--- a/ping/icmp.h
+++ b/ping/icmp.h
@@ -4,9 +4,11 @@
#define _ICMP_H
//#include <windows.h>
+#include <iphlpapi.h>
+#include <icmpapi.h>
// Structures required to use functions in ICMP.DLL
-
+/*
typedef struct {
unsigned char Ttl; // Time To Live
unsigned char Tos; // Type Of Service
@@ -26,16 +28,16 @@ typedef struct {
unsigned char ReplyData[8];
} IP_ECHO_REPLY, * PIP_ECHO_REPLY;
-
+*/
typedef HANDLE (WINAPI* pfnHV)(VOID);
typedef BOOL (WINAPI* pfnBH)(HANDLE);
-typedef DWORD (WINAPI* pfnDHDPWPipPDD)(HANDLE, DWORD, LPVOID, WORD, PIP_OPTION_INFORMATION, LPVOID, DWORD, DWORD); // evil, no?
+typedef DWORD (WINAPI* pfnDHDPWPipPDD)(HANDLE, HANDLE, FARPROC, PVOID, IPAddr, LPVOID, WORD, PIP_OPTION_INFORMATION, LPVOID, DWORD, DWORD);
class ICMP {
protected:
pfnHV pIcmpCreateFile;
pfnBH pIcmpCloseHandle;
- pfnDHDPWPipPDD pIcmpSendEcho;
+ pfnDHDPWPipPDD pIcmpSendEcho2;
HMODULE hDLL;
@@ -46,13 +48,16 @@ protected:
// protected constructor - singleton class
ICMP();
- static ICMP instance;
+ static ICMP *instance;
+
+ char *buff;
public:
~ICMP();
- static ICMP *get_instance() {return &instance;}
+ static ICMP *get_instance();
+ static void cleanup();
- bool ping(char *host, IP_ECHO_REPLY &reply);
+ bool ping(char *host, ICMP_ECHO_REPLY &reply);
void set_timeout(unsigned int t) {
timeout = t;
diff --git a/ping/options.cpp b/ping/options.cpp
index 621825b..56e2d69 100644
--- a/ping/options.cpp
+++ b/ping/options.cpp
@@ -39,8 +39,6 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
SetDlgItemInt(hwndDlg, IDC_RPT, options.retries, FALSE);
- SendDlgItemMessage(hwndDlg, IDC_BGCOL, CPM_SETCOLOUR, 0, options.bg_colour);
-
SetDlgItemText(hwndDlg, IDC_ED_FILENAME, options.log_filename);
if(!options.logging) {
hw = GetDlgItem(hwndDlg, IDC_ED_FILENAME);
@@ -62,10 +60,6 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
return TRUE;
}
case WM_COMMAND:
- if(LOWORD(wParam) == IDC_BGCOL) {
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
- break;
- }
if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
switch( LOWORD( wParam )) {
case IDC_PPM:
@@ -155,7 +149,6 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
options.indent = SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_GETPOS, 0, 0);
options.row_height = SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_GETPOS, 0, 0);
- options.bg_colour = SendDlgItemMessage(hwndDlg, IDC_BGCOL, CPM_GETCOLOUR, 0, 0);
DWORD new_retries = GetDlgItemInt( hwndDlg, IDC_RPT, &trans_success, FALSE);
if(trans_success) {
@@ -593,7 +586,6 @@ void LoadOptions() {
options.indent = DBGetContactSettingWord(NULL, PLUG, "Indent", 0);
options.row_height = DBGetContactSettingWord(NULL, PLUG, "RowHeight", GetSystemMetrics(SM_CYSMICON));
- options.bg_colour = (COLORREF)DBGetContactSettingDword(NULL, PLUG, "BgColor", GetSysColor(COLOR_3DFACE));
options.retries = DBGetContactSettingDword(NULL, PLUG, "Retries", 0);
@@ -618,7 +610,6 @@ void SaveOptions() {
DBWriteContactSettingWord(NULL, PLUG, "Indent", options.indent);
DBWriteContactSettingWord(NULL, PLUG, "RowHeight", options.row_height);
- DBWriteContactSettingDword(NULL, PLUG, "BgColor", (DWORD)options.bg_colour);
DBWriteContactSettingDword(NULL, PLUG, "Retries", (DWORD)options.retries);
diff --git a/ping/ping.cpp b/ping/ping.cpp
index b5fba5c..9623fcd 100644
--- a/ping/ping.cpp
+++ b/ping/ping.cpp
@@ -13,7 +13,7 @@ bool use_raw_ping = true;
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
"Ping Plugin",
- PLUGIN_MAKE_VERSION(0, 8, 0, 2),
+ PLUGIN_MAKE_VERSION(0, 9, 1, 0),
"Ping labelled IP addresses or domain names.",
"Scott Ellis",
"mail@scottellis.com.au",
@@ -27,6 +27,7 @@ PLUGININFOEX pluginInfo={
extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
hInst=hinstDLL;
+ DisableThreadLibraryCalls(hInst);
return TRUE;
}
@@ -87,7 +88,7 @@ int OnShutdown(WPARAM wParam, LPARAM lParam) {
if(use_raw_ping)
cleanup_raw_ping();
else
- ICMP::get_instance()->stop();
+ ICMP::cleanup();
DeinitList();
@@ -105,6 +106,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
update.szComponentName = pluginInfo.shortName;
update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
update.cpbVersion = strlen((char *)update.pbVersion);
+ update.szBetaChangelogURL = "https://server.scottellis.com.au/websvn/log.php?repname=Miranda+Plugins&path=%2Fping%2F&rev=0&sc=0&isdir=1";
update.szUpdateURL = UPDATER_AUTOREGISTER;
@@ -121,6 +123,8 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
}
+
+
NETLIBUSER nl_user = {0};
nl_user.cbSize = sizeof(nl_user);
nl_user.szSettingsModule = PLUG;
@@ -136,7 +140,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
- InitIcons();
+ InitUtils();
InitMenus();
@@ -164,11 +168,11 @@ extern "C" PING_API int Load(PLUGINLINK *link)
{
pluginLink=link;
- if(init_raw_ping()) {
+ //if(init_raw_ping()) {
//MessageBox(0, Translate("Failed to initialize. Plugin disabled."), Translate("Ping Plugin"), MB_OK | MB_ICONERROR);
//return 1;
use_raw_ping = false;
- }
+ //}
DBWriteContactSettingByte(0, PLUG, "UsingRawSockets", (BYTE)use_raw_ping);
DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );
@@ -204,6 +208,8 @@ extern "C" PING_API int Unload(void)
DeleteCriticalSection(&thread_finished_cs);
DeleteCriticalSection(&list_changed_cs);
DeleteCriticalSection(&data_list_cs);
+
+ DeinitUtils();
CloseHandle( mainThread );
diff --git a/ping/ping.rc b/ping/ping.rc
index f26caec..5289966 100644
--- a/ping/ping.rc
+++ b/ping/ping.rc
@@ -98,8 +98,6 @@ BEGIN
GROUPBOX "Interface",IDC_STATIC,4,84,293,76
CONTROL "Do not change icon when testing",IDC_CHK_NOTESTICON,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,145,181,10
- CONTROL "Custom1",IDC_BGCOL,"ColourPicker",WS_TABSTOP,220,108,40,9
- CTEXT "Background",IDC_STATIC,217,96,45,9
LTEXT "Use the Customize/Fonts options to change text size and colour.",IDC_STATFS,20,101,174,18
RTEXT "Indent:",IDC_STATIC,44,127,33,8
EDITTEXT IDC_EDIT1,89,124,33,15,ES_AUTOHSCROLL
diff --git a/ping/pingthread.cpp b/ping/pingthread.cpp
index afbaea2..3c6b2c9 100644
--- a/ping/pingthread.cpp
+++ b/ping/pingthread.cpp
@@ -21,7 +21,9 @@ int frame_id = -1;
HBRUSH tbrush = 0;
FontID font_id;
+ColourID bk_col_id;
HFONT hFont = 0;
+COLORREF bk_col = RGB(255, 255, 255);
////////////////
#define WinVerMajor() LOBYTE(LOWORD(GetVersion()))
@@ -393,7 +395,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
tcol = DBGetContactSettingDword(NULL,"CLC","SelTextColour", GetSysColor(COLOR_HIGHLIGHTTEXT));
SetTextColor(dis->hDC, tcol);
} else {
- tcol = options.bg_colour;
+ tcol = bk_col;
SetBkColor(dis->hDC, tcol);
FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));
@@ -435,14 +437,14 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
{
if(tbrush) DeleteObject(tbrush);
- return (BOOL)(tbrush = CreateSolidBrush(options.bg_colour));
+ return (BOOL)(tbrush = CreateSolidBrush(bk_col));
}
case WM_ERASEBKGND:
{
RECT r;
GetClientRect(hwnd, &r);
- if(!tbrush) tbrush = CreateSolidBrush(options.bg_colour);
+ if(!tbrush) tbrush = CreateSolidBrush(bk_col);
FillRect((HDC)wParam, &r, tbrush);
}
return TRUE;
@@ -877,13 +879,16 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
int ReloadFont(WPARAM wParam, LPARAM lParam) {
- DeleteObject(hFont);
+ if(hFont) DeleteObject(hFont);
LOGFONT log_font;
CallService(MS_FONT_GET, (WPARAM)&font_id, (LPARAM)&log_font);
hFont = CreateFontIndirect(&log_font);
SendMessage(list_hwnd, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);
+ bk_col = CallService(MS_COLOUR_GET, (WPARAM)&bk_col_id, 0);
+ RefreshWindow(0, 0);
+
return 0;
}
@@ -1027,19 +1032,24 @@ void InitList() {
if(ServiceExists(MS_FONT_REGISTER)) {
font_id.cbSize = sizeof(FontID);
- strncpy(font_id.group, "Frames", sizeof(font_id.group));
- strncpy(font_id.name, "Ping", sizeof(font_id.name));
+ strncpy(font_id.group, "Ping", sizeof(font_id.group));
+ strncpy(font_id.name, "List", sizeof(font_id.name));
strncpy(font_id.dbSettingsGroup, "PING", sizeof(font_id.dbSettingsGroup));
strncpy(font_id.prefix, "Font", sizeof(font_id.prefix));
font_id.order = 0;
CallService(MS_FONT_REGISTER, (WPARAM)&font_id, 0);
- LOGFONT log_font;
- CallService(MS_FONT_GET, (WPARAM)&font_id, (LPARAM)&log_font);
- hFont = CreateFontIndirect(&log_font);
- SendMessage(list_hwnd, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);
-
+
+ bk_col_id.cbSize = sizeof(ColourID);
+ strncpy(bk_col_id.group, "Ping", sizeof(bk_col_id.group));
+ strncpy(bk_col_id.name, "Background", sizeof(bk_col_id.name));
+ strncpy(bk_col_id.dbSettingsGroup, "PING", sizeof(bk_col_id.dbSettingsGroup));
+ strncpy(bk_col_id.setting, "BgColor", sizeof(bk_col_id.setting));
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&bk_col_id, 0);
+
HookEvent(ME_FONT_RELOAD, ReloadFont);
+
+ ReloadFont(0, 0);
}
start_ping_thread();
diff --git a/ping/rawping.cpp b/ping/rawping.cpp
index 65478e2..c5289dd 100644
--- a/ping/rawping.cpp
+++ b/ping/rawping.cpp
@@ -62,7 +62,7 @@ extern int init_raw_ping() {
ICMPHeader *header = (ICMPHeader *)packet;
- header->type = ICMP_ECHO_REQUEST;
+ header->type = PT_ICMP_ECHO_REQUEST;
header->code = 0;
header->id = (USHORT)GetCurrentProcessId();
@@ -177,7 +177,7 @@ extern int raw_ping(char *host, int timeout) {
if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: wrong ID...cycling", 0);
continue;
- if(reply->type != ICMP_ECHO_REPLY && reply->type != ICMP_SOURCE_QUENCH) {
+ if(reply->type != PT_ICMP_ECHO_REPLY && reply->type != PT_ICMP_SOURCE_QUENCH) {
if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: wrong type...cycling", 0);
continue;
}
@@ -189,7 +189,7 @@ extern int raw_ping(char *host, int timeout) {
continue;
}
- if(reply->type == ICMP_SOURCE_QUENCH) {
+ if(reply->type == PT_ICMP_SOURCE_QUENCH) {
char buff[1024];
sprintf(buff, Translate("Host %s requests that you reduce the amount of traffic you are sending."), host);
MessageBox(0, buff, Translate(PLUG " Warning"), MB_OK | MB_ICONWARNING);
diff --git a/ping/rawping.h b/ping/rawping.h
index 1149180..23d9df1 100644
--- a/ping/rawping.h
+++ b/ping/rawping.h
@@ -9,11 +9,11 @@
#define ICMP_PROTO 1
// ICMP packet types
-#define ICMP_ECHO_REPLY 0
-#define ICMP_DEST_UNREACH 3
-#define ICMP_TTL_EXPIRE 11
-#define ICMP_ECHO_REQUEST 8
-#define ICMP_SOURCE_QUENCH 4
+#define PT_ICMP_ECHO_REPLY 0
+#define PT_ICMP_DEST_UNREACH 3
+#define PT_ICMP_TTL_EXPIRE 11
+#define PT_ICMP_ECHO_REQUEST 8
+#define PT_ICMP_SOURCE_QUENCH 4
// Minimum ICMP packet size, in bytes
#define ICMP_MIN 8
diff --git a/ping/utils.cpp b/ping/utils.cpp
index a8aaaef..6cf147a 100644
--- a/ping/utils.cpp
+++ b/ping/utils.cpp
@@ -1,5 +1,6 @@
#include "common.h"
#include "utils.h"
+#include "icmp.h"
LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
@@ -39,21 +40,29 @@ void __stdcall ShowPopup( const char* line1, const char* line2, int flags )
return;
}
- POPUPDATAEX* ppd = ( POPUPDATAEX* )calloc( sizeof( POPUPDATAEX ), 1 );
+ if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
+ PopupClassInstance d = {sizeof(d), "pingpopups"};
+ d.pwszTitle = (wchar_t *)line1;
+ d.pwszText = (wchar_t *)line2;
+ CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
+ } else {
+
+ POPUPDATAEX* ppd = ( POPUPDATAEX* )calloc( sizeof( POPUPDATAEX ), 1 );
- ppd->lchContact = NULL;
- ppd->lchIcon = (flags ? hIconResponding : hIconNotResponding);
- strcpy( ppd->lpzContactName, line1 );
- strcpy( ppd->lpzText, line2 );
+ ppd->lchContact = NULL;
+ ppd->lchIcon = (flags ? hIconResponding : hIconNotResponding);
+ strcpy( ppd->lpzContactName, line1 );
+ strcpy( ppd->lpzText, line2 );
- ppd->colorBack = GetSysColor( COLOR_BTNFACE );
- ppd->colorText = GetSysColor( COLOR_WINDOWTEXT );
- ppd->iSeconds = 10;
+ ppd->colorBack = GetSysColor( COLOR_BTNFACE );
+ ppd->colorText = GetSysColor( COLOR_WINDOWTEXT );
+ ppd->iSeconds = 10;
- ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
- ppd->PluginData = NULL;
+ ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
+ ppd->PluginData = NULL;
- QueueUserAPC( sttMainThreadCallback , mainThread, ( ULONG )ppd );
+ QueueUserAPC( sttMainThreadCallback , mainThread, ( ULONG )ppd );
+ }
}
// service functions
@@ -72,7 +81,7 @@ int PluginPing(WPARAM wParam,LPARAM lParam)
pa->responding = (pa->round_trip_time != -1);
} else {
- IP_ECHO_REPLY result;
+ ICMP_ECHO_REPLY result;
pa->responding = ICMP::get_instance()->ping(pa->pszName, result);
if(pa->responding)
pa->round_trip_time = (short)result.RoundTripTime;
@@ -310,7 +319,7 @@ int ReloadIcons(WPARAM wParam, LPARAM lParam) {
return 0;
}
-void InitIcons() {
+void InitUtils() {
if(ServiceExists(MS_SKIN2_ADDICON)) {
SKINICONDESC sid = {0};
@@ -357,6 +366,26 @@ void InitIcons() {
hIconTesting = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_TESTING), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
hIconDisabled = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_DISABLED), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
}
+
+ if(ServiceExists(MS_YAPP_REGISTERCLASS)) {
+ PopupClass test = {0};
+ test.cbSize = sizeof(test);
+ test.flags = PCF_TCHAR;
+ test.hIcon = hIconResponding;
+ test.timeout = -1;
+ test.ptszDescription = TranslateT("Ping");
+ test.pszName = "pingpopups";
+ test.windowProc = NullWindowProc;
+ CallService(MS_YAPP_REGISTERCLASS, 0, (WPARAM)&test);
+ }
}
+void DeinitUtils() {
+ if(!ServiceExists(MS_SKIN2_ADDICON)) {
+ if(hIconResponding) DestroyIcon(hIconResponding);
+ if(hIconResponding) DestroyIcon(hIconNotResponding);
+ if(hIconResponding) DestroyIcon(hIconTesting);
+ if(hIconResponding) DestroyIcon(hIconDisabled);
+ }
+} \ No newline at end of file
diff --git a/ping/utils.h b/ping/utils.h
index a7ec017..0427ff3 100644
--- a/ping/utils.h
+++ b/ping/utils.h
@@ -28,7 +28,8 @@ int EditContact(WPARAM wParam, LPARAM lParam);
void import_ping_addresses();
// use icolib if possible
-void InitIcons();
+void InitUtils();
+void DeinitUtils();
extern HICON hIconResponding, hIconNotResponding, hIconTesting, hIconDisabled;