Allow a progress dialog to have "Stop" or "Cancel" as the "terminate
[obnox/wireshark/wip.git] / gtk / graph_analysis.h
1 /* graph_analysis.h
2  * Graphic Analysis addition for ethereal
3  *
4  * $Id$
5  *
6  * Copyright 2004, Verso Technologies Inc.
7  * By Alejandro Vaquero <alejandrovaquero@yahoo.com>
8  *
9  * based on rtp_analysis.c and io_stat
10  *
11  *
12  * Ethereal - Network traffic analyzer
13  * By Gerald Combs <gerald@ethereal.com>
14  * Copyright 1998 Gerald Combs
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation,  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29  */
30
31 #ifndef GRAPH_ANALYSIS_H_INCLUDED
32 #define GRAPH_ANALYSIS_H_INCLUDED
33
34 #include <glib.h>
35 #include <gtk/gtk.h>
36 #include "gtkglobals.h"
37 #include <epan/address.h>
38
39 #define MAX_NUM_NODES 10
40
41 /* defines an entry in for the graph analysis */
42 typedef struct _graph_analysis_item {
43         guint32 frame_num;                      /* frame number used to "go to" that frame */
44         double time;                            /* frame time */
45         address src_addr;
46         guint16 port_src;
47         address dst_addr;
48         guint16 port_dst;
49         gchar *frame_label;                     /* the label on top of the arrow */
50         gchar *comment;                         /* a comment that appears at the left of the graph */
51         guint16 conv_num;                       /* the conversation number, each conversation will be colored */
52         gboolean display;                       /* indicate if the packet is displayed or not in the graph */
53         guint16 src_node;                       /* this is used by graph_analysis.c to identify the node */
54         guint16 dst_node;                       /* a node is an IP address that will be displayed in columns */
55         guint16 line_style;                     /* the arrow line width in pixels*/
56 } graph_analysis_item_t;
57
58 /* defines the graph analysis structure */
59 typedef struct _graph_analysis_info {
60         int     nconv;       /* number of conversations in the list */
61         GList*  list;   /* list with the graph analysis items */
62 } graph_analysis_info_t;
63
64 /* max number of nodes to display, each node will be an IP address */
65 #define MAX_NUM_COL_CONV 10
66 #define NODE_OVERFLOW MAX_NUM_NODES+1
67 #define NUM_DISPLAY_ITEMS 1000
68
69 typedef struct _display_items {
70         guint32 frame_num;                      /* frame number used to "go to" that frame */
71         double time;                            /* frame time */
72         guint16 port_src;
73         guint16 port_dst;
74         gchar *frame_label;                     /* the label on top of the arrow */
75         gchar *comment;                         /* a comment that appears at the left of the graph */
76         guint16 conv_num;                       /* the conversation number, each conversation will be colored */
77         guint16 src_node;                       /* this is used by graph_analysis.c to identify the node */
78         guint16 dst_node;                       /* a node is an IP address that will be displayed in columns */
79         guint16 line_style;                     /* the arrow line width in pixels*/
80 } display_items_t;
81
82 typedef struct _dialog_data_t {
83         GtkWidget *window;
84         gboolean needs_redraw;
85         gboolean inverse;          /* set the nodes in reverse mode as "dst <---- src" instead of "src ----> dst"*/
86         gint selected_row;
87     GtkWidget *draw_area_time;
88     GtkWidget *draw_area;
89         GtkWidget *draw_area_comments;
90     GdkPixmap *pixmap_time;
91     GdkPixmap *pixmap;
92     GdkPixmap *pixmap_comments;
93         GtkWidget *scroll_window;
94         GtkWidget *v_scrollbar;
95         GtkAdjustment *v_scrollbar_adjustment;
96         GtkWidget *hpane;
97         GdkGC *div_line_gc[2];
98         GdkGC *bg_gc[MAX_NUM_COL_CONV+1];
99     int pixmap_width;
100     int pixmap_height;
101         guint16 first_node;                     /* the first node on the left to show in the screen */
102         guint32 first_item;                     /* the first item (row) to show from the top */
103         guint32 selected_item;          /* the selected item */
104         display_items_t items[NUM_DISPLAY_ITEMS];
105     guint32 left_x_border;
106     char *save_file;
107         char *title;                            /* Graph analysis window's title */
108 } dialog_data_t;
109
110 typedef void (*destroy_user_data_cb)(void *data);
111
112 /* structure that holds general information and the dialog */
113 typedef struct _graph_analysis_data_t {
114         /* graphic data */
115         graph_analysis_info_t *graph_info;
116
117         /* dialog associated data */
118         dialog_data_t dlg;
119         address nodes[MAX_NUM_NODES];
120         guint32 num_nodes;
121         guint32 num_items;
122         destroy_user_data_cb on_destroy_user_data;  /* callback info for destroy */
123         void *data; /* data to be passes when on destroy */
124 } graph_analysis_data_t;
125
126 graph_analysis_data_t* graph_analysis_init(void);
127 void graph_analysis_create(graph_analysis_data_t* user_data);
128 void graph_analysis_update(graph_analysis_data_t* user_data);
129 void graph_analysis_redraw(graph_analysis_data_t* user_data);
130
131
132 #endif /*GRAPH_ANALYSIS_H_INCLUDED*/