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
This commit is contained in:
João Mesquita 2010-01-28 03:13:57 +00:00
parent 8a3001e611
commit 6a939c199a
6 changed files with 330 additions and 249 deletions

View File

@ -234,27 +234,42 @@
<context name="default">
<extension name="codec_and_sip_uri">
<condition field="destination_number" expression="^sip:(.*):(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="{absolute_codec_string=$1}sofia/softphone/$2"/>
</condition>
</extension>
<extension name="sip_uri">
<condition field="destination_number" expression="^sip:(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="sofia/softphone/$1"/>
</condition>
</extension>
<extension name="codec_and_number">
<condition field="destination_number" expression="^(.*):(.*)@(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="{absolute_codec_string=$1}sofia/gateway/$3/$2"/>
</condition>
</extension>
<extension name="number">
<condition field="destination_number" expression="^(.*)@(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="sofia/gateway/$2/$1"/>
</condition>
</extension>
<extension name="number">
<condition field="destination_number" expression="^(.*)$">
<!-- Default gateway is set by FSComm when default account is selected -->
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="sofia/gateway/${default_gateway}/$1"/>
</condition>
</extension>
@ -263,6 +278,8 @@
<extension name="public_extensions">
<condition field="$${auto_answer}" expression="^true$"/>
<condition field="destination_number" expression="^(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="portaudio/auto_answer"/>
</condition>
@ -271,12 +288,16 @@
<condition field="${sip_to_params}" expression="intercom=true"/>
<condition field="${alert_info}" expression="Ring;Answer"/>
<condition field="destination_number" expression="^(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="bridge" data="portaudio/auto_answer"/>
</condition>
</extension>
<extension name="public_extensions">
<condition field="destination_number" expression="^(.*)$">
<action application="export" data="origination_caller_id_number=${fscomm_caller_id_num}"/>
<action application="export" data="origination_caller_id_name=${fscomm_caller_id_name}"/>
<action application="info"/>
<action application="set" data="ringback=${us-ring}"/>
<action application="pre_answer"/>
@ -286,5 +307,3 @@
</context>
</section>
</document>

View File

@ -485,3 +485,22 @@ void FSHost::printEventHeaders(switch_event_t *event)
}
qDebug() << "\n\n";
}
QSharedPointer<Account> FSHost::getAccountByName(QString accStr)
{
foreach(QSharedPointer<Account> acc, _accounts.values())
{
if (acc.data()->getName() == accStr)
return acc;
}
return QSharedPointer<Account>();
}
QSharedPointer<Account> FSHost::getCurrentDefaultAccount()
{
QSettings settings;
settings.beginGroup("FreeSWITCH/conf/globals");
QString accString = settings.value("default_gateway").toString();
settings.endGroup();
return getAccountByName(accString);
}

View File

@ -47,6 +47,8 @@ public:
QSharedPointer<Call> getCurrentActiveCall();
QList<QSharedPointer<Account> > getAccounts() { return _accounts.values(); }
QSharedPointer<Account> getAccountByUUID(QString uuid);
QSharedPointer<Account> getCurrentDefaultAccount();
QSharedPointer<Account> getAccountByName(QString accStr);
void accountReloadCmd(QSharedPointer<Account> acc);
protected:

View File

@ -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<Account> 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);

View File

@ -138,6 +138,17 @@ void AccountDialog::writeConfig()
_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());
_settings->endGroup();

View File

@ -193,7 +193,7 @@
<item row="9" column="1">
<widget class="QComboBox" name="clidSettingsCombo">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<item>
<property name="text">