Have (almost) all preferences use the generic preferences API (per https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7402). This cleaned up a lot of hardcoded code and allows breaking up the prefs structure (or at least prevent it from growing too large) if desired.
Bugfixed problems mentioned in http://www.wireshark.org/lists/wireshark-dev/201208/msg00001.html Column preferences now support default '#' character svn path=/trunk/; revision=44348
This commit is contained in:
parent
68e2e8b889
commit
e0e533d643
|
@ -1584,7 +1584,7 @@ airpcap_get_default_if(GList* airpcap_if_list)
|
|||
{
|
||||
airpcap_if_info_t* if_info = NULL;
|
||||
|
||||
if(prefs.capture_device != NULL)
|
||||
if ((prefs.capture_device != NULL) && (*prefs.capture_device != '\0'))
|
||||
{
|
||||
if_info = get_airpcap_if_from_name(airpcap_if_list,
|
||||
get_if_name(prefs.capture_device));
|
||||
|
|
|
@ -55,7 +55,8 @@ capture_dev_user_descr_find(const gchar *if_name)
|
|||
int lp = 0;
|
||||
int ct = 0;
|
||||
|
||||
if (prefs.capture_devices_descr == NULL) {
|
||||
if ((prefs.capture_devices_descr == NULL) ||
|
||||
(*prefs.capture_devices_descr == '\0')) {
|
||||
/* There are no descriptions. */
|
||||
return NULL;
|
||||
}
|
||||
|
@ -108,7 +109,8 @@ capture_dev_user_linktype_find(const gchar *if_name)
|
|||
gchar *p, *next;
|
||||
long linktype;
|
||||
|
||||
if (prefs.capture_devices_linktypes == NULL) {
|
||||
if ((prefs.capture_devices_linktypes == NULL) ||
|
||||
(*prefs.capture_devices_linktypes == '\0')) {
|
||||
/* There are no link-layer header types */
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,6 @@ convert_string_case
|
|||
convert_string_to_hex
|
||||
copy_file_binary_mode
|
||||
copy_persconffile_profile
|
||||
copy_prefs
|
||||
crc16_ccitt_tvb
|
||||
crc16_plain_tvb_offset
|
||||
crc16_ccitt_tvb_offset
|
||||
|
@ -490,7 +489,6 @@ frame_data_compare
|
|||
frame_data_init
|
||||
frame_data_set_before_dissect
|
||||
frame_data_set_after_dissect
|
||||
free_prefs
|
||||
ftype_can_contains
|
||||
ftype_can_eq
|
||||
ftype_can_ge
|
||||
|
|
2353
epan/prefs.c
2353
epan/prefs.c
File diff suppressed because it is too large
Load Diff
|
@ -477,12 +477,6 @@ extern e_prefs *read_prefs(int *, int *, char **, int *, int *, char **);
|
|||
into "*pf_path_return", and return the errno. */
|
||||
extern int write_prefs(char **);
|
||||
|
||||
/* Copy a set of preferences. */
|
||||
extern void copy_prefs(e_prefs *dest, e_prefs *src);
|
||||
|
||||
/* Free a set of preferences. */
|
||||
extern void free_prefs(e_prefs *pr);
|
||||
|
||||
/*
|
||||
* Given a string of the form "<pref name>:<pref value>", as might appear
|
||||
* as an argument to a "-o" option, parse it and set the preference in
|
||||
|
|
2
tshark.c
2
tshark.c
|
@ -1791,7 +1791,7 @@ main(int argc, char *argv[])
|
|||
#ifdef HAVE_LIBPCAP
|
||||
/* trim the interface name and exit if that failed */
|
||||
if (!capture_opts_trim_iface(&global_capture_opts,
|
||||
(prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL)) {
|
||||
((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -3484,7 +3484,7 @@ static void local_hide_cb(GtkCellRendererToggle *cell _U_,
|
|||
gtk_tree_model_get (model, &iter, 0, &name, 1, &hide, -1);
|
||||
|
||||
/* See if this is the currently selected capturing device */
|
||||
if (prefs.capture_device != NULL) {
|
||||
if ((prefs.capture_device != NULL) && (*prefs.capture_device != '\0')) {
|
||||
guint i;
|
||||
interface_t device;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
|
@ -3541,16 +3541,8 @@ apply_local_cb(GtkWidget *win _U_, gpointer *data _U_)
|
|||
g_free(name);
|
||||
}
|
||||
/* write new "hidden" string to preferences */
|
||||
if (strlen(new_hide) > 0) {
|
||||
g_free(prefs.capture_devices_hide);
|
||||
prefs.capture_devices_hide = new_hide;
|
||||
}
|
||||
/* no "hidden" interfaces */
|
||||
else {
|
||||
g_free(prefs.capture_devices_hide);
|
||||
g_free(new_hide);
|
||||
prefs.capture_devices_hide = NULL;
|
||||
}
|
||||
g_free(prefs.capture_devices_hide);
|
||||
prefs.capture_devices_hide = new_hide;
|
||||
hide_interface(g_strdup(new_hide));
|
||||
|
||||
/* Refresh all places that are displaying an interface list
|
||||
|
@ -4916,7 +4908,8 @@ capture_start_confirmed(void)
|
|||
guint i;
|
||||
|
||||
/* did the user ever select a capture interface before? */
|
||||
if(global_capture_opts.num_selected == 0 && prefs.capture_device == NULL) {
|
||||
if(global_capture_opts.num_selected == 0 &&
|
||||
((prefs.capture_device == NULL) || (*prefs.capture_device != '\0'))) {
|
||||
simple_dialog(ESD_TYPE_CONFIRMATION,
|
||||
ESD_BTN_OK,
|
||||
"%sNo capture interface selected!%s\n\n"
|
||||
|
|
|
@ -2895,7 +2895,7 @@ main(int argc, char *argv[])
|
|||
if (start_capture || list_link_layer_types) {
|
||||
/* Did the user specify an interface to use? */
|
||||
if (!capture_opts_trim_iface(&global_capture_opts,
|
||||
(prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL)) {
|
||||
((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL)) {
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -2945,7 +2945,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if ((global_capture_opts.num_selected == 0) &&
|
||||
(prefs.capture_device != NULL)) {
|
||||
(prefs.capture_device != NULL) && (*prefs_p->capture_device != '\0')) {
|
||||
guint i;
|
||||
interface_t device;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
|
|
|
@ -269,6 +269,10 @@ capture_prefs_fetch(GtkWidget *w)
|
|||
g_free(if_text);
|
||||
if_text = NULL;
|
||||
}
|
||||
|
||||
/* Ensure capture device is not NULL */
|
||||
if (if_text == NULL)
|
||||
if_text = g_strdup("");
|
||||
prefs.capture_device = if_text;
|
||||
|
||||
prefs.capture_prom_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
|
||||
|
@ -1085,7 +1089,7 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
|
|||
gtk_entry_set_text(GTK_ENTRY(if_descr_te), comment);
|
||||
|
||||
/* See if this is the currently selected capturing device */
|
||||
if (prefs.capture_device != NULL) {
|
||||
if ((prefs.capture_device != NULL) && (*prefs.capture_device != '\0')) {
|
||||
guint i;
|
||||
interface_t device;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
|
@ -1392,7 +1396,8 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
|
|||
text[2] = g_strdup("");
|
||||
|
||||
/* add interface descriptions */
|
||||
if (prefs.capture_devices_descr != NULL) {
|
||||
if ((prefs.capture_devices_descr != NULL) &&
|
||||
(*prefs.capture_devices_descr != '\0')) {
|
||||
/* create working copy of device descriptions */
|
||||
pr_descr = g_strdup(prefs.capture_devices_descr);
|
||||
|
||||
|
@ -1553,16 +1558,8 @@ ifopts_write_new_monitor_mode(void)
|
|||
}
|
||||
|
||||
/* write new "hidden" string to preferences */
|
||||
if (strlen(new_monitor_mode) > 0) {
|
||||
g_free(prefs.capture_devices_monitor_mode);
|
||||
prefs.capture_devices_monitor_mode = new_monitor_mode;
|
||||
}
|
||||
/* no "hidden" interfaces */
|
||||
else {
|
||||
g_free(prefs.capture_devices_monitor_mode);
|
||||
g_free(new_monitor_mode);
|
||||
prefs.capture_devices_monitor_mode = NULL;
|
||||
}
|
||||
g_free(prefs.capture_devices_monitor_mode);
|
||||
prefs.capture_devices_monitor_mode = new_monitor_mode;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1620,16 +1617,8 @@ ifopts_write_new_linklayer(void)
|
|||
}
|
||||
|
||||
/* write new link-layer string to preferences */
|
||||
if (strlen(new_linklayer) > 0) {
|
||||
g_free(prefs.capture_devices_linktypes);
|
||||
prefs.capture_devices_linktypes = new_linklayer;
|
||||
}
|
||||
/* no link-layers */
|
||||
else {
|
||||
g_free(prefs.capture_devices_linktypes);
|
||||
g_free(new_linklayer);
|
||||
prefs.capture_devices_linktypes = NULL;
|
||||
}
|
||||
g_free(prefs.capture_devices_linktypes);
|
||||
prefs.capture_devices_linktypes = new_linklayer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1686,16 +1675,8 @@ ifopts_write_new_descr(void)
|
|||
}
|
||||
|
||||
/* write new description string to preferences */
|
||||
if (strlen(new_descr) > 0) {
|
||||
g_free(prefs.capture_devices_descr);
|
||||
prefs.capture_devices_descr = new_descr;
|
||||
}
|
||||
/* no descriptions */
|
||||
else {
|
||||
g_free(prefs.capture_devices_descr);
|
||||
g_free(new_descr);
|
||||
prefs.capture_devices_descr = NULL;
|
||||
}
|
||||
g_free(prefs.capture_devices_descr);
|
||||
prefs.capture_devices_descr = new_descr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1747,16 +1728,8 @@ ifopts_write_new_hide(void)
|
|||
}
|
||||
|
||||
/* write new "hidden" string to preferences */
|
||||
if (strlen(new_hide) > 0) {
|
||||
g_free(prefs.capture_devices_hide);
|
||||
prefs.capture_devices_hide = new_hide;
|
||||
}
|
||||
/* no "hidden" interfaces */
|
||||
else {
|
||||
g_free(prefs.capture_devices_hide);
|
||||
g_free(new_hide);
|
||||
prefs.capture_devices_hide = NULL;
|
||||
}
|
||||
g_free(prefs.capture_devices_hide);
|
||||
prefs.capture_devices_hide = new_hide;
|
||||
hide_interface(g_strdup(new_hide));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,13 +104,6 @@ static GtkWidget *create_preference_filename_entry(GtkWidget *, int,
|
|||
*/
|
||||
static GtkWidget *prefs_w;
|
||||
|
||||
/*
|
||||
* Save the value of the preferences as of when the preferences dialog
|
||||
* box was first popped up, so we can revert to those values if the
|
||||
* user selects "Cancel".
|
||||
*/
|
||||
static e_prefs saved_prefs;
|
||||
|
||||
struct ct_struct {
|
||||
GtkWidget *main_vb;
|
||||
GtkWidget *notebook;
|
||||
|
@ -446,10 +439,6 @@ prefs_page_cb(GtkWidget *w _U_, gpointer dummy _U_, PREFS_PAGE_E prefs_page)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Save the current preferences, so we can revert to those values
|
||||
if the user presses "Cancel". */
|
||||
copy_prefs(&saved_prefs, &prefs);
|
||||
|
||||
prefs_w = dlg_conf_window_new("Wireshark: Preferences");
|
||||
|
||||
/*
|
||||
|
@ -1404,7 +1393,6 @@ prefs_main_destroy_all(GtkWidget *dlg)
|
|||
|
||||
/* Free up the saved preferences (both for "prefs" and for registered
|
||||
preferences). */
|
||||
free_prefs(&saved_prefs);
|
||||
prefs_modules_foreach(module_prefs_clean, NULL);
|
||||
}
|
||||
|
||||
|
@ -1468,8 +1456,6 @@ module_prefs_copy(module_t *module, gpointer user_data _U_)
|
|||
/* Copy prefs to saved values so we can revert to these values */
|
||||
/* if the user selects Cancel. */
|
||||
static void prefs_copy(void) {
|
||||
free_prefs(&saved_prefs);
|
||||
copy_prefs(&saved_prefs, &prefs);
|
||||
prefs_modules_foreach(module_prefs_copy, NULL);
|
||||
}
|
||||
|
||||
|
@ -1699,8 +1685,6 @@ prefs_main_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
|
|||
|
||||
/* Free up the current preferences and copy the saved preferences to the
|
||||
current preferences. */
|
||||
free_prefs(&prefs);
|
||||
copy_prefs(&prefs, &saved_prefs);
|
||||
cfile.cinfo.columns_changed = FALSE; /* [XXX: "columns_changed" should treally be stored in prefs struct ??] */
|
||||
|
||||
/* Now revert the registered preferences. */
|
||||
|
|
Loading…
Reference in New Issue