5 * Ulf Lamping <ulf.lamping@web.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34 #include <epan/filesystem.h>
35 #include <epan/plugins.h>
37 #include <epan/oids.h>
40 #include <epan/geoip_db.h>
43 #include "../globals.h"
45 #include "../version_info.h"
47 #include "gtk/about_dlg.h"
48 #include "gtk/gui_utils.h"
49 #include "gtk/dlg_utils.h"
50 #include "gtk/file_dlg.h"
51 #include "gtk/text_page_utils.h"
52 #include "gtk/gtkglobals.h"
54 #include "gtk/plugins_dlg.h"
56 #include "../image/wssplash-dev.xpm"
57 #include "webbrowser.h"
60 * Update frequence for the splash screen, given in milliseconds.
62 int splash_register_freq = 100;
64 static void about_wireshark_destroy_cb(GtkWidget *, gpointer);
68 * Keep a static pointer to the current "About Wireshark" window, if any, so
69 * that if somebody tries to do "About Wireshark" while there's already an
70 * "About Wireshark" window up, we just pop up the existing one, rather than
73 static GtkWidget *about_wireshark_w;
77 about_wireshark(GtkWidget *parent, GtkWidget *main_vb)
79 GtkWidget *msg_label, *icon;
81 const char *title = "Network Protocol Analyzer";
83 icon = xpm_to_widget_from_parent(parent, wssplash_xpm);
84 gtk_container_add(GTK_CONTAINER(main_vb), icon);
86 msg_label = gtk_label_new(title);
87 message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
88 gtk_label_set_markup(GTK_LABEL(msg_label), message);
90 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
94 splash_update_label(GtkWidget *win, const char *message)
98 if (win == NULL) return;
100 main_lb = g_object_get_data(G_OBJECT(win), "splash_label");
101 gtk_label_set_text(GTK_LABEL(main_lb), message);
103 /* Process all pending GUI events before continuing, so that
104 the splash screen window gets updated. */
105 while (gtk_events_pending()) gtk_main_iteration();
109 splash_new(const char *message)
115 GtkWidget *percentage_hb;
117 GtkWidget *percentage_lb;
119 win = splash_window_new();
121 /* When calling about_wireshark(), we must realize the top-level
122 widget for the window, otherwise GTK will throw a warning
123 because we don't have a colormap associated with that window and
124 can't handle the pixmap. */
125 gtk_widget_realize(win);
127 main_vb = gtk_vbox_new(FALSE, 6);
128 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 24);
129 gtk_container_add(GTK_CONTAINER(win), main_vb);
131 about_wireshark(win, main_vb);
133 main_lb = gtk_label_new(message);
134 gtk_container_add(GTK_CONTAINER(main_vb), main_lb);
135 g_object_set_data(G_OBJECT(win), "splash_label", main_lb);
137 main_lb = gtk_label_new("");
138 gtk_container_add(GTK_CONTAINER(main_vb), main_lb);
139 g_object_set_data(G_OBJECT(win), "protocol_label", main_lb);
141 percentage_hb = gtk_hbox_new(FALSE, 1);
142 gtk_box_pack_start(GTK_BOX(main_vb), percentage_hb, TRUE, TRUE, 3);
144 prog_bar = gtk_progress_bar_new();
145 gtk_box_pack_start(GTK_BOX(percentage_hb), prog_bar, TRUE, TRUE, 3);
146 g_object_set_data(G_OBJECT(win), "progress_bar", prog_bar);
148 percentage_lb = gtk_label_new(" 0%");
149 gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0f, 0.0f);
150 gtk_box_pack_start(GTK_BOX(percentage_hb), percentage_lb, FALSE, TRUE, 3);
151 g_object_set_data(G_OBJECT(win), "percentage_label", percentage_lb);
153 gtk_widget_show_all(win);
155 splash_update_label(win, message);
161 splash_update(register_action_e action, const char *message, gpointer client_data)
166 GtkWidget *percentage_lb;
168 gulong ul_percentage;
170 const char *action_msg;
172 static gulong ul_sofar = 0;
173 static gulong ul_count = 0;
175 static register_action_e last_action = RA_NONE;
177 static GTimeVal cur_tv;
178 static GTimeVal next_tv = {0, 0};
180 win = (GtkWidget *)client_data;
182 if (win == NULL) return;
184 g_get_current_time(&cur_tv);
185 if (cur_tv.tv_sec <= next_tv.tv_sec && cur_tv.tv_usec <= next_tv.tv_usec && ul_sofar < ul_count - 1) {
186 /* Only update every splash_register_freq milliseconds */
190 memcpy(&next_tv, &cur_tv, sizeof(next_tv));
191 next_tv.tv_usec += splash_register_freq * 1000;
192 if (next_tv.tv_usec >= 1000000) {
194 next_tv.tv_usec -= 1000000;
197 if(last_action != action) {
198 /* the action has changed */
201 action_msg = "Initializing dissectors ...";
204 action_msg = "Initializing tap listeners ...";
207 action_msg = "Registering dissector ...";
209 case RA_PLUGIN_REGISTER:
210 action_msg = "Registering plugins ...";
213 action_msg = "Handing off dissector ...";
215 case RA_PLUGIN_HANDOFF:
216 action_msg = "Handing off plugins ...";
219 action_msg = "Loading module preferences ...";
221 case RA_CONFIGURATION:
222 action_msg = "Loading configuration files ...";
225 action_msg = "(Unknown action)";;
228 splash_update_label(win, action_msg);
229 last_action = action;
232 if(ul_count == 0) /* get the count of dissectors */
233 ul_count = register_count() + 6; /* additional 6 for:
234 dissectors, listeners,
235 registering plugins, handingoff plugins,
236 preferences and configuration */
238 main_lb = g_object_get_data(G_OBJECT(win), "protocol_label");
239 /* make_dissector_reg.py changed -
240 so we need to strip off the leading elements to get back to the protocol */
242 if(!strncmp(message, "proto_register_", 15))
244 else if(!strncmp(message, "proto_reg_handoff_", 18))
247 gtk_label_set_text(GTK_LABEL(main_lb), message ? message : "");
251 g_assert (ul_sofar <= ul_count);
253 percentage = (gfloat)ul_sofar/(gfloat)ul_count;
254 ul_percentage = (gulong)(percentage * 100);
256 /* update progress bar */
257 prog_bar = g_object_get_data(G_OBJECT(win), "progress_bar");
258 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage);
260 percentage_lb = g_object_get_data(G_OBJECT(win), "percentage_label");
261 g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage);
262 gtk_label_set_text((GtkLabel*)percentage_lb, tmp);
264 /* Process all pending GUI events before continuing, so that
265 the splash screen window gets updated. */
266 while (gtk_events_pending()) gtk_main_iteration();
271 splash_destroy(GtkWidget *win)
276 gtk_widget_destroy(win);
281 about_wireshark_page_new(void)
283 GtkWidget *main_vb, *msg_label /*, *icon*/;
286 main_vb = gtk_vbox_new(FALSE, 6);
287 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 12);
289 #if GTK_CHECK_VERSION(2,9,0)
290 g_object_set(gtk_widget_get_settings(main_vb),
291 "gtk-label-select-on-focus", FALSE, NULL);
294 about_wireshark(top_level, main_vb);
296 /* Construct the message string */
297 message = g_strdup_printf(
298 "Version " VERSION "%s\n"
306 "Wireshark is Open Source Software released under the GNU General Public License.\n"
308 "Check the man page and http://www.wireshark.org for more information.",
309 wireshark_svnversion, get_copyright_info(), comp_info_str->str,
310 runtime_info_str->str);
312 msg_label = gtk_label_new(message);
314 gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
315 gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
316 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
322 about_authors_page_new(void)
327 absolute_path = get_datafile_path("AUTHORS-SHORT");
328 page = text_page_new(absolute_path);
333 static gint about_folders_callback(GtkWidget *widget, GdkEventButton *event, gint id _U_)
335 GtkTreeSelection *tree_selection;
340 tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
342 if(gtk_tree_selection_count_selected_rows(tree_selection) == 0)
345 if(event->type != GDK_2BUTTON_PRESS)
346 /* not a double click */
349 if(gtk_tree_selection_get_selected (tree_selection, &model, &iter)) {
350 gtk_tree_model_get(model, &iter, 1, &path, -1);
351 filemanager_open_directory(path);
359 about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
361 simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
365 about_folders_page_new(void)
368 const char *constpath;
370 const gchar *titles[] = { "Name", "Folder", "Typical Files"};
371 GtkWidget *scrolledwindow;
372 #if defined (HAVE_LIBSMI) || defined (HAVE_GEOIP)
377 scrolledwindow = scrolled_window_new(NULL, NULL);
378 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
381 /* Container for our data */
382 table = simple_list_new(3, titles);
384 /* connect a callback so we can spot a double-click */
385 g_signal_connect(table, "button_press_event",
386 G_CALLBACK(about_folders_callback), NULL);
388 simple_list_url_col(table, 1);
391 about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
395 path = get_tempfile_path("");
396 about_folders_row(table, "Temp", path,
397 "untitled capture files");
401 path = get_persconffile_path("", FALSE, FALSE);
402 about_folders_row(table, "Personal configuration", path,
403 "\"dfilters\", \"preferences\", \"ethers\", ...");
407 constpath = get_datafile_dir();
408 if (constpath != NULL) {
409 about_folders_row(table, "Global configuration", constpath,
410 "\"dfilters\", \"preferences\", \"manuf\", ...");
414 constpath = get_systemfile_dir();
415 about_folders_row(table, "System", constpath,
416 "\"ethers\", \"ipxnets\"");
419 constpath = get_progfile_dir();
420 about_folders_row(table, "Program", constpath,
423 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA_5_1)
425 path = get_plugins_pers_dir();
426 about_folders_row(table, "Personal Plugins", path,
427 "dissector plugins");
431 about_folders_row(table, "Global Plugins", get_plugin_dir(),
432 "dissector plugins");
436 /* global python bindings */
437 about_folders_row(table, "Python Bindings", get_wspython_dir(),
443 path = geoip_db_get_paths();
445 resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);
447 for(i = 0; resultArray[i]; i++)
448 about_folders_row(table, "GeoIP path", g_strstrip(resultArray[i]),
449 "GeoIP database search path");
450 g_strfreev(resultArray);
456 path = oid_get_default_mib_path();
458 resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);
460 for(i = 0; resultArray[i]; i++)
461 about_folders_row(table, "MIB/PIB path", g_strstrip(resultArray[i]),
462 "SMI MIB/PIB search path");
463 g_strfreev(resultArray);
467 gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
469 return scrolledwindow;
473 about_license_page_new(void)
478 absolute_path = get_datafile_path("COPYING");
479 page = text_page_new(absolute_path);
485 about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ )
487 GtkWidget *main_vb, *main_nb, *bbox, *ok_btn;
488 GtkWidget *page_lb, *about_page, *folders_page;
490 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA_5_1)
491 GtkWidget *plugins_page;
494 GtkWidget *authors_page, *license_page;
496 if (about_wireshark_w != NULL) {
497 /* There's already an "About Wireshark" dialog box; reactivate it. */
498 reactivate_window(about_wireshark_w);
503 * XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
504 * Should we use GtkDialog for simple_dialog() as well? Or
505 * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
506 * not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
508 about_wireshark_w = dlg_window_new("About Wireshark");
509 /* set the initial position (must be done, before show is called!) */
510 /* default position is not appropriate for the about dialog */
511 gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER_ON_PARENT);
512 gtk_window_set_default_size(GTK_WINDOW(about_wireshark_w), 600, 400);
513 gtk_container_set_border_width(GTK_CONTAINER(about_wireshark_w), 6);
515 main_vb = gtk_vbox_new(FALSE, 12);
516 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
517 gtk_container_add(GTK_CONTAINER(about_wireshark_w), main_vb);
519 main_nb = gtk_notebook_new();
520 gtk_box_pack_start(GTK_BOX(main_vb), main_nb, TRUE, TRUE, 0);
522 about_page = about_wireshark_page_new();
523 page_lb = gtk_label_new("Wireshark");
524 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
526 authors_page = about_authors_page_new();
527 page_lb = gtk_label_new("Authors");
528 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
530 folders_page = about_folders_page_new();
531 page_lb = gtk_label_new("Folders");
532 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
534 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA_5_1)
535 plugins_page = about_plugins_page_new();
536 page_lb = gtk_label_new("Plugins");
537 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
540 license_page = about_license_page_new();
541 page_lb = gtk_label_new("License");
542 /* set a minmum width to avoid a lot of line breaks at the wrong places */
543 gtk_widget_set_size_request(license_page, 600, -1);
544 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), license_page, page_lb);
547 bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
548 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
550 ok_btn = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
551 gtk_widget_grab_focus(ok_btn);
552 gtk_widget_grab_default(ok_btn);
553 window_set_cancel_button(about_wireshark_w, ok_btn, window_cancel_button_cb);
555 g_signal_connect(about_wireshark_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
556 g_signal_connect(about_wireshark_w, "destroy", G_CALLBACK(about_wireshark_destroy_cb), NULL);
558 gtk_widget_show_all(about_wireshark_w);
559 window_present(about_wireshark_w);
563 about_wireshark_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
565 /* Note that we no longer have an "About Wireshark" dialog box. */
566 about_wireshark_w = NULL;