forked from osmocom/wireshark
Backing out r50690 (exept simple_dialog)
struct FILE is different on windows vs *nix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8942 svn path=/trunk/; revision=50691
This commit is contained in:
parent
e0341f776c
commit
e9d236ec0b
|
@ -570,10 +570,8 @@ read_filters_file(FILE *f, gpointer user_data)
|
|||
dfilter_t *temp_dfilter;
|
||||
|
||||
if (!dfilter_compile(filter_exp, &temp_dfilter)) {
|
||||
g_warning("Could not compile \"%s\" in colorfilters file.\n%s",
|
||||
g_warning("Could not compile color filter \"%s\" from saved filters: %s",
|
||||
name, dfilter_error_msg);
|
||||
prefs.unknown_colorfilters = TRUE;
|
||||
|
||||
skip_end_of_line = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
|
71
epan/prefs.c
71
epan/prefs.c
|
@ -2900,7 +2900,7 @@ void
|
|||
prefs_reset(void)
|
||||
{
|
||||
prefs_initialized = FALSE;
|
||||
g_free(prefs.saved_at_version);
|
||||
|
||||
/*
|
||||
* Unload all UAT preferences.
|
||||
*/
|
||||
|
@ -3060,24 +3060,12 @@ read_prefs_file(const char *pf_path, FILE *pf,
|
|||
GString *cur_val;
|
||||
GString *cur_var;
|
||||
gboolean got_val = FALSE;
|
||||
gboolean first_line = TRUE;
|
||||
gint fline = 1, pline = 1;
|
||||
gchar hint[] = "(save preferences to remove this warning)";
|
||||
|
||||
gchar hint[] = "(applying your preferences once should remove this warning)";
|
||||
|
||||
cur_val = g_string_new("");
|
||||
cur_var = g_string_new("");
|
||||
|
||||
/* Try to read in the profile name in the first line of the preferences file. */
|
||||
got_c = getc(pf);
|
||||
if(got_c
|
||||
&& pf->_base
|
||||
&& strncmp((const char *)pf->_base, "# Configuration file for ", 25) == 0) {
|
||||
gchar *eol = strchr(pf->_base, '\n');
|
||||
int len = eol - (pf->_base + 25) - 1;
|
||||
prefs.saved_at_version = g_strndup((const gchar *)pf->_base + 25, len);
|
||||
}
|
||||
rewind(pf);
|
||||
|
||||
while ((got_c = getc(pf)) != EOF) {
|
||||
if (got_c == '\n') {
|
||||
state = START;
|
||||
|
@ -3107,8 +3095,8 @@ read_prefs_file(const char *pf_path, FILE *pf,
|
|||
break;
|
||||
|
||||
case PREFS_SET_SYNTAX_ERR:
|
||||
g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
|
||||
cur_var->str, pline, pf_path, hint);
|
||||
g_warning ("%s line %d: Syntax error in preference \"%s\" %s",
|
||||
pf_path, pline, cur_var->str, hint);
|
||||
break;
|
||||
|
||||
case PREFS_SET_NO_SUCH_PREF:
|
||||
|
@ -3117,26 +3105,19 @@ read_prefs_file(const char *pf_path, FILE *pf,
|
|||
* on non-Win32 platforms.
|
||||
*/
|
||||
if (strcmp(cur_var->str, "print.command") != 0)
|
||||
g_warning ("No such preference \"%s\" at line %d of\n%s %s",
|
||||
cur_var->str, pline, pf_path, hint);
|
||||
prefs.unknown_prefs = TRUE;
|
||||
g_warning ("%s line %d: No such preference \"%s\" %s",
|
||||
pf_path, pline, cur_var->str, hint);
|
||||
break;
|
||||
|
||||
case PREFS_SET_OBSOLETE:
|
||||
if (strcmp(cur_var->str, "print.command") != 0)
|
||||
/* If an attempt is made to save the preferences, a popup warning will be
|
||||
displayed stating that obsolete prefs have been detected and the user will
|
||||
be given the opportunity to save these prefs under a different profile name.
|
||||
The prefs in question need to be listed in the console window so that the
|
||||
user can make an informed choice.
|
||||
*/
|
||||
g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
|
||||
cur_var->str, pline, pf_path, hint);
|
||||
prefs.unknown_prefs = TRUE;
|
||||
/* We silently ignore attempts to set these; it's
|
||||
probably not the user's fault that it's in there -
|
||||
they may have saved preferences with a release that
|
||||
supported them. */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
|
||||
g_warning ("%s line %d: Incomplete preference %s", pf_path, pline, hint);
|
||||
}
|
||||
}
|
||||
state = IN_VAR;
|
||||
|
@ -3149,7 +3130,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
|
|||
} else if (got_c == '#') {
|
||||
state = IN_SKIP;
|
||||
} else {
|
||||
g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
|
||||
g_warning ("%s line %d: Malformed line %s", pf_path, fline, hint);
|
||||
}
|
||||
break;
|
||||
case IN_VAR:
|
||||
|
@ -3189,23 +3170,22 @@ read_prefs_file(const char *pf_path, FILE *pf,
|
|||
break;
|
||||
|
||||
case PREFS_SET_SYNTAX_ERR:
|
||||
g_warning ("Syntax error in preference %s at line %d of\n%s %s",
|
||||
cur_var->str, pline, pf_path, hint);
|
||||
g_warning ("%s line %d: Syntax error in preference %s %s", pf_path, pline, cur_var->str, hint);
|
||||
break;
|
||||
|
||||
case PREFS_SET_NO_SUCH_PREF:
|
||||
g_warning ("No such preference \"%s\" at line %d of\n%s %s",
|
||||
cur_var->str, pline, pf_path, hint);
|
||||
prefs.unknown_prefs = TRUE;
|
||||
g_warning ("%s line %d: No such preference \"%s\" %s", pf_path,
|
||||
pline, cur_var->str, hint);
|
||||
break;
|
||||
|
||||
case PREFS_SET_OBSOLETE:
|
||||
prefs.unknown_prefs = TRUE;
|
||||
/* We silently ignore attempts to set these; it's probably not
|
||||
the user's fault that it's in there - they may have saved
|
||||
preferences with a release that supported it. */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
g_warning ("Incomplete preference at line %d of\n%s %s",
|
||||
pline, pf_path, hint);
|
||||
g_warning ("%s line %d: Incomplete preference %s", pf_path, pline, hint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3684,16 +3664,9 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
|
|||
else if (strcmp(pref_name, "sonmp") == 0)
|
||||
module = prefs_find_module("ndp");
|
||||
else if (strcmp(pref_name, "etheric") == 0 ||
|
||||
strcmp(pref_name, "isup_thin") == 0) {
|
||||
strcmp(pref_name, "isup_thin") == 0)
|
||||
/* This protocol was removed 7. July 2009 */
|
||||
return PREFS_SET_OBSOLETE;
|
||||
}
|
||||
if (module) {
|
||||
g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
|
||||
"Save your preferences to make this change permanent.",
|
||||
pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
|
||||
prefs.unknown_prefs = TRUE;
|
||||
}
|
||||
}
|
||||
*dotp = '.'; /* put the preference string back */
|
||||
dotp++; /* skip past separator to preference name */
|
||||
|
@ -3704,8 +3677,6 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
|
|||
pref = prefs_find_preference(module, dotp);
|
||||
|
||||
if (pref == NULL) {
|
||||
prefs.unknown_prefs = TRUE;
|
||||
|
||||
/* "gui" prefix was added to column preferences for better organization
|
||||
* within the preferences file
|
||||
*/
|
||||
|
|
|
@ -201,9 +201,6 @@ typedef struct _e_prefs {
|
|||
gboolean gui_update_enabled;
|
||||
software_update_channel_e gui_update_channel;
|
||||
gint gui_update_interval;
|
||||
gchar *saved_at_version;
|
||||
gboolean unknown_prefs; /* unknown or obsolete pref(s) */
|
||||
gboolean unknown_colorfilters; /* unknown or obsolete color filter(s) */
|
||||
} e_prefs;
|
||||
|
||||
WS_DLL_PUBLIC e_prefs prefs;
|
||||
|
|
|
@ -1019,42 +1019,6 @@ color_clear_cb(GtkWidget *widget, gpointer data _U_) {
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
overwrite_existing_colorfilters_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
|
||||
{
|
||||
switch (btn) {
|
||||
case(ESD_BTN_SAVE):
|
||||
/* overwrite the file*/
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open colorfilter file: %s", g_strerror(errno));
|
||||
else
|
||||
prefs.unknown_colorfilters = FALSE;
|
||||
break;
|
||||
case(ESD_BTN_DONT_SAVE):
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
colorfilters_main_save()
|
||||
{
|
||||
if (prefs.unknown_colorfilters) {
|
||||
gpointer dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE,
|
||||
"Obsolete or unrecognized color filters have been detected. "
|
||||
"If this profile will be used with an older or nonstandard Wireshark version "
|
||||
"or one that includes a proprietary dissector plugin, click 'Continue "
|
||||
"without Saving' and save this profile under a different name.\n\n");
|
||||
|
||||
simple_dialog_set_cb(dialog, overwrite_existing_colorfilters_cb, NULL);
|
||||
} else {
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open filter file: %s", g_strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* User pressed "Ok" button: Exit dialog and apply new list of
|
||||
color filters to the capture. */
|
||||
|
@ -1074,8 +1038,11 @@ static void
|
|||
color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save)
|
||||
colorfilters_main_save();
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open filter file: %s", g_strerror(errno));
|
||||
}
|
||||
|
||||
/* Apply the coloring rules, both the temporary ones in
|
||||
* color_filter_tmp_list as the permanent ones in color_filter_edit_list
|
||||
|
@ -1091,7 +1058,10 @@ color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
|
|||
static void
|
||||
color_save_cb(GtkButton *button _U_, gpointer user_data _U_)
|
||||
{
|
||||
colorfilters_main_save();
|
||||
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open filter file: %s", g_strerror(errno));
|
||||
}
|
||||
|
||||
/* User pressed "Cancel" button (or "ESC" or the 'X'):
|
||||
|
|
|
@ -1252,8 +1252,8 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
|
|||
/* XXX - check the non-registered preferences too */
|
||||
switch (prefs_modules_foreach(module_prefs_check, (gpointer)&badpref)) {
|
||||
|
||||
case PREFS_SET_SYNTAX_ERR:
|
||||
switch (badpref->type) {
|
||||
case PREFS_SET_SYNTAX_ERR:
|
||||
switch (badpref->type) {
|
||||
|
||||
case PREF_UINT:
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
|
@ -1391,55 +1391,6 @@ static void prefs_copy(void) {
|
|||
prefs_modules_foreach(module_prefs_copy, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
overwrite_existing_prefs_cb(gpointer dialog _U_, gint btn, gpointer parent_w)
|
||||
{
|
||||
switch (btn) {
|
||||
case(ESD_BTN_SAVE):
|
||||
prefs_main_write();
|
||||
prefs.unknown_prefs = FALSE;
|
||||
break;
|
||||
case(ESD_BTN_DONT_SAVE):
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
static void
|
||||
prefs_main_save(gpointer parent_w)
|
||||
{
|
||||
if (prefs.unknown_prefs) {
|
||||
gpointer dialog;
|
||||
gchar *msg;
|
||||
gchar *msg1 = "These preferences were last saved at version ";
|
||||
gchar *msg2 = "Obsolete or unrecognized preferences have been detected. "
|
||||
"If you plan to use this profile with ";
|
||||
gchar *msg3 = "that version of Wireshark, ";
|
||||
gchar *msg4 = "an older or nonstandard Wireshark version, ";
|
||||
gchar *msg5 = "click 'Continue without Saving' and save this profile under a another name.\n";
|
||||
|
||||
if (prefs.saved_at_version) {
|
||||
gulong tot_msg_len = 246 + strlen(prefs.saved_at_version) + 1;
|
||||
|
||||
msg = (gchar *)g_malloc(tot_msg_len);
|
||||
g_snprintf(msg, tot_msg_len, "%s\"%s\". %s%s%s",
|
||||
msg1, prefs.saved_at_version, msg2, msg3, msg5);
|
||||
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE, msg);
|
||||
} else {
|
||||
msg = (gchar *)g_malloc(214);
|
||||
|
||||
g_snprintf(msg, 214, "%s%s%s", msg2, msg4, msg5);
|
||||
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE, msg);
|
||||
}
|
||||
|
||||
simple_dialog_set_cb(dialog, overwrite_existing_prefs_cb, parent_w);
|
||||
g_free(msg);
|
||||
|
||||
} else {
|
||||
prefs_main_write();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
||||
{
|
||||
|
@ -1450,7 +1401,7 @@ prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
prefs_main_save(parent_w);
|
||||
prefs_main_write();
|
||||
}
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
|
@ -1491,7 +1442,7 @@ prefs_main_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
|
|||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
prefs_main_save(parent_w);
|
||||
prefs_main_write();
|
||||
prefs_copy(); /* save prefs for reverting if Cancel */
|
||||
}
|
||||
|
||||
|
@ -1519,7 +1470,7 @@ prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
|
|||
if (!prefs_main_fetch_all((GtkWidget *)parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting - already reported */
|
||||
|
||||
prefs_main_save(parent_w);
|
||||
prefs_main_write();
|
||||
prefs_copy(); /* save prefs for reverting if Cancel */
|
||||
|
||||
/* Now apply those preferences.
|
||||
|
|
Loading…
Reference in New Issue