#include "config.h"
+#include "ws_diag_control.h"
+
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <epan/address.h>
#include <epan/addr_resolv.h>
#include <epan/oids.h>
-#ifdef HAVE_GEOIP
-#include <epan/geoip_db.h>
-#endif
+#include <epan/maxmind_db.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto.h>
{NULL, NULL, -1}
};
-/* GTK+ only. */
-static const enum_val_t gui_hex_dump_highlight_style[] = {
- {"BOLD", "BOLD", 0},
- {"INVERSE", "INVERSE", 1},
- {NULL, NULL, -1}
-};
-
static const enum_val_t gui_console_open_type[] = {
{"NEVER", "NEVER", console_open_never},
{"AUTOMATIC", "AUTOMATIC", console_open_auto},
{NULL, NULL, -1}
};
-/* GTK knows of two ways representing "both", vertical and horizontal aligned.
- * as this may not work on other guis, we use only "both" in general here */
static const enum_val_t gui_toolbar_style[] = {
{"ICONS", "ICONS", 0},
{"TEXT", "TEXT", 1},
return pref->info.max_value;
}
-void* prefs_get_control(pref_t *pref)
-{
- return pref->control;
-}
-
-void prefs_set_control(pref_t *pref, void* control)
-{
- pref->control = control;
-}
-
-int prefs_get_ordinal(pref_t *pref)
-{
- return pref->ordinal;
-}
-
/*
* List of all modules with preference settings.
*/
static void
free_string_like_preference(pref_t *pref)
{
- g_free(*pref->varp.string);
+DIAG_OFF(cast-qual)
+ g_free((char *)*pref->varp.string);
+DIAG_ON(cast-qual)
*pref->varp.string = NULL;
g_free(pref->default_val.string);
pref->default_val.string = NULL;
case PREF_SAVE_FILENAME:
case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
- g_free(*pref->varp.string);
- *pref->varp.string = NULL;
- g_free(pref->default_val.string);
- pref->default_val.string = NULL;
+ free_string_like_preference(pref);
break;
case PREF_RANGE:
case PREF_DECODE_AS_RANGE:
/* Clean the uats */
uat_cleanup();
+ /* Shut down mmdbresolve */
+ maxmind_db_pref_cleanup();
+
g_free(prefs.saved_at_version);
g_free(gpf_path);
gpf_path = NULL;
}
}
+/*
+ * Assign to a string preference.
+ */
+static void
+pref_set_string_like_pref_value(pref_t *pref, const gchar *value)
+{
+DIAG_OFF(cast-qual)
+ g_free((void *)*pref->varp.string);
+DIAG_ON(cast-qual)
+ *pref->varp.string = g_strdup(value);
+}
+
/*
* For use by UI code that sets preferences.
*/
if (*pref->varp.string) {
if (strcmp(*pref->varp.string, value) != 0) {
changed = prefs_get_effect_flags(pref);
- g_free(*pref->varp.string);
- *pref->varp.string = g_strdup(value);
+ pref_set_string_like_pref_value(pref, value);
}
} else if (value) {
- *pref->varp.string = g_strdup(value);
+ pref_set_string_like_pref_value(pref, value);
}
break;
default:
if (unstash_data->handle_decode_as) {
sub_dissectors = find_dissector_table(pref->name);
if (sub_dissectors != NULL) {
- handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)unstash_data->module->title);
+ handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
if (handle != NULL) {
dissector_change_uint(pref->name, *pref->varp.uint, handle);
}
if (unstash_data->handle_decode_as) {
sub_dissectors = find_dissector_table(pref->name);
if (sub_dissectors != NULL) {
- handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)unstash_data->module->title);
+ handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
if (handle != NULL) {
/* Delete all of the old values from the dissector table */
for (i = 0; i < (*pref->varp.range)->nranges; i++) {
if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000)
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
-#ifdef HAVE_LIBPORTAUDIO
- /* Test for a sane max channels entry */
- if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
-#endif
-
/* burst resolution can't be less than 1 (ms) */
if (prefs.st_burst_resolution < 1) {
prefs.st_burst_resolution = 1;
prefs_register_obsolete_preference(gui_module, "scrollbar_on_right");
prefs_register_obsolete_preference(gui_module, "packet_list_sel_browse");
prefs_register_obsolete_preference(gui_module, "protocol_tree_sel_browse");
-
- prefs_register_bool_preference(gui_module, "tree_view_altern_colors",
- "Alternating colors in TreeViews",
- "Alternating colors in TreeViews?",
- &prefs.gui_altern_colors);
+ prefs_register_obsolete_preference(gui_module, "tree_view_altern_colors");
prefs_register_bool_preference(gui_module, "expert_composite_eyecandy",
"Display Icons on Expert Composite Dialog Tabs",
"Protocol-tree expander style",
&prefs.gui_ptree_expander_style, gui_ptree_expander_style, FALSE);
- prefs_register_enum_preference(gui_module, "hex_dump_highlight_style",
- "Hex dump highlight style",
- "Hex dump highlight style",
- &prefs.gui_hex_dump_highlight_style, gui_hex_dump_highlight_style, FALSE);
+ prefs_register_obsolete_preference(gui_module, "hex_dump_highlight_style");
gui_column_module = prefs_register_subtree(gui_module, "Columns", "Columns", NULL);
prefs_register_obsolete_preference(gui_font_module, "font_name");
- register_string_like_preference(gui_font_module, "gtk2.font_name", "Font name",
- "Font name for packet list, protocol tree, and hex dump panes. (GTK+)",
- &prefs.gui_gtk2_font_name, PREF_STRING, NULL, TRUE);
+ prefs_register_obsolete_preference(gui_font_module, "gtk2.font_name");
register_string_like_preference(gui_font_module, "qt.font_name", "Font name",
"Font name for packet list, protocol tree, and hex dump panes. (Qt)",
"Save window maximized state at exit?",
&prefs.gui_geometry_save_maximized);
- /* GTK+ only */
- prefs_register_bool_preference(gui_module, "macosx_style",
- "Use macOS style",
- "Use macOS style (macOS with native GTK only)?",
- &prefs.gui_macosx_style);
+ prefs_register_obsolete_preference(gui_module, "macosx_style");
prefs_register_obsolete_preference(gui_module, "geometry.main.x");
prefs_register_obsolete_preference(gui_module, "geometry.main.y");
"Show version in the start page and/or main screen's title bar",
(gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE);
- prefs_register_bool_preference(gui_module, "auto_scroll_on_expand",
- "Automatically scroll packet details",
- "When selecting a new packet, automatically scroll"
- "to the packet detail item that matches the most"
- "recently selected item",
- &prefs.gui_auto_scroll_on_expand);
-
- prefs_register_uint_preference(gui_module, "auto_scroll_percentage",
- "Packet detail scroll percentage",
- "The percentage down the view the recently expanded detail item should be scrolled",
- 10,
- &prefs.gui_auto_scroll_percentage);
+ prefs_register_obsolete_preference(gui_module, "auto_scroll_on_expand");
+ prefs_register_obsolete_preference(gui_module, "auto_scroll_percentage");
/* User Interface : Layout */
gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
prefs_register_bool_preference(capture_module, "auto_scroll", "Scroll packet list during capture",
"Scroll packet list during capture?", &prefs.capture_auto_scroll);
- /* GTK+ only */
+ /* GTK+ only, but we might implement this in Qt */
prefs_register_bool_preference(capture_module, "show_info", "Show capture info dialog while capturing",
"Show capture info dialog while capturing?", &prefs.capture_show_info);
"Name Resolution", NULL, TRUE);
addr_resolve_pref_init(nameres_module);
oid_pref_init(nameres_module);
-#ifdef HAVE_GEOIP
- geoip_db_pref_init(nameres_module);
-#endif
+ maxmind_db_pref_init(nameres_module);
/* Printing */
printing = prefs_register_module(NULL, "print", "Printing",
10,
&prefs.tap_update_interval);
-#ifdef HAVE_LIBPORTAUDIO
- prefs_register_uint_preference(stats_module, "rtp_player_max_visible",
- "Max visible channels in RTP Player",
- "Determines maximum height of RTP Player window",
- 10,
- &prefs.rtp_player_max_visible);
-#endif
+ prefs_register_obsolete_preference(stats_module, "rtp_player_max_visible");
prefs_register_bool_preference(stats_module, "st_enable_burstinfo",
"Enable the calculation of burst information",
g_free(prefs.pr_cmd);
prefs.pr_cmd = g_strdup("lpr");
- prefs.gui_altern_colors = FALSE;
prefs.gui_expert_composite_eyecandy = FALSE;
prefs.gui_ptree_line_style = 0;
prefs.gui_ptree_expander_style = 1;
- prefs.gui_hex_dump_highlight_style = 1; /* GTK+ only */
prefs.filter_toolbar_show_in_statusbar = FALSE;
prefs.restore_filter_after_following_stream = FALSE;
prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
- /* These will be g_freed, so they must be g_mallocated. */
- g_free(prefs.gui_gtk2_font_name);
-#ifdef _WIN32
- prefs.gui_gtk2_font_name = g_strdup("Lucida Console 10");
-#else
- prefs.gui_gtk2_font_name = g_strdup("Monospace 10");
-#endif
/* We try to find the best font in the Qt code */
g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = g_strdup("");
prefs.gui_geometry_save_position = TRUE;
prefs.gui_geometry_save_size = TRUE;
prefs.gui_geometry_save_maximized= TRUE;
- prefs.gui_macosx_style = TRUE;
prefs.gui_console_open = console_open_never;
prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED;
prefs.gui_recent_df_entries_max = 10;
g_free(prefs.gui_start_title);
prefs.gui_start_title = g_strdup("The World's Most Popular Network Protocol Analyzer");
prefs.gui_version_placement = version_both;
- prefs.gui_auto_scroll_on_expand = FALSE;
- prefs.gui_auto_scroll_percentage = 0;
prefs.gui_layout_type = layout_type_5;
prefs.gui_layout_content_1 = layout_pane_content_plist;
prefs.gui_layout_content_2 = layout_pane_content_pdetails;
/* set the default values for the tap/statistics dialog box */
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
prefs.st_enable_burstinfo = TRUE;
prefs.st_burst_showcount = FALSE;
prefs.st_burst_resolution = ST_DEF_BURSTRES;
if (p == value || *p != '\0')
return FALSE; /* number was bad */
- module = prefs_find_module((gchar*)port_prefs[i].module_name);
+ module = prefs_find_module(port_prefs[i].module_name);
pref = prefs_find_preference(module, port_prefs[i].table_name);
if (pref != NULL)
{
{
sub_dissectors = find_dissector_table(port_prefs[i].table_name);
if (sub_dissectors != NULL) {
- handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)port_prefs[i].module_name);
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_prefs[i].module_name);
if (handle != NULL) {
dissector_change_uint(port_prefs[i].table_name, uval, handle);
decode_build_reset_list(port_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
g_assert_not_reached();
}
- module = prefs_find_module((gchar*)port_range_prefs[i].module_name);
+ module = prefs_find_module(port_range_prefs[i].module_name);
pref = prefs_find_preference(module, port_range_prefs[i].table_name);
if (pref != NULL)
{
return FALSE; /* number was bad */
}
- handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)port_range_prefs[i].module_name);
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_range_prefs[i].module_name);
if (handle != NULL) {
for (range_i = 0; range_i < (*pref->varp.range)->nranges; range_i++) {
}
} else if (strcmp(module->name, "taps") == 0) {
/* taps preferences moved to "statistics" module */
- if (strcmp(dotp, "update_interval") == 0 ||
- strcmp(dotp, "rtp_player_max_visible") == 0)
+ if (strcmp(dotp, "update_interval") == 0)
pref = prefs_find_preference(stats_module, dotp);
} else if (strcmp(module->name, "packet_list") == 0) {
/* packet_list preferences moved to protocol module */
/* Name of preference is the dissector table */
sub_dissectors = find_dissector_table(pref->name);
if (sub_dissectors != NULL) {
- handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)module->title);
+ handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
if (handle != NULL) {
if (uval != 0) {
dissector_change_uint(pref->name, uval, handle);
/* Name of preference is the dissector table */
sub_dissectors = find_dissector_table(pref->name);
if (sub_dissectors != NULL) {
- handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)module->title);
+ handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
if (handle != NULL) {
/* Delete all of the old values from the dissector table */
for (i = 0; i < (*pref->varp.range)->nranges; i++) {