rename capture_clear() to capture_restart()
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Apr 2005 20:08:00 +0000 (20:08 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Apr 2005 20:08:00 +0000 (20:08 +0000)
statusbar update should work now even in capture error case

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@14105 f5534014-38df-0310-8fa8-9805f1628bb7

capture.c
capture.h
gtk/capture_dlg.c
gtk/capture_dlg.h
gtk/main.c
gtk/menu.c
gtk/toolbar.c

index e6cfde0fdea4a974b2859a607cff42f7043e19d5..07b751e9ec8a1850f466cef3fa619edf12ecb816 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -104,7 +104,7 @@ capture_stop(capture_options *capture_opts)
 
 
 void
-capture_clear(capture_options *capture_opts)
+capture_restart(capture_options *capture_opts)
 {
     capture_opts->restart = TRUE;
     capture_stop(capture_opts);
@@ -263,6 +263,8 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
   int  err;
 
 
+  g_assert(capture_opts->save_file);
+
   if(capture_opts->real_time_mode) {
     /* Read from the capture file the number of records the child told us
        it added.
@@ -296,6 +298,15 @@ capture_input_closed(capture_options *capture_opts)
     int  err;
 
 
+    /* if we have no file (happens if an error occured), do a fake start */
+    if(capture_opts->save_file == NULL) {
+        if(capture_opts->real_time_mode) {
+            cf_callback_invoke(cf_cb_live_capture_update_started, capture_opts);
+        } else {
+            cf_callback_invoke(cf_cb_live_capture_fixed_started, 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);
@@ -339,6 +350,7 @@ capture_input_closed(capture_options *capture_opts)
 
     /* if we couldn't open a capture file, there's nothing more for us to do */
     if(capture_opts->save_file == NULL) {
+        cf_close(capture_opts->cf);
         return;
     }
 
index 98cafb1cc75ee7c9a26759ab18d266d73c987720..b903b2e71e0555c7c558b128713077d8121d80ad 100644 (file)
--- a/capture.h
+++ b/capture.h
@@ -107,8 +107,8 @@ extern gboolean capture_start(capture_options *capture_opts);
 /** Stop a capture session (usually from a menu item). */
 extern void capture_stop(capture_options *capture_opts);
 
-/** Clear the current captured packets and start again. */
-extern void capture_clear(capture_options *capture_opts);
+/** Restart the current captured packets and start again. */
+extern void capture_restart(capture_options *capture_opts);
 
 /** Terminate the capture child cleanly when exiting. */
 extern void capture_kill_child(capture_options *capture_opts);
index b4271e0ea509f63dbeec9e3538ee5d273cdf5c3f..952734cb41e1f01ce5097c8ca1fa7471ec02eb05 100644 (file)
@@ -165,9 +165,9 @@ capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
 }
 
 void
-capture_clear_cb(GtkWidget *w _U_, gpointer d _U_)
+capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
 {
-    capture_clear(capture_opts);
+    capture_restart(capture_opts);
 }
 
 static void
index 70921784f299cbfcddb30f4ef931e694f80b524f..2d76a848bdf0a2a47b91e73a0448130598352cac 100644 (file)
@@ -52,12 +52,12 @@ void capture_start_cb(GtkWidget *widget, gpointer data);
  */
 void capture_stop_cb(GtkWidget *widget, gpointer data);
 
-/** User requested capture clear by menu or toolbar.
+/** User requested capture restart by menu or toolbar.
  *
  * @param widget parent widget (unused)
  * @param data unused
  */
-void capture_clear_cb(GtkWidget *widget, gpointer data);
+void capture_restart_cb(GtkWidget *widget, gpointer data);
 
 /** Create the "Capture Options" dialog box.
  */
index 268cdce8300e8c32b0f64e9b1ee365d6060c82cb..9447b6a99210fae644ba37aea5de6c8df6517e61 100644 (file)
@@ -1357,7 +1357,8 @@ main_cf_cb_live_capture_fixed_started(capture_options *capture_opts)
     /*set_menus_for_captured_packets(TRUE);*/
 
     capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s", 
-        get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file);
+        get_interface_descriptive_name(capture_opts->iface), 
+        (capture_opts->save_file) ? capture_opts->save_file : "");
 
     statusbar_push_file_msg(capture_msg);
     gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, " <capturing>");
index b217f6f6baa900d08b5fd8e05ea3774cd8cbd886..84597557d553dafb4f42b987bf2ac76645cd5f0a 100644 (file)
@@ -305,7 +305,7 @@ static GtkItemFactoryEntry menu_items[] =
                              capture_start_cb, 0, ETHEREAL_STOCK_CAPTURE_START),
     ITEM_FACTORY_STOCK_ENTRY("/Capture/S_top", "<control>E", capture_stop_cb,
                              0, ETHEREAL_STOCK_CAPTURE_STOP),
-    ITEM_FACTORY_STOCK_ENTRY("/Capture/_Restart", NULL, capture_clear_cb,
+    ITEM_FACTORY_STOCK_ENTRY("/Capture/_Restart", NULL, capture_restart_cb,
                              0, ETHEREAL_STOCK_CAPTURE_RESTART),
     ITEM_FACTORY_STOCK_ENTRY("/Capture/Capture _Filters...", NULL, cfilter_dialog_cb,
                        0, ETHEREAL_STOCK_CAPTURE_FILTER),
index 80c16af37d43bcbc8441dd710d98e33db55554ce..5eaef1f31544ce638398f8e21b3486cabf167e38 100644 (file)
@@ -502,7 +502,7 @@ toolbar_new(void)
     toolbar_item(stop_button, window, main_tb, 
         ETHEREAL_STOCK_CAPTURE_STOP, "Stop the running live capture", capture_stop_24_xpm, capture_stop_cb, NULL);
     toolbar_item(clear_button, window, main_tb, 
-        ETHEREAL_STOCK_CAPTURE_RESTART, "Restart the running live capture", capture_restart_24_xpm, capture_clear_cb, NULL);
+        ETHEREAL_STOCK_CAPTURE_RESTART, "Restart the running live capture", capture_restart_24_xpm, capture_restart_cb, NULL);
     toolbar_append_separator(main_tb);
 #endif /* HAVE_LIBPCAP */