diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2006-01-22 16:26:41 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2006-01-22 16:26:41 +0000 |
commit | 35dd233580b699562636e2f870d59d66cddc68b9 (patch) | |
tree | e1fb038745f931088696bf5afb2b5e2f76faca3a | |
parent | c73ed3c6d5f79fb73f829ed1d57ec06101b0c48d (diff) |
show the number of packets captured, if "Update list of packets ..." isn't used
svn path=/trunk/; revision=17071
-rw-r--r-- | capture.c | 16 | ||||
-rw-r--r-- | file.c | 9 | ||||
-rw-r--r-- | file.h | 11 | ||||
-rw-r--r-- | gtk/main.c | 28 |
4 files changed, 53 insertions, 11 deletions
@@ -217,7 +217,7 @@ guint32 drops) } /* if we didn't captured even a single packet, close the file again */ - if(cf_packet_count(capture_opts->cf) == 0 && !capture_opts->restart) { + if(cf_get_packet_count(capture_opts->cf) == 0 && !capture_opts->restart) { simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, "%sNo packets captured!%s\n" "\n" @@ -327,9 +327,6 @@ capture_input_new_packets(capture_options *capture_opts, int to_read) XXX - abort on a read error? */ cf_callback_invoke(cf_cb_live_capture_update_continue, capture_opts->cf); - - /* update the main window, so we get events (e.g. from the stop toolbar button) */ - main_window_update(); break; case CF_READ_ABORTED: @@ -338,8 +335,17 @@ capture_input_new_packets(capture_options *capture_opts, int to_read) capture_kill_child(capture_opts); break; } + } else { + /* increase capture file packet counter by the number or incoming packets */ + cf_set_packet_count(capture_opts->cf, + cf_get_packet_count(capture_opts->cf) + to_read); + + cf_callback_invoke(cf_cb_live_capture_fixed_continue, capture_opts->cf); } + /* update the main window, so we get events (e.g. from the stop toolbar button) */ + main_window_update(); + if(capture_opts->show_info) capture_info_new_packets(to_read); } @@ -408,7 +414,7 @@ capture_input_closed(capture_options *capture_opts) switch (status) { case CF_READ_OK: - if(cf_packet_count(capture_opts->cf) == 0 && !capture_opts->restart) { + if(cf_get_packet_count(capture_opts->cf) == 0 && !capture_opts->restart) { simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, "%sNo packets captured!%s\n" "\n" @@ -696,12 +696,19 @@ cf_get_display_name(capture_file *cf) /* XXX - use a macro instead? */ int -cf_packet_count(capture_file *cf) +cf_get_packet_count(capture_file *cf) { return cf->count; } /* XXX - use a macro instead? */ +void +cf_set_packet_count(capture_file *cf, int packet_count) +{ + cf->count = packet_count; +} + +/* XXX - use a macro instead? */ gboolean cf_is_tempfile(capture_file *cf) { @@ -66,6 +66,7 @@ typedef enum { cf_cb_live_capture_update_continue, cf_cb_live_capture_update_finished, cf_cb_live_capture_fixed_started, + cf_cb_live_capture_fixed_continue, cf_cb_live_capture_fixed_finished, cf_cb_live_capture_stopping, #endif @@ -178,7 +179,15 @@ const gchar *cf_get_display_name(capture_file *cf); * @param cf the capture file * @return the number of packets in the capture file */ -int cf_packet_count(capture_file *cf); +int cf_get_packet_count(capture_file *cf); + +/** + * Set the number of packets in the capture file. + * + * @param cf the capture file + * @param the number of packets in the capture file + */ +void cf_set_packet_count(capture_file *cf, int packet_count); /** * Is this capture file a temporary file? diff --git a/gtk/main.c b/gtk/main.c index bd19ddf690..0716ff9201 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1608,7 +1608,7 @@ main_cf_cb_live_capture_fixed_started(capture_options *capture_opts) (capture_opts->save_file) ? capture_opts->save_file : ""); statusbar_push_file_msg(capture_msg); - gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, " <capturing>"); + gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, " P: 0"); g_free(capture_msg); @@ -1617,6 +1617,22 @@ main_cf_cb_live_capture_fixed_started(capture_options *capture_opts) } static void +main_cf_cb_live_capture_fixed_continue(capture_file *cf) +{ + gchar *capture_msg; + + + gtk_statusbar_pop(GTK_STATUSBAR(packets_bar), packets_ctx); + + capture_msg = g_strdup_printf(" P: %u", + cf_get_packet_count(cf)); + + gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, capture_msg); + + g_free(capture_msg); +} + +static void main_cf_cb_live_capture_fixed_finished(capture_file *cf _U_) { if(stop_dlg != NULL) { @@ -1780,13 +1796,17 @@ static void main_cf_callback(gint event, gpointer data, gpointer user_data _U_) /*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/ main_cf_cb_live_capture_update_continue(data); break; + case(cf_cb_live_capture_update_finished): + g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished"); + main_cf_cb_live_capture_update_finished(data); + break; case(cf_cb_live_capture_fixed_started): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started"); main_cf_cb_live_capture_fixed_started(data); break; - case(cf_cb_live_capture_update_finished): - g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished"); - main_cf_cb_live_capture_update_finished(data); + case(cf_cb_live_capture_fixed_continue): + g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue"); + main_cf_cb_live_capture_fixed_continue(data); break; case(cf_cb_live_capture_fixed_finished): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished"); |