added some more info to the statusbar (filesize, packet count, ..),
fixed a minor bug in the cfile handling (file length in summary dialog) svn path=/trunk/; revision=9961
This commit is contained in:
parent
22b253fb30
commit
3f2f2929eb
3
cfile.h
3
cfile.h
|
@ -1,7 +1,7 @@
|
|||
/* cfile.h
|
||||
* capture_file definition & GUI-independent manipulation
|
||||
*
|
||||
* $Id: cfile.h,v 1.8 2004/01/25 00:58:11 guy Exp $
|
||||
* $Id: cfile.h,v 1.9 2004/02/03 00:16:58 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -52,6 +52,7 @@ typedef struct _capture_file {
|
|||
int lnk_t; /* Link-layer type with which to save capture */
|
||||
guint32 vers; /* Version. For tcpdump minor is appended to major */
|
||||
int count; /* Total number of frames */
|
||||
int displayed_count; /* Number of displayed frames */
|
||||
int marked_count; /* Number of marked frames */
|
||||
gboolean drops_known; /* TRUE if we know how many packets were dropped */
|
||||
guint32 drops; /* Dropped packets */
|
||||
|
|
59
file.c
59
file.c
|
@ -1,7 +1,7 @@
|
|||
/* file.c
|
||||
* File I/O routines
|
||||
*
|
||||
* $Id: file.c,v 1.354 2004/01/31 04:10:04 guy Exp $
|
||||
* $Id: file.c,v 1.355 2004/02/03 00:16:58 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -189,6 +189,7 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
|
|||
|
||||
cf->cd_t = wtap_file_type(cf->wth);
|
||||
cf->count = 0;
|
||||
cf->displayed_count = 0;
|
||||
cf->marked_count = 0;
|
||||
cf->drops_known = FALSE;
|
||||
cf->drops = 0;
|
||||
|
@ -267,6 +268,11 @@ cf_close(capture_file *cf)
|
|||
packet_list_clear();
|
||||
packet_list_thaw();
|
||||
|
||||
cf->f_len = 0;
|
||||
cf->count = 0;
|
||||
cf->esec = 0;
|
||||
cf->eusec = 0;
|
||||
|
||||
/* Clear any file-related status bar messages.
|
||||
XXX - should be "clear *ALL* file-related status bar messages;
|
||||
will there ever be more than one on the stack? */
|
||||
|
@ -294,11 +300,12 @@ set_display_filename(capture_file *cf)
|
|||
{
|
||||
gchar *name_ptr;
|
||||
size_t msg_len;
|
||||
static const gchar done_fmt_nodrops[] = " File: %s";
|
||||
static const gchar done_fmt_drops[] = " File: %s Drops: %u";
|
||||
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";
|
||||
gchar *done_msg;
|
||||
gchar *win_name_fmt = "%s - Ethereal";
|
||||
gchar *win_name;
|
||||
gchar *size_str;
|
||||
|
||||
name_ptr = cf_get_display_name(cf);
|
||||
|
||||
|
@ -307,14 +314,20 @@ set_display_filename(capture_file *cf)
|
|||
add_menu_recent_capture_file(cf->filename);
|
||||
}
|
||||
|
||||
if (cf->drops_known) {
|
||||
msg_len = strlen(name_ptr) + strlen(done_fmt_drops) + 64;
|
||||
done_msg = g_malloc(msg_len);
|
||||
snprintf(done_msg, msg_len, done_fmt_drops, name_ptr, cf->drops);
|
||||
if (cf->f_len/1024/1024 > 10) {
|
||||
size_str = g_strdup_printf("%u MB", cf->f_len/1024/1024);
|
||||
} else if (cf->f_len/1024 > 10) {
|
||||
size_str = g_strdup_printf("%u KB", cf->f_len/1024);
|
||||
} else {
|
||||
msg_len = strlen(name_ptr) + strlen(done_fmt_nodrops);
|
||||
done_msg = g_malloc(msg_len);
|
||||
snprintf(done_msg, msg_len, done_fmt_nodrops, name_ptr);
|
||||
size_str = g_strdup_printf("%u 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);
|
||||
}
|
||||
statusbar_push_file_msg(done_msg);
|
||||
g_free(done_msg);
|
||||
|
@ -332,7 +345,6 @@ cf_read(capture_file *cf)
|
|||
int err;
|
||||
gchar *err_info;
|
||||
gchar *name_ptr, *load_msg, *load_fmt = "%s";
|
||||
size_t msg_len;
|
||||
char *errmsg;
|
||||
char errmsg_errno[1024+1];
|
||||
gchar err_str[2048+1];
|
||||
|
@ -358,10 +370,11 @@ cf_read(capture_file *cf)
|
|||
tap_dfilter_dlg_update();
|
||||
name_ptr = get_basename(cf->filename);
|
||||
|
||||
msg_len = strlen(name_ptr) + strlen(load_fmt) + 2;
|
||||
load_msg = g_malloc(msg_len);
|
||||
snprintf(load_msg, msg_len, load_fmt, name_ptr);
|
||||
load_msg = g_strdup_printf(" Loading: %s", name_ptr);
|
||||
statusbar_push_file_msg(load_msg);
|
||||
g_free(load_msg);
|
||||
|
||||
load_msg = g_strdup_printf(load_fmt, name_ptr);
|
||||
|
||||
/* Update the progress bar when it gets to this value. */
|
||||
progbar_nextstep = 0;
|
||||
|
@ -581,6 +594,8 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
{
|
||||
gchar *err_info;
|
||||
long data_offset;
|
||||
int fd;
|
||||
struct stat cf_stat;
|
||||
|
||||
packet_list_freeze();
|
||||
|
||||
|
@ -613,6 +628,13 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
/* We're done reading sequentially through the file. */
|
||||
cf->state = FILE_READ_DONE;
|
||||
|
||||
/* we have to update the f_len field */
|
||||
/* Find the size of the file. */
|
||||
fd = wtap_fd(cf->wth);
|
||||
if (fstat(fd, &cf_stat) >= 0) {
|
||||
cf->f_len = cf_stat.st_size;
|
||||
}
|
||||
|
||||
/* We're done reading sequentially through the file; close the
|
||||
sequential I/O side, to free up memory it requires. */
|
||||
wtap_sequential_close(cf->wth);
|
||||
|
@ -664,12 +686,12 @@ cf_get_display_name(capture_file *cf)
|
|||
/* Add this filename to the list of recent files in the "Recent Files" submenu */
|
||||
add_menu_recent_capture_file(cf->filename);
|
||||
} else {
|
||||
displayname="<no file>";
|
||||
displayname="(No file)";
|
||||
}
|
||||
} else {
|
||||
/* The file we read is a temporary file from a live capture;
|
||||
we don't mention its name. */
|
||||
displayname = "<capture>";
|
||||
displayname = "(Untitled)";
|
||||
}
|
||||
return displayname;
|
||||
}
|
||||
|
@ -866,6 +888,8 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
|||
frame. */
|
||||
prevsec = fdata->abs_secs;
|
||||
prevusec = fdata->abs_usecs;
|
||||
|
||||
cf->displayed_count++;
|
||||
} else {
|
||||
/* This frame didn't pass the display filter, so it's not being added
|
||||
to the clist, and thus has no row. */
|
||||
|
@ -1076,6 +1100,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
|||
cf->first_displayed = NULL;
|
||||
cf->last_displayed = NULL;
|
||||
|
||||
/* We currently don't display any packets */
|
||||
cf->displayed_count = 0;
|
||||
|
||||
/* Iterate through the list of frames. Call a routine for each frame
|
||||
to check whether it should be displayed and, if so, add it to
|
||||
the display list. */
|
||||
|
|
69
gtk/main.c
69
gtk/main.c
|
@ -1,6 +1,6 @@
|
|||
/* main.c
|
||||
*
|
||||
* $Id: main.c,v 1.387 2004/02/01 22:43:34 guy Exp $
|
||||
* $Id: main.c,v 1.388 2004/02/03 00:16:58 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -136,6 +136,7 @@ GtkWidget *top_level = NULL, *tree_view, *byte_nb_ptr, *tv_scrollw;
|
|||
GtkWidget *upper_pane, *lower_pane;
|
||||
GtkWidget *menubar, *main_vbox, *main_tb, *pkt_scrollw, *stat_hbox, *filter_tb;
|
||||
static GtkWidget *info_bar;
|
||||
static GtkWidget *packets_bar = NULL;
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
GdkFont *m_r_font, *m_b_font;
|
||||
guint m_font_height, m_font_width;
|
||||
|
@ -143,6 +144,8 @@ guint m_font_height, m_font_width;
|
|||
PangoFontDescription *m_r_font, *m_b_font;
|
||||
#endif
|
||||
static guint main_ctx, file_ctx, help_ctx;
|
||||
static guint packets_ctx;
|
||||
static gchar *packets_str = NULL;
|
||||
static GString *comp_info_str, *runtime_info_str;
|
||||
gchar *ethereal_path = NULL;
|
||||
gchar *last_open_dir = NULL;
|
||||
|
@ -852,7 +855,7 @@ filter_reset_cb(GtkWidget *w, gpointer data _U_)
|
|||
if ((filter_te = OBJECT_GET_DATA(w, E_DFILTER_TE_KEY))) {
|
||||
gtk_entry_set_text(GTK_ENTRY(filter_te), "");
|
||||
}
|
||||
filter_packets(&cfile, NULL);
|
||||
main_filter_packets(&cfile, "");
|
||||
}
|
||||
|
||||
/* mark as reference time frame */
|
||||
|
@ -1096,6 +1099,31 @@ statusbar_pop_field_msg(void)
|
|||
gtk_statusbar_pop(GTK_STATUSBAR(info_bar), help_ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* update the packets statusbar to the current values
|
||||
*/
|
||||
void packets_bar_update(void)
|
||||
{
|
||||
|
||||
if(packets_bar) {
|
||||
/* remove old status */
|
||||
if(packets_str) {
|
||||
g_free(packets_str);
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(packets_bar), packets_ctx);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
} else {
|
||||
packets_str = g_strdup(" No Packets");
|
||||
}
|
||||
gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, packets_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
main_do_quit(void)
|
||||
{
|
||||
|
@ -3423,7 +3451,30 @@ static void try_to_get_windows_font_gtk2(void)
|
|||
|
||||
#endif /* WIN32 */
|
||||
|
||||
GtkWidget *info_bar_new(void)
|
||||
{
|
||||
/* tip: tooltips don't work on statusbars! */
|
||||
info_bar = gtk_statusbar_new();
|
||||
main_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "main");
|
||||
file_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "file");
|
||||
help_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "help");
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(info_bar), FALSE);
|
||||
#endif
|
||||
gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, DEF_READY_MESSAGE);
|
||||
|
||||
return info_bar;
|
||||
}
|
||||
|
||||
GtkWidget *packets_bar_new(void)
|
||||
{
|
||||
/* tip: tooltips don't work on statusbars! */
|
||||
packets_bar = gtk_statusbar_new();
|
||||
packets_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(packets_bar), "packets");
|
||||
packets_bar_update();
|
||||
|
||||
return packets_bar;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -3457,6 +3508,7 @@ void main_widgets_rearrange(void) {
|
|||
gtk_widget_ref(lower_pane);
|
||||
gtk_widget_ref(stat_hbox);
|
||||
gtk_widget_ref(info_bar);
|
||||
gtk_widget_ref(packets_bar);
|
||||
|
||||
/* empty all containers participating */
|
||||
gtk_container_foreach(GTK_CONTAINER(main_vbox), foreach_remove_a_child, main_vbox);
|
||||
|
@ -3525,6 +3577,7 @@ void main_widgets_rearrange(void) {
|
|||
/* statusbar */
|
||||
if (recent.statusbar_show) {
|
||||
gtk_box_pack_start(GTK_BOX(stat_hbox), info_bar, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(stat_hbox), packets_bar, TRUE, TRUE, 0);
|
||||
}
|
||||
|
||||
gtk_widget_show(main_vbox);
|
||||
|
@ -3728,14 +3781,14 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
|||
OBJECT_SET_DATA(popup_menu_object, E_DFILTER_TE_KEY, filter_te);
|
||||
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_KEY, packet_list);
|
||||
|
||||
/* statusbar */
|
||||
info_bar = gtk_statusbar_new();
|
||||
main_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "main");
|
||||
file_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "file");
|
||||
help_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "help");
|
||||
gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, DEF_READY_MESSAGE);
|
||||
/* info (main) statusbar */
|
||||
info_bar = info_bar_new();
|
||||
gtk_widget_show(info_bar);
|
||||
|
||||
/* packets statusbar */
|
||||
packets_bar = packets_bar_new();
|
||||
gtk_widget_show(packets_bar);
|
||||
|
||||
/* Filter/status hbox */
|
||||
stat_hbox = gtk_hbox_new(FALSE, 1);
|
||||
gtk_container_border_width(GTK_CONTAINER(stat_hbox), 0);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* main.h
|
||||
* Global defines, etc.
|
||||
*
|
||||
* $Id: main.h,v 1.41 2004/01/31 18:32:37 ulfl Exp $
|
||||
* $Id: main.h,v 1.42 2004/02/03 00:16:58 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -109,6 +109,8 @@ extern gboolean main_do_quit(void);
|
|||
extern void main_widgets_rearrange(void);
|
||||
extern int main_filter_packets(capture_file *cf, const gchar *dftext);
|
||||
extern void dnd_open_file_cmd(gpointer cf_name);
|
||||
extern void packets_bar_update(void);
|
||||
|
||||
|
||||
typedef enum {
|
||||
FA_SUCCESS,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* menu.c
|
||||
* Menu routines
|
||||
*
|
||||
* $Id: menu.c,v 1.155 2004/02/01 15:36:15 ulfl Exp $
|
||||
* $Id: menu.c,v 1.156 2004/02/03 00:16:59 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -1272,6 +1272,7 @@ set_menus_for_capture_file(gboolean have_capture_file)
|
|||
set_menu_sensitivity(main_menu_factory, "/File/Export", have_capture_file);
|
||||
set_menu_sensitivity(main_menu_factory, "/View/Reload", have_capture_file);
|
||||
set_toolbar_for_capture_file(have_capture_file);
|
||||
packets_bar_update();
|
||||
}
|
||||
|
||||
/* Enable or disable menu items based on whether you have an unsaved
|
||||
|
@ -1410,6 +1411,7 @@ set_menus_for_captured_packets(gboolean have_captured_packets)
|
|||
walk_menu_tree_for_captured_packets(&tap_menu_tree_root,
|
||||
have_captured_packets);
|
||||
set_toolbar_for_captured_packets(have_captured_packets);
|
||||
packets_bar_update();
|
||||
}
|
||||
|
||||
/* Enable or disable menu items based on whether a packet is selected and,
|
||||
|
@ -1515,6 +1517,7 @@ set_menus_for_selected_packet(capture_file *cf)
|
|||
|
||||
walk_menu_tree_for_selected_packet(&tap_menu_tree_root, cf->current_frame,
|
||||
cf->edt);
|
||||
packets_bar_update();
|
||||
}
|
||||
|
||||
/* Enable or disable menu items based on whether a tree row is selected
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet_list.c
|
||||
* packet list related functions 2002 Olivier Abad
|
||||
*
|
||||
* $Id: packet_list.c,v 1.16 2004/01/31 04:26:23 guy Exp $
|
||||
* $Id: packet_list.c,v 1.17 2004/02/03 00:16:59 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -35,6 +35,7 @@
|
|||
#include "color.h"
|
||||
#include "../ui_util.h"
|
||||
#include "ui_util.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "color_utils.h"
|
||||
#include "column.h"
|
||||
|
@ -294,7 +295,12 @@ set_frame_mark(gboolean set, frame_data *frame, gint row) {
|
|||
eth_clist_set_background(ETH_CLIST(packet_list), row, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* call this after last set_frame_mark is done */
|
||||
void mark_frames_ready(void) {
|
||||
file_set_save_marked_sensitive();
|
||||
packets_bar_update();
|
||||
}
|
||||
|
||||
void mark_frame_cb(GtkWidget *w _U_, gpointer data _U_) {
|
||||
|
@ -304,23 +310,29 @@ void mark_frame_cb(GtkWidget *w _U_, gpointer data _U_) {
|
|||
cfile.current_frame,
|
||||
eth_clist_find_row_from_data(ETH_CLIST(packet_list),
|
||||
cfile.current_frame));
|
||||
mark_frames_ready();
|
||||
}
|
||||
}
|
||||
|
||||
static void mark_all_frames(gboolean set) {
|
||||
frame_data *fdata;
|
||||
|
||||
/* XXX: we might need a progressbar here */
|
||||
cfile.marked_count = 0;
|
||||
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
|
||||
set_frame_mark(set,
|
||||
fdata,
|
||||
eth_clist_find_row_from_data(ETH_CLIST(packet_list), fdata));
|
||||
}
|
||||
mark_frames_ready();
|
||||
}
|
||||
|
||||
void update_marked_frames(void) {
|
||||
frame_data *fdata;
|
||||
|
||||
if (cfile.plist == NULL) return;
|
||||
|
||||
/* XXX: we might need a progressbar here */
|
||||
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
|
||||
if (fdata->flags.marked)
|
||||
set_frame_mark(TRUE,
|
||||
|
@ -328,6 +340,7 @@ void update_marked_frames(void) {
|
|||
eth_clist_find_row_from_data(ETH_CLIST(packet_list),
|
||||
fdata));
|
||||
}
|
||||
mark_frames_ready();
|
||||
}
|
||||
|
||||
void mark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
|
||||
|
@ -363,6 +376,7 @@ packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
|
|||
frame_data *fdata = (frame_data *) eth_clist_get_row_data(ETH_CLIST(w),
|
||||
row);
|
||||
set_frame_mark(!fdata->flags.marked, fdata, row);
|
||||
mark_frames_ready();
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -382,6 +396,7 @@ packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
|
|||
frame_data *fdata = (frame_data *)eth_clist_get_row_data(ETH_CLIST(w),
|
||||
row);
|
||||
set_frame_mark(!fdata->flags.marked, fdata, row);
|
||||
mark_frames_ready();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -572,6 +587,7 @@ void
|
|||
packet_list_thaw(void)
|
||||
{
|
||||
eth_clist_thaw(ETH_CLIST(packet_list));
|
||||
packets_bar_update();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue