diff --git a/fscomm/preferences/prefsofia.cpp b/fscomm/preferences/prefsofia.cpp index c2c49410ca..0cfb1c24d2 100644 --- a/fscomm/preferences/prefsofia.cpp +++ b/fscomm/preferences/prefsofia.cpp @@ -6,71 +6,124 @@ PrefSofia::PrefSofia(Ui::PrefDialog *ui, QObject *parent) : QObject(parent), _ui(ui) { - _settings = new QSettings(); } void PrefSofia::readConfig() { + QSettings settings; int guess_mask; char guess_ip[80]; switch_find_local_ip(guess_ip, sizeof(guess_ip), &guess_mask, AF_INET); _ui->sofiaRtpIpEdit->setText(QString(guess_ip)); _ui->sofiaSipIpEdit->setText(QString(guess_ip)); + + settings.beginGroup("FreeSWITCH/conf"); + settings.beginGroup("sofia.conf"); + + /* General Settings */ + settings.beginGroup("global_settings/params"); + _ui->sofiaLogLevelSpin->setValue(settings.value("log-level").toInt()); + _ui->sofiaAutoRestartCombo->setCurrentIndex(_ui->sofiaAutoRestartCombo->findText(settings.value("auto-restart").toString())); + _ui->sofiaDebugPresenceSpin->setValue(settings.value("debug-presence").toInt()); + _ui->sofiaRewriteMulticastedFsPathCombo->setCurrentIndex(_ui->sofiaRewriteMulticastedFsPathCombo->findText(settings.value("rewrite-multicasted-fs-path").toString())); + settings.endGroup(); + + /* Profile settings */ + settings.beginGroup("profiles"); + settings.beginGroup("profile"); + + + settings.beginGroup("settings/params"); + _ui->sofiaUserAgentStringEdit->setText(settings.value("user-agent-string").toString()); + _ui->sofiaDebugSpin->setValue(settings.value("debug").toInt()); + _ui->sofiaSipTraceCombo->setCurrentIndex(_ui->sofiaSipTraceCombo->findText(settings.value("sip-trace").toString())); + _ui->sofiaContextEdit->setText(settings.value("context").toString()); + _ui->sofiaRfc2833PtEdit->setText(settings.value("rfc2833-pt").toString()); + _ui->sofiaSipPortSpin->setValue(settings.value("sip-port").toInt()); + _ui->sofiaDialplanEdit->setText(settings.value("dialplan").toString()); + _ui->sofiaDtmfDurationSpin->setValue(settings.value("dtmf-duration").toInt()); + _ui->sofiaCodecPrefsEdit->setText(settings.value("codec-prefs").toString()); + _ui->sofiaUseRtpTimerCombo->setCurrentIndex(_ui->sofiaUseRtpTimerCombo->findText(settings.value("use-rtp-timer").toString())); + _ui->sofiaRtpTimerNameEdit->setText(settings.value("rtp-timer-name").toString()); + _ui->sofiaRtpIpEdit->setText(settings.value("rtp-ip").toString()); + _ui->sofiaSipIpEdit->setText(settings.value("sip-ip").toString()); + _ui->sofiaHoldMusicEdit->setText(settings.value("hold-music").toString()); + _ui->sofiaApplyNatAclEdit->setText(settings.value("apply-nat-acl").toString()); + _ui->sofiaManagePresenceCombo->setCurrentIndex(_ui->sofiaManagePresenceCombo->findText(settings.value("manage-presence").toString())); + _ui->sofiaMaxProceedingEdit->setValue(settings.value("max-proceeding").toInt()); + _ui->sofiaInboundCodecNegotiationCombo->setCurrentIndex(_ui->sofiaInboundCodecNegotiationCombo->findText(settings.value("inbound-codec-negotiation").toString())); + _ui->sofiaNonceTtlSpin->setValue(settings.value("nonce-ttl").toInt()); + _ui->sofiaAuthCallsCombo->setCurrentIndex(_ui->sofiaAuthCallsCombo->findText(settings.value("auth-calls").toString())); + _ui->sofiaAuthAllPacketsCombo->setCurrentIndex(_ui->sofiaAuthAllPacketsCombo->findText(settings.value("auth-all-packets").toString())); + _ui->sofiaExtRtpIpEdit->setText(settings.value("ext-rtp-ip").toString()); + _ui->sofiaExtSipIpEdit->setText(settings.value("ext-sip-ip").toString()); + _ui->sofiaRtpTimeoutSecSpin->setValue(settings.value("rtp-timeout-sec").toInt()); + _ui->sofiaRtpHoldTimeoutSecSpin->setValue(settings.value("rtp-hold-timeout-sec").toInt()); + _ui->sofiaDisableRegisterCombo->setCurrentIndex(_ui->sofiaDisableRegisterCombo->findText(settings.value("disable-register").toString())); + _ui->sofiaChallengeRealmCombo->setCurrentIndex(_ui->sofiaChallengeRealmCombo->findText(settings.value("challenge-realm").toString())); + settings.endGroup(); + + settings.endGroup(); + settings.endGroup(); + settings.endGroup(); + settings.endGroup(); + } void PrefSofia::writeConfig() { - _settings->beginGroup("FreeSWITCH/conf"); - _settings->beginGroup("sofia.conf"); + QSettings settings; + settings.beginGroup("FreeSWITCH/conf"); + settings.beginGroup("sofia.conf"); /* General Settings */ - _settings->beginGroup("global_settings/params"); - _settings->setValue("log-level", _ui->sofiaLogLevelSpin->value()); - _settings->setValue("auto-restart", _ui->sofiaAutoRestartCombo->currentText()); - _settings->setValue("debug-presence", _ui->sofiaDebugPresenceSpin->value()); - _settings->setValue("rewrite-multicasted-fs-path", _ui->sofiaRewriteMulticastedFsPathCombo->currentText()); - _settings->endGroup(); + settings.beginGroup("global_settings/params"); + settings.setValue("log-level", _ui->sofiaLogLevelSpin->value()); + settings.setValue("auto-restart", _ui->sofiaAutoRestartCombo->currentText()); + settings.setValue("debug-presence", _ui->sofiaDebugPresenceSpin->value()); + settings.setValue("rewrite-multicasted-fs-path", _ui->sofiaRewriteMulticastedFsPathCombo->currentText()); + settings.endGroup(); /* Profile settings */ - _settings->beginGroup("profiles"); - _settings->beginGroup("profile"); + settings.beginGroup("profiles"); + settings.beginGroup("profile"); - _settings->beginGroup("attrs"); - _settings->setValue("name", "softphone"); - _settings->endGroup(); + settings.beginGroup("attrs"); + settings.setValue("name", "softphone"); + settings.endGroup(); - _settings->beginGroup("settings/params"); - _settings->setValue("user-agent-string", _ui->sofiaUserAgentStringEdit->text()); - _settings->setValue("debug", _ui->sofiaDebugSpin->value()); - _settings->setValue("sip-trace", _ui->sofiaSipTraceCombo->currentText()); - _settings->setValue("context", _ui->sofiaContextEdit->text()); - _settings->setValue("rfc2833-pt", _ui->sofiaRfc2833PtEdit->text()); - _settings->setValue("sip-port", _ui->sofiaSipPortSpin->value()); - _settings->setValue("dialplan", _ui->sofiaDialplanEdit->text()); - _settings->setValue("dtmf-duration", _ui->sofiaDtmfDurationSpin->value()); - _settings->setValue("codec-prefs", _ui->sofiaCodecPrefsEdit->text()); - _settings->setValue("use-rtp-timer", _ui->sofiaUseRtpTimerCombo->currentText()); - _settings->setValue("rtp-timer-name", _ui->sofiaRtpTimerNameEdit->text()); - _settings->setValue("rtp-ip", _ui->sofiaRtpIpEdit->text()); - _settings->setValue("sip-ip", _ui->sofiaSipIpEdit->text()); - _settings->setValue("hold-music", _ui->sofiaHoldMusicEdit->text()); - _settings->setValue("apply-nat-acl", _ui->sofiaApplyNatAclEdit->text()); - _settings->setValue("manage-presence", _ui->sofiaManagePresenceCombo->currentText()); - _settings->setValue("max-proceeding", _ui->sofiaMaxProceedingEdit->text()); - _settings->setValue("inbound-codec-negotiation", _ui->sofiaInboundCodecNegotiationCombo->currentText()); - _settings->setValue("nonce-ttl", _ui->sofiaNonceTtlSpin->value()); - _settings->setValue("auth-calls", _ui->sofiaAuthCallsCombo->currentText()); - _settings->setValue("auth-all-packets", _ui->sofiaAuthAllPacketsCombo->currentText()); - _settings->setValue("ext-rtp-ip", _ui->sofiaExtRtpIpEdit->text()); - _settings->setValue("ext-sip-ip", _ui->sofiaExtSipIpEdit->text()); - _settings->setValue("rtp-timeout-sec", _ui->sofiaRtpTimeoutSecSpin->value()); - _settings->setValue("rtp-hold-timeout-sec", _ui->sofiaRtpHoldTimeoutSecSpin->value()); - _settings->setValue("disable-register", _ui->sofiaDisableRegisterCombo->currentText()); - _settings->setValue("challenge-realm", _ui->sofiaChallengeRealmCombo->currentText()); - _settings->endGroup(); + settings.beginGroup("settings/params"); + settings.setValue("user-agent-string", _ui->sofiaUserAgentStringEdit->text()); + settings.setValue("debug", _ui->sofiaDebugSpin->value()); + settings.setValue("sip-trace", _ui->sofiaSipTraceCombo->currentText()); + settings.setValue("context", _ui->sofiaContextEdit->text()); + settings.setValue("rfc2833-pt", _ui->sofiaRfc2833PtEdit->text()); + settings.setValue("sip-port", _ui->sofiaSipPortSpin->value()); + settings.setValue("dialplan", _ui->sofiaDialplanEdit->text()); + settings.setValue("dtmf-duration", _ui->sofiaDtmfDurationSpin->value()); + settings.setValue("codec-prefs", _ui->sofiaCodecPrefsEdit->text()); + settings.setValue("use-rtp-timer", _ui->sofiaUseRtpTimerCombo->currentText()); + settings.setValue("rtp-timer-name", _ui->sofiaRtpTimerNameEdit->text()); + settings.setValue("rtp-ip", _ui->sofiaRtpIpEdit->text()); + settings.setValue("sip-ip", _ui->sofiaSipIpEdit->text()); + settings.setValue("hold-music", _ui->sofiaHoldMusicEdit->text()); + settings.setValue("apply-nat-acl", _ui->sofiaApplyNatAclEdit->text()); + settings.setValue("manage-presence", _ui->sofiaManagePresenceCombo->currentText()); + settings.setValue("max-proceeding", _ui->sofiaMaxProceedingEdit->text()); + settings.setValue("inbound-codec-negotiation", _ui->sofiaInboundCodecNegotiationCombo->currentText()); + settings.setValue("nonce-ttl", _ui->sofiaNonceTtlSpin->value()); + settings.setValue("auth-calls", _ui->sofiaAuthCallsCombo->currentText()); + settings.setValue("auth-all-packets", _ui->sofiaAuthAllPacketsCombo->currentText()); + settings.setValue("ext-rtp-ip", _ui->sofiaExtRtpIpEdit->text()); + settings.setValue("ext-sip-ip", _ui->sofiaExtSipIpEdit->text()); + settings.setValue("rtp-timeout-sec", _ui->sofiaRtpTimeoutSecSpin->value()); + settings.setValue("rtp-hold-timeout-sec", _ui->sofiaRtpHoldTimeoutSecSpin->value()); + settings.setValue("disable-register", _ui->sofiaDisableRegisterCombo->currentText()); + settings.setValue("challenge-realm", _ui->sofiaChallengeRealmCombo->currentText()); + settings.endGroup(); - _settings->endGroup(); - _settings->endGroup(); - _settings->endGroup(); - _settings->endGroup(); + settings.endGroup(); + settings.endGroup(); + settings.endGroup(); + settings.endGroup(); } diff --git a/fscomm/preferences/prefsofia.h b/fscomm/preferences/prefsofia.h index e08ae663f0..f5f12d64ca 100644 --- a/fscomm/preferences/prefsofia.h +++ b/fscomm/preferences/prefsofia.h @@ -4,8 +4,6 @@ #include #include "ui_prefdialog.h" -class QSettings; - class PrefSofia : public QObject { Q_OBJECT @@ -15,7 +13,6 @@ public: void readConfig(); private: - QSettings *_settings; Ui::PrefDialog *_ui; };