summaryrefslogtreecommitdiff
path: root/ui/preference_utils.c
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2016-01-21 13:41:42 +0100
committerRoland Knall <rknall@gmail.com>2016-01-26 16:37:06 +0000
commit1c822e713034d06944315c138d093aa720ab5752 (patch)
tree0ba13bd0af2d3369f73cc7073a3515f450b53dc3 /ui/preference_utils.c
parent7e72253c0ec259c46546bd45fc27e1d045bfdf55 (diff)
downloadwireshark-1c822e713034d06944315c138d093aa720ab5752.tar.gz
prefutils: Add convenience function
This is a convenience function for allowing multiple key/values to be saved to the preference system, without having to reference pref_t or the real underlying value. It is used by the extcap save functionality, to store the saved values Change-Id: I1c8bf787db8ed2d17628024ec1cd19073e49d017 Reviewed-on: https://code.wireshark.org/review/13471 Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/preference_utils.c')
-rw-r--r--ui/preference_utils.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/ui/preference_utils.c b/ui/preference_utils.c
index 95abc5c03b..ca0a70c7a3 100644
--- a/ui/preference_utils.c
+++ b/ui/preference_utils.c
@@ -273,8 +273,8 @@ prefs_main_write(void)
}
}
-gboolean
-prefs_store_ext(const char * module_name, const char *pref_name, const char *pref_value)
+static gboolean
+prefs_store_ext_helper(const char * module_name, const char *pref_name, const char *pref_value)
{
module_t * module = NULL;
pref_t * pref = NULL;
@@ -305,6 +305,49 @@ prefs_store_ext(const char * module_name, const char *pref_name, const char *pre
}
}
+ return pref_changed;
+}
+
+gboolean
+prefs_store_ext(const char * module_name, const char *pref_name, const char *pref_value)
+{
+ if ( prefs_store_ext_helper(module_name, pref_name, pref_value) )
+ {
+ prefs_main_write();
+ prefs_apply_all();
+ prefs_to_capture_opts();
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
+{
+ gboolean pref_changed = FALSE;
+ GList * keys = NULL;
+
+ if ( ! prefs_is_registered_protocol(module))
+ return pref_changed;
+
+ keys = g_hash_table_get_keys(pref_values);
+ if ( ! keys )
+ return pref_changed;
+
+ while ( keys != NULL )
+ {
+ gchar * pref_name = (gchar *)keys->data;
+ gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, keys->data);
+
+ if ( pref_name && pref_value )
+ {
+ if ( prefs_store_ext_helper(module, pref_name, pref_value) )
+ pref_changed = TRUE;
+ }
+ keys = g_list_next(keys);
+ }
+
if ( pref_changed )
{
prefs_main_write();