summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Ping/ping_10.vcxproj15
-rw-r--r--plugins/Ping/ping_10.vcxproj.filters9
-rw-r--r--plugins/Ping/ping_11.vcxproj15
-rw-r--r--plugins/Ping/ping_11.vcxproj.filters9
-rw-r--r--plugins/Ping/res/Version.rc38
-rw-r--r--plugins/Ping/res/ping.rc16
-rw-r--r--plugins/Ping/src/Version.h14
-rw-r--r--plugins/Ping/src/collection.h28
-rw-r--r--plugins/Ping/src/common.h85
-rw-r--r--plugins/Ping/src/icmp.cpp39
-rw-r--r--plugins/Ping/src/icmp.h32
-rw-r--r--plugins/Ping/src/log.cpp1
-rw-r--r--plugins/Ping/src/log.h3
-rw-r--r--plugins/Ping/src/menu.cpp1
-rw-r--r--plugins/Ping/src/menu.h4
-rw-r--r--plugins/Ping/src/options.cpp92
-rw-r--r--plugins/Ping/src/options.h15
-rw-r--r--plugins/Ping/src/ping.cpp33
-rw-r--r--plugins/Ping/src/ping.h23
-rw-r--r--plugins/Ping/src/pinggraph.cpp89
-rw-r--r--plugins/Ping/src/pinggraph.h5
-rw-r--r--plugins/Ping/src/pinglist.cpp111
-rw-r--r--plugins/Ping/src/pinglist.h8
-rw-r--r--plugins/Ping/src/pingthread.cpp156
-rw-r--r--plugins/Ping/src/pingthread.h11
-rw-r--r--plugins/Ping/src/rawping.cpp148
-rw-r--r--plugins/Ping/src/rawping.h4
-rw-r--r--plugins/Ping/src/utils.cpp50
-rw-r--r--plugins/Ping/src/utils.h8
29 files changed, 534 insertions, 528 deletions
diff --git a/plugins/Ping/ping_10.vcxproj b/plugins/Ping/ping_10.vcxproj
index 246ad32217..9fe0ccac6a 100644
--- a/plugins/Ping/ping_10.vcxproj
+++ b/plugins/Ping/ping_10.vcxproj
@@ -73,7 +73,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -81,7 +81,6 @@
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -104,9 +103,8 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
@@ -133,14 +131,13 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -163,9 +160,8 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -191,6 +187,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="res\ping.rc" />
+ <ResourceCompile Include="res\Version.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\collection.h" />
@@ -199,13 +196,13 @@
<ClInclude Include="src\log.h" />
<ClInclude Include="src\menu.h" />
<ClInclude Include="src\options.h" />
- <ClInclude Include="src\ping.h" />
<ClInclude Include="src\pinggraph.h" />
<ClInclude Include="src\pinglist.h" />
<ClInclude Include="src\pingthread.h" />
<ClInclude Include="src\rawping.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\utils.h" />
+ <ClInclude Include="src\Version.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\icmp.cpp" />
diff --git a/plugins/Ping/ping_10.vcxproj.filters b/plugins/Ping/ping_10.vcxproj.filters
index 88f78f08e5..d20de68fd7 100644
--- a/plugins/Ping/ping_10.vcxproj.filters
+++ b/plugins/Ping/ping_10.vcxproj.filters
@@ -18,6 +18,9 @@
<ResourceCompile Include="res\ping.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\Version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\collection.h">
@@ -38,9 +41,6 @@
<ClInclude Include="src\options.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\ping.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\pinggraph.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -59,6 +59,9 @@
<ClInclude Include="src\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\Version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\icmp.cpp">
diff --git a/plugins/Ping/ping_11.vcxproj b/plugins/Ping/ping_11.vcxproj
index f5f0388727..7739c46c13 100644
--- a/plugins/Ping/ping_11.vcxproj
+++ b/plugins/Ping/ping_11.vcxproj
@@ -77,7 +77,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -85,7 +85,6 @@
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -108,9 +107,8 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
@@ -137,14 +135,13 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -167,9 +164,8 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -195,6 +191,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="res\ping.rc" />
+ <ResourceCompile Include="res\Version.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\collection.h" />
@@ -203,13 +200,13 @@
<ClInclude Include="src\log.h" />
<ClInclude Include="src\menu.h" />
<ClInclude Include="src\options.h" />
- <ClInclude Include="src\ping.h" />
<ClInclude Include="src\pinggraph.h" />
<ClInclude Include="src\pinglist.h" />
<ClInclude Include="src\pingthread.h" />
<ClInclude Include="src\rawping.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\utils.h" />
+ <ClInclude Include="src\Version.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\icmp.cpp" />
diff --git a/plugins/Ping/ping_11.vcxproj.filters b/plugins/Ping/ping_11.vcxproj.filters
index 88f78f08e5..d20de68fd7 100644
--- a/plugins/Ping/ping_11.vcxproj.filters
+++ b/plugins/Ping/ping_11.vcxproj.filters
@@ -18,6 +18,9 @@
<ResourceCompile Include="res\ping.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\Version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\collection.h">
@@ -38,9 +41,6 @@
<ClInclude Include="src\options.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\ping.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\pinggraph.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -59,6 +59,9 @@
<ClInclude Include="src\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\Version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\icmp.cpp">
diff --git a/plugins/Ping/res/Version.rc b/plugins/Ping/res/Version.rc
new file mode 100644
index 0000000000..5bfbab4754
--- /dev/null
+++ b/plugins/Ping/res/Version.rc
@@ -0,0 +1,38 @@
+// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "afxres.h"
+#include "..\src\version.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/plugins/Ping/res/ping.rc b/plugins/Ping/res/ping.rc
index db3bc43e6a..581595bd75 100644
--- a/plugins/Ping/res/ping.rc
+++ b/plugins/Ping/res/ping.rc
@@ -29,7 +29,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
1 TEXTINCLUDE
BEGIN
- "resource.h\0"
+ "..\\src\\resource.h\0"
END
2 TEXTINCLUDE
@@ -46,18 +46,6 @@ END
#endif // APSTUDIO_INVOKED
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (Australia) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
-#pragma code_page(1252)
-#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
@@ -210,7 +198,7 @@ BEGIN
END
END
-#endif // English (Australia) resources
+#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Ping/src/Version.h b/plugins/Ping/src/Version.h
new file mode 100644
index 0000000000..d2d45e4dd8
--- /dev/null
+++ b/plugins/Ping/src/Version.h
@@ -0,0 +1,14 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 9
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 1
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+
+#define __PLUGIN_NAME "Ping"
+#define __FILENAME "Ping.dll"
+#define __DESCRIPTION "Ping labelled IP addresses or domain names."
+#define __AUTHOR "Scott Ellis"
+#define __AUTHOREMAIL "mail@scottellis.com.au"
+#define __AUTHORWEB "http://miranda-ng.org/"
+#define __COPYRIGHT "© 2005 Scott Ellis"
diff --git a/plugins/Ping/src/collection.h b/plugins/Ping/src/collection.h
index f8709e3ef8..78fde37dfd 100644
--- a/plugins/Ping/src/collection.h
+++ b/plugins/Ping/src/collection.h
@@ -1,5 +1,3 @@
-#include <malloc.h>
-
template<class T> class Collection {
protected:
unsigned long count;
@@ -28,7 +26,7 @@ public:
ListNode(const T &v): Node<T>(v), next(0), prev(0) {}
virtual ~ListNode() {
if(next) next->prev = prev;
- if(prev) prev->next = next;
+ if(prev) prev->next = next;
}
};
@@ -53,19 +51,21 @@ public:
LinkedList(): Collection<T>(), head(0), tail(0) {};
LinkedList(const LinkedList<T> &other): Collection<T>(), head(0), tail(0) {
- for(Iterator i = other.start(); i.has_val(); i.next())
+ for(Iterator i = other.begin(); i.has_val(); i.next())
add(i.val());
}
- virtual ~LinkedList() {clear();}
+ virtual ~LinkedList() { clear(); }
- LinkedList<T> &operator=(const LinkedList<T> &other) {
+ LinkedList<T> &operator=(const LinkedList<T> &other)
+ {
clear();
- for(Iterator i = other.start(); i.has_val(); i.next())
+ for(Iterator i = other.begin(); i.has_val(); i.next())
add(i.val());
return *this;
}
- virtual void clear() {
+ virtual void clear()
+ {
ListNode<T> *n;
while(head) {
n = head;
@@ -76,7 +76,7 @@ public:
Collection<T>::count = 0;
}
- virtual Iterator start() const {return Iterator(head);}
+ virtual Iterator begin() const {return Iterator(head);}
virtual void add_front(T &val) {
ListNode<T> *n = new ListNode<T>(val);
@@ -190,7 +190,7 @@ public:
}
}
- virtual Iterator start() const {return Iterator(ar, Collection<T>::count, 0);}
+ virtual Iterator begin() const {return Iterator(ar, Collection<T>::count, 0);}
virtual void add(const T &val) {
if(Collection<T>::count == limit) {
@@ -202,7 +202,7 @@ public:
}
virtual void add_all(DynamicArray<T> &other) {
- for(Iterator i = other.start(); i.has_val(); i.next()) {
+ for(Iterator i = other.begin(); i != pl.end(); ++i) {
add(i.val());
}
}
@@ -431,14 +431,14 @@ public:
BinaryTree(): Collection<T>(), root(0) {};
BinaryTree(BinaryTree<T> &other): Collection<T>(), root(0) {
- for(Iterator i = other.start(); i.has_val(); i.next())
+ for(Iterator i = other.begin(); i != pl.end(); ++i)
add(i.val());
}
virtual ~BinaryTree() {clear();}
BinaryTree &operator=(BinaryTree<T> &other) {
clear();
- for(Iterator i = other.start(); i.has_val(); i.next())
+ for(Iterator i = other.begin(); i != pl.end(); ++i)
add(i.val());
return *this;
}
@@ -497,7 +497,7 @@ public:
return current != 0;
}
- Iterator start() const {return Iterator(root);}
+ Iterator begin() const {return Iterator(root);}
};
#define RED 1
diff --git a/plugins/Ping/src/common.h b/plugins/Ping/src/common.h
index e4e338cc34..48ddd31e03 100644
--- a/plugins/Ping/src/common.h
+++ b/plugins/Ping/src/common.h
@@ -1,64 +1,63 @@
#ifndef _COMMON_H
#define _COMMON_H
-#define MAX_HISTORY (1440) // 12 hrs at 30 sec intervals
-
-#define PLUG "PING"
-
-#define DEFAULT_PING_PERIOD 30
-#define DEFAULT_PING_TIMEOUT 2
-#define DEFAULT_SHOW_POPUP true
-#define DEFAULT_SHOW_POPUP2 false
-#define DEFAULT_BLOCK_REPS true
-#define DEFAULT_LOGGING_ENABLED false
-#define DEFAULT_LOG_FILENAME "ping_log.txt"
-#define DEFAULT_NO_TEST_ICON true
-#define DEFAULT_ATTACH_TO_CLIST false
-
-#define MAX_PINGADDRESS_STRING_LENGTH 256
-
-//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-//#define VC_EXTRALEAN
-//#define _WIN32_WINNT 0x0500
+#define _CRT_SECURE_NO_DEPRECATE
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#define _WIN32_IE 0x0300
-#define MIRANDA_VER 0x0600
#include <windows.h>
-
-//#include <prsht.h>
+#include <winsock.h>
#include <shellapi.h>
#include <commdlg.h>
#include <commctrl.h>
-#include <time.h>
-
-#include <stdio.h>
+#include <iphlpapi.h>
+#include <list>
#include <newpluginapi.h>
-#include <statusmodes.h>
#include <m_options.h>
#include <m_langpack.h>
#include <m_popup.h>
-#include <m_system.h>
#include <m_skin.h>
#include <m_netlib.h>
#include <m_database.h>
-#include <m_protocols.h>
-#include <m_protomod.h>
#include <m_protosvc.h>
-#include <m_ignore.h>
-#include <m_clist.h>
#include <m_clui.h>
-#include <m_genmenu.h>
#include <m_cluiframes.h>
-#include <m_utils.h>
#include <m_fontservice.h>
#include <m_icolib.h>
#include <win2k.h>
+#include "resource.h"
#include "collection.h"
+#include "Version.h"
+#include "icmp.h"
+#include "log.h"
+#include "menu.h"
+#include "pinggraph.h"
+#include "pinglist.h"
+#include "pingthread.h"
+#include "rawping.h"
+#include "utils.h"
+
+#define MAX_HISTORY (1440) // 12 hrs at 30 sec intervals
+
+#define PLUG "PING"
+
+#define DEFAULT_PING_PERIOD 30
+#define DEFAULT_PING_TIMEOUT 2
+#define DEFAULT_SHOW_POPUP true
+#define DEFAULT_SHOW_POPUP2 false
+#define DEFAULT_BLOCK_REPS true
+#define DEFAULT_LOGGING_ENABLED false
+#define DEFAULT_LOG_FILENAME "ping_log.txt"
+#define DEFAULT_NO_TEST_ICON true
+#define DEFAULT_ATTACH_TO_CLIST false
+
+#define MAX_PINGADDRESS_STRING_LENGTH 256
+
typedef struct {
int ping_period, ping_timeout;
@@ -72,8 +71,6 @@ typedef struct {
bool log_csv;
} PingOptions;
-#pragma warning( disable : 4786 )
-
// a deque of pairs - ping time and timestamp
struct HistPair {
short first;
@@ -110,7 +107,10 @@ struct PINGADDRESS {
const bool operator<(const PINGADDRESS &b) const;
};
+#include "options.h"
typedef Map<DWORD, HistoryList> HistoryMap;
+typedef std::list<PINGADDRESS> PINGLIST;
+typedef std::list<PINGADDRESS>::iterator pinglist_it;
extern HANDLE hNetlibUser;
@@ -118,4 +118,19 @@ extern HINSTANCE hInst;
extern bool use_raw_ping;
+// wake event for ping thread
+extern HANDLE hWakeEvent;
+
+extern PingOptions options;
+extern PINGADDRESS add_edit_addr;
+extern HistoryMap history_map;
+extern PINGLIST list_items;
+extern HANDLE reload_event_handle;
+extern CRITICAL_SECTION list_cs;
+extern HANDLE mainThread;
+extern HANDLE hWakeEvent;
+extern CRITICAL_SECTION thread_finished_cs, list_changed_cs, data_list_cs;
+
+extern PINGLIST data_list;
+
#endif
diff --git a/plugins/Ping/src/icmp.cpp b/plugins/Ping/src/icmp.cpp
index af9a3605e4..bdf8776d22 100644
--- a/plugins/Ping/src/icmp.cpp
+++ b/plugins/Ping/src/icmp.cpp
@@ -1,10 +1,9 @@
#include "common.h"
-#include "icmp.h"
char data[] = "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHH";
ICMP *ICMP::instance = 0;
-#define BUFFER_SIZE (8 * (sizeof(ICMP_ECHO_REPLY) + sizeof(data)))
+#define BUFFER_SIZE (16 * (sizeof(ICMP_ECHO_REPLY) + sizeof(data)))
ICMP::ICMP():
timeout(2000),
@@ -30,8 +29,8 @@ ICMP::ICMP():
} else
DBWriteContactSettingString(0, PLUG, "PingLib", "IPHLPAPI.DLL"); // for debugging
- WSAData wsaData;
- if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
+ WSAData wsaData;
+ if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
WSACleanup();
FreeLibrary((HMODULE)hDLL);
return;
@@ -44,7 +43,7 @@ ICMP::ICMP():
return;
}
*/
-
+
buff = new char[BUFFER_SIZE];
functions_loaded = true;
}
@@ -60,21 +59,27 @@ ICMP::~ICMP() {
if(hIP) stop();
WSACleanup();
if(hDLL)
- FreeLibrary(hDLL);
+ FreeLibrary(hDLL);
delete[] buff;
}
-bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply) {
- if(!functions_loaded) return false;
+
+bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply)
+{
+ if (!functions_loaded)
+ return false;
HOSTENT *rec;
IP_OPTION_INFORMATION ipoi;
unsigned long address = inet_addr(host);
- if (address == INADDR_NONE) {
+ if (address == INADDR_NONE)
+ {
rec = gethostbyname(host);
- if(rec) address = *(unsigned long *)(*rec->h_addr_list);
- else return false;
+ if (rec != NULL)
+ address = *(unsigned long *)(*rec->h_addr_list);
+ else
+ return false;
}
ipoi.Ttl = 255;
@@ -83,15 +88,19 @@ bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply) {
ipoi.OptionsSize = 0;
ipoi.OptionsData = 0;
- reply.Status = 0;
+ reply.Status = 0;
hIP = pIcmpCreateFile();
- if (hIP == INVALID_HANDLE_VALUE) return false;
+ 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);
- if(pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, BUFFER_SIZE, timeout) == 0) {
+ DWORD rep_cnt = pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, BUFFER_SIZE, timeout);
+ if (rep_cnt == 0)
+ {
DWORD code = GetLastError();
- if(code != 11010) {
+ if (code != 11010)
+ {
char winmsg[512], msg[1024];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, code, 0, winmsg, 512, 0);
mir_snprintf(msg, 1024, "Ping error (%d): %s", code, winmsg);
diff --git a/plugins/Ping/src/icmp.h b/plugins/Ping/src/icmp.h
index 984fd88fe9..e3da22691b 100644
--- a/plugins/Ping/src/icmp.h
+++ b/plugins/Ping/src/icmp.h
@@ -3,32 +3,6 @@
#ifndef _ICMP_H
#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
- unsigned char Flags; // IP header flags
- unsigned char OptionsSize; // Size in bytes of options data
- unsigned char *OptionsData; // Pointer to options data
-} IP_OPTION_INFORMATION, * PIP_OPTION_INFORMATION;
-
-typedef struct {
- DWORD Address; // Replying address
- unsigned long Status; // Reply status
- unsigned long RoundTripTime; // RTT in milliseconds
- unsigned short DataSize; // Echo data size
- unsigned short Reserved; // Reserved for system use
- void *Data; // Pointer to the echo data
- IP_OPTION_INFORMATION Options; // Reply options
- 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, HANDLE, FARPROC, PVOID, IPAddr, LPVOID, WORD, PIP_OPTION_INFORMATION, LPVOID, DWORD, DWORD);
@@ -36,9 +10,9 @@ typedef DWORD (WINAPI* pfnDHDPWPipPDD)(HANDLE, HANDLE, FARPROC, PVOID, IPAddr, L
class ICMP {
protected:
pfnHV pIcmpCreateFile;
- pfnBH pIcmpCloseHandle;
- pfnDHDPWPipPDD pIcmpSendEcho2;
-
+ pfnBH pIcmpCloseHandle;
+ pfnDHDPWPipPDD pIcmpSendEcho2;
+
HMODULE hDLL;
HANDLE hIP;
diff --git a/plugins/Ping/src/log.cpp b/plugins/Ping/src/log.cpp
index de2889fde1..c95c49a910 100644
--- a/plugins/Ping/src/log.cpp
+++ b/plugins/Ping/src/log.cpp
@@ -1,5 +1,4 @@
#include "common.h"
-#include "log.h"
INT_PTR Log(WPARAM wParam, LPARAM lParam) {
diff --git a/plugins/Ping/src/log.h b/plugins/Ping/src/log.h
index 8fed816122..1930dddede 100644
--- a/plugins/Ping/src/log.h
+++ b/plugins/Ping/src/log.h
@@ -1,9 +1,6 @@
#ifndef _PING_LOG
#define _PING_LOG
-#pragma warning( disable : 4786 )
-#include "options.h"
-
INT_PTR Log(WPARAM wParam, LPARAM lParam);
INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam);
INT_PTR SetLogFilename(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Ping/src/menu.cpp b/plugins/Ping/src/menu.cpp
index 29b3d24696..2c8dc45bab 100644
--- a/plugins/Ping/src/menu.cpp
+++ b/plugins/Ping/src/menu.cpp
@@ -1,5 +1,4 @@
#include "common.h"
-#include "menu.h"
HANDLE hMenuDisable, hMenuGraph, hMenuEdit;
HANDLE hEventMenuBuild;
diff --git a/plugins/Ping/src/menu.h b/plugins/Ping/src/menu.h
index e6e1334885..314aa679c2 100644
--- a/plugins/Ping/src/menu.h
+++ b/plugins/Ping/src/menu.h
@@ -1,10 +1,6 @@
#ifndef _MENU_H
#define _MENU_H
-#include "pinglist.h"
-#include "pinggraph.h"
-#include "utils.h"
-
void InitMenus();
#endif
diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp
index 7660f00896..578c2a174f 100644
--- a/plugins/Ping/src/options.cpp
+++ b/plugins/Ping/src/options.cpp
@@ -1,5 +1,4 @@
#include "common.h"
-#include "options.h"
PingOptions options;
@@ -249,8 +248,10 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
}
}
- if ( HIWORD( wParam ) == BN_CLICKED ) {
- switch( LOWORD( wParam )) {
+ if ( HIWORD( wParam ) == BN_CLICKED )
+ {
+ switch( LOWORD( wParam ))
+ {
case IDC_CHK_DESTTCP:
hw = GetDlgItem(hwndDlg, IDC_ED_DESTPORT);
EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP));
@@ -262,7 +263,8 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
GetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_addr.pszParams, MAX_PATH);
hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTPROTO);
- if(SendMessage(hw, CB_GETCURSEL, 0, 0) != -1) {
+ if(SendMessage(hw, CB_GETCURSEL, 0, 0) != -1)
+ {
GetDlgItemText(hwndDlg, IDC_COMBO_DESTPROTO, add_edit_addr.pszProto, MAX_PINGADDRESS_STRING_LENGTH);
if(!strcmp(add_edit_addr.pszProto, Translate("<none>"))) add_edit_addr.pszProto[0] = '\0';
else {
@@ -278,7 +280,8 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
} else
add_edit_addr.pszProto[0] = '\0';
- if(IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP)) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP))
+ {
BOOL tr;
int port = GetDlgItemInt(hwndDlg, IDC_ED_DESTPORT, &tr, FALSE);
if(tr) add_edit_addr.port = port;
@@ -292,7 +295,7 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
EndDialog(hwndDlg, IDCANCEL);
break;
}
-
+
}
return TRUE;
@@ -300,17 +303,18 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
return FALSE;
}
-BOOL Edit(HWND hwnd, PINGADDRESS &addr) {
- if(&addr != NULL)
+bool Edit(HWND hwnd, PINGADDRESS &addr)
+{
+ add_edit_addr = addr;
+ if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK)
{
- add_edit_addr = addr;
- if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK) {
- addr = add_edit_addr;
- return TRUE;
- }
+ addr = add_edit_addr;
+ return true;
}
- return FALSE;
+
+ return false;
}
+
// ping hosts list window
static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -328,19 +332,22 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
Unlock(&data_list_cs);
hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
- for(PINGLIST::Iterator i = temp_list.start(); i.has_val(); i.next()) {
- int index = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i.val().pszLabel);
- SendMessage(hw, LB_SETITEMDATA, index, (LPARAM)&i.val());
+ for (pinglist_it i = temp_list.begin(); i != temp_list.end(); ++i)
+ {
+ int index = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->pszLabel);
+ SendMessage(hw, LB_SETITEMDATA, index, (LPARAM)&(*i));
}
}
return TRUE;
case WM_COMMAND:
- if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_DEST) {
+ if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_DEST)
+ {
hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
sel = SendMessage(hw, LB_GETCURSEL, 0, 0);
- if(sel != LB_ERR) {
+ if(sel != LB_ERR)
+ {
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM);
EnableWindow(hw, TRUE);
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT);
@@ -355,21 +362,25 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
}
}
- if ( HIWORD( wParam ) == BN_CLICKED ) {
- switch( LOWORD( wParam )) {
+ if ( HIWORD( wParam ) == BN_CLICKED )
+ {
+ switch( LOWORD( wParam ))
+ {
case IDC_BTN_DESTEDIT:
hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
sel = SendMessage(hw, LB_GETCURSEL, 0, 0);
- if(sel != LB_ERR) {
+ if (sel != LB_ERR)
+ {
PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel, 0);
PINGADDRESS temp = *item;
- if(Edit(hwndDlg, temp)) {
+ if (Edit(hwndDlg, temp))
+ {
*item = temp;
SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0);
SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)item->pszLabel);
SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel, (LPARAM)item);
SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0);
-
+
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM);
EnableWindow(hw, TRUE);
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT);
@@ -379,7 +390,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
EnableWindow(hw, (sel < count - 1));
-
+
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
}
}
@@ -393,15 +404,17 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
add_edit_addr.get_status = ID_STATUS_OFFLINE;
add_edit_addr.status = PS_NOTRESPONDING;
add_edit_addr.item_id = 0;
+ add_edit_addr.index = temp_list.size();
- if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK) {
-
- temp_list.add(add_edit_addr);
+ if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
+ {
+ temp_list.push_back(add_edit_addr);
hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
int index = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)add_edit_addr.pszLabel);
hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
SendMessage(hw, LB_SETCURSEL, (WPARAM)index, 0);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)index, (LPARAM)&(temp_list.back()));
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM);
EnableWindow(hw, TRUE);
@@ -415,7 +428,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
EnableWindow(hw, (sel < count - 1));
-
+
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
}
@@ -449,8 +462,8 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
*item2 = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2 + 1, 0);
if(item && item2)
{
- add_edit_addr = *item;
- *item = *item2;
+ add_edit_addr = *item;
+ *item = *item2;
*item2 = add_edit_addr;
// keep indexes the same, as they're used for sorting the binary tree
@@ -475,7 +488,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
}
- }
+ }
}
break;
case IDC_BTN_DESTUP:
@@ -488,8 +501,8 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (item && item2)
{
- add_edit_addr = *item;
- *item = *item2;
+ add_edit_addr = *item;
+ *item = *item2;
*item2 = add_edit_addr;
// keep indexes the same, as they're used for sorting the binary tree
@@ -513,10 +526,10 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
EnableWindow(hw, (sel2 - 1 < count - 1));
-
+
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
}
- }
+ }
}
break;
@@ -530,7 +543,8 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ if (((LPNMHDR)lParam)->code == PSN_APPLY )
+ {
CallService(PLUG "/SetAndSavePingList", (WPARAM)&temp_list, 0);
CallService(PLUG "/GetPingList", 0, (LPARAM)&temp_list);
// the following will be affected due to list rebuild event
@@ -567,7 +581,7 @@ int PingOptInit(WPARAM wParam,LPARAM lParam)
void LoadOptions() {
options.ping_period = DBGetContactSettingDword(NULL, PLUG, "PingPeriod", DEFAULT_PING_PERIOD);
-
+
options.ping_timeout = DBGetContactSettingDword(NULL, PLUG, "PingTimeout", DEFAULT_PING_TIMEOUT);
CallService(PLUG "/SetPingTimeout", (WPARAM)options.ping_timeout, 0);
options.show_popup = (DBGetContactSettingByte(NULL, PLUG, "ShowPopup", DEFAULT_SHOW_POPUP ? 1 : 0) == 1);
@@ -585,7 +599,7 @@ void LoadOptions() {
CallService(PLUG "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename);
ICMP::get_instance()->set_timeout(options.ping_timeout * 1000);
-
+
options.attach_to_clist = (DBGetContactSettingByte(NULL, PLUG, "AttachToClist", DEFAULT_ATTACH_TO_CLIST ? 1 : 0) == 1);
options.log_csv = (DBGetContactSettingByte(NULL, PLUG, "LogCSV", 0) == 1);
}
diff --git a/plugins/Ping/src/options.h b/plugins/Ping/src/options.h
index 1963649bfb..8ea876a40f 100644
--- a/plugins/Ping/src/options.h
+++ b/plugins/Ping/src/options.h
@@ -1,24 +1,11 @@
#ifndef _PING_OPTIONS
#define _PING_OPTIONS
-#include "pinglist.h"
-#include "utils.h"
-#include "icmp.h"
-#include "pingthread.h"
-
-#include "resource.h"
-
-// wake event for ping thread
-extern HANDLE hWakeEvent;
-
-extern PingOptions options;
-extern PINGADDRESS add_edit_addr;
-
INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
int PingOptInit(WPARAM wParam,LPARAM lParam);
-BOOL Edit(HWND hwnd, PINGADDRESS &addr);
+bool Edit(HWND hwnd, PINGADDRESS &addr);
void LoadOptions();
void SaveOptions();
diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp
index 7e3863ae81..347f1930c8 100644
--- a/plugins/Ping/src/ping.cpp
+++ b/plugins/Ping/src/ping.cpp
@@ -1,6 +1,5 @@
#include "common.h"
-#include "ping.h"
-#include <list>
+
HINSTANCE hInst;
int hLangpack = 0;
@@ -12,15 +11,15 @@ bool use_raw_ping = true;
// plugin stuff
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
- "Ping Plugin",
- PLUGIN_MAKE_VERSION(0, 9, 1, 1),
- "Ping labelled IP addresses or domain names.",
- "Scott Ellis",
- "mail@scottellis.com.au",
- "© 2005 Scott Ellis",
- "http://www.scottellis.com.au/",
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
UNICODE_AWARE,
- // {760EA901-C0C2-446c-8029-94C3BC47C45E}
+ // {760EA901-C0C2-446C-8029-94C3BC47C45E}
{0x760ea901, 0xc0c2, 0x446c, {0x80, 0x29, 0x94, 0xc3, 0xbc, 0x47, 0xc4, 0x5e}}
};
@@ -70,13 +69,13 @@ int OnShutdown(WPARAM wParam, LPARAM lParam) {
UnhookEvent(hFillListEvent);
+ DeinitList();
+
if(use_raw_ping)
cleanup_raw_ping();
else
ICMP::cleanup();
- DeinitList();
-
return 0;
}
@@ -99,7 +98,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
InitUtils();
InitMenus();
-
+
hFillListEvent = HookEvent(PLUG "/ListReload", FillList);
if(!DBGetContactSettingByte(0, PLUG, "PingPlugImport", 0)) {
@@ -111,8 +110,8 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
InitList();
- CallService(PLUG "/LoadPingList", 0, 0);
-
+ CallService(PLUG "/LoadPingList", 0, 0);
+
graphs_init();
if(options.logging) CallService(PLUG "/Log", (WPARAM)"start", 0);
@@ -136,7 +135,7 @@ extern "C" __declspec(dllexport) int Load(void)
InitializeCriticalSection(&thread_finished_cs);
InitializeCriticalSection(&list_changed_cs);
InitializeCriticalSection(&data_list_cs);
-
+
// create services before loading options - so we can have the 'getlogfilename' service!
CreatePluginServices();
@@ -145,7 +144,7 @@ extern "C" __declspec(dllexport) int Load(void)
SkinAddNewSound("PingTimeout", "Ping Timout", 0);
SkinAddNewSound("PingReply", "Ping Reply", 0);
- HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
HookEvent(ME_OPT_INITIALISE, PingOptInit );
diff --git a/plugins/Ping/src/ping.h b/plugins/Ping/src/ping.h
deleted file mode 100644
index b45586914d..0000000000
--- a/plugins/Ping/src/ping.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-Based on the
-Miranda plugin template, originally by Richard Hughes
-http://miranda-icq.sourceforge.net/
-
-© 2004 Scott Ellis
-
-*/
-
-// The following ifdef block is the standard way of creating macros which make exporting
-// from a DLL simpler. All files within this DLL are compiled with the PINGPROTO_EXPORTS
-// symbol defined on the command line. this symbol should not be defined on any project
-// that uses this DLL. This way any other project whose source files include this file see
-// PINGPROTO_API functions as being imported from a DLL, wheras this DLL sees symbols
-// defined with this macro as being exported.
-
-#include "utils.h"
-#include "options.h"
-#include "pinglist.h"
-#include "log.h"
-#include "pingthread.h"
-#include "menu.h"
-#include "rawping.h"
diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp
index 30d5d6c2df..c7edf260ef 100644
--- a/plugins/Ping/src/pinggraph.cpp
+++ b/plugins/Ping/src/pinggraph.cpp
@@ -1,5 +1,4 @@
#include "common.h"
-#include "pinggraph.h"
HistoryMap history_map;
@@ -25,8 +24,8 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
bool found = false;
EnterCriticalSection(&data_list_cs);
- for(PINGLIST::Iterator i = data_list.start(); i.has_val(); i.next()) {
- if(i.val().item_id == wd->item_id) {
+ for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i) {
+ if(i->item_id == wd->item_id) {
wd->list = history_map[wd->item_id];
found = true;
break;
@@ -86,23 +85,31 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
HDC hdc;
RECT r;
WindowData *wd = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if(wd && (hdc = BeginPaint(hwnd, &ps)) != 0) {
+ if (wd && (hdc = BeginPaint(hwnd, &ps)) != 0)
+ {
GetClientRect(hwnd, &r);
FillRect(hdc, &r, GetSysColorBrush(COLOR_WINDOW));
short max_value = -1, min_value = (short)0x7FFF,
graph_height = 0; // this is minimum graph height, in ms
+
double avg = 0;
- for(HistoryList::Iterator hli = wd->list.start(); hli.has_val(); hli.next()) {
- if(hli.val().first > max_value) max_value = hli.val().first;
- if(hli.val().first >= 0 && hli.val().first < min_value) min_value = hli.val().first;
+ for(HistoryList::Iterator hli = wd->list.begin(); hli.has_val(); hli.next())
+ {
+ if (hli.val().first > max_value)
+ max_value = hli.val().first;
+ if (hli.val().first >= 0 && hli.val().first < min_value)
+ min_value = hli.val().first;
avg += hli.val().first;
}
- if(wd->list.size())
+
+ if (wd->list.size())
avg /= wd->list.size();
graph_height = (int)(max_value * 1.2f);
- if(graph_height < MIN_GRAPH_HEIGHT) graph_height = MIN_GRAPH_HEIGHT;
+
+ if(graph_height < MIN_GRAPH_HEIGHT)
+ graph_height = MIN_GRAPH_HEIGHT;
#ifdef max
float unit_width = (r.right - r.left) / (float)max((int)wd->list.size(), MIN_BARS), // space for at least MIN_BARS bars
@@ -113,7 +120,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
time_t last_time = 0, time, start_time = 0;
if(wd->list.size())
- start_time = wd->list.start().val().second;
+ start_time = wd->list.begin().val().second;
RECT bar;
bar.bottom = r.bottom;
@@ -125,15 +132,18 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
HPEN hPenOld, hPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW));
hPenOld = (HPEN)SelectObject(hdc, hPen);
- for(HistoryList::Iterator hi = wd->list.start(); hi.has_val(); hi.next()) {
- if(hi.val().first != -1) {
+ for(HistoryList::Iterator hi = wd->list.begin(); hi.has_val(); hi.next())
+ {
+ if(hi.val().first != -1)
+ {
bar.top = bar.bottom - (int)(hi.val().first * unit_height + 0.5f);
FillRect(hdc, &bar, GetSysColorBrush(COLOR_HOTLIGHT));
}
time = hi.val().second - start_time;
-
- if(time / MARK_PERIOD != last_time / MARK_PERIOD) { // new minute
+
+ if(time / MARK_PERIOD != last_time / MARK_PERIOD)
+ { // new minute
MoveToEx(hdc, bar.left, r.bottom, 0);
LineTo(hdc, bar.left, r.top);
}
@@ -145,20 +155,24 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
bar.right = (int)(x + unit_width + 0.5f);
}
- if(wd->show_grid) {
+ if(wd->show_grid)
+ {
// draw horizontal lines to mark every 100ms
- for(int li = 0; li < graph_height; li += MARK_TIME) {
+ for(int li = 0; li < graph_height; li += MARK_TIME)
+ {
MoveToEx(hdc, r.left, r.bottom - (int)(li * unit_height + 0.5f), 0);
LineTo(hdc, r.right, r.bottom - (int)(li * unit_height + 0.5f));
}
}
-
+
HPEN hPen2 = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
- if(wd->show_stat) {
+ if(wd->show_stat)
+ {
SelectObject(hdc, hPen2);
MoveToEx(hdc, r.left, r.bottom - (int)(avg * unit_height + 0.5f), 0);
LineTo(hdc, r.right, r.bottom - (int)(avg * unit_height + 0.5f));
- if(max_value != avg) {
+ if (max_value != avg)
+ {
MoveToEx(hdc, r.left, r.bottom - (int)(max_value * unit_height + 0.5f), 0);
LineTo(hdc, r.right, r.bottom - (int)(max_value * unit_height + 0.5f));
MoveToEx(hdc, r.left, r.bottom - (int)(min_value * unit_height + 0.5f), 0);
@@ -174,16 +188,19 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, GetSysColor(COLOR_3DDKSHADOW));
char buff[64];
- if(wd->show_grid) {
+ if(wd->show_grid)
+ {
sprintf(buff, Translate("%d ms"), MARK_TIME);
TextOut(hdc, r.right - 100, r.bottom - (int)(unit_height * MARK_TIME + 0.5f), buff, strlen(buff));
}
- if(wd->show_stat) {
+ if (wd->show_stat)
+ {
SetTextColor(hdc, RGB(255, 0, 0));
sprintf(buff, Translate("AVG %.1lf ms"), avg);
TextOut(hdc, r.left + 10, r.bottom - (int)(avg * unit_height + 0.5f), buff, strlen(buff));
- if(max_value != avg) {
+ if (max_value != avg)
+ {
sprintf(buff, Translate("MAX %hd ms"), max_value);
TextOut(hdc, r.left + 10, r.bottom - (int)(max_value * unit_height + 0.5f), buff, strlen(buff));
sprintf(buff, Translate("MIN %hd ms"), min_value);
@@ -247,16 +264,16 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) {
}
WNDCLASS wndclass;
- wndclass.style = 0;
- wndclass.lpfnWndProc = GraphWindowProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
- wndclass.hIcon = hIconResponding;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = _T(PLUG) _T("GraphWindow");
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = GraphWindowProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = hIconResponding;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = _T(PLUG) _T("GraphWindow");
RegisterClass(&wndclass);
char title[256];
@@ -313,13 +330,13 @@ void graphs_init() {
PINGLIST pl;
char buff[64];
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
- for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
- sprintf(buff, "WindowHandle%d", i.val().item_id); // clean up from possible crash
+ for(pinglist_it i = pl.begin(); i != pl.end(); ++i) {
+ sprintf(buff, "WindowHandle%d", i->item_id); // clean up from possible crash
DBWriteContactSettingDword(0, PLUG, buff, 0);
- sprintf(buff, "WindowWasOpen%d", i.val().item_id); // restore windows that were open on shutdown
+ sprintf(buff, "WindowWasOpen%d", i->item_id); // restore windows that were open on shutdown
if(DBGetContactSettingByte(0, PLUG, buff, 0)) {
DBWriteContactSettingByte(0, PLUG, buff, 0);
- ShowGraph((WPARAM)i.val().item_id, (LPARAM)i.val().pszLabel);
+ ShowGraph((WPARAM)i->item_id, (LPARAM)i->pszLabel);
}
}
}
diff --git a/plugins/Ping/src/pinggraph.h b/plugins/Ping/src/pinggraph.h
index 268b376a58..50b6040c98 100644
--- a/plugins/Ping/src/pinggraph.h
+++ b/plugins/Ping/src/pinggraph.h
@@ -1,9 +1,6 @@
#ifndef _PINGGRAPH_H
#define _PINGGRAPH_H
-#include "pinglist.h"
-#include "pingthread.h"
-
#define MIN_GRAPH_HEIGHT 10 // minimum braph height, ms
#define MIN_BARS 20 // space for at least this many bars
#define MARK_PERIOD 3600 // vertical lines every this many secs (3600 == 1 hour)
@@ -17,6 +14,4 @@ void graphs_cleanup();
// restore windows that were open when cleanup was called last?
void graphs_init();
-extern HistoryMap history_map;
-
#endif
diff --git a/plugins/Ping/src/pinglist.cpp b/plugins/Ping/src/pinglist.cpp
index 91d00f97af..45873da685 100644
--- a/plugins/Ping/src/pinglist.cpp
+++ b/plugins/Ping/src/pinglist.cpp
@@ -1,7 +1,4 @@
#include "common.h"
-#include "pinglist.h"
-
-#include "options.h"
PINGLIST list_items;
CRITICAL_SECTION list_cs;
@@ -11,19 +8,26 @@ DWORD NextID = 1;
BOOL clist_handle_changing = FALSE;
-BOOL changing_clist_handle() {
+BOOL changing_clist_handle()
+{
return clist_handle_changing;
}
-void set_changing_clist_handle(BOOL flag) {
+
+void set_changing_clist_handle(BOOL flag)
+{
clist_handle_changing = flag;
}
-const bool PINGADDRESS::operator==(const PINGADDRESS &b) const {
+
+const bool PINGADDRESS::operator==(const PINGADDRESS &b) const
+{
return index == b.index;
}
-const bool PINGADDRESS::operator<(const PINGADDRESS &b) const {
+
+const bool PINGADDRESS::operator<(const PINGADDRESS &b) const
+{
return index < b.index;
}
@@ -40,7 +44,8 @@ INT_PTR GetPingList(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR GetListSize(WPARAM wParam, LPARAM lParam) {
+INT_PTR GetListSize(WPARAM wParam, LPARAM lParam)
+{
INT_PTR ret = 0;
EnterCriticalSection(&list_cs);
ret = list_items.size();
@@ -48,40 +53,44 @@ INT_PTR GetListSize(WPARAM wParam, LPARAM lParam) {
return ret;
}
-void write_ping_address(PINGADDRESS *i) {
+
+void write_ping_address(PINGADDRESS &i)
+{
char buff[16];
- sprintf(buff, "PING_DEST_%d", i->index);
+ sprintf(buff, "PING_DEST_%d", i.index);
- if(i->item_id == 0) {
- i->item_id = NextID++;
+ if(i.item_id == 0) {
+ i.item_id = NextID++;
DBWriteContactSettingDword(0, PLUG, "NextID", NextID);
}
- DBWriteContactSettingDword(0, buff, "Id", i->item_id);
- DBWriteContactSettingString(0, buff, "Address", i->pszName);
- DBWriteContactSettingString(0, buff, "Label", i->pszLabel);
- DBWriteContactSettingWord(0, buff, "Status", i->status);
- DBWriteContactSettingDword(0, buff, "Port", i->port);
- DBWriteContactSettingString(0, buff, "Proto", i->pszProto);
- if(strlen(i->pszCommand))
- DBWriteContactSettingString(0, buff, "Command", i->pszCommand);
+ DBWriteContactSettingDword(0, buff, "Id", i.item_id);
+ DBWriteContactSettingString(0, buff, "Address", i.pszName);
+ DBWriteContactSettingString(0, buff, "Label", i.pszLabel);
+ DBWriteContactSettingWord(0, buff, "Status", i.status);
+ DBWriteContactSettingDword(0, buff, "Port", i.port);
+ DBWriteContactSettingString(0, buff, "Proto", i.pszProto);
+ if(strlen(i.pszCommand))
+ DBWriteContactSettingString(0, buff, "Command", i.pszCommand);
else
DBDeleteContactSetting(0, buff, "Command");
- if(strlen(i->pszParams))
- DBWriteContactSettingString(0, buff, "CommandParams", i->pszParams);
+ if(strlen(i.pszParams))
+ DBWriteContactSettingString(0, buff, "CommandParams", i.pszParams);
else
DBDeleteContactSetting(0, buff, "CommandParams");
- DBWriteContactSettingWord(0, buff, "SetStatus", i->set_status);
- DBWriteContactSettingWord(0, buff, "GetStatus", i->get_status);
- DBWriteContactSettingWord(0, buff, "Index", i->index);
+ DBWriteContactSettingWord(0, buff, "SetStatus", i.set_status);
+ DBWriteContactSettingWord(0, buff, "GetStatus", i.get_status);
+ DBWriteContactSettingWord(0, buff, "Index", i.index);
}
// call with list_cs locked
-void write_ping_addresses() {
+void write_ping_addresses()
+{
int index = 0;
- for(PINGLIST::Iterator i = list_items.start(); i.has_val(); i.next(), index++) {
- i.val().index = index;
- write_ping_address(&i.val());
+ for(pinglist_it i = list_items.begin(); i != list_items.end(); ++i, index++)
+ {
+ i->index = index;
+ write_ping_address(*i);
}
// mark further destinations in the DB as invalid
@@ -157,73 +166,79 @@ bool read_ping_address(PINGADDRESS &pa) {
}
// call with list_cs locked
-void read_ping_addresses() {
+void read_ping_addresses()
+{
PINGADDRESS pa;
-
pa.index = 0;
-
list_items.clear();
- while(read_ping_address(pa)) {
- list_items.add(pa);
- pa.index++;
+ while (read_ping_address(pa))
+ {
+ list_items.push_back(pa);
+ ++pa.index;
}
}
-INT_PTR LoadPingList(WPARAM wParam, LPARAM lParam) {
+
+INT_PTR LoadPingList(WPARAM wParam, LPARAM lParam)
+{
EnterCriticalSection(&list_cs);
read_ping_addresses();
LeaveCriticalSection(&list_cs);
- NotifyEventHooks(reload_event_handle, 0, 0);
+ NotifyEventHooks(reload_event_handle, 0, 0);
return 0;
}
// wParam is zero
// lParam is zero
-INT_PTR SavePingList(WPARAM wParam, LPARAM lParam) {
+INT_PTR SavePingList(WPARAM wParam, LPARAM lParam)
+{
EnterCriticalSection(&list_cs);
write_ping_addresses();
LeaveCriticalSection(&list_cs);
//NotifyEventHooks(reload_event_handle, 0, 0);
-
+
return 0;
}
// wParam is address of a PINGLIST structure to replace the current one
// lParam is zero
-INT_PTR SetPingList(WPARAM wParam, LPARAM lParam) {
+INT_PTR SetPingList(WPARAM wParam, LPARAM lParam)
+{
PINGLIST *pli = (PINGLIST *)wParam;
-
+
EnterCriticalSection(&list_cs);
list_items = *pli;
LeaveCriticalSection(&list_cs);
NotifyEventHooks(reload_event_handle, 0, 0);
-
+
return 0;
}
// wParam is address of a PINGLIST structure to replace the current one
// lParam is zero
-INT_PTR SetAndSavePingList(WPARAM wParam, LPARAM lParam) {
+INT_PTR SetAndSavePingList(WPARAM wParam, LPARAM lParam)
+{
PINGLIST *pli = (PINGLIST *)wParam;
-
+
EnterCriticalSection(&list_cs);
// set new list
list_items = *pli;
write_ping_addresses();
LeaveCriticalSection(&list_cs);
-
+
NotifyEventHooks(reload_event_handle, 0, 0);
-
+
return 0;
}
-INT_PTR ClearPingList(WPARAM wParam, LPARAM lParam) {
+INT_PTR ClearPingList(WPARAM wParam, LPARAM lParam)
+{
EnterCriticalSection(&list_cs);
list_items.clear();
LeaveCriticalSection(&list_cs);
-
+
NotifyEventHooks(reload_event_handle, 0, 0);
return 0;
}
diff --git a/plugins/Ping/src/pinglist.h b/plugins/Ping/src/pinglist.h
index ed2a94810f..4766c8e115 100644
--- a/plugins/Ping/src/pinglist.h
+++ b/plugins/Ping/src/pinglist.h
@@ -1,14 +1,6 @@
#ifndef _PINGLIST_H
#define _PINGLIST_H
-typedef BinaryTree<PINGADDRESS> PINGLIST;
-
-#include <algorithm> // for sort
-
-extern PINGLIST list_items;
-extern HANDLE reload_event_handle;
-extern CRITICAL_SECTION list_cs;
-
INT_PTR LoadPingList(WPARAM wParam, LPARAM lParam);
INT_PTR GetPingList(WPARAM wParam,LPARAM lParam);
INT_PTR SavePingList(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index 06bba39044..415f9d7fcc 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -1,5 +1,4 @@
#include "common.h"
-#include "pingthread.h"
int upCount, total = 0;
@@ -91,12 +90,12 @@ void SetProtoStatus(char *pszLabel, char *pszProto, int if_status, int new_statu
DWORD WINAPI sttCheckStatusThreadProc( void *vp)
{
clock_t start_t = clock(), end_t;
- while(!get_thread_finished()) {
-
+ while (!get_thread_finished())
+ {
end_t = clock();
int wait = (int)((options.ping_period - ((end_t - start_t) / (double)CLOCKS_PER_SEC)) * 1000);
- if(wait > 0)
+ if (wait > 0)
WaitForSingleObjectEx(hWakeEvent, wait, TRUE);
if(get_thread_finished()) break;
@@ -116,21 +115,24 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
Unlock(&data_list_cs);
int index = 0;
- for(; index < size; index++) {
+ for(; index < size; index++)
+ {
Lock(&data_list_cs, "ping thread loop start");
int c = 0;
- for(PINGLIST::Iterator i = data_list.start(); i.has_val() && c <= index; i.next(), c++) {
- if(c == index) {
+ for (pinglist_it i = data_list.begin(); i != data_list.end() && c <= index; ++i, c++)
+ {
+ if (c == index)
+ {
// copy just what we need - i.e. not history, not command
- pa.get_status = i.val().get_status;
- pa.item_id = i.val().item_id;
- pa.miss_count = i.val().miss_count;
- pa.port = i.val().port;
- strcpy(pa.pszLabel, i.val().pszLabel);
- strcpy(pa.pszName, i.val().pszName);
- strcpy(pa.pszProto, i.val().pszProto);
- pa.set_status = i.val().set_status;
- pa.status = i.val().status;
+ pa.get_status = i->get_status;
+ pa.item_id = i->item_id;
+ pa.miss_count = i->miss_count;
+ pa.port = i->port;
+ strcpy(pa.pszLabel, i->pszLabel);
+ strcpy(pa.pszName, i->pszName);
+ strcpy(pa.pszProto, i->pszProto);
+ pa.set_status = i->set_status;
+ pa.status = i->status;
break;
}
@@ -143,9 +145,11 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
if(pa.status != PS_DISABLED) {
if(!options.no_test_icon) {
Lock(&data_list_cs, "ping thread loop start");
- for(PINGLIST::Iterator i = data_list.start(); i.has_val(); i.next()) {
- if(i.val().item_id == pa.item_id) {
- i.val().status = PS_TESTING;
+ for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
+ {
+ if(i->item_id == pa.item_id)
+ {
+ i->status = PS_TESTING;
}
}
Unlock(&data_list_cs);
@@ -158,44 +162,49 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
if(get_list_changed()) break;
Lock(&data_list_cs, "ping thread loop start");
- for(PINGLIST::Iterator i = data_list.start(); i.has_val(); i.next()) {
- if(i.val().item_id == pa.item_id) {
- i.val().responding = pa.responding;
- i.val().round_trip_time = pa.round_trip_time;
- history_entry.first = i.val().round_trip_time;
+ for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
+ {
+ if(i->item_id == pa.item_id)
+ {
+ i->responding = pa.responding;
+ i->round_trip_time = pa.round_trip_time;
+ history_entry.first = i->round_trip_time;
history_entry.second = time(0);
- history_map[i.val().item_id].push_back(history_entry);
+ history_map[i->item_id].push_back(history_entry);
// maintain history (-1 represents no response)
- while(history_map[i.val().item_id].size() >= MAX_HISTORY)
- //history_map[i.val().item_id].pop_front();
- history_map[i.val().item_id].remove(history_map[i.val().item_id].start().val());
+ while(history_map[i->item_id].size() >= MAX_HISTORY)
+ //history_map[i->item_id].pop_front();
+ history_map[i->item_id].remove(history_map[i->item_id].begin().val());
- if(pa.responding) {
+ if(pa.responding)
+ {
if(pa.miss_count > 0)
pa.miss_count = -1;
else
pa.miss_count--;
pa.status = PS_RESPONDING;
}
- else {
+ else
+ {
if(pa.miss_count < 0)
pa.miss_count = 1;
else
pa.miss_count++;
pa.status = PS_NOTRESPONDING;
}
- i.val().miss_count = pa.miss_count;
- i.val().status = pa.status;
+
+ i->miss_count = pa.miss_count;
+ i->status = pa.status;
break;
}
}
Unlock(&data_list_cs);
- if(pa.responding) {
+ if(pa.responding) {
count++;
- if(pa.miss_count == -1 - options.retries ||
+ if(pa.miss_count == -1 - options.retries ||
(((-pa.miss_count) % (options.retries + 1)) == 0 && !options.block_reps))
{
reply = true;
@@ -211,7 +220,7 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
SetProtoStatus(pa.pszLabel, pa.pszProto, pa.get_status, pa.set_status);
} else {
- if(pa.miss_count == 1 + options.retries ||
+ if(pa.miss_count == 1 + options.retries ||
((pa.miss_count % (options.retries + 1)) == 0 && !options.block_reps))
{
timeout = true;
@@ -283,8 +292,9 @@ int FillList(WPARAM wParam, LPARAM lParam) {
SendMessage(list_hwnd, LB_RESETCONTENT, 0, 0);
int index = 0;
- for(PINGLIST::Iterator j = data_list.start(); j.has_val(); j.next(), index++) {
- SendMessage(list_hwnd, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&j.val());
+ for(pinglist_it j = data_list.begin(); j != data_list.end(); ++j, index++)
+ {
+ SendMessage(list_hwnd, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&(*j));
}
set_list_changed(true);
@@ -303,12 +313,14 @@ int FillList(WPARAM wParam, LPARAM lParam) {
return 0;
}
-INT_PTR PingPlugShowWindow(WPARAM wParam, LPARAM lParam) {
- if(hpwnd) {
- if(frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_SHFRAME)) CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
- else {
+INT_PTR PingPlugShowWindow(WPARAM wParam, LPARAM lParam)
+{
+ if(hpwnd)
+ {
+ if (frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_SHFRAME))
+ CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
+ else
ShowWindow(hpwnd, IsWindowVisible(hpwnd) ? SW_HIDE : SW_SHOW);
- }
}
return 0;
}
@@ -321,9 +333,10 @@ void CALLBACK TimerProc(
DWORD dwTime // current system time
)
{
- if(frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if(frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+ {
char TBcapt[255];
- if(total > 0)
+ if (total > 0)
wsprintf(TBcapt,"Ping (%d/%d)", upCount, total);
else
wsprintf(TBcapt,"Ping");
@@ -383,7 +396,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
GetClientRect(hwnd, &r);
- if((dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS)
+ 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 = DBGetContactSettingDword(NULL,"CLC","SelBkColour", GetSysColor(COLOR_HIGHLIGHT));
@@ -438,7 +451,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return (BOOL)(tbrush = CreateSolidBrush(bk_col));
}
- case WM_ERASEBKGND:
+ case WM_ERASEBKGND:
{
RECT r;
GetClientRect(hwnd, &r);
@@ -509,9 +522,9 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_CREATE:
- list_hwnd = CreateWindow("LISTBOX", "",
- //(WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT| LBS_STANDARD | WS_CLIPCHILDREN | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY)
- (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY)
+ list_hwnd = CreateWindow("LISTBOX", "",
+ //(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, NULL, hInst,0);
if (DBGetContactSettingByte(NULL,"CList","Transparent",0))
@@ -595,7 +608,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return FALSE;
case WM_SHOWWINDOW:
- { static int noRecurse=0;
+ {
+ static int noRecurse=0;
if(lParam) break;
if(noRecurse) break;
if(!DBGetContactSettingByte(NULL,"CLUI","FadeInOut",0) || !IsWinVer2000Plus()) break;
@@ -658,7 +672,6 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
//DeleteObject(brush);
EndPaint(hwnd, &paintStruct); //
-
};
return TRUE;
@@ -877,7 +890,6 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return(TRUE);
};
-
int ReloadFont(WPARAM wParam, LPARAM lParam) {
if(hFont) DeleteObject(hFont);
@@ -920,12 +932,8 @@ void UpdateFrame() {
WNDPROC wpOrigClistProc;
-// Subclass procedure
-LRESULT APIENTRY ClistSubclassProc(
- HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
+// Subclass procedure
+LRESULT APIENTRY ClistSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if(uMsg == WM_SIZE || uMsg == WM_MOVE)
UpdateFrame();
@@ -944,10 +952,11 @@ LRESULT APIENTRY ClistSubclassProc(
ShowWindow(hpwnd, wParam);
}
- return CallWindowProc(wpOrigClistProc, hwnd, uMsg, wParam, lParam);
+ return CallWindowProc(wpOrigClistProc, hwnd, uMsg, wParam, lParam);
}
-void AttachToClist(bool attach) {
+void AttachToClist(bool attach)
+{
if(!hpwnd) return;
if(attach) {
@@ -968,8 +977,8 @@ void AttachToClist(bool attach) {
}
}
-void InitList() {
-
+void InitList()
+{
hUserDll = LoadLibrary(_T("user32.dll"));
if (hUserDll) {
MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
@@ -980,16 +989,16 @@ void InitList() {
WNDCLASS wndclass;
- wndclass.style = 0;
- wndclass.lpfnWndProc = FrameWindowProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
- wndclass.hIcon = hIconResponding;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = _T(PLUG) _T("WindowClass");
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = FrameWindowProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = hIconResponding;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = _T(PLUG) _T("WindowClass");
RegisterClass(&wndclass);
if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
@@ -1003,7 +1012,6 @@ void InitList() {
frame.Flags=F_VISIBLE | F_SHOWTB | F_SHOWTBTIP;
frame.height=30;
frame.TBname=Translate("Ping");
- frame.hIcon = hIconResponding;
frame_id=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&frame,0);
} else {
@@ -1036,7 +1044,7 @@ void InitList() {
strncpy(font_id.dbSettingsGroup, "PING", sizeof(font_id.dbSettingsGroup));
strncpy(font_id.prefix, "Font", sizeof(font_id.prefix));
_tcsncpy(font_id.backgroundGroup, _T("Ping"), SIZEOF(font_id.backgroundGroup));
- _tcsncpy(font_id.backgroundName ,_T("Background"), SIZEOF(font_id.backgroundName));
+ _tcsncpy(font_id.backgroundName, _T("Background"), SIZEOF(font_id.backgroundName));
font_id.order = 0;
FontRegisterT(&font_id);
diff --git a/plugins/Ping/src/pingthread.h b/plugins/Ping/src/pingthread.h
index eda6dae61f..37b50e308c 100644
--- a/plugins/Ping/src/pingthread.h
+++ b/plugins/Ping/src/pingthread.h
@@ -1,17 +1,6 @@
#ifndef _PINGTHREAD_H
#define _PINGTHREAD_H
-#include "pinglist.h"
-#include "pinggraph.h"
-#include "utils.h"
-#include "options.h"
-
-extern HANDLE mainThread;
-extern HANDLE hWakeEvent;
-extern CRITICAL_SECTION thread_finished_cs, list_changed_cs, data_list_cs;
-
-extern PINGLIST data_list;
-
int FillList(WPARAM wParam, LPARAM lParam);
int RefreshWindow(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp
index c5289dd16f..6b0f152d94 100644
--- a/plugins/Ping/src/rawping.cpp
+++ b/plugins/Ping/src/rawping.cpp
@@ -1,30 +1,24 @@
#include "common.h"
-#include "rawping.h"
-//#define _WSPIAPI_COUNTOF
-#ifndef _MSC_VER
-#include <ws2tcpip.h>
-#endif
-
-USHORT ip_checksum(USHORT* buffer, int size)
+USHORT ip_checksum(USHORT* buffer, int size)
{
- unsigned long cksum = 0;
-
- // Sum all the words together, adding the final byte if size is odd
- while (size > 1) {
- cksum += *buffer++;
- size -= sizeof(USHORT);
- }
- if (size) {
- cksum += *(UCHAR*)buffer;
- }
-
- // Do a little shuffling
- cksum = (cksum >> 16) + (cksum & 0xffff);
- cksum += (cksum >> 16);
-
- // Return the bitwise complement of the resulting mishmash
- return (USHORT)(~cksum);
+ unsigned long cksum = 0;
+
+ // Sum all the words together, adding the final byte if size is odd
+ while (size > 1) {
+ cksum += *buffer++;
+ size -= sizeof(USHORT);
+ }
+ if (size) {
+ cksum += *(UCHAR*)buffer;
+ }
+
+ // Do a little shuffling
+ cksum = (cksum >> 16) + (cksum & 0xffff);
+ cksum += (cksum >> 16);
+
+ // Return the bitwise complement of the resulting mishmash
+ return (USHORT)(~cksum);
}
SOCKET sd = -1;
@@ -33,38 +27,38 @@ char recv_buff[1024];
USHORT seq_no = 0;
bool inited = false;
-extern int init_raw_ping() {
- WSAData wsaData;
- if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
+extern int init_raw_ping()
+{
+ WSAData wsaData;
+ if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
WSACleanup();
return 1;
- }
+ }
if(sd != -1)
closesocket(sd);
- // Create the socket
- //sd = WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, 0, 0, 0);
+ // Create the socket
+ //sd = WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, 0, 0, 0);
sd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
- if (sd == INVALID_SOCKET) {
- return 2;
- }
+ if (sd == INVALID_SOCKET) {
+ return 2;
+ }
int ttl = 255;
- if (setsockopt(sd, IPPROTO_IP, IP_TTL, (const char*)&ttl, sizeof(ttl)) == SOCKET_ERROR) {
- return 3;
- }
+ if (setsockopt(sd, IPPROTO_IP, IP_TTL, (const char*)&ttl, sizeof(ttl)) == SOCKET_ERROR) {
+ return 3;
+ }
int our_recv_timeout = 100; // so we ca do multiple recv calls
if(setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&our_recv_timeout, sizeof(int)) == SOCKET_ERROR) {
return 4;
}
-
ICMPHeader *header = (ICMPHeader *)packet;
- header->type = PT_ICMP_ECHO_REQUEST;
- header->code = 0;
- header->id = (USHORT)GetCurrentProcessId();
+ header->type = PT_ICMP_ECHO_REQUEST;
+ header->code = 0;
+ header->id = (USHORT)GetCurrentProcessId();
inited = true;
if(raw_ping("127.0.0.1", 500) >= 0) {
@@ -75,40 +69,41 @@ extern int init_raw_ping() {
return 5;
}
-extern int raw_ping(char *host, int timeout) {
+extern int raw_ping(char *host, int timeout)
+{
if(!inited) return -1;
- // Initialize the destination host info block
+ // Initialize the destination host info block
sockaddr_in dest;
- memset(&dest, 0, sizeof(dest));
-
- // Turn first passed parameter into an IP address to ping
- unsigned int addr = inet_addr(host);
- if (addr != INADDR_NONE) {
- // It was a dotted quad number, so save result
- dest.sin_addr.s_addr = addr;
- dest.sin_family = AF_INET;
- }
- else {
- // Not in dotted quad form, so try and look it up
- hostent* hp = gethostbyname(host);
- if (hp != 0) {
- // Found an address for that host, so save it
- memcpy(&(dest.sin_addr), hp->h_addr, hp->h_length);
- //dest.sin_family = hp->h_addrtype;
+ memset(&dest, 0, sizeof(dest));
+
+ // Turn first passed parameter into an IP address to ping
+ unsigned int addr = inet_addr(host);
+ if (addr != INADDR_NONE) {
+ // It was a dotted quad number, so save result
+ dest.sin_addr.s_addr = addr;
+ dest.sin_family = AF_INET;
+ }
+ else {
+ // Not in dotted quad form, so try and look it up
+ hostent* hp = gethostbyname(host);
+ if (hp != 0) {
+ // Found an address for that host, so save it
+ memcpy(&(dest.sin_addr), hp->h_addr, hp->h_length);
+ //dest.sin_family = hp->h_addrtype;
dest.sin_family = AF_INET;
- }
- else {
- // Not a recognized hostname either!
+ }
+ else {
+ // Not a recognized hostname either!
if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: unrecognised host", 0);
- return -1;
- }
- }
+ return -1;
+ }
+ }
ICMPHeader *header = (ICMPHeader *)packet;
- header->seq = ++seq_no;
+ header->seq = ++seq_no;
header->checksum = 0;
- header->checksum = ip_checksum((USHORT*)header, sizeof(ICMPHeader));
+ header->checksum = ip_checksum((USHORT*)header, sizeof(ICMPHeader));
bool use_hi_res = false;
LARGE_INTEGER hr_freq, hr_send_time;
@@ -120,15 +115,15 @@ extern int raw_ping(char *host, int timeout) {
send_time = GetTickCount();
// send packet
- int bwrote = sendto(sd, (char*)packet, sizeof(ICMPHeader), 0, (sockaddr*)&dest, sizeof(dest));
- if (bwrote == SOCKET_ERROR) {
+ int bwrote = sendto(sd, (char*)packet, sizeof(ICMPHeader), 0, (sockaddr*)&dest, sizeof(dest));
+ if (bwrote == SOCKET_ERROR) {
if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: unable to send", 0);
- return -1;
- }
+ return -1;
+ }
- // Wait for the ping reply
+ // Wait for the ping reply
sockaddr_in source;
- int fromlen = sizeof(source);
+ int fromlen = sizeof(source);
IPHeader *reply_header = (IPHeader *)recv_buff;
ICMPHeader *reply;
DWORD start, current_time;
@@ -145,13 +140,13 @@ extern int raw_ping(char *host, int timeout) {
while(((use_hi_res && (hr_current_time.QuadPart < hr_start.QuadPart + hr_timeout.QuadPart))
|| (!use_hi_res && current_time < start + timeout)))
{
- int bread = recvfrom(sd, recv_buff, 1024, 0, (sockaddr*)&source, &fromlen);
+ int bread = recvfrom(sd, recv_buff, 1024, 0, (sockaddr*)&source, &fromlen);
if(use_hi_res)
QueryPerformanceCounter(&hr_current_time);
else
current_time = GetTickCount();
-
+
if (bread == SOCKET_ERROR) {
if(WSAGetLastError() != WSAETIMEDOUT) {
if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: socket error...cycling", 0);
@@ -181,7 +176,7 @@ extern int raw_ping(char *host, int timeout) {
if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: wrong type...cycling", 0);
continue;
}
-
+
//if(reply->seq < seq_no) continue;
//if(reply->seq > seq_no) return -1;
if(reply->seq != seq_no) {
@@ -207,7 +202,8 @@ extern int raw_ping(char *host, int timeout) {
return -1;
}
-extern int cleanup_raw_ping() {
+extern int cleanup_raw_ping()
+{
if(inited) {
closesocket(sd);
sd = -1;
diff --git a/plugins/Ping/src/rawping.h b/plugins/Ping/src/rawping.h
index 23d9df1d61..635a220129 100644
--- a/plugins/Ping/src/rawping.h
+++ b/plugins/Ping/src/rawping.h
@@ -1,10 +1,6 @@
#ifndef _RAWPING_H
#define _RAWPING_H
-#include "options.h"
-#include "log.h"
-
-
// ICMP protocol identifier
#define ICMP_PROTO 1
diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp
index 28200aa85c..425aef76a2 100644
--- a/plugins/Ping/src/utils.cpp
+++ b/plugins/Ping/src/utils.cpp
@@ -1,6 +1,4 @@
#include "common.h"
-#include "utils.h"
-#include "icmp.h"
LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
@@ -160,9 +158,9 @@ void Unlock(CRITICAL_SECTION *cs) {
INT_PTR PingDisableAll(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
- for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
- i.val().status = PS_DISABLED;
- i.val().miss_count = 0;
+ for(pinglist_it i = pl.begin(); i != pl.end(); ++i) {
+ i->status = PS_DISABLED;
+ i->miss_count = 0;
}
CallService(PLUG "/SetPingList", (WPARAM)&pl, 0);
return 0;
@@ -171,9 +169,9 @@ INT_PTR PingDisableAll(WPARAM wParam, LPARAM lParam) {
INT_PTR PingEnableAll(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
- for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
- if(i.val().status == PS_DISABLED) {
- i.val().status = PS_NOTRESPONDING;
+ 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);
@@ -185,14 +183,14 @@ INT_PTR ToggleEnabled(WPARAM wParam, LPARAM lParam) {
int retval = 0;
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
- for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
- if(i.val().item_id == (DWORD)wParam) {
+ for(pinglist_it i = pl.begin(); i != pl.end(); ++i) {
+ if(i->item_id == (DWORD)wParam) {
- if(i.val().status == PS_DISABLED)
- i.val().status = PS_NOTRESPONDING;
+ if(i->status == PS_DISABLED)
+ i->status = PS_NOTRESPONDING;
else {
- i.val().status = PS_DISABLED;
- i.val().miss_count = 0;
+ i->status = PS_DISABLED;
+ i->miss_count = 0;
retval = 1;
}
}
@@ -206,14 +204,14 @@ INT_PTR EditContact(WPARAM wParam, LPARAM lParam) {
HWND hwndList = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
- for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
- if(i.val().item_id == (DWORD)wParam) {
+ for(pinglist_it i = pl.begin(); i != pl.end(); ++i) {
+ if(i->item_id == (DWORD)wParam) {
- add_edit_addr = i.val();
+ add_edit_addr = *i;
if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) {
- i.val() = add_edit_addr;
+ *i = add_edit_addr;
CallService(PLUG "/SetAndSavePingList", (WPARAM)&pl, 0);
return 0;
}
@@ -225,10 +223,10 @@ INT_PTR EditContact(WPARAM wParam, LPARAM lParam) {
INT_PTR DblClick(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
- for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
- if(i.val().item_id == (DWORD)wParam) {
- if(strlen(i.val().pszCommand)) {
- ShellExecute(0, "open", i.val().pszCommand, i.val().pszParams, 0, SW_SHOW);
+ for(pinglist_it i = pl.begin(); i != pl.end(); ++i) {
+ if(i->item_id == (DWORD)wParam) {
+ if(strlen(i->pszCommand)) {
+ ShellExecute(0, "open", i->pszCommand, i->pszParams, 0, SW_SHOW);
} else {
return CallService(PLUG "/ToggleEnabled", wParam, 0);
}
@@ -286,15 +284,17 @@ void import_ping_address(int index, PINGADDRESS &pa) {
}
// read in addresses from old pingplug
-void import_ping_addresses() {
+void import_ping_addresses()
+{
int count = DBGetContactSettingDword(0, "PingPlug", "NumEntries", 0);
PINGADDRESS pa;
EnterCriticalSection(&list_cs);
list_items.clear();
- for(int index = 0; index < count; index++) {
+ for(int index = 0; index < count; index++)
+ {
import_ping_address(index, pa);
- list_items.add(pa);
+ list_items.push_back(pa);
}
write_ping_addresses();
LeaveCriticalSection(&list_cs);
diff --git a/plugins/Ping/src/utils.h b/plugins/Ping/src/utils.h
index 0d27745908..15d8a736e5 100644
--- a/plugins/Ping/src/utils.h
+++ b/plugins/Ping/src/utils.h
@@ -1,14 +1,6 @@
#ifndef _PING_UTILS
#define _PING_UTILS
-#pragma warning( disable : 4786 )
-
-#include "pingthread.h" // for mainthread, for popup
-//#include "icmp.h"
-#include "rawping.h"
-#include "icmp.h"
-#include "options.h"
-
void __stdcall ShowPopup( const char* line1, const char* line2, int flags );
INT_PTR PluginPing(WPARAM wParam,LPARAM lParam);