Revision
16346
Author
jmesquita
Date
2010-01-17 17:10:57 -0600 (Sun, 17 Jan 2010)

Log Message

First created account is set as default outbound account. Will start making GUI stuff to be able to select between accounts.

Modified Paths

Diff

Modified: freeswitch/trunk/fscomm/conf/freeswitch.xml (16345 => 16346)


--- freeswitch/trunk/fscomm/conf/freeswitch.xml	2010-01-17 22:50:49 UTC (rev 16345)
+++ freeswitch/trunk/fscomm/conf/freeswitch.xml	2010-01-17 23:10:57 UTC (rev 16346)
@@ -7,7 +7,6 @@
 	<X-PRE-PROCESS cmd="set" data="external_rtp_ip=stun:stun.freeswitch.org"/>
 	<X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.freeswitch.org"/>
 	<X-PRE-PROCESS cmd="set" data="console_loglevel=info"/>
-	<X-PRE-PROCESS cmd="set" data="default_gateway=default"/>
 	<X-PRE-PROCESS cmd="set" data="us-ring=%(2000, 4000, 440.0, 480.0)"/>
 	<X-PRE-PROCESS cmd="set" data="bong-ring=v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1400,0,350,440)"/>
 	<X-PRE-PROCESS cmd="set" data="sit=%(274,0,913.8);%(274,0,1370.6);%(380,0,1776.7)"/>
@@ -255,6 +254,7 @@
 			</extension>
 			<extension name="number">
 				<condition field="destination_number" expression="^(.*)$">
+                                 <!-- Default gateway is set by FSComm when default account is selected -->
 					<action application="bridge" data="sofia/gateway/${default_gateway}/$1"/>
 				</condition>
 			</extension>

Modified: freeswitch/trunk/fscomm/preferences/accountdialog.cpp (16345 => 16346)


--- freeswitch/trunk/fscomm/preferences/accountdialog.cpp	2010-01-17 22:50:49 UTC (rev 16345)
+++ freeswitch/trunk/fscomm/preferences/accountdialog.cpp	2010-01-17 23:10:57 UTC (rev 16346)
@@ -130,13 +130,7 @@
 
     _settings->endGroup();
 
-    QString res;
-    if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
-        return;
-    }
-    emit gwAdded();
+    emit gwAdded(_accId);
 }
 
 void AccountDialog::clear()

Modified: freeswitch/trunk/fscomm/preferences/accountdialog.h (16345 => 16346)


--- freeswitch/trunk/fscomm/preferences/accountdialog.h	2010-01-17 22:50:49 UTC (rev 16345)
+++ freeswitch/trunk/fscomm/preferences/accountdialog.h	2010-01-17 23:10:57 UTC (rev 16346)
@@ -19,7 +19,7 @@
     void readConfig();
 
 signals:
-    void gwAdded();
+    void gwAdded(QString);
 
 private slots:
     void writeConfig();

Modified: freeswitch/trunk/fscomm/preferences/prefaccounts.cpp (16345 => 16346)


--- freeswitch/trunk/fscomm/preferences/prefaccounts.cpp	2010-01-17 22:50:49 UTC (rev 16345)
+++ freeswitch/trunk/fscomm/preferences/prefaccounts.cpp	2010-01-17 23:10:57 UTC (rev 16346)
@@ -24,7 +24,8 @@
             return;
         }
         _accDlg = new AccountDialog(uuid);
-        connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig()));
+        connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(readConfig()));
+        connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(applyNewGw(QString)));
     }
     else
     {
@@ -43,6 +44,26 @@
     _accDlg->activateWindow();
 }
 
+void PrefAccounts::applyNewGw(QString accId)
+{
+    QString res;
+    if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
+    {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
+        return;
+    }
+
+    if (_ui->accountsTable->rowCount() == 1)
+    {
+        _settings->beginGroup("FreeSWITCH/conf/globals");
+        _settings->setValue("default_gateway",_settings->value("/attrs/name"));
+        _settings->endGroup();
+        _settings->beginGroup(QString("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways/%1/gateway").arg(accId));
+        switch_core_set_variable("default_gateway",_settings->value("/attrs/name").toByteArray().data());
+        _settings->endGroup();
+    }
+}
+
 void PrefAccounts::editAccountBtnClicked()
 {
     QList<QTableWidgetSelectionRange> selList = _ui->accountsTable->selectedRanges();
@@ -56,7 +77,7 @@
     if (!_accDlg)
     {
         _accDlg = new AccountDialog(uuid);
-        connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig()));
+        connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(readConfig()));
     }
     else
     {

Modified: freeswitch/trunk/fscomm/preferences/prefaccounts.h (16345 => 16346)


--- freeswitch/trunk/fscomm/preferences/prefaccounts.h	2010-01-17 22:50:49 UTC (rev 16345)
+++ freeswitch/trunk/fscomm/preferences/prefaccounts.h	2010-01-17 23:10:57 UTC (rev 16346)
@@ -20,6 +20,7 @@
     void addAccountBtnClicked();
     void editAccountBtnClicked();
     void remAccountBtnClicked();
+    void applyNewGw(QString);
 
 private:
     Ui::PrefDialog *_ui;

Modified: freeswitch/trunk/fscomm/preferences/prefdialog.cpp (16345 => 16346)


--- freeswitch/trunk/fscomm/preferences/prefdialog.cpp	2010-01-17 22:50:49 UTC (rev 16345)
+++ freeswitch/trunk/fscomm/preferences/prefdialog.cpp	2010-01-17 23:10:57 UTC (rev 16346)
@@ -28,6 +28,7 @@
 {    
     _mod_portaudio->writeConfig();
     _mod_sofia->writeConfig();
+
 }
 
 void PrefDialog::changeEvent(QEvent *e)