Some more house cleaning.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16192 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
João Mesquita committed 2010-01-07 05:19:36 +00:00
1 parent a7537a771d
commit fa9900bf72
6 files changed
+7 -7

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#include <QtGui>
#include "prefdialog.h"
#include "ui_prefdialog.h"
#include "prefportaudio.h"
PrefDialog::PrefDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PrefDialog)
{
ui->setupUi(this);
_settings = new QSettings();
connect(this, SIGNAL(accepted()), this, SLOT(writeConfig()));
_mod_portaudio = new PrefPortaudio(ui, this);
readConfig();
}
PrefDialog::~PrefDialog()
{
delete ui;
}
void PrefDialog::writeConfig()
{
_mod_portaudio->writeConfig();
}
void PrefDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void PrefDialog::readConfig()
{
_mod_portaudio->readConfig();
}
+35
View File
@@ -0,0 +1,35 @@
#ifndef PREFDIALOG_H
#define PREFDIALOG_H
#include <QDialog>
#include <QDomDocument>
#include <QSettings>
#include <fshost.h>
class PrefPortaudio;
namespace Ui {
class PrefDialog;
}
class PrefDialog : public QDialog {
Q_OBJECT
public:
PrefDialog(QWidget *parent = 0);
~PrefDialog();
protected:
void changeEvent(QEvent *e);
private slots:
void writeConfig();
private:
void readConfig();
QSettings *_settings;
Ui::PrefDialog *ui;
PrefPortaudio *_mod_portaudio;
};
#endif // PREFDIALOG_H
+942
View File
@@ -0,0 +1,942 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PrefDialog</class>
<widget class="QDialog" name="PrefDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>839</width>
<height>613</height>
</rect>
</property>
<property name="windowTitle">
<string>Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="listSections">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="iconSize">
<size>
<width>96</width>
<height>84</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="spacing">
<number>12</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<item>
<property name="text">
<string>General</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/pref_general.jpg</normaloff>:/images/pref_general.jpg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Sofia</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/pref_sip.png</normaloff>:/images/pref_sip.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>PortAudio</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/pref_audio.gif</normaloff>:/images/pref_audio.gif</iconset>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>User Information</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>CallerID Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="PaCallerIdNameEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>CallerID Number:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="PaCallerIdNumEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Global</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>log-level</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="sofiaLogLevelSpin"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>auto-restart</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="sofiaAutoRestartCombo">
<item>
<property name="text">
<string>true</string>
</property>
</item>
<item>
<property name="text">
<string>false</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>debug-presence</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="sofiaDebugPresenceSpin"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>rewrite-multicasted-fs-path</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="sofiaRewriteMulticastedFsPathCombo">
<item>
<property name="text">
<string>false</string>
</property>
</item>
<item>
<property name="text">
<string>true</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Profile</string>
</property>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>user-agent-string</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sofiaUserAgentStringEdit">
<property name="text">
<string>FreeSWITCH/FSComm</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>hold-music</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sofiaHoldMusicEdit">
<property name="text">
<string>localstream://moh</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>context</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="sofiaContextEdit">
<property name="text">
<string>public</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>dialplan</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="text">
<string>XML</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Network</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Softphone Profile</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>sip-port</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="sofiaSipPortSpin">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>12345</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>use-rtp-timer</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="sofiaUseRtpTimerCombo">
<item>
<property name="text">
<string>true</string>
</property>
</item>
<item>
<property name="text">
<string>false</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>rtp-ip</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="sofiaRtpIpEdit">
<property name="text">
<string>$${local_ip_v4}</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>sip-ip</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="sofiaSipIpEdit">
<property name="text">
<string>$${local_ip_v4}</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>apply-nat-acl</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="sofiaApplyNatAclEdit">
<property name="text">
<string>rfc1918</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_34">
<property name="text">
<string>ext-rtp-ip</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="sofiaExtRtpIpEdit">
<property name="text">
<string>stun:stun.freeswitch.org</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>ext-sip-ip</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="sofiaExtSipIpEdit">
<property name="text">
<string>stun:stun.freeswitch.org</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Codecs</string>
</attribute>
<layout class="QFormLayout" name="formLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>codec-prefs</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sofiaCodecPrefsEdit">
<property name="text">
<string>CELT@48000h,G7221@32000h,G7221@16000h,G722,PCMU,PCMA,GSM</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
<string>inbound-codec-negotiation</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="sofiaInboundCodecNegotiationCombo">
<item>
<property name="text">
<string>generous</string>
</property>
</item>
<item>
<property name="text">
<string>greedy</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Profile</string>
</property>
<layout class="QFormLayout" name="formLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>rfc2833-pt</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sofiaRfc2833PtEdit">
<property name="text">
<string>101</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>debug</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="sofiaDebugSpin"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>sip-trace</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="sofiaSipTraceCombo">
<item>
<property name="text">
<string>false</string>
</property>
</item>
<item>
<property name="text">
<string>true</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>dtmf-duration</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spinBox">
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>rtp-timer-name</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="sofiaRtpTimerNameEdit">
<property name="text">
<string>soft</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>manage-presence</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="sofiaManagePresenceCombo">
<item>
<property name="text">
<string>false</string>
</property>
</item>
<item>
<property name="text">
<string>true</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_29">
<property name="text">
<string>max-proceeding</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="sofiaMaxProceedingEdit">
<property name="value">
<number>3</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_31">
<property name="text">
<string>nonce-ttl</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="sofiaNonceTtlSpin">
<property name="value">
<number>60</number>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_36">
<property name="text">
<string>rtp-timeout-sec</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="sofiaRtpTimeoutSecSpin">
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>300</number>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_37">
<property name="text">
<string>rtp-hold-timeout-sec</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="sofiaRtpHoldTimeoutSecSpin">
<property name="maximum">
<number>5000</number>
</property>
<property name="value">
<number>1800</number>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>auth-calls</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="sofiaAuthCallsCombo">
<item>
<property name="text">
<string>false</string>
</property>
</item>
<item>
<property name="text">
<string>true</string>
</property>
</item>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_33">
<property name="text">
<string>auth-all-packets</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QComboBox" name="sofiaAuthAllPacketsCombo">
<item>
<property name="text">
<string>false</string>
</property>
</item>
<item>
<property name="text">
<string>true</string>
</property>
</item>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_38">
<property name="text">
<string>disable-register</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="sofiaDisableRegisterCombo">
<item>
<property name="text">
<string>true</string>
</property>
</item>
<item>
<property name="text">
<string>false</string>
</property>
</item>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_39">
<property name="text">
<string>challenge-realm</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QComboBox" name="sofiaChallengeRealmCombo">
<item>
<property name="text">
<string>auto_from</string>
</property>
</item>
<item>
<property name="text">
<string>auto_to</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Devices</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>indev</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="PaIndevCombo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>outdev</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="PaOutdevCombo"/>
</item>
<item>
<widget class="QPushButton" name="PaOutdevTestBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>86</width>
<height>27</height>
</size>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>rindgev</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="PaRingdevCombo"/>
</item>
<item>
<widget class="QPushButton" name="PaRingdevTestBtn">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximumSize">
<size>
<width>86</width>
<height>27</height>
</size>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Files</string>
</property>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>ring-file</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="PaRingFileEdit">
<property name="text">
<string>tone_stream://%(2000,4000,440.0,480.0);loops=20</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="PaRingFileBtn">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>ring-interval</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="PaRingIntervalSpin">
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>hold-file</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="PaHoldFileEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="PaHoldFileBtn">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PrefDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>544</x>
<y>224</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>246</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PrefDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>544</x>
<y>230</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>246</y>
</hint>
</hints>
</connection>
<connection>
<sender>listSections</sender>
<signal>currentRowChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>180</x>
<y>83</y>
</hint>
<hint type="destinationlabel">
<x>524</x>
<y>102</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+285
View File
@@ -0,0 +1,285 @@
#include <QtGui>
#include <fshost.h>
#include "prefportaudio.h"
PrefPortaudio::PrefPortaudio(Ui::PrefDialog *ui, QObject *parent) :
QObject(parent),
_ui(ui)
{
_settings = new QSettings();
connect(_ui->PaRingFileBtn, SIGNAL(clicked()), this, SLOT(ringFileChoose()));
connect(_ui->PaHoldFileBtn, SIGNAL(clicked()), this, SLOT(holdFileChoose()));
connect(_ui->PaOutdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(outdevChangeDev(int)));
connect(_ui->PaRingdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(ringdevChangeDev(int)));
connect(_ui->PaRingdevTestBtn, SIGNAL(clicked()), this, SLOT(ringdevTest()));
}
void PrefPortaudio::ringdevTest()
{
QString result;
if (g_FSHost.sendCmd("pa", QString("play %1/.fscomm/sounds/test.wav 0").arg(QDir::homePath()).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error testing ringdev on mod_portaudio! %s\n",
result.toAscii().constData());
}
}
void PrefPortaudio::ringdevChangeDev(int dev)
{
QString result;
if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev to #%d on mod_portaudio!\n", dev);
QMessageBox::critical(0, tr("Unable to change device."),
tr("There was an error changing the ringdev.\nPlease report this bug."),
QMessageBox::Ok);
}
}
void PrefPortaudio::outdevChangeDev(int dev)
{
QString result;
if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev to #%d on mod_portaudio!\n", dev);
QMessageBox::critical(0, tr("Unable to change device."),
tr("There was an error changing the outdev.\nPlease report this bug."),
QMessageBox::Ok);
}
}
void PrefPortaudio::holdFileChoose()
{
QString fileName = QFileDialog::getOpenFileName(0,
tr("Select file"),
QDir::homePath(),
NULL);
if (!fileName.isNull())
_ui->PaHoldFileEdit->setText(fileName);
}
void PrefPortaudio::ringFileChoose()
{
QString fileName = QFileDialog::getOpenFileName(0,
tr("Select file"),
QDir::homePath(),
NULL);
if (!fileName.isNull())
_ui->PaRingFileEdit->setText(fileName);
}
void PrefPortaudio::writeConfig()
{
_settings->beginGroup("FreeSWITCH/conf");
_settings->beginGroup("portaudio.conf");
QString cid_name = _settings->value("cid-name").toString();
QString ncid_name = _ui->PaCallerIdNameEdit->text();
QString cid_num = _settings->value("cid-num").toString();
QString ncid_num = _ui->PaCallerIdNumEdit->text();
QString hold_file = _settings->value("hold-file").toString();
QString nhold_file = _ui->PaHoldFileEdit->text();
QString ring_file = _settings->value("ring-file").toString();
QString nring_file = _ui->PaRingFileEdit->text();
int ring_interval = _settings->value("ring-interval").toInt();
int nring_interval = _ui->PaRingIntervalSpin->value();
QString result;
if (cid_name != ncid_name ||
cid_num != ncid_num ||
hold_file != nhold_file ||
ring_file != nring_file ||
ring_interval != nring_interval)
{
if (g_FSHost.sendCmd("reload", "mod_portaudio", &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("cid-name", ncid_name);
_settings->setValue("cid-num", ncid_num);
_settings->setValue("ring-file", nring_file);
_settings->setValue("ring-interval", nring_interval);
_settings->setValue("hold-file", nhold_file);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while issuing reload command to mod_portaudio!\n");
QMessageBox::critical(0, tr("Unable to save settings"),
tr("There was an error saving your settings.\nPlease report this bug."),
QMessageBox::Ok);
}
}
int nindev = _ui->PaIndevCombo->currentIndex();
int indev = _settings->value("indev").toInt();
int noutdev = _ui->PaOutdevCombo->currentIndex();
int outdev = _settings->value("outdev").toInt();
int nringdev = _ui->PaRingdevCombo->currentIndex();
int ringdev = _settings->value("ringdev").toInt();
if (nindev != indev)
{
if (g_FSHost.sendCmd("pa", QString("indev #%1").arg(nindev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("indev", nindev);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting indev from #%d to #%d on mod_portaudio!\n",
indev, nindev);
QMessageBox::critical(0, tr("Unable to save settings"),
tr("There was an error changing the indev.\nPlease report this bug."),
QMessageBox::Ok);
}
}
if (noutdev!= outdev)
{
_settings->setValue("outdev", noutdev);
}
if (nringdev != ringdev)
{
_settings->setValue("ringdev", nringdev);
}
_settings->endGroup();
_settings->endGroup();
}
void PrefPortaudio::readConfig()
{
getPaDevlist();
_settings->beginGroup("FreeSWITCH/conf");
_settings->beginGroup("portaudio.conf");
_ui->PaCallerIdNameEdit->setText(_settings->value("cid-name").toString());
_ui->PaCallerIdNumEdit->setText(_settings->value("cid-num").toString());
_ui->PaHoldFileEdit->setText(_settings->value("hold-file").toString());
_ui->PaRingFileEdit->setText(_settings->value("ring-file").toString());
_ui->PaRingIntervalSpin->setValue(_settings->value("ring-interval").toInt());
_settings->endGroup();
_settings->endGroup();
}
void PrefPortaudio::getPaDevlist()
{
QString result;
int errorLine, errorColumn;
QString errorMsg;
if (g_FSHost.sendCmd("pa", "devlist xml", &result) != SWITCH_STATUS_SUCCESS)
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error querying audio devices."),
QMessageBox::Ok);
return;
}
if (!_xmlPaDevList.setContent(result, &errorMsg, &errorLine, &errorColumn))
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist.\n%1 (Line:%2, Col:%3).").arg(errorMsg,
errorLine,
errorColumn),
QMessageBox::Ok);
return;
}
QDomElement root = _xmlPaDevList.documentElement();
if (root.tagName() != "xml")
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. Root tag is not <xml>."),
QMessageBox::Ok);
return;
}
QDomElement devices = root.firstChildElement("devices");
if (devices.isNull())
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There is no <devices> tag."),
QMessageBox::Ok);
return;
}
QDomElement child = devices.firstChildElement();
if (child.isNull())
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There is no <device> tag."),
QMessageBox::Ok);
return;
}
while (!child.isNull())
{
if (child.tagName() == "device")
{
QString id, name, inputs, outputs;
id = child.attribute("id","-1");
name = child.attribute("name","Null");
inputs = child.attribute("inputs","0");
outputs = child.attribute("outputs","0");
if (inputs.toInt() != 0)
_ui->PaIndevCombo->addItem(name,id.toInt());
if (outputs.toInt() != 0)
{
_ui->PaOutdevCombo->addItem(name,id.toInt());
_ui->PaRingdevCombo->addItem(name,id.toInt());
}
}
child = child.nextSiblingElement();
}
QDomElement bindings = root.firstChildElement("bindings");
if (bindings.isNull())
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There is no <bindings> tag."),
QMessageBox::Ok);
return;
}
child = bindings.firstChildElement();
if (child.isNull())
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There are no bindings."),
QMessageBox::Ok);
return;
}
while (!child.isNull())
{
QString id = child.attribute("device","-1");
if (child.tagName() == "ring")
{
for(int itemId=0; itemId<_ui->PaRingdevCombo->count(); itemId++)
{
if (itemId == _ui->PaRingdevCombo->itemData(itemId,Qt::UserRole).toInt())
{
_ui->PaRingdevCombo->setCurrentIndex(itemId);
break;
}
}
}
else if (child.tagName() == "input")
_ui->PaIndevCombo->setCurrentIndex(id.toInt());
else if (child.tagName() == "output")
for(int itemId=0; itemId<_ui->PaOutdevCombo->count(); itemId++)
{
if (itemId == _ui->PaOutdevCombo->itemData(itemId,Qt::UserRole).toInt())
{
_ui->PaOutdevCombo->setCurrentIndex(itemId);
break;
}
}
child = child.nextSiblingElement();
}
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef PREFPORTAUDIO_H
#define PREFPORTAUDIO_H
#include <QObject>
#include <QDomDocument>
#include "ui_prefdialog.h"
class QSettings;
class PrefPortaudio : public QObject
{
Q_OBJECT
public:
explicit PrefPortaudio(Ui::PrefDialog *ui, QObject *parent = 0);
void writeConfig();
void readConfig();
private slots:
void ringFileChoose();
void holdFileChoose();
void outdevChangeDev(int);
void ringdevChangeDev(int);
void ringdevTest();
private:
void getPaDevlist(void);
QSettings *_settings;
Ui::PrefDialog *_ui;
QDomDocument _xmlPaDevList;
};
#endif // PREFPORTAUDIO_H