summaryrefslogtreecommitdiff
path: root/ui
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 /ui
parent7dcafd67c0274800fda530d3b512ed009e0e0875 (diff)
downloadwireshark-09c5152fa71f84fc37b28808d6d522d1be896dcb.tar.gz
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 'ui')
-rw-r--r--ui/gtk/color_dlg.c48
-rw-r--r--ui/gtk/prefs_dlg.c59
2 files changed, 93 insertions, 14 deletions
diff --git a/ui/gtk/color_dlg.c b/ui/gtk/color_dlg.c
index b222870cee..84bed9bd84 100644
--- a/ui/gtk/color_dlg.c
+++ b/ui/gtk/color_dlg.c
@@ -1019,6 +1019,42 @@ 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. */
@@ -1038,11 +1074,8 @@ 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) {
- 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));
- }
+ if (!prefs.gui_use_pref_save)
+ colorfilters_main_save();
/* Apply the coloring rules, both the temporary ones in
* color_filter_tmp_list as the permanent ones in color_filter_edit_list
@@ -1058,10 +1091,7 @@ color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
static void
color_save_cb(GtkButton *button _U_, gpointer user_data _U_)
{
-
- 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));
+ colorfilters_main_save();
}
/* User pressed "Cancel" button (or "ESC" or the 'X'):
diff --git a/ui/gtk/prefs_dlg.c b/ui/gtk/prefs_dlg.c
index 9bc073f72a..e3a540568c 100644
--- a/ui/gtk/prefs_dlg.c
+++ b/ui/gtk/prefs_dlg.c
@@ -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,
@@ -1392,6 +1392,55 @@ static void prefs_copy(void) {
}
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 + (gulong)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)
{
gboolean must_redissect = FALSE;
@@ -1401,7 +1450,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_write();
+ prefs_main_save(parent_w);
}
#ifdef HAVE_AIRPCAP
@@ -1442,7 +1491,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_write();
+ prefs_main_save(parent_w);
prefs_copy(); /* save prefs for reverting if Cancel */
}
@@ -1470,7 +1519,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_write();
+ prefs_main_save(parent_w);
prefs_copy(); /* save prefs for reverting if Cancel */
/* Now apply those preferences.