Revision
16350
Author
jmesquita
Date
2010-01-17 22:21:46 -0600 (Sun, 17 Jan 2010)

Log Message

Fix DTMF for outbound calls, default settings on startup and dialplan correctly set. We must be ready to go and really test this thing.

Modified Paths

Diff

Modified: freeswitch/trunk/fscomm/fshost.cpp (16349 => 16350)


--- freeswitch/trunk/fscomm/fshost.cpp	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/fshost.cpp	2010-01-18 04:21:46 UTC (rev 16350)
@@ -237,6 +237,7 @@
         {
         case SWITCH_EVENT_CHANNEL_ANSWER:
             {
+                /* When do we get here? */
                 emit answered(call);
                 break;
             }
@@ -254,7 +255,11 @@
                     call.data()->setState(FSCOMM_CALL_STATE_RINGING);
                     emit ringing(call);
                 }
-                //printEventHeaders(event);
+                else if (QString(switch_event_get_header_nil(event, "Answer-State")) == "answered")
+                {
+                    call.data()->setState(FSCOMM_CALL_STATE_ANSWERED);
+                    emit answered(call);
+                }
                 break;
             }
 

Modified: freeswitch/trunk/fscomm/mainwindow.cpp (16349 => 16350)


--- freeswitch/trunk/fscomm/mainwindow.cpp	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/mainwindow.cpp	2010-01-18 04:21:46 UTC (rev 16350)
@@ -300,6 +300,8 @@
             }
         }
     }
+    ui->recoredCallBtn->setEnabled(true);
+    ui->recoredCallBtn->setChecked(false);
     ui->dtmf0Btn->setEnabled(true);
     ui->dtmf1Btn->setEnabled(true);
     ui->dtmf2Btn->setEnabled(true);
@@ -334,6 +336,8 @@
                                                                              call.data()->getCause()));
     call.data()->setActive(false);
     /* TODO: Will cause problems if 2 calls are received at the same time */
+    ui->recoredCallBtn->setEnabled(false);
+    ui->recoredCallBtn->setChecked(false);
     ui->answerBtn->setEnabled(false);
     ui->hangupBtn->setEnabled(false);
     ui->dtmf0Btn->setEnabled(false);
@@ -369,6 +373,8 @@
     call.data()->setActive(false);
     ui->textEdit->setText(tr("Call with %1 (%2) hungup.").arg(call.data()->getCidName(), call.data()->getCidNumber()));
     /* TODO: Will cause problems if 2 calls are received at the same time */
+    ui->recoredCallBtn->setEnabled(false);
+    ui->recoredCallBtn->setChecked(false);
     ui->answerBtn->setEnabled(false);
     ui->hangupBtn->setEnabled(false);
     ui->dtmf0Btn->setEnabled(false);

Modified: freeswitch/trunk/fscomm/mainwindow.ui (16349 => 16350)


--- freeswitch/trunk/fscomm/mainwindow.ui	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/mainwindow.ui	2010-01-18 04:21:46 UTC (rev 16350)
@@ -41,6 +41,9 @@
         </item>
         <item>
          <widget class="QPushButton" name="recoredCallBtn">
+          <property name="enabled">
+           <bool>false</bool>
+          </property>
           <property name="text">
            <string>Record</string>
           </property>
@@ -273,7 +276,7 @@
             <bool>false</bool>
            </property>
            <property name="selectionMode">
-            <enum>QAbstractItemView::NoSelection</enum>
+            <enum>QAbstractItemView::SingleSelection</enum>
            </property>
            <property name="selectionBehavior">
             <enum>QAbstractItemView::SelectRows</enum>

Modified: freeswitch/trunk/fscomm/mod_qsettings/mod_qsettings.cpp (16349 => 16350)


--- freeswitch/trunk/fscomm/mod_qsettings/mod_qsettings.cpp	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/mod_qsettings/mod_qsettings.cpp	2010-01-18 04:21:46 UTC (rev 16350)
@@ -178,9 +178,103 @@
     binding = NULL;
 
     switch_xml_free(xml);
+
+    QSettings settings;
+    if (!settings.allKeys().contains("FreeSWITCH/conf"))
+        setQSettingsDefaults();
+    setGlobals();
+
     return SWITCH_STATUS_SUCCESS;
 }
 
+void setQSettingsDefaults()
+{
+    QSettings settings;
+    settings.beginGroup("FreeSWITCH/conf");
+
+    /* Globals config */
+    /* Sofia config */
+    settings.beginGroup("sofia.conf");
+
+    /* General Settings */
+    settings.beginGroup("global_settings/params");
+    settings.setValue("log-level", 0);
+    settings.setValue("auto-restart", "true");
+    settings.setValue("debug-presence", 0);
+    settings.endGroup();
+
+    /* Profile settings */
+    settings.beginGroup("profiles");
+    settings.beginGroup("profile");
+
+    settings.beginGroup("attrs");
+    settings.setValue("name", "softphone");
+    settings.endGroup();
+
+    settings.beginGroup("settings/params");
+    settings.setValue("user-agent-string", "FreeSWITCH/FSComm");
+    settings.setValue("debug", 0);
+    settings.setValue("sip-trace", "no");
+    settings.setValue("context", "public");
+    settings.setValue("rfc2833-pt", 101);
+    settings.setValue("sip-port", 12345);
+    settings.setValue("dialplan", "XML");
+    settings.setValue("dtmf-duration", 100);
+    settings.setValue("codec-prefs", "CELT@48000h,G7221@32000h,G7221@16000h,G722,PCMU,PCMA,GSM");
+    settings.setValue("use-rtp-timer", "true");
+    settings.setValue("rtp-timer-name", "soft");
+    settings.setValue("rtp-ip", "auto");
+    settings.setValue("sip-ip", "auto");
+    settings.setValue("hold-music", "local_stream://moh");
+    settings.setValue("apply-nat-acl", "rfc1918");
+    settings.setValue("manage-presence", "false");
+    settings.setValue("max-proceeding", 3);
+    settings.setValue("inbound-codec-negotiation", "generous");
+    settings.setValue("nonce-ttl", 60);
+    settings.setValue("auth-calls", "false");
+    settings.setValue("auth-all-packets", "false");
+    settings.setValue("ext-rtp-ip", "stun:stun.freeswitch.org");
+    settings.setValue("ext-sip-ip", "stun:stun.freeswitch.org");
+    settings.setValue("rtp-timeout-sec", 300);
+    settings.setValue("rtp-hold-timeout-sec", 1800);
+    settings.setValue("disable-register", "true");
+    settings.setValue("challenge-realm", "auto_from");
+    settings.endGroup();
+
+    settings.endGroup();
+    settings.endGroup();
+    settings.endGroup();
+
+    /* PortAudio config */
+    settings.beginGroup("portaudio.conf/settings/params");
+    settings.setValue("cid-name", "FSComm");
+    settings.setValue("cid-num", "00000000");
+    settings.setValue("ring-file", "tone_stream://%(2000,4000,440.0,480.0);loops=20");
+    settings.setValue("dialplan", "XML");
+    settings.setValue("ring-interval", 5);
+    settings.setValue("hold-file", "local_stream://moh");
+    settings.setValue("sample-rate", 48000);
+    settings.setValue("codec-ms", 10);
+    settings.setValue("indev", "");
+    settings.setValue("outdev", "");
+    settings.setValue("ringdev", "");
+    settings.endGroup();
+
+    /* Finish configs */
+    settings.endGroup();
+}
+
+void setGlobals()
+{
+    QSettings settings;
+    settings.beginGroup("FreeSWITCH/conf/globals");
+    foreach (QString k, settings.childKeys())
+    {
+        switch_core_set_variable(k.toAscii().data(), settings.value(k).toByteArray().data());
+    }
+    settings.endGroup();
+}
+
 switch_status_t mod_qsettings_load(void)
 {
 

Modified: freeswitch/trunk/fscomm/mod_qsettings/mod_qsettings.h (16349 => 16350)


--- freeswitch/trunk/fscomm/mod_qsettings/mod_qsettings.h	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/mod_qsettings/mod_qsettings.h	2010-01-18 04:21:46 UTC (rev 16350)
@@ -34,7 +34,7 @@
 #include <QSettings>
 #include <switch.h>
 
-switch_status_t mod_qsettings_load(void);
+class QXmlStreamWriter;
 
 class XMLBinding
 {
@@ -48,4 +48,8 @@
     QSettings* _settings;
 };
 
+switch_status_t mod_qsettings_load(void);
+void setQSettingsDefaults(void);
+void setGlobals(void);
+
 #endif // MOD_QSETTINGS_H

Modified: freeswitch/trunk/fscomm/preferences/prefaccounts.cpp (16349 => 16350)


--- freeswitch/trunk/fscomm/preferences/prefaccounts.cpp	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/preferences/prefaccounts.cpp	2010-01-18 04:21:46 UTC (rev 16350)
@@ -25,7 +25,6 @@
         }
         _accDlg = new AccountDialog(uuid);
         connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(readConfig()));
-        connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(applyNewGw(QString)));
     }
     else
     {
@@ -44,26 +43,6 @@
     _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();
@@ -113,6 +92,7 @@
     if (offset > 0)
     {
         QString res;
+        _settings->sync();
         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");
@@ -153,4 +133,23 @@
     }
 
     _settings->endGroup();
+
+    QString res;
+    _settings->sync();
+    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)
+    {
+        QString default_gateway = _settings->value(QString("/FreeSWITCH/conf/sofia.conf/profiles/profile/gateways/%1/gateway/attrs/name").arg(_ui->accountsTable->item(0,0)->data(Qt::UserRole).toString())).toString();
+        _settings->beginGroup("FreeSWITCH/conf/globals");
+        qDebug() << QString("Fucking gw: %1").arg(default_gateway);
+        _settings->setValue("default_gateway", default_gateway);
+        _settings->endGroup();
+        switch_core_set_variable("default_gateway", default_gateway.toAscii().data());
+    }
+
 }

Modified: freeswitch/trunk/fscomm/preferences/prefaccounts.h (16349 => 16350)


--- freeswitch/trunk/fscomm/preferences/prefaccounts.h	2010-01-18 02:43:48 UTC (rev 16349)
+++ freeswitch/trunk/fscomm/preferences/prefaccounts.h	2010-01-18 04:21:46 UTC (rev 16350)
@@ -20,7 +20,6 @@
     void addAccountBtnClicked();
     void editAccountBtnClicked();
     void remAccountBtnClicked();
-    void applyNewGw(QString);
 
 private:
     Ui::PrefDialog *_ui;