Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/call.h (16128 => 16129)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/call.h 2010-01-03 14:58:50 UTC (rev 16128)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/call.h 2010-01-03 20:17:38 UTC (rev 16129)
@@ -47,6 +47,7 @@
QString getCidNumber(void) { return _cid_number; }
int getCallID(void) { return _call_id; }
QString getUUID(void) { return _uuid; }
+ void setbUUID(QString uuid) { _buuid = uuid; }
fsphone_call_direction_t getDirection() { return _direction; }
private:
@@ -55,6 +56,7 @@
QString _cid_number;
fsphone_call_direction_t _direction;
QString _uuid;
+ QString _buuid;
};
Q_DECLARE_METATYPE(Call)
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp (16128 => 16129)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp 2010-01-03 14:58:50 UTC (rev 16128)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp 2010-01-03 20:17:38 UTC (rev 16129)
@@ -145,16 +145,15 @@
}
}
-void FSHost::generalEventHandler(switch_event_t *event)
+switch_status_t FSHost::processAlegEvent(switch_event_t * event, QString uuid)
{
- QString uuid = switch_event_get_header_nil(event, "Unique-ID");
-
- if (_active_calls.contains(uuid))
+ if (_active_calls.value(uuid)->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
{
switch(event->event_id) {
case SWITCH_EVENT_CHANNEL_ANSWER:
- case SWITCH_EVENT_CHANNEL_BRIDGE:
{
+ _active_calls.value(uuid)->setbUUID(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"));
+ _bleg_uuids.insert(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"), uuid);
emit answered(uuid);
break;
}
@@ -163,26 +162,85 @@
emit hungup(uuid);
break;
}
- case SWITCH_EVENT_CUSTOM:
+ case SWITCH_EVENT_CHANNEL_STATE:
{
- /* We dont want to treat this anymore */
- if (strcmp(event->subclass_name, "portaudio::ringing") == 0)
- {
- return;
- }
+ printf("CHANNEL_STATE Answer-State: %s | Channel-State: %s | %s | %s\n", switch_event_get_header_nil(event, "Answer-State"),switch_event_get_header_nil(event, "Channel-State"), uuid.toAscii().constData(), switch_event_get_header_nil(event, "Other-Leg-Unique-ID"));
+ break;
}
default:
{
- printf("Untreated event from an UUID we have: %s -> %s | %s\n", switch_event_name(event->event_id), (!zstr(event->subclass_name) ? event->subclass_name : "NULL"), uuid.toAscii().constData());
+ break;
}
}
}
+ /* Outbound call */
+ else
+ {
+ switch(event->event_id)
+ {
+ case SWITCH_EVENT_CHANNEL_BRIDGE:
+ {
+ _active_calls.value(uuid)->setbUUID(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"));
+ _bleg_uuids.insert(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"), uuid);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+switch_status_t FSHost::processBlegEvent(switch_event_t * event, QString buuid)
+{
+ QString uuid = _bleg_uuids.value(buuid);
+ printf("We know this is an uuid related to our call: %s | Event: %s\n", buuid.toAscii().constData(),
+ switch_event_name(event->event_id));
+ /* Inbound call */
+ if (_active_calls.value(uuid)->getDirection() == FSPHONE_CALL_DIRECTION_INBOUND)
+ {
+ qDebug() << " Inbound call";
+ }
+ /* Outbound call */
+ else
+ {
+ switch(event->event_id)
+ {
+ case SWITCH_EVENT_CHANNEL_ANSWER:
+ {
+ emit answered(uuid);
+ }
+ default:
+ break;
+ }
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+void FSHost::generalEventHandler(switch_event_t *event)
+{
+ QString uuid = switch_event_get_header_nil(event, "Unique-ID");
+
+ if (_bleg_uuids.contains(uuid))
+ {
+ if (processBlegEvent(event, uuid) == SWITCH_STATUS_SUCCESS)
+ {
+ return;
+ }
+ }
+ if (_active_calls.contains(uuid))
+ {
+ if (processAlegEvent(event, uuid) == SWITCH_STATUS_SUCCESS)
+ {
+ return;
+ }
+ }
+
/* This is how we identify new calls, inbound and outbound */
switch(event->event_id) {
case SWITCH_EVENT_CUSTOM:
{
- if (strcmp(event->subclass_name, "portaudio::ringing") == 0)
+ if (strcmp(event->subclass_name, "portaudio::ringing") == 0 && !_active_calls.contains(uuid))
{
Call *call = new Call(atoi(switch_event_get_header_nil(event, "call_id")),
switch_event_get_header_nil(event, "Caller-Caller-ID-Name"),
@@ -196,7 +254,7 @@
{
Call *call = new Call(atoi(switch_event_get_header_nil(event, "call_id")),NULL,
switch_event_get_header_nil(event, "Caller-Destination-Number"),
- FSPHONE_CALL_DIRECTION_INBOUND,
+ FSPHONE_CALL_DIRECTION_OUTBOUND,
uuid);
_active_calls.insert(uuid, call);
emit newOutgoingCall(uuid);
@@ -226,7 +284,7 @@
}
else
{
- printf("We got a not treated custom event: %s\n", (!zstr(event->subclass_name) ? event->subclass_name : "NULL"));
+ //printf("We got a not treated custom event: %s\n", (!zstr(event->subclass_name) ? event->subclass_name : "NULL"));
}
break;
}
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h (16128 => 16129)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h 2010-01-03 14:58:50 UTC (rev 16128)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h 2010-01-03 20:17:38 UTC (rev 16129)
@@ -80,7 +80,10 @@
void gwStateChange(QString, int);
private:
+ switch_status_t processBlegEvent(switch_event_t *, QString);
+ switch_status_t processAlegEvent(switch_event_t *, QString);
QHash<QString, Call*> _active_calls;
+ QHash<QString, QString> _bleg_uuids;
};
extern FSHost g_FSHost;
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui (16128 => 16129)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui 2010-01-03 14:58:50 UTC (rev 16128)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui 2010-01-03 20:17:38 UTC (rev 16129)
@@ -213,6 +213,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTableWidget" name="tableAccounts">
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
@@ -243,18 +246,6 @@
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
- <attribute name="verticalHeaderVisible">
- <bool>false</bool>
- </attribute>
- <attribute name="horizontalHeaderCascadingSectionResizes">
- <bool>false</bool>
- </attribute>
- <attribute name="horizontalHeaderVisible">
- <bool>true</bool>
- </attribute>
- <attribute name="verticalHeaderHighlightSections">
- <bool>false</bool>
- </attribute>
<column>
<property name="text">
<string>Account</string>
@@ -280,7 +271,7 @@
<x>0</x>
<y>0</y>
<width>579</width>
- <height>24</height>
+ <height>22</height>
</rect>
</property>
</widget>