Set reftime without recreating the packet list.
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 28 Jul 2009 16:20:05 +0000 (16:20 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 28 Jul 2009 16:20:05 +0000 (16:20 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29220 f5534014-38df-0310-8fa8-9805f1628bb7

file.c
gtk/main.c
gtk/new_packet_list.c

diff --git a/file.c b/file.c
index f37c933db33afe271bbf13e718dd8bdd7aeeb828..5f7840e7d990eb4f99cc81dff5926b82bcfc93e8 100644 (file)
--- a/file.c
+++ b/file.c
@@ -116,6 +116,8 @@ static const char *file_rename_error_message(int err);
 static void cf_write_failure_alert_box(const char *filename, int err);
 static void cf_close_failure_alert_box(const char *filename, int err);
 
+static void ref_time_packets(capture_file *cf);
+
 /* Update the progress bar this many times when reading a file. */
 #define N_PROGBAR_UPDATES      100
 
@@ -1555,7 +1557,12 @@ cf_colorize_packets(capture_file *cf)
 void
 cf_reftime_packets(capture_file *cf)
 {
-  rescan_packets(cf, "Updating Reftime", "all packets", FALSE, FALSE);
+
+#ifdef NEW_PACKET_LIST
+  ref_time_packets(cf);
+#else
+  rescan_packets(cf, "Reprocessing", "all packets", TRUE, TRUE);
+#endif
 }
 
 void
@@ -1888,6 +1895,79 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
     dfilter_free(dfcode);
   }
 }
+/*
+ * Scan trough all frame data and recalculate the ref time
+ * without rereading the file.
+ * XXX - do we need a progres bar or is this fast enough?
+ */
+
+static void
+ref_time_packets(capture_file *cf)
+{
+
+
+  frame_data *fdata;
+
+  nstime_set_unset(&first_ts);
+  nstime_set_unset(&prev_dis_ts);
+  cum_bytes=0;
+
+  for (fdata = cf->plist; fdata != NULL; fdata = fdata->next) {
+
+       fdata->cum_bytes  = cum_bytes + fdata->pkt_len;
+       /* just add some value here until we know if it is being displayed or not */
+       fdata->cum_bytes  = cum_bytes + fdata->pkt_len;
+
+       /* If we don't have the time stamp of the first packet in the
+     capture, it's because this is the first packet.  Save the time
+     stamp of this packet as the time stamp of the first packet. */
+       if (nstime_is_unset(&first_ts)) {
+       first_ts  = fdata->abs_ts;
+       }
+         /* if this frames is marked as a reference time frame, reset
+       firstsec and firstusec to this frame */
+       if(fdata->flags.ref_time){
+    first_ts = fdata->abs_ts;
+       }
+
+       /* If we don't have the time stamp of the previous displayed packet,
+     it's because this is the first displayed packet.  Save the time
+     stamp of this packet as the time stamp of the previous displayed
+     packet. */
+       if (nstime_is_unset(&prev_dis_ts)) {
+       prev_dis_ts = fdata->abs_ts;
+       }
+
+       /* Get the time elapsed between the first packet and this packet. */
+       nstime_delta(&fdata->rel_ts, &fdata->abs_ts, &first_ts);
+
+       /* If it's greater than the current elapsed time, set the elapsed time
+     to it (we check for "greater than" so as not to be confused by
+     time moving backwards). */
+       if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs
+               || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) {
+       cf->elapsed_time = fdata->rel_ts;
+       }
+
+       /* Get the time elapsed between the previous displayed packet and
+     this packet. */
+       nstime_delta(&fdata->del_dis_ts, &fdata->abs_ts, &prev_dis_ts);
+
+       if( (fdata->flags.passed_dfilter) || (fdata->flags.ref_time) ){
+       /* This frame either passed the display filter list or is marked as
+               a time reference frame.  All time reference frames are displayed
+               even if they dont pass the display filter */
+       if(fdata->flags.ref_time){
+                       /* if this was a TIME REF frame we should reset the cul bytes field */
+               cum_bytes = fdata->pkt_len;
+               fdata->cum_bytes =  cum_bytes;
+       } else {
+               /* increase cum_bytes with this packets length */
+               cum_bytes += fdata->pkt_len;
+       }
+       }
+  }
+}
 
 typedef enum {
   PSP_FINISHED,
index 6d25b66845ae46d11de145f5da3c1af441897409..400f2818bb738ee2a871feed1b69f0f1b59ad874 100644 (file)
@@ -607,6 +607,9 @@ set_frame_reftime(gboolean set, frame_data *frame, gint row) {
     frame->flags.ref_time=0;
   }
   cf_reftime_packets(&cfile);
+#ifdef NEW_PACKET_LIST
+  new_packet_list_queue_draw();
+#endif
 }
 
 
index 39c91c9519fcc9a6fee268f2b76e1e4c8034c5f5..27808ec18d6883c8a8ae48137befbbfa3745b33b 100644 (file)
@@ -40,6 +40,7 @@
 #include "gui_utils.h"
 #include "packet_list_store.h"
 #include "epan/column_info.h"
+#include "epan/prefs.h"
 #include "../ui_util.h"
 #include "epan/emem.h"
 #include "globals.h"
@@ -406,12 +407,17 @@ show_cell_data_func(GtkTreeViewColumn *col _U_, GtkCellRenderer *renderer,
                                   -1);
        }
 
-       if(fdata->color_filter){
-               color_filter = fdata->color_filter;
-               fg_color_t = color_filter->fg_color;
-               bg_color_t = color_filter->bg_color;
-               color_t_to_gdkcolor(&fg_gdk, &fg_color_t);
-               color_t_to_gdkcolor(&bg_gdk, &bg_color_t);
+       if((fdata->color_filter)||(fdata->flags.marked)){
+               if(fdata->color_filter){
+                       color_filter = fdata->color_filter;
+                       fg_color_t = color_filter->fg_color;
+                       bg_color_t = color_filter->bg_color;
+                       color_t_to_gdkcolor(&fg_gdk, &fg_color_t);
+                       color_t_to_gdkcolor(&bg_gdk, &bg_color_t);
+               }else{
+                       color_t_to_gdkcolor(&fg_gdk, &prefs.gui_marked_fg);
+                       color_t_to_gdkcolor(&bg_gdk, &prefs.gui_marked_bg);
+               }
                g_object_set(renderer,
                     "text", cell_text,
                     "foreground-gdk", &fg_gdk,