summaryrefslogtreecommitdiffstats
path: root/ui/preference_utils.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:33 +0000
commit9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9 (patch)
tree2784370cda9bbf2da9114d70f05399c0b229d28c /ui/preference_utils.c
parentAdding debian version 4.2.6-1. (diff)
downloadwireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.tar.xz
wireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.zip
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--ui/preference_utils.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/ui/preference_utils.c b/ui/preference_utils.c
index 751b47b8..992596a7 100644
--- a/ui/preference_utils.c
+++ b/ui/preference_utils.c
@@ -38,6 +38,7 @@ prefs_to_capture_opts(void)
/* Set promiscuous mode from the preferences setting. */
/* the same applies to other preferences settings as well. */
global_capture_opts.default_options.promisc_mode = prefs.capture_prom_mode;
+ global_capture_opts.default_options.monitor_mode = prefs.capture_monitor_mode;
global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
global_capture_opts.show_info = prefs.capture_show_info;
global_capture_opts.real_time_mode = prefs.capture_real_time;
@@ -93,7 +94,7 @@ prefs_store_ext_helper(const char * module_name, const char *pref_name, const ch
if (!pref)
return 0;
- if (prefs_get_type(pref) == PREF_STRING )
+ if (prefs_get_type(pref) == PREF_STRING || prefs_get_type(pref) == PREF_DISSECTOR)
{
pref_changed |= prefs_set_string_value(pref, pref_value, pref_stashed);
if ( !pref_changed || prefs_get_string_value(pref, pref_stashed) != 0 )
@@ -123,10 +124,10 @@ prefs_store_ext(const char * module_name, const char *pref_name, const char *pre
return 0;
}
-gboolean
+bool
prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
{
- gboolean pref_changed = FALSE;
+ bool pref_changed = false;
GList * keys = NULL;
if ( !prefs_is_registered_protocol(module))
@@ -138,13 +139,13 @@ prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
for ( GList * key = keys; key != NULL; key = g_list_next(key) )
{
- gchar * pref_name = (gchar *)key->data;
- gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, key->data);
+ char * pref_name = (char *)key->data;
+ char * pref_value = (char *) g_hash_table_lookup(pref_values, key->data);
if ( pref_name && pref_value )
{
if ( prefs_store_ext_helper(module, pref_name, pref_value) )
- pref_changed = TRUE;
+ pref_changed = true;
}
}
g_list_free(keys);
@@ -156,15 +157,15 @@ prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
prefs_to_capture_opts();
}
- return TRUE;
+ return true;
}
-gint
-column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields, gint position)
+int
+column_prefs_add_custom(int fmt, const char *title, const char *custom_fields, int position)
{
GList *clp;
fmt_data *cfmt, *last_cfmt;
- gint colnr;
+ int colnr;
cfmt = g_new(fmt_data, 1);
/*
@@ -176,17 +177,18 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields
cfmt->fmt = fmt;
cfmt->custom_fields = g_strdup(custom_fields);
cfmt->custom_occurrence = 0;
- cfmt->resolved = TRUE;
+ cfmt->resolved = true;
colnr = g_list_length(prefs.col_list);
if (custom_fields) {
- cfmt->visible = TRUE;
+ cfmt->visible = true;
clp = g_list_last(prefs.col_list);
last_cfmt = (fmt_data *) clp->data;
if (position > 0 && position <= colnr) {
/* Custom fields may be added at any position, depending on the given argument */
- prefs.col_list = g_list_insert(prefs.col_list, cfmt, position);
+ colnr = position;
+ prefs.col_list = g_list_insert(prefs.col_list, cfmt, colnr);
} else if (last_cfmt->fmt == COL_INFO) {
/* Last column is COL_INFO, add custom column before this */
colnr -= 1;
@@ -195,21 +197,22 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
} else {
- cfmt->visible = FALSE; /* Will be set to TRUE in visible_toggled() when added to list */
+ cfmt->visible = false; /* Will be set to true in visible_toggled() when added to list */
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
+ recent_insert_column(colnr);
return colnr;
}
-gint
-column_prefs_has_custom(const gchar *custom_field)
+int
+column_prefs_has_custom(const char *custom_field)
{
GList *clp;
fmt_data *cfmt;
- gint colnr = -1;
+ int colnr = -1;
- for (gint i = 0; i < prefs.num_cols; i++) {
+ for (int i = 0; i < prefs.num_cols; i++) {
clp = g_list_nth(prefs.col_list, i);
if (clp == NULL) /* Sanity check, invalid column requested */
continue;
@@ -224,25 +227,25 @@ column_prefs_has_custom(const gchar *custom_field)
return colnr;
}
-gboolean
-column_prefs_custom_resolve(const gchar* custom_field)
+bool
+column_prefs_custom_resolve(const char* custom_field)
{
- gchar **fields;
+ char **fields;
header_field_info *hfi;
bool resolve = false;
fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX, custom_field,
- (GRegexCompileFlags) (G_REGEX_ANCHORED | G_REGEX_RAW),
- G_REGEX_MATCH_ANCHORED);
+ (GRegexCompileFlags) (G_REGEX_RAW),
+ 0);
- for (guint i = 0; i < g_strv_length(fields); i++) {
+ for (unsigned i = 0; i < g_strv_length(fields); i++) {
if (fields[i] && *fields[i]) {
hfi = proto_registrar_get_byname(fields[i]);
if (hfi && ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_ETHER) || (hfi->type == FT_IPv4) || (hfi->type == FT_IPv6) || (hfi->type == FT_FCWWN) || (hfi->type == FT_BOOLEAN) ||
((hfi->strings != NULL) &&
(FT_IS_INT(hfi->type) || FT_IS_UINT(hfi->type)))))
{
- resolve = TRUE;
+ resolve = true;
break;
}
}
@@ -270,12 +273,13 @@ column_prefs_remove_link(GList *col_link)
}
void
-column_prefs_remove_nth(gint col)
+column_prefs_remove_nth(int col)
{
column_prefs_remove_link(g_list_nth(prefs.col_list, col));
+ recent_remove_column(col);
}
-void save_migrated_uat(const char *uat_name, gboolean *old_pref)
+void save_migrated_uat(const char *uat_name, bool *old_pref)
{
char *err = NULL;
@@ -287,7 +291,7 @@ void save_migrated_uat(const char *uat_name, gboolean *old_pref)
// Ensure that any old preferences are removed after successful migration.
if (*old_pref) {
- *old_pref = FALSE;
+ *old_pref = false;
prefs_main_write();
}
}