aboutsummaryrefslogtreecommitdiffstats
path: root/epan/prefs.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2013-07-18 04:28:36 +0000
committerAnders Broman <anders.broman@ericsson.com>2013-07-18 04:28:36 +0000
commit09c5152fa71f84fc37b28808d6d522d1be896dcb (patch)
tree9702b2d7879fed4a169c36692af4d1143622fd40 /epan/prefs.c
parent7dcafd67c0274800fda530d3b512ed009e0e0875 (diff)
From Cal Turney:
Unrecognized preferences and color filters created in proprietary or older versions are discarded when saved. If the user attempts to save the preferences or colorfilters file, a popup is displayed that warns that unrecognized prefs or color filters have been detected and will be discarded if the save operation is allowed to proceed. In the case of Preferences, the popup message includes the version at which the file was last saved. A "Continue without Saving" button is provided so that the user can save the profile under a different name. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8942 svn path=/trunk/; revision=50716
Diffstat (limited to 'epan/prefs.c')
-rw-r--r--epan/prefs.c76
1 files changed, 55 insertions, 21 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index 0127a0f71e..82fec9789a 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -2900,7 +2900,7 @@ void
prefs_reset(void)
{
prefs_initialized = FALSE;
-
+ g_free(prefs.saved_at_version);
/*
* Unload all UAT preferences.
*/
@@ -3061,11 +3061,28 @@ read_prefs_file(const char *pf_path, FILE *pf,
GString *cur_var;
gboolean got_val = FALSE;
gint fline = 1, pline = 1;
- gchar hint[] = "(applying your preferences once should remove this warning)";
-
+ gchar hint[] = "(save preferences to 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) {
+ GString *firstl = (GString *)pf;
+
+ if (strncmp(firstl->str, " Configuration file for ", 24) == 0) {
+ gchar *eol;
+ gsize len;
+
+ firstl->str += 24;
+ eol = strchr((char *) firstl->str, '\n');
+ len = eol - firstl->str - 1;
+ prefs.saved_at_version = g_strndup((const gchar *)firstl->str, len);
+ }
+ }
+ rewind(pf);
+
while ((got_c = getc(pf)) != EOF) {
if (got_c == '\n') {
state = START;
@@ -3095,8 +3112,8 @@ read_prefs_file(const char *pf_path, FILE *pf,
break;
case PREFS_SET_SYNTAX_ERR:
- g_warning ("%s line %d: Syntax error in preference \"%s\" %s",
- pf_path, pline, cur_var->str, hint);
+ g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
break;
case PREFS_SET_NO_SUCH_PREF:
@@ -3105,19 +3122,26 @@ read_prefs_file(const char *pf_path, FILE *pf,
* on non-Win32 platforms.
*/
if (strcmp(cur_var->str, "print.command") != 0)
- g_warning ("%s line %d: No such preference \"%s\" %s",
- pf_path, pline, cur_var->str, hint);
+ g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
+ prefs.unknown_prefs = TRUE;
break;
case PREFS_SET_OBSOLETE:
- /* 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. */
+ 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;
break;
}
} else {
- g_warning ("%s line %d: Incomplete preference %s", pf_path, pline, hint);
+ g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
}
}
state = IN_VAR;
@@ -3130,7 +3154,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
} else if (got_c == '#') {
state = IN_SKIP;
} else {
- g_warning ("%s line %d: Malformed line %s", pf_path, fline, hint);
+ g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
}
break;
case IN_VAR:
@@ -3170,22 +3194,23 @@ read_prefs_file(const char *pf_path, FILE *pf,
break;
case PREFS_SET_SYNTAX_ERR:
- g_warning ("%s line %d: Syntax error in preference %s %s", pf_path, pline, cur_var->str, hint);
+ g_warning ("Syntax error in preference %s at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
break;
case PREFS_SET_NO_SUCH_PREF:
- g_warning ("%s line %d: No such preference \"%s\" %s", pf_path,
- pline, cur_var->str, hint);
+ g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+ cur_var->str, pline, pf_path, hint);
+ prefs.unknown_prefs = TRUE;
break;
case PREFS_SET_OBSOLETE:
- /* 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. */
+ prefs.unknown_prefs = TRUE;
break;
}
} else {
- g_warning ("%s line %d: Incomplete preference %s", pf_path, pline, hint);
+ g_warning ("Incomplete preference at line %d of\n%s %s",
+ pline, pf_path, hint);
}
}
@@ -3664,9 +3689,16 @@ 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 */
@@ -3677,6 +3709,8 @@ 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
*/