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; }
void ManageInterfacesDialog::on_buttonBox_accepted() { pipeAccepted(); localAccepted(); #ifdef HAVE_PCAP_REMOTE remoteAccepted(); #endif prefs_main_write(); emit ifsChanged(); }
void FilterExpressionFrame::on_okButton_clicked() { QByteArray label_ba = ui->labelLineEdit->text().toUtf8(); QByteArray expr_ba = ui->displayFilterLineEdit->text().toUtf8(); filter_expression_new(label_ba.constData(), expr_ba.constData(), TRUE); on_cancelButton_clicked(); emit filterExpressionsChanged(); prefs_main_write(); }
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; }
void ProtocolPreferencesMenu::enumPreferenceTriggered() { EnumPreferenceAction *epa = static_cast<EnumPreferenceAction *>(QObject::sender()); if (!epa) return; if (epa->setEnumValue()) { // Changed prefs_apply(module_); if (!prefs.gui_use_pref_save) { prefs_main_write(); } wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged); } }
void PreferenceEditorFrame::on_okButton_clicked() { bool apply = false; switch(pref_->type) { case PREF_UINT: if (pref_->stashed_val.uint != new_uint_) { pref_->stashed_val.uint = new_uint_; apply = true; } break; case PREF_STRING: if (new_str_.compare(pref_->stashed_val.string) != 0) { g_free(pref_->stashed_val.string); pref_->stashed_val.string = qstring_strdup(new_str_); apply = true; } break; case PREF_RANGE: if (!ranges_are_equal(pref_->stashed_val.range, new_range_)) { g_free(pref_->stashed_val.range); pref_->stashed_val.range = range_copy(new_range_); apply = true; } break; default: break; } if (apply && module_) { pref_unstash(pref_, &module_->prefs_changed); prefs_apply(module_); if (!prefs.gui_use_pref_save) { prefs_main_write(); } } on_cancelButton_clicked(); // Emit signals once UI is hidden if (apply) { wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged); wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged); } }
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 CaptureInterfacesDialog::saveOptionsToPreferences() { interface_t device; gchar *new_prefs, *tmp_prefs; for (int col = LINK; col <= FILTER; col++){ if (ui->tbInterfaces->isColumnHidden(col)) { continue; } /* All entries are separated by comma. There is also one before the first interface to be able to identify word boundaries. As 'lo' is part of 'nflog' an exact match is necessary. */ switch (col) { case LINK: new_prefs = (gchar *)g_malloc0(MAX_VAL_LEN); for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); if (device.active_dlt == -1) { continue; } g_strlcat(new_prefs, ",", MAX_VAL_LEN); tmp_prefs = g_strdup_printf("%s(%d)", device.name, device.active_dlt); g_strlcat(new_prefs, tmp_prefs, MAX_VAL_LEN); g_free(tmp_prefs); } g_free(prefs.capture_devices_linktypes); prefs.capture_devices_linktypes = new_prefs; break; #if defined(_WIN32) || defined(HAVE_PCAP_CREATE) case BUFFER: new_prefs = (gchar *)g_malloc0(MAX_VAL_LEN); for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); if (device.buffer == -1) { continue; } g_strlcat(new_prefs, ",", MAX_VAL_LEN); tmp_prefs = g_strdup_printf("%s(%d)", device.name, device.buffer); g_strlcat(new_prefs, tmp_prefs, MAX_VAL_LEN); g_free(tmp_prefs); } g_free(prefs.capture_devices_buffersize); prefs.capture_devices_buffersize = new_prefs; break; #endif case SNAPLEN: new_prefs = (gchar *)g_malloc0(MAX_VAL_LEN); for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); g_strlcat(new_prefs, ",", MAX_VAL_LEN); tmp_prefs = g_strdup_printf("%s:%d(%d)", device.name, device.has_snaplen, (device.has_snaplen?device.snaplen:WTAP_MAX_PACKET_SIZE)); g_strlcat(new_prefs, tmp_prefs, MAX_VAL_LEN); g_free(tmp_prefs); } g_free(prefs.capture_devices_snaplen); prefs.capture_devices_snaplen = new_prefs; break; case PMODE: new_prefs = (gchar *)g_malloc0(MAX_VAL_LEN); for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); if (device.pmode == -1) { continue; } g_strlcat(new_prefs, ",", MAX_VAL_LEN); tmp_prefs = g_strdup_printf("%s(%d)", device.name, device.pmode); g_strlcat(new_prefs, tmp_prefs, MAX_VAL_LEN); g_free(tmp_prefs); } g_free(prefs.capture_devices_pmode); prefs.capture_devices_pmode = new_prefs; break; #ifdef HAVE_PCAP_CREATE case MONITOR: new_prefs = (gchar *)g_malloc0(MAX_VAL_LEN); for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); if (!device.monitor_mode_supported || (device.monitor_mode_supported && !device.monitor_mode_enabled)) { continue; } g_strlcat(new_prefs, ",", MAX_VAL_LEN); tmp_prefs = g_strdup_printf("%s", device.name); g_strlcat(new_prefs, tmp_prefs, MAX_VAL_LEN); g_free(tmp_prefs); } g_free(prefs.capture_devices_monitor_mode); prefs.capture_devices_monitor_mode = new_prefs; break; #endif case FILTER: new_prefs = (gchar *)g_malloc0(MAX_VAL_LEN); for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); if (!device.cfilter) { continue; } g_strlcat(new_prefs, ",", MAX_VAL_LEN); tmp_prefs = g_strdup_printf("%s(%s)", device.name, device.cfilter); g_strlcat(new_prefs, tmp_prefs, MAX_VAL_LEN); g_free(tmp_prefs); } g_free(prefs.capture_devices_filter); prefs.capture_devices_filter = new_prefs; break; } } if (!prefs.gui_use_pref_save) { prefs_main_write(); } }
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(); }