forked from osmocom/wireshark
Remove fdata->opt_comment, add pkt_comment to pinfo
Original (read from file) comments can be accessed by pkthdr->opt_comment Keep user comments in seperated BST, add new method for epan session to get it. svn path=/trunk/; revision=51090
This commit is contained in:
parent
6c5e16185d
commit
08eb36b5af
1
cfile.h
1
cfile.h
|
@ -124,6 +124,7 @@ typedef struct _capture_file {
|
|||
GTree *edited_frames; /* BST with modified frames */
|
||||
#endif
|
||||
gpointer window; /* Top-level window associated with file */
|
||||
GTree *frames_user_comments; /* BST with user comments for frames (key = frame_data) */
|
||||
} capture_file;
|
||||
|
||||
extern void cap_file_init(capture_file *cf);
|
||||
|
|
|
@ -229,14 +229,14 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
}
|
||||
}
|
||||
|
||||
if(pinfo->fd->opt_comment){
|
||||
if(pinfo->pkt_comment){
|
||||
item = proto_tree_add_item(tree, proto_pkt_comment, tvb, 0, -1, ENC_NA);
|
||||
comments_tree = proto_item_add_subtree(item, ett_comments);
|
||||
comment_item = proto_tree_add_string_format(comments_tree, hf_comments_text, tvb, 0, -1,
|
||||
pinfo->fd->opt_comment, "%s",
|
||||
pinfo->fd->opt_comment);
|
||||
pinfo->pkt_comment, "%s",
|
||||
pinfo->pkt_comment);
|
||||
expert_add_info_format_text(pinfo, comment_item, &ei_comments_text,
|
||||
"%s", pinfo->fd->opt_comment);
|
||||
"%s", pinfo->pkt_comment);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifndef __EPAN_INT_H__
|
||||
#define __EPAN_INT_H__
|
||||
|
||||
#include <epan/frame_data.h>
|
||||
#include <wsutil/nstime.h>
|
||||
|
||||
struct epan_session {
|
||||
|
@ -31,6 +32,7 @@ struct epan_session {
|
|||
|
||||
const nstime_t *(*get_frame_ts)(void *data, guint32 frame_num);
|
||||
const char *(*get_interface_name)(void *data, guint32 interface_id);
|
||||
const char *(*get_user_comment)(void *data, const frame_data *fd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -148,6 +148,15 @@ epan_new(void)
|
|||
return session;
|
||||
}
|
||||
|
||||
const char *
|
||||
epan_get_user_comment(const epan_t *session, const frame_data *fd)
|
||||
{
|
||||
if (session->get_user_comment)
|
||||
return session->get_user_comment(session->data, fd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
epan_get_interface_name(const epan_t *session, guint32 interface_id)
|
||||
{
|
||||
|
|
|
@ -129,6 +129,8 @@ typedef struct epan_session epan_t;
|
|||
|
||||
WS_DLL_PUBLIC epan_t *epan_new(void);
|
||||
|
||||
const char *epan_get_user_comment(const epan_t *session, const frame_data *fd);
|
||||
|
||||
const char *epan_get_interface_name(const epan_t *session, guint32 interface_id);
|
||||
|
||||
const nstime_t *epan_get_frame_ts(const epan_t *session, guint32 frame_num);
|
||||
|
|
|
@ -279,6 +279,7 @@ frame_data_init(frame_data *fdata, guint32 num,
|
|||
fdata->flags.ref_time = 0;
|
||||
fdata->flags.ignored = 0;
|
||||
fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0;
|
||||
fdata->flags.has_phdr_comment = (phdr->opt_comment != NULL);
|
||||
fdata->color_filter = NULL;
|
||||
fdata->abs_ts.secs = phdr->ts.secs;
|
||||
fdata->abs_ts.nsecs = phdr->ts.nsecs;
|
||||
|
@ -286,7 +287,6 @@ frame_data_init(frame_data *fdata, guint32 num,
|
|||
fdata->shift_offset.nsecs = 0;
|
||||
fdata->frame_ref_num = 0;
|
||||
fdata->prev_dis_num = 0;
|
||||
fdata->opt_comment = phdr->opt_comment;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -357,11 +357,6 @@ frame_data_destroy(frame_data *fdata)
|
|||
g_slist_free(fdata->pfd);
|
||||
fdata->pfd = NULL;
|
||||
}
|
||||
|
||||
if (fdata->opt_comment) {
|
||||
g_free(fdata->opt_comment);
|
||||
fdata->opt_comment = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -73,6 +73,8 @@ typedef struct _frame_data {
|
|||
unsigned int ref_time : 1; /**< 1 = marked as a reference time frame, 0 = normal */
|
||||
unsigned int ignored : 1; /**< 1 = ignore this frame, 0 = normal */
|
||||
unsigned int has_ts : 1; /**< 1 = has time stamp, 0 = no time stamp */
|
||||
unsigned int has_phdr_comment : 1; /** 1 = there's comment for this packet */
|
||||
unsigned int has_user_comment : 1; /** 1 = user set (also deleted) comment for this packet */
|
||||
} flags;
|
||||
|
||||
const void *color_filter; /**< Per-packet matching color_filter_t object */
|
||||
|
@ -81,7 +83,6 @@ typedef struct _frame_data {
|
|||
nstime_t shift_offset; /**< How much the abs_tm of the frame is shifted */
|
||||
guint32 frame_ref_num; /**< Previous reference frame (0 if this is one) */
|
||||
guint32 prev_dis_num; /**< Previous displayed frame (0 if first one) */
|
||||
gchar *opt_comment; /**< NULL if not available */
|
||||
} frame_data;
|
||||
|
||||
#ifdef WANT_PACKET_EDITOR
|
||||
|
|
|
@ -358,6 +358,12 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
|||
|
||||
frame_delta_abs_time(edt->session, fd, fd->frame_ref_num, &edt->pi.rel_ts);
|
||||
|
||||
/* pkt comment use first user, later from phdr */
|
||||
if (fd->flags.has_user_comment)
|
||||
edt->pi.pkt_comment = epan_get_user_comment(edt->session, fd);
|
||||
else
|
||||
edt->pi.pkt_comment = phdr->opt_comment;
|
||||
|
||||
/* to enable decode as for ethertype=0x0000 (fix for bug 4721) */
|
||||
edt->pi.ethertype = G_MAXINT;
|
||||
|
||||
|
|
|
@ -227,6 +227,7 @@ typedef struct _packet_info {
|
|||
struct _wmem_allocator_t *pool; /**< Memory pool scoped to the pinfo struct */
|
||||
struct epan_session *epan;
|
||||
nstime_t rel_ts; /**< Relative timestamp (yes, it can be negative) */
|
||||
const gchar *pkt_comment; /**< NULL if not available */
|
||||
} packet_info;
|
||||
|
||||
/**< For old code that hasn't yet been changed. */
|
||||
|
|
|
@ -317,7 +317,7 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
|
|||
pkthdr.pkt_encap = DUMPER_ENCAP(d);
|
||||
pkthdr.pseudo_header = *ph->wph;
|
||||
|
||||
/* TODO: Can we get access to pinfo->fd->opt_comment here somehow? We
|
||||
/* TODO: Can we get access to pinfo->pkt_comment here somehow? We
|
||||
* should be copying it to pkthdr.opt_comment if we can. */
|
||||
|
||||
if (! wtap_dump(d, &pkthdr, ba->data, &err)) {
|
||||
|
@ -409,8 +409,8 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
|
|||
pkthdr.pkt_encap = lua_pinfo->fd->lnk_t;
|
||||
pkthdr.pseudo_header = *lua_pinfo->pseudo_header;
|
||||
|
||||
if (lua_pinfo->fd->opt_comment)
|
||||
pkthdr.opt_comment = ep_strdup(lua_pinfo->fd->opt_comment);
|
||||
if (lua_pinfo->pkt_comment)
|
||||
pkthdr.opt_comment = ep_strdup(lua_pinfo->pkt_comment);
|
||||
|
||||
data = (const guchar *)ep_tvb_memdup(tvb,0,pkthdr.caplen);
|
||||
|
||||
|
|
126
file.c
126
file.c
|
@ -150,6 +150,8 @@ static gboolean find_packet(capture_file *cf,
|
|||
match_result (*match_function)(capture_file *, frame_data *, void *),
|
||||
void *criterion, search_direction dir);
|
||||
|
||||
static const char *cf_get_user_packet_comment(capture_file *cf, const frame_data *fd);
|
||||
|
||||
static void cf_open_failure_alert_box(const char *filename, int err,
|
||||
gchar *err_info, gboolean for_writing,
|
||||
int file_type);
|
||||
|
@ -323,6 +325,14 @@ ws_get_frame_ts(void *data, guint32 frame_num)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
ws_get_user_comment(void *data, const frame_data *fd)
|
||||
{
|
||||
capture_file *cf = (capture_file *) data;
|
||||
|
||||
return cf_get_user_packet_comment(cf, fd);
|
||||
}
|
||||
|
||||
static epan_t *
|
||||
ws_epan_new(capture_file *cf)
|
||||
{
|
||||
|
@ -331,6 +341,7 @@ ws_epan_new(capture_file *cf)
|
|||
epan->data = cf;
|
||||
epan->get_frame_ts = ws_get_frame_ts;
|
||||
epan->get_interface_name = cap_file_get_interface_name;
|
||||
epan->get_user_comment = ws_get_user_comment;
|
||||
|
||||
return epan;
|
||||
}
|
||||
|
@ -486,6 +497,10 @@ cf_reset_state(capture_file *cf)
|
|||
cf->edited_frames = NULL;
|
||||
}
|
||||
#endif
|
||||
if (cf->frames_user_comments) {
|
||||
g_tree_destroy(cf->frames_user_comments);
|
||||
cf->frames_user_comments = NULL;
|
||||
}
|
||||
cf_unselect_packet(cf); /* nothing to select */
|
||||
cf->first_displayed = 0;
|
||||
cf->last_displayed = 0;
|
||||
|
@ -1262,7 +1277,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
|
|||
fdata = frame_data_sequence_add(cf->frames, &fdlocal);
|
||||
|
||||
cf->count++;
|
||||
if (fdlocal.opt_comment != NULL)
|
||||
if (phdr->opt_comment != NULL)
|
||||
cf->packet_comment_count++;
|
||||
cf->f_datalen = offset + fdlocal.cap_len;
|
||||
|
||||
|
@ -1719,7 +1734,7 @@ cf_redissect_packets(capture_file *cf)
|
|||
}
|
||||
|
||||
gboolean
|
||||
cf_read_frame_r(capture_file *cf, frame_data *fdata,
|
||||
cf_read_frame_r(capture_file *cf, const frame_data *fdata,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf)
|
||||
{
|
||||
int err;
|
||||
|
@ -3921,25 +3936,82 @@ cf_update_capture_comment(capture_file *cf, gchar *comment)
|
|||
cf->unsaved_changes = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
cf_update_packet_comment(capture_file *cf, frame_data *fdata, gchar *comment)
|
||||
static const char *
|
||||
cf_get_user_packet_comment(capture_file *cf, const frame_data *fd)
|
||||
{
|
||||
if (fdata->opt_comment != NULL) {
|
||||
/* OK, remove the old comment. */
|
||||
g_free(fdata->opt_comment);
|
||||
fdata->opt_comment = NULL;
|
||||
if (cf->frames_user_comments)
|
||||
return g_tree_lookup(cf->frames_user_comments, fd);
|
||||
|
||||
/* g_warning? */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
cf_get_comment(capture_file *cf, const frame_data *fd)
|
||||
{
|
||||
/* fetch user comment */
|
||||
if (fd->flags.has_user_comment)
|
||||
return g_strdup(cf_get_user_packet_comment(cf, fd));
|
||||
|
||||
/* fetch phdr comment */
|
||||
if (fd->flags.has_phdr_comment) {
|
||||
struct wtap_pkthdr phdr; /* Packet header */
|
||||
Buffer buf; /* Packet data */
|
||||
|
||||
phdr.opt_comment = NULL;
|
||||
|
||||
buffer_init(&buf, 1500);
|
||||
if (!cf_read_frame_r(cf, fd, &phdr, &buf))
|
||||
{ /* XXX, what we can do here? */ }
|
||||
|
||||
buffer_free(&buf);
|
||||
return phdr.opt_comment;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
frame_cmp(gconstpointer a, gconstpointer b, gpointer user_data _U_)
|
||||
{
|
||||
const frame_data *fdata1 = (const frame_data *) a;
|
||||
const frame_data *fdata2 = (const frame_data *) b;
|
||||
|
||||
return (fdata1->num < fdata2->num) ? -1 :
|
||||
(fdata1->num > fdata2->num) ? 1 :
|
||||
0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cf_set_user_packet_comment(capture_file *cf, frame_data *fd, const gchar *new_comment)
|
||||
{
|
||||
char *pkt_comment = cf_get_comment(cf, fd);
|
||||
|
||||
/* Check if the comment has changed */
|
||||
if (!g_strcmp0(pkt_comment, new_comment)) {
|
||||
g_free(pkt_comment);
|
||||
return FALSE;
|
||||
}
|
||||
g_free(pkt_comment);
|
||||
|
||||
if (pkt_comment)
|
||||
cf->packet_comment_count--;
|
||||
}
|
||||
if (comment != NULL) {
|
||||
/* Add the new comment. */
|
||||
fdata->opt_comment = comment;
|
||||
|
||||
if (new_comment)
|
||||
cf->packet_comment_count++;
|
||||
}
|
||||
|
||||
fd->flags.has_user_comment = TRUE;
|
||||
|
||||
if (!cf->frames_user_comments)
|
||||
cf->frames_user_comments = g_tree_new_full(frame_cmp, NULL, NULL, g_free);
|
||||
|
||||
/* insert new packet comment */
|
||||
g_tree_replace(cf->frames_user_comments, fd, g_strdup(new_comment));
|
||||
|
||||
expert_update_comment_count(cf->packet_comment_count);
|
||||
|
||||
/* OK, we have unsaved changes. */
|
||||
cf->unsaved_changes = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3979,6 +4051,12 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
|
|||
struct wtap_pkthdr hdr;
|
||||
int err;
|
||||
gchar *display_basename;
|
||||
const char *pkt_comment;
|
||||
|
||||
if (fdata->flags.has_user_comment)
|
||||
pkt_comment = cf_get_user_packet_comment(cf, fdata);
|
||||
else
|
||||
pkt_comment = phdr->opt_comment;
|
||||
|
||||
/* init the wtap header for saving */
|
||||
/* TODO: reuse phdr */
|
||||
|
@ -4009,7 +4087,8 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
|
|||
hdr.interface_id = phdr->interface_id; /* identifier of the interface. */
|
||||
/* options */
|
||||
hdr.pack_flags = phdr->pack_flags;
|
||||
hdr.opt_comment = fdata->opt_comment; /* NULL if not available */
|
||||
hdr.opt_comment = g_strdup(pkt_comment);
|
||||
|
||||
/* pseudo */
|
||||
hdr.pseudo_header = phdr->pseudo_header;
|
||||
#if 0
|
||||
|
@ -4046,6 +4125,8 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free(hdr.opt_comment);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -4665,15 +4746,20 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
/* Remove SHB comment, if any. */
|
||||
wtap_write_shb_comment(cf->wth, NULL);
|
||||
|
||||
/* Remove packet comments. */
|
||||
/* remove all user comments */
|
||||
for (framenum = 1; framenum <= cf->count; framenum++) {
|
||||
fdata = frame_data_sequence_find(cf->frames, framenum);
|
||||
if (fdata->opt_comment) {
|
||||
g_free(fdata->opt_comment);
|
||||
fdata->opt_comment = NULL;
|
||||
cf->packet_comment_count--;
|
||||
}
|
||||
|
||||
fdata->flags.has_phdr_comment = FALSE;
|
||||
fdata->flags.has_user_comment = FALSE;
|
||||
}
|
||||
|
||||
if (cf->frames_user_comments) {
|
||||
g_tree_destroy(cf->frames_user_comments);
|
||||
cf->frames_user_comments = NULL;
|
||||
}
|
||||
|
||||
cf->packet_comment_count = 0;
|
||||
}
|
||||
}
|
||||
return CF_WRITE_OK;
|
||||
|
|
6
file.h
6
file.h
|
@ -148,7 +148,7 @@ cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
|
|||
* @param buf a Buffer into which to read the packet's raw data
|
||||
* @return TRUE if the read succeeded, FALSE if there was an error
|
||||
*/
|
||||
gboolean cf_read_frame_r(capture_file *cf, frame_data *fdata,
|
||||
gboolean cf_read_frame_r(capture_file *cf, const frame_data *fdata,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf);
|
||||
|
||||
/**
|
||||
|
@ -667,6 +667,8 @@ const gchar* cf_read_shb_comment(capture_file *cf);
|
|||
*/
|
||||
void cf_update_capture_comment(capture_file *cf, gchar *comment);
|
||||
|
||||
char *cf_get_comment(capture_file *cf, const frame_data *fd);
|
||||
|
||||
/**
|
||||
* Update(replace) the comment on a capture from a frame
|
||||
*
|
||||
|
@ -674,7 +676,7 @@ void cf_update_capture_comment(capture_file *cf, gchar *comment);
|
|||
* @param fdata the frame_data structure for the frame
|
||||
* @param comment the string replacing the old comment
|
||||
*/
|
||||
void cf_update_packet_comment(capture_file *cf, frame_data *fdata, gchar *comment);
|
||||
gboolean cf_set_user_packet_comment(capture_file *cf, frame_data *fd, const gchar *new_comment);
|
||||
|
||||
/**
|
||||
* What types of comments does this file have?
|
||||
|
|
|
@ -1611,6 +1611,7 @@ raw_epan_new(capture_file *cf)
|
|||
epan->data = cf;
|
||||
epan->get_frame_ts = raw_get_frame_ts;
|
||||
epan->get_interface_name = cap_file_get_interface_name;
|
||||
epan->get_user_comment = NULL;
|
||||
|
||||
return epan;
|
||||
}
|
||||
|
|
1
tshark.c
1
tshark.c
|
@ -2198,6 +2198,7 @@ tshark_epan_new(capture_file *cf)
|
|||
epan->data = cf;
|
||||
epan->get_frame_ts = tshark_get_frame_ts;
|
||||
epan->get_interface_name = cap_file_get_interface_name;
|
||||
epan->get_user_comment = NULL;
|
||||
|
||||
return epan;
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
|||
GtkWidget *bbox;
|
||||
GtkWidget *ok_bt, *cancel_bt, *help_bt;
|
||||
GtkTextBuffer *buffer;
|
||||
const gchar *opt_comment;
|
||||
gchar *buf_str;
|
||||
gchar *opt_comment;
|
||||
|
||||
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, 500, 160);
|
||||
|
@ -138,9 +137,8 @@ edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
|||
/*g_warning("Fetched comment '%s'",opt_comment);*/
|
||||
|
||||
if(opt_comment){
|
||||
buf_str = g_strdup_printf("%s", opt_comment);
|
||||
gtk_text_buffer_set_text (buffer, buf_str, -1);
|
||||
g_free(buf_str);
|
||||
gtk_text_buffer_set_text(buffer, opt_comment, -1);
|
||||
g_free(opt_comment);
|
||||
}
|
||||
|
||||
/* Button row. */
|
||||
|
|
|
@ -88,11 +88,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co
|
|||
pkthdr.pkt_encap = exp_pdu_tap_data->pkt_encap;
|
||||
pkthdr.interface_id = 0;
|
||||
pkthdr.presence_flags = 0;
|
||||
if(pinfo->fd->opt_comment == NULL){
|
||||
pkthdr.opt_comment = NULL;
|
||||
}else{
|
||||
pkthdr.opt_comment = g_strdup(pinfo->fd->opt_comment);
|
||||
}
|
||||
pkthdr.opt_comment = g_strdup(pinfo->pkt_comment);
|
||||
pkthdr.drop_count = 0;
|
||||
pkthdr.pack_flags = 0;
|
||||
pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
|
||||
|
|
|
@ -1559,7 +1559,7 @@ packet_list_copy_summary_cb(gpointer data _U_, copy_summary_type copy_type)
|
|||
g_string_free(text,TRUE);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gchar *
|
||||
packet_list_get_packet_comment(void)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
|
@ -1574,7 +1574,7 @@ packet_list_get_packet_comment(void)
|
|||
|
||||
fdata = packet_list_get_record(model, &iter);
|
||||
|
||||
return fdata->opt_comment;
|
||||
return cf_get_comment(&cfile, fdata);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1585,11 +1585,15 @@ packet_list_return_all_comments(GtkTextBuffer *buffer)
|
|||
gchar *buf_str;
|
||||
|
||||
for (framenum = 1; framenum <= cfile.count ; framenum++) {
|
||||
char *pkt_comment;
|
||||
|
||||
fdata = frame_data_sequence_find(cfile.frames, framenum);
|
||||
if (fdata->opt_comment) {
|
||||
buf_str = g_strdup_printf("Frame %u: %s \n\n",framenum, fdata->opt_comment);
|
||||
pkt_comment = cf_get_comment(&cfile, fdata);
|
||||
if (pkt_comment) {
|
||||
buf_str = g_strdup_printf("Frame %u: %s \n\n",framenum, pkt_comment);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, buf_str, -1);
|
||||
g_free(buf_str);
|
||||
g_free(pkt_comment);
|
||||
}
|
||||
if (gtk_text_buffer_get_char_count(buffer) > MAX_COMMENTS_TO_FETCH) {
|
||||
buf_str = g_strdup_printf("[ Comment text exceeds %s. Stopping. ]",
|
||||
|
@ -1616,22 +1620,15 @@ packet_list_update_packet_comment(gchar *new_packet_comment)
|
|||
|
||||
fdata = packet_list_get_record(model, &iter);
|
||||
|
||||
/* Check if the comment has changed */
|
||||
if (fdata->opt_comment) {
|
||||
if (strcmp(fdata->opt_comment, new_packet_comment) == 0) {
|
||||
g_free(new_packet_comment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we are clearing the comment */
|
||||
if(strlen(new_packet_comment) == 0) {
|
||||
g_free(new_packet_comment);
|
||||
new_packet_comment = NULL;
|
||||
}
|
||||
|
||||
/* The comment has changed, let's update it */
|
||||
cf_update_packet_comment(&cfile, fdata, new_packet_comment);
|
||||
cf_set_user_packet_comment(&cfile, fdata, new_packet_comment);
|
||||
|
||||
g_free(new_packet_comment);
|
||||
|
||||
/* Update the main window, as we now have unsaved changes. */
|
||||
main_update_for_unsaved_changes(&cfile);
|
||||
|
@ -1707,6 +1704,8 @@ query_packet_list_tooltip_cb(GtkWidget *widget, gint x, gint y, gboolean keyboar
|
|||
return result;
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view), x, y, NULL, &column, NULL, NULL)) {
|
||||
char *pkt_comment;
|
||||
|
||||
num_cols = g_list_length(prefs.col_list);
|
||||
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
|
@ -1715,8 +1714,10 @@ query_packet_list_tooltip_cb(GtkWidget *widget, gint x, gint y, gboolean keyboar
|
|||
}
|
||||
|
||||
fdata = packet_list_get_record(model, &iter);
|
||||
if (fdata->opt_comment != NULL) {
|
||||
gtk_tooltip_set_markup (tooltip, fdata->opt_comment);
|
||||
pkt_comment = cf_get_comment(&cfile, fdata);
|
||||
|
||||
if (pkt_comment != NULL) {
|
||||
gtk_tooltip_set_markup(tooltip, pkt_comment);
|
||||
renderer_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
|
||||
/* get the first renderer */
|
||||
if (g_list_first(renderer_list)) {
|
||||
|
@ -1724,6 +1725,7 @@ query_packet_list_tooltip_cb(GtkWidget *widget, gint x, gint y, gboolean keyboar
|
|||
gtk_tree_view_set_tooltip_cell (tree_view, tooltip, path, column, renderer);
|
||||
}
|
||||
g_list_free(renderer_list);
|
||||
g_free(pkt_comment);
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ typedef enum {
|
|||
*/
|
||||
void packet_list_copy_summary_cb(gpointer data _U_, copy_summary_type copy_type);
|
||||
|
||||
const gchar *packet_list_get_packet_comment(void);
|
||||
gchar *packet_list_get_packet_comment(void);
|
||||
void packet_list_update_packet_comment(gchar *new_packet_comment);
|
||||
void packet_list_return_all_comments(GtkTextBuffer *buffer);
|
||||
|
||||
|
|
|
@ -628,6 +628,7 @@ QString PacketList::packetComment()
|
|||
{
|
||||
int row = currentIndex().row();
|
||||
frame_data *fdata;
|
||||
char *pkt_comment;
|
||||
|
||||
if (!cap_file_ || !packet_list_model_) return NULL;
|
||||
|
||||
|
@ -635,7 +636,11 @@ QString PacketList::packetComment()
|
|||
|
||||
if (!fdata) return NULL;
|
||||
|
||||
return QString(fdata->opt_comment);
|
||||
pkt_comment = cf_get_comment(cap_file_, fdata);
|
||||
|
||||
return QString(pkt_comment);
|
||||
|
||||
/* XXX, g_free(pkt_comment) */
|
||||
}
|
||||
|
||||
void PacketList::setPacketComment(QString new_comment)
|
||||
|
@ -650,20 +655,12 @@ void PacketList::setPacketComment(QString new_comment)
|
|||
|
||||
if (!fdata) return;
|
||||
|
||||
/* Check if the comment has changed */
|
||||
if (fdata->opt_comment) {
|
||||
if (strcmp(fdata->opt_comment, new_packet_comment) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we are clearing the comment */
|
||||
if(new_comment.isEmpty()) {
|
||||
new_packet_comment = NULL;
|
||||
}
|
||||
|
||||
/* The comment has changed, let's update it */
|
||||
cf_update_packet_comment(cap_file_, fdata, g_strdup(new_packet_comment));
|
||||
cf_set_user_packet_comment(cap_file_, fdata, new_packet_comment);
|
||||
|
||||
updateAll();
|
||||
}
|
||||
|
@ -678,8 +675,12 @@ QString PacketList::allPacketComments()
|
|||
|
||||
for (framenum = 1; framenum <= cap_file_->count ; framenum++) {
|
||||
fdata = frame_data_sequence_find(cap_file_->frames, framenum);
|
||||
if (fdata->opt_comment) {
|
||||
buf_str.append(QString(tr("Frame %1: %2 \n\n")).arg(framenum).arg(fdata->opt_comment));
|
||||
|
||||
char *pkt_comment = cf_get_comment(cap_file_, fdata);
|
||||
|
||||
if (pkt_comment) {
|
||||
buf_str.append(QString(tr("Frame %1: %2 \n\n")).arg(framenum).arg(pkt_comment));
|
||||
g_free(pkt_comment);
|
||||
}
|
||||
if (buf_str.length() > max_comments_to_fetch_) {
|
||||
buf_str.append(QString(tr("[ Comment text exceeds %1. Stopping. ]"))
|
||||
|
|
Loading…
Reference in New Issue