2 * expert_comp_dlg 2005 Greg Morris
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <epan/packet_info.h>
32 #include <epan/prefs.h>
34 #include <epan/stat_cmd_args.h>
36 #include "../stat_menu.h"
38 #include "ui/simple_dialog.h"
40 #include "ui/gtk/gui_utils.h"
41 #include "ui/gtk/dlg_utils.h"
42 #include "ui/gtk/expert_comp_table.h"
43 #include "ui/gtk/gui_stat_menu.h"
44 #include "ui/gtk/help_dlg.h"
45 #include "ui/gtk/expert_comp_dlg.h"
46 #include "ui/gtk/stock_icons.h"
47 #include "ui/gtk/main.h"
48 #include "ui/gtk/expert_indicators.h"
49 #include "ui/gtk/packet_panes.h"
50 #include "ui/gtk/old-gtk-compat.h"
51 #include "ui/gtk/edit_packet_comment_dlg.h"
52 #include "ui/gtk/capture_comment_icons.h"
57 SUMMARY_COLUMN_C_TABLE
,
58 FOREGROUND_COLOR_COL_C_TABLE
,
59 BACKGROUND_COLOR_COL_C_TABLE
,
75 /* used to keep track of the statistics for an entire program interface */
76 typedef struct _expert_comp_dlg_t
{
78 GtkWidget
*pkt_comments_label
;
79 GtkWidget
*chat_label
;
80 GtkWidget
*note_label
;
81 GtkWidget
*warn_label
;
82 GtkWidget
*error_label
;
84 error_equiv_table chat_table
;
85 error_equiv_table note_table
;
86 error_equiv_table warn_table
;
87 error_equiv_table error_table
;
88 guint32 pkt_comments_events
;
96 struct expert_tapdata_s
{
98 GtkWidget
*scrolled_window
;
99 GtkTreeView
*tree_view
;
100 GtkWidget
*scrolled_window_comments
;
101 GtkTreeView
*tree_view_comments
;
103 guint32 pkt_comments_events
;
108 guint32 error_events
;
109 int severity_report_level
;
111 GArray
*ei_array
; /* expert info items */
114 GStringChunk
*text
; /* summary text */
117 static GtkWidget
*expert_comp_dlg_w
= NULL
;
120 select_row_cb(GtkTreeSelection
*selection
, gpointer
*user_data _U_
)
122 /*guint num = GPOINTER_TO_UINT(gtk_clist_get_row_data(clist, row));*/
124 /*cf_goto_frame(&cfile, num);*/
133 if (gtk_tree_selection_get_selected (selection
, &model
, &iter
)){
134 gtk_tree_model_get (model
, &iter
, NO_COLUMN
, &fnumber
, -1);
135 cf_goto_frame(&cfile
, fnumber
);
140 /* reset of display only, e.g. for filtering */
141 static void expert_dlg_display_reset(expert_tapdata_t
* etd
)
143 etd
->disp_events
= 0;
144 gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(etd
->tree_view
))));
145 gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(etd
->tree_view_comments
))));
147 gtk_window_set_title(GTK_WINDOW(etd
->win
), "Wireshark: ? Expert Infos");
149 gtk_label_set_text(GTK_LABEL(etd
->label
), "Please wait ...");
153 /* complete reset, e.g. capture file closed */
155 expert_dlg_reset(void *tapdata
)
157 expert_tapdata_t
* etd
= (expert_tapdata_t
*)tapdata
;
159 etd
->chat_events
= 0;
160 etd
->note_events
= 0;
161 etd
->warn_events
= 0;
162 etd
->error_events
= 0;
163 etd
->pkt_comments_events
= 0;
166 /* g_string_chunk_clear() is introduced in glib 2.14 */
167 g_string_chunk_free(etd
->text
);
168 etd
->text
= g_string_chunk_new(100);
169 g_array_set_size(etd
->ei_array
, 0);
171 expert_dlg_display_reset(etd
);
175 expert_dlg_packet(void *tapdata
, packet_info
*pinfo _U_
, epan_dissect_t
*edt _U_
, const void *pointer
)
178 expert_tapdata_t
*etd
= (expert_tapdata_t
*)tapdata
;
180 g_array_append_val(etd
->ei_array
, *(expert_info_t
*)pointer
);
181 etd
->last
= etd
->ei_array
->len
;
182 ei
= &g_array_index(etd
->ei_array
, expert_info_t
, etd
->last
-1); /* ugly */
183 ei
->protocol
= g_string_chunk_insert_const(etd
->text
, ei
->protocol
);
184 ei
->summary
= g_string_chunk_insert_const(etd
->text
, ei
->summary
);
186 switch(ei
->severity
) {
188 etd
->pkt_comments_events
++;
203 g_assert_not_reached();
205 if(ei
->severity
< etd
->severity_report_level
) {
206 return 0; /* draw not required */
208 return 1; /* draw required */
212 error_set_title(expert_comp_dlg_t
*ss
)
214 set_window_title(ss
->win
, "Expert Info");
218 error_reset(void *pss
)
220 expert_comp_dlg_t
*ss
=(expert_comp_dlg_t
*)pss
;
223 ss
->error_events
= 0;
228 ss
->pkt_comments_events
= 0;
230 reset_error_table_data(&ss
->error_table
);
231 buf
= g_strdup_printf("Errors: %u (0)", ss
->error_table
.num_procs
);
232 gtk_label_set_text( GTK_LABEL(ss
->error_label
), buf
);
235 reset_error_table_data(&ss
->warn_table
);
236 buf
= g_strdup_printf("Warnings: %u (0)", ss
->warn_table
.num_procs
);
237 gtk_label_set_text( GTK_LABEL(ss
->warn_label
), buf
);
240 reset_error_table_data(&ss
->note_table
);
241 buf
= g_strdup_printf("Notes: %u (0)", ss
->note_table
.num_procs
);
242 gtk_label_set_text( GTK_LABEL(ss
->note_label
), buf
);
245 reset_error_table_data(&ss
->chat_table
);
246 buf
= g_strdup_printf("Chats: %u (0)", ss
->chat_table
.num_procs
);
247 gtk_label_set_text( GTK_LABEL(ss
->chat_label
), buf
);
250 gtk_label_set_text( GTK_LABEL(ss
->all_label
), "Details: 0");
252 gtk_label_set_text( GTK_LABEL(ss
->pkt_comments_label
), "Packet comments: 0");
258 error_packet(void *pss
, packet_info
*pinfo _U_
, epan_dissect_t
*edt _U_
, const void *prv
)
260 expert_comp_dlg_t
*ss
=(expert_comp_dlg_t
*)pss
;
261 const expert_info_t
*error_pkt
=(expert_info_t
*)prv
;
263 /* if return value is 0 then no error */
268 switch (error_pkt
->severity
) {
272 init_error_table_row(&ss
->error_table
, error_pkt
);
277 init_error_table_row(&ss
->warn_table
, error_pkt
);
282 init_error_table_row(&ss
->note_table
, error_pkt
);
287 init_error_table_row(&ss
->chat_table
, error_pkt
);
290 ss
->disp_events
++; /* Count ? */
291 ss
->pkt_comments_events
++;
294 return FALSE
; /* Don't draw */
296 return TRUE
; /* Draw */
300 expert_comp_draw(void *data
)
304 expert_comp_dlg_t
*ss
=(expert_comp_dlg_t
*)data
;
306 buf
= g_strdup_printf("Errors: %u (%u)", ss
->error_table
.num_procs
, ss
->error_events
);
307 gtk_label_set_text( GTK_LABEL(ss
->error_label
), buf
);
310 buf
= g_strdup_printf("Warnings: %u (%u)", ss
->warn_table
.num_procs
, ss
->warn_events
);
311 gtk_label_set_text( GTK_LABEL(ss
->warn_label
), buf
);
314 buf
= g_strdup_printf("Notes: %u (%u)", ss
->note_table
.num_procs
, ss
->note_events
);
315 gtk_label_set_text( GTK_LABEL(ss
->note_label
), buf
);
318 buf
= g_strdup_printf("Chats: %u (%u)", ss
->chat_table
.num_procs
, ss
->chat_events
);
319 gtk_label_set_text( GTK_LABEL(ss
->chat_label
), buf
);
322 buf
= g_strdup_printf("Details: %u", ss
->disp_events
);
323 gtk_label_set_text( GTK_LABEL(ss
->all_label
), buf
);
326 buf
= g_strdup_printf("Packet Comments: %u", ss
->pkt_comments_events
);
327 gtk_label_set_text( GTK_LABEL(ss
->pkt_comments_label
), buf
);
333 win_destroy_cb(GtkWindow
*win _U_
, gpointer data
)
335 expert_comp_dlg_t
*ss
=(expert_comp_dlg_t
*)data
;
337 remove_tap_listener(ss
);
339 if (expert_comp_dlg_w
!= NULL
) {
340 window_destroy(expert_comp_dlg_w
);
341 expert_comp_dlg_w
= NULL
;
344 free_error_table_data(&ss
->error_table
);
345 free_error_table_data(&ss
->warn_table
);
346 free_error_table_data(&ss
->note_table
);
347 free_error_table_data(&ss
->chat_table
);
353 expert_dlg_destroy_cb(GtkWindow
*win _U_
, gpointer data
)
355 expert_tapdata_t
*etd
=(expert_tapdata_t
*)data
;
357 remove_tap_listener(etd
);
359 /*free_srt_table_data(&etd->afp_srt_table);*/
360 g_array_free(etd
->ei_array
, TRUE
);
361 g_string_chunk_free(etd
->text
);
365 static expert_tapdata_t
* expert_dlg_new_table(void)
367 expert_tapdata_t
* etd
;
368 etd
=(expert_tapdata_t
*)g_malloc0(sizeof(expert_tapdata_t
));
370 etd
->ei_array
= g_array_sized_new(FALSE
, FALSE
, sizeof(expert_info_t
), 1000);
371 etd
->text
= g_string_chunk_new(100);
372 etd
->severity_report_level
= PI_COMMENT
;
377 comments_row_double_click_cb(GtkTreeView
*treeview _U_
, GtkTreePath
*path _U_
,
378 GtkTreeViewColumn
*col _U_
, gpointer userdata _U_
)
380 edit_packet_comment_dlg(NULL
, NULL
);
384 expert_dlg_init_comments_table(expert_tapdata_t
* etd
, GtkWidget
*vbox
)
388 GtkTreeViewColumn
*column
;
389 GtkCellRenderer
*renderer
;
390 GtkTreeSortable
*sortable
;
391 GtkTreeSelection
*selection
;
393 /* Create the store */
394 store
= gtk_list_store_new(N_COLUMNS_COMMENT_TBL
, /* Total number of columns */
395 G_TYPE_UINT
, /* No */
396 G_TYPE_POINTER
, /* Summary */
397 G_TYPE_STRING
, /* Foreground */
398 G_TYPE_STRING
); /* Background */
401 tree
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (store
));
402 etd
->tree_view_comments
= GTK_TREE_VIEW(tree
);
403 sortable
= GTK_TREE_SORTABLE(store
);
405 /* Speed up the list display */
406 gtk_tree_view_set_fixed_height_mode(etd
->tree_view_comments
, TRUE
);
408 /* Setup the sortable columns */
409 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree
), FALSE
);
411 /* The view now holds a reference. We can get rid of our own reference */
412 g_object_unref (G_OBJECT (store
));
414 /* Let the font be the default one to have the same look as the rest of the tabs
415 * Bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4388
416 * gtk_widget_modify_font(GTK_WIDGET (etd->tree_view), user_font_get_regular());
419 /* Create a cell renderer */
420 renderer
= gtk_cell_renderer_text_new ();
421 g_object_set(renderer
, "ypad", 0, NULL
);
422 g_object_set(renderer
, "xalign", 1.0, NULL
);
424 /* Create the first column, associating the "text" attribute of the
425 * cell_renderer to the first column of the model */
427 column
= gtk_tree_view_column_new_with_attributes ("No", renderer
,
428 "text", NO_COLUMN_C_TABLE
,
429 "foreground", FOREGROUND_COLOR_COL_C_TABLE
,
430 "background", BACKGROUND_COLOR_COL_C_TABLE
,
432 gtk_tree_view_column_set_sort_column_id(column
, NO_COLUMN_C_TABLE
);
433 gtk_tree_view_column_set_resizable(column
, TRUE
);
434 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
435 gtk_tree_view_column_set_min_width(column
, 40);
436 gtk_tree_view_append_column (etd
->tree_view_comments
, column
);
440 renderer
= gtk_cell_renderer_text_new ();
441 g_object_set(renderer
, "ypad", 0, NULL
);
442 column
= gtk_tree_view_column_new_with_attributes ("Summary", renderer
,
443 "foreground", FOREGROUND_COLOR_COL_C_TABLE
,
444 "background", BACKGROUND_COLOR_COL_C_TABLE
,
446 gtk_tree_view_column_set_cell_data_func(column
, renderer
, str_ptr_data_func
,
447 GINT_TO_POINTER(SUMMARY_COLUMN_C_TABLE
), NULL
);
449 gtk_tree_sortable_set_sort_func(sortable
, SUMMARY_COLUMN
, str_ptr_sort_func
,
450 GINT_TO_POINTER(SUMMARY_COLUMN_C_TABLE
), NULL
);
452 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
453 gtk_tree_view_column_set_min_width(column
, 90);
454 gtk_tree_view_column_set_sort_column_id(column
, SUMMARY_COLUMN_C_TABLE
);
455 gtk_tree_view_column_set_resizable(column
, TRUE
);
456 gtk_tree_view_append_column (etd
->tree_view_comments
, column
);
458 gtk_tree_view_set_search_column (etd
->tree_view_comments
, SUMMARY_COLUMN_C_TABLE
); /* Allow searching the summary */
459 gtk_tree_view_set_reorderable (etd
->tree_view_comments
, TRUE
); /* Allow user to reorder data with drag n drop */
461 /* Now enable the sorting of each column */
462 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(etd
->tree_view_comments
), TRUE
);
463 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(etd
->tree_view_comments
), TRUE
);
465 /* Setup the selection handler */
466 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(etd
->tree_view_comments
));
467 gtk_tree_selection_set_mode(selection
, GTK_SELECTION_SINGLE
);
469 g_signal_connect (G_OBJECT (selection
), "changed", /* select_row */
470 G_CALLBACK (select_row_cb
),
473 g_signal_connect(tree
, "row-activated",
474 G_CALLBACK(comments_row_double_click_cb
), NULL
);
476 etd
->scrolled_window_comments
=scrolled_window_new(NULL
, NULL
);
477 gtk_container_add(GTK_CONTAINER(etd
->scrolled_window_comments
), GTK_WIDGET (etd
->tree_view_comments
));
479 gtk_box_pack_start(GTK_BOX(vbox
), etd
->scrolled_window_comments
, TRUE
, TRUE
, 0);
483 expert_dlg_init_table(expert_tapdata_t
* etd
, GtkWidget
*vbox
)
487 GtkTreeViewColumn
*column
;
488 GtkCellRenderer
*renderer
;
489 GtkTreeSortable
*sortable
;
490 GtkTreeSelection
*selection
;
492 /* Create the store */
493 store
= gtk_list_store_new(N_COLUMNS
, /* Total number of columns */
494 G_TYPE_UINT
, /* No */
495 G_TYPE_POINTER
, /* Severity */
496 G_TYPE_POINTER
, /* Group */
497 G_TYPE_POINTER
, /* Protocol */
498 G_TYPE_POINTER
, /* Summary */
499 G_TYPE_STRING
, /* Foreground */
500 G_TYPE_STRING
); /* Background */
503 tree
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (store
));
504 etd
->tree_view
= GTK_TREE_VIEW(tree
);
505 sortable
= GTK_TREE_SORTABLE(store
);
507 /* Speed up the list display */
508 gtk_tree_view_set_fixed_height_mode(etd
->tree_view
, TRUE
);
510 /* Setup the sortable columns */
511 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree
), FALSE
);
513 /* The view now holds a reference. We can get rid of our own reference */
514 g_object_unref (G_OBJECT (store
));
516 /* Let the font be the default one to have the same look as the rest of the tabs
517 * Bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4388
518 * gtk_widget_modify_font(GTK_WIDGET (etd->tree_view), user_font_get_regular());
521 /* Create a cell renderer */
522 renderer
= gtk_cell_renderer_text_new ();
523 g_object_set(renderer
, "ypad", 0, NULL
);
524 g_object_set(renderer
, "xalign", 1.0, NULL
);
526 /* Create the first column, associating the "text" attribute of the
527 * cell_renderer to the first column of the model */
529 column
= gtk_tree_view_column_new_with_attributes ("No", renderer
,
531 "foreground", FOREGROUND_COLOR_COL
,
532 "background", BACKGROUND_COLOR_COL
,
534 gtk_tree_view_column_set_sort_column_id(column
, NO_COLUMN
);
535 gtk_tree_view_column_set_resizable(column
, TRUE
);
536 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
537 gtk_tree_view_column_set_min_width(column
, 40);
538 gtk_tree_view_append_column (etd
->tree_view
, column
);
541 renderer
= gtk_cell_renderer_text_new ();
542 g_object_set(renderer
, "ypad", 0, NULL
);
544 column
= gtk_tree_view_column_new_with_attributes ("Severity", renderer
,
545 "foreground", FOREGROUND_COLOR_COL
,
546 "background", BACKGROUND_COLOR_COL
,
549 gtk_tree_view_column_set_cell_data_func(column
, renderer
, str_ptr_data_func
,
550 GINT_TO_POINTER(SEVERITY_COLUMN
), NULL
);
552 gtk_tree_sortable_set_sort_func(sortable
, SEVERITY_COLUMN
, str_ptr_sort_func
,
553 GINT_TO_POINTER(SEVERITY_COLUMN
), NULL
);
555 gtk_tree_view_column_set_sort_column_id(column
, SEVERITY_COLUMN
);
556 gtk_tree_view_column_set_resizable(column
, TRUE
);
557 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
558 gtk_tree_view_column_set_min_width(column
, 80);
559 /* Add the column to the view. */
560 gtk_tree_view_append_column (etd
->tree_view
, column
);
563 renderer
= gtk_cell_renderer_text_new ();
564 g_object_set(renderer
, "ypad", 0, NULL
);
565 column
= gtk_tree_view_column_new_with_attributes ("Group", renderer
,
566 "foreground", FOREGROUND_COLOR_COL
,
567 "background", BACKGROUND_COLOR_COL
,
570 gtk_tree_view_column_set_cell_data_func(column
, renderer
, str_ptr_data_func
,
571 GINT_TO_POINTER(GROUP_COLUMN
), NULL
);
573 gtk_tree_sortable_set_sort_func(sortable
, GROUP_COLUMN
, str_ptr_sort_func
,
574 GINT_TO_POINTER(GROUP_COLUMN
), NULL
);
576 gtk_tree_view_column_set_sort_column_id(column
, GROUP_COLUMN
);
577 gtk_tree_view_column_set_resizable(column
, TRUE
);
578 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
579 gtk_tree_view_column_set_min_width(column
, 80);
580 /* Add the column to the view. */
581 gtk_tree_view_append_column (etd
->tree_view
, column
);
584 renderer
= gtk_cell_renderer_text_new ();
585 g_object_set(renderer
, "ypad", 0, NULL
);
586 column
= gtk_tree_view_column_new_with_attributes ("Protocol", renderer
,
587 "foreground", FOREGROUND_COLOR_COL
,
588 "background", BACKGROUND_COLOR_COL
,
590 gtk_tree_view_column_set_cell_data_func(column
, renderer
, str_ptr_data_func
,
591 GINT_TO_POINTER(PROTOCOL_COLUMN
), NULL
);
593 gtk_tree_sortable_set_sort_func(sortable
, PROTOCOL_COLUMN
, str_ptr_sort_func
,
594 GINT_TO_POINTER(PROTOCOL_COLUMN
), NULL
);
596 gtk_tree_view_column_set_sort_column_id(column
, PROTOCOL_COLUMN
);
597 gtk_tree_view_column_set_resizable(column
, TRUE
);
598 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
599 gtk_tree_view_column_set_min_width(column
, 80);
600 gtk_tree_view_append_column (etd
->tree_view
, column
);
603 renderer
= gtk_cell_renderer_text_new ();
604 g_object_set(renderer
, "ypad", 0, NULL
);
605 column
= gtk_tree_view_column_new_with_attributes ("Summary", renderer
,
606 "foreground", FOREGROUND_COLOR_COL
,
607 "background", BACKGROUND_COLOR_COL
,
609 gtk_tree_view_column_set_cell_data_func(column
, renderer
, str_ptr_data_func
,
610 GINT_TO_POINTER(SUMMARY_COLUMN
), NULL
);
612 gtk_tree_sortable_set_sort_func(sortable
, SUMMARY_COLUMN
, str_ptr_sort_func
,
613 GINT_TO_POINTER(SUMMARY_COLUMN
), NULL
);
615 gtk_tree_view_column_set_sizing(column
, GTK_TREE_VIEW_COLUMN_FIXED
);
616 gtk_tree_view_column_set_min_width(column
, 90);
617 gtk_tree_view_column_set_sort_column_id(column
, SUMMARY_COLUMN
);
618 gtk_tree_view_column_set_resizable(column
, TRUE
);
619 gtk_tree_view_append_column (etd
->tree_view
, column
);
621 gtk_tree_view_set_search_column (etd
->tree_view
, SUMMARY_COLUMN
); /* Allow searching the summary */
622 gtk_tree_view_set_reorderable (etd
->tree_view
, TRUE
); /* Allow user to reorder data with drag n drop */
624 /* Now enable the sorting of each column */
625 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(etd
->tree_view
), TRUE
);
626 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(etd
->tree_view
), TRUE
);
628 /* Setup the selection handler */
629 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(etd
->tree_view
));
630 gtk_tree_selection_set_mode(selection
, GTK_SELECTION_SINGLE
);
632 g_signal_connect (G_OBJECT (selection
), "changed", /* select_row */
633 G_CALLBACK (select_row_cb
),
636 etd
->scrolled_window
=scrolled_window_new(NULL
, NULL
);
637 gtk_container_add(GTK_CONTAINER(etd
->scrolled_window
), GTK_WIDGET (etd
->tree_view
));
639 gtk_box_pack_start(GTK_BOX(vbox
), etd
->scrolled_window
, TRUE
, TRUE
, 0);
643 expert_dlg_draw(void *data
)
645 expert_tapdata_t
*etd
= (expert_tapdata_t
*)data
;
648 const char *entries
[2]; /**< column entries */
649 GtkListStore
*list_store
, *comments_list_store
;
651 gchar
*color_str
= NULL
;
653 const gchar
*group_str
;
654 const gchar
*severity_str
;
658 if(etd
->last
- etd
->first
) {
659 title
= g_strdup_printf("Adding: %u new messages",etd
->last
- etd
->first
);
660 gtk_label_set_text(GTK_LABEL(etd
->label
), title
);
665 list_store
= GTK_LIST_STORE(gtk_tree_view_get_model(etd
->tree_view
)); /* Get store */
666 comments_list_store
= GTK_LIST_STORE(gtk_tree_view_get_model(etd
->tree_view_comments
));
668 /* append new events (remove from new list, append to displayed list and clist) */
669 while(etd
->first
< etd
->last
){
670 ei
= &g_array_index(etd
->ei_array
, expert_info_t
, etd
->first
);
673 if(ei
->severity
< etd
->severity_report_level
) {
680 packet_no
= ei
->packet_num
;
683 /* try_val_to_str return a static string or NULL
685 severity_str
= try_val_to_str(ei
->severity
, expert_severity_vals
);
687 group_str
= try_val_to_str(ei
->group
, expert_group_vals
);
691 entries
[0] = ei
->protocol
;
697 entries
[1] = ei
->summary
;
699 /* set rows background color depending on severity */
700 switch(ei
->severity
) {
702 color_str
= expert_color_comment_str
;
703 gtk_list_store_insert_with_values(comments_list_store
, &iter
, G_MAXINT
,
704 NO_COLUMN_C_TABLE
, packet_no
,
705 SUMMARY_COLUMN_C_TABLE
, entries
[1],
706 FOREGROUND_COLOR_COL_C_TABLE
, expert_color_foreground_str
,
707 BACKGROUND_COLOR_COL_C_TABLE
, color_str
,
711 color_str
= expert_color_chat_str
;
714 color_str
= expert_color_note_str
;
717 color_str
= expert_color_warn_str
;
720 color_str
= expert_color_error_str
;
723 g_assert_not_reached();
727 /* Creates a new row at position. iter will be changed to point to this new row.
728 * If position is larger than the number of rows on the list, then the new row will be appended to the list.
729 * The row will be filled with the values given to this function.
731 * should generally be preferred when inserting rows in a sorted list store.
733 gtk_list_store_insert_with_values( list_store
, &iter
, G_MAXINT
,
734 NO_COLUMN
, packet_no
,
735 SEVERITY_COLUMN
, severity_str
,
736 GROUP_COLUMN
, group_str
,
737 PROTOCOL_COLUMN
, entries
[0],
738 SUMMARY_COLUMN
, entries
[1],
739 FOREGROUND_COLOR_COL
, expert_color_foreground_str
,
740 BACKGROUND_COLOR_COL
, color_str
,
745 title
= g_strdup_printf("Errors: %u Warnings: %u Notes: %u Chats: %u, Packet comments: %u",
746 etd
->error_events
, etd
->warn_events
,
747 etd
->note_events
, etd
->chat_events
, etd
->pkt_comments_events
);
748 gtk_label_set_text(GTK_LABEL(etd
->label
), title
);
752 title
= g_strdup_printf("Wireshark: %u Expert Info%s",
754 plurality(etd
->disp_events
, "", "s"));
755 gtk_window_set_title(GTK_WINDOW(etd
->win
), title
);
760 expert_comp_init(const char *opt_arg _U_
, void* userdata _U_
)
762 expert_comp_dlg_t
*ss
;
763 const char *filter
=NULL
;
764 GString
*error_string
;
765 GtkWidget
*temp_page
, *details_page
, *comments_page
;
773 expert_tapdata_t
*etd
;
775 ss
=(expert_comp_dlg_t
*)g_malloc(sizeof(expert_comp_dlg_t
));
777 ss
->pkt_comments_events
= 0;
782 ss
->error_events
= 0;
784 expert_comp_dlg_w
= ss
->win
=dlg_window_new("err"); /* transient_for top_level */
785 gtk_window_set_destroy_with_parent (GTK_WINDOW(ss
->win
), TRUE
);
786 gtk_window_set_default_size(GTK_WINDOW(ss
->win
), 700, 300);
790 vbox
=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 3, FALSE
);
791 gtk_container_add(GTK_CONTAINER(ss
->win
), vbox
);
792 gtk_container_set_border_width(GTK_CONTAINER(vbox
), 12);
794 main_nb
= gtk_notebook_new();
795 gtk_box_pack_start(GTK_BOX(vbox
), main_nb
, TRUE
, TRUE
, 0);
797 /* We must display TOP LEVEL Widget before calling init_table() */
798 gtk_widget_show_all(ss
->win
);
801 temp_page
=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6, FALSE
);
802 ss
->error_label
= gtk_label_new("Errors: 0/y");
803 gtk_widget_show(ss
->error_label
);
804 hbox
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 3, FALSE
);
805 if ( prefs
.gui_expert_composite_eyecandy
) {
806 image
= pixbuf_to_widget(expert_error_pb_data
);
807 gtk_widget_show(image
);
808 gtk_box_pack_start(GTK_BOX(hbox
), image
, TRUE
, TRUE
, 0);
810 gtk_box_pack_start(GTK_BOX(hbox
), ss
->error_label
, TRUE
, TRUE
, 0);
811 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb
), temp_page
, hbox
);
812 init_error_table(&ss
->error_table
, 0, temp_page
);
815 temp_page
= ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6, FALSE
);
816 ss
->warn_label
= gtk_label_new("Warnings: 0/y");
817 gtk_widget_show(ss
->warn_label
);
818 hbox
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 3, FALSE
);
819 if ( prefs
.gui_expert_composite_eyecandy
) {
820 image
= pixbuf_to_widget(expert_warn_pb_data
);
821 gtk_widget_show(image
);
822 gtk_box_pack_start(GTK_BOX(hbox
), image
, TRUE
, TRUE
, 0);
825 gtk_box_pack_start(GTK_BOX(hbox
), ss
->warn_label
, TRUE
, TRUE
, 0);
826 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb
), temp_page
, hbox
);
827 init_error_table(&ss
->warn_table
, 0, temp_page
);
830 temp_page
= ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6, FALSE
);
831 ss
->note_label
= gtk_label_new("Notes: 0/y");
832 gtk_widget_show(ss
->note_label
);
833 hbox
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 3, FALSE
);
834 if ( prefs
.gui_expert_composite_eyecandy
) {
835 image
= pixbuf_to_widget(expert_note_pb_data
);
836 gtk_widget_show(image
);
837 gtk_box_pack_start(GTK_BOX(hbox
), image
, TRUE
, TRUE
, 0);
839 gtk_box_pack_start(GTK_BOX(hbox
), ss
->note_label
, TRUE
, TRUE
, 0);
840 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb
), temp_page
, hbox
);
841 init_error_table(&ss
->note_table
, 0, temp_page
);
844 temp_page
= ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6, FALSE
);
845 ss
->chat_label
= gtk_label_new("Chats: 0/y");
846 gtk_widget_show(ss
->chat_label
);
847 hbox
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 3, FALSE
);
848 if ( prefs
.gui_expert_composite_eyecandy
) {
849 image
= pixbuf_to_widget(expert_chat_pb_data
);
850 gtk_widget_show(image
);
851 gtk_box_pack_start(GTK_BOX(hbox
), image
, TRUE
, TRUE
, 0);
853 gtk_box_pack_start(GTK_BOX(hbox
), ss
->chat_label
, TRUE
, TRUE
, 0);
854 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb
), temp_page
, hbox
);
855 init_error_table(&ss
->chat_table
, 0, temp_page
);
858 details_page
= ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6, FALSE
);
859 ss
->all_label
= gtk_label_new("Details: 0/y");
860 gtk_widget_show(ss
->all_label
);
861 hbox
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 3, FALSE
);
862 if ( prefs
.gui_expert_composite_eyecandy
) {
863 image
= pixbuf_to_widget(capture_comment_disabled_pb_data
);
864 gtk_widget_show(image
);
865 gtk_box_pack_start(GTK_BOX(hbox
), image
, TRUE
, TRUE
, 0);
867 gtk_box_pack_start(GTK_BOX(hbox
), ss
->all_label
, TRUE
, TRUE
, 0);
868 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb
), details_page
, hbox
);
870 /* Packet comments */
871 comments_page
= ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6, FALSE
);
872 ss
->pkt_comments_label
= gtk_label_new("Packet Comments: 0/y");
873 gtk_widget_show(ss
->pkt_comments_label
);
874 hbox
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 3, FALSE
);
875 if ( prefs
.gui_expert_composite_eyecandy
) {
876 image
= pixbuf_to_widget(capture_comment_update_pb_data
);
877 gtk_widget_show(image
);
878 gtk_box_pack_start(GTK_BOX(hbox
), image
, TRUE
, TRUE
, 0);
880 gtk_box_pack_start(GTK_BOX(hbox
), ss
->pkt_comments_label
, TRUE
, TRUE
, 0);
881 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb
), comments_page
, hbox
);
883 etd
= expert_dlg_new_table();
884 etd
->label
=gtk_label_new("Please wait ...");
885 gtk_misc_set_alignment(GTK_MISC(etd
->label
), 0.0f
, 0.5f
);
888 expert_dlg_init_table(etd
, details_page
);
889 expert_dlg_init_comments_table(etd
, comments_page
);
891 /* Add tap listener functions for expert details, From expert_dlg.c*/
892 error_string
=register_tap_listener("expert", etd
, NULL
/* fstring */,
893 TL_REQUIRES_PROTO_TREE
,
898 simple_dialog(ESD_TYPE_ERROR
, ESD_BTN_OK
, "%s", error_string
->str
);
899 g_string_free(error_string
, TRUE
);
904 g_signal_connect(etd
->win
, "delete_event", G_CALLBACK(window_delete_event_cb
), NULL
);
905 g_signal_connect(etd
->win
, "destroy", G_CALLBACK(expert_dlg_destroy_cb
), etd
);
907 /* Register the tap listener */
909 error_string
=register_tap_listener("expert", ss
, filter
, 0, error_reset
, error_packet
, expert_comp_draw
);
911 simple_dialog(ESD_TYPE_ERROR
, ESD_BTN_OK
, "%s", error_string
->str
);
912 g_string_free(error_string
, TRUE
);
918 bbox
= dlg_button_row_new(GTK_STOCK_CLOSE
, GTK_STOCK_HELP
, NULL
);
919 gtk_box_pack_end(GTK_BOX(vbox
), bbox
, FALSE
, FALSE
, 0);
921 close_bt
= (GtkWidget
*)g_object_get_data(G_OBJECT(bbox
), GTK_STOCK_CLOSE
);
922 window_set_cancel_button(ss
->win
, close_bt
, window_cancel_button_cb
);
924 help_bt
= (GtkWidget
*)g_object_get_data(G_OBJECT(bbox
), GTK_STOCK_HELP
);
925 g_signal_connect(help_bt
, "clicked", G_CALLBACK(topic_cb
), (gpointer
)HELP_EXPERT_INFO_DIALOG
);
926 gtk_widget_set_tooltip_text (help_bt
, "Show topic specific help");
928 g_signal_connect(ss
->win
, "delete_event", G_CALLBACK(window_delete_event_cb
), NULL
);
929 g_signal_connect(ss
->win
, "destroy", G_CALLBACK(win_destroy_cb
), ss
);
931 gtk_widget_show_all(ss
->win
);
932 window_present(ss
->win
);
935 * At least at present, the only information the tap listener appears
936 * to care about is available regardless of whether the protocol tree
937 * is being built, so we don't appear to need to have the protocol
940 * This means we can use cf_retap_packets(), even though it will only
941 * build the protocol tree if at least one tap has a filter in place.
942 * cf_retap_packets() is faster than cf_redissect_packets(), as it
943 * assumes we didn't change anything that would cause any packets to
944 * dissect differently, and thus doesn't redo the packet display.
946 cf_retap_packets(&cfile
);
948 /* This will bring up the progress bar
949 * Put our window back in front
951 gdk_window_raise(gtk_widget_get_window(ss
->win
));
952 /* Set the label text */
953 expert_comp_draw(ss
);
957 expert_comp_dlg_launch(void)
959 if (expert_comp_dlg_w
) {
960 reactivate_window(expert_comp_dlg_w
);
962 expert_comp_init("", NULL
);
967 register_tap_listener_expert_comp(void)
969 register_stat_cmd_arg("expert_comp", expert_comp_init
,NULL
);
973 expert_comp_packet_comment_updated(void)
975 if (expert_comp_dlg_w
)
976 cf_retap_packets(&cfile
);