show the number of packets captured, if "Update list of packets ..." isn't used

svn path=/trunk/; revision=17071
This commit is contained in:
Ulf Lamping 2006-01-22 16:26:41 +00:00
parent c73ed3c6d5
commit 35dd233580
4 changed files with 53 additions and 11 deletions

View File

@ -217,7 +217,7 @@ guint32 drops)
} }
/* if we didn't captured even a single packet, close the file again */ /* 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, simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
"%sNo packets captured!%s\n" "%sNo packets captured!%s\n"
"\n" "\n"
@ -327,9 +327,6 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
XXX - abort on a read error? */ XXX - abort on a read error? */
cf_callback_invoke(cf_cb_live_capture_update_continue, capture_opts->cf); 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; break;
case CF_READ_ABORTED: case CF_READ_ABORTED:
@ -338,8 +335,17 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
capture_kill_child(capture_opts); capture_kill_child(capture_opts);
break; 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) if(capture_opts->show_info)
capture_info_new_packets(to_read); capture_info_new_packets(to_read);
} }
@ -408,7 +414,7 @@ capture_input_closed(capture_options *capture_opts)
switch (status) { switch (status) {
case CF_READ_OK: 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, simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
"%sNo packets captured!%s\n" "%sNo packets captured!%s\n"
"\n" "\n"

9
file.c
View File

@ -696,11 +696,18 @@ cf_get_display_name(capture_file *cf)
/* XXX - use a macro instead? */ /* XXX - use a macro instead? */
int int
cf_packet_count(capture_file *cf) cf_get_packet_count(capture_file *cf)
{ {
return cf->count; 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? */ /* XXX - use a macro instead? */
gboolean gboolean
cf_is_tempfile(capture_file *cf) cf_is_tempfile(capture_file *cf)

11
file.h
View File

@ -66,6 +66,7 @@ typedef enum {
cf_cb_live_capture_update_continue, cf_cb_live_capture_update_continue,
cf_cb_live_capture_update_finished, cf_cb_live_capture_update_finished,
cf_cb_live_capture_fixed_started, cf_cb_live_capture_fixed_started,
cf_cb_live_capture_fixed_continue,
cf_cb_live_capture_fixed_finished, cf_cb_live_capture_fixed_finished,
cf_cb_live_capture_stopping, cf_cb_live_capture_stopping,
#endif #endif
@ -178,7 +179,15 @@ const gchar *cf_get_display_name(capture_file *cf);
* @param cf the capture file * @param cf the capture file
* @return the number of packets in 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? * Is this capture file a temporary file?

View File

@ -1608,7 +1608,7 @@ main_cf_cb_live_capture_fixed_started(capture_options *capture_opts)
(capture_opts->save_file) ? capture_opts->save_file : ""); (capture_opts->save_file) ? capture_opts->save_file : "");
statusbar_push_file_msg(capture_msg); 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); g_free(capture_msg);
@ -1616,6 +1616,22 @@ main_cf_cb_live_capture_fixed_started(capture_options *capture_opts)
main_set_for_capture_file(FALSE); main_set_for_capture_file(FALSE);
} }
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 static void
main_cf_cb_live_capture_fixed_finished(capture_file *cf _U_) main_cf_cb_live_capture_fixed_finished(capture_file *cf _U_)
{ {
@ -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");*/ /*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/
main_cf_cb_live_capture_update_continue(data); main_cf_cb_live_capture_update_continue(data);
break; 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): case(cf_cb_live_capture_fixed_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started"); g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started");
main_cf_cb_live_capture_fixed_started(data); main_cf_cb_live_capture_fixed_started(data);
break; break;
case(cf_cb_live_capture_update_finished): case(cf_cb_live_capture_fixed_continue):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished"); g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");
main_cf_cb_live_capture_update_finished(data); main_cf_cb_live_capture_fixed_continue(data);
break; break;
case(cf_cb_live_capture_fixed_finished): case(cf_cb_live_capture_fixed_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished"); g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished");