2005-11-25 23:42:52 +00:00
|
|
|
/* expert_comp_table.c
|
|
|
|
* expert_comp_table 2005 Greg Morris
|
|
|
|
* Portions copied from service_response_time_table.c by Ronnie Sahlberg
|
|
|
|
* Helper routines common to all composite expert statistics
|
|
|
|
* tap.
|
|
|
|
*
|
|
|
|
* $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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.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"
|
2009-08-19 18:37:13 +00:00
|
|
|
#include "epan/strutil.h"
|
|
|
|
|
2008-04-13 01:54:20 +00:00
|
|
|
#include <epan/expert.h>
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "../simple_dialog.h"
|
|
|
|
#include "../globals.h"
|
|
|
|
#include "../color.h"
|
|
|
|
|
|
|
|
#include "gtk/expert_comp_table.h"
|
2008-05-17 22:59:52 +00:00
|
|
|
#include "gtk/filter_utils.h"
|
2005-11-25 23:42:52 +00:00
|
|
|
#include "gtk/find_dlg.h"
|
|
|
|
#include "gtk/color_dlg.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "gtk/main.h"
|
|
|
|
#include "gtk/gui_utils.h"
|
|
|
|
#include "gtk/gtkglobals.h"
|
|
|
|
#include "gtk/webbrowser.h"
|
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
const char *packet = "Packet:";
|
2009-08-26 17:26:26 +00:00
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GROUP_COLUMN,
|
|
|
|
PROTOCOL_COLUMN,
|
|
|
|
SUMMARY_COLUMN,
|
|
|
|
COUNT_COLUMN,
|
|
|
|
N_COLUMNS
|
|
|
|
};
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
static void
|
|
|
|
proto_data_func (GtkTreeViewColumn *column _U_,
|
|
|
|
GtkCellRenderer *renderer,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gchar *str = NULL;
|
|
|
|
gchar *grp = NULL; /* type pointer, don't free */
|
|
|
|
|
|
|
|
/* The col to get data from is in userdata */
|
|
|
|
gint data_column = GPOINTER_TO_INT(user_data);
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, iter, data_column, &str, -1);
|
|
|
|
gtk_tree_model_get(model, iter, GROUP_COLUMN, &grp, -1);
|
|
|
|
/* XXX should we check that str is non NULL and print a warning or do assert? */
|
|
|
|
|
|
|
|
g_object_set(renderer, "text", str, NULL);
|
|
|
|
if (grp == packet) {
|
|
|
|
/* it's a number right align */
|
|
|
|
g_object_set(renderer, "xalign", 1.0, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_object_set(renderer, "xalign", 0.0, NULL);
|
|
|
|
}
|
|
|
|
g_free(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
proto_sort_func(GtkTreeModel *model,
|
|
|
|
GtkTreeIter *a,
|
|
|
|
GtkTreeIter *b,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gchar *str_a = NULL;
|
|
|
|
gchar *str_b = NULL;
|
|
|
|
gchar *grp = NULL; /* type pointer, don't free */
|
|
|
|
gint ret = 0;
|
|
|
|
|
|
|
|
/* The col to get data from is in userdata */
|
|
|
|
gint data_column = GPOINTER_TO_INT(user_data);
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, a, data_column, &str_a, -1);
|
|
|
|
gtk_tree_model_get(model, b, data_column, &str_b, -1);
|
|
|
|
gtk_tree_model_get(model, a, GROUP_COLUMN, &grp, -1);
|
|
|
|
|
|
|
|
if (str_a == str_b) {
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
else if (str_a == NULL || str_b == NULL) {
|
|
|
|
ret = (str_a == NULL) ? -1 : 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (grp == packet) {
|
2009-09-29 19:29:03 +00:00
|
|
|
gint int_a = atoi(str_a);
|
|
|
|
gint int_b = atoi(str_b);
|
|
|
|
if (int_a == int_b)
|
2009-09-02 05:48:38 +00:00
|
|
|
ret = 0;
|
2009-09-29 19:29:03 +00:00
|
|
|
else if (int_a < int_b)
|
2009-09-02 05:48:38 +00:00
|
|
|
ret = -1;
|
|
|
|
else
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = g_ascii_strcasecmp(str_a,str_b);
|
|
|
|
}
|
|
|
|
g_free(str_a);
|
|
|
|
g_free(str_b);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
static gint find_summary_data(error_equiv_table *err, const expert_info_t *expert_data)
|
2005-11-25 23:42:52 +00:00
|
|
|
{
|
2009-08-19 18:37:13 +00:00
|
|
|
guint i;
|
|
|
|
error_procedure_t *procedure;
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* First time thru values will be 0 */
|
|
|
|
if (err->num_procs==0) {
|
|
|
|
return -1;
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2006-05-04 15:36:41 +00:00
|
|
|
for (i=0;i<err->num_procs;i++) {
|
2009-08-19 18:37:13 +00:00
|
|
|
procedure = &g_array_index(err->procs_array, error_procedure_t, i);
|
2009-08-26 17:26:26 +00:00
|
|
|
if (strcmp(procedure->entries[0], expert_data->protocol) == 0 &&
|
|
|
|
strcmp(procedure->entries[1], expert_data->summary) == 0) {
|
2006-05-04 15:36:41 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
error_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callback_action)
|
|
|
|
{
|
2007-12-03 21:55:44 +00:00
|
|
|
int action, type, selection;
|
|
|
|
error_equiv_table *err = (error_equiv_table *)callback_data;
|
2009-08-19 18:37:13 +00:00
|
|
|
char str[512];
|
2007-12-03 21:55:44 +00:00
|
|
|
const char *current_filter;
|
2009-08-19 18:37:13 +00:00
|
|
|
error_procedure_t *procedure;
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
2009-05-19 15:53:26 +00:00
|
|
|
expert_info_t expert_data;
|
|
|
|
gchar *grp;
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2007-12-04 08:27:48 +00:00
|
|
|
action=FILTER_ACTION(callback_action);
|
|
|
|
type=FILTER_ACTYPE(callback_action);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_selection_get_selected(err->select, &model, &iter);
|
|
|
|
|
2009-05-19 15:53:26 +00:00
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
GROUP_COLUMN, &grp,
|
|
|
|
PROTOCOL_COLUMN, &expert_data.protocol,
|
|
|
|
SUMMARY_COLUMN, &expert_data.summary,
|
|
|
|
-1);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
if (strcmp(grp, packet)==0) {
|
2007-12-03 21:55:44 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You cannot filter or search for packet number. Click on a valid item header.");
|
2009-05-19 15:53:26 +00:00
|
|
|
g_free(expert_data.summary);
|
2006-03-19 20:26:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2009-05-19 15:53:26 +00:00
|
|
|
/* XXX: find_summary_data doesn't (currently) reference expert_data.group. */
|
|
|
|
/* If "group" is required, then the message from GROUP_COLUMN will need */
|
|
|
|
/* to be translated to the group number (or the actual group number */
|
|
|
|
/* will also need to be stored in the TreeModel). */
|
2006-05-04 15:36:41 +00:00
|
|
|
selection = find_summary_data(err, &expert_data);
|
2009-09-13 16:03:46 +00:00
|
|
|
/* g_free(expert_data.protocol); - const */
|
2009-05-19 15:53:26 +00:00
|
|
|
g_free(expert_data.summary);
|
|
|
|
|
2007-12-03 21:55:44 +00:00
|
|
|
if(selection>=(int)err->num_procs){
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No items are selected");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
current_filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Some expert data doesn't pass an expert item. Without this we cannot create a filter */
|
|
|
|
/* But allow for searching of internet for error string */
|
2009-08-19 18:37:13 +00:00
|
|
|
procedure = &g_array_index(err->procs_array, error_procedure_t, selection);
|
|
|
|
|
|
|
|
/* FIXME what is 7 ?*/
|
|
|
|
if (action != ACTION_WEB_LOOKUP && action != 7) {
|
|
|
|
char *msg;
|
|
|
|
if (0 /*procedure->fvalue_value==NULL*/) {
|
|
|
|
if (action != ACTION_FIND_FRAME && action != ACTION_FIND_NEXT && action != ACTION_FIND_PREVIOUS) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Wireshark cannot create a filter on this item - %s, try using find instead.",
|
2009-08-26 17:26:26 +00:00
|
|
|
procedure->entries[1]);
|
2005-11-25 23:42:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2009-08-26 17:26:26 +00:00
|
|
|
msg = g_malloc(escape_string_len(procedure->entries[1]));
|
|
|
|
escape_string(msg, procedure->entries[1]);
|
2007-12-03 21:55:44 +00:00
|
|
|
switch(type){
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTYPE_SELECTED:
|
2005-11-25 23:42:52 +00:00
|
|
|
/* if no expert item was passed */
|
2009-08-19 18:37:13 +00:00
|
|
|
if (procedure->fvalue_value==NULL) {
|
|
|
|
g_snprintf(str, sizeof(str), "expert.message==%s", msg);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* expert item exists. Use it. */
|
2009-08-19 18:37:13 +00:00
|
|
|
g_strlcpy(str, procedure->fvalue_value, sizeof(str));
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTYPE_NOT_SELECTED:
|
2005-11-25 23:42:52 +00:00
|
|
|
/* if no expert item was passed */
|
2009-08-19 18:37:13 +00:00
|
|
|
if (procedure->fvalue_value==NULL) {
|
|
|
|
g_snprintf(str, sizeof(str), "!(expert.message==%s)", msg);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* expert item exists. Use it. */
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "!(%s)", procedure->fvalue_value);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2005-11-25 23:42:52 +00:00
|
|
|
/* the remaining cases will only exist if the expert item exists so no need to check */
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTYPE_AND_SELECTED:
|
2008-05-17 22:59:52 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "expert.message==%s", msg);
|
2008-05-17 22:59:52 +00:00
|
|
|
else
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "(%s) && (expert.message==%s)", current_filter, msg);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTYPE_OR_SELECTED:
|
2008-05-17 22:59:52 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "expert.message==%s", msg);
|
2008-05-17 22:59:52 +00:00
|
|
|
else
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "(%s) || (expert.message==%s)", current_filter, msg);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTYPE_AND_NOT_SELECTED:
|
2008-05-17 22:59:52 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "!(expert.message==%s)", msg);
|
2008-05-17 22:59:52 +00:00
|
|
|
else
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "(%s) && !(expert.message==%s)", current_filter, msg);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTYPE_OR_NOT_SELECTED:
|
2008-05-17 22:59:52 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "!(expert.message==%s)", msg);
|
2008-05-17 22:59:52 +00:00
|
|
|
else
|
2009-08-19 18:37:13 +00:00
|
|
|
g_snprintf(str, sizeof(str), "(%s) || !(expert.message==%s)", current_filter, msg);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2005-11-25 23:42:52 +00:00
|
|
|
default:
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't find menu type - %u", type);
|
2007-12-03 21:55:44 +00:00
|
|
|
}
|
2009-08-19 18:37:13 +00:00
|
|
|
g_free(msg);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
2007-12-03 21:55:44 +00:00
|
|
|
switch(action){
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_MATCH:
|
2007-12-03 21:55:44 +00:00
|
|
|
main_filter_packets(&cfile, str, FALSE);
|
2005-11-25 23:42:52 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_PREPARE:
|
2005-11-25 23:42:52 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_FIND_FRAME:
|
2005-11-25 23:42:52 +00:00
|
|
|
/* When trying to perform a find without expert item, we must pass
|
|
|
|
* the expert string to the find window. The user might need to modify
|
|
|
|
* the string and click on the text search to locate the packet in question.
|
|
|
|
* So regardless of the type we will just bring up the find window and allow
|
|
|
|
* the user to modify the search criteria and options.
|
|
|
|
*/
|
2007-12-04 07:50:44 +00:00
|
|
|
find_frame_with_filter(str);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_FIND_NEXT:
|
2005-11-25 23:42:52 +00:00
|
|
|
/* In the case of find next, if there was no expert item, then most likely the expert
|
|
|
|
* string was modified to locate the text inside the message. So we can't just perform
|
|
|
|
* a find with the expert string or we will not really be performing a find next.
|
|
|
|
* In an effort to allow the user to modify the string and/or continue searching, we
|
|
|
|
* will just present the user with the find window again with the default expert string.
|
|
|
|
* A better aproach would be to attempt in capturing the last find string and utilize this
|
|
|
|
* with a find next/previous. Also a better approach might be to just send a <Ctl-N> keystroke.
|
|
|
|
*/
|
2009-08-19 18:37:13 +00:00
|
|
|
if (procedure->fvalue_value==NULL) {
|
2005-11-25 23:42:52 +00:00
|
|
|
find_frame_with_filter(str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We have an expert item so just continue search without find dialog. */
|
2007-12-03 21:55:44 +00:00
|
|
|
find_previous_next_frame_with_filter(str, FALSE);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_FIND_PREVIOUS:
|
2005-11-25 23:42:52 +00:00
|
|
|
/* In the case of find previous, if there was no expert item, then most likely the expert
|
|
|
|
* string was modified to locate the text inside the message. So we can't just perform
|
|
|
|
* a find with the expert string or we will not really be performing a find previous.
|
|
|
|
* In an effort to allow the user to modify the string and/or continue searching, we
|
|
|
|
* will just present the user with the find window again with the default expert string.
|
|
|
|
* A better aproach would be to attempt in capturing the last find string and utilize this
|
|
|
|
* with a find next/previous. Also a better approach might be to just send a <Ctl-B> keystroke.
|
|
|
|
*/
|
2009-08-19 18:37:13 +00:00
|
|
|
if (procedure->fvalue_value==NULL) {
|
2005-11-25 23:42:52 +00:00
|
|
|
find_frame_with_filter(str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We have an expert item so just continue search without find dialog. */
|
2007-12-03 21:55:44 +00:00
|
|
|
find_previous_next_frame_with_filter(str, TRUE);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_COLORIZE:
|
2007-12-03 21:55:44 +00:00
|
|
|
color_display_with_filter(str);
|
|
|
|
break;
|
2007-12-04 08:27:48 +00:00
|
|
|
case ACTION_WEB_LOOKUP:
|
2007-12-03 21:55:44 +00:00
|
|
|
/* Lookup expert string on internet. Default search via www.google.com */
|
2009-08-26 17:26:26 +00:00
|
|
|
g_snprintf(str, sizeof(str), "http://www.google.com/search?hl=en&q=%s+'%s'", procedure->entries[0], procedure->entries[1]);
|
2005-11-25 23:42:52 +00:00
|
|
|
browser_open_url(str);
|
2007-12-03 21:55:44 +00:00
|
|
|
break;
|
2005-11-25 23:42:52 +00:00
|
|
|
default:
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't find menu action - %u", action);
|
2007-12-03 21:55:44 +00:00
|
|
|
}
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
error_show_popup_menu_cb(void *widg _U_, GdkEvent *event, error_equiv_table *err)
|
|
|
|
{
|
|
|
|
GdkEventButton *bevent = (GdkEventButton *)event;
|
|
|
|
|
|
|
|
if(event->type==GDK_BUTTON_PRESS && bevent->button==3){
|
|
|
|
gtk_menu_popup(GTK_MENU(err->menu), NULL, NULL, NULL, NULL,
|
|
|
|
bevent->button, bevent->time);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkItemFactoryEntry error_list_menu_items[] =
|
|
|
|
{
|
|
|
|
/* Match */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Apply as Filter/Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_MATCH(ACTYPE_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Apply as Filter/... not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_MATCH(ACTYPE_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Apply as Filter/.. and Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_MATCH(ACTYPE_AND_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Apply as Filter/... or Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_MATCH(ACTYPE_OR_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Apply as Filter/... and not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_MATCH(ACTYPE_AND_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Apply as Filter/... or not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_MATCH(ACTYPE_OR_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Prepare */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Prepare a Filter/Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_PREPARE(ACTYPE_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Prepare a Filter/Not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_PREPARE(ACTYPE_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Prepare a Filter/... and Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_PREPARE(ACTYPE_AND_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Prepare a Filter/... or Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_PREPARE(ACTYPE_OR_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Prepare a Filter/... and not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_PREPARE(ACTYPE_AND_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Prepare a Filter/... or not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_PREPARE(ACTYPE_OR_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Find Frame */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Find Frame", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Find Frame/Find Frame", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Find Frame/Find Frame/Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_FIND_FRAME(ACTYPE_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Find Frame/Find Frame/Not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_FIND_FRAME(ACTYPE_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
2005-11-25 23:42:52 +00:00
|
|
|
/* Find Next */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Find Frame/Find Next", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Find Frame/Find Next/Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_FIND_NEXT(ACTYPE_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Find Frame/Find Next/Not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_FIND_NEXT(ACTYPE_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Find Previous */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Find Frame/Find Previous", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Find Frame/Find Previous/Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_FIND_PREVIOUS(ACTYPE_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Find Frame/Find Previous/Not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_FIND_PREVIOUS(ACTYPE_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Colorize Procedure */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Colorize Procedure", NULL, NULL, 0, "<Branch>", NULL,},
|
|
|
|
{"/Colorize Procedure/Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_COLORIZE(ACTYPE_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
|
|
|
{"/Colorize Procedure/Not Selected", NULL,
|
2008-05-17 22:59:52 +00:00
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_COLORIZE(ACTYPE_NOT_SELECTED, 0),
|
2008-04-11 23:12:24 +00:00
|
|
|
NULL, NULL,},
|
2005-11-25 23:42:52 +00:00
|
|
|
|
|
|
|
/* Search Internet */
|
2008-04-11 23:12:24 +00:00
|
|
|
{"/Internet Search for Info Text", NULL,
|
|
|
|
GTK_MENU_FUNC(error_select_filter_cb), CALLBACK_WEB_LOOKUP, NULL, NULL,}
|
2005-11-25 23:42:52 +00:00
|
|
|
};
|
|
|
|
|
2009-10-05 08:32:59 +00:00
|
|
|
#if 0
|
|
|
|
/* Prepare to change GtkItemFactory to GtkUIManager */
|
|
|
|
static void
|
|
|
|
apply_as_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
apply_as_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
apply_as_and_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
apply_as_or_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
apply_as_and_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
apply_as_or_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
prep_as_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
prep_as_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
prep_as_and_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
prep_as_or_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
prep_as_and_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
prep_as_or_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
find_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
find_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
find_prev_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
find_prev_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
find_next_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
find_next_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
color_next_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
color_next_not_selected_cb(GtkAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static const char *ui_description =
|
|
|
|
"<ui>"
|
|
|
|
" <popup name='MainMenu'>"
|
|
|
|
" <menu action='/Apply as Filter'>"
|
|
|
|
" <menuitem action='/Apply as Filter/Selected'/>"
|
|
|
|
" <menuitem action='/Apply as Filter/... not Selected'/>"
|
|
|
|
" <menuitem action='/Apply as Filter/... and Selected'/>"
|
|
|
|
" <menuitem action='/Apply as Filter/... or Selected'/>"
|
|
|
|
" <menuitem action='/Apply as Filter/... and not Selected'/>"
|
|
|
|
" <menuitem action='/Apply as Filter/... or not Selected'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='/Prepare a Filter'>"
|
|
|
|
" <menuitem action='/Prepare a Filter/Selected'/>"
|
|
|
|
" <menuitem action='/Prepare a Filter/... not Selected'/>"
|
|
|
|
" <menuitem action='/Prepare a Filter/... and Selected'/>"
|
|
|
|
" <menuitem action='/Prepare a Filter/... or Selected'/>"
|
|
|
|
" <menuitem action='/Prepare a Filter/... and not Selected'/>"
|
|
|
|
" <menuitem action='/Prepare a Filter/... or not Selected'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='/Find Frame'>"
|
|
|
|
" <menu action='/Find Frame/Find Frame'>"
|
|
|
|
" <menuitem action='/Find Frame/Selected'/>"
|
|
|
|
" <menuitem action='/Find Frame/Not Selected'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='/Find Frame/Find Next'>"
|
|
|
|
" <menuitem action='/Find Next/Selected'/>"
|
|
|
|
" <menuitem action='/Find Next/Not Selected'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='/Find Frame/Find Previous'>"
|
|
|
|
" <menuitem action='/Find Previous/Selected'/>"
|
|
|
|
" <menuitem action='/Find Previous/Not Selected'/>"
|
|
|
|
" </menu>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='/Colorize Procedure'>"
|
|
|
|
" <menuitem action='/Colorize Procedure/Selected'/>"
|
|
|
|
" <menuitem action='/Colorize Procedure/Not Selected'/>"
|
|
|
|
" </menu>"
|
|
|
|
" </popup>"
|
|
|
|
"</ui>";
|
|
|
|
|
|
|
|
|
|
|
|
/* Normal items */
|
|
|
|
static const GtkActionEntry entries[] = {
|
|
|
|
{ "/Apply as Filter", NULL, "Apply as Filter" },
|
|
|
|
{ "/Prepare a Filter", NULL, "Prepare a Filter" },
|
|
|
|
{ "/Find Frame", NULL, "Find Frame" },
|
|
|
|
{ "/Find Frame/Find Frame", NULL, "Find Frame" },
|
|
|
|
{ "/Find Frame/Find Next", NULL, "Find Next" },
|
|
|
|
{ "/Find Frame/Find Previous", NULL, "Find Previous" },
|
|
|
|
{ "/Colorize Procedure", NULL, "Colorize Procedure" },
|
|
|
|
{ "/Apply as Filter/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(apply_as_selected_cb) },
|
|
|
|
{ "/Apply as Filter/... not Selected", NULL, "... not Selected", NULL, "... not Selected", G_CALLBACK(apply_as_not_selected_cb) },
|
|
|
|
{ "/Apply as Filter/... and Selected", NULL, "... and Selected", NULL, "... and Selected", G_CALLBACK(apply_as_and_selected_cb) },
|
|
|
|
{ "/Apply as Filter/... or Selected", NULL, "... or Selected", NULL, "... or Selected", G_CALLBACK(apply_as_or_selected_cb) },
|
|
|
|
{ "/Apply as Filter/... and not Selected", NULL, "... and not Selected", NULL, "... and not Selected", G_CALLBACK(apply_as_and_not_selected_cb) },
|
|
|
|
{ "/Apply as Filter/... or not Selected", NULL, "... or not Selected", NULL, "... or not Selected", G_CALLBACK(apply_as_or_not_selected_cb) },
|
|
|
|
{ "/Prepare a Filter/Selected", NULL, "Selected", NULL, "selcted", G_CALLBACK(prep_as_selected_cb) },
|
|
|
|
{ "/Prepare a Filter/... not Selected", NULL, "... not Selected", NULL, "... not Selected", G_CALLBACK(prep_as_not_selected_cb) },
|
|
|
|
{ "/Prepare a Filter/... and Selected", NULL, "... and Selected", NULL, "... and Selected", G_CALLBACK(prep_as_and_selected_cb) },
|
|
|
|
{ "/Prepare a Filter/... or Selected", NULL, "... or Selected", NULL, "... or Selected", G_CALLBACK(prep_as_or_selected_cb) },
|
|
|
|
{ "/Prepare a Filter/... and not Selected", NULL, "... and not Selected", NULL, "... and not Selected", G_CALLBACK(prep_as_and_not_selected_cb) },
|
|
|
|
{ "/Prepare a Filter/... or not Selected", NULL, "... or not Selected", NULL, "... or not Selected", G_CALLBACK(prep_as_or_not_selected_cb) },
|
|
|
|
{ "/Find Frame/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_selected_cb) },
|
|
|
|
{ "/Find Frame/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_not_selected_cb) },
|
|
|
|
{ "/Find Previous/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_prev_selected_cb) },
|
|
|
|
{ "/Find Previous/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_prev_not_selected_cb) },
|
|
|
|
{ "/Find Next/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_next_selected_cb) },
|
|
|
|
{ "/Find Next/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_next_not_selected_cb) },
|
|
|
|
{ "/Colorize Procedure/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(color_next_selected_cb) },
|
|
|
|
{ "/Colorize Procedure/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(color_next_not_selected_cb) },
|
|
|
|
};
|
|
|
|
#endif
|
2006-05-04 15:36:41 +00:00
|
|
|
static void
|
2007-02-19 15:30:06 +00:00
|
|
|
expert_goto_pkt_cb (GtkTreeSelection *selection, gpointer data _U_)
|
2006-05-04 15:36:41 +00:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
gchar *pkt;
|
|
|
|
gchar *grp;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
|
|
|
{
|
2009-05-19 15:53:26 +00:00
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
PROTOCOL_COLUMN, &pkt,
|
|
|
|
GROUP_COLUMN, &grp,
|
|
|
|
-1);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
if (strcmp(grp, packet)==0) {
|
2006-05-04 15:36:41 +00:00
|
|
|
cf_goto_frame(&cfile, atoi(pkt));
|
|
|
|
}
|
|
|
|
g_free (pkt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-25 23:42:52 +00:00
|
|
|
static void
|
|
|
|
error_create_popup_menu(error_equiv_table *err)
|
|
|
|
{
|
2007-12-04 07:53:23 +00:00
|
|
|
GtkItemFactory *item_factory;
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
err->select = gtk_tree_view_get_selection (GTK_TREE_VIEW (err->tree_view));
|
|
|
|
gtk_tree_selection_set_mode (err->select, GTK_SELECTION_SINGLE);
|
|
|
|
g_signal_connect (G_OBJECT (err->select), "changed",
|
|
|
|
G_CALLBACK (expert_goto_pkt_cb),
|
|
|
|
err);
|
2007-12-04 07:53:23 +00:00
|
|
|
item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2007-12-04 07:53:23 +00:00
|
|
|
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);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2007-12-04 07:53:23 +00:00
|
|
|
err->menu = gtk_item_factory_get_widget(item_factory, "<main>");
|
2008-04-11 21:39:16 +00:00
|
|
|
g_signal_connect(err->tree_view, "button_press_event", G_CALLBACK(error_show_popup_menu_cb), err);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-19 18:37:13 +00:00
|
|
|
init_error_table(error_equiv_table *err, guint num_procs, GtkWidget *vbox)
|
2005-11-25 23:42:52 +00:00
|
|
|
{
|
2006-05-04 15:36:41 +00:00
|
|
|
GtkTreeStore *store;
|
|
|
|
GtkWidget *tree;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeSortable *sortable;
|
|
|
|
|
|
|
|
/* Create the store */
|
|
|
|
store = gtk_tree_store_new (4, /* Total number of columns */
|
2009-08-19 18:37:13 +00:00
|
|
|
G_TYPE_POINTER, /* Group */
|
2006-05-04 15:36:41 +00:00
|
|
|
G_TYPE_STRING, /* Protocol */
|
|
|
|
G_TYPE_STRING, /* Summary */
|
2007-04-20 23:10:03 +00:00
|
|
|
G_TYPE_INT); /* Count */
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* Create a view */
|
|
|
|
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
|
|
|
err->tree_view = GTK_TREE_VIEW(tree);
|
|
|
|
sortable = GTK_TREE_SORTABLE(store);
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
|
|
|
/* Speed up the list display */
|
2009-09-02 05:48:38 +00:00
|
|
|
gtk_tree_view_set_fixed_height_mode(err->tree_view, TRUE);
|
2009-08-24 16:11:00 +00:00
|
|
|
#endif
|
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
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));
|
|
|
|
|
2009-05-19 15:53:26 +00:00
|
|
|
/* Create a cell renderer */
|
2006-05-04 15:36:41 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
|
|
|
|
/* Create the first column, associating the "text" attribute of the
|
|
|
|
* cell_renderer to the first column of the model */
|
2009-09-02 05:48:38 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Group", renderer, NULL);
|
2009-08-22 16:17:42 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, GROUP_COLUMN);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
2009-09-02 05:48:38 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func(sortable, GROUP_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
2006-05-04 15:36:41 +00:00
|
|
|
/* Add the column to the view. */
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
|
|
|
|
|
|
|
/* Second column.. Protocol. */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Protocol", renderer, "text", PROTOCOL_COLUMN, NULL);
|
2009-08-22 16:17:42 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, PROTOCOL_COLUMN);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
2009-09-02 05:48:38 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, proto_data_func,
|
|
|
|
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func(sortable, PROTOCOL_COLUMN, proto_sort_func,
|
|
|
|
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
2009-08-24 20:33:49 +00:00
|
|
|
gtk_tree_view_column_set_min_width(column, 40);
|
|
|
|
gtk_tree_view_column_set_fixed_width(column, 100);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
|
|
|
|
|
|
|
/* Third column.. Summary. */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Summary", renderer, "text", SUMMARY_COLUMN, NULL);
|
2009-08-22 16:17:42 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SUMMARY_COLUMN);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
2009-08-24 20:33:49 +00:00
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_column_set_fixed_width(column, 230);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
|
|
|
|
|
|
|
/* Last column.. Count. */
|
2009-09-02 05:48:38 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
/* right align */
|
|
|
|
g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
|
2006-05-04 15:36:41 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Count", renderer, "text", COUNT_COLUMN, NULL);
|
2009-08-22 16:17:42 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, COUNT_COLUMN);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
|
|
|
|
2006-12-11 03:32:01 +00:00
|
|
|
err->scrolled_window=scrolled_window_new(NULL, NULL);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(err->scrolled_window), GTK_WIDGET (err->tree_view));
|
|
|
|
|
2006-12-11 03:32:01 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
gtk_tree_view_set_search_column (err->tree_view, SUMMARY_COLUMN); /* Allow searching the summary */
|
|
|
|
gtk_tree_view_set_reorderable (err->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(err->tree_view), TRUE);
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(err->tree_view), TRUE);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2006-12-11 03:32:01 +00:00
|
|
|
gtk_widget_show(err->scrolled_window);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2006-03-19 20:26:45 +00:00
|
|
|
err->num_procs=num_procs;
|
2009-08-19 18:37:13 +00:00
|
|
|
|
|
|
|
err->text = g_string_chunk_new(100);
|
|
|
|
err->procs_array = g_array_sized_new(FALSE, FALSE, sizeof(error_procedure_t), num_procs);
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2006-12-11 03:32:01 +00:00
|
|
|
/* create popup menu for this table */
|
|
|
|
error_create_popup_menu(err);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data)
|
|
|
|
{
|
2009-08-19 18:37:13 +00:00
|
|
|
guint old_num_procs=err->num_procs;
|
2005-11-25 23:42:52 +00:00
|
|
|
gint row=0;
|
2009-08-19 18:37:13 +00:00
|
|
|
error_procedure_t *procedure;
|
2006-05-04 15:36:41 +00:00
|
|
|
GtkTreeStore *store;
|
2009-08-19 18:37:13 +00:00
|
|
|
GtkTreeIter new_iter;
|
2009-08-26 17:26:26 +00:00
|
|
|
gchar num[10];
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2006-05-15 02:43:39 +00:00
|
|
|
/* we have discovered a new procedure. Extend the table accordingly */
|
2005-11-25 23:42:52 +00:00
|
|
|
row = find_summary_data(err, expert_data);
|
2006-05-15 02:43:39 +00:00
|
|
|
if(row==-1){
|
2009-08-19 18:37:13 +00:00
|
|
|
error_procedure_t new_procedure;
|
2006-05-04 15:36:41 +00:00
|
|
|
/* First time we have seen this event so initialize memory table */
|
|
|
|
row = old_num_procs; /* Number of expert events since this is a new event */
|
2009-08-19 18:37:13 +00:00
|
|
|
|
|
|
|
new_procedure.count=0; /* count of events for this item */
|
|
|
|
new_procedure.fvalue_value = NULL; /* Filter string value */
|
2009-08-26 17:26:26 +00:00
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
g_array_append_val(err->procs_array, new_procedure);
|
|
|
|
procedure = &g_array_index(err->procs_array, error_procedure_t, row);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
2006-05-15 02:43:39 +00:00
|
|
|
/* Create the item in our memory table */
|
2009-09-09 19:34:14 +00:00
|
|
|
procedure->entries[0]=(char *)g_string_chunk_insert_const(err->text, expert_data->protocol); /* Protocol */
|
|
|
|
procedure->entries[1]=(char *)g_string_chunk_insert_const(err->text, expert_data->summary); /* Summary */
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* Create a new item in our tree view */
|
|
|
|
store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view)); /* Get store */
|
2009-08-19 18:37:13 +00:00
|
|
|
gtk_tree_store_append (store, &procedure->iter, NULL); /* Acquire an iterator */
|
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
/* match_strval return a static constant or null */
|
2009-08-19 18:37:13 +00:00
|
|
|
gtk_tree_store_set (store, &procedure->iter,
|
2009-09-02 05:48:38 +00:00
|
|
|
GROUP_COLUMN, match_strval(expert_data->group, expert_group_vals),
|
2009-08-26 17:26:26 +00:00
|
|
|
PROTOCOL_COLUMN, procedure->entries[0],
|
|
|
|
SUMMARY_COLUMN, procedure->entries[1], -1);
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* If an expert item was passed then build the filter string */
|
2006-11-23 21:16:46 +00:00
|
|
|
if (expert_data->pitem) {
|
|
|
|
char *filter;
|
2009-08-21 11:03:30 +00:00
|
|
|
|
|
|
|
g_assert(PITEM_FINFO(expert_data->pitem));
|
2009-08-09 17:57:31 +00:00
|
|
|
filter = proto_construct_match_selected_string(PITEM_FINFO(expert_data->pitem), NULL);
|
2006-11-24 18:25:23 +00:00
|
|
|
if (filter != NULL)
|
2009-09-09 19:34:14 +00:00
|
|
|
procedure->fvalue_value = g_string_chunk_insert_const(err->text, filter);
|
2006-03-19 20:26:45 +00:00
|
|
|
}
|
2006-05-04 15:36:41 +00:00
|
|
|
/* Store the updated count of events */
|
|
|
|
err->num_procs = ++old_num_procs;
|
2006-05-15 02:43:39 +00:00
|
|
|
}
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* Update our memory table with event data */
|
2009-08-19 18:37:13 +00:00
|
|
|
procedure = &g_array_index(err->procs_array, error_procedure_t, row);
|
|
|
|
procedure->count++; /* increment the count of events for this item */
|
2006-05-04 15:36:41 +00:00
|
|
|
|
|
|
|
/* Update the tree with new count for this event */
|
|
|
|
store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
|
2009-08-24 20:33:49 +00:00
|
|
|
gtk_tree_store_set(store, &procedure->iter,
|
|
|
|
COUNT_COLUMN, procedure->count,
|
|
|
|
-1);
|
2009-08-26 17:26:26 +00:00
|
|
|
|
|
|
|
g_snprintf(num, sizeof(num), "%d", expert_data->packet_num);
|
2009-08-24 20:33:49 +00:00
|
|
|
#if 0
|
|
|
|
This does not have a big performance improvment :(
|
|
|
|
if GTK_CHECK_VERSION(2,10,0)
|
|
|
|
gtk_tree_store_insert_with_values (store,
|
|
|
|
&new_iter, /* *iter */
|
|
|
|
&procedure->iter, /* *parent*/
|
|
|
|
G_MAXINT, /* position */
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* FIXME gtk is plagued with slow algorithms
|
|
|
|
gtk_tree_store_append call new_path and its nice recursive linear search....
|
|
|
|
*/
|
|
|
|
if (procedure->count > 1000) {
|
|
|
|
/* If there's more than 1000 sub rows give up and prepend new rows, at least
|
|
|
|
it will end in a reasonable time. Anyway with so many rows it's not
|
2009-09-02 05:48:38 +00:00
|
|
|
very useful and if sorted the right order is restored.
|
2009-08-24 20:33:49 +00:00
|
|
|
*/
|
|
|
|
gtk_tree_store_prepend(store, &new_iter, &procedure->iter);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gtk_tree_store_append(store, &new_iter, &procedure->iter);
|
|
|
|
}
|
2006-05-04 15:36:41 +00:00
|
|
|
gtk_tree_store_set(store, &new_iter,
|
2009-08-24 20:33:49 +00:00
|
|
|
#endif
|
2009-09-02 05:48:38 +00:00
|
|
|
GROUP_COLUMN, packet,
|
2009-08-26 17:26:26 +00:00
|
|
|
PROTOCOL_COLUMN, num,
|
2009-05-19 15:53:26 +00:00
|
|
|
COUNT_COLUMN, 1,
|
|
|
|
-1);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
reset_error_table_data(error_equiv_table *err)
|
|
|
|
{
|
2006-05-04 15:36:41 +00:00
|
|
|
GtkTreeStore *store;
|
2005-11-25 23:42:52 +00:00
|
|
|
|
2006-05-04 15:36:41 +00:00
|
|
|
store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
|
|
|
|
gtk_tree_store_clear(store);
|
2005-11-25 23:42:52 +00:00
|
|
|
err->num_procs = 0;
|
2009-08-23 18:13:03 +00:00
|
|
|
/* g_string_chunk_clear() is introduced in glib 2.14 */
|
|
|
|
g_string_chunk_free(err->text);
|
|
|
|
err->text = g_string_chunk_new(100);
|
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
g_array_set_size(err->procs_array, 0);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
free_error_table_data(error_equiv_table *err)
|
|
|
|
{
|
2007-12-03 21:55:44 +00:00
|
|
|
err->num_procs=0;
|
2009-08-19 18:37:13 +00:00
|
|
|
g_string_chunk_free(err->text);
|
|
|
|
g_array_free(err->procs_array, TRUE);
|
2005-11-25 23:42:52 +00:00
|
|
|
}
|