2 * expert_comp_table 2005 Greg Morris
3 * Portions copied from service_response_time_table.c by Ronnie Sahlberg
4 * Helper routines common to all composite expert statistics
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #include "compat_macros.h"
38 #include "epan/packet_info.h"
39 #include "expert_comp_table.h"
41 #if (GTK_MAJOR_VERSION < 2)
42 #include "image/clist_ascend.xpm"
43 #include "image/clist_descend.xpm"
46 #include "simple_dialog.h"
48 #include "gtk/find_dlg.h"
50 #include "gtk/color_dlg.h"
52 #include "gui_utils.h"
53 #include "gtkglobals.h"
54 #include "webbrowser.h"
55 #include <epan/expert.h>
56 #include <epan/emem.h>
58 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
60 #define SORT_ALPHABETICAL 0
62 #if (GTK_MAJOR_VERSION >= 2)
64 sort_iter_compare_func (GtkTreeModel *model,
69 gint sortcol = GPOINTER_TO_INT(userdata);
73 case SORT_ALPHABETICAL:
76 gtk_tree_model_get(model, a, 0, &name1, -1);
77 gtk_tree_model_get(model, b, 0, &name2, -1);
78 if (name1 == NULL || name2 == NULL)
80 if (name1 == NULL && name2 == NULL)
81 break; /* both equal => ret = 0 */
82 ret = (name1 == NULL) ? -1 : 1;
86 ret = g_ascii_strcasecmp(name1,name2);
93 g_return_val_if_reached(0);
99 #if (GTK_MAJOR_VERSION < 2)
101 typedef struct column_arrows {
103 GtkWidget *ascend_pm;
104 GtkWidget *descend_pm;
108 error_click_column_cb(GtkCList *clist, gint column, gpointer data)
110 column_arrows *col_arrows = (column_arrows *) data;
113 gtk_clist_freeze(clist);
115 for (i = 0; i < 4; i++) {
116 gtk_widget_hide(col_arrows[i].ascend_pm);
117 gtk_widget_hide(col_arrows[i].descend_pm);
120 if (column == clist->sort_column) {
121 if (clist->sort_type == GTK_SORT_ASCENDING) {
122 clist->sort_type = GTK_SORT_DESCENDING;
123 gtk_widget_show(col_arrows[column].descend_pm);
125 clist->sort_type = GTK_SORT_ASCENDING;
126 gtk_widget_show(col_arrows[column].ascend_pm);
130 clist->sort_type = GTK_SORT_DESCENDING;
131 gtk_widget_show(col_arrows[column].descend_pm);
133 clist->sort_type = GTK_SORT_ASCENDING;
134 gtk_widget_show(col_arrows[column].ascend_pm);
136 gtk_clist_set_sort_column(clist, column);
138 gtk_clist_thaw(clist);
140 gtk_clist_sort(clist);
144 error_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
150 const GtkCListRow *row1 = ptr1;
151 const GtkCListRow *row2 = ptr2;
153 text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
154 text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
156 switch(clist->sort_column){
160 return strcmp (text1, text2);
164 sscanf(text1,"%f",&f1);
165 sscanf(text2,"%f",&f2);
166 if(fabs(f1-f2)<0.000005)
172 g_assert_not_reached();
187 static gint find_summary_data(error_equiv_table *err, const expert_info_t *expert_data)
191 /* First time thru values will be 0 */
192 if (err->num_procs==0) {
195 for (i=0;i<err->num_procs;i++) {
196 if (strcmp(err->procedures[i].entries[2], expert_data->summary) == 0) {
203 /* action is encoded as
204 filter_action*256+filter_type
212 5: Colorize Procedure
213 6: Lookup on Internet
223 error_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callback_action)
225 int action, type, selection;
226 error_equiv_table *err = (error_equiv_table *)callback_data;
228 const char *current_filter;
230 #if (GTK_MAJOR_VERSION >= 2)
233 const expert_info_t expert_data;
236 action=(callback_action>>8)&0xff;
237 type=callback_action&0xff;
240 #if (GTK_MAJOR_VERSION < 2)
241 selection=GPOINTER_TO_INT(g_list_nth_data(GTK_CLIST(err->table)->selection, 0));
243 gtk_tree_selection_get_selected(err->select, &model, &iter);
245 gtk_tree_model_get (model, &iter, GROUP_COLUMN, &expert_data.group, -1);
246 gtk_tree_model_get (model, &iter, PROTOCOL_COLUMN, &expert_data.protocol, -1);
247 gtk_tree_model_get (model, &iter, SUMMARY_COLUMN, &expert_data.summary, -1);
249 if (strcmp((char *)expert_data.group, "Packet:")==0) {
250 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You cannot filter or search for packet number. Click on a valid item header.");
254 selection = find_summary_data(err, &expert_data);
257 if(selection>=(int)err->num_procs){
258 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No items are selected");
261 #if (GTK_MAJOR_VERSION < 2)
262 /* translate it back from row index to index in procedures array */
263 selection=GPOINTER_TO_INT(gtk_clist_get_row_data(err->table, selection));
266 current_filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
268 /* Some expert data doesn't pass an expert item. Without this we cannot create a filter */
269 /* But allow for searching of internet for error string */
270 if (action != 6 && action != 7) {
271 if (err->procedures[selection].fvalue_value==NULL) {
272 if (action != 2 && action != 3 && action != 4) {
273 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Wireshark cannot create a filter on this item - %s, try using find instead.", err->procedures[selection].entries[2]);
280 /* if no expert item was passed */
281 if (err->procedures[selection].fvalue_value==NULL) {
282 g_snprintf(str, 255, "%s", err->procedures[selection].entries[2]);
286 /* expert item exists. Use it. */
287 g_snprintf(str, 255, "%s", err->procedures[selection].fvalue_value);
292 /* if no expert item was passed */
293 if (err->procedures[selection].fvalue_value==NULL) {
294 g_snprintf(str, 255, "!%s", err->procedures[selection].entries[2]);
298 /* expert item exists. Use it. */
299 g_snprintf(str, 255, "!(%s)", err->procedures[selection].fvalue_value);
302 /* the remaining cases will only exist if the expert item exists so no need to check */
305 g_snprintf(str, 255, "(%s) && (%s)", current_filter, err->procedures[selection].fvalue_value);
309 g_snprintf(str, 255, "(%s) || (%s)", current_filter, err->procedures[selection].fvalue_value);
312 /* and not selected */
313 g_snprintf(str, 255, "(%s) && !(%s)", current_filter, err->procedures[selection].fvalue_value);
316 /* or not selected */
317 g_snprintf(str, 255, "(%s) || !(%s)", current_filter, err->procedures[selection].fvalue_value);
320 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't find menu type - %u", type);
327 main_filter_packets(&cfile, str, FALSE);
331 gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
335 /* When trying to perform a find without expert item, we must pass
336 * the expert string to the find window. The user might need to modify
337 * the string and click on the text search to locate the packet in question.
338 * So regardless of the type we will just bring up the find window and allow
339 * the user to modify the search criteria and options.
341 find_frame_with_filter(str);
345 /* In the case of find next, if there was no expert item, then most likely the expert
346 * string was modified to locate the text inside the message. So we can't just perform
347 * a find with the expert string or we will not really be performing a find next.
348 * In an effort to allow the user to modify the string and/or continue searching, we
349 * will just present the user with the find window again with the default expert string.
350 * A better aproach would be to attempt in capturing the last find string and utilize this
351 * with a find next/previous. Also a better approach might be to just send a <Ctl-N> keystroke.
353 if (err->procedures[selection].fvalue_value==NULL) {
354 find_frame_with_filter(str);
358 /* We have an expert item so just continue search without find dialog. */
359 find_previous_next_frame_with_filter(str, FALSE);
364 /* In the case of find previous, if there was no expert item, then most likely the expert
365 * string was modified to locate the text inside the message. So we can't just perform
366 * a find with the expert string or we will not really be performing a find previous.
367 * In an effort to allow the user to modify the string and/or continue searching, we
368 * will just present the user with the find window again with the default expert string.
369 * A better aproach would be to attempt in capturing the last find string and utilize this
370 * with a find next/previous. Also a better approach might be to just send a <Ctl-B> keystroke.
372 if (err->procedures[selection].fvalue_value==NULL) {
373 find_frame_with_filter(str);
377 /* We have an expert item so just continue search without find dialog. */
378 find_previous_next_frame_with_filter(str, TRUE);
382 /* colorize procedure */
383 color_display_with_filter(str);
386 /* Lookup expert string on internet. Default search via www.google.com */
387 g_snprintf(str, 255, "http://www.google.com/search?hl=en&q=%s+'%s'", err->procedures[selection].entries[1], err->procedures[selection].entries[2]);
388 browser_open_url(str);
390 #if (GTK_MAJOR_VERSION < 2)
392 /* Goto the first occurance (packet) in the trace */
393 cf_goto_frame(&cfile, err->procedures[selection].packet_num);
397 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't find menu action - %u", action);
403 error_show_popup_menu_cb(void *widg _U_, GdkEvent *event, error_equiv_table *err)
405 GdkEventButton *bevent = (GdkEventButton *)event;
407 if(event->type==GDK_BUTTON_PRESS && bevent->button==3){
408 gtk_menu_popup(GTK_MENU(err->menu), NULL, NULL, NULL, NULL,
409 bevent->button, bevent->time);
415 static GtkItemFactoryEntry error_list_menu_items[] =
418 ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL),
419 ITEM_FACTORY_ENTRY("/Apply as Filter/Selected", NULL,
420 error_select_filter_cb, 0*256+0, NULL, NULL),
421 ITEM_FACTORY_ENTRY("/Apply as Filter/... not Selected", NULL,
422 error_select_filter_cb, 0*256+1, NULL, NULL),
423 ITEM_FACTORY_ENTRY("/Apply as Filter/.. and Selected", NULL,
424 error_select_filter_cb, 0*256+2, NULL, NULL),
425 ITEM_FACTORY_ENTRY("/Apply as Filter/... or Selected", NULL,
426 error_select_filter_cb, 0*256+3, NULL, NULL),
427 ITEM_FACTORY_ENTRY("/Apply as Filter/... and not Selected", NULL,
428 error_select_filter_cb, 0*256+4, NULL, NULL),
429 ITEM_FACTORY_ENTRY("/Apply as Filter/... or not Selected", NULL,
430 error_select_filter_cb, 0*256+5, NULL, NULL),
433 ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL),
434 ITEM_FACTORY_ENTRY("/Prepare a Filter/Selected", NULL,
435 error_select_filter_cb, 1*256+0, NULL, NULL),
436 ITEM_FACTORY_ENTRY("/Prepare a Filter/Not Selected", NULL,
437 error_select_filter_cb, 1*256+1, NULL, NULL),
438 ITEM_FACTORY_ENTRY("/Prepare a Filter/... and Selected", NULL,
439 error_select_filter_cb, 1*256+2, NULL, NULL),
440 ITEM_FACTORY_ENTRY("/Prepare a Filter/... or Selected", NULL,
441 error_select_filter_cb, 1*256+3, NULL, NULL),
442 ITEM_FACTORY_ENTRY("/Prepare a Filter/... and not Selected", NULL,
443 error_select_filter_cb, 1*256+4, NULL, NULL),
444 ITEM_FACTORY_ENTRY("/Prepare a Filter/... or not Selected", NULL,
445 error_select_filter_cb, 1*256+5, NULL, NULL),
448 ITEM_FACTORY_ENTRY("/Find Frame", NULL, NULL, 0, "<Branch>", NULL),
449 ITEM_FACTORY_ENTRY("/Find Frame/Find Frame", NULL, NULL, 0, "<Branch>", NULL),
450 ITEM_FACTORY_ENTRY("/Find Frame/Find Frame/Selected", NULL,
451 error_select_filter_cb, 2*256+0, NULL, NULL),
452 ITEM_FACTORY_ENTRY("/Find Frame/Find Frame/Not Selected", NULL,
453 error_select_filter_cb, 2*256+1, NULL, NULL),
455 ITEM_FACTORY_ENTRY("/Find Frame/Find Next", NULL, NULL, 0, "<Branch>", NULL),
456 ITEM_FACTORY_ENTRY("/Find Frame/Find Next/Selected", NULL,
457 error_select_filter_cb, 3*256+0, NULL, NULL),
458 ITEM_FACTORY_ENTRY("/Find Frame/Find Next/Not Selected", NULL,
459 error_select_filter_cb, 3*256+1, NULL, NULL),
462 ITEM_FACTORY_ENTRY("/Find Frame/Find Previous", NULL, NULL, 0, "<Branch>", NULL),
463 ITEM_FACTORY_ENTRY("/Find Frame/Find Previous/Selected", NULL,
464 error_select_filter_cb, 4*256+0, NULL, NULL),
465 ITEM_FACTORY_ENTRY("/Find Frame/Find Previous/Not Selected", NULL,
466 error_select_filter_cb, 4*256+1, NULL, NULL),
468 /* Colorize Procedure */
469 ITEM_FACTORY_ENTRY("/Colorize Procedure", NULL, NULL, 0, "<Branch>", NULL),
470 ITEM_FACTORY_ENTRY("/Colorize Procedure/Selected", NULL,
471 error_select_filter_cb, 5*256+0, NULL, NULL),
472 ITEM_FACTORY_ENTRY("/Colorize Procedure/Not Selected", NULL,
473 error_select_filter_cb, 5*256+1, NULL, NULL),
475 /* Search Internet */
476 ITEM_FACTORY_ENTRY("/Internet Search for Info Text", NULL,
477 error_select_filter_cb, 6*256+0, NULL, NULL),
478 #if (GTK_MAJOR_VERSION < 2)
479 /* Go to first packet matching this entry */
480 ITEM_FACTORY_ENTRY("/Goto First Occurrence", NULL,
481 error_select_filter_cb, 7*256+0, NULL, NULL),
485 #if (GTK_MAJOR_VERSION >= 2)
487 expert_goto_pkt_cb (GtkTreeSelection *selection, gpointer data _U_)
494 if (gtk_tree_selection_get_selected (selection, &model, &iter))
496 gtk_tree_model_get (model, &iter, PROTOCOL_COLUMN, &pkt, -1);
497 gtk_tree_model_get (model, &iter, GROUP_COLUMN, &grp, -1);
499 if (strcmp(grp, "Packet:")==0) {
500 cf_goto_frame(&cfile, atoi(pkt));
509 error_create_popup_menu(error_equiv_table *err)
511 GtkItemFactory *item_factory;
514 #if (GTK_MAJOR_VERSION >= 2)
515 err->select = gtk_tree_view_get_selection (GTK_TREE_VIEW (err->tree_view));
516 gtk_tree_selection_set_mode (err->select, GTK_SELECTION_SINGLE);
517 g_signal_connect (G_OBJECT (err->select), "changed",
518 G_CALLBACK (expert_goto_pkt_cb),
521 item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
523 gtk_item_factory_create_items_ac(item_factory, sizeof(error_list_menu_items)/sizeof(error_list_menu_items[0]), error_list_menu_items, err, 2);
525 err->menu = gtk_item_factory_get_widget(item_factory, "<main>");
526 #if (GTK_MAJOR_VERSION >= 2)
527 SIGNAL_CONNECT(err->tree_view, "button_press_event", error_show_popup_menu_cb, err);
529 SIGNAL_CONNECT(err->table, "button_press_event", error_show_popup_menu_cb, err);
534 init_error_table(error_equiv_table *err, guint16 num_procs, GtkWidget *vbox)
537 #if (GTK_MAJOR_VERSION < 2)
538 column_arrows *col_arrows;
539 GdkBitmap *ascend_bm, *descend_bm;
540 GdkPixmap *ascend_pm, *descend_pm;
542 GtkWidget *column_lb;
544 const char *default_titles[] = { "Group", "Protocol", "Summary", "Count"};
546 err->scrolled_window=scrolled_window_new(NULL, NULL);
547 gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
549 err->table=(GtkCList *)gtk_clist_new(4);
551 gtk_widget_show(GTK_WIDGET(err->table));
552 gtk_widget_show(err->scrolled_window);
554 col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * 4);
555 win_style = gtk_widget_get_style(err->scrolled_window);
556 ascend_pm = gdk_pixmap_create_from_xpm_d(err->scrolled_window->window,
558 &win_style->bg[GTK_STATE_NORMAL],
559 (gchar **)clist_ascend_xpm);
560 descend_pm = gdk_pixmap_create_from_xpm_d(err->scrolled_window->window,
562 &win_style->bg[GTK_STATE_NORMAL],
563 (gchar **)clist_descend_xpm);
564 for (i = 0; i < 4; i++) {
565 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
566 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
567 column_lb = gtk_label_new(default_titles[i]);
568 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
569 gtk_widget_show(column_lb);
571 col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
572 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
573 col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
574 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
576 gtk_widget_show(col_arrows[i].descend_pm);
578 gtk_clist_set_column_widget(GTK_CLIST(err->table), i, col_arrows[i].table);
579 gtk_widget_show(col_arrows[i].table);
581 gtk_clist_column_titles_show(GTK_CLIST(err->table));
583 gtk_clist_set_compare_func(err->table, error_sort_column);
584 gtk_clist_set_sort_column(err->table, 3);
585 gtk_clist_set_sort_type(err->table, GTK_SORT_DESCENDING);
588 /*XXX instead of this we should probably have some code to
589 dynamically adjust the width of the columns */
590 gtk_clist_set_column_width(err->table, 0, 75);
591 gtk_clist_set_column_width(err->table, 1, 75);
592 gtk_clist_set_column_width(err->table, 2, 400);
593 gtk_clist_set_column_width(err->table, 3, 50);
596 gtk_clist_set_shadow_type(err->table, GTK_SHADOW_IN);
597 gtk_clist_column_titles_show(err->table);
598 gtk_container_add(GTK_CONTAINER(err->scrolled_window), (GtkWidget *)err->table);
600 SIGNAL_CONNECT(err->table, "click-column", error_click_column_cb, col_arrows);
602 gtk_widget_show(GTK_WIDGET(err->table));
606 GtkTreeViewColumn *column;
607 GtkCellRenderer *renderer;
608 GtkTreeSortable *sortable;
610 /* Create the store */
611 store = gtk_tree_store_new (4, /* Total number of columns */
612 G_TYPE_STRING, /* Group */
613 G_TYPE_STRING, /* Protocol */
614 G_TYPE_STRING, /* Summary */
615 G_TYPE_INT); /* Count */
618 tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
619 err->tree_view = GTK_TREE_VIEW(tree);
620 sortable = GTK_TREE_SORTABLE(store);
622 /* Setup the sortable columns */
623 gtk_tree_sortable_set_sort_func(sortable, SORT_ALPHABETICAL, sort_iter_compare_func, GINT_TO_POINTER(SORT_ALPHABETICAL), NULL);
624 gtk_tree_sortable_set_sort_column_id(sortable, SORT_ALPHABETICAL, GTK_SORT_ASCENDING);
625 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree), FALSE);
627 /* The view now holds a reference. We can get rid of our own reference */
628 g_object_unref (G_OBJECT (store));
630 /* Create a cell render */
631 renderer = gtk_cell_renderer_text_new ();
633 /* Create the first column, associating the "text" attribute of the
634 * cell_renderer to the first column of the model */
635 column = gtk_tree_view_column_new_with_attributes ("Group", renderer, "text", GROUP_COLUMN, NULL);
636 gtk_tree_view_column_set_sort_column_id(column, 0);
637 gtk_tree_view_column_set_resizable(column, TRUE);
638 /* Add the column to the view. */
639 gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
641 /* Second column.. Protocol. */
642 renderer = gtk_cell_renderer_text_new ();
643 column = gtk_tree_view_column_new_with_attributes ("Protocol", renderer, "text", PROTOCOL_COLUMN, NULL);
644 gtk_tree_view_column_set_sort_column_id(column, 1);
645 gtk_tree_view_column_set_resizable(column, TRUE);
646 gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
648 /* Third column.. Summary. */
649 renderer = gtk_cell_renderer_text_new ();
650 column = gtk_tree_view_column_new_with_attributes ("Summary", renderer, "text", SUMMARY_COLUMN, NULL);
651 gtk_tree_view_column_set_sort_column_id(column, 2);
652 gtk_tree_view_column_set_resizable(column, TRUE);
653 gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
655 /* Last column.. Count. */
656 column = gtk_tree_view_column_new_with_attributes ("Count", renderer, "text", COUNT_COLUMN, NULL);
657 gtk_tree_view_column_set_sort_column_id(column, 3);
658 gtk_tree_view_column_set_resizable(column, TRUE);
659 gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
661 err->scrolled_window=scrolled_window_new(NULL, NULL);
663 gtk_container_add(GTK_CONTAINER(err->scrolled_window), GTK_WIDGET (err->tree_view));
665 gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
667 gtk_tree_view_set_search_column (err->tree_view, SUMMARY_COLUMN); /* Allow searching the summary */
668 gtk_tree_view_set_reorderable (err->tree_view, TRUE); /* Allow user to reorder data with drag n drop */
670 /* Now enable the sorting of each column */
671 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(err->tree_view), TRUE);
672 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(err->tree_view), TRUE);
675 gtk_widget_show(err->scrolled_window);
677 err->num_procs=num_procs;
678 err->procedures=g_malloc(sizeof(error_procedure_t)*(num_procs+1));
679 for(i=0;i<num_procs;i++){
681 err->procedures[i].entries[j]=NULL; /* reset all values */
685 /* create popup menu for this table */
686 error_create_popup_menu(err);
690 init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data)
692 guint16 old_num_procs=err->num_procs;
696 #if (GTK_MAJOR_VERSION >= 2)
700 /* we have discovered a new procedure. Extend the table accordingly */
701 row = find_summary_data(err, expert_data);
703 /* First time we have seen this event so initialize memory table */
704 #if (GTK_MAJOR_VERSION < 2)
708 err->procedures=g_realloc(err->procedures, (sizeof(error_procedure_t)*(old_num_procs+1)));
709 err->procedures[err->num_procs].count=0;
712 err->procedures[err->num_procs].entries[j]=NULL;
714 err->procedures[err->num_procs].packet_num = (guint32)expert_data->packet_num; /* First packet num */
715 err->procedures[err->num_procs].entries[0]=(char *)g_strdup(val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)")); /* Group */
716 err->procedures[err->num_procs].entries[1]=(char *)g_strdup(expert_data->protocol); /* Protocol */
717 err->procedures[err->num_procs].entries[2]=(char *)g_strdup(expert_data->summary); /* Summary */
718 err->procedures[err->num_procs].entries[3]=(char *)g_strdup_printf("%d", err->procedures[row].count); /* Count */
719 err->procedures[err->num_procs].fvalue_value = NULL;
721 /* Store the updated count of events */
722 err->num_procs = old_num_procs;
724 row = old_num_procs; /* Number of expert events since this is a new event */
725 err->procedures=g_realloc(err->procedures, (sizeof(error_procedure_t)*(old_num_procs+1)));
726 err->procedures[row].count=0; /* count of events for this item */
727 err->procedures[row].fvalue_value = NULL; /* Filter string value */
729 err->procedures[row].entries[j]=NULL;
732 /* Create the item in our memory table */
733 err->procedures[row].entries[0]=(char *)g_strdup(val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)")); /* Group */
734 err->procedures[row].entries[1]=(char *)g_strdup(expert_data->protocol); /* Protocol */
735 err->procedures[row].entries[2]=(char *)g_strdup(expert_data->summary); /* Summary */
737 /* Create a new item in our tree view */
738 store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view)); /* Get store */
739 gtk_tree_store_append (store, &err->procedures[row].iter, NULL); /* Acquire an iterator */
741 gtk_tree_store_set (store, &err->procedures[row].iter,
742 GROUP_COLUMN, (char *)g_strdup(val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)")),
743 PROTOCOL_COLUMN, (char *)g_strdup(expert_data->protocol),
744 SUMMARY_COLUMN, (char *)g_strdup(expert_data->summary), -1);
746 /* If an expert item was passed then build the filter string */
747 if (expert_data->pitem) {
750 filter = proto_construct_match_selected_string(expert_data->pitem->finfo, NULL);
752 err->procedures[row].fvalue_value = g_strdup(filter);
754 /* Store the updated count of events */
755 err->num_procs = ++old_num_procs;
758 /* Update our memory table with event data */
759 err->procedures[row].count++; /* increment the count of events for this item */
761 /* Store the updated count for this event item */
762 err->procedures[row].entries[3]=(char *)g_strdup_printf("%d", err->procedures[row].count); /* Count */
764 /* Update the tree with new count for this event */
765 store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
766 gtk_tree_store_set(store, &err->procedures[row].iter, COUNT_COLUMN, err->procedures[row].count, -1);
771 add_error_table_data(error_equiv_table *err, const expert_info_t *expert_data)
773 error_procedure_t *errp;
775 #if (GTK_MAJOR_VERSION < 2)
779 GtkTreeIter new_iter;
782 index = find_summary_data(err,expert_data);
784 /* We should never encounter a condition where we cannot find the expert data. If
785 * we do then we will just abort.
788 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not find expert data. Aborting");
791 errp=&err->procedures[index];
793 #if (GTK_MAJOR_VERSION < 2)
795 row=gtk_clist_append(err->table, err->procedures[index].entries);
796 gtk_clist_set_row_data(err->table, row, (gpointer) index);
799 err->procedures[index].entries[3] = (char *)g_strdup_printf("%d", errp->count);
802 store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
804 gtk_tree_store_append(store, &new_iter, &errp->iter);
806 gtk_tree_store_set(store, &new_iter,
807 GROUP_COLUMN, "Packet:",
808 PROTOCOL_COLUMN, (char *)g_strdup_printf("%d", expert_data->packet_num),
814 #if (GTK_MAJOR_VERSION < 2)
816 draw_error_table_data(error_equiv_table *err)
821 for(i=0;i<err->num_procs;i++){
822 /* ignore procedures with no calls (they don't have CList rows) */
823 if(err->procedures[i].count==0){
827 j=gtk_clist_find_row_from_data(err->table, (gpointer)i);
828 strp=g_strdup_printf("%d", err->procedures[i].count);
829 gtk_clist_set_text(err->table, j, 3, strp);
830 err->procedures[i].entries[3]=(char *)strp;
834 gtk_clist_sort(err->table);
839 reset_error_table_data(error_equiv_table *err)
842 #if (GTK_MAJOR_VERSION >= 2)
846 for(i=0;i<err->num_procs;i++){
847 err->procedures[i].entries[0] = NULL;
848 err->procedures[i].entries[1] = NULL;
849 err->procedures[i].entries[2] = NULL;
850 err->procedures[i].entries[3] = NULL;
851 #if (GTK_MAJOR_VERSION < 2)
852 err->procedures[i].packet_num=0;
854 err->procedures[i].count=0;
859 #if (GTK_MAJOR_VERSION < 2)
860 gtk_clist_clear(err->table);
862 store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
863 gtk_tree_store_clear(store);
869 free_error_table_data(error_equiv_table *err)
873 for(i=0;i<err->num_procs;i++){
875 if(err->procedures[i].entries[j]){
876 err->procedures[i].entries[j]=NULL;
878 err->procedures[i].fvalue_value=NULL;
880 #if (GTK_MAJOR_VERSION < 2)
881 err->procedures[i].packet_num=0;
883 err->procedures[i].count=0;
887 err->procedures=NULL;