<!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][16131] </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=16131">16131</a></dd>
<dt>Author</dt> <dd>jmesquita</dd>
<dt>Date</dt> <dd>2010-01-03 17:36:24 -0600 (Sun, 03 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Got part of the outgoing events working and no mem leaking (I think).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkcontribjmesquitaFSPhonecallh">freeswitch/trunk/contrib/jmesquita/FSPhone/call.h</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitaFSPhonefshostcpp">freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitaFSPhonefshosth">freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitaFSPhonemainwindowcpp">freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitaFSPhonemainwindowh">freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkcontribjmesquitaFSPhonecallh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/call.h (16130 => 16131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/FSPhone/call.h        2010-01-03 21:10:34 UTC (rev 16130)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/call.h        2010-01-03 23:36:24 UTC (rev 16131)
</span><span class="lines">@@ -34,6 +34,12 @@
</span><span class="cx"> #include <fshost.h>
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><ins>+ FSPHONE_CALL_STATE_RINGING = 0,
+ FSPHONE_CALL_STATE_TRYING = 1,
+ FSPHONE_CALL_STATE_ANSWERED = 2
+} fsphone_call_state_t;
+
+typedef enum {
</ins><span class="cx"> FSPHONE_CALL_DIRECTION_INBOUND = 0,
</span><span class="cx"> FSPHONE_CALL_DIRECTION_OUTBOUND = 1
</span><span class="cx"> } fsphone_call_direction_t;
</span><span class="lines">@@ -49,6 +55,8 @@
</span><span class="cx"> QString getUUID(void) { return _uuid; }
</span><span class="cx"> void setbUUID(QString uuid) { _buuid = uuid; }
</span><span class="cx"> fsphone_call_direction_t getDirection() { return _direction; }
</span><ins>+ fsphone_call_state_t getState() { return _state; }
+ void setState(fsphone_call_state_t state) { _state = state; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> int _call_id;
</span><span class="lines">@@ -57,6 +65,7 @@
</span><span class="cx"> fsphone_call_direction_t _direction;
</span><span class="cx"> QString _uuid;
</span><span class="cx"> QString _buuid;
</span><ins>+ fsphone_call_state_t _state;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Q_DECLARE_METATYPE(Call)
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitaFSPhonefshostcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp (16130 => 16131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp        2010-01-03 21:10:34 UTC (rev 16130)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp        2010-01-03 23:36:24 UTC (rev 16131)
</span><span class="lines">@@ -147,19 +147,23 @@
</span><span class="cx">
</span><span class="cx"> switch_status_t FSHost::processAlegEvent(switch_event_t * event, QString uuid)
</span><span class="cx"> {
</span><del>- if (_active_calls.value(uuid)->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
</del><ins>+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ Call * call = _active_calls.value(uuid);
+ /* Inbound call */
+ if (call->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
</ins><span class="cx"> {
</span><span class="cx"> switch(event->event_id) {
</span><span class="cx"> case SWITCH_EVENT_CHANNEL_ANSWER:
</span><span class="cx"> {
</span><del>- _active_calls.value(uuid)->setbUUID(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"));
</del><ins>+ call->setbUUID(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"));
</ins><span class="cx"> _bleg_uuids.insert(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"), uuid);
</span><ins>+ call->setState(FSPHONE_CALL_STATE_ANSWERED);
</ins><span class="cx"> emit answered(uuid);
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:
</span><span class="cx"> {
</span><del>- emit hungup(uuid);
</del><ins>+ emit hungup(_active_calls.take(uuid));
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case SWITCH_EVENT_CHANNEL_STATE:
</span><span class="lines">@@ -184,20 +188,30 @@
</span><span class="cx"> _bleg_uuids.insert(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"), uuid);
</span><span class="cx"> break;
</span><span class="cx"> }
</span><ins>+ case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:
+ {
+ if (call->getState() == FSPHONE_CALL_STATE_TRYING)
+ {
+ emit callFailed(uuid);
+ _active_calls.take(uuid);
+ }
+ break;
+ }
</ins><span class="cx"> default:
</span><ins>+ printf("A leg: %s(%s)\n",switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass"));
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+ return status;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> switch_status_t FSHost::processBlegEvent(switch_event_t * event, QString buuid)
</span><span class="cx"> {
</span><span class="cx"> QString uuid = _bleg_uuids.value(buuid);
</span><del>- printf("We know this is an uuid related to our call: %s | Event: %s\n", buuid.toAscii().constData(),
- switch_event_name(event->event_id));
</del><ins>+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ Call * call = _active_calls.value(uuid);
</ins><span class="cx"> /* Inbound call */
</span><del>- if (_active_calls.value(uuid)->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
</del><ins>+ if (call->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
</ins><span class="cx"> {
</span><span class="cx"> qDebug() << " Inbound call";
</span><span class="cx"> }
</span><span class="lines">@@ -209,12 +223,31 @@
</span><span class="cx"> case SWITCH_EVENT_CHANNEL_ANSWER:
</span><span class="cx"> {
</span><span class="cx"> emit answered(uuid);
</span><ins>+ break;
</ins><span class="cx"> }
</span><ins>+ case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:
+ {
+ emit hungup(_active_calls.take(uuid));
+ _bleg_uuids.take(buuid);
+ break;
+ }
+ case SWITCH_EVENT_CHANNEL_STATE:
+ {
+ if (QString(switch_event_get_header_nil(event, "Answer-State")) == "early")
+ {
+ call->setState(FSPHONE_CALL_STATE_RINGING);
+ emit ringing(uuid);
+ }
+ //printEventHeaders(event);
+ break;
+ }
+
</ins><span class="cx"> default:
</span><ins>+ printf("B leg: %s(%s)\n",switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass"));
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+ return status;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void FSHost::generalEventHandler(switch_event_t *event)
</span><span class="lines">@@ -248,6 +281,7 @@
</span><span class="cx"> FSPHONE_CALL_DIRECTION_INBOUND,
</span><span class="cx"> uuid);
</span><span class="cx"> _active_calls.insert(uuid, call);
</span><ins>+ call->setState(FSPHONE_CALL_STATE_RINGING);
</ins><span class="cx"> emit ringing(uuid);
</span><span class="cx"> }
</span><span class="cx"> else if (strcmp(event->subclass_name, "portaudio::makecall") == 0)
</span><span class="lines">@@ -257,6 +291,7 @@
</span><span class="cx"> FSPHONE_CALL_DIRECTION_OUTBOUND,
</span><span class="cx"> uuid);
</span><span class="cx"> _active_calls.insert(uuid, call);
</span><ins>+ call->setState(FSPHONE_CALL_STATE_TRYING);
</ins><span class="cx"> emit newOutgoingCall(uuid);
</span><span class="cx"> }
</span><span class="cx"> else if (strcmp(event->subclass_name, "sofia::gateway_state") == 0)
</span><span class="lines">@@ -288,6 +323,8 @@
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> }
</span><ins>+ default:
+ break;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -301,3 +338,13 @@
</span><span class="cx">
</span><span class="cx"> return status;
</span><span class="cx"> }
</span><ins>+
+void FSHost::printEventHeaders(switch_event_t *event)
+{
+ switch_event_header_t *hp;
+ printf("Received event: %s(%s)\n", switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass"));
+ for (hp = event->headers; hp; hp = hp->next) {
+ printf("%s=%s\n", hp->name, hp->value);
+ }
+ printf("\n\n");
+}
</ins></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitaFSPhonefshosth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h (16130 => 16131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h        2010-01-03 21:10:34 UTC (rev 16130)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h        2010-01-03 23:36:24 UTC (rev 16131)
</span><span class="lines">@@ -76,12 +76,14 @@
</span><span class="cx"> void ringing(QString);
</span><span class="cx"> void answered(QString);
</span><span class="cx"> void newOutgoingCall(QString);
</span><del>- void hungup(QString);
</del><ins>+ void callFailed(QString);
+ void hungup(Call*);
</ins><span class="cx"> void gwStateChange(QString, int);
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> switch_status_t processBlegEvent(switch_event_t *, QString);
</span><span class="cx"> switch_status_t processAlegEvent(switch_event_t *, QString);
</span><ins>+ void printEventHeaders(switch_event_t *event);
</ins><span class="cx"> QHash<QString, Call*> _active_calls;
</span><span class="cx"> QHash<QString, QString> _bleg_uuids;
</span><span class="cx"> };
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitaFSPhonemainwindowcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp (16130 => 16131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp        2010-01-03 21:10:34 UTC (rev 16130)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp        2010-01-03 23:36:24 UTC (rev 16131)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> connect(&g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady()));
</span><span class="cx"> connect(&g_FSHost, SIGNAL(ringing(QString)), this, SLOT(ringing(QString)));
</span><span class="cx"> connect(&g_FSHost, SIGNAL(answered(QString)), this, SLOT(answered(QString)));
</span><del>- connect(&g_FSHost, SIGNAL(hungup(QString)), this, SLOT(hungup(QString)));
</del><ins>+ connect(&g_FSHost, SIGNAL(hungup(Call*)), this, SLOT(hungup(Call*)));
</ins><span class="cx"> connect(&g_FSHost, SIGNAL(newOutgoingCall(QString)), this, SLOT(newOutgoingCall(QString)));
</span><span class="cx"> connect(&g_FSHost, SIGNAL(gwStateChange(QString,int)), this, SLOT(gwStateChanged(QString,int)));
</span><span class="cx"> /*connect(&g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString)));*/
</span><span class="lines">@@ -210,6 +210,17 @@
</span><span class="cx"> {
</span><span class="cx">
</span><span class="cx"> Call *call = g_FSHost.getCallByUUID(uuid);
</span><ins>+ for (int i=0; i<ui->listCalls->count(); i++)
+ {
+ QListWidgetItem *item = ui->listCalls->item(i);
+ if (item->data(Qt::UserRole).toString() == uuid)
+ {
+ item->setText(tr("%1 - Ringing").arg(call->getCidNumber()));
+ ui->textEdit->setText(QString("Call from %1 (%2)").arg(call->getCidName(), call->getCidNumber()));
+ return;
+ }
+ }
+
</ins><span class="cx"> ui->textEdit->setText(QString("Call from %1 (%2)").arg(call->getCidName(), call->getCidNumber()));
</span><span class="cx"> QListWidgetItem *item = new QListWidgetItem(tr("%1 (%2) - Ringing").arg(call->getCidName(), call->getCidNumber()));
</span><span class="cx"> item->setData(Qt::UserRole, uuid);
</span><span class="lines">@@ -225,8 +236,16 @@
</span><span class="cx"> QListWidgetItem *item = ui->listCalls->item(i);
</span><span class="cx"> if (item->data(Qt::UserRole).toString() == uuid)
</span><span class="cx"> {
</span><del>- item->setText(tr("%1 (%2) - Active").arg(call->getCidName(), call->getCidNumber()));
- break;
</del><ins>+ if (call->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
+ {
+ item->setText(tr("%1 (%2) - Active").arg(call->getCidName(), call->getCidNumber()));
+ break;
+ }
+ else
+ {
+ item->setText(tr("%1 - Active").arg(call->getCidNumber()));
+ break;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> ui->dtmf0Btn->setEnabled(true);
</span><span class="lines">@@ -243,13 +262,12 @@
</span><span class="cx"> ui->dtmfPoundBtn->setEnabled(true);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MainWindow::hungup(QString uuid)
</del><ins>+void MainWindow::hungup(Call* call)
</ins><span class="cx"> {
</span><del>- Call *call = g_FSHost.getCallByUUID(uuid);
</del><span class="cx"> for (int i=0; i<ui->listCalls->count(); i++)
</span><span class="cx"> {
</span><span class="cx"> QListWidgetItem *item = ui->listCalls->item(i);
</span><del>- if (item->data(Qt::UserRole).toString() == uuid)
</del><ins>+ if (item->data(Qt::UserRole).toString() == call->getUUID())
</ins><span class="cx"> {
</span><span class="cx"> delete ui->listCalls->takeItem(i);
</span><span class="cx"> break;
</span><span class="lines">@@ -271,6 +289,7 @@
</span><span class="cx"> ui->dtmf9Btn->setEnabled(false);
</span><span class="cx"> ui->dtmfAstBtn->setEnabled(false);
</span><span class="cx"> ui->dtmfPoundBtn->setEnabled(false);
</span><ins>+ delete call;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MainWindow::changeEvent(QEvent *e)
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitaFSPhonemainwindowh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h (16130 => 16131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h        2010-01-03 21:10:34 UTC (rev 16130)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h        2010-01-03 23:36:24 UTC (rev 16131)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> void newOutgoingCall(QString);
</span><span class="cx"> void ringing(QString);
</span><span class="cx"> void answered(QString);
</span><del>- void hungup(QString);
</del><ins>+ void hungup(Call*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> Ui::MainWindow *ui;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>