2005-11-25 23:42:52 +00:00
|
|
|
/* expert_comp_dlg.c
|
|
|
|
* expert_comp_dlg 2005 Greg Morris
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-11-25 23:42:52 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-11-25 23:42:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
#include <gtk/gtk.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
#include <epan/packet_info.h>
|
2011-08-03 18:45:06 +00:00
|
|
|
#include <epan/prefs.h>
|
2005-11-25 23:42:52 +00:00
|
|
|
#include <epan/tap.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
#include <epan/stat_cmd_args.h>
|
2011-03-22 06:17:20 +00:00
|
|
|
#include <epan/prefs.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
#include "../stat_menu.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/simple_dialog.h"
|
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/expert_comp_table.h"
|
|
|
|
#include "ui/gtk/gui_stat_menu.h"
|
|
|
|
#include "ui/gtk/help_dlg.h"
|
|
|
|
#include "ui/gtk/expert_comp_dlg.h"
|
|
|
|
#include "ui/gtk/stock_icons.h"
|
|
|
|
#include "ui/gtk/main.h"
|
|
|
|
#include "ui/gtk/expert_indicators.h"
|
2012-06-16 20:52:04 +00:00
|
|
|
#include "ui/gtk/packet_panes.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/old-gtk-compat.h"
|
2012-03-09 13:36:29 +00:00
|
|
|
#include "ui/gtk/edit_packet_comment_dlg.h"
|
2011-03-22 06:17:20 +00:00
|
|
|
|
2012-03-05 13:34:55 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NO_COLUMN_C_TABLE,
|
|
|
|
SUMMARY_COLUMN_C_TABLE,
|
|
|
|
FOREGROUND_COLOR_COL_C_TABLE,
|
|
|
|
BACKGROUND_COLOR_COL_C_TABLE,
|
|
|
|
N_COLUMNS_COMMENT_TBL
|
|
|
|
};
|
|
|
|
|
2011-03-22 06:17:20 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NO_COLUMN,
|
|
|
|
SEVERITY_COLUMN,
|
|
|
|
GROUP_COLUMN,
|
|
|
|
PROTOCOL_COLUMN,
|
|
|
|
SUMMARY_COLUMN,
|
|
|
|
FOREGROUND_COLOR_COL,
|
|
|
|
BACKGROUND_COLOR_COL,
|
|
|
|
N_COLUMNS
|
|
|
|
};
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* used to keep track of the statistics for an entire program interface */
|
2005-12-23 10:55:05 +00:00
|
|
|
typedef struct _expert_comp_dlg_t {
|
|
|
|
GtkWidget *win;
|
2012-03-02 13:31:16 +00:00
|
|
|
GtkWidget *pkt_comments_label;
|
2005-11-25 23:42:52 +00:00
|
|
|
GtkWidget *chat_label;
|
|
|
|
GtkWidget *note_label;
|
|
|
|
GtkWidget *warn_label;
|
|
|
|
GtkWidget *error_label;
|
2006-05-04 15:36:41 +00:00
|
|
|
GtkWidget *all_label;
|
2005-12-23 10:55:05 +00:00
|
|
|
error_equiv_table chat_table;
|
|
|
|
error_equiv_table note_table;
|
|
|
|
error_equiv_table warn_table;
|
2005-11-25 23:42:52 +00:00
|
|
|
error_equiv_table error_table;
|
2012-03-02 13:31:16 +00:00
|
|
|
guint32 pkt_comments_events;
|
2009-01-18 14:47:51 +00:00
|
|
|
guint32 disp_events;
|
|
|
|
guint32 chat_events;
|
|
|
|
guint32 note_events;
|
|
|
|
guint32 warn_events;
|
|
|
|
guint32 error_events;
|
2005-12-23 10:55:05 +00:00
|
|
|
} expert_comp_dlg_t;
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2011-03-22 07:24:14 +00:00
|
|
|
struct expert_tapdata_s {
|
2012-03-09 14:25:30 +00:00
|
|
|
GtkWidget *win;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
GtkWidget *scrolled_window_comments;
|
|
|
|
GtkTreeView *tree_view_comments;
|
|
|
|
GtkWidget *label;
|
|
|
|
guint32 pkt_comments_events;
|
|
|
|
guint32 disp_events;
|
|
|
|
guint32 chat_events;
|
|
|
|
guint32 note_events;
|
|
|
|
guint32 warn_events;
|
|
|
|
guint32 error_events;
|
|
|
|
int severity_report_level;
|
|
|
|
|
|
|
|
GArray *ei_array; /* expert info items */
|
|
|
|
guint first;
|
|
|
|
guint last;
|
|
|
|
GStringChunk *text; /* summary text */
|
2011-03-22 07:24:14 +00:00
|
|
|
};
|
2011-03-22 06:17:20 +00:00
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
static GtkWidget *expert_comp_dlg_w = NULL;
|
|
|
|
|
2011-03-22 06:17:20 +00:00
|
|
|
static void
|
|
|
|
select_row_cb(GtkTreeSelection *selection, gpointer *user_data _U_)
|
|
|
|
{
|
|
|
|
/*guint num = GPOINTER_TO_UINT(gtk_clist_get_row_data(clist, row));*/
|
|
|
|
|
|
|
|
/*cf_goto_frame(&cfile, num);*/
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
guint fnumber;
|
|
|
|
|
|
|
|
if (selection==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected (selection, &model, &iter)){
|
|
|
|
gtk_tree_model_get (model, &iter, NO_COLUMN, &fnumber, -1);
|
|
|
|
cf_goto_frame(&cfile, fnumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset of display only, e.g. for filtering */
|
|
|
|
static void expert_dlg_display_reset(expert_tapdata_t * etd)
|
|
|
|
{
|
|
|
|
etd->disp_events = 0;
|
|
|
|
gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(etd->tree_view))));
|
2012-06-03 17:52:05 +00:00
|
|
|
gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(etd->tree_view_comments))));
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(etd->win), "Wireshark: ? Expert Infos");
|
|
|
|
if(etd->label) {
|
|
|
|
gtk_label_set_text(GTK_LABEL(etd->label), "Please wait ...");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* complete reset, e.g. capture file closed */
|
2011-07-11 19:10:57 +00:00
|
|
|
static void
|
2011-03-22 06:17:20 +00:00
|
|
|
expert_dlg_reset(void *tapdata)
|
|
|
|
{
|
|
|
|
expert_tapdata_t * etd = tapdata;
|
|
|
|
|
|
|
|
etd->chat_events = 0;
|
|
|
|
etd->note_events = 0;
|
|
|
|
etd->warn_events = 0;
|
|
|
|
etd->error_events = 0;
|
2012-03-02 13:31:16 +00:00
|
|
|
etd->pkt_comments_events = 0;
|
2011-03-22 06:17:20 +00:00
|
|
|
etd->last = 0;
|
|
|
|
etd->first = 0;
|
|
|
|
/* g_string_chunk_clear() is introduced in glib 2.14 */
|
|
|
|
g_string_chunk_free(etd->text);
|
|
|
|
etd->text = g_string_chunk_new(100);
|
|
|
|
g_array_set_size(etd->ei_array, 0);
|
|
|
|
|
|
|
|
expert_dlg_display_reset(etd);
|
|
|
|
}
|
|
|
|
|
2011-07-11 19:10:57 +00:00
|
|
|
static int
|
2011-03-22 06:17:20 +00:00
|
|
|
expert_dlg_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pointer)
|
|
|
|
{
|
|
|
|
expert_info_t *ei;
|
|
|
|
expert_tapdata_t *etd = tapdata;
|
|
|
|
|
|
|
|
g_array_append_val(etd->ei_array, *(expert_info_t *)pointer);
|
|
|
|
etd->last = etd->ei_array->len;
|
|
|
|
ei = &g_array_index(etd->ei_array, expert_info_t, etd->last -1); /* ugly */
|
|
|
|
ei->protocol = g_string_chunk_insert_const(etd->text, ei->protocol);
|
|
|
|
ei->summary = g_string_chunk_insert_const(etd->text, ei->summary);
|
|
|
|
|
|
|
|
switch(ei->severity) {
|
2012-03-02 13:31:16 +00:00
|
|
|
case(PI_COMMENT):
|
|
|
|
etd->pkt_comments_events++;
|
|
|
|
break;
|
2011-03-22 06:17:20 +00:00
|
|
|
case(PI_CHAT):
|
|
|
|
etd->chat_events++;
|
|
|
|
break;
|
|
|
|
case(PI_NOTE):
|
|
|
|
etd->note_events++;
|
|
|
|
break;
|
|
|
|
case(PI_WARN):
|
|
|
|
etd->warn_events++;
|
|
|
|
break;
|
|
|
|
case(PI_ERROR):
|
|
|
|
etd->error_events++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
if(ei->severity < etd->severity_report_level) {
|
|
|
|
return 0; /* draw not required */
|
|
|
|
} else {
|
|
|
|
return 1; /* draw required */
|
|
|
|
}
|
|
|
|
}
|
2005-11-25 23:42:52 +00:00
|
|
|
static void
|
2005-12-23 10:55:05 +00:00
|
|
|
error_set_title(expert_comp_dlg_t *ss)
|
2005-11-25 23:42:52 +00:00
|
|
|
{
|
2012-06-03 22:03:05 +00:00
|
|
|
set_window_title(ss->win, "Expert Info");
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
error_reset(void *pss)
|
|
|
|
{
|
2005-12-23 10:55:05 +00:00
|
|
|
expert_comp_dlg_t *ss=(expert_comp_dlg_t *)pss;
|
2009-03-12 20:38:42 +00:00
|
|
|
gchar *buf;
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->error_events = 0;
|
|
|
|
ss->warn_events = 0;
|
|
|
|
ss->note_events = 0;
|
|
|
|
ss->chat_events = 0;
|
|
|
|
ss->disp_events = 0;
|
2012-03-09 14:25:30 +00:00
|
|
|
ss->pkt_comments_events = 0;
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
reset_error_table_data(&ss->error_table);
|
2009-03-12 20:38:42 +00:00
|
|
|
buf = g_strdup_printf("Errors: %u (0)", ss->error_table.num_procs);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->error_label), buf);
|
|
|
|
g_free(buf);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
reset_error_table_data(&ss->warn_table);
|
2009-03-12 20:38:42 +00:00
|
|
|
buf = g_strdup_printf("Warnings: %u (0)", ss->warn_table.num_procs);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->warn_label), buf);
|
|
|
|
g_free(buf);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
reset_error_table_data(&ss->note_table);
|
2009-03-12 20:38:42 +00:00
|
|
|
buf = g_strdup_printf("Notes: %u (0)", ss->note_table.num_procs);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->note_label), buf);
|
|
|
|
g_free(buf);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
reset_error_table_data(&ss->chat_table);
|
2009-03-12 20:38:42 +00:00
|
|
|
buf = g_strdup_printf("Chats: %u (0)", ss->chat_table.num_procs);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->chat_label), buf);
|
|
|
|
g_free(buf);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2009-03-12 20:38:42 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL(ss->all_label), "Details: 0");
|
2012-03-02 13:31:16 +00:00
|
|
|
|
2012-03-05 13:34:55 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL(ss->pkt_comments_label), "Packet comments: 0");
|
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
error_set_title(ss);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
2010-08-19 00:09:56 +00:00
|
|
|
static gboolean
|
2006-07-01 12:06:36 +00:00
|
|
|
error_packet(void *pss, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *prv)
|
2005-11-25 23:42:52 +00:00
|
|
|
{
|
2005-12-23 10:55:05 +00:00
|
|
|
expert_comp_dlg_t *ss=(expert_comp_dlg_t *)pss;
|
2005-11-25 23:42:52 +00:00
|
|
|
const expert_info_t *error_pkt=prv;
|
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
/* if return value is 0 then no error */
|
|
|
|
if(error_pkt==NULL){
|
2010-08-19 00:09:56 +00:00
|
|
|
return FALSE;
|
2005-12-23 10:55:05 +00:00
|
|
|
}
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
switch (error_pkt->severity) {
|
|
|
|
case PI_ERROR:
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->disp_events++;
|
|
|
|
ss->error_events++;
|
2005-11-25 23:42:52 +00:00
|
|
|
init_error_table_row(&ss->error_table, error_pkt);
|
|
|
|
break;
|
|
|
|
case PI_WARN:
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->disp_events++;
|
|
|
|
ss->warn_events++;
|
2005-11-25 23:42:52 +00:00
|
|
|
init_error_table_row(&ss->warn_table, error_pkt);
|
|
|
|
break;
|
|
|
|
case PI_NOTE:
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->disp_events++;
|
|
|
|
ss->note_events++;
|
2005-11-25 23:42:52 +00:00
|
|
|
init_error_table_row(&ss->note_table, error_pkt);
|
|
|
|
break;
|
|
|
|
case PI_CHAT:
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->disp_events++;
|
|
|
|
ss->chat_events++;
|
2005-11-25 23:42:52 +00:00
|
|
|
init_error_table_row(&ss->chat_table, error_pkt);
|
|
|
|
break;
|
2012-03-02 13:31:16 +00:00
|
|
|
case PI_COMMENT:
|
|
|
|
ss->disp_events++; /* Count ? */
|
|
|
|
ss->pkt_comments_events++;
|
|
|
|
break;
|
2005-11-25 23:42:52 +00:00
|
|
|
default:
|
2010-08-19 00:09:56 +00:00
|
|
|
return FALSE; /* Don't draw */
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2010-08-19 00:09:56 +00:00
|
|
|
return TRUE; /* Draw */
|
2009-08-19 18:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
expert_comp_draw(void *data)
|
|
|
|
{
|
|
|
|
gchar *buf = NULL;
|
|
|
|
|
|
|
|
expert_comp_dlg_t *ss=(expert_comp_dlg_t *)data;
|
|
|
|
|
|
|
|
buf = g_strdup_printf("Errors: %u (%u)", ss->error_table.num_procs, ss->error_events);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->error_label), buf);
|
|
|
|
g_free(buf);
|
|
|
|
|
|
|
|
buf = g_strdup_printf("Warnings: %u (%u)", ss->warn_table.num_procs, ss->warn_events);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->warn_label), buf);
|
|
|
|
g_free(buf);
|
|
|
|
|
|
|
|
buf = g_strdup_printf("Notes: %u (%u)", ss->note_table.num_procs, ss->note_events);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->note_label), buf);
|
|
|
|
g_free(buf);
|
|
|
|
|
|
|
|
buf = g_strdup_printf("Chats: %u (%u)", ss->chat_table.num_procs, ss->chat_events);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->chat_label), buf);
|
2009-03-12 20:38:42 +00:00
|
|
|
g_free(buf);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2009-03-12 20:38:42 +00:00
|
|
|
buf = g_strdup_printf("Details: %u", ss->disp_events);
|
|
|
|
gtk_label_set_text( GTK_LABEL(ss->all_label), buf);
|
|
|
|
g_free(buf);
|
2010-08-19 00:09:56 +00:00
|
|
|
|
2012-03-05 13:34:55 +00:00
|
|
|
buf = g_strdup_printf("Packet Comments: %u", ss->pkt_comments_events);
|
2012-03-02 13:31:16 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL(ss->pkt_comments_label), buf);
|
|
|
|
g_free(buf);
|
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
2005-12-23 10:55:05 +00:00
|
|
|
expert_comp_dlg_t *ss=(expert_comp_dlg_t *)data;
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
protect_thread_critical_region();
|
|
|
|
remove_tap_listener(ss);
|
|
|
|
unprotect_thread_critical_region();
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2009-08-26 04:37:08 +00:00
|
|
|
if (expert_comp_dlg_w != NULL) {
|
|
|
|
window_destroy(expert_comp_dlg_w);
|
|
|
|
expert_comp_dlg_w = NULL;
|
|
|
|
}
|
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
free_error_table_data(&ss->error_table);
|
|
|
|
free_error_table_data(&ss->warn_table);
|
|
|
|
free_error_table_data(&ss->note_table);
|
|
|
|
free_error_table_data(&ss->chat_table);
|
|
|
|
g_free(ss);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-03-22 06:17:20 +00:00
|
|
|
static void
|
|
|
|
expert_dlg_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
|
|
|
expert_tapdata_t *etd=(expert_tapdata_t *)data;
|
|
|
|
|
|
|
|
protect_thread_critical_region();
|
|
|
|
remove_tap_listener(etd);
|
|
|
|
unprotect_thread_critical_region();
|
|
|
|
|
|
|
|
/*free_srt_table_data(&etd->afp_srt_table);*/
|
|
|
|
g_array_free(etd->ei_array, TRUE);
|
|
|
|
g_string_chunk_free(etd->text);
|
|
|
|
g_free(etd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static expert_tapdata_t * expert_dlg_new_table(void)
|
|
|
|
{
|
|
|
|
expert_tapdata_t * etd;
|
|
|
|
etd=g_malloc0(sizeof(expert_tapdata_t));
|
|
|
|
|
|
|
|
etd->ei_array = g_array_sized_new(FALSE, FALSE, sizeof(expert_info_t), 1000);
|
|
|
|
etd->text = g_string_chunk_new(100);
|
2012-03-02 13:31:16 +00:00
|
|
|
etd->severity_report_level = PI_COMMENT;
|
2011-03-22 06:17:20 +00:00
|
|
|
return etd;
|
|
|
|
}
|
|
|
|
|
2012-03-09 13:36:29 +00:00
|
|
|
static void
|
2012-03-09 14:20:53 +00:00
|
|
|
coments_row_double_click_cb(GtkTreeView *treeview _U_, GtkTreePath *path _U_,
|
2012-03-09 14:25:30 +00:00
|
|
|
GtkTreeViewColumn *col _U_, gpointer userdata _U_)
|
2012-03-09 13:36:29 +00:00
|
|
|
{
|
2012-03-09 14:25:30 +00:00
|
|
|
edit_packet_comment_dlg(NULL, NULL);
|
2012-03-09 13:36:29 +00:00
|
|
|
}
|
2012-03-05 13:34:55 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
expert_dlg_init_comments_table(expert_tapdata_t * etd, GtkWidget *vbox)
|
|
|
|
{
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkWidget *tree;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeSortable *sortable;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
/* Create the store */
|
|
|
|
store = gtk_list_store_new(N_COLUMNS_COMMENT_TBL, /* Total number of columns */
|
|
|
|
G_TYPE_UINT, /* No */
|
2012-03-09 14:25:30 +00:00
|
|
|
G_TYPE_POINTER, /* Summary */
|
2012-03-05 13:34:55 +00:00
|
|
|
G_TYPE_STRING, /* forground */
|
|
|
|
G_TYPE_STRING); /* Background */
|
|
|
|
|
|
|
|
/* Create a view */
|
|
|
|
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
|
|
|
etd->tree_view_comments = GTK_TREE_VIEW(tree);
|
|
|
|
sortable = GTK_TREE_SORTABLE(store);
|
|
|
|
|
|
|
|
/* Speed up the list display */
|
|
|
|
gtk_tree_view_set_fixed_height_mode(etd->tree_view_comments, TRUE);
|
|
|
|
|
|
|
|
/* Setup the sortable columns */
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree), FALSE);
|
|
|
|
|
|
|
|
/* The view now holds a reference. We can get rid of our own reference */
|
|
|
|
g_object_unref (G_OBJECT (store));
|
|
|
|
|
|
|
|
/* Let the font be the default one to have the same look as the rest of the tabs
|
2012-03-09 14:25:30 +00:00
|
|
|
* Bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4388
|
|
|
|
* gtk_widget_modify_font(GTK_WIDGET (etd->tree_view), user_font_get_regular());
|
|
|
|
*/
|
2012-03-05 13:34:55 +00:00
|
|
|
|
|
|
|
/* Create a cell renderer */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
g_object_set(renderer, "xalign", 1.0, NULL);
|
|
|
|
|
|
|
|
/* Create the first column, associating the "text" attribute of the
|
|
|
|
* cell_renderer to the first column of the model */
|
|
|
|
/* No */
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("No", renderer,
|
|
|
|
"text", NO_COLUMN_C_TABLE,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL_C_TABLE,
|
|
|
|
"background", BACKGROUND_COLOR_COL_C_TABLE,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, NO_COLUMN_C_TABLE);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 40);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view_comments, column);
|
|
|
|
|
|
|
|
|
|
|
|
/* Summary. */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Summary", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL_C_TABLE,
|
|
|
|
"background", BACKGROUND_COLOR_COL_C_TABLE,
|
|
|
|
NULL);
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(SUMMARY_COLUMN_C_TABLE), NULL);
|
2012-03-05 13:34:55 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(sortable, SUMMARY_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(SUMMARY_COLUMN_C_TABLE), NULL);
|
2012-03-05 13:34:55 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 90);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SUMMARY_COLUMN_C_TABLE);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view_comments, column);
|
|
|
|
|
|
|
|
gtk_tree_view_set_search_column (etd->tree_view_comments, SUMMARY_COLUMN_C_TABLE); /* Allow searching the summary */
|
|
|
|
gtk_tree_view_set_reorderable (etd->tree_view_comments, TRUE); /* Allow user to reorder data with drag n drop */
|
|
|
|
|
|
|
|
/* Now enable the sorting of each column */
|
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(etd->tree_view_comments), TRUE);
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(etd->tree_view_comments), TRUE);
|
|
|
|
|
|
|
|
/* Setup the selection handler */
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(etd->tree_view_comments));
|
|
|
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (selection), "changed", /* select_row */
|
|
|
|
G_CALLBACK (select_row_cb),
|
|
|
|
NULL);
|
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
g_signal_connect(tree, "row-activated",
|
|
|
|
G_CALLBACK(coments_row_double_click_cb), NULL);
|
2012-03-09 13:36:29 +00:00
|
|
|
|
2012-03-05 13:34:55 +00:00
|
|
|
etd->scrolled_window_comments=scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_container_add(GTK_CONTAINER(etd->scrolled_window_comments), GTK_WIDGET (etd->tree_view_comments));
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), etd->scrolled_window_comments, TRUE, TRUE, 0);
|
|
|
|
}
|
|
|
|
|
2011-03-22 06:17:20 +00:00
|
|
|
static void
|
|
|
|
expert_dlg_init_table(expert_tapdata_t * etd, GtkWidget *vbox)
|
|
|
|
{
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkWidget *tree;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeSortable *sortable;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
/* Create the store */
|
|
|
|
store = gtk_list_store_new(N_COLUMNS, /* Total number of columns */
|
2012-03-02 13:31:16 +00:00
|
|
|
G_TYPE_UINT, /* No */
|
|
|
|
G_TYPE_POINTER, /* Severity */
|
|
|
|
G_TYPE_POINTER, /* Group */
|
|
|
|
G_TYPE_POINTER, /* Protocol */
|
|
|
|
G_TYPE_POINTER, /* Summary */
|
|
|
|
G_TYPE_STRING, /* forground */
|
|
|
|
G_TYPE_STRING); /* Background */
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
/* Create a view */
|
|
|
|
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
|
|
|
etd->tree_view = GTK_TREE_VIEW(tree);
|
|
|
|
sortable = GTK_TREE_SORTABLE(store);
|
|
|
|
|
|
|
|
/* Speed up the list display */
|
|
|
|
gtk_tree_view_set_fixed_height_mode(etd->tree_view, TRUE);
|
|
|
|
|
|
|
|
/* Setup the sortable columns */
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree), FALSE);
|
|
|
|
|
|
|
|
/* The view now holds a reference. We can get rid of our own reference */
|
|
|
|
g_object_unref (G_OBJECT (store));
|
|
|
|
|
|
|
|
/* Let the font be the default one to have the same look as the rest of the tabs
|
2012-03-09 14:25:30 +00:00
|
|
|
* Bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4388
|
|
|
|
* gtk_widget_modify_font(GTK_WIDGET (etd->tree_view), user_font_get_regular());
|
|
|
|
*/
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
/* Create a cell renderer */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
g_object_set(renderer, "xalign", 1.0, NULL);
|
|
|
|
|
|
|
|
/* Create the first column, associating the "text" attribute of the
|
|
|
|
* cell_renderer to the first column of the model */
|
|
|
|
/* No */
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("No", renderer,
|
|
|
|
"text", NO_COLUMN,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, NO_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
2012-03-02 13:31:16 +00:00
|
|
|
gtk_tree_view_column_set_min_width(column, 40);
|
2011-03-22 06:17:20 +00:00
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
/* Severity */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Severity", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(SEVERITY_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(sortable, SEVERITY_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(SEVERITY_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SEVERITY_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
/* Add the column to the view. */
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
/* Group */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Group", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(sortable, GROUP_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, GROUP_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
/* Add the column to the view. */
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
/* Protocol. */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Protocol", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(sortable, PROTOCOL_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, PROTOCOL_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
/* Summary. */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Summary", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(SUMMARY_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(sortable, SUMMARY_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(SUMMARY_COLUMN), NULL);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 90);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SUMMARY_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
gtk_tree_view_set_search_column (etd->tree_view, SUMMARY_COLUMN); /* Allow searching the summary */
|
|
|
|
gtk_tree_view_set_reorderable (etd->tree_view, TRUE); /* Allow user to reorder data with drag n drop */
|
|
|
|
|
|
|
|
/* Now enable the sorting of each column */
|
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(etd->tree_view), TRUE);
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(etd->tree_view), TRUE);
|
|
|
|
|
|
|
|
/* Setup the selection handler */
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(etd->tree_view));
|
|
|
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (selection), "changed", /* select_row */
|
|
|
|
G_CALLBACK (select_row_cb),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
etd->scrolled_window=scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_container_add(GTK_CONTAINER(etd->scrolled_window), GTK_WIDGET (etd->tree_view));
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), etd->scrolled_window, TRUE, TRUE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
expert_dlg_draw(void *data)
|
|
|
|
{
|
|
|
|
expert_tapdata_t *etd = data;
|
|
|
|
expert_info_t *ei;
|
|
|
|
gchar *title;
|
|
|
|
const char *entries[2]; /**< column entries */
|
2012-03-05 13:34:55 +00:00
|
|
|
GtkListStore *list_store, *comments_list_store;
|
2011-03-22 06:17:20 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *color_str = NULL;
|
|
|
|
guint packet_no = 0;
|
2012-03-09 14:25:30 +00:00
|
|
|
const gchar *group_str;
|
|
|
|
const gchar *severity_str;
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
if(etd->label) {
|
|
|
|
if(etd->last - etd->first) {
|
|
|
|
title = g_strdup_printf("Adding: %u new messages",etd->last - etd->first);
|
|
|
|
gtk_label_set_text(GTK_LABEL(etd->label), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 13:34:55 +00:00
|
|
|
list_store = GTK_LIST_STORE(gtk_tree_view_get_model(etd->tree_view)); /* Get store */
|
2012-03-09 14:25:30 +00:00
|
|
|
comments_list_store = GTK_LIST_STORE(gtk_tree_view_get_model(etd->tree_view_comments));
|
2012-03-05 13:34:55 +00:00
|
|
|
|
2011-03-22 06:17:20 +00:00
|
|
|
/* append new events (remove from new list, append to displayed list and clist) */
|
|
|
|
while(etd->first < etd->last){
|
|
|
|
ei = &g_array_index(etd->ei_array, expert_info_t, etd->first);
|
|
|
|
etd->first++;
|
|
|
|
|
|
|
|
if(ei->severity < etd->severity_report_level) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
etd->disp_events++;
|
|
|
|
|
|
|
|
/* packet number */
|
|
|
|
if(ei->packet_num) {
|
|
|
|
packet_no = ei->packet_num;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match_strval return a static string or NULL
|
|
|
|
severity */
|
2012-03-09 14:25:30 +00:00
|
|
|
severity_str = match_strval(ei->severity, expert_severity_vals);
|
2011-03-22 06:17:20 +00:00
|
|
|
/* group */
|
2012-03-09 14:25:30 +00:00
|
|
|
group_str = match_strval(ei->group, expert_group_vals);
|
2011-03-22 06:17:20 +00:00
|
|
|
|
|
|
|
/* protocol */
|
|
|
|
if(ei->protocol) {
|
|
|
|
entries[0] = ei->protocol;
|
|
|
|
} else {
|
|
|
|
entries[0] = "-";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* summary */
|
|
|
|
entries[1] = ei->summary;
|
|
|
|
|
|
|
|
/* set rows background color depending on severity */
|
|
|
|
switch(ei->severity) {
|
2012-03-02 13:31:16 +00:00
|
|
|
case(PI_COMMENT):
|
|
|
|
color_str = expert_color_comment_str;
|
2012-03-09 14:25:30 +00:00
|
|
|
gtk_list_store_insert_with_values(comments_list_store , &iter, G_MAXINT,
|
|
|
|
NO_COLUMN_C_TABLE, packet_no,
|
|
|
|
SUMMARY_COLUMN_C_TABLE, entries[1],
|
|
|
|
FOREGROUND_COLOR_COL_C_TABLE, expert_color_foreground_str,
|
|
|
|
BACKGROUND_COLOR_COL_C_TABLE, color_str,
|
|
|
|
-1);
|
2012-03-02 13:31:16 +00:00
|
|
|
break;
|
2011-03-22 06:17:20 +00:00
|
|
|
case(PI_CHAT):
|
|
|
|
color_str = expert_color_chat_str;
|
|
|
|
break;
|
|
|
|
case(PI_NOTE):
|
|
|
|
color_str = expert_color_note_str;
|
|
|
|
break;
|
|
|
|
case(PI_WARN):
|
|
|
|
color_str = expert_color_warn_str;
|
|
|
|
break;
|
|
|
|
case(PI_ERROR):
|
|
|
|
color_str = expert_color_error_str;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Creates a new row at position. iter will be changed to point to this new row.
|
|
|
|
* If position is larger than the number of rows on the list, then the new row will be appended to the list.
|
|
|
|
* The row will be filled with the values given to this function.
|
|
|
|
* :
|
|
|
|
* should generally be preferred when inserting rows in a sorted list store.
|
|
|
|
*/
|
|
|
|
gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
|
|
|
|
NO_COLUMN, packet_no,
|
|
|
|
SEVERITY_COLUMN, severity_str,
|
|
|
|
GROUP_COLUMN, group_str,
|
|
|
|
PROTOCOL_COLUMN, entries[0],
|
|
|
|
SUMMARY_COLUMN, entries[1],
|
|
|
|
FOREGROUND_COLOR_COL, expert_color_foreground_str,
|
|
|
|
BACKGROUND_COLOR_COL, color_str,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(etd->label) {
|
2012-03-02 13:53:30 +00:00
|
|
|
title = g_strdup_printf("Errors: %u Warnings: %u Notes: %u Chats: %u, Packet comments: %u",
|
2011-03-22 06:17:20 +00:00
|
|
|
etd->error_events, etd->warn_events,
|
2012-03-02 13:31:16 +00:00
|
|
|
etd->note_events, etd->chat_events, etd->pkt_comments_events);
|
2011-03-22 06:17:20 +00:00
|
|
|
gtk_label_set_text(GTK_LABEL(etd->label), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
title = g_strdup_printf("Wireshark: %u Expert Info%s",
|
|
|
|
etd->disp_events,
|
|
|
|
plurality(etd->disp_events, "", "s"));
|
|
|
|
gtk_window_set_title(GTK_WINDOW(etd->win), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
static void
|
2006-07-01 12:06:36 +00:00
|
|
|
expert_comp_init(const char *optarg _U_, void* userdata _U_)
|
2005-11-25 23:42:52 +00:00
|
|
|
{
|
2005-12-23 10:55:05 +00:00
|
|
|
expert_comp_dlg_t *ss;
|
|
|
|
const char *filter=NULL;
|
|
|
|
GString *error_string;
|
2012-03-05 13:34:55 +00:00
|
|
|
GtkWidget *temp_page, *details_page, *comments_page;
|
2005-11-25 23:42:52 +00:00
|
|
|
GtkWidget *main_nb;
|
2005-12-23 10:55:05 +00:00
|
|
|
GtkWidget *vbox;
|
2009-01-18 14:47:51 +00:00
|
|
|
GtkWidget *hbox;
|
2011-08-03 18:45:06 +00:00
|
|
|
GtkWidget *image;
|
2005-12-23 10:55:05 +00:00
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *close_bt;
|
2008-02-17 21:22:00 +00:00
|
|
|
GtkWidget *help_bt;
|
|
|
|
expert_tapdata_t *etd;
|
2011-10-18 18:05:11 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
ss=g_malloc(sizeof(expert_comp_dlg_t));
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
ss->pkt_comments_events = 0;
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->disp_events = 0;
|
|
|
|
ss->chat_events = 0;
|
|
|
|
ss->note_events = 0;
|
|
|
|
ss->warn_events = 0;
|
|
|
|
ss->error_events = 0;
|
|
|
|
|
2010-08-19 00:09:56 +00:00
|
|
|
expert_comp_dlg_w = ss->win=dlg_window_new("err"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE);
|
2005-12-23 10:55:05 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(ss->win), 700, 300);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2005-12-23 10:55:05 +00:00
|
|
|
error_set_title(ss);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2012-04-21 16:40:14 +00:00
|
|
|
vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
2005-12-23 10:55:05 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(ss->win), vbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
main_nb = gtk_notebook_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), main_nb, TRUE, TRUE, 0);
|
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
/* We must display TOP LEVEL Widget before calling init_table() */
|
2005-12-23 10:55:05 +00:00
|
|
|
gtk_widget_show_all(ss->win);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
|
|
|
/* Errors */
|
2012-04-21 16:40:14 +00:00
|
|
|
temp_page =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->error_label = gtk_label_new("Errors: 0/y");
|
|
|
|
gtk_widget_show(ss->error_label);
|
2012-04-21 16:40:14 +00:00
|
|
|
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
2011-10-18 18:05:11 +00:00
|
|
|
if ( prefs.gui_expert_composite_eyecandy ) {
|
2011-08-03 18:45:06 +00:00
|
|
|
image = pixbuf_to_widget(expert_error_pb_data);
|
|
|
|
gtk_widget_show(image);
|
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), image);
|
|
|
|
}
|
2009-01-18 14:47:51 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), ss->error_label);
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
2005-11-25 23:42:52 +00:00
|
|
|
init_error_table(&ss->error_table, 0, temp_page);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
/* Warnings */
|
2012-04-21 16:40:14 +00:00
|
|
|
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->warn_label = gtk_label_new("Warnings: 0/y");
|
|
|
|
gtk_widget_show(ss->warn_label);
|
2012-04-21 16:40:14 +00:00
|
|
|
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
2011-10-18 18:05:11 +00:00
|
|
|
if ( prefs.gui_expert_composite_eyecandy ) {
|
2011-08-03 18:45:06 +00:00
|
|
|
image = pixbuf_to_widget(expert_warn_pb_data);
|
|
|
|
gtk_widget_show(image);
|
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), image);
|
|
|
|
}
|
2009-01-18 14:47:51 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), ss->warn_label);
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
2005-12-23 10:55:05 +00:00
|
|
|
init_error_table(&ss->warn_table, 0, temp_page);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
/* Notes */
|
2012-04-21 16:40:14 +00:00
|
|
|
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->note_label = gtk_label_new("Notes: 0/y");
|
|
|
|
gtk_widget_show(ss->note_label);
|
2012-04-21 16:40:14 +00:00
|
|
|
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
2011-10-18 18:05:11 +00:00
|
|
|
if ( prefs.gui_expert_composite_eyecandy ) {
|
2011-08-03 18:45:06 +00:00
|
|
|
image = pixbuf_to_widget(expert_note_pb_data);
|
|
|
|
gtk_widget_show(image);
|
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), image);
|
|
|
|
}
|
2009-01-18 14:47:51 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), ss->note_label);
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
2005-12-23 10:55:05 +00:00
|
|
|
init_error_table(&ss->note_table, 0, temp_page);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
/* Chat */
|
2012-04-21 16:40:14 +00:00
|
|
|
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->chat_label = gtk_label_new("Chats: 0/y");
|
|
|
|
gtk_widget_show(ss->chat_label);
|
2012-04-21 16:40:14 +00:00
|
|
|
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
2011-10-18 18:05:11 +00:00
|
|
|
if ( prefs.gui_expert_composite_eyecandy ) {
|
2011-08-03 18:45:06 +00:00
|
|
|
image = pixbuf_to_widget(expert_chat_pb_data);
|
|
|
|
gtk_widget_show(image);
|
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), image);
|
|
|
|
}
|
2009-01-18 14:47:51 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), ss->chat_label);
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
2005-12-23 10:55:05 +00:00
|
|
|
init_error_table(&ss->chat_table, 0, temp_page);
|
2009-01-18 14:47:51 +00:00
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
/* Details */
|
2012-04-21 16:40:14 +00:00
|
|
|
details_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
2009-01-18 14:47:51 +00:00
|
|
|
ss->all_label = gtk_label_new("Details: 0");
|
2012-03-02 13:31:16 +00:00
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), details_page, ss->all_label);
|
|
|
|
|
|
|
|
/* Paket comments */
|
2012-04-21 16:40:14 +00:00
|
|
|
comments_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
2012-03-02 13:31:16 +00:00
|
|
|
ss->pkt_comments_label = gtk_label_new("Packet Comments: 0/y");
|
|
|
|
gtk_widget_show(ss->pkt_comments_label);
|
2012-04-21 16:40:14 +00:00
|
|
|
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
2012-03-02 13:31:16 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(hbox), ss->pkt_comments_label);
|
2012-03-05 13:34:55 +00:00
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), comments_page, hbox);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2012-03-09 14:25:30 +00:00
|
|
|
etd = expert_dlg_new_table();
|
2008-02-17 21:22:00 +00:00
|
|
|
etd->label=gtk_label_new("Please wait ...");
|
2009-04-21 16:57:52 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(etd->label), 0.0f, 0.5f);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
etd->win=ss->win;
|
2012-03-02 13:31:16 +00:00
|
|
|
expert_dlg_init_table(etd, details_page);
|
2012-03-05 13:34:55 +00:00
|
|
|
expert_dlg_init_comments_table(etd, comments_page);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* Add tap listener functions for expert details, From expert_dlg.c*/
|
2008-02-17 21:22:00 +00:00
|
|
|
error_string=register_tap_listener("expert", etd, NULL /* fstring */,
|
2009-08-23 18:32:29 +00:00
|
|
|
TL_REQUIRES_PROTO_TREE,
|
2008-02-17 21:22:00 +00:00
|
|
|
expert_dlg_reset,
|
|
|
|
expert_dlg_packet,
|
|
|
|
expert_dlg_draw);
|
|
|
|
if(error_string){
|
2008-10-31 09:53:56 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
2008-02-17 21:22:00 +00:00
|
|
|
g_string_free(error_string, TRUE);
|
|
|
|
g_free(etd);
|
|
|
|
return;
|
|
|
|
}
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2008-04-11 21:39:16 +00:00
|
|
|
g_signal_connect(etd->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(etd->win, "destroy", G_CALLBACK(expert_dlg_destroy_cb), etd);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Register the tap listener */
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
error_string=register_tap_listener("expert", ss, filter, 0, error_reset, error_packet, expert_comp_draw);
|
2005-12-23 10:55:05 +00:00
|
|
|
if(error_string){
|
2008-10-31 09:53:56 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
2005-12-23 10:55:05 +00:00
|
|
|
g_string_free(error_string, TRUE);
|
|
|
|
g_free(ss);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Button row. */
|
2008-06-21 13:36:31 +00:00
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
|
2005-12-23 10:55:05 +00:00
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
|
2008-04-11 17:14:11 +00:00
|
|
|
close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2005-12-23 10:55:05 +00:00
|
|
|
window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);
|
|
|
|
|
2008-06-21 13:36:31 +00:00
|
|
|
help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_EXPERT_INFO_DIALOG);
|
2011-07-13 08:48:13 +00:00
|
|
|
gtk_widget_set_tooltip_text (help_bt, "Show topic specific help");
|
2008-02-17 21:22:00 +00:00
|
|
|
|
2008-04-11 21:39:16 +00:00
|
|
|
g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss);
|
2005-12-23 10:55:05 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all(ss->win);
|
|
|
|
window_present(ss->win);
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2009-05-05 00:35:54 +00:00
|
|
|
/*
|
|
|
|
* At least at present, the only information the tap listener appears
|
|
|
|
* to care about is available regardless of whether the protocol tree
|
|
|
|
* is being built, so we don't appear to need to have the protocol
|
|
|
|
* tree built.
|
|
|
|
*
|
|
|
|
* This means we can use cf_retap_packets(), even though it will only
|
|
|
|
* build the protocol tree if at least one tap has a filter in place.
|
|
|
|
* cf_retap_packets() is faster than cf_redissect_packets(), as it
|
|
|
|
* assumes we didn't change anything that would cause any packets to
|
|
|
|
* dissect differently, and thus doesn't redo the packet display.
|
2005-11-25 23:42:52 +00:00
|
|
|
*/
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2009-05-05 00:35:54 +00:00
|
|
|
|
|
|
|
/* This will bring up the progress bar
|
|
|
|
* Put our window back in front
|
|
|
|
*/
|
2011-07-21 20:12:08 +00:00
|
|
|
gdk_window_raise(gtk_widget_get_window(ss->win));
|
2010-08-19 00:09:56 +00:00
|
|
|
/* Set the lable text */
|
|
|
|
expert_comp_draw(ss);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
void
|
2010-08-19 00:09:56 +00:00
|
|
|
expert_comp_dlg_launch(void)
|
2005-11-25 23:42:52 +00:00
|
|
|
{
|
2009-08-19 18:37:13 +00:00
|
|
|
if (expert_comp_dlg_w) {
|
2010-08-19 00:09:56 +00:00
|
|
|
reactivate_window(expert_comp_dlg_w);
|
2009-08-19 18:37:13 +00:00
|
|
|
} else {
|
2010-08-19 00:09:56 +00:00
|
|
|
expert_comp_init("", NULL);
|
2009-08-19 18:37:13 +00:00
|
|
|
}
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_expert_comp(void)
|
|
|
|
{
|
2006-02-11 13:05:24 +00:00
|
|
|
register_stat_cmd_arg("expert_comp", expert_comp_init,NULL);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2011-09-25 21:19:45 +00:00
|
|
|
|