From 6a939c199a4cd1e00fd7ddf789fd98dbff56f6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Thu, 28 Jan 2010 03:13:57 +0000 Subject: [PATCH] Make caller id per account option available. Needs to wipe out the ~/.fscomm/conf/freeswitch.xml file, sorry. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16529 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- fscomm/conf/freeswitch.xml | 515 ++++++++++++++------------- fscomm/fshost.cpp | 19 + fscomm/fshost.h | 2 + fscomm/mainwindow.cpp | 30 ++ fscomm/preferences/accountdialog.cpp | 11 + fscomm/preferences/accountdialog.ui | 2 +- 6 files changed, 330 insertions(+), 249 deletions(-) diff --git a/fscomm/conf/freeswitch.xml b/fscomm/conf/freeswitch.xml index 0d1d5c0d63..18e514546d 100644 --- a/fscomm/conf/freeswitch.xml +++ b/fscomm/conf/freeswitch.xml @@ -1,102 +1,102 @@ - - - - - - - - - - + + + + + + + + + + -
- - - - - - - - - - +
+ + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -125,166 +125,185 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
-
- - - - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index 641d46e086..564fa843bd 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -485,3 +485,22 @@ void FSHost::printEventHeaders(switch_event_t *event) } qDebug() << "\n\n"; } + +QSharedPointer FSHost::getAccountByName(QString accStr) +{ + foreach(QSharedPointer acc, _accounts.values()) + { + if (acc.data()->getName() == accStr) + return acc; + } + return QSharedPointer(); +} + +QSharedPointer FSHost::getCurrentDefaultAccount() +{ + QSettings settings; + settings.beginGroup("FreeSWITCH/conf/globals"); + QString accString = settings.value("default_gateway").toString(); + settings.endGroup(); + return getAccountByName(accString); +} diff --git a/fscomm/fshost.h b/fscomm/fshost.h index f86cedab97..e6b9a41bb6 100644 --- a/fscomm/fshost.h +++ b/fscomm/fshost.h @@ -47,6 +47,8 @@ public: QSharedPointer getCurrentActiveCall(); QList > getAccounts() { return _accounts.values(); } QSharedPointer getAccountByUUID(QString uuid); + QSharedPointer getCurrentDefaultAccount(); + QSharedPointer getAccountByName(QString accStr); void accountReloadCmd(QSharedPointer acc); protected: diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index b44570bf0c..95f8e3343d 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -239,6 +239,36 @@ void MainWindow::makeCall() QString dialstring = QInputDialog::getText(this, tr("Make new call"), tr("Number to dial:"), QLineEdit::Normal, NULL,&ok); + QSharedPointer acc = g_FSHost.getCurrentDefaultAccount(); + if (!acc.isNull()) { + QSettings settings; + settings.beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways/"); + settings.beginGroup(acc.data()->getUUID()); + settings.beginGroup("gateway/global_vars"); + QString cidName = settings.value("caller_id_name").toString(); + QString cidNum = settings.value("caller_id_num").toString(); + settings.endGroup(); + settings.endGroup(); + settings.endGroup(); + + if (cidName.isEmpty()) { + settings.beginGroup("FreeSWITCH/conf/portaudio.conf/settings/params"); + cidName = settings.value("cid-name").toString(); + settings.endGroup(); + } + if (cidNum.isEmpty()) { + settings.beginGroup("FreeSWITCH/conf/portaudio.conf/settings/params"); + cidNum = settings.value("cid-num").toString(); + settings.endGroup(); + } + + /* Set the vars for this call */ + switch_core_set_variable("fscomm_caller_id_name", cidName.toAscii().data()); + switch_core_set_variable("fscomm_caller_id_num", cidNum.toAscii().data()); + + qDebug() << "Name:" << cidName << "Num:" << cidNum; + } + if (ok && !dialstring.isEmpty()) { paCall(dialstring); diff --git a/fscomm/preferences/accountdialog.cpp b/fscomm/preferences/accountdialog.cpp index 7470c5e324..098977d8fe 100644 --- a/fscomm/preferences/accountdialog.cpp +++ b/fscomm/preferences/accountdialog.cpp @@ -137,6 +137,17 @@ void AccountDialog::writeConfig() _settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways"); _settings->beginGroup(_accId); + + _settings->beginGroup("gateway/global_vars"); + if (ui->clidSettingsCombo->currentIndex() == 0) + { + _settings->remove("caller_id_name"); + _settings->remove("caller_id_num"); + } else { + _settings->setValue("caller_id_name", ui->sofiaCallerIDName->text()); + _settings->setValue("caller_id_num", ui->sofiaCallerIDNum->text()); + } + _settings->endGroup(); _settings->beginGroup("gateway/attrs"); _settings->setValue("name", ui->sofiaGwNameEdit->text()); diff --git a/fscomm/preferences/accountdialog.ui b/fscomm/preferences/accountdialog.ui index 309102a821..53d9100aaa 100644 --- a/fscomm/preferences/accountdialog.ui +++ b/fscomm/preferences/accountdialog.ui @@ -193,7 +193,7 @@ - false + true