Change the use of threads from "mostly always, depending on your
[obnox/wireshark/wip.git] / gtk / main.h
1 /* main.h
2  * Global defines, etc.
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __MAIN_H__
26 #define __MAIN_H__
27
28 #include "globals.h"
29
30 /** @defgroup main_window_group Main window
31  * The main window has the following submodules:
32    @dot
33   digraph main_dependencies {
34       node [shape=record, fontname=Helvetica, fontsize=10];
35       main [ label="main window" URL="\ref main.h"];
36       menu [ label="menubar" URL="\ref menus.h"];
37       toolbar [ label="toolbar" URL="\ref main_toolbar.h"];
38       packet_list [ label="packet list pane" URL="\ref new_packet_list.h"];
39       proto_draw [ label="packet details & bytes panes" URL="\ref main_proto_draw.h"];
40       recent [ label="recent user settings" URL="\ref recent.h"];
41       main -> menu [ arrowhead="open", style="solid" ];
42       main -> toolbar [ arrowhead="open", style="solid" ];
43       main -> packet_list [ arrowhead="open", style="solid" ];
44       main -> proto_draw [ arrowhead="open", style="solid" ];
45       main -> recent [ arrowhead="open", style="solid" ];
46   }
47   @enddot
48  */
49
50 /** @file
51  *  The main window, filter toolbar, program start/stop and a lot of other things
52  *  @ingroup main_window_group
53  *  @ingroup windows_group
54  */
55
56 /** Global compile time version string */
57 extern GString *comp_info_str;
58 /** Global runtime version string */
59 extern GString *runtime_info_str;
60
61 extern GtkWidget* airpcap_tb;
62
63 extern void protect_thread_critical_region(void);
64 extern void unprotect_thread_critical_region(void);
65
66 void
67 airpcap_toolbar_encryption_cb(GtkWidget *entry, gpointer user_data);
68
69 /** User requested "Zoom In" by menu or toolbar.
70  *
71  * @param widget parent widget (unused)
72  * @param data unused
73  */
74 extern void view_zoom_in_cb(GtkWidget *widget, gpointer data);
75
76 /** User requested "Zoom Out" by menu or toolbar.
77  *
78  * @param widget parent widget (unused)
79  * @param data unused
80  */
81 extern void view_zoom_out_cb(GtkWidget *widget, gpointer data);
82
83 /** User requested "Zoom 100%" by menu or toolbar.
84  *
85  * @param widget parent widget (unused)
86  * @param data unused
87  */
88 extern void view_zoom_100_cb(GtkWidget *widget, gpointer data);
89
90 /** User requested "Protocol Info" by ptree context menu.
91  *
92  * @param widget parent widget (unused)
93  * @param data unused
94  */
95 extern void selected_ptree_info_cb(GtkWidget *widget, gpointer data);
96
97 /** User requested "Filter Reference" by ptree context menu.
98  *
99  * @param widget parent widget (unused)
100  * @param data unused
101  */
102 extern void selected_ptree_ref_cb(GtkWidget *widget, gpointer data);
103
104 /** "Apply as Filter" / "Prepare a Filter" action type. */
105 typedef enum {
106     MATCH_SELECTED_REPLACE, /**< "Selected" */
107     MATCH_SELECTED_AND,     /**< "and Selected" */
108     MATCH_SELECTED_OR,      /**< "or Selected" */
109     MATCH_SELECTED_NOT,     /**< "Not Selected" */
110     MATCH_SELECTED_AND_NOT, /**< "and not Selected" */
111     MATCH_SELECTED_OR_NOT   /**< "or not Selected" */
112 } MATCH_SELECTED_E;
113
114 /** mask MATCH_SELECTED_E values (internally used) */
115 #define MATCH_SELECTED_MASK         0x0ff
116
117 /** "bitwise or" this with MATCH_SELECTED_E value for instant apply instead of prepare only */
118 #define MATCH_SELECTED_APPLY_NOW    0x100
119
120 /** "bitwise or" this with MATCH_SELECTED_E value for copy to clipboard instead of prepare only */
121 #define MATCH_SELECTED_COPY_ONLY    0x200
122
123 /** User requested one of "Apply as Filter" or "Prepare a Filter" functions
124  *  by menu or context menu of protocol tree.
125  *
126  * @param widget parent widget
127  * @param data parent widget
128  * @param action the function to use
129  */
130 extern void match_selected_ptree_cb(GtkWidget *widget, gpointer data, MATCH_SELECTED_E action);
131
132 /** "Copy ..." action type. */
133 typedef enum {
134     COPY_SELECTED_DESCRIPTION,  /**< "Copy Description" */
135     COPY_SELECTED_FIELDNAME,    /**< "Copy Fieldname" */
136     COPY_SELECTED_VALUE         /**< "Copy Value" */
137 } COPY_SELECTED_E;
138
139 /** User highlighted item in details window and then right clicked and selected the copy option
140  *
141  * @param w parent widget
142  * @param data parent widget
143  * @param action the function to use
144  */
145 extern void copy_selected_plist_cb(GtkWidget *w _U_, gpointer data, COPY_SELECTED_E action);
146
147 /** Set or remove a time reference on this frame
148  *
149  * @param set TRUE = set time ref, FALSE=unset time ref
150  * @param frame pointer to frame
151  * @param row row number
152  */
153 extern void set_frame_reftime(gboolean set, frame_data *frame, gint row);
154
155 /** User requested the colorize function
156  *  by menu or context menu of protocol tree.
157  *
158  * @param w parent widget
159  * @param data parent widget
160  * @param filt_nr  1-10: use filter for color 1-10
161  *                    0: open new colorization rule dialog
162  *                  255: clear filters for color 1-10
163  */
164 extern void colorize_selected_ptree_cb(GtkWidget *w, gpointer data, guint8 filt_nr);
165
166 /** User requested one of "Apply as Filter" or "Prepare a Filter" functions
167  *  by context menu of packet list.
168  *
169  * @param widget parent widget (unused)
170  * @param data parent widget
171  * @param action the function to use
172  */
173 extern void match_selected_plist_cb(GtkWidget *widget, gpointer data, MATCH_SELECTED_E action);
174
175 /** User requested "Quit" by menu or toolbar.
176  *
177  * @param widget parent widget (unused)
178  * @param data unused
179  */
180 extern void file_quit_cmd_cb(GtkWidget *widget, gpointer data);
181
182 /** User requested "Print" by menu or toolbar.
183  *
184  * @param widget parent widget (unused)
185  * @param data unused
186  */
187 extern void file_print_cmd_cb(GtkWidget *widget, gpointer data);
188
189 /** User requested "Print" by packet list context menu.
190  *
191  * @param widget parent widget (unused)
192  * @param data unused
193  */
194 extern void file_print_selected_cmd_cb(GtkWidget *widget _U_, gpointer data _U_);
195
196 /** User requested "Export as Plain Text" by menu.
197  *
198  * @param widget parent widget (unused)
199  * @param data unused
200  */
201 extern void export_text_cmd_cb(GtkWidget *widget, gpointer data);
202
203 /** User requested "Export as Postscript" by menu.
204  *
205  * @param widget parent widget (unused)
206  * @param data unused
207  */
208 extern void export_ps_cmd_cb(GtkWidget *widget, gpointer data);
209
210 /** User requested "Export as PSML" by menu.
211  *
212  * @param widget parent widget (unused)
213  * @param data unused
214  */
215 extern void export_psml_cmd_cb(GtkWidget *widget, gpointer data);
216
217 /** User requested "Export as PDML" by menu.
218  *
219  * @param widget parent widget (unused)
220  * @param data unused
221  */
222 extern void export_pdml_cmd_cb(GtkWidget *widget, gpointer data);
223
224 /** User requested "Export as CSV" by menu.
225  *
226  * @param widget parent widget (unused)
227  * @param data unused
228  */
229 extern void export_csv_cmd_cb(GtkWidget *widget, gpointer data);
230
231 /** User requested "Export as C Arrays" by menu.
232  *
233  * @param widget parent widget (unused)
234  * @param data unused
235  */
236 extern void export_carrays_cmd_cb(GtkWidget *widget, gpointer data);
237
238 /** User requested "Expand Tree" by menu.
239  *
240  * @param widget parent widget (unused)
241  * @param data unused
242  */
243 extern void expand_tree_cb(GtkWidget *widget, gpointer data);
244
245 /** User requested "Expand All" by menu.
246  *
247  * @param widget parent widget (unused)
248  * @param data unused
249  */
250 extern void expand_all_cb(GtkWidget *widget, gpointer data);
251
252 /** User requested "Apply as a custom column" by menu.
253  *
254  * @param widget parent widget (unused)
255  * @param data unused
256  */
257 extern void apply_as_custom_column_cb(GtkWidget *widget, gpointer data);
258
259 /** User requested "Collapse All" by menu.
260  *
261  * @param widget parent widget (unused)
262  * @param data unused
263  */
264 extern void collapse_all_cb(GtkWidget *widget, gpointer data);
265
266 /** User requested "Resolve Name" by menu.
267  *
268  * @param widget parent widget (unused)
269  * @param data unused
270  */
271 extern void resolve_name_cb(GtkWidget *widget, gpointer data);
272
273 /** Action to take for reftime_frame_cb() */
274 typedef enum {
275     REFTIME_TOGGLE,     /**< toggle ref frame */
276     REFTIME_FIND_NEXT,  /**< find next ref frame */
277     REFTIME_FIND_PREV   /**< find previous ref frame */
278 } REFTIME_ACTION_E;
279
280 /** User requested one of the "Time Reference" functions by menu.
281  *
282  * @param widget parent widget (unused)
283  * @param data unused
284  * @param action the function to use
285  */
286 extern void reftime_frame_cb(GtkWidget *widget, gpointer data, REFTIME_ACTION_E action);
287
288 /** User requested the "Find Next Mark" function by menu.
289  *
290  * @param widget parent widget (unused)
291  * @param data unused
292  * @param action unused
293  */
294 extern void find_next_mark_cb(GtkWidget *widget, gpointer data, int action);
295
296 /** User requested the "Find Previous Mark" function by menu.
297  *
298  * @param widget parent widget (unused)
299  * @param data unused
300  * @param action unused
301  */
302 extern void find_prev_mark_cb(GtkWidget *widget, gpointer data, int action);
303
304 /** Add a display filter coming from the user's recent file to the dfilter combo box.
305  *
306  * @param dftext the filter string
307  */
308 extern gboolean dfilter_combo_add_recent(gchar *dftext);
309
310 #if 0
311 /** Empty out the combobox entry field */
312 extern void dfilter_combo_add_empty(void);
313 #endif
314 /** Write all non empty display filters (until maximum count)
315  *  of the combo box GList to the user's recent file.
316  *
317  * @param rf the recent file
318  */
319 extern void dfilter_recent_combo_write_all(FILE *rf);
320
321 /** Quit the program.
322  *
323  * @return TRUE, if a file read is in progress
324  */
325 extern gboolean main_do_quit(void);
326
327 /** Rearrange the main window widgets, user changed it's preferences. */
328 extern void main_widgets_rearrange(void);
329
330 /** Show or hide the main window widgets, user changed it's preferences. */
331 extern void main_widgets_show_or_hide(void);
332
333 /** Apply a new filter string.
334  *  Call cf_filter_packets() and add this filter string to the recent filter list.
335  *
336  * @param cf the capture file
337  * @param dftext the new filter string
338  * @param force force the refiltering, even if filter string doesn't changed
339  * @return TRUE, if the filtering succeeded
340  */
341 extern gboolean main_filter_packets(capture_file *cf, const gchar *dftext,
342     gboolean force);
343
344 #ifdef _WIN32
345 /** Win32 only: Create a console. Beware: cannot be closed again. */
346 extern void create_console(void);
347 #endif
348
349 #if defined(_WIN32)
350 /** Restart the tap update display timer with new configured interval */
351 extern void reset_tap_update_timer(void);
352 #endif
353
354 /** Fill in capture options with values from the preferences */
355 extern void prefs_to_capture_opts(void);
356
357 /** Change configuration profile */
358 extern void change_configuration_profile(const gchar *profile_name);
359
360 /** redissect packets and update UI */
361 extern void redissect_packets(void);
362
363 /** Fetch all IP addresses from selected row */
364 extern GList *get_ip_address_list_from_packet_list_row(gpointer data);
365
366 extern GtkWidget *pkt_scrollw;
367
368 #endif /* __MAIN_H__ */