diff options
Diffstat (limited to 'ui/gtk/capture_file_dlg.c')
-rw-r--r-- | ui/gtk/capture_file_dlg.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c index d83ca35cde..bae633e28e 100644 --- a/ui/gtk/capture_file_dlg.c +++ b/ui/gtk/capture_file_dlg.c @@ -87,7 +87,7 @@ static gboolean test_file_close(capture_file *cf, gboolean from_quit, #define PREVIEW_TABLE_KEY "preview_table_key" #define PREVIEW_FORMAT_KEY "preview_format_key" #define PREVIEW_SIZE_KEY "preview_size_key" -#define PREVIEW_PACKETS_KEY "preview_packets_key" +#define PREVIEW_DATA_RECORDS_KEY "preview_data_records_key" #define PREVIEW_FIRST_ELAPSED_KEY "preview_first_elapsed_key" /* XXX - can we make these not be static? */ @@ -113,7 +113,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name) gtk_label_set_text(GTK_LABEL(label), "-"); label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_SIZE_KEY); gtk_label_set_text(GTK_LABEL(label), "-"); - label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_PACKETS_KEY); + label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_DATA_RECORDS_KEY); gtk_label_set_text(GTK_LABEL(label), "-"); label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FIRST_ELAPSED_KEY); gtk_label_set_text(GTK_LABEL(label), "-"); @@ -166,22 +166,21 @@ preview_do(GtkWidget *prev, wtap *wth) GtkWidget *label; int err; gchar *err_info; - guint32 packets; - ws_file_preview_times times; - ws_file_preview_times_status status; + ws_file_preview_stats stats; + ws_file_preview_stats_status status; gchar string_buff[PREVIEW_STR_MAX]; gchar first_buff[PREVIEW_STR_MAX]; time_t ti_time; struct tm *ti_tm; unsigned int elapsed_time; - status = get_times_for_preview(wth, ×, &packets, &err, &err_info); + status = get_stats_for_preview(wth, &stats, &err, &err_info); if(status == PREVIEW_READ_ERROR) { /* XXX - give error details? */ g_free(err_info); - g_snprintf(string_buff, PREVIEW_STR_MAX, "error after reading %u packets", packets); - label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_PACKETS_KEY); + g_snprintf(string_buff, PREVIEW_STR_MAX, "error after reading %u records", stats.records); + label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_DATA_RECORDS_KEY); gtk_label_set_text(GTK_LABEL(label), string_buff); wtap_close(wth); return; @@ -189,18 +188,22 @@ preview_do(GtkWidget *prev, wtap *wth) /* packet count */ if(status == PREVIEW_TIMED_OUT) { - g_snprintf(string_buff, PREVIEW_STR_MAX, "more than %u packets (preview timeout)", packets); + g_snprintf(string_buff, PREVIEW_STR_MAX, "more than %u data records (preview timeout)", stats.data_records); } else { - g_snprintf(string_buff, PREVIEW_STR_MAX, "%u", packets); + g_snprintf(string_buff, PREVIEW_STR_MAX, "%u", stats.data_records); } - label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_PACKETS_KEY); + label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_DATA_RECORDS_KEY); gtk_label_set_text(GTK_LABEL(label), string_buff); /* First packet */ - if(status == PREVIEW_HAVE_NO_TIMES) { - g_snprintf(first_buff, PREVIEW_STR_MAX, "unknown"); - } else { - ti_time = (long)times.start_time; + if(stats.have_times) { + /* + * We saw at least one record with a time stamp, so we can give + * a start time (if we have a mix of records with and without + * time stamps, and there were records without time stamps + * before the one with a time stamp, this may be inaccurate). + */ + ti_time = (long)stats.start_time; ti_tm = localtime( &ti_time ); if (ti_tm) { g_snprintf(first_buff, PREVIEW_STR_MAX, @@ -214,22 +217,30 @@ preview_do(GtkWidget *prev, wtap *wth) } else { g_snprintf(first_buff, PREVIEW_STR_MAX, "?"); } + } else { + g_snprintf(first_buff, PREVIEW_STR_MAX, "unknown"); } /* Elapsed time */ - if(status == PREVIEW_HAVE_NO_TIMES) { - g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / unknown", first_buff); - } else { - elapsed_time = (unsigned int)(times.stop_time-times.start_time); - if(status == PREVIEW_TIMED_OUT) { - g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / unknown", first_buff); - } else if (elapsed_time/86400) { + if(status == PREVIEW_SUCCEEDED && stats.have_times) { + /* + * We didn't time out, so we looked at all packets, and we got + * at least one packet with a time stamp, so we can calculate + * an elapsed time from the time stamp of the last packet with + * with a time stamp (if we have a mix of records with and without + * time stamps, and there were records without time stamps after + * the last one with a time stamp, this may be inaccurate). + */ + elapsed_time = (unsigned int)(stats.stop_time-stats.start_time); + if (elapsed_time/86400) { g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / %02u days %02u:%02u:%02u", first_buff, elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60); } else { g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / %02u:%02u:%02u", first_buff, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60); } + } else { + g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / unknown", first_buff); } label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FIRST_ELAPSED_KEY); gtk_label_set_text(GTK_LABEL(label), string_buff); @@ -365,7 +376,7 @@ preview_new(void) label = add_string_to_grid(grid, &row, "Size:", "-"); g_object_set_data(G_OBJECT(grid), PREVIEW_SIZE_KEY, label); label = add_string_to_grid(grid, &row, "Packets:", "-"); - g_object_set_data(G_OBJECT(grid), PREVIEW_PACKETS_KEY, label); + g_object_set_data(G_OBJECT(grid), PREVIEW_DATA_RECORDS_KEY, label); label = add_string_to_grid(grid, &row, "Start / elapsed:", "-"); g_object_set_data(G_OBJECT(grid), PREVIEW_FIRST_ELAPSED_KEY, label); |