diff --git a/tests/src/components/call/CallModel.cpp b/tests/src/components/call/CallModel.cpp index a32127d63..419ddc6b7 100644 --- a/tests/src/components/call/CallModel.cpp +++ b/tests/src/components/call/CallModel.cpp @@ -57,10 +57,6 @@ void CallModel::transfer () { // TODO } -float CallModel::getQuality () const { - return m_linphone_call->getCurrentQuality(); -} - // ----------------------------------------------------------------------------- QString CallModel::getSipAddress () const { @@ -90,6 +86,14 @@ CallModel::CallStatus CallModel::getStatus () const { return m_linphone_call->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing; } +int CallModel::getDuration () const { + return m_linphone_call->getDuration(); +} + +float CallModel::getQuality () const { + return m_linphone_call->getCurrentQuality(); +} + bool CallModel::getMicroMuted () const { return m_micro_muted; } diff --git a/tests/src/components/call/CallModel.hpp b/tests/src/components/call/CallModel.hpp index 1eab7af76..2cbcd4000 100644 --- a/tests/src/components/call/CallModel.hpp +++ b/tests/src/components/call/CallModel.hpp @@ -12,6 +12,8 @@ class CallModel : public QObject { Q_PROPERTY(QString sipAddress READ getSipAddress CONSTANT); Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged); Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT); + Q_PROPERTY(int duration READ getDuration CONSTANT); + Q_PROPERTY(float quality READ getQuality CONSTANT); Q_PROPERTY(bool microMuted READ getMicroMuted WRITE setMicroMuted NOTIFY microMutedChanged); Q_PROPERTY(bool pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY statusChanged); Q_PROPERTY(bool videoInputEnabled READ getVideoInputEnabled WRITE setVideoInputEnabled NOTIFY videoInputEnabled); @@ -37,8 +39,6 @@ public: Q_INVOKABLE void terminate (); Q_INVOKABLE void transfer (); - Q_INVOKABLE float getQuality () const; - signals: void statusChanged (CallStatus status); void microMutedChanged (bool status); @@ -53,6 +53,9 @@ private: return m_linphone_call->getDir() == linphone::CallDirOutgoing; } + int getDuration () const; + float getQuality () const; + bool getMicroMuted () const; void setMicroMuted (bool status); diff --git a/tests/src/components/calls/CallsListModel.cpp b/tests/src/components/calls/CallsListModel.cpp index 64a72607b..aa4f489cc 100644 --- a/tests/src/components/calls/CallsListModel.cpp +++ b/tests/src/components/calls/CallsListModel.cpp @@ -63,13 +63,21 @@ QVariant CallsListModel::data (const QModelIndex &index, int role) const { void CallsListModel::launchAudioCall (const QString &sip_uri) const { shared_ptr core = CoreManager::getInstance()->getCore(); - core->inviteAddress( - core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)) - ); + shared_ptr address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)); + + if (!address) + return; + + shared_ptr params = core->createCallParams(nullptr); + params->enableVideo(false); + + core->inviteAddressWithParams(address, params); } void CallsListModel::launchVideoCall (const QString &sip_uri) const { - // TODO + shared_ptr core = CoreManager::getInstance()->getCore(); + // TODO: Deal with videos. + core->inviteAddress(core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri))); } // ----------------------------------------------------------------------------- diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index be10cbdb6..6c7c7d3dd 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -314,6 +314,30 @@ function find (obj, cb, context) { // ----------------------------------------------------------------------------- +function formatElapsedTime (seconds) { + seconds = parseInt(seconds, 10) + + var h = Math.floor(seconds / 3600) + var m = Math.floor((seconds - h * 3600) / 60) + var s = seconds - h * 3600 - m * 60 + + if (h < 10 && h > 0) { + h = '0' + h + } + + if (m < 10) { + m = '0' + m + } + + if (s < 10) { + s = '0' + s + } + + return (h === 0 ? '' : h + ':') + m + ':' + s +} + +// ----------------------------------------------------------------------------- + function formatSize (size) { var units = ['KB', 'MB', 'GB', 'TB'] var unit = 'B' diff --git a/tests/ui/views/App/Calls/Incall.qml b/tests/ui/views/App/Calls/Incall.qml index adbacff35..bc2235257 100644 --- a/tests/ui/views/App/Calls/Incall.qml +++ b/tests/ui/views/App/Calls/Incall.qml @@ -5,6 +5,7 @@ import Common 1.0 import Common.Styles 1.0 import Linphone 1.0 import LinphoneUtils 1.0 +import Utils 1.0 import App.Styles 1.0 @@ -56,11 +57,7 @@ Rectangle { triggeredOnStart: true onTriggered: { - if (!call.getQuality) { - return - } - - var quality = call.getQuality() + var quality = call.quality callQuality.icon = 'call_quality_' + ( // Note: `quality` is in the [0, 5] interval. // It's necessary to map in the `call_quality_` interval. ([0, 3]) @@ -106,6 +103,24 @@ Rectangle { } } + Text { + id: elapsedTime + + Layout.fillWidth: true + color: CallStyle.header.elapsedTime.color + font.pointSize: CallStyle.header.elapsedTime.fontSize + horizontalAlignment: Text.AlignHCenter + + Component.onCompleted: { + var updateDuration = function () { + text = Utils .formatElapsedTime(call.duration) + Utils.setTimeout(elapsedTime, 1000, updateDuration) + } + + updateDuration() + } + } + // ------------------------------------------------------------------------- // Contact visual. // ------------------------------------------------------------------------- diff --git a/tests/ui/views/App/Styles/Calls/CallStyle.qml b/tests/ui/views/App/Styles/Calls/CallStyle.qml index aeaca94e4..c22a18faa 100644 --- a/tests/ui/views/App/Styles/Calls/CallStyle.qml +++ b/tests/ui/views/App/Styles/Calls/CallStyle.qml @@ -47,5 +47,10 @@ QtObject { property int height: 60 property int width: 150 } + + property QtObject elapsedTime: QtObject { + property color color: Colors.j + property int fontSize: 10 + } } }