]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Do the time properly.
authorJoão Mesquita <jmesquita@freeswitch.org>
Thu, 28 Jan 2010 01:12:34 +0000 (01:12 +0000)
committerJoão Mesquita <jmesquita@freeswitch.org>
Thu, 28 Jan 2010 01:12:34 +0000 (01:12 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16528 d0543943-73ff-0310-b7d9-9358b9ac24b2

fscomm/call.cpp
fscomm/call.h
fscomm/fshost.cpp
fscomm/mainwindow.cpp

index f177bc32784da625cac8234afd77adafbd810f1a..32bdaf894a337e7dc0b188be984607dfaa9f1deb 100644 (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");
+}
index 6ec45d2076d968816094f0d19e55b1505d93affe..4973c0484d6089305840640a3a5dee7bc37b2b3d 100644 (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)
index 69e732cc7a97cbb701f6578ccd4523b518db433b..641d46e086958786c972703c3b5e70cc323a24d2 100644 (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;
             }
index 10544f2686b397b65b2316991f28ab9f68f4ca8f..b44570bf0c73457e6a4a73a1fe617e80663ad55d 100644 (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);
     }
 }