diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-03-03 14:04:30 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-03-03 14:04:30 +0000 |
commit | 22f052f313379a8e864e61fdd3593126e088ded4 (patch) | |
tree | 4b089d5d0e5a75a3af00d5cfb256065c82c23d9c /plugins/Ping/src/pinglist.cpp | |
parent | a7c5d18647c0dd188eaa723df3f73e4250a61920 (diff) |
removed not used headers
added version info
fixed crash #169 (patch from $ergi0)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3873 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Ping/src/pinglist.cpp')
-rw-r--r-- | plugins/Ping/src/pinglist.cpp | 111 |
1 files changed, 63 insertions, 48 deletions
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;
}
|