INT_PTR GetListSize(WPARAM, LPARAM) { INT_PTR ret = 0; mir_cslock lck(list_cs); ret = list_items.size(); return ret; }
int FillList(WPARAM, LPARAM) { if (options.logging) CallService(PLUG "/Log", (WPARAM)_T("ping address list reload"), 0); PINGLIST pl; CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); SendMessage(list_hwnd, WM_SETREDRAW, FALSE, 0); { mir_cslock lck(data_list_cs); data_list = pl; SendMessage(list_hwnd, LB_RESETCONTENT, 0, 0); int index = 0; 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); list_size = data_list.size(); } SendMessage(list_hwnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(list_hwnd, 0, FALSE); SetEvent(hWakeEvent); if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && options.attach_to_clist) UpdateFrame(); return 0; }
// wParam is address of a PINGLIST structure to replace the current one // lParam is zero int SetAndSavePingList(WPARAM wParam, LPARAM lParam) { PINGLIST *pli = (PINGLIST *)wParam; EnterCriticalSection(&list_cs); // delete items that aren't in the new list bool found; for(PINGLIST::iterator i = list_items.begin(); i != list_items.end(); i++) { found = false; for(PINGLIST::iterator j = pli->begin(); j != pli->end(); j++) { if(i->hContact == j->hContact) { found = true; break; } } if(!found) { //MessageBox(0, "Deleting contact", "Ping", MB_OK); // remove prot first, so that our contact deleted event handler isn't activated CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)i->hContact, (LPARAM)PROTO); CallService(MS_DB_CONTACT_DELETE, (WPARAM)i->hContact, 0); } } // set new list if(pli->size()) list_items = *pli; else list_items.clear(); write_ping_addresses(); LeaveCriticalSection(&list_cs); NotifyEventHooks(reload_event_handle, 0, 0); return 0; }
// ping hosts list window static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); Lock(&data_list_cs, "init options dialog"); temp_list = data_list; Unlock(&data_list_cs); 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) { int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if(sel != LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel > 0)); int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel < count - 1)); } } if ( HIWORD( wParam ) == BN_CLICKED ) { switch( LOWORD( wParam )) { case IDC_BTN_DESTEDIT: { int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if (sel != LB_ERR) { PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel, 0); PINGADDRESS temp = *item; if (Edit(hwndDlg, temp)) { *item = temp; SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel, 0); SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)item->pszLabel); SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel, (LPARAM)item); SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)sel, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), sel > 0); 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 ); } } } break; case IDC_BTN_DESTADD: 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; add_edit_addr.get_status = ID_STATUS_OFFLINE; add_edit_addr.status = PS_NOTRESPONDING; add_edit_addr.item_id = 0; add_edit_addr.index = (int)temp_list.size(); if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK) { temp_list.push_back(add_edit_addr); int index = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)add_edit_addr.pszLabel); SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)index, 0); SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)index, (LPARAM)&(temp_list.back())); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE); int sel = (int)temp_list.size() - 1; EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel > 0)); 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 ); } break; case IDC_BTN_DESTREM: { int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); 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); } EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), FALSE); 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, (LPARAM)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), (LPARAM)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; 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, (LPARAM)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), (LPARAM)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; } } if(LOWORD(wParam) == IDC_BGCOL || LOWORD(wParam) == IDC_SP_INDENT || LOWORD(wParam) == IDC_SP_ROWHEIGHT) { SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } break; case WM_NOTIFY: 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 //if(hWakeEvent) SetEvent(hWakeEvent); return TRUE; } break; } return FALSE; }
// ping destinations list window static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hw; int sel; switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault( hwndDlg ); Lock(&data_list_cs, "init options dialog"); temp_list = data_list; Unlock(&data_list_cs); hw = GetDlgItem(hwndDlg, IDC_LST_DEST); for(PINGLIST::iterator i = temp_list.begin(); i != temp_list.end(); i++) { //int index = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->pszLabel); } } return TRUE; case WM_COMMAND: 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) { hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); EnableWindow(hw, (sel > 0)); hw = GetDlgItem(hwndDlg, IDC_LST_DEST); int count = SendMessage(hw, LB_GETCOUNT, 0, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); EnableWindow(hw, (sel < count - 1)); } } 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) { add_edit_addr = temp_list[sel]; if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK) { temp_list[sel] = add_edit_addr; SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)temp_list[sel].pszLabel); SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); EnableWindow(hw, TRUE); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } } break; case IDC_BTN_DESTADD: 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; add_edit_addr.get_status = ID_STATUS_OFFLINE; add_edit_addr.status = options.nrstatus; 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); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); EnableWindow(hw, TRUE); sel = temp_list.size() - 1; hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); EnableWindow(hw, (sel > 0)); hw = GetDlgItem(hwndDlg, IDC_LST_DEST); 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 ); } break; case IDC_BTN_DESTREM: hw = GetDlgItem(hwndDlg, IDC_LST_DEST); sel = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel != LB_ERR) { SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0); PINGLIST::iterator i = temp_list.begin(); while(sel > 0 && i != temp_list.end()) { sel--; i++; } if(i != temp_list.end()) temp_list.erase(i); } hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); EnableWindow(hw, FALSE); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; case IDC_BTN_DESTDOWN: { hw = GetDlgItem(hwndDlg, IDC_LST_DEST); int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel2 != LB_ERR) { add_edit_addr = temp_list[sel2]; temp_list[sel2] = temp_list[sel2 + 1]; temp_list[sel2 + 1] = add_edit_addr; SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)temp_list[sel2].pszLabel); SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)temp_list[sel2 + 1].pszLabel); SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); EnableWindow(hw, (sel2 + 1 > 0)); hw = GetDlgItem(hwndDlg, IDC_LST_DEST); 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; case IDC_BTN_DESTUP: { hw = GetDlgItem(hwndDlg, IDC_LST_DEST); int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel2 != LB_ERR) { add_edit_addr = temp_list[sel2 - 1]; temp_list[sel2 - 1] = temp_list[sel2]; temp_list[sel2] = add_edit_addr; SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)temp_list[sel2].pszLabel); SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)temp_list[sel2 - 1].pszLabel); SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); EnableWindow(hw, (sel2 - 1 > 0)); hw = GetDlgItem(hwndDlg, IDC_LST_DEST); 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; } } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { CallService(PROTO "/SetAndSavePingList", (WPARAM)&temp_list, 0); CallService(PROTO "/GetPingList", 0, (LPARAM)&temp_list); // the following will be affected due to list rebuild event //if(hWakeEvent) SetEvent(hWakeEvent); return TRUE; } break; } return FALSE; }
void __cdecl sttCheckStatusThreadProc(void*) { clock_t start_t = clock(), end_t; 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) WaitForSingleObjectEx(hWakeEvent, wait, TRUE); if (get_thread_finished()) break; start_t = clock(); bool timeout = false; bool reply = false; int count = 0; PINGADDRESS pa = { 0 }; HistPair history_entry; size_t size; { mir_cslock lck(data_list_cs); set_list_changed(false); size = data_list.size(); } size_t index = 0; for (; index < size; index++) { { 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++) { if (c == index) { // copy just what we need - i.e. not history, not command pa.get_status = i->get_status; pa.item_id = i->item_id; pa.miss_count = i->miss_count; pa.port = i->port; mir_tstrncpy(pa.pszLabel, i->pszLabel, _countof(pa.pszLabel)); mir_tstrncpy(pa.pszName, i->pszName, _countof(pa.pszName)); mir_strncpy(pa.pszProto, i->pszProto, _countof(pa.pszProto)); pa.set_status = i->set_status; pa.status = i->status; break; } } } if (get_thread_finished()) break; if (get_list_changed()) break; if (pa.status != PS_DISABLED) { if (!options.no_test_icon) { 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) i->status = PS_TESTING; InvalidateRect(list_hwnd, 0, FALSE); } CallService(PLUG "/Ping", 0, (LPARAM)&pa); if (get_thread_finished()) break; if (get_list_changed()) break; { 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) { 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->item_id].push_back(history_entry); // maintain history (-1 represents no response) 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.miss_count > 0) pa.miss_count = -1; else pa.miss_count--; pa.status = PS_RESPONDING; } else { if (pa.miss_count < 0) pa.miss_count = 1; else pa.miss_count++; pa.status = PS_NOTRESPONDING; } i->miss_count = pa.miss_count; i->status = pa.status; break; } } } if (pa.responding) { count++; if (pa.miss_count == -1 - options.retries || (((-pa.miss_count) % (options.retries + 1)) == 0 && !options.block_reps)) { reply = true; if (options.show_popup2 && ServiceExists(MS_POPUP_SHOWMESSAGE)) { ShowPopup(TranslateT("Ping Reply"), pa.pszLabel, 1); } } if (pa.miss_count == -1 - options.retries && options.logging) { TCHAR buf[512]; mir_sntprintf(buf, TranslateT("%s - reply, %d"), pa.pszLabel, pa.round_trip_time); CallService(PLUG "/Log", (WPARAM)buf, 0); } SetProtoStatus(pa.pszLabel, pa.pszProto, pa.get_status, pa.set_status); } else { if (pa.miss_count == 1 + options.retries || ((pa.miss_count % (options.retries + 1)) == 0 && !options.block_reps)) { timeout = true; if (options.show_popup) ShowPopup(TranslateT("Ping Timeout"), pa.pszLabel, 0); } if (pa.miss_count == 1 + options.retries && options.logging) { TCHAR buf[512]; mir_sntprintf(buf, TranslateT("%s - timeout"), pa.pszLabel); CallService(PLUG "/Log", (WPARAM)buf, 0); } } InvalidateRect(list_hwnd, 0, FALSE); } } if (timeout) SkinPlaySound("PingTimeout"); if (reply) SkinPlaySound("PingReply"); if (!get_list_changed()) { upCount = count; total = (int)index; } else total = 0; } }