Do the time properly.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16528 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
João Mesquita 2010-01-28 01:12:34 +00:00
parent f859964993
commit 8a3001e611
4 changed files with 16 additions and 2 deletions

View File

@ -78,3 +78,9 @@ void Call::sendDTMF(QString digit)
QMessageBox::critical(0, QWidget::tr("DTMF Error"), QWidget::tr("There was an error sending DTMF, please report this bug."), QMessageBox::Ok);
}
}
QTime Call::getCurrentStateTime()
{
int now = QDateTime::fromTime_t(_answered_epoch).secsTo(QDateTime::currentDateTime());
return QTime::fromString(QString::number(now), "s");
}

View File

@ -63,6 +63,8 @@ public:
bool isActive() { return _isActive == true; }
switch_status_t toggleRecord(bool);
void sendDTMF(QString digit);
void setAnsweredEpoch(qulonglong time) { _answered_epoch = time/1000000; }
QTime getCurrentStateTime();
private:
int _call_id;
@ -75,6 +77,7 @@ private:
bool _isActive;
QString _recording_filename;
fscomm_call_state_t _state;
qulonglong _answered_epoch;
};
Q_DECLARE_METATYPE(Call)

View File

@ -177,6 +177,8 @@ switch_status_t FSHost::processAlegEvent(switch_event_t * event, QString uuid)
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);
@ -257,6 +259,8 @@ switch_status_t FSHost::processBlegEvent(switch_event_t * event, QString buuid)
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;
}

View File

@ -130,9 +130,10 @@ void MainWindow::updateCallTimers()
for(int row=0; row<ui->tableCalls->rowCount(); row++)
{
QTableWidgetItem* item = ui->tableCalls->item(row, 2);
QTime time = QTime::fromString(item->text(),"hh:mm:ss");
time = time.addSecs(1);
QSharedPointer<Call> call = g_FSHost.getCallByUUID(item->data(Qt::UserRole).toString());
QTime time = call.data()->getCurrentStateTime();
item->setText(time.toString("hh:mm:ss"));
item->setTextAlignment(Qt::AlignRight);
}
}