summaryrefslogtreecommitdiff
path: root/plugins/Ping
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-09-25 19:25:38 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-09-25 19:25:38 +0000
commit2cf824fd2efaec5fa0125fdde5fd513dd906d844 (patch)
treeaadae8304f8cf90c06c73ca49180c62faeef539b /plugins/Ping
parenta01f62f394fc01e3c6ed89924be804d2438787e5 (diff)
plugins cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6233 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Ping')
-rw-r--r--plugins/Ping/ping_10.vcxproj8
-rw-r--r--plugins/Ping/ping_11.vcxproj8
-rw-r--r--plugins/Ping/src/common.h1
-rw-r--r--plugins/Ping/src/icmp.cpp45
-rw-r--r--plugins/Ping/src/icmp.h10
-rw-r--r--plugins/Ping/src/pingthread.cpp37
6 files changed, 28 insertions, 81 deletions
diff --git a/plugins/Ping/ping_10.vcxproj b/plugins/Ping/ping_10.vcxproj
index dd9bec31ab..de3c728eef 100644
--- a/plugins/Ping/ping_10.vcxproj
+++ b/plugins/Ping/ping_10.vcxproj
@@ -93,7 +93,7 @@
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -115,7 +115,7 @@
<AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -144,7 +144,7 @@
<AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<BaseAddress>0x22040000</BaseAddress>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -173,7 +173,7 @@
<AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
diff --git a/plugins/Ping/ping_11.vcxproj b/plugins/Ping/ping_11.vcxproj
index b983868e95..570e9328b9 100644
--- a/plugins/Ping/ping_11.vcxproj
+++ b/plugins/Ping/ping_11.vcxproj
@@ -97,7 +97,7 @@
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin11\lib</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
@@ -120,7 +120,7 @@
<AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -149,7 +149,7 @@
<AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<BaseAddress>0x22040000</BaseAddress>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -178,7 +178,7 @@
<AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
diff --git a/plugins/Ping/src/common.h b/plugins/Ping/src/common.h
index 48ddd31e03..f2d7259c65 100644
--- a/plugins/Ping/src/common.h
+++ b/plugins/Ping/src/common.h
@@ -14,6 +14,7 @@
#include <commdlg.h>
#include <commctrl.h>
#include <iphlpapi.h>
+#include <Icmpapi.h>
#include <list>
#include <newpluginapi.h>
diff --git a/plugins/Ping/src/icmp.cpp b/plugins/Ping/src/icmp.cpp
index eeab3cf567..3cd34384bc 100644
--- a/plugins/Ping/src/icmp.cpp
+++ b/plugins/Ping/src/icmp.cpp
@@ -9,57 +9,23 @@ ICMP::ICMP():
timeout(2000),
functions_loaded(false)
{
- hDLL = LoadLibrary(_T("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(_T("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
- db_set_s(0, PLUG, "PingLib", "ICMP.DLL"); // for debugging
- } else
- db_set_s(0, PLUG, "PingLib", "IPHLPAPI.DLL"); // for debugging
-
WSAData wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
WSACleanup();
- FreeLibrary((HMODULE)hDLL);
return;
}
- /*
- hIP = pIcmpCreateFile();
- if (hIP == INVALID_HANDLE_VALUE) {
- pIcmpCloseHandle(hIP);
- return;
- }
- */
-
buff = new char[BUFFER_SIZE];
functions_loaded = true;
}
-void ICMP::stop() {
- //if(hIP) {
- // pIcmpCloseHandle(hIP);
- // hIP = 0;
- //}
+void ICMP::stop()
+{
}
ICMP::~ICMP() {
if(hIP) stop();
WSACleanup();
- if(hDLL)
- FreeLibrary(hDLL);
delete[] buff;
}
@@ -90,12 +56,11 @@ bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply)
reply.Status = 0;
- hIP = pIcmpCreateFile();
+ hIP = IcmpCreateFile();
if (hIP == INVALID_HANDLE_VALUE)
return false;
- //pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), &ipoi, buff, sizeof(ICMP_ECHO_REPLY) + sizeof(data), timeout);
- DWORD rep_cnt = pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, BUFFER_SIZE, timeout);
+ DWORD rep_cnt = IcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, BUFFER_SIZE, timeout);
if (rep_cnt == 0)
{
DWORD code = GetLastError();
@@ -110,7 +75,7 @@ bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply)
}
memcpy(&reply, buff, sizeof(ICMP_ECHO_REPLY));
- pIcmpCloseHandle(hIP);
+ IcmpCloseHandle(hIP);
return (reply.Status == 0);
}
diff --git a/plugins/Ping/src/icmp.h b/plugins/Ping/src/icmp.h
index e3da22691b..110f5b554c 100644
--- a/plugins/Ping/src/icmp.h
+++ b/plugins/Ping/src/icmp.h
@@ -3,18 +3,8 @@
#ifndef _ICMP_H
#define _ICMP_H
-typedef HANDLE (WINAPI* pfnHV)(VOID);
-typedef BOOL (WINAPI* pfnBH)(HANDLE);
-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 pIcmpSendEcho2;
-
- HMODULE hDLL;
-
HANDLE hIP;
unsigned int timeout;
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index 242f7266bd..f785976e51 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -2,7 +2,7 @@
int upCount, total = 0;
-int list_size = 0;
+size_t list_size = 0;
HANDLE mainThread;
HANDLE hWakeEvent = 0;
@@ -25,9 +25,6 @@ HFONT hFont = 0;
COLORREF bk_col = RGB(255, 255, 255);
////////////////
-static HMODULE hUserDll;
-BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
-BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags);
#define TM_AUTOALPHA 1
static int transparentFocus=1;
/////////////////
@@ -105,7 +102,7 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
Lock(&data_list_cs, "ping thread loop start");
set_list_changed(false);
- int size = data_list.size();
+ size_t size = data_list.size();
Unlock(&data_list_cs);
int index = 0;
@@ -530,7 +527,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
#endif
#ifdef LWA_ALPHA
- if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(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(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
#endif
}
}
@@ -553,7 +550,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
if(db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)) {
KillTimer(hwnd,TM_AUTOALPHA);
#ifdef LWA_ALPHA
- if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(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(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
#endif
transparentFocus=1;
}
@@ -562,9 +559,9 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
case WM_SETCURSOR:
if(db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)) {
- if (!transparentFocus && GetForegroundWindow()!=hwnd && MySetLayeredWindowAttributes) {
+ if (!transparentFocus && GetForegroundWindow()!=hwnd) {
#ifdef LWA_ALPHA
- MySetLayeredWindowAttributes(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(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
#endif
transparentFocus=1;
SetTimer(hwnd, TM_AUTOALPHA,250,NULL);
@@ -588,12 +585,12 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
hwndPt=WindowFromPoint(pt);
inwnd=(hwndPt==hwnd || GetParent(hwndPt)==hwnd);
}
- if (inwnd!=transparentFocus && MySetLayeredWindowAttributes)
+ if (inwnd!=transparentFocus)
{ //change
transparentFocus=inwnd;
#ifdef LWA_ALPHA
- if(transparentFocus) MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
- else MySetLayeredWindowAttributes(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(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);
#endif
}
if(!transparentFocus) KillTimer(hwnd,TM_AUTOALPHA);
@@ -616,7 +613,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
sourceAlpha=0;
destAlpha=(BYTE)db_get_b(NULL,"CList","Alpha",SETTING_AUTOALPHA_DEFAULT);
#ifdef LWA_ALPHA
- MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA);
#endif
noRecurse=1;
ShowWindow(hwnd,SW_SHOW);
@@ -630,16 +627,16 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
thisTick=GetTickCount();
if(thisTick>=startTick+200) break;
#ifdef LWA_ALPHA
- MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)(sourceAlpha+(destAlpha-sourceAlpha)*(int)(thisTick-startTick)/200), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)(sourceAlpha+(destAlpha-sourceAlpha)*(int)(thisTick-startTick)/200), LWA_ALPHA);
#endif
}
#ifdef LWA_ALPHA
- MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)destAlpha, LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)destAlpha, LWA_ALPHA);
#endif
}
else {
// if(wParam) SetForegroundWindow(hwnd);
- MyAnimateWindow(hwnd,200,AW_BLEND|(wParam?0:AW_HIDE));
+ AnimateWindow(hwnd,200,AW_BLEND|(wParam?0:AW_HIDE));
//SetWindowPos(label,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
}
#endif
@@ -915,7 +912,7 @@ void UpdateFrame() {
GetWindowRect(hwnd_clist, &r_clist);
RECT r_frame;
GetWindowRect(hpwnd, &r_frame);
- int height = list_size * options.row_height;
+ int height = (int)list_size * options.row_height;
if(GetWindowLong(hpwnd, GWL_STYLE) & WS_BORDER) {
RECT r_frame_client;
GetClientRect(hpwnd, &r_frame_client);
@@ -969,12 +966,6 @@ void AttachToClist(bool attach)
void InitList()
{
- hUserDll = LoadLibrary(_T("user32.dll"));
- if (hUserDll) {
- MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
- MyAnimateWindow=(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow");
- }
-
hwnd_clist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
WNDCLASS wndclass;