- Add a LED in the statusbar to indicate that capture comments exists,
clickable to open an edit window. - Add checks for NULL pointers. Help with a different color LED possibly with Jeff's (c) in it apreceated. Should the LED be placed elsewhere or the whole thing done differently? svn path=/trunk/; revision=41242
This commit is contained in:
parent
094e8f8947
commit
d24fad6371
31
file.c
31
file.c
|
@ -3650,6 +3650,37 @@ cf_unignore_frame(capture_file *cf, frame_data *frame)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the comment in SHB block
|
||||
*/
|
||||
|
||||
const gchar*
|
||||
cf_read_shb_comment(capture_file *cf)
|
||||
{
|
||||
wtapng_section_t* shb_inf;
|
||||
const gchar *temp_str;
|
||||
|
||||
|
||||
/* Get info from SHB */
|
||||
shb_inf = wtap_file_get_shb_info(cf->wth);
|
||||
if(shb_inf == NULL)
|
||||
return NULL;
|
||||
temp_str = shb_inf->opt_comment;
|
||||
g_free(shb_inf);
|
||||
|
||||
return temp_str;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
cf_update_capture_comment(capture_file *cf, gchar *comment)
|
||||
{
|
||||
|
||||
/* Get info from SHB */
|
||||
wtap_write_shb_comment(cf->wth, comment);
|
||||
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
wtap_dumper *pdh;
|
||||
const char *fname;
|
||||
|
|
17
file.h
17
file.h
|
@ -580,6 +580,23 @@ cf_status_t
|
|||
cf_merge_files(char **out_filename, int in_file_count,
|
||||
char *const *in_filenames, int file_type, gboolean do_append);
|
||||
|
||||
|
||||
/**
|
||||
* Get the comment on a capture from the SHB data block
|
||||
*
|
||||
* @param cf the capture file
|
||||
*/
|
||||
const gchar* cf_read_shb_comment(capture_file *cf);
|
||||
|
||||
/**
|
||||
* Update(replace) the comment on a capture from the SHB data block
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param comment the string replacing the old comment
|
||||
*/
|
||||
void cf_update_capture_comment(capture_file *cf, gchar *comment);
|
||||
|
||||
|
||||
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
|
||||
void read_keytab_file(const char *);
|
||||
#endif
|
||||
|
|
19
summary.c
19
summary.c
|
@ -159,11 +159,18 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
shb_inf = wtap_file_get_shb_info(cf->wth);
|
||||
|
||||
shb_inf = wtap_file_get_shb_info(cf->wth);
|
||||
st->opt_comment = shb_inf->opt_comment;
|
||||
st->shb_hardware = shb_inf->shb_hardware;
|
||||
st->shb_os = shb_inf->shb_os;
|
||||
st->shb_user_appl = shb_inf->shb_user_appl;
|
||||
g_free(shb_inf);
|
||||
if(shb_inf == NULL){
|
||||
st->opt_comment = NULL;
|
||||
st->shb_hardware = NULL;
|
||||
st->shb_os = NULL;
|
||||
st->shb_user_appl = NULL;
|
||||
}else{
|
||||
st->opt_comment = shb_inf->opt_comment;
|
||||
st->shb_hardware = shb_inf->shb_hardware;
|
||||
st->shb_os = shb_inf->shb_os;
|
||||
st->shb_user_appl = shb_inf->shb_user_appl;
|
||||
g_free(shb_inf);
|
||||
}
|
||||
|
||||
st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options));
|
||||
}
|
||||
|
@ -228,4 +235,4 @@ summary_update_comment(capture_file *cf, gchar *comment)
|
|||
/* Get info from SHB */
|
||||
wtap_write_shb_comment(cf->wth, comment);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/epan.h>
|
||||
#include <epan/filesystem.h>
|
||||
|
||||
#include "../cfile.h"
|
||||
#include "../file.h"
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
|
@ -46,10 +52,11 @@
|
|||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
GtkWidget *edit_or_add_pkt_comment_dlg = NULL;
|
||||
GtkWidget *edit_or_add_capture_comment_dlg = NULL;
|
||||
|
||||
|
||||
static void
|
||||
pkt_comment_text_buff_clear_cb(GtkWidget *w _U_, GtkWidget *view)
|
||||
comment_text_buff_clear_cb(GtkWidget *w _U_, GtkWidget *view)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
|
@ -80,6 +87,31 @@ pkt_comment_text_buff_save_cb(GtkWidget *w _U_, GtkWidget *view)
|
|||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
capture_comment_text_buff_save_cb(GtkWidget *w _U_, GtkWidget *view)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start_iter;
|
||||
GtkTextIter end_iter;
|
||||
gchar *new_capture_comment = NULL;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
||||
|
||||
new_capture_comment = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE /* whether to include invisible text */);
|
||||
|
||||
/*g_warning("The new comment is '%s'",new_capture_comment);*/
|
||||
cf_update_capture_comment(&cfile, new_capture_comment);
|
||||
|
||||
/* Mark the file as unsaved, caues a popup asking to save the file if we quit the file */
|
||||
cfile.user_saved = FALSE;
|
||||
|
||||
/*window_destroy(w);*/
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
||||
{
|
||||
|
@ -93,7 +125,7 @@ edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
|||
const gchar *buf_str;
|
||||
|
||||
edit_or_add_pkt_comment_dlg = dlg_window_new ("Edit or Add Packet Comments");
|
||||
gtk_widget_set_size_request (edit_or_add_pkt_comment_dlg, 400, 80);
|
||||
gtk_widget_set_size_request (edit_or_add_pkt_comment_dlg, 500, 160);
|
||||
gtk_window_set_resizable (GTK_WINDOW (edit_or_add_pkt_comment_dlg), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (edit_or_add_pkt_comment_dlg), 0);
|
||||
|
||||
|
@ -124,7 +156,7 @@ edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
|||
gtk_widget_set_sensitive (save_bt, TRUE);
|
||||
|
||||
clear_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR);
|
||||
g_signal_connect(clear_bt, "clicked", G_CALLBACK(pkt_comment_text_buff_clear_cb), view);
|
||||
g_signal_connect(clear_bt, "clicked", G_CALLBACK(comment_text_buff_clear_cb), view);
|
||||
|
||||
close_bt = g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
||||
window_set_cancel_button (edit_or_add_pkt_comment_dlg, close_bt, window_cancel_button_cb);
|
||||
|
@ -141,3 +173,64 @@ edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
|||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
edit_capture_dlg_launch (void)
|
||||
{
|
||||
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *view;
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *save_bt, *clear_bt, *close_bt, *help_bt;
|
||||
GtkTextBuffer *buffer = NULL;
|
||||
const gchar *comment_str = NULL;
|
||||
const gchar *buf_str;
|
||||
|
||||
edit_or_add_capture_comment_dlg = dlg_window_new ("Edit or Add Capture Comments");
|
||||
gtk_widget_set_size_request (edit_or_add_capture_comment_dlg, 500, 160);
|
||||
gtk_window_set_resizable (GTK_WINDOW (edit_or_add_capture_comment_dlg), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (edit_or_add_capture_comment_dlg), 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (edit_or_add_capture_comment_dlg), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
/* Get the comment */
|
||||
comment_str = cf_read_shb_comment(&cfile);
|
||||
/*g_warning("Fetched comment '%s'",opt_comment);*/
|
||||
|
||||
if(comment_str != NULL){
|
||||
buf_str = g_strdup_printf("%s", comment_str);
|
||||
gtk_text_buffer_set_text (buffer, buf_str, -1);
|
||||
}
|
||||
gtk_container_add(GTK_CONTAINER(vbox), view);
|
||||
gtk_widget_show (view);
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new (GTK_STOCK_SAVE, GTK_STOCK_CLEAR, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
save_bt = g_object_get_data (G_OBJECT(bbox), GTK_STOCK_SAVE);
|
||||
g_signal_connect (save_bt, "clicked", G_CALLBACK(capture_comment_text_buff_save_cb), view);
|
||||
gtk_widget_set_sensitive (save_bt, TRUE);
|
||||
|
||||
clear_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR);
|
||||
g_signal_connect(clear_bt, "clicked", G_CALLBACK(comment_text_buff_clear_cb), view);
|
||||
|
||||
close_bt = g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
||||
window_set_cancel_button (edit_or_add_capture_comment_dlg, close_bt, window_cancel_button_cb);
|
||||
|
||||
help_bt = g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
|
||||
gtk_widget_set_sensitive (help_bt, FALSE);
|
||||
|
||||
gtk_widget_grab_default (save_bt);
|
||||
g_signal_connect (edit_or_add_capture_comment_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
|
||||
gtk_widget_show (edit_or_add_capture_comment_dlg);
|
||||
|
||||
}
|
|
@ -26,5 +26,6 @@
|
|||
#define __EDIT_PACKET_COMMENTS_H__
|
||||
|
||||
void edit_packet_comment_dlg (GtkAction *action, gpointer data);
|
||||
void edit_capture_dlg_launch (void);
|
||||
|
||||
#endif /* __EDIT_PACKET_COMMENTS_H__ */
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "ui/gtk/expert_indicators.h"
|
||||
#include "ui/gtk/keys.h"
|
||||
#include "ui/gtk/menus.h"
|
||||
#include "ui/gtk/edit_packet_comment_dlg.h"
|
||||
|
||||
/*
|
||||
* The order below defines the priority of info bar contexts.
|
||||
|
@ -84,6 +85,8 @@ static GtkWidget *info_bar, *info_bar_event, *packets_bar, *profile_bar, *pro
|
|||
static GtkWidget *expert_info_error, *expert_info_warn, *expert_info_note;
|
||||
static GtkWidget *expert_info_chat, *expert_info_none;
|
||||
|
||||
static GtkWidget *capture_comment_none, *capture_comment;
|
||||
|
||||
static guint main_ctx, file_ctx, help_ctx, filter_ctx, packets_ctx, profile_ctx;
|
||||
static guint status_levels[NUM_STATUS_LEVELS];
|
||||
static GString *packets_str = NULL;
|
||||
|
@ -94,6 +97,7 @@ static void info_bar_new(void);
|
|||
static void packets_bar_new(void);
|
||||
static void profile_bar_new(void);
|
||||
static void status_expert_new(void);
|
||||
static void status_capture_comment_new(void);
|
||||
|
||||
/* Temporary message timeouts */
|
||||
#define TEMPORARY_MSG_TIMEOUT (7 * 1000)
|
||||
|
@ -309,6 +313,9 @@ statusbar_new(void)
|
|||
/* expert info indicator */
|
||||
status_expert_new();
|
||||
|
||||
/* Capture comments indicator */
|
||||
status_capture_comment_new();
|
||||
|
||||
/* Pane for the statusbar */
|
||||
status_pane_left = gtk_hpaned_new();
|
||||
gtk_widget_show(status_pane_left);
|
||||
|
@ -358,7 +365,10 @@ statusbar_widgets_emptying(GtkWidget *statusbar)
|
|||
g_object_ref(G_OBJECT(expert_info_note));
|
||||
g_object_ref(G_OBJECT(expert_info_chat));
|
||||
g_object_ref(G_OBJECT(expert_info_none));
|
||||
g_object_ref(G_OBJECT(capture_comment));
|
||||
g_object_ref(G_OBJECT(capture_comment_none));
|
||||
|
||||
|
||||
/* empty all containers participating */
|
||||
gtk_container_foreach(GTK_CONTAINER(statusbar), foreach_remove_a_child, statusbar);
|
||||
gtk_container_foreach(GTK_CONTAINER(status_pane_left), foreach_remove_a_child, status_pane_left);
|
||||
|
@ -373,6 +383,8 @@ statusbar_widgets_pack(GtkWidget *statusbar)
|
|||
gtk_box_pack_start(GTK_BOX(statusbar), expert_info_note, FALSE, FALSE, 2);
|
||||
gtk_box_pack_start(GTK_BOX(statusbar), expert_info_chat, FALSE, FALSE, 2);
|
||||
gtk_box_pack_start(GTK_BOX(statusbar), expert_info_none, FALSE, FALSE, 2);
|
||||
gtk_box_pack_start(GTK_BOX(statusbar), capture_comment, FALSE, FALSE, 2);
|
||||
gtk_box_pack_start(GTK_BOX(statusbar), capture_comment_none, FALSE, FALSE, 2);
|
||||
gtk_box_pack_start(GTK_BOX(statusbar), status_pane_left, TRUE, TRUE, 0);
|
||||
gtk_paned_pack1(GTK_PANED(status_pane_left), info_bar_event, FALSE, FALSE);
|
||||
gtk_paned_pack2(GTK_PANED(status_pane_left), status_pane_right, TRUE, FALSE);
|
||||
|
@ -527,6 +539,13 @@ expert_comp_dlg_event_cb(GtkWidget *w _U_, GdkEventButton *event _U_, gpointer u
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
edit_capture_comment_dlg_event_cb(GtkWidget *w _U_, GdkEventButton *event _U_, gpointer user_data _U_)
|
||||
{
|
||||
edit_capture_dlg_launch();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
status_expert_new(void)
|
||||
{
|
||||
|
@ -604,6 +623,55 @@ status_expert_update(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
status_capture_comment_new(void)
|
||||
{
|
||||
GtkWidget *comment_image;
|
||||
|
||||
/* XXX Comment exist LED, change to use it's own stuff and other color? */
|
||||
comment_image = pixbuf_to_widget(expert_chat_pb_data);
|
||||
gtk_widget_set_tooltip_text(comment_image, "Capture comment present, click to read");
|
||||
gtk_widget_show(comment_image);
|
||||
capture_comment = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(capture_comment), comment_image);
|
||||
g_signal_connect(capture_comment, "button_press_event", G_CALLBACK(edit_capture_comment_dlg_event_cb), NULL);
|
||||
|
||||
/* XXX No Comment exist LED, change to use it's own stuff and other color? */
|
||||
comment_image = pixbuf_to_widget(expert_none_pb_data);
|
||||
gtk_widget_set_tooltip_text(comment_image, "No capture comment, click to add");
|
||||
gtk_widget_show(comment_image);
|
||||
capture_comment_none = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(capture_comment_none), comment_image);
|
||||
g_signal_connect(capture_comment_none, "button_press_event", G_CALLBACK(edit_capture_comment_dlg_event_cb), NULL);
|
||||
gtk_widget_show(capture_comment_none);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
status_capture_comment_hide(void)
|
||||
{
|
||||
/* reset capture coment info indicator */
|
||||
gtk_widget_hide(capture_comment);
|
||||
gtk_widget_hide(capture_comment_none);
|
||||
}
|
||||
|
||||
void
|
||||
status_capture_comment_update(void)
|
||||
{
|
||||
const gchar *comment_str;
|
||||
|
||||
status_capture_comment_hide();
|
||||
|
||||
comment_str = cf_read_shb_comment(&cfile);
|
||||
|
||||
if(comment_str != NULL){
|
||||
gtk_widget_show(capture_comment);
|
||||
}else{
|
||||
gtk_widget_show(capture_comment_none);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
statusbar_set_filename(const char *file_name, gint64 file_length, nstime_t *file_elapsed_time)
|
||||
{
|
||||
|
@ -672,6 +740,7 @@ statusbar_cf_file_read_finished_cb(capture_file *cf)
|
|||
{
|
||||
statusbar_pop_file_msg();
|
||||
statusbar_set_filename(cf->filename, cf->f_datalen, &(cf->elapsed_time));
|
||||
status_capture_comment_update();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ wtapng_section_t* wtap_file_get_shb_info(wtap *wth)
|
|||
{
|
||||
wtapng_section_t *shb_hdr;
|
||||
|
||||
if(wth == NULL)
|
||||
return NULL;
|
||||
shb_hdr = g_new(wtapng_section_t,1);
|
||||
shb_hdr->section_length = wth->shb_hdr.section_length;
|
||||
/* options */
|
||||
|
|
Loading…
Reference in New Issue