<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16349] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16349">16349</a></dd>
<dt>Author</dt> <dd>jmesquita</dd>
<dt>Date</dt> <dd>2010-01-17 20:43:48 -0600 (Sun, 17 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/FSCOMM-1">FSCOMM-1</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkfscommcallcpp">freeswitch/trunk/fscomm/call.cpp</a></li>
<li><a href="#freeswitchtrunkfscommcallh">freeswitch/trunk/fscomm/call.h</a></li>
<li><a href="#freeswitchtrunkfscommfshostcpp">freeswitch/trunk/fscomm/fshost.cpp</a></li>
<li><a href="#freeswitchtrunkfscommfshosth">freeswitch/trunk/fscomm/fshost.h</a></li>
<li><a href="#freeswitchtrunkfscommmainwindowcpp">freeswitch/trunk/fscomm/mainwindow.cpp</a></li>
<li><a href="#freeswitchtrunkfscommmainwindowh">freeswitch/trunk/fscomm/mainwindow.h</a></li>
<li><a href="#freeswitchtrunkfscommmainwindowui">freeswitch/trunk/fscomm/mainwindow.ui</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkfscommcallcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/call.cpp (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/call.cpp        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/call.cpp        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -41,4 +41,29 @@
</span><span class="cx">         _direction(direction),
</span><span class="cx">         _uuid (uuid)
</span><span class="cx"> {
</span><ins>+    _isActive = false;
</ins><span class="cx"> }
</span><ins>+
+switch_status_t Call::toggleRecord(bool startRecord)
+{
+    QDir conf_dir = QDir::home();
+    QString result;
+    switch_status_t status;
+
+    if (startRecord)
+    {
+        _recording_filename = QString(&quot;%1/.fscomm/recordings/%2_%3.wav&quot;).arg(
+                                         conf_dir.absolutePath(),
+                                         QDateTime::currentDateTime().toString(&quot;yyyyMMddhhmmss&quot;),
+                                         _cid_number);
+        status = g_FSHost.sendCmd(&quot;uuid_record&quot;, QString(&quot;%1 start %2&quot;).arg(_uuid, _recording_filename).toAscii().data(),&amp;result);
+    }
+    else
+    {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Stopping call recording on call [%s]\n&quot;,
+                          _uuid.toAscii().data());
+        status = g_FSHost.sendCmd(&quot;uuid_record&quot;, QString(&quot;%1 stop %2&quot;).arg(_uuid, _recording_filename).toAscii().data(),&amp;result);
+    }
+
+    return status;
+}
</ins></span></pre></div>
<a id="freeswitchtrunkfscommcallh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/call.h (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/call.h        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/call.h        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;QtCore&gt;
</span><span class="cx"> #include &lt;QString&gt;
</span><ins>+#include &lt;switch.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><span class="cx">     FSCOMM_CALL_STATE_RINGING = 0,
</span><span class="lines">@@ -59,6 +60,9 @@
</span><span class="cx">     void setState(fscomm_call_state_t state) { _state = state; }
</span><span class="cx">     void setCause(QString cause) { _cause = cause; }
</span><span class="cx">     QString getCause() { return _cause; }
</span><ins>+    void setActive(bool isActive) { _isActive = isActive; }
+    bool isActive() { return _isActive == true; }
+    switch_status_t toggleRecord(bool);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     int _call_id;
</span><span class="lines">@@ -68,6 +72,8 @@
</span><span class="cx">     fscomm_call_direction_t _direction;
</span><span class="cx">     QString _uuid;
</span><span class="cx">     QString _buuid;
</span><ins>+    bool _isActive;
+    QString _recording_filename;
</ins><span class="cx">     fscomm_call_state_t _state;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunkfscommfshostcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/fshost.cpp (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/fshost.cpp        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/fshost.cpp        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -51,17 +51,18 @@
</span><span class="cx">     /* Create directory structure for softphone with default configs */
</span><span class="cx">     QDir conf_dir = QDir::home();
</span><span class="cx">     if (!conf_dir.exists(&quot;.fscomm&quot;))
</span><del>-    {
-        conf_dir.mkpath(&quot;.fscomm/conf/accounts&quot;);
</del><ins>+        conf_dir.mkpath(&quot;.fscomm&quot;);
+    if (!conf_dir.exists(&quot;.fscomm/recordings&quot;))
+        conf_dir.mkpath(&quot;.fscomm/recordings&quot;);
+    if (!conf_dir.exists(&quot;.fscomm/sounds&quot;)) {
</ins><span class="cx">         conf_dir.mkpath(&quot;.fscomm/sounds&quot;);
</span><span class="cx">         QFile::copy(&quot;:/sounds/test.wav&quot;, QString(&quot;%1/.fscomm/sounds/test.wav&quot;).arg(QDir::homePath()));
</span><ins>+    }
+    if(!QFile::exists(QString(&quot;%1/.fscomm/conf/freeswitch.xml&quot;).arg(conf_dir.absolutePath()))) {
+        conf_dir.mkdir(&quot;.fscomm/conf&quot;);
</ins><span class="cx">         QFile rootXML(&quot;:/confs/freeswitch.xml&quot;);
</span><span class="cx">         QString dest = QString(&quot;%1/.fscomm/conf/freeswitch.xml&quot;).arg(conf_dir.absolutePath());
</span><span class="cx">         rootXML.copy(dest);
</span><del>-
-        QFile defaultAccount(&quot;:/confs/template.xml&quot;);
-        dest = QString(&quot;%1/.fscomm/conf/accounts/template.xml&quot;).arg(conf_dir.absolutePath());
-        defaultAccount.copy(dest);
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     /* Set all directories to the home user directory */
</span><span class="lines">@@ -351,6 +352,7 @@
</span><span class="cx">     switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">     switch_stream_handle_t stream = { 0 };
</span><span class="cx">     SWITCH_STANDARD_STREAM(stream);
</span><ins>+    qDebug() &lt;&lt; &quot;Sending command: &quot; &lt;&lt; cmd &lt;&lt; args &lt;&lt; endl;
</ins><span class="cx">     status = switch_api_execute(cmd, args, NULL, &amp;stream);
</span><span class="cx">     *res = switch_str_nil((char *) stream.data);
</span><span class="cx">     switch_safe_free(stream.data);
</span><span class="lines">@@ -358,6 +360,16 @@
</span><span class="cx">     return status;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+QSharedPointer&lt;Call&gt; FSHost::getCurrentActiveCall()
+{
+    foreach(QSharedPointer&lt;Call&gt; call, _active_calls.values())
+    {
+        if (call.data()-&gt;isActive())
+            return call;
+    }
+    return QSharedPointer&lt;Call&gt;();
+}
+
</ins><span class="cx"> void FSHost::printEventHeaders(switch_event_t *event)
</span><span class="cx"> {
</span><span class="cx">     switch_event_header_t *hp;
</span></span></pre></div>
<a id="freeswitchtrunkfscommfshosth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/fshost.h (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/fshost.h        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/fshost.h        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">     switch_status_t sendCmd(const char *cmd, const char *args, QString *res);
</span><span class="cx">     void generalEventHandler(switch_event_t *event);
</span><span class="cx">     QSharedPointer&lt;Call&gt; getCallByUUID(QString uuid) { return _active_calls.value(uuid); }
</span><ins>+    QSharedPointer&lt;Call&gt; getCurrentActiveCall();
</ins><span class="cx">     QString getGwStateName(int id) { return fscomm_gw_state_names[id]; }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="freeswitchtrunkfscommmainwindowcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/mainwindow.cpp (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/mainwindow.cpp        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/mainwindow.cpp        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -87,6 +87,7 @@
</span><span class="cx">     connect(ui-&gt;newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall()));
</span><span class="cx">     connect(ui-&gt;answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer()));
</span><span class="cx">     connect(ui-&gt;hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup()));
</span><ins>+    connect(ui-&gt;recoredCallBtn, SIGNAL(toggled(bool)), SLOT(recordCall(bool)));
</ins><span class="cx">     connect(ui-&gt;listCalls, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(callListDoubleClick(QListWidgetItem*)));
</span><span class="cx">     connect(ui-&gt;action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered()));
</span><span class="cx">     connect(ui-&gt;action_Exit, SIGNAL(triggered()), this, SLOT(close()));
</span><span class="lines">@@ -153,6 +154,7 @@
</span><span class="cx"> 
</span><span class="cx"> void MainWindow::callListDoubleClick(QListWidgetItem *item)
</span><span class="cx"> {
</span><ins>+    QSharedPointer&lt;Call&gt; lastCall = g_FSHost.getCurrentActiveCall();
</ins><span class="cx">     QSharedPointer&lt;Call&gt; call = g_FSHost.getCallByUUID(item-&gt;data(Qt::UserRole).toString());
</span><span class="cx">     QString switch_str = QString(&quot;switch %1&quot;).arg(call.data()-&gt;getCallID());
</span><span class="cx">     QString result;
</span><span class="lines">@@ -161,6 +163,8 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     ui-&gt;hangupBtn-&gt;setEnabled(true);
</span><ins>+    lastCall.data()-&gt;setActive(false);
+    call.data()-&gt;setActive(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MainWindow::makeCall()
</span><span class="lines">@@ -220,6 +224,31 @@
</span><span class="cx">     ui-&gt;hangupBtn-&gt;setEnabled(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MainWindow::recordCall(bool pressed)
+{
+    QSharedPointer&lt;Call&gt; call = g_FSHost.getCurrentActiveCall();
+
+    if (call.isNull())
+    {
+        QMessageBox::warning(this,tr(&quot;Record call&quot;),
+                             tr(&quot;&lt;p&gt;FSComm reports that there are no active calls to be recorded.&quot;
+                                &quot;&lt;p&gt;Please report this bug.&quot;),
+                             QMessageBox::Ok);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Could not record call because there is not current active call!.\n&quot;);
+        return;
+    }
+
+    if (call.data()-&gt;toggleRecord(pressed) != SWITCH_STATUS_SUCCESS)
+    {
+        QMessageBox::warning(this,tr(&quot;Record call&quot;),
+                             tr(&quot;&lt;p&gt;Could not get active call to start/stop recording.&quot;
+                                &quot;&lt;p&gt;Please report this bug.&quot;),
+                             QMessageBox::Ok);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Could not record call [%s].\n&quot;, call.data()-&gt;getUUID().toAscii().data());
+        return;
+    }
+}
+
</ins><span class="cx"> void MainWindow::newOutgoingCall(QSharedPointer&lt;Call&gt; call)
</span><span class="cx"> {
</span><span class="cx">     ui-&gt;textEdit-&gt;setText(QString(&quot;Calling %1 (%2)&quot;).arg(call.data()-&gt;getCidName(), call.data()-&gt;getCidNumber()));
</span><span class="lines">@@ -227,6 +256,7 @@
</span><span class="cx">     item-&gt;setData(Qt::UserRole, call.data()-&gt;getUUID());
</span><span class="cx">     ui-&gt;listCalls-&gt;addItem(item);
</span><span class="cx">     ui-&gt;hangupBtn-&gt;setEnabled(true);
</span><ins>+    call.data()-&gt;setActive(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MainWindow::ringing(QSharedPointer&lt;Call&gt; call)
</span><span class="lines">@@ -248,6 +278,7 @@
</span><span class="cx">     item-&gt;setData(Qt::UserRole, call.data()-&gt;getUUID());
</span><span class="cx">     ui-&gt;listCalls-&gt;addItem(item);
</span><span class="cx">     ui-&gt;answerBtn-&gt;setEnabled(true);
</span><ins>+    call.data()-&gt;setActive(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MainWindow::answered(QSharedPointer&lt;Call&gt; call)
</span><span class="lines">@@ -301,6 +332,7 @@
</span><span class="cx">     ui-&gt;textEdit-&gt;setText(tr(&quot;Call with %1 (%2) failed with reason %3.&quot;).arg(call.data()-&gt;getCidName(),
</span><span class="cx">                                                                              call.data()-&gt;getCidNumber(),
</span><span class="cx">                                                                              call.data()-&gt;getCause()));
</span><ins>+    call.data()-&gt;setActive(false);
</ins><span class="cx">     /* TODO: Will cause problems if 2 calls are received at the same time */
</span><span class="cx">     ui-&gt;answerBtn-&gt;setEnabled(false);
</span><span class="cx">     ui-&gt;hangupBtn-&gt;setEnabled(false);
</span><span class="lines">@@ -334,6 +366,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    call.data()-&gt;setActive(false);
</ins><span class="cx">     ui-&gt;textEdit-&gt;setText(tr(&quot;Call with %1 (%2) hungup.&quot;).arg(call.data()-&gt;getCidName(), call.data()-&gt;getCidNumber()));
</span><span class="cx">     /* TODO: Will cause problems if 2 calls are received at the same time */
</span><span class="cx">     ui-&gt;answerBtn-&gt;setEnabled(false);
</span></span></pre></div>
<a id="freeswitchtrunkfscommmainwindowh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/mainwindow.h (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/mainwindow.h        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/mainwindow.h        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">     void answered(QSharedPointer&lt;Call&gt;);
</span><span class="cx">     void hungup(QSharedPointer&lt;Call&gt;);
</span><span class="cx">     void callFailed(QSharedPointer&lt;Call&gt;);
</span><ins>+    void recordCall(bool);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     Ui::MainWindow *ui;
</span></span></pre></div>
<a id="freeswitchtrunkfscommmainwindowui"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/fscomm/mainwindow.ui (16348 => 16349)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/fscomm/mainwindow.ui        2010-01-18 00:29:03 UTC (rev 16348)
+++ freeswitch/trunk/fscomm/mainwindow.ui        2010-01-18 02:43:48 UTC (rev 16349)
</span><span class="lines">@@ -39,6 +39,19 @@
</span><span class="cx">           &lt;/property&gt;
</span><span class="cx">          &lt;/widget&gt;
</span><span class="cx">         &lt;/item&gt;
</span><ins>+        &lt;item&gt;
+         &lt;widget class=&quot;QPushButton&quot; name=&quot;recoredCallBtn&quot;&gt;
+          &lt;property name=&quot;text&quot;&gt;
+           &lt;string&gt;Record&lt;/string&gt;
+          &lt;/property&gt;
+          &lt;property name=&quot;checkable&quot;&gt;
+           &lt;bool&gt;true&lt;/bool&gt;
+          &lt;/property&gt;
+          &lt;property name=&quot;checked&quot;&gt;
+           &lt;bool&gt;false&lt;/bool&gt;
+          &lt;/property&gt;
+         &lt;/widget&gt;
+        &lt;/item&gt;
</ins><span class="cx">        &lt;/layout&gt;
</span><span class="cx">       &lt;/item&gt;
</span><span class="cx">       &lt;item&gt;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>