Refactor the way we track events. Testing needed, please. Lots of bugs to be found, for sure.

This commit is contained in:
Joao Mesquita 2010-04-05 03:03:06 -03:00
parent a763ddff81
commit 1b919f2c6f
9 changed files with 293 additions and 233 deletions

View File

@ -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 \

View File

@ -32,18 +32,7 @@
#include <fshost.h>
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);
}
}

View File

@ -32,6 +32,7 @@
#include <QtCore>
#include <QString>
#include <switch.h>
#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 = channel; }
QSharedPointer<Channel> getChannel() { return _channel; }
void setOtherLegChannel(QSharedPointer<Channel> channel) { _otherLegChannel = channel; }
QSharedPointer<Channel> 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> _channel; /* This should be our portaudio channel */
QSharedPointer<Channel> _otherLegChannel;
QString _cause;
fscomm_call_direction_t _direction;
QString _uuid;
QString _buuid;
bool _isActive;
QString _recording_filename;
fscomm_call_state_t _state;

6
fscomm/channel.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "channel.h"
Channel::Channel(QString uuid):
_uuid(uuid)
{
}

31
fscomm/channel.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef CHANNEL_H
#define CHANNEL_H
#include <QtCore>
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

View File

@ -89,6 +89,7 @@
<load module="mod_ilbc"/>
<load module="mod_speex"/>
<load module="mod_celt"/>
<load module="mod_silk"/>
<load module="mod_siren"/>
<load module="mod_sndfile"/>
<load module="mod_tone_stream"/>

View File

@ -43,9 +43,10 @@ FSHost::FSHost(QObject *parent) :
switch_core_set_globals();
qRegisterMetaType<QSharedPointer<Call> >("QSharedPointer<Call>");
qRegisterMetaType<QSharedPointer<Call> >("QSharedPointer<Channel>");
qRegisterMetaType<QSharedPointer<Account> >("QSharedPointer<Account>");
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> 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> 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> 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> 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);
QSharedPointer<Channel>channel(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> 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> 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<Call> 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;
}

View File

@ -35,6 +35,7 @@
#include <QSharedPointer>
#include <switch.h>
#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<Call>);
void answered(QSharedPointer<Call>);
void newOutgoingCall(QSharedPointer<Call>);
void callFailed(QSharedPointer<Call>);
void hungup(QSharedPointer<Call>);
/* Account signals */
void accountStateChange(QSharedPointer<Account>);
void newAccount(QSharedPointer<Account>);
void delAccount(QSharedPointer<Account>);
@ -73,16 +79,37 @@ signals:
private slots:
/* We need to wait for the gateway deletion before reloading it */
void accountReloadSlot(QSharedPointer<Account>);
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<QString, QSharedPointer<Call> > _active_calls;
QHash<QString, QSharedPointer<Account> > _accounts;
QHash<QString, QString> _bleg_uuids;
QHash<QString, QSharedPointer<Channel> > _channels;
QList<QString> _reloading_Accounts;
QList<QString> _loadedModules;
};

View File

@ -131,6 +131,7 @@ void MainWindow::updateCallTimers()
{
QTableWidgetItem* item = ui->tableCalls->item(row, 2);
QSharedPointer<Call> 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("<p>Could not get active call to start/stop recording."
"<p>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> 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> call)
for (int i=0; i<ui->tableCalls->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> 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> call)
for (int i=0; i<ui->tableCalls->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> call)
for (int i=0; i<ui->tableCalls->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> call)
for (int i=0; i<ui->tableCalls->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)
}
}
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);