]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
First created account is set as default outbound account. Will start making GUI stuff...
authorJoão Mesquita <jmesquita@freeswitch.org>
Sun, 17 Jan 2010 23:10:57 +0000 (23:10 +0000)
committerJoão Mesquita <jmesquita@freeswitch.org>
Sun, 17 Jan 2010 23:10:57 +0000 (23:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16346 d0543943-73ff-0310-b7d9-9358b9ac24b2

fscomm/conf/freeswitch.xml
fscomm/preferences/accountdialog.cpp
fscomm/preferences/accountdialog.h
fscomm/preferences/prefaccounts.cpp
fscomm/preferences/prefaccounts.h
fscomm/preferences/prefdialog.cpp

index 60d3190b7876f963841e6421fb95bced75ea1835..0d1d5c0d6374b3a03469107e907470a66961156f 100644 (file)
@@ -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)"/>
                        </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>
index 819514ac96dc1084cb3dfa4b6151f58db05ccb3e..aa8cddbecc425b222c4c5e9e9bb8b361d9f0d25e 100644 (file)
@@ -130,13 +130,7 @@ void AccountDialog::writeConfig()
 
     _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()
index 1a9504180c524bffd4fea4a991a2d4de4aca47a0..9be1b6e26f46642caf2ead66a5fd82d24da5ed82 100644 (file)
@@ -19,7 +19,7 @@ public:
     void readConfig();
 
 signals:
-    void gwAdded();
+    void gwAdded(QString);
 
 private slots:
     void writeConfig();
index 3694963234aa0eab7876f3badb5e009a60c3369a..ce70dd83ed676610f5f5b8c7ee45b7540ed3720a 100644 (file)
@@ -24,7 +24,8 @@ void PrefAccounts::addAccountBtnClicked()
             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 @@ void PrefAccounts::addAccountBtnClicked()
     _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 @@ void PrefAccounts::editAccountBtnClicked()
     if (!_accDlg)
     {
         _accDlg = new AccountDialog(uuid);
-        connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig()));
+        connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(readConfig()));
     }
     else
     {
index 08ec5c18da623067e986886a326a154fdf0e147e..2a78c654d9d82b4fd7f9cbe47046afd7d63f6e2e 100644 (file)
@@ -20,6 +20,7 @@ private slots:
     void addAccountBtnClicked();
     void editAccountBtnClicked();
     void remAccountBtnClicked();
+    void applyNewGw(QString);
 
 private:
     Ui::PrefDialog *_ui;
index 3edb4c8bdf03a2200d3da9939a95de2a519478aa..c6154115918c69c659e75f27e87596a995504fb6 100644 (file)
@@ -28,6 +28,7 @@ void PrefDialog::writeConfig()
 {    
     _mod_portaudio->writeConfig();
     _mod_sofia->writeConfig();
+
 }
 
 void PrefDialog::changeEvent(QEvent *e)