statusbar changes:
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 18 Apr 2005 22:05:56 +0000 (22:05 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 18 Apr 2005 22:05:56 +0000 (22:05 +0000)
-show the current capture file size, if capturing in real time mode.
-move the packet "Drops" count (if available) from file to packets statusbar part

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

capture.c
file.c
file.h
gtk/main.c

index 4e21495edf4815a9038379896b35127fdcc6dd4e..f9f6788af8864a0220b12f51816daa31139c0e7e 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -278,6 +278,7 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
          file.
 
          XXX - abort on a read error? */
+         cf_callback_invoke(cf_cb_live_capture_update_continue, capture_opts->cf);
          main_window_update();
       break;
 
@@ -308,10 +309,7 @@ capture_input_closed(capture_options *capture_opts)
     }
 
     if(capture_opts->real_time_mode) {
-        /* first of all, update the file length field */
-        cf_update_f_len(capture_opts->cf);
-
-        /* we are not doing a capture any more */
+        /* 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.
diff --git a/file.c b/file.c
index f4055d7ed983467c97091021a7b184a3b3697aa1..dd624f8771d9124ef725dc3c4ea52e0422c0cd48 100644 (file)
--- a/file.c
+++ b/file.c
@@ -625,20 +625,6 @@ cf_finish_tail(capture_file *cf, int *err)
 }
 #endif /* HAVE_LIBPCAP */
 
-
-/* update the f_len field */
-cf_update_f_len(capture_file *cf) {
-  int         fd;
-  struct stat cf_stat;
-
-
-  fd = wtap_fd(cf->wth);
-  if (fstat(fd, &cf_stat) >= 0) {
-      cf->f_len = cf_stat.st_size;
-  }
-}
-
-
 const gchar *
 cf_get_display_name(capture_file *cf)
 {
@@ -908,6 +894,7 @@ read_packet(capture_file *cf, long offset)
     cf->plist_end = fdata;
 
     cf->count++;
+    cf->f_len = offset + phdr->caplen;
     fdata->num = cf->count;
     add_packet_to_packet_list(fdata, cf, pseudo_header, buf, TRUE);
   } else {
diff --git a/file.h b/file.h
index da9277f327bbe261e2694d6cca2d21eb51fb9f8c..74cc6981b61309895afcf963c88a948288dcc3a5 100644 (file)
--- a/file.h
+++ b/file.h
@@ -61,8 +61,9 @@ typedef enum {
     cf_cb_file_read_finished,
 #ifdef HAVE_LIBPCAP
     cf_cb_live_capture_update_started,
-    cf_cb_live_capture_fixed_started,
+    cf_cb_live_capture_update_continue,
     cf_cb_live_capture_update_finished,
+    cf_cb_live_capture_fixed_started,
     cf_cb_live_capture_fixed_finished,
 #endif
     cf_cb_packet_selected,
index 9447b6a99210fae644ba37aea5de6c8df6517e61..31dbd842f6cd1a9c6c49dd16267bb07d19b0e0eb 100644 (file)
@@ -846,8 +846,13 @@ void packets_bar_update(void)
 
         /* do we have any packets? */
         if(cfile.count) {
-            packets_str = g_strdup_printf(" P: %u D: %u M: %u", 
-                cfile.count, cfile.displayed_count, cfile.marked_count);
+            if(cfile.drops_known) {
+                packets_str = g_strdup_printf(" P: %u D: %u M: %u Drops: %u", 
+                    cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops);
+            } else {
+                packets_str = g_strdup_printf(" P: %u D: %u M: %u", 
+                    cfile.count, cfile.displayed_count, cfile.marked_count);
+            }
         } else {
             packets_str = g_strdup(" No Packets");
         }
@@ -1181,8 +1186,7 @@ set_display_filename(capture_file *cf)
 {
   const gchar *name_ptr;
   size_t       msg_len;
-  static const gchar done_fmt_nodrops[] = " File: %s %s %02u:%02u:%02u";
-  static const gchar done_fmt_drops[] = " File: %s %s %02u:%02u:%02u Drops: %u";
+  static const gchar done_fmt[] = " File: %s %s %02u:%02u:%02u";
   gchar       *done_msg;
   gchar       *win_name_fmt = "%s - Ethereal";
   gchar       *win_name;
@@ -1200,16 +1204,11 @@ set_display_filename(capture_file *cf)
   } else if (cf->f_len/1024 > 10) {
     size_str = g_strdup_printf("%ld KB", cf->f_len/1024);
   } else {
-    size_str = g_strdup_printf("%ld bytes", cf->f_len);
+    size_str = g_strdup_printf("%ld Bytes", cf->f_len);
   }
 
-  if (cf->drops_known) {
-    done_msg = g_strdup_printf(done_fmt_drops, name_ptr, size_str, 
-        cf->esec/3600, cf->esec%3600/60, cf->esec%60, cf->drops);
-  } else {
-    done_msg = g_strdup_printf(done_fmt_nodrops, name_ptr, size_str,
-        cf->esec/3600, cf->esec%3600/60, cf->esec%60);
-  }
+  done_msg = g_strdup_printf(done_fmt, name_ptr, size_str,
+    cf->esec/3600, cf->esec%3600/60, cf->esec%60);
   g_free(size_str);
   statusbar_push_file_msg(done_msg);
   g_free(done_msg);
@@ -1305,7 +1304,8 @@ main_cf_cb_live_capture_update_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);
 
@@ -1315,6 +1315,34 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts)
     main_set_for_capture_file(TRUE);
 }
 
+static void
+main_cf_cb_live_capture_update_continue(capture_file *cf)
+{
+    gchar *capture_msg;
+
+
+    statusbar_pop_file_msg();
+
+    if (cf->f_len/1024/1024 > 10) {
+        capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld MB", 
+            get_interface_descriptive_name(capture_opts->iface), 
+            capture_opts->save_file,
+            cf->f_len/1024/1024);
+    } else if (cf->f_len/1024 > 10) {
+        capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld KB", 
+            get_interface_descriptive_name(capture_opts->iface), 
+            capture_opts->save_file,
+            cf->f_len/1024);
+    } else {
+        capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld Bytes", 
+            get_interface_descriptive_name(capture_opts->iface), 
+            capture_opts->save_file,
+            cf->f_len);
+    }
+
+    statusbar_push_file_msg(capture_msg);
+}
+
 static void
 main_cf_cb_live_capture_update_finished(capture_file *cf)
 {
@@ -1471,6 +1499,9 @@ void main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
     case(cf_cb_live_capture_update_started):
         main_cf_cb_live_capture_update_started(data);
         break;
+    case(cf_cb_live_capture_update_continue):
+        main_cf_cb_live_capture_update_continue(data);
+        break;
     case(cf_cb_live_capture_fixed_started):
         main_cf_cb_live_capture_fixed_started(data);
         break;