From 1b919f2c6f8ecf632aac9d9bd5e97c998fe6d71a Mon Sep 17 00:00:00 2001 From: Joao Mesquita Date: Mon, 5 Apr 2010 03:03:06 -0300 Subject: [PATCH] Refactor the way we track events. Testing needed, please. Lots of bugs to be found, for sure. --- fscomm/FSComm.pro | 6 +- fscomm/call.cpp | 23 +-- fscomm/call.h | 30 ++-- fscomm/channel.cpp | 6 + fscomm/channel.h | 31 ++++ fscomm/conf/freeswitch.xml | 1 + fscomm/fshost.cpp | 356 ++++++++++++++++++------------------- fscomm/fshost.h | 37 +++- fscomm/mainwindow.cpp | 36 ++-- 9 files changed, 293 insertions(+), 233 deletions(-) create mode 100644 fscomm/channel.cpp create mode 100644 fscomm/channel.h diff --git a/fscomm/FSComm.pro b/fscomm/FSComm.pro index 32d76548a8..8542f54123 100644 --- a/fscomm/FSComm.pro +++ b/fscomm/FSComm.pro @@ -32,7 +32,8 @@ SOURCES += main.cpp \ preferences/accountdialog.cpp \ preferences/prefaccounts.cpp \ account.cpp \ - widgets/codecwidget.cpp + widgets/codecwidget.cpp \ + channel.cpp HEADERS += mainwindow.h \ fshost.h \ call.h \ @@ -43,7 +44,8 @@ HEADERS += mainwindow.h \ preferences/accountdialog.h \ preferences/prefaccounts.h \ account.h \ - widgets/codecwidget.h + widgets/codecwidget.h \ + channel.h FORMS += mainwindow.ui \ preferences/prefdialog.ui \ preferences/accountdialog.ui \ diff --git a/fscomm/call.cpp b/fscomm/call.cpp index 32bdaf894a..1fa8775e32 100644 --- a/fscomm/call.cpp +++ b/fscomm/call.cpp @@ -32,18 +32,7 @@ #include Call::Call() -{ -} - -Call::Call(int call_id, QString cid_name, QString cid_number, fscomm_call_direction_t direction, QString uuid) : - _call_id(call_id), - _cid_name(cid_name), - _cid_number(cid_number), - _direction(direction), - _uuid (uuid) -{ - _isActive = false; -} +{} switch_status_t Call::toggleRecord(bool startRecord) { @@ -56,14 +45,14 @@ switch_status_t Call::toggleRecord(bool startRecord) _recording_filename = QString("%1/.fscomm/recordings/%2_%3.wav").arg( conf_dir.absolutePath(), QDateTime::currentDateTime().toString("yyyyMMddhhmmss"), - _cid_number); - status = g_FSHost.sendCmd("uuid_record", QString("%1 start %2").arg(_uuid, _recording_filename).toAscii().data(),&result); + getCidNumber()); + status = g_FSHost.sendCmd("uuid_record", QString("%1 start %2").arg(getUuid(), _recording_filename).toAscii().data(),&result); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stopping call recording on call [%s]\n", - _uuid.toAscii().data()); - status = g_FSHost.sendCmd("uuid_record", QString("%1 stop %2").arg(_uuid, _recording_filename).toAscii().data(),&result); + getUuid().toAscii().data()); + status = g_FSHost.sendCmd("uuid_record", QString("%1 stop %2").arg(getUuid(), _recording_filename).toAscii().data(),&result); } return status; @@ -74,7 +63,7 @@ void Call::sendDTMF(QString digit) QString result; QString dtmf_string = QString("dtmf %1").arg(digit); if (g_FSHost.sendCmd("pa", dtmf_string.toAscii(), &result) == SWITCH_STATUS_FALSE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not send DTMF digit %s on call[%s]", digit.toAscii().data(), _uuid.toAscii().data()); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not send DTMF digit %s on call[%s]", digit.toAscii().data(), getUuid().toAscii().data()); QMessageBox::critical(0, QWidget::tr("DTMF Error"), QWidget::tr("There was an error sending DTMF, please report this bug."), QMessageBox::Ok); } } diff --git a/fscomm/call.h b/fscomm/call.h index 4973c0484d..5662a75876 100644 --- a/fscomm/call.h +++ b/fscomm/call.h @@ -32,6 +32,7 @@ #include #include #include +#include "channel.h" typedef enum { FSCOMM_CALL_STATE_RINGING = 0, @@ -48,12 +49,20 @@ typedef enum { class Call { public: Call(); - Call(int call_id, QString cid_name, QString cid_number, fscomm_call_direction_t direction, QString uuid); - QString getCidName(void) { return _cid_name; } - QString getCidNumber(void) { return _cid_number; } - int getCallID(void) { return _call_id; } - QString getUUID(void) { return _uuid; } - void setbUUID(QString uuid) { _buuid = uuid; } + /* Needs rework */ + QString getCidName(void) { return _channel.data()->getCidName(); } + QString getCidNumber(void) { return _channel.data()->getCidNumber(); } + QString getDestinationNumber(void) { return _otherLegChannel.data()->getDestinationNumber(); } + + void setChannel(QSharedPointer channel) { _channel = channel; } + QSharedPointer getChannel() { return _channel; } + void setOtherLegChannel(QSharedPointer channel) { _otherLegChannel = channel; } + QSharedPointer getOtherLegChannel() { return _otherLegChannel; } + + QString getUuid(void) { return _channel.data()->getUuid(); } + QString getOtherLegUuid(void) { return _otherLegChannel.data()->getUuid(); } + void setCallDirection(fscomm_call_direction_t dir) { _direction = dir; } + int getCallID(void) { return _channel.data()->getPaCallId(); } fscomm_call_direction_t getDirection() { return _direction; } fscomm_call_state_t getState() { return _state; } void setState(fscomm_call_state_t state) { _state = state; } @@ -67,13 +76,12 @@ public: QTime getCurrentStateTime(); private: - int _call_id; - QString _cid_name; - QString _cid_number; + QSharedPointer _channel; /* This should be our portaudio channel */ + QSharedPointer _otherLegChannel; + QString _cause; fscomm_call_direction_t _direction; - QString _uuid; - QString _buuid; + bool _isActive; QString _recording_filename; fscomm_call_state_t _state; diff --git a/fscomm/channel.cpp b/fscomm/channel.cpp new file mode 100644 index 0000000000..75f1aaf29e --- /dev/null +++ b/fscomm/channel.cpp @@ -0,0 +1,6 @@ +#include "channel.h" + +Channel::Channel(QString uuid): + _uuid(uuid) +{ +} diff --git a/fscomm/channel.h b/fscomm/channel.h new file mode 100644 index 0000000000..2dc744261e --- /dev/null +++ b/fscomm/channel.h @@ -0,0 +1,31 @@ +#ifndef CHANNEL_H +#define CHANNEL_H + +#include + +class Channel +{ +public: + Channel() {} + Channel(QString uuid); + QString getUuid() { return _uuid; } + void setCidName(QString cidName) { _cidName = cidName; } + QString getCidName() { return _cidName; } + void setCidNumber(QString cidNumber) { _cidNumber = cidNumber; } + QString getCidNumber() { return _cidNumber; } + void setDestinatinonNumber(QString destinationNumber) { _destinationNumber = destinationNumber; } + QString getDestinationNumber() { return _destinationNumber; } + + int getPaCallId() { return _pa_call_id; } + +private: + QString _uuid; + QString _cidName; + QString _cidNumber; + QString _destinationNumber; + int _pa_call_id; +}; + +Q_DECLARE_METATYPE(Channel) + +#endif // CHANNEL_H diff --git a/fscomm/conf/freeswitch.xml b/fscomm/conf/freeswitch.xml index 18e514546d..285940ad18 100644 --- a/fscomm/conf/freeswitch.xml +++ b/fscomm/conf/freeswitch.xml @@ -89,6 +89,7 @@ + diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index c5f5056c0d..609f7e9351 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -43,9 +43,10 @@ FSHost::FSHost(QObject *parent) : switch_core_set_globals(); qRegisterMetaType >("QSharedPointer"); + qRegisterMetaType >("QSharedPointer"); qRegisterMetaType >("QSharedPointer"); - connect(this, SIGNAL(loadedModule(QString,QString,QString)), this, SLOT(minimalModuleLoaded(QString,QString,QString))); + connect(this, SIGNAL(loadedModule(QString,QString)), this, SLOT(minimalModuleLoaded(QString,QString))); } @@ -167,190 +168,95 @@ void FSHost::run(void) } } -switch_status_t FSHost::processAlegEvent(switch_event_t * event, QString uuid) -{ - switch_status_t status = SWITCH_STATUS_SUCCESS; - QSharedPointer call = _active_calls.value(uuid); - - if (call.isNull()) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "We don't have a call object for A leg on event %s.\n", switch_event_name(event->event_id)); - qDebug() << _active_calls.keys(); - printEventHeaders(event); - return SWITCH_STATUS_FALSE; - } - - /* Inbound call */ - if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND) - { - switch(event->event_id) { - case SWITCH_EVENT_CHANNEL_ANSWER: - { - QString answeredEpoch = switch_event_get_header_nil(event, "Caller-Channel-Answered-Time"); - call.data()->setAnsweredEpoch(answeredEpoch.toLong()); - call.data()->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); - call.data()->setState(FSCOMM_CALL_STATE_ANSWERED); - emit answered(call); - break; - } - case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE: - { - emit hungup(_active_calls.take(uuid)); - break; - } - case SWITCH_EVENT_CHANNEL_STATE: - { - qDebug() << QString("CHANNEL_STATE Answer-State: %1 | Channel-State: %2 | %3 | %4\n").arg(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: - { - break; - } - } - } - /* Outbound call */ - else - { - switch(event->event_id) - { - case SWITCH_EVENT_CHANNEL_BRIDGE: - { - _active_calls.value(uuid).data()->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; - } - case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE: - { - if (call.data()->getState() == FSCOMM_CALL_STATE_TRYING) - { - QString cause = switch_event_get_header_nil(event, "Hangup-Cause"); - call.data()->setState(FSCOMM_CALL_STATE_FAILED); - call.data()->setCause(cause); - emit callFailed(call); - _active_calls.take(uuid); - } - break; - } - default: - qDebug() << QString("A leg: %1(%2)\n").arg(switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass")); - break; - } - } - return status; -} - -switch_status_t FSHost::processBlegEvent(switch_event_t * event, QString buuid) -{ - QString uuid = _bleg_uuids.value(buuid); - switch_status_t status = SWITCH_STATUS_SUCCESS; - QSharedPointer call = _active_calls.value(uuid); - - if (call.isNull()) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "We don't have a call object for B leg on event %s.\n", switch_event_name(event->event_id)); - qDebug() << _active_calls.keys(); - printEventHeaders(event); - return SWITCH_STATUS_FALSE; - } - - /* Inbound call */ - if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND) - { - qDebug() << " Inbound call"; - } - /* Outbound call */ - else - { - switch(event->event_id) - { - case SWITCH_EVENT_CHANNEL_ANSWER: - { - /* When do we get here? */ - QString answeredEpoch = switch_event_get_header_nil(event, "Caller-Channel-Answered-Time"); - call.data()->setAnsweredEpoch(answeredEpoch.toULongLong()); - emit answered(call); - break; - } - case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE: - { - _active_calls.take(uuid); - emit hungup(call); - _bleg_uuids.take(buuid); - break; - } - case SWITCH_EVENT_CHANNEL_STATE: - { - if (QString(switch_event_get_header_nil(event, "Answer-State")) == "early") - { - call.data()->setState(FSCOMM_CALL_STATE_RINGING); - emit ringing(call); - } - else if (QString(switch_event_get_header_nil(event, "Answer-State")) == "answered") - { - call.data()->setState(FSCOMM_CALL_STATE_ANSWERED); - emit answered(call); - } - break; - } - - default: - qDebug() << QString("B leg: %1(%2)\n").arg(switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass")); - break; - } - } - return status; -} - void FSHost::generalEventHandler(switch_event_t *event) { - /*printEventHeaders(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: + case SWITCH_EVENT_CHANNEL_CREATE: /*1A - 17B*/ { - if (strcmp(event->subclass_name, "portaudio::ringing") == 0 && !_active_calls.contains(uuid)) - { - Call *callPtr = new Call(atoi(switch_event_get_header_nil(event, "call_id")), - switch_event_get_header_nil(event, "Caller-Caller-ID-Name"), - switch_event_get_header_nil(event, "Caller-Caller-ID-Number"), - FSCOMM_CALL_DIRECTION_INBOUND, - uuid); - QSharedPointer call(callPtr); - _active_calls.insert(uuid, call); - call.data()->setState(FSCOMM_CALL_STATE_RINGING); - emit ringing(call); - } - else if (strcmp(event->subclass_name, "portaudio::makecall") == 0) - { - Call *callPtr = new Call(atoi(switch_event_get_header_nil(event, "call_id")),NULL, - switch_event_get_header_nil(event, "Caller-Destination-Number"), - FSCOMM_CALL_DIRECTION_OUTBOUND, - uuid); - QSharedPointer call(callPtr); - _active_calls.insert(uuid, call); - call.data()->setState(FSCOMM_CALL_STATE_TRYING); - emit newOutgoingCall(call); - } - else if (strcmp(event->subclass_name, "sofia::gateway_state") == 0) + eventChannelCreate(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_ANSWER: /*2A - 31B*/ + { + eventChannelAnswer(event, uuid); + break; + } + case SWITCH_EVENT_CODEC:/*3/4A - 24/25B*/ + { + eventCodec(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_STATE:/*6/7/8/37/44/46A - 20/21/22/28/38/40/42B*/ + { + eventChannelState(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_EXECUTE:/*9/11/13/15A*/ + { + eventChannelExecute(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE:/*10/12/14/16/35A*/ + { + eventChannelExecuteComplete(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_OUTGOING:/*18B*/ + { + eventChannelOutgoing(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_ORIGINATE:/*19B*/ + { + eventChannelOriginate(event, uuid); + break; + } + case SWITCH_EVENT_CALL_UPDATE:/*23/29/30B*/ + { + eventCallUpdate(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA:/*26B*/ + { + eventChannelProgressMedia(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_BRIDGE:/*27A*/ + { + eventChannelBridge(event, uuid); + break; + } + /*32?*/ + /*case SWITCH_EVENT_RECV_INFO: + { + eventRecvInfo(event, uuid); + break; + }*/ + case SWITCH_EVENT_CHANNEL_HANGUP:/*36A-33B*/ + { + eventChannelHangup(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_UNBRIDGE:/*34A*/ + { + eventChannelUnbridge(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:/*39/43B*/ + { + eventChannelHangupComplete(event, uuid); + break; + } + case SWITCH_EVENT_CHANNEL_DESTROY:/*45A-41B*/ + { + eventChannelDestroy(event, uuid); + break; + } + case SWITCH_EVENT_CUSTOM:/*5A*/ + { + if (strcmp(event->subclass_name, "sofia::gateway_state") == 0) { QString state = switch_event_get_header_nil(event, "State"); QString gw = switch_event_get_header_nil(event, "Gateway"); @@ -412,16 +318,15 @@ void FSHost::generalEventHandler(switch_event_t *event) } else { - printEventHeaders(event); + //printEventHeaders(event); } break; } case SWITCH_EVENT_MODULE_LOAD: { QString modType = switch_event_get_header_nil(event, "type"); - QString modName = switch_event_get_header_nil(event, "name"); QString modKey = switch_event_get_header_nil(event, "key"); - emit loadedModule(modType, modName, modKey); + emit loadedModule(modType, modKey); break; } default: @@ -429,7 +334,90 @@ void FSHost::generalEventHandler(switch_event_t *event) } } -void FSHost::minimalModuleLoaded(QString modType, QString modName, QString modKey) +void FSHost::eventChannelCreate(switch_event_t *event, QString uuid) +{ + Channel *channelPtr = new Channel(uuid); + QSharedPointerchannel(channelPtr); + _channels.insert(uuid, channel); +} +void FSHost::eventChannelAnswer(switch_event_t *event, QString uuid) +{ + _channels.value(uuid).data()->setDestinatinonNumber(switch_event_get_header_nil(event, "Caller-Destination-Number")); + if (_active_calls.contains(uuid)) + { + _active_calls.value(uuid).data()->setAnsweredEpoch(QString(switch_event_get_header_nil(event, "Caller-Channel-Answered-Time")).toULongLong()); + emit answered(_active_calls.value(uuid)); + } +} +void FSHost::eventChannelState(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelExecute(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelExecuteComplete(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelOutgoing(switch_event_t *event, QString uuid) +{ + /* Checks if this is an inbound or outbound call */ + /** Outbound call */ + if ( strcmp(switch_event_get_header_nil(event, "Caller-Source"), "mod_portaudio") == 0 ) + { + Call *callPtr = new Call(); + + callPtr->setCallDirection(FSCOMM_CALL_DIRECTION_OUTBOUND); + callPtr->setChannel(_channels.value(uuid)); + callPtr->setOtherLegChannel(_channels.value(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"))); + QSharedPointer call(callPtr); + _active_calls.insert(uuid, call); + call.data()->setState(FSCOMM_CALL_STATE_TRYING); + emit newOutgoingCall(call); + } + /** Inbound call */ + else + { + Call *callPtr = new Call(); + + callPtr->setCallDirection(FSCOMM_CALL_DIRECTION_INBOUND); + callPtr->setChannel(_channels.value(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"))); + callPtr->setOtherLegChannel(_channels.value(uuid)); + QSharedPointer call(callPtr); + _active_calls.insert(switch_event_get_header_nil(event, "Other-Leg-Unique-ID"), call); + call.data()->setState(FSCOMM_CALL_STATE_RINGING); + emit ringing(call); + qDebug() << _channels.value(uuid).data()->getCidName() << _channels.value(uuid).data()->getCidNumber(); + } +} +void FSHost::eventChannelOriginate(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelProgressMedia(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelBridge(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelHangup(switch_event_t *event, QString uuid) +{ + if (_active_calls.contains(uuid)) + { + emit hungup(_active_calls.take(uuid)); + } +} +void FSHost::eventChannelUnbridge(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelHangupComplete(switch_event_t *event, QString uuid) +{} +void FSHost::eventChannelDestroy(switch_event_t *event, QString uuid) +{ + _channels.take(uuid); +} +void FSHost::eventCodec(switch_event_t *event, QString uuid) +{ + _channels.value(uuid).data()->setCidName(switch_event_get_header_nil(event, "Caller-Caller-ID-Name")); + _channels.value(uuid).data()->setCidNumber(switch_event_get_header_nil(event, "Caller-Caller-ID-Number")); +} +void FSHost::eventCallUpdate(switch_event_t *event, QString uuid) +{} +void FSHost::eventRecvInfo(switch_event_t *event, QString uuid) +{} + +void FSHost::minimalModuleLoaded(QString modType, QString modKey) { if (modType == "endpoint") { @@ -504,7 +492,7 @@ QSharedPointer FSHost::getCurrentActiveCall() void FSHost::printEventHeaders(switch_event_t *event) { switch_event_header_t *hp; - qDebug() << QString("Received event: %1(%2)\n").arg(switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass")); + qDebug() << QString("Received event: %1(%2)").arg(switch_event_name(event->event_id), switch_event_get_header_nil(event, "Event-Subclass")); for (hp = event->headers; hp; hp = hp->next) { qDebug() << hp->name << "=" << hp->value; } diff --git a/fscomm/fshost.h b/fscomm/fshost.h index f20cd036d2..5f7b113ebc 100644 --- a/fscomm/fshost.h +++ b/fscomm/fshost.h @@ -35,6 +35,7 @@ #include #include #include "call.h" +#include "channel.h" #include "account.h" class FSHost : public QThread @@ -57,15 +58,20 @@ protected: void run(void); signals: + /* Status signals */ void coreLoadingError(QString); void loadingModules(QString, int, QColor); - void loadedModule(QString, QString, QString); + void loadedModule(QString, QString); void ready(void); + + /* Call signals */ void ringing(QSharedPointer); void answered(QSharedPointer); void newOutgoingCall(QSharedPointer); void callFailed(QSharedPointer); void hungup(QSharedPointer); + + /* Account signals */ void accountStateChange(QSharedPointer); void newAccount(QSharedPointer); void delAccount(QSharedPointer); @@ -73,16 +79,37 @@ signals: private slots: /* We need to wait for the gateway deletion before reloading it */ void accountReloadSlot(QSharedPointer); - void minimalModuleLoaded(QString, QString, QString); + void minimalModuleLoaded(QString, QString); private: - switch_status_t processBlegEvent(switch_event_t *, QString); - switch_status_t processAlegEvent(switch_event_t *, QString); void createFolders(); void printEventHeaders(switch_event_t *event); + + /*FSM State handlers*/ + /**Channel Related*/ + void eventChannelCreate(switch_event_t *event, QString uuid); + void eventChannelAnswer(switch_event_t *event, QString uuid); + void eventChannelState(switch_event_t *event, QString uuid); + void eventChannelExecute(switch_event_t *event, QString uuid); + void eventChannelExecuteComplete(switch_event_t *event, QString uuid); + void eventChannelOutgoing(switch_event_t *event, QString uuid); + void eventChannelOriginate(switch_event_t *event, QString uuid); + void eventChannelProgressMedia(switch_event_t *event, QString uuid); + void eventChannelBridge(switch_event_t *event, QString uuid); + void eventChannelHangup(switch_event_t *event, QString uuid); + void eventChannelUnbridge(switch_event_t *event, QString uuid); + void eventChannelHangupComplete(switch_event_t *event, QString uuid); + void eventChannelDestroy(switch_event_t *event, QString uuid); + + /**Others*/ + void eventCodec(switch_event_t *event, QString uuid); + void eventCallUpdate(switch_event_t *event, QString uuid); + void eventRecvInfo(switch_event_t *event, QString uuid); + /*END*/ + QHash > _active_calls; QHash > _accounts; - QHash _bleg_uuids; + QHash > _channels; QList _reloading_Accounts; QList _loadedModules; }; diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index 54143da947..2b2edd9b1d 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -131,6 +131,7 @@ void MainWindow::updateCallTimers() { QTableWidgetItem* item = ui->tableCalls->item(row, 2); QSharedPointer call = g_FSHost.getCallByUUID(item->data(Qt::UserRole).toString()); + /*if (call.data() == NULL) continue;*/ QTime time = call.data()->getCurrentStateTime(); item->setText(time.toString("hh:mm:ss")); item->setTextAlignment(Qt::AlignRight); @@ -357,26 +358,26 @@ void MainWindow::recordCall(bool pressed) tr("

Could not get active call to start/stop recording." "

Please report this bug."), QMessageBox::Ok); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not record call [%s].\n", call.data()->getUUID().toAscii().data()); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not record call [%s].\n", call.data()->getUuid().toAscii().data()); return; } } void MainWindow::newOutgoingCall(QSharedPointer call) { - ui->textEdit->setText(QString("Calling %1 (%2)").arg(call.data()->getCidName(), call.data()->getCidNumber())); + ui->textEdit->setText(QString("Calling %1").arg(call.data()->getDestinationNumber())); ui->tableCalls->setRowCount(ui->tableCalls->rowCount()+1); - QTableWidgetItem *item0 = new QTableWidgetItem(QString("%1 (%2)").arg(call.data()->getCidName(), call.data()->getCidNumber())); - item0->setData(Qt::UserRole, call.data()->getUUID()); + QTableWidgetItem *item0 = new QTableWidgetItem(QString("%1").arg(call.data()->getDestinationNumber())); + item0->setData(Qt::UserRole, call.data()->getUuid()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,0,item0); QTableWidgetItem *item1 = new QTableWidgetItem(tr("Dialing...")); - item1->setData(Qt::UserRole, call.data()->getUUID()); + item1->setData(Qt::UserRole, call.data()->getUuid()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,1,item1); QTableWidgetItem *item2 = new QTableWidgetItem("00:00:00"); - item2->setData(Qt::UserRole, call.data()->getUUID()); + item2->setData(Qt::UserRole, call.data()->getUuid()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,2,item2); ui->tableCalls->resizeColumnsToContents(); @@ -393,7 +394,7 @@ void MainWindow::ringing(QSharedPointer call) for (int i=0; itableCalls->rowCount(); i++) { QTableWidgetItem *item = ui->tableCalls->item(i, 1); - if (item->data(Qt::UserRole).toString() == call.data()->getUUID()) + if (item->data(Qt::UserRole).toString() == call.data()->getUuid()) { item->setText(tr("Ringing")); ui->textEdit->setText(QString("Call from %1 (%2)").arg(call.data()->getCidName(), call.data()->getCidNumber())); @@ -405,15 +406,15 @@ void MainWindow::ringing(QSharedPointer call) ui->tableCalls->setRowCount(ui->tableCalls->rowCount()+1); QTableWidgetItem *item0 = new QTableWidgetItem(QString("%1 (%2)").arg(call.data()->getCidName(), call.data()->getCidNumber())); - item0->setData(Qt::UserRole, call.data()->getUUID()); + item0->setData(Qt::UserRole, call.data()->getUuid()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,0,item0); QTableWidgetItem *item1 = new QTableWidgetItem(tr("Ringing")); - item1->setData(Qt::UserRole, call.data()->getUUID()); + item1->setData(Qt::UserRole, call.data()->getUuid()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,1,item1); QTableWidgetItem *item2 = new QTableWidgetItem("00:00:00"); - item2->setData(Qt::UserRole, call.data()->getUUID()); + item2->setData(Qt::UserRole, call.data()->getUuid()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,2,item2); ui->tableCalls->resizeColumnsToContents(); @@ -429,7 +430,7 @@ void MainWindow::answered(QSharedPointer call) for (int i=0; itableCalls->rowCount(); i++) { QTableWidgetItem *item = ui->tableCalls->item(i, 1); - if (item->data(Qt::UserRole).toString() == call.data()->getUUID()) + if (item->data(Qt::UserRole).toString() == call.data()->getUuid()) { item->setText(tr("Answered")); ui->tableCalls->resizeColumnsToContents(); @@ -463,7 +464,7 @@ void MainWindow::callFailed(QSharedPointer call) for (int i=0; itableCalls->rowCount(); i++) { QTableWidgetItem *item = ui->tableCalls->item(i, 1); - if (item->data(Qt::UserRole).toString() == call.data()->getUUID()) + if (item->data(Qt::UserRole).toString() == call.data()->getUuid()) { ui->tableCalls->removeRow(i); ui->tableCalls->resizeColumnsToContents(); @@ -505,7 +506,7 @@ void MainWindow::hungup(QSharedPointer call) for (int i=0; itableCalls->rowCount(); i++) { QTableWidgetItem *item = ui->tableCalls->item(i, 1); - if (item->data(Qt::UserRole).toString() == call.data()->getUUID()) + if (item->data(Qt::UserRole).toString() == call.data()->getUuid()) { ui->tableCalls->removeRow(i); ui->tableCalls->resizeColumnsToContents(); @@ -515,7 +516,14 @@ void MainWindow::hungup(QSharedPointer call) } } call.data()->setActive(false); - ui->textEdit->setText(tr("Call with %1 (%2) hungup.").arg(call.data()->getCidName(), call.data()->getCidNumber())); + if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND) + { + ui->textEdit->setText(tr("Call with %1 (%2) hungup.").arg(call.data()->getCidName(), call.data()->getCidNumber())); + } + else + { + ui->textEdit->setText(tr("Call with %1 hungup.").arg(call.data()->getCidNumber())); + } /* TODO: Will cause problems if 2 calls are received at the same time */ ui->recoredCallBtn->setEnabled(false); ui->recoredCallBtn->setChecked(false);