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(); prefs_apply_all(); prefs_to_capture_opts(); } return TRUE; }
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(const char * module_name, const char *pref_name, const char *pref_value) { module_t * module = NULL; pref_t * pref = NULL; gboolean pref_changed = TRUE; if ( ! prefs_is_registered_protocol(module_name)) return FALSE; module = prefs_find_module(module_name); if ( ! module ) return FALSE; pref = prefs_find_preference(module, pref_name); if (!pref) return FALSE; if ( pref->type == PREF_STRING ) { g_free((void *)pref->stashed_val.string); pref->stashed_val.string = (gchar *) g_strdup(pref_value); /* unstash - taken from preferences_util */ if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) { pref_changed = TRUE; g_free(*pref->varp.string); *pref->varp.string = g_strdup(pref->stashed_val.string); } } if ( pref_changed ) { prefs_main_write(); prefs_apply_all(); prefs_to_capture_opts(); } return TRUE; }
void WiresharkApplication::setConfigurationProfile(const gchar *profile_name) { char *gdp_path, *dp_path; char *rf_path; int rf_open_errno; gchar *err_msg = NULL; /* First check if profile exists */ if (!profile_exists(profile_name, FALSE)) { if (profile_exists(profile_name, TRUE)) { char *pf_dir_path, *pf_dir_path2, *pf_filename; /* Copy from global profile */ if (create_persconffile_profile(profile_name, &pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory\n\"%s\":\n%s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); } if (copy_persconffile_profile(profile_name, profile_name, TRUE, &pf_filename, &pf_dir_path, &pf_dir_path2) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.", pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno)); g_free(pf_filename); g_free(pf_dir_path); g_free(pf_dir_path2); } } else { /* No personal and no global profile exists */ return; } } /* Then check if changing to another profile */ if (profile_name && strcmp (profile_name, get_profile_name()) == 0) { return; } /* Get the current geometry, before writing it to disk */ emit profileChanging(); if (profile_exists(get_profile_name(), FALSE)) { /* Write recent file for profile we are leaving, if it still exists */ write_profile_recent(); } /* Set profile name and update the status bar */ set_profile_name (profile_name); emit profileNameChanged(profile_name); /* Apply new preferences */ readConfigurationFiles (&gdp_path, &dp_path, true); if (!recent_read_profile_static(&rf_path, &rf_open_errno)) { simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "Could not open common recent file\n\"%s\": %s.", rf_path, g_strerror(rf_open_errno)); g_free(rf_path); } if (recent.gui_fileopen_remembered_dir && test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) { set_last_open_dir(recent.gui_fileopen_remembered_dir); } timestamp_set_type (recent.gui_time_format); timestamp_set_precision(recent.gui_time_precision); timestamp_set_seconds_type (recent.gui_seconds_format); packet_list_enable_color(recent.packet_list_colorize); tap_update_timer_.setInterval(prefs.tap_update_interval); prefs_to_capture_opts(); prefs_apply_all(); #ifdef HAVE_LIBPCAP update_local_interfaces(); #endif setMonospaceFont(prefs.gui_qt_font_name); emit columnsChanged(); emit preferencesChanged(); emit recentFilesRead(); emit filterExpressionsChanged(); emit checkDisplayFilter(); /* Enable all protocols and disable from the disabled list */ proto_enable_all(); if (gdp_path == NULL && dp_path == NULL) { set_disabled_protos_list(); set_disabled_heur_dissector_list(); } /* Reload color filters */ if (!color_filters_reload(&err_msg, color_filter_add_cb)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg); g_free(err_msg); } emit localInterfaceListChanged(); emit packetDissectionChanged(); }
void WiresharkApplication::setConfigurationProfile(const gchar *profile_name) { char *gdp_path, *dp_path; char *rf_path; int rf_open_errno; /* First check if profile exists */ if (!profile_exists(profile_name, FALSE)) { if (profile_exists(profile_name, TRUE)) { char *pf_dir_path, *pf_dir_path2, *pf_filename; /* Copy from global profile */ if (create_persconffile_profile(profile_name, &pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory\n\"%s\":\n%s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); } if (copy_persconffile_profile(profile_name, profile_name, TRUE, &pf_filename, &pf_dir_path, &pf_dir_path2) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.", pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno)); g_free(pf_filename); g_free(pf_dir_path); g_free(pf_dir_path2); } } else { /* No personal and no global profile exists */ return; } } /* Then check if changing to another profile */ if (profile_name && strcmp (profile_name, get_profile_name()) == 0) { return; } /* Get the current geometry, before writing it to disk */ emit profileChanging(); if (profile_exists(get_profile_name(), FALSE)) { /* Write recent file for profile we are leaving, if it still exists */ write_profile_recent(); } /* Set profile name and update the status bar */ set_profile_name (profile_name); emit profileNameChanged(profile_name); /* Reset current preferences and apply the new */ prefs_reset(); // menu_prefs_reset(); (void) readConfigurationFiles (&gdp_path, &dp_path); recent_read_profile_static(&rf_path, &rf_open_errno); if (rf_path != NULL && rf_open_errno != 0) { simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "Could not open common recent file\n\"%s\": %s.", rf_path, g_strerror(rf_open_errno)); } if (recent.gui_fileopen_remembered_dir && test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) { set_last_open_dir(recent.gui_fileopen_remembered_dir); } timestamp_set_type (recent.gui_time_format); timestamp_set_seconds_type (recent.gui_seconds_format); color_filters_enable(recent.packet_list_colorize); tap_update_timer_.setInterval(prefs.tap_update_interval); prefs_to_capture_opts(); prefs_apply_all(); emit preferencesChanged(); emit columnsChanged(); emit recentFilesRead(); emit filterExpressionsChanged(); // macros_post_update(); /* Enable all protocols and disable from the disabled list */ proto_enable_all(); if (gdp_path == NULL && dp_path == NULL) { set_disabled_protos_list(); set_disabled_heur_dissector_list(); } /* Reload color filters */ color_filters_reload(); // user_font_apply(); /* Update menus with new recent values */ // menu_recent_read_finished(); }
void PreferencesDialog::on_buttonBox_accepted() { gchar* err = NULL; unsigned int redissect_flags = 0; // XXX - We should validate preferences as the user changes them, not here. // XXX - We're also too enthusiastic about setting must_redissect. prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer)&redissect_flags); if (redissect_flags & PREF_EFFECT_GUI_LAYOUT) { // Layout type changed, reset sizes recent.gui_geometry_main_upper_pane = 0; recent.gui_geometry_main_lower_pane = 0; } pd_ui_->columnFrame->unstash(); pd_ui_->filterExpressonsFrame->acceptChanges(); pd_ui_->expertFrame->acceptChanges(); //Filter expressions don't affect dissection, so there is no need to //send any events to that effect. However, the app needs to know //about any button changes. wsApp->emitAppSignal(WiresharkApplication::FilterExpressionsChanged); prefs_main_write(); if (save_decode_as_entries(&err) < 0) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err); g_free(err); } write_language_prefs(); wsApp->loadLanguage(QString(language)); #ifdef HAVE_AIRPCAP /* * Load the Wireshark decryption keys (just set) and save * the changes to the adapters' registry */ //airpcap_load_decryption_keys(airpcap_if_list); #endif // gtk/prefs_dlg.c:prefs_main_apply_all /* * Apply the protocol preferences first - "gui_prefs_apply()" could * cause redissection, and we have to make sure the protocol * preference changes have been fully applied. */ prefs_apply_all(); /* Fill in capture options with values from the preferences */ prefs_to_capture_opts(); #ifdef HAVE_AIRPCAP // prefs_airpcap_update(); #endif wsApp->setMonospaceFont(prefs.gui_qt_font_name); if (redissect_flags & PREF_EFFECT_DISSECTION) { /* Redissect all the packets, and re-evaluate the display filter. */ wsApp->queueAppSignal(WiresharkApplication::PacketDissectionChanged); } wsApp->queueAppSignal(WiresharkApplication::PreferencesChanged); if (redissect_flags & PREF_EFFECT_GUI_LAYOUT) { wsApp->queueAppSignal(WiresharkApplication::RecentPreferencesRead); } if (prefs.capture_no_extcap != saved_capture_no_extcap_) wsApp->refreshLocalInterfaces(); }