* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PREFS_INT_H__
struct pref_module *parent; /**< parent module */
wmem_tree_t *submodules; /**< list of its submodules */
int numprefs; /**< number of non-obsolete preferences */
- gboolean prefs_changed; /**< if TRUE, a preference has changed since we last checked */
+ unsigned int prefs_changed_flags; /**< Bitmask of the types of changes done by module preferences since we last checked */
gboolean obsolete; /**< if TRUE, this is a module that used to
* exist but no longer does
*/
* use simple GUI controls to change the options. In general, the "general"
* Wireshark preferences should have this set to FALSE, while the protocol
* modules will have this set to TRUE */
+ unsigned int effect_flags; /**< Flags of types effected by preference (PREF_TYPE_DISSECTION, PREF_EFFECT_CAPTURE, etc).
+ These flags will be set in all module's preferences on creation. Flags must be non-zero
+ to ensure saving to disk */
};
typedef struct {
typedef void (*pref_custom_free_cb) (pref_t* pref);
typedef void (*pref_custom_reset_cb) (pref_t* pref);
-typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, gboolean* changed);
+typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, unsigned int* changed_flags);
/* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
/* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
typedef const char * (*pref_custom_type_name_cb) (void);
* PREF_OBSOLETE is used for preferences that a module used to support
* but no longer supports; we give different error messages for them.
*/
-#define PREF_UINT (1u << 0)
-#define PREF_BOOL (1u << 1)
-#define PREF_ENUM (1u << 2)
-#define PREF_STRING (1u << 3)
-#define PREF_RANGE (1u << 4)
-#define PREF_STATIC_TEXT (1u << 5)
-#define PREF_UAT (1u << 6)
-#define PREF_FILENAME (1u << 7)
-#define PREF_COLOR (1u << 8) /* XXX - These are only supported for "internal" (non-protocol) */
-#define PREF_CUSTOM (1u << 9) /* use and not as a generic protocol preference */
-#define PREF_OBSOLETE (1u << 10)
-#define PREF_DIRNAME (1u << 11)
-#define PREF_DECODE_AS_UINT (1u << 12) /* XXX - These are only supported for "internal" (non-protocol) */
-#define PREF_DECODE_AS_RANGE (1u << 13) /* use and not as a generic protocol preference */
+#define PREF_UINT (1u << 0)
+#define PREF_BOOL (1u << 1)
+#define PREF_ENUM (1u << 2)
+#define PREF_STRING (1u << 3)
+#define PREF_RANGE (1u << 4)
+#define PREF_STATIC_TEXT (1u << 5)
+#define PREF_UAT (1u << 6)
+#define PREF_SAVE_FILENAME (1u << 7)
+#define PREF_COLOR (1u << 8) /* XXX - These are only supported for "internal" (non-protocol) */
+#define PREF_CUSTOM (1u << 9) /* use and not as a generic protocol preference */
+#define PREF_OBSOLETE (1u << 10)
+#define PREF_DIRNAME (1u << 11)
+#define PREF_DECODE_AS_UINT (1u << 12) /* XXX - These are only supported for "internal" (non-protocol) */
+#define PREF_DECODE_AS_RANGE (1u << 13) /* use and not as a generic protocol preference */
+#define PREF_OPEN_FILENAME (1u << 14)
typedef enum {
GUI_ALL,
GUI_QT
} gui_type_t;
-/** Struct to hold preference data */
-struct preference {
- const char *name; /**< name of preference */
- const char *title; /**< title to use in GUI */
- const char *description; /**< human-readable description of preference */
- int ordinal; /**< ordinal number of this preference */
- int type; /**< type of that preference */
- gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
- union { /* The Qt preference code assumes that these will all be pointers (and unique) */
- guint *uint;
- gboolean *boolp;
- gint *enump;
- char **string;
- range_t **range;
- struct epan_uat* uat;
- color_t *colorp;
- GList** list;
- } varp; /**< pointer to variable storing the value */
- union {
- guint uint;
- gboolean boolval;
- gint enumval;
- char *string;
- range_t *range;
- color_t color;
- GList* list;
- } stashed_val; /**< original value, when editing from the GUI */
- union {
- guint uint;
- gboolean boolval;
- gint enumval;
- char *string;
- range_t *range;
- color_t color;
- GList* list;
- } default_val; /**< the default value of the preference */
- union {
- guint base; /**< input/output base, for PREF_UINT */
- guint32 max_value; /**< maximum value of a range */
- struct {
- const enum_val_t *enumvals; /**< list of name & values */
- gboolean radio_buttons; /**< TRUE if it should be shown as
- radio buttons rather than as an
- option menu or combo box in
- the preferences tab */
- } enum_info; /**< for PREF_ENUM */
- } info; /**< display/text file information */
- struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
- void *control; /**< handle for GUI control for this preference. GTK+ only? */
-};
-
/* read_prefs_file: read in a generic config file and do a callback to */
/* pref_set_pair_fct() for every key/value pair found */
/**
*/
typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, const gchar *value, void *private_data, gboolean return_range_errors);
-/** Set the value of a string-like preference. */
WS_DLL_PUBLIC
-void
-prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed);
+const char* prefs_get_description(pref_t *pref);
-/** Set the value of a range preference. Return FALSE on error, TRUE otherwise. */
WS_DLL_PUBLIC
-gboolean
-prefs_set_range_value(pref_t *pref, const gchar *value, gboolean *changed);
+const char* prefs_get_title(pref_t *pref);
WS_DLL_PUBLIC
-gboolean
-prefs_set_stashed_range_value(pref_t *pref, const gchar *value);
+const char* prefs_get_name(pref_t *pref);
WS_DLL_PUBLIC
-gboolean
-prefs_set_stashed_range(pref_t *pref, range_t *value);
+int prefs_get_type(pref_t *pref);
WS_DLL_PUBLIC
-range_t *
-prefs_get_stashed_range(pref_t *pref);
+gui_type_t prefs_get_gui_type(pref_t *pref);
+
+WS_DLL_PUBLIC guint32 prefs_get_max_value(pref_t *pref);
+
+/* Bitmask of flags for the effect of a preference in Wireshark */
+#define PREF_EFFECT_DISSECTION (1u << 0)
+#define PREF_EFFECT_CAPTURE (1u << 1)
+#define PREF_EFFECT_GUI (1u << 2)
+#define PREF_EFFECT_FONT (1u << 3)
+#define PREF_EFFECT_GUI_LAYOUT (1u << 4)
+#define PREF_EFFECT_CUSTOM (1u << 31)
+
+/** Fetch flags that show the effect of the preference
+ *
+ * @param pref A preference.
+ *
+ * @return A bitmask of the types of things the preference will
+ * effect.
+ */
+WS_DLL_PUBLIC
+unsigned int prefs_get_effect_flags(pref_t *pref);
+
+/** Set flags for the effect of the preference
+ * The intention is to distinguish preferences that affect
+ * dissection from those that don't. A bitmask was added to
+ * provide greater flexibility in the types of effects
+ * preferences can have.
+ *
+ * @param pref A preference.
+ * @param flags Bitmask of flags to apply to preference. Note that flags
+ * must be non-zero to ensure preference is properly saved to disk.
+ *
+ */
+WS_DLL_PUBLIC
+void prefs_set_effect_flags(pref_t *pref, unsigned int flags);
+
+/** Same as prefs_set_effect_flags, just different way to get preference
+ */
+WS_DLL_PUBLIC
+void prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags);
+
+/** Fetch flags that show module's preferences effect
+ * The flag values of the module will be applied to any individual preferences
+ * of the module when they are created
+ *
+ * @param module A preference module.
+ *
+ * @return A bitmask of the types of things the module's preferences will
+ * effect.
+ */
+WS_DLL_PUBLIC
+unsigned int prefs_get_module_effect_flags(module_t * module);
+
+/** Set flags for module's preferences effect
+ * The intention is to distinguish preferences that affect
+ * dissection from those that don't. Since modules are a grouping
+ * of preferences, it's likely that a whole module will want the
+ * same flags for its preferences. The flag values of the module will
+ * be applied to any individual preferences of the module when they
+ * are created
+ *
+ * @param module A preference module.
+ * @param flags Bitmask of flags to apply to module. Note that flags
+ * must be non-zero to ensure preferences are properly saved to disk.
+ *
+ */
+WS_DLL_PUBLIC
+void prefs_set_module_effect_flags(module_t * module, unsigned int flags);
+
+WS_DLL_PUBLIC
+gboolean prefs_set_range_value_work(pref_t *pref, const gchar *value,
+ gboolean return_range_errors, unsigned int *changed_flags);
+
+WS_DLL_PUBLIC
+unsigned int
+prefs_set_stashed_range_value(pref_t *pref, const gchar *value);
/** Add a range value of a range preference. */
WS_DLL_PUBLIC
void
prefs_range_remove_value(pref_t *pref, guint32 val);
-/** Set the value of an enum preference. */
-WS_DLL_PUBLIC
-void
-prefs_set_enum_value(pref_t *pref, const gchar *value, gboolean *changed);
+
+WS_DLL_PUBLIC unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source);
+WS_DLL_PUBLIC gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source);
+WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
+
+WS_DLL_PUBLIC unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source);
+WS_DLL_PUBLIC guint prefs_get_uint_base(pref_t *pref);
+WS_DLL_PUBLIC guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source);
+
+
+WS_DLL_PUBLIC unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source);
+WS_DLL_PUBLIC gint prefs_get_enum_value(pref_t *pref, pref_source_t source);
+WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
+WS_DLL_PUBLIC gboolean prefs_get_enum_radiobuttons(pref_t *pref);
+
+WS_DLL_PUBLIC gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
+WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
+
+WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
+WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);
+
+WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);
+
+WS_DLL_PUBLIC gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source);
+WS_DLL_PUBLIC range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source);
+
+WS_DLL_PUBLIC gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace);
+WS_DLL_PUBLIC gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default);
+
+WS_DLL_PUBLIC void reset_pref(pref_t *pref);
/** read the preferences file (or similar) and call the callback
* function to set each key/value pair found