From 080a4a10d229d308a306b8d3db253e180ba9a33a Mon Sep 17 00:00:00 2001 From: Kaian Date: Sun, 1 Mar 2015 01:18:15 +0100 Subject: [PATCH] Fix wrong displayed filtered calls in CallList --- src/filter.c | 17 ++++++++++------- src/filter.h | 9 +++++---- src/ui_call_list.c | 5 ++--- src/ui_save_pcap.c | 8 ++++++-- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/filter.c b/src/filter.c index 678dd4f..73623be 100644 --- a/src/filter.c +++ b/src/filter.c @@ -63,19 +63,22 @@ filter_get(int type) return filters[type].expr; } -int -filter_display_count() +void +filter_stats(int *total, int *displayed) { sip_call_t *call = NULL; - int filtered_cnt = 0; - while ((call = call_get_next_filtered(call))) { - filtered_cnt++; + // Initialize stats + *total = 0; + *displayed = 0; + + while ((call = call_get_next(call))) { + (*total)++; + if (filter_check_call(call) == 0) + (*displayed)++; } - return filtered_cnt; } - int filter_check_call(sip_call_t *call) { diff --git a/src/filter.h b/src/filter.h index b984376..c4b6c56 100644 --- a/src/filter.h +++ b/src/filter.h @@ -99,12 +99,13 @@ const char * filter_get(int type); /** - * @brief Number of calls that not have been filtered + * @brief Get Filtered calls * - * @return Number of calls without filtered flag + * @param total Total calls processed + * @param displayed number of calls matching filters */ -int -filter_display_count(); +void +filter_stats(int *total, int *displayed); /** * @brief Check if a call if filtered diff --git a/src/ui_call_list.c b/src/ui_call_list.c index 1e78b06..e391cbe 100644 --- a/src/ui_call_list.c +++ b/src/ui_call_list.c @@ -226,9 +226,8 @@ call_list_draw(PANEL *panel) wattroff(win, A_BOLD | A_REVERSE | COLOR_PAIR(CP_DEF_ON_CYAN)); } - // Store call counters - callcnt = sip_calls_count(); - dispcallcnt = filter_display_count(); + // Get filter call counters + filter_stats(&callcnt, &dispcallcnt); // Print calls count (also filtered) mvwprintw(win, 1, 35, "%*s", 35, ""); diff --git a/src/ui_save_pcap.c b/src/ui_save_pcap.c index 186c0ab..e35443b 100644 --- a/src/ui_save_pcap.c +++ b/src/ui_save_pcap.c @@ -144,15 +144,19 @@ save_destroy(PANEL *panel) int save_draw(PANEL *panel) { + int total, displayed; + // Get panel information save_info_t *info = (save_info_t*) panel_userptr(panel); WINDOW *win = panel_window(panel); + // Get filter stats + filter_stats(&total, &displayed); + mvwprintw(win, 5, 3, "( ) Save all dialogs"); mvwprintw(win, 6, 3, "( ) Save selected dialogs (%d dialogs)", call_group_count(info->group)); - mvwprintw(win, 7, 3, "( ) Save displayed dialogs (%d dialogs)", - filter_display_count()); + mvwprintw(win, 7, 3, "( ) Save displayed dialogs (%d dialogs)", displayed); set_field_buffer(info->fields[FLD_SAVE_ALL], 0, (info->savemode == SAVE_ALL) ? "*" : "");