From 163f2b61a857b93126e1f84f8686555b9121b989 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Sun, 10 Apr 2005 19:36:56 +0000 Subject: [PATCH] fix statusbar messages by splitting into update and fixed messages between capture and main svn path=/trunk/; revision=14044 --- capture.c | 17 +++++++------ file.h | 6 +++-- gtk/main.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 78 insertions(+), 15 deletions(-) diff --git a/capture.c b/capture.c index a0bc013be6..3893587ed0 100644 --- a/capture.c +++ b/capture.c @@ -221,9 +221,12 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file) return FALSE; break; } + + cf_callback_invoke(cf_cb_live_capture_update_started, capture_opts->cf); + } else { + cf_callback_invoke(cf_cb_live_capture_fixed_started, capture_opts->cf); } - cf_callback_invoke(cf_cb_live_capture_started, capture_opts->cf); return TRUE; } @@ -269,6 +272,9 @@ capture_input_closed(capture_options *capture_opts) if(capture_opts->real_time_mode) { + /* first of all, we are not doing a capture any more */ + cf_callback_invoke(cf_cb_live_capture_update_finished, capture_opts->cf); + /* Read what remains of the capture file, and finish the capture. XXX - do something if this fails? */ switch (cf_finish_tail(capture_opts->cf, &err)) { @@ -296,17 +302,14 @@ capture_input_closed(capture_options *capture_opts) } } else { + /* first of all, we are not doing a capture any more */ + cf_callback_invoke(cf_cb_live_capture_fixed_finished, capture_opts->cf); + /* this is a normal mode capture, read in the capture file data */ capture_input_read_all(capture_opts, cf_is_tempfile(capture_opts->cf), cf_get_drops_known(capture_opts->cf), cf_get_drops(capture_opts->cf)); } - /* if we have captured some packets, call cf_cb_live_capture_finished! */ - /* (otherwise we already have called cf_close) */ - if(cf_packet_count(capture_opts->cf) != 0) { - cf_callback_invoke(cf_cb_live_capture_finished, capture_opts->cf); - } - /* We're not doing a capture any more, so we don't have a save file. */ g_assert(capture_opts->save_file); g_free(capture_opts->save_file); diff --git a/file.h b/file.h index 091ea08e3b..8b6e8d9cd7 100644 --- a/file.h +++ b/file.h @@ -61,8 +61,10 @@ typedef enum { cf_cb_file_read_finished, #ifdef HAVE_LIBPCAP cf_cb_live_capture_prepare, - cf_cb_live_capture_started, - cf_cb_live_capture_finished, + cf_cb_live_capture_update_started, + cf_cb_live_capture_fixed_started, + cf_cb_live_capture_update_finished, + cf_cb_live_capture_fixed_finished, #endif cf_cb_packet_selected, cf_cb_packet_unselected, diff --git a/gtk/main.c b/gtk/main.c index 9b2666b1ca..fa006d15fa 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -795,6 +795,7 @@ void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) { void statusbar_push_file_msg(gchar *msg) { + /*g_warning("statusbar_push: %s", msg);*/ gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, msg); } @@ -804,6 +805,7 @@ statusbar_push_file_msg(gchar *msg) void statusbar_pop_file_msg(void) { + /*g_warning("statusbar_pop");*/ gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx); } @@ -1292,7 +1294,7 @@ main_cf_cb_live_capture_prepare(capture_options *capture_opts) } static void -main_cf_cb_live_capture_started(capture_options *capture_opts) +main_cf_cb_live_capture_update_started(capture_options *capture_opts) { gchar *capture_msg; @@ -1319,7 +1321,36 @@ main_cf_cb_live_capture_started(capture_options *capture_opts) } static void -main_cf_cb_live_capture_finished(capture_file *cf) +main_cf_cb_live_capture_fixed_started(capture_options *capture_opts) +{ + gchar *capture_msg; + + /* Disable menu items that make no sense if you're currently running + a capture. */ + set_menus_for_capture_in_progress(TRUE); + + /* Enable menu items that make sense if you have some captured + packets (yes, I know, we don't have any *yet*). */ + /*set_menus_for_captured_packets(TRUE);*/ + + if(capture_opts->iface) { + capture_msg = g_strdup_printf(" %s: ", get_interface_descriptive_name(capture_opts->iface)); + } else { + capture_msg = g_strdup_printf(" "); + } + + statusbar_push_file_msg(capture_msg); + + g_free(capture_msg); + + /* Set up main window for a capture file. */ +/* main_set_for_capture_file(TRUE);*/ + /* XXX: shouldn't be already set */ + main_set_for_capture_file(FALSE); +} + +static void +main_cf_cb_live_capture_update_finished(capture_file *cf) { /* Pop the "" message off the status bar. */ statusbar_pop_file_msg(); @@ -1338,6 +1369,27 @@ main_cf_cb_live_capture_finished(capture_file *cf) /* Set up main window for a capture file. */ main_set_for_capture_file(TRUE); } + +static void +main_cf_cb_live_capture_fixed_finished(capture_file *cf) +{ + /* Pop the "" message off the status bar. */ + statusbar_pop_file_msg(); + + /*set_display_filename(cf);*/ + + /* Enable menu items that make sense if you're not currently running + a capture. */ + set_menus_for_capture_in_progress(FALSE); + + /* Enable menu items that make sense if you have a capture file + you've finished reading. */ + set_menus_for_capture_file(TRUE); + set_menus_for_unsaved_capture_file(!cf->user_saved); + + /* Set up main window for a capture file. */ + main_set_for_capture_file(TRUE); +} #endif static void @@ -1422,11 +1474,17 @@ void main_cf_callback(gint event, gpointer data, gpointer user_data _U_) case(cf_cb_live_capture_prepare): main_cf_cb_live_capture_prepare(data); break; - case(cf_cb_live_capture_started): - main_cf_cb_live_capture_started(data); + case(cf_cb_live_capture_update_started): + main_cf_cb_live_capture_update_started(data); break; - case(cf_cb_live_capture_finished): - main_cf_cb_live_capture_finished(data); + case(cf_cb_live_capture_fixed_started): + main_cf_cb_live_capture_fixed_started(data); + break; + case(cf_cb_live_capture_update_finished): + main_cf_cb_live_capture_update_finished(data); + break; + case(cf_cb_live_capture_fixed_finished): + main_cf_cb_live_capture_fixed_finished(data); break; #endif case(cf_cb_packet_selected):