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.
32 #include <wsutil/filesystem.h>
33 #include <wsutil/plugins.h>
35 #include <epan/oids.h>
38 #include <epan/geoip_db.h>
41 #include <epan/wslua/init_wslua.h>
45 #include "../version_info.h"
46 #include "../register.h"
48 #include "ui/last_open_dir.h"
50 #include "ui/gtk/about_dlg.h"
51 #include "ui/gtk/gui_utils.h"
52 #include "ui/gtk/dlg_utils.h"
53 #include "ui/gtk/file_dlg.h"
54 #include "ui/gtk/text_page_utils.h"
55 #include "ui/gtk/gtkglobals.h"
56 #include "ui/gtk/main.h"
57 #include "ui/gtk/plugins_dlg.h"
58 #include "ui/gtk/gui_utils.h"
59 #include "ui/gtk/wssplash.h"
61 #include "webbrowser.h"
64 * Update frequence for the splash screen, given in milliseconds.
66 int info_update_freq = 100;
68 static void about_wireshark_destroy_cb(GtkWidget *, gpointer);
72 * Keep a static pointer to the current "About Wireshark" window, if any, so
73 * that if somebody tries to do "About Wireshark" while there's already an
74 * "About Wireshark" window up, we just pop up the existing one, rather than
77 static GtkWidget *about_wireshark_w;
81 about_wireshark(GtkWidget *parent _U_, GtkWidget *main_vb)
83 GtkWidget *msg_label, *icon;
85 const char *title = "Network Protocol Analyzer";
87 /*icon = xpm_to_widget_from_parent(parent, wssplash_xpm);*/
88 icon = pixbuf_to_widget(wssplash_pb_data);
90 gtk_box_pack_start(GTK_BOX(main_vb), icon, TRUE, TRUE, 0);
93 msg_label = gtk_label_new(title);
94 message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
95 gtk_label_set_markup(GTK_LABEL(msg_label), message);
97 gtk_box_pack_start(GTK_BOX(main_vb), msg_label, TRUE, TRUE, 0);
101 splash_update_label(GtkWidget *win, const char *message)
105 if (win == NULL) return;
107 main_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "splash_label");
108 gtk_label_set_text(GTK_LABEL(main_lb), message);
110 /* Process all pending GUI events before continuing, so that
111 the splash screen window gets updated. */
112 while (gtk_events_pending()) gtk_main_iteration();
116 splash_new(const char *message)
122 GtkWidget *percentage_box;
124 GtkWidget *percentage_lb;
126 win = splash_window_new();
128 /* When calling about_wireshark(), we must realize the top-level
129 widget for the window, otherwise GTK will throw a warning
130 because we don't have a colormap associated with that window and
131 can't handle the pixmap. */
132 gtk_widget_realize(win);
134 main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
135 gtk_container_set_border_width(GTK_CONTAINER(main_box), 24);
136 gtk_container_add(GTK_CONTAINER(win), main_box);
139 about_wireshark(win, main_box);
141 main_lb = gtk_label_new(message);
142 gtk_box_pack_start(GTK_BOX(main_box), main_lb, TRUE, TRUE, 0);
143 g_object_set_data(G_OBJECT(win), "splash_label", main_lb);
145 main_lb = gtk_label_new("");
146 gtk_box_pack_start(GTK_BOX(main_box), main_lb, TRUE, TRUE, 0);
147 g_object_set_data(G_OBJECT(win), "protocol_label", main_lb);
149 percentage_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
150 gtk_box_pack_start(GTK_BOX(main_box), percentage_box, TRUE, TRUE, 3);
152 prog_bar = gtk_progress_bar_new();
153 gtk_box_pack_start(GTK_BOX(percentage_box), prog_bar, TRUE, TRUE, 3);
154 g_object_set_data(G_OBJECT(win), "progress_bar", prog_bar);
156 percentage_lb = gtk_label_new(" 0%");
157 gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0f, 0.0f);
158 gtk_box_pack_start(GTK_BOX(percentage_box), percentage_lb, FALSE, TRUE, 3);
159 g_object_set_data(G_OBJECT(win), "percentage_label", percentage_lb);
161 gtk_widget_show_all(win);
163 splash_update_label(win, message);
169 splash_update(register_action_e action, const char *message, gpointer client_data)
174 GtkWidget *percentage_lb;
176 gulong ul_percentage;
178 const char *action_msg;
180 static gulong ul_sofar = 0;
181 static gulong ul_count = 0;
183 static register_action_e last_action = RA_NONE;
185 static GTimeVal cur_tv;
186 static GTimeVal next_tv = {0, 0};
188 win = (GtkWidget *)client_data;
190 if (win == NULL) return;
192 g_get_current_time(&cur_tv);
193 if (last_action == action && cur_tv.tv_sec <= next_tv.tv_sec && cur_tv.tv_usec <= next_tv.tv_usec && ul_sofar < ul_count - 1) {
194 /* Only update every splash_register_freq milliseconds */
198 memcpy(&next_tv, &cur_tv, sizeof(next_tv));
199 next_tv.tv_usec += info_update_freq * 1000;
200 if (next_tv.tv_usec >= 1000000) {
202 next_tv.tv_usec -= 1000000;
205 if(last_action != action) {
206 /* the action has changed */
209 action_msg = "Initializing dissectors ...";
212 action_msg = "Initializing tap listeners ...";
215 action_msg = "Registering dissector ...";
217 case RA_PLUGIN_REGISTER:
218 action_msg = "Registering plugins ...";
220 case RA_PYTHON_REGISTER:
221 action_msg = "Registering Python dissectors ...";
224 action_msg = "Handing off dissector ...";
226 case RA_PLUGIN_HANDOFF:
227 action_msg = "Handing off plugins ...";
229 case RA_PYTHON_HANDOFF:
230 action_msg = "Handing off Python dissectors ...";
233 action_msg = "Loading Lua plugins ...";
236 action_msg = "Loading module preferences ...";
238 case RA_CONFIGURATION:
239 action_msg = "Loading configuration files ...";
242 action_msg = "(Unknown action)";
245 splash_update_label(win, action_msg);
246 last_action = action;
249 if(ul_count == 0) { /* get the count of dissectors */
250 ul_count = register_count() + 6; /* additional 6 for:
251 dissectors, listeners,
252 registering plugins, handingoff plugins,
253 preferences and configuration */
255 ul_count += wslua_count_plugins (); /* get count of lua plugins */
258 ul_count += 2; /* additional 2 for python register and handoff */
262 main_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "protocol_label");
263 /* make_dissector_reg.py changed -
264 so we need to strip off the leading elements to get back to the protocol */
266 if(!strncmp(message, "proto_register_", 15))
268 else if(!strncmp(message, "proto_reg_handoff_", 18))
271 gtk_label_set_text(GTK_LABEL(main_lb), message ? message : "");
275 g_assert (ul_sofar <= ul_count);
277 percentage = (gfloat)ul_sofar/(gfloat)ul_count;
278 ul_percentage = (gulong)(percentage * 100);
280 /* update progress bar */
281 prog_bar = (GtkWidget *)g_object_get_data(G_OBJECT(win), "progress_bar");
282 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage);
284 percentage_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "percentage_label");
285 g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage);
286 gtk_label_set_text((GtkLabel*)percentage_lb, tmp);
288 /* Process all pending GUI events before continuing, so that
289 the splash screen window gets updated. */
290 while (gtk_events_pending()) gtk_main_iteration();
295 splash_destroy(GtkWidget *win)
300 gtk_widget_destroy(win);
305 about_wireshark_page_new(void)
307 GtkWidget *main_box, *msg_label /*, *icon*/;
310 main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
311 gtk_container_set_border_width(GTK_CONTAINER(main_box), 12);
313 g_object_set(gtk_widget_get_settings(main_box),
314 "gtk-label-select-on-focus", FALSE, NULL);
316 about_wireshark(top_level, main_box);
318 /* Construct the message string */
319 message = g_strdup_printf(
320 "Version " VERSION "%s\n"
328 "Wireshark is Open Source Software released under the GNU General Public License.\n"
330 "Check the man page and http://www.wireshark.org for more information.",
331 wireshark_gitversion, get_copyright_info(), comp_info_str->str,
332 runtime_info_str->str);
334 msg_label = gtk_label_new(message);
336 gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
337 gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
338 gtk_box_pack_start(GTK_BOX (main_box), msg_label, TRUE, TRUE, 0);
345 about_authors_page_new(void)
350 absolute_path = get_datafile_path("AUTHORS-SHORT");
351 page = text_page_new(absolute_path);
356 static gboolean about_folders_callback(GtkWidget *widget, GdkEventButton *event, gint id _U_)
358 GtkTreeSelection *tree_selection;
363 tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
365 if(gtk_tree_selection_count_selected_rows(tree_selection) == 0)
368 if(event->type != GDK_2BUTTON_PRESS)
369 /* not a double click */
372 if(gtk_tree_selection_get_selected (tree_selection, &model, &iter)) {
373 gtk_tree_model_get(model, &iter, 1, &path, -1);
374 filemanager_open_directory(path);
382 about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
384 simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
388 about_folders_page_new(void)
391 const char *constpath;
393 static const gchar *titles[] = { "Name", "Folder", "Typical Files"};
394 GtkWidget *scrolledwindow;
395 #if defined (HAVE_LIBSMI) || defined (HAVE_GEOIP)
400 const gchar * const *dirs;
403 scrolledwindow = scrolled_window_new(NULL, NULL);
404 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
407 /* Container for our data */
408 table = simple_list_new(3, titles);
410 /* connect a callback so we can spot a double-click */
411 g_signal_connect(table, "button_press_event",
412 G_CALLBACK(about_folders_callback), NULL);
414 simple_list_url_col(table, 1);
417 about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
421 about_folders_row(table, "Temp", g_get_tmp_dir(),
422 "untitled capture files");
425 path = get_persconffile_path("", FALSE);
426 about_folders_row(table, "Personal configuration", path,
427 "\"dfilters\", \"preferences\", \"ethers\", ...");
431 constpath = get_datafile_dir();
432 if (constpath != NULL) {
433 about_folders_row(table, "Global configuration", constpath,
434 "\"dfilters\", \"preferences\", \"manuf\", ...");
437 dirs = g_get_system_data_dirs ();
438 for (i = 0; dirs[i]; i++){
439 g_warning("glibs data path %u %s",i+1,dirs[i]);
443 constpath = get_systemfile_dir();
444 about_folders_row(table, "System", constpath,
445 "\"ethers\", \"ipxnets\"");
448 constpath = get_progfile_dir();
449 about_folders_row(table, "Program", constpath,
452 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
454 path = get_plugins_pers_dir();
455 about_folders_row(table, "Personal Plugins", path,
456 "dissector plugins");
460 about_folders_row(table, "Global Plugins", get_plugin_dir(),
461 "dissector plugins");
465 /* global python bindings */
466 about_folders_row(table, "Python Bindings", get_wspython_dir(),
472 path = geoip_db_get_paths();
474 resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);
476 for(i = 0; resultArray[i]; i++)
477 about_folders_row(table, "GeoIP path", g_strstrip(resultArray[i]),
478 "GeoIP database search path");
479 g_strfreev(resultArray);
485 path = oid_get_default_mib_path();
487 resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);
489 for(i = 0; resultArray[i]; i++)
490 about_folders_row(table, "MIB/PIB path", g_strstrip(resultArray[i]),
491 "SMI MIB/PIB search path");
492 g_strfreev(resultArray);
496 gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
498 return scrolledwindow;
502 about_license_page_new(void)
508 absolute_path = get_datafile_path("COPYING.txt");
510 absolute_path = get_datafile_path("COPYING");
512 page = text_page_new(absolute_path);
518 about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ )
520 GtkWidget *main_box, *main_nb, *bbox, *ok_btn;
521 GtkWidget *page_lb, *about_page, *folders_page;
523 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
524 GtkWidget *plugins_page;
527 GtkWidget *authors_page, *license_page;
529 if (about_wireshark_w != NULL) {
530 /* There's already an "About Wireshark" dialog box; reactivate it. */
531 reactivate_window(about_wireshark_w);
536 * XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
537 * Should we use GtkDialog for simple_dialog() as well? Or
538 * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
539 * not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
541 about_wireshark_w = dlg_window_new("About Wireshark");
542 /* set the initial position (must be done, before show is called!) */
543 /* default position is not appropriate for the about dialog */
544 gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER_ON_PARENT);
545 gtk_window_set_default_size(GTK_WINDOW(about_wireshark_w), 600, 400);
546 gtk_container_set_border_width(GTK_CONTAINER(about_wireshark_w), 6);
548 main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
549 gtk_container_set_border_width(GTK_CONTAINER(main_box), 6);
550 gtk_container_add(GTK_CONTAINER(about_wireshark_w), main_box);
552 main_nb = gtk_notebook_new();
553 gtk_box_pack_start(GTK_BOX(main_box), main_nb, TRUE, TRUE, 0);
555 about_page = about_wireshark_page_new();
556 page_lb = gtk_label_new("Wireshark");
557 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
559 authors_page = about_authors_page_new();
560 page_lb = gtk_label_new("Authors");
561 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
563 folders_page = about_folders_page_new();
564 page_lb = gtk_label_new("Folders");
565 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
567 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
568 plugins_page = about_plugins_page_new();
569 page_lb = gtk_label_new("Plugins");
570 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
573 license_page = about_license_page_new();
574 page_lb = gtk_label_new("License");
575 /* set a minmum width to avoid a lot of line breaks at the wrong places */
576 gtk_widget_set_size_request(license_page, 600, -1);
577 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), license_page, page_lb);
580 bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
581 gtk_box_pack_start(GTK_BOX(main_box), bbox, FALSE, FALSE, 0);
583 ok_btn = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
584 gtk_widget_grab_focus(ok_btn);
585 gtk_widget_grab_default(ok_btn);
586 window_set_cancel_button(about_wireshark_w, ok_btn, window_cancel_button_cb);
588 g_signal_connect(about_wireshark_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
589 g_signal_connect(about_wireshark_w, "destroy", G_CALLBACK(about_wireshark_destroy_cb), NULL);
591 gtk_widget_show_all(about_wireshark_w);
592 window_present(about_wireshark_w);
596 about_wireshark_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
598 /* Note that we no longer have an "About Wireshark" dialog box. */
599 about_wireshark_w = NULL;