diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 06:55:19 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 06:55:19 +0000 |
commit | 87dd1548f9212c0721d37d511588b79783f55b69 (patch) | |
tree | f541e0281ae281f76db0aaedd9d4b875eba968ff | |
parent | cf45ff050dad2570c3172e111d739a3ae11a9ec1 (diff) |
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13278 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Ping/src/common.h | 4 | ||||
-rw-r--r-- | plugins/Ping/src/options.cpp | 290 | ||||
-rw-r--r-- | plugins/Ping/src/ping.cpp | 10 | ||||
-rw-r--r-- | plugins/Ping/src/pinggraph.cpp | 3 | ||||
-rw-r--r-- | plugins/Ping/src/pinglist.cpp | 24 | ||||
-rw-r--r-- | plugins/Ping/src/pingthread.cpp | 53 | ||||
-rw-r--r-- | plugins/Ping/src/utils.cpp | 26 | ||||
-rw-r--r-- | plugins/Ping/src/utils.h | 3 |
8 files changed, 176 insertions, 237 deletions
diff --git a/plugins/Ping/src/common.h b/plugins/Ping/src/common.h index 3d46b2b2c6..5242b5c848 100644 --- a/plugins/Ping/src/common.h +++ b/plugins/Ping/src/common.h @@ -123,10 +123,10 @@ extern PINGADDRESS add_edit_addr; extern HistoryMap history_map;
extern PINGLIST list_items;
extern HANDLE reload_event_handle;
-extern CRITICAL_SECTION list_cs;
+extern mir_cs list_cs;
extern HANDLE mainThread;
extern HANDLE hWakeEvent;
-extern CRITICAL_SECTION thread_finished_cs, list_changed_cs, data_list_cs;
+extern mir_cs thread_finished_cs, list_changed_cs, data_list_cs;
extern PINGLIST data_list;
diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp index 8d6ef33cc4..b2f698a9cf 100644 --- a/plugins/Ping/src/options.cpp +++ b/plugins/Ping/src/options.cpp @@ -5,11 +5,11 @@ PingOptions options; // main ping options
static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
- if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ATTACH), FALSE);
CheckDlgButton(hwndDlg, IDC_CHK_ATTACH, options.attach_to_clist ? BST_CHECKED : BST_UNCHECKED);
@@ -31,37 +31,37 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetDlgItemInt(hwndDlg, IDC_RPT, options.retries, FALSE);
SetDlgItemText(hwndDlg, IDC_ED_FILENAME, options.log_filename);
- if(!options.logging) {
+ if (!options.logging) {
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_FILENAME), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOGCSV), FALSE);
}
- if( !ServiceExists( MS_POPUP_ADDPOPUPT )) {
+ if (!ServiceExists(MS_POPUP_ADDPOPUPT)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECKPOPUP), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECKPOPUP2), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_BLOCK), FALSE);
- }
+ }
return TRUE;
case WM_COMMAND:
- if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
- switch( LOWORD( wParam )) {
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
+ switch (LOWORD(wParam)) {
case IDC_PPM:
case IDC_PT:
case IDC_ED_FILENAME:
case IDC_RPT:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ }
break;
}
- if (HIWORD( wParam ) == CBN_SELCHANGE) {
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
- if ( HIWORD( wParam ) == BN_CLICKED ) {
- switch( LOWORD( wParam )) {
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
case IDC_CHK_LOG:
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_FILENAME), IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG));
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE), IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG));
@@ -74,7 +74,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_CHK_MINMAX:
case IDC_CHK_NOTESTICON:
case IDC_CHK_ATTACH:
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_BTN_VIEWLOG:
CallService(PLUG "/ViewLogData", 0, 0);
@@ -83,7 +83,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
TCHAR filter[MAX_PATH];
mir_sntprintf(filter, SIZEOF(filter), _T("%s%c*.txt%c%s%c*.*%c"), TranslateT("Text Files (*.txt)"), 0, 0, TranslateT("All Files"), 0, 0);
- OPENFILENAME ofn = {0};
+ OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = options.log_filename;
ofn.hwndOwner = hwndDlg;
@@ -96,31 +96,31 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST;
- if(GetOpenFileName(&ofn) == TRUE) {
+ if (GetOpenFileName(&ofn) == TRUE) {
SetDlgItemText(hwndDlg, IDC_ED_FILENAME, ofn.lpstrFile);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
- break;
+ break;
}
break;
}
break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == UDN_DELTAPOS ) {
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
- }
- if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ if (((LPNMHDR)lParam)->code == UDN_DELTAPOS) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
BOOL trans_success;
- DWORD new_ping_period = GetDlgItemInt( hwndDlg, IDC_PPM, &trans_success, FALSE);
- if(trans_success) {
+ DWORD new_ping_period = GetDlgItemInt(hwndDlg, IDC_PPM, &trans_success, FALSE);
+ if (trans_success) {
options.ping_period = new_ping_period;
}
- DWORD new_ping_timeout = GetDlgItemInt( hwndDlg, IDC_PT, &trans_success, FALSE);
- if(trans_success) {
+ DWORD new_ping_timeout = GetDlgItemInt(hwndDlg, IDC_PT, &trans_success, FALSE);
+ if (trans_success) {
options.ping_timeout = new_ping_timeout;
}
options.show_popup = IsDlgButtonChecked(hwndDlg, IDC_CHECKPOPUP) == BST_CHECKED;
@@ -141,7 +141,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }
bool new_attach = (IsDlgButtonChecked(hwndDlg, IDC_CHK_ATTACH) == BST_CHECKED);
- if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && options.attach_to_clist != new_attach)
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && options.attach_to_clist != new_attach)
AttachToClist(new_attach);
options.attach_to_clist = new_attach;
@@ -150,8 +150,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA RefreshWindow(0, 0);
- if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("options changed"), 0);
- if(hWakeEvent) SetEvent(hWakeEvent);
+ if (options.logging) CallService(PLUG "/Log", (WPARAM)_T("options changed"), 0);
+ if (hWakeEvent) SetEvent(hWakeEvent);
return TRUE;
}
break;
@@ -165,10 +165,10 @@ PINGADDRESS add_edit_addr; // host edit
INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
- switch ( msg ) {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- for(int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
INT_PTR ret = CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)i, GSMDF_TCHAR);
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)ret);
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT2, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)ret);
@@ -183,7 +183,7 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l SetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_addr.pszParams);
CheckDlgButton(hwndDlg, IDC_CHK_DESTTCP, add_edit_addr.port != -1 ? BST_CHECKED : BST_UNCHECKED);
- if(add_edit_addr.port != -1) {
+ if (add_edit_addr.port != -1) {
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_DESTPORT), TRUE);
SetDlgItemInt(hwndDlg, IDC_ED_DESTPORT, add_edit_addr.port, FALSE);
}
@@ -195,15 +195,16 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l int num_protocols = 0;
PROTOACCOUNT **pppDesc;
- ProtoEnumAccounts(&num_protocols,&pppDesc);
- for(int i = 0; i < num_protocols; i++)
+ ProtoEnumAccounts(&num_protocols, &pppDesc);
+ for (int i = 0; i < num_protocols; i++)
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->tszAccountName);
-
+
}
- if(add_edit_addr.pszProto[0] == '\0') {
+ if (add_edit_addr.pszProto[0] == '\0') {
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_SETCURSEL, 0, 0);
- } else {
+ }
+ else {
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_SELECTSTRING, 0, (LPARAM)add_edit_addr.pszProto);
EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT), TRUE);
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_SETCURSEL, (WPARAM)(add_edit_addr.set_status - ID_STATUS_OFFLINE), 0);
@@ -216,17 +217,17 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l SetFocus(GetDlgItem(hwndDlg, IDC_ED_DESTLAB));
return FALSE;
case WM_COMMAND:
- if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_COMBO_DESTPROTO) {
+ if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_COMBO_DESTPROTO) {
int sel = SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_GETCURSEL, 0, 0);
- if(sel != CB_ERR) {
+ if (sel != CB_ERR) {
EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT), sel != 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2), sel != 0);
}
}
- if ( HIWORD( wParam ) == BN_CLICKED )
+ if (HIWORD(wParam) == BN_CLICKED)
{
- switch( LOWORD( wParam ))
+ switch (LOWORD(wParam))
{
case IDC_CHK_DESTTCP:
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_DESTPORT), IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP));
@@ -237,30 +238,32 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l GetDlgItemText(hwndDlg, IDC_ED_COMMAND, add_edit_addr.pszCommand, SIZEOF(add_edit_addr.pszCommand));
GetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_addr.pszParams, SIZEOF(add_edit_addr.pszParams));
- if(SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_GETCURSEL, 0, 0) != -1)
+ if (SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_GETCURSEL, 0, 0) != -1)
{
GetDlgItemTextA(hwndDlg, IDC_COMBO_DESTPROTO, add_edit_addr.pszProto, SIZEOF(add_edit_addr.pszProto));
- if(!strcmp(add_edit_addr.pszProto, Translate("<none>")))
+ if (!strcmp(add_edit_addr.pszProto, Translate("<none>")))
add_edit_addr.pszProto[0] = '\0';
else {
int sel = SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_GETCURSEL, 0, 0);
- if(sel != CB_ERR)
+ if (sel != CB_ERR)
add_edit_addr.set_status = ID_STATUS_OFFLINE + sel;
sel = SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT2, CB_GETCURSEL, 0, 0);
- if(sel != CB_ERR)
+ if (sel != CB_ERR)
add_edit_addr.get_status = ID_STATUS_OFFLINE + sel;
}
- } else
+ }
+ else
add_edit_addr.pszProto[0] = '\0';
if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP))
{
BOOL tr;
int port = GetDlgItemInt(hwndDlg, IDC_ED_DESTPORT, &tr, FALSE);
- if(tr) add_edit_addr.port = port;
+ if (tr) add_edit_addr.port = port;
else add_edit_addr.port = -1;
- } else
+ }
+ else
add_edit_addr.port = -1;
EndDialog(hwndDlg, IDOK);
@@ -292,26 +295,27 @@ bool Edit(HWND hwnd, PINGADDRESS &addr) // ping hosts list window
static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
- case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ switch (msg) {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
- Lock(&data_list_cs, "init options dialog");
- temp_list = data_list;
- Unlock(&data_list_cs);
+ mir_cslock lck(data_list_cs);
+ temp_list = data_list;
- for (pinglist_it i = temp_list.begin(); i != temp_list.end(); ++i)
- {
- int index = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->pszLabel);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, index, (LPARAM)&(*i));
- }
- return TRUE;
+ for (pinglist_it i = temp_list.begin(); i != temp_list.end(); ++i)
+ {
+ int index = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->pszLabel);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, 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)
{
int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0);
- if(sel != LB_ERR)
+ if (sel != LB_ERR)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE);
@@ -322,9 +326,9 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR }
}
- if ( HIWORD( wParam ) == BN_CLICKED )
+ if (HIWORD(wParam) == BN_CLICKED)
{
- switch( LOWORD( wParam ))
+ switch (LOWORD(wParam))
{
case IDC_BTN_DESTEDIT:
{
@@ -347,14 +351,14 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int count = SendDlgItemMessage(hwndDlg, IDC_BTN_DESTDOWN, LB_GETCOUNT, 0, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel < count - 1));
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
}
- break;
+ break;
case IDC_BTN_DESTADD:
- memset(&add_edit_addr,0,sizeof(add_edit_addr));
+ memset(&add_edit_addr, 0, sizeof(add_edit_addr));
add_edit_addr.cbSize = sizeof(add_edit_addr);
add_edit_addr.port = -1;
add_edit_addr.set_status = ID_STATUS_ONLINE;
@@ -363,7 +367,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR add_edit_addr.item_id = 0;
add_edit_addr.index = (int)temp_list.size();
- if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
+ if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
{
temp_list.push_back(add_edit_addr);
@@ -379,14 +383,14 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel < count - 1));
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
case IDC_BTN_DESTREM:
{
int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0);
- if(sel != LB_ERR) {
+ if (sel != LB_ERR) {
PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel, 0);
SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel, 0);
temp_list.remove(*item);
@@ -397,93 +401,93 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), FALSE);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
RefreshWindow(0, 0);
break;
}
case IDC_BTN_DESTDOWN:
- {
- int sel2 = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0);
- if(sel2 != LB_ERR) {
- PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2, 0),
- *item2 = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2 + 1, 0);
- if(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
- int index = item->index, index2 = item2->index;
- item->index = index2;
- item2->index = index;
-
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel2, 0);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)(sel2 + 1), 0);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)item2->pszLabel);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)(sel2 + 1), (LPARAM)item2);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel2 + 1 > 0));
- int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel2 + 1 < count - 1));
-
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
- }
+ {
+ int sel2 = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0);
+ if (sel2 != LB_ERR) {
+ PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2, 0),
+ *item2 = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2 + 1, 0);
+ if (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
+ int index = item->index, index2 = item2->index;
+ item->index = index2;
+ item2->index = index;
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel2, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)(sel2 + 1), 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)item2->pszLabel);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)(sel2 + 1), (LPARAM)item2);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel2 + 1 > 0));
+ int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel2 + 1 < count - 1));
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
- break;
+ }
+ break;
case IDC_BTN_DESTUP:
- {
- int sel2 = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0);
- if(sel2 != LB_ERR) {
- PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2, 0),
- *item2 = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2 - 1, 0);
-
- if (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
- int index = item->index, index2 = item2->index;
- item->index = index2;
- item2->index = index;
-
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel2, 0);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
-
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)(sel2 - 1), 0);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)item2->pszLabel);
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)(sel2 - 1), (LPARAM)item2);
-
- SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel2 - 1 > 0));
- int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel2 - 1 < count - 1));
-
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
- }
+ {
+ int sel2 = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0);
+ if (sel2 != LB_ERR) {
+ PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2, 0),
+ *item2 = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2 - 1, 0);
+
+ if (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
+ int index = item->index, index2 = item2->index;
+ item->index = index2;
+ item2->index = index;
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel2, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)(sel2 - 1), 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)item2->pszLabel);
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)(sel2 - 1), (LPARAM)item2);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel2 - 1 > 0));
+ int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel2 - 1 < count - 1));
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
+ }
- break;
+ break;
}
}
- if(LOWORD(wParam) == IDC_BGCOL
+ if (LOWORD(wParam) == IDC_BGCOL
|| LOWORD(wParam) == IDC_SP_INDENT || LOWORD(wParam) == IDC_SP_ROWHEIGHT)
{
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
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);
@@ -497,23 +501,23 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE;
}
-int PingOptInit(WPARAM wParam,LPARAM)
+int PingOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
odp.ptszGroup = LPGENT("Network");
odp.ptszTitle = LPGENT("Ping");
odp.ptszTab = LPGENT("Settings");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG1);
odp.pfnDlgProc = DlgProcOpts;
- Options_AddPage(wParam,&odp);
+ Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("Hosts");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG2);
odp.pfnDlgProc = DlgProcOpts2;
- Options_AddPage(wParam,&odp);
+ Options_AddPage(wParam, &odp);
return 0;
}
diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp index d63cbcbe9c..9b07356ed1 100644 --- a/plugins/Ping/src/ping.cpp +++ b/plugins/Ping/src/ping.cpp @@ -137,11 +137,6 @@ extern "C" __declspec(dllexport) int Load(void) DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );
hWakeEvent = CreateEvent(NULL, FALSE, FALSE, _T("Local\\ThreadWaitEvent"));
- InitializeCriticalSection(&list_cs);
- 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();
@@ -167,11 +162,6 @@ extern "C" __declspec(dllexport) int Unload(void) {
SavePingList(0, 0);
- DeleteCriticalSection(&list_cs);
- DeleteCriticalSection(&thread_finished_cs);
- DeleteCriticalSection(&list_changed_cs);
- DeleteCriticalSection(&data_list_cs);
-
CloseHandle( mainThread );
if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("stop"), 0);
diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp index cc2252a521..735d8a4bfa 100644 --- a/plugins/Ping/src/pinggraph.cpp +++ b/plugins/Ping/src/pinggraph.cpp @@ -23,7 +23,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar WindowData *wd = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
bool found = false;
- EnterCriticalSection(&data_list_cs);
+ mir_cslock lck(data_list_cs);
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];
@@ -31,7 +31,6 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar break;
}
}
- LeaveCriticalSection(&data_list_cs);
if(!found) {
PostMessage(hwnd, WM_CLOSE, 0, 0);
diff --git a/plugins/Ping/src/pinglist.cpp b/plugins/Ping/src/pinglist.cpp index ccd95600c6..4b4a19363d 100644 --- a/plugins/Ping/src/pinglist.cpp +++ b/plugins/Ping/src/pinglist.cpp @@ -1,7 +1,7 @@ #include "common.h"
PINGLIST list_items;
-CRITICAL_SECTION list_cs;
+mir_cs list_cs;
HANDLE reload_event_handle;
DWORD NextID = 1;
@@ -37,9 +37,8 @@ INT_PTR GetPingList(WPARAM,LPARAM lParam) {
PINGLIST *pa = (PINGLIST *)lParam;
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
*pa = list_items;
- LeaveCriticalSection(&list_cs);
return 0;
}
@@ -47,9 +46,8 @@ INT_PTR GetPingList(WPARAM,LPARAM lParam) INT_PTR GetListSize(WPARAM, LPARAM)
{
INT_PTR ret = 0;
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
ret = list_items.size();
- LeaveCriticalSection(&list_cs);
return ret;
}
@@ -182,9 +180,8 @@ void read_ping_addresses() INT_PTR LoadPingList(WPARAM wParam, LPARAM lParam)
{
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
read_ping_addresses();
- LeaveCriticalSection(&list_cs);
NotifyEventHooks(reload_event_handle, 0, 0);
return 0;
}
@@ -193,10 +190,8 @@ INT_PTR LoadPingList(WPARAM wParam, LPARAM lParam) // lParam is zero
INT_PTR SavePingList(WPARAM wParam, LPARAM lParam)
{
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
write_ping_addresses();
- LeaveCriticalSection(&list_cs);
- //NotifyEventHooks(reload_event_handle, 0, 0);
return 0;
}
@@ -207,9 +202,8 @@ INT_PTR SetPingList(WPARAM wParam, LPARAM lParam) {
PINGLIST *pli = (PINGLIST *)wParam;
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
list_items = *pli;
- LeaveCriticalSection(&list_cs);
NotifyEventHooks(reload_event_handle, 0, 0);
return 0;
@@ -221,12 +215,11 @@ INT_PTR SetAndSavePingList(WPARAM wParam, LPARAM lParam) {
PINGLIST *pli = (PINGLIST *)wParam;
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
// set new list
list_items = *pli;
write_ping_addresses();
- LeaveCriticalSection(&list_cs);
NotifyEventHooks(reload_event_handle, 0, 0);
@@ -235,9 +228,8 @@ INT_PTR SetAndSavePingList(WPARAM wParam, LPARAM lParam) INT_PTR ClearPingList(WPARAM wParam, LPARAM lParam)
{
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
list_items.clear();
- LeaveCriticalSection(&list_cs);
NotifyEventHooks(reload_event_handle, 0, 0);
return 0;
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index d27e151260..26c9aad06c 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -8,7 +8,7 @@ HANDLE mainThread; HANDLE hWakeEvent = 0;
// thread protected variables
-CRITICAL_SECTION thread_finished_cs, list_changed_cs, data_list_cs;
+mir_cs thread_finished_cs, list_changed_cs, data_list_cs;
bool thread_finished = false, list_changed = false;
PINGLIST data_list;
@@ -30,29 +30,25 @@ static int transparentFocus=1; /////////////////
bool get_thread_finished() {
- Lock(&thread_finished_cs, "get_thread_finished");
+ mir_cslock lck(thread_finished_cs);
bool retval = thread_finished;
- Unlock(&thread_finished_cs);
return retval;
}
void set_thread_finished(bool f) {
- Lock(&thread_finished_cs, "set_thread_finished");
+ mir_cslock lck(thread_finished_cs);
thread_finished = f;
- Unlock(&thread_finished_cs);
}
bool get_list_changed() {
- Lock(&list_changed_cs, "get_list_changed");
+ mir_cslock lck(list_changed_cs);
bool retval = list_changed;
- Unlock(&list_changed_cs);
return retval;
}
void set_list_changed(bool f) {
- Lock(&list_changed_cs, "set_list_changed");
+ mir_cslock lck(list_changed_cs);
list_changed = f;
- Unlock(&list_changed_cs);
}
void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_status) {
@@ -100,15 +96,14 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) PINGADDRESS pa;
HistPair history_entry;
- Lock(&data_list_cs, "ping thread loop start");
+ mir_cslock lck(data_list_cs);
set_list_changed(false);
size_t size = data_list.size();
- Unlock(&data_list_cs);
size_t index = 0;
for(; index < size; index++)
{
- Lock(&data_list_cs, "ping thread loop start");
+ mir_cslock lck(data_list_cs);
size_t c = 0;
for (pinglist_it i = data_list.begin(); i != data_list.end() && c <= index; ++i, c++)
{
@@ -128,14 +123,13 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) }
}
- Unlock(&data_list_cs);
if(get_thread_finished()) break;
if(get_list_changed()) break;
if(pa.status != PS_DISABLED) {
if(!options.no_test_icon) {
- Lock(&data_list_cs, "ping thread loop start");
+ mir_cslock lck(data_list_cs);
for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
{
if(i->item_id == pa.item_id)
@@ -143,7 +137,6 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) i->status = PS_TESTING;
}
}
- Unlock(&data_list_cs);
InvalidateRect(list_hwnd, 0, FALSE);
}
@@ -152,7 +145,7 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) if(get_thread_finished()) break;
if(get_list_changed()) break;
- Lock(&data_list_cs, "ping thread loop start");
+ mir_cslock lck(data_list_cs);
for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
{
if(i->item_id == pa.item_id)
@@ -190,7 +183,6 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) break;
}
}
- Unlock(&data_list_cs);
if(pa.responding) {
count++;
@@ -276,7 +268,7 @@ int FillList(WPARAM wParam, LPARAM lParam) { CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
SendMessage(list_hwnd, WM_SETREDRAW, FALSE, 0);
- Lock(&data_list_cs, "fill_list");
+ mir_cslock lck(data_list_cs);
data_list = pl;
SendMessage(list_hwnd, LB_RESETCONTENT, 0, 0);
@@ -290,7 +282,6 @@ int FillList(WPARAM wParam, LPARAM lParam) { list_size = data_list.size();
- Unlock(&data_list_cs);
SendMessage(list_hwnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(list_hwnd, 0, FALSE);
@@ -369,9 +360,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar HBRUSH ttbrush = 0;
COLORREF tcol;
if(dis->itemID != -1) {
- Lock(&data_list_cs, "draw item");
+ mir_cslock lck(data_list_cs);
itemData = *(PINGADDRESS *)dis->itemData;
- Unlock(&data_list_cs);
SendMessage(list_hwnd, LB_SETITEMHEIGHT, 0, (LPARAM)options.row_height);
//dis->rcItem.bottom = dis->rcItem.top + options.row_height;
@@ -468,13 +458,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar bool found = false;
if(HIWORD(item) == 0) {
int count = LOWORD(item);
- Lock(&data_list_cs, "show graph");
+ mir_cslock lck(data_list_cs);
if(count >= 0 && count < (int)data_list.size()) {
itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
found = true;
}
- Unlock(&data_list_cs);
-
}
if(found) {
@@ -681,12 +669,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if(HIWORD(item) == 0) {
int count = LOWORD(item);
bool found = false;
- Lock(&data_list_cs, "menu show graph");
+ mir_cslock lck(data_list_cs);
if(count >= 0 && count < (int)data_list.size()) {
itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
found = true;
}
- Unlock(&data_list_cs);
if(found)
CallService(PLUG "/ShowGraph", (WPARAM)itemData.item_id, (LPARAM)itemData.pszLabel);
}
@@ -702,12 +689,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if(HIWORD(item) == 0) {
int count = LOWORD(item);
bool found = false;
- Lock(&data_list_cs, "menu toggle");
+ mir_cslock lck(data_list_cs);
if(count >= 0 && count < (int)data_list.size()) {
itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
found = true;
}
- Unlock(&data_list_cs);
if(found)
CallService(PLUG "/ToggleEnabled", (WPARAM)itemData.item_id, 0);
}
@@ -723,18 +709,16 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar PINGADDRESS *temp = 0;
if(HIWORD(item) == 0) {
int count = LOWORD(item);
- Lock(&data_list_cs, "menu edit");
+ mir_cslock lck(data_list_cs);
if(count >= 0 && count < (int)data_list.size()) {
temp = (PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
}
- Unlock(&data_list_cs);
if(temp) {
itemData = *temp;
if(Edit(hwnd, itemData)) {
- Lock(&data_list_cs, "menu edited");
+ mir_cslock lck(data_list_cs);
*temp = itemData;
CallService(PLUG "/SetAndSavePingList", (WPARAM)&data_list, 0);
- Unlock(&data_list_cs);
}
}
}
@@ -774,11 +758,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if(lp != LB_ERR) {
PINGADDRESS *pItemData = (PINGADDRESS *)lp;
- Lock(&data_list_cs, "command");
+ mir_cslock lck(data_list_cs);
if(pItemData) {
DWORD item_id = pItemData->item_id;
- Unlock(&data_list_cs);
int wake = CallService(PLUG "/DblClick", (WPARAM)item_id, 0);
InvalidateRect(list_hwnd, 0, FALSE);
@@ -790,8 +773,6 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar CallService(PLUG "/Log", (WPARAM)buf, 0);
}
- } else {
- Unlock(&data_list_cs);
}
}
}
diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp index 8aaf1d21b6..8e57dde2ff 100644 --- a/plugins/Ping/src/utils.cpp +++ b/plugins/Ping/src/utils.cpp @@ -130,29 +130,6 @@ INT_PTR PluginPing(WPARAM,LPARAM lParam) return 0;
}
-void Lock(CRITICAL_SECTION *cs, char *lab) {
-// if(logging) {
-// std::ostringstream oss1;
-// oss1 << "Locking cs: " << cs << ", " << lab;
-// CallService(PROTO "/Log", (WPARAM)oss1.str().c_str(), 0);
-// }
- EnterCriticalSection(cs);
-// if(logging) {
-// std::ostringstream oss2;
-// oss2 << "Locked cs: " << cs;
-// CallService(PROTO "/Log", (WPARAM)oss2.str().c_str(), 0);
-// }
-}
-
-void Unlock(CRITICAL_SECTION *cs) {
-// if(logging) {
-// std::ostringstream oss1;
-// oss1 << "Unlocking cs: " << cs;
-// CallService(PROTO "/Log", (WPARAM)oss1.str().c_str(), 0);
-// }
- LeaveCriticalSection(cs);
-}
-
INT_PTR PingDisableAll(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
@@ -287,7 +264,7 @@ void import_ping_addresses() int count = db_get_dw(0, "PingPlug", "NumEntries", 0);
PINGADDRESS pa;
- EnterCriticalSection(&list_cs);
+ mir_cslock lck(list_cs);
list_items.clear();
for(int index = 0; index < count; index++)
{
@@ -295,7 +272,6 @@ void import_ping_addresses() list_items.push_back(pa);
}
write_ping_addresses();
- LeaveCriticalSection(&list_cs);
}
HANDLE hPopupClass;
diff --git a/plugins/Ping/src/utils.h b/plugins/Ping/src/utils.h index 1cb3a19405..d2c134026f 100644 --- a/plugins/Ping/src/utils.h +++ b/plugins/Ping/src/utils.h @@ -5,9 +5,6 @@ void __stdcall ShowPopup(TCHAR *line1, TCHAR *line2, int flags ); INT_PTR PluginPing(WPARAM wParam,LPARAM lParam);
-void Lock(CRITICAL_SECTION *cs, char *lab);
-void Unlock(CRITICAL_SECTION *cs);
-
INT_PTR PingDisableAll(WPARAM wParam, LPARAM lParam);
INT_PTR PingEnableAll(WPARAM wParam, LPARAM lParam);
|