diff --git a/tests/assets/images/end_call.svg b/tests/assets/images/ended_call.svg
similarity index 100%
rename from tests/assets/images/end_call.svg
rename to tests/assets/images/ended_call.svg
diff --git a/tests/resources.qrc b/tests/resources.qrc
index e190e2408..dab9cb87e 100644
--- a/tests/resources.qrc
+++ b/tests/resources.qrc
@@ -27,7 +27,7 @@
assets/images/delete_hovered.svg
assets/images/delete_normal.svg
assets/images/delete_pressed.svg
- assets/images/end_call.svg
+ assets/images/ended_call.svg
assets/images/filter.svg
assets/images/history.svg
assets/images/home_normal.svg
diff --git a/tests/src/app/DefaultTranslator.cpp b/tests/src/app/DefaultTranslator.cpp
index 5decff453..445641a93 100644
--- a/tests/src/app/DefaultTranslator.cpp
+++ b/tests/src/app/DefaultTranslator.cpp
@@ -14,7 +14,7 @@ DefaultTranslator::DefaultTranslator () {
QString basename = info.baseName();
if (m_contexts.contains(basename))
- qWarning() << QStringLiteral("QML file `%1` already exists in context list.").arg(basename);
+ qWarning() << QStringLiteral("QML context `%1` already exists in contexts list.").arg(basename);
else
m_contexts << basename;
}
@@ -33,7 +33,7 @@ QString DefaultTranslator::translate (
QString translation = QTranslator::translate(context, source_text, disambiguation, n);
if (translation.length() == 0)
- qWarning() << QStringLiteral("Unable to found a translation. (context=%1, label=%2)")
+ qWarning() << QStringLiteral("Unable to find a translation. (context=%1, label=%2)")
.arg(context).arg(source_text);
return translation;
diff --git a/tests/src/components/chat/ChatModel.cpp b/tests/src/components/chat/ChatModel.cpp
index ec48223c4..b49b57c84 100644
--- a/tests/src/components/chat/ChatModel.cpp
+++ b/tests/src/components/chat/ChatModel.cpp
@@ -1,6 +1,7 @@
#include
#include
+#include
#include
#include "../../utils.hpp"
@@ -104,16 +105,26 @@ void ChatModel::fillCallStartEntry (
dest["timestamp"] = timestamp;
dest["isOutgoing"] = call_log->getDir() == linphone::CallDirOutgoing;
dest["status"] = call_log->getStatus();
+ dest["isStart"] = true;
}
void ChatModel::fillCallEndEntry (
QVariantMap &dest,
const std::shared_ptr &call_log
) {
+ QDateTime timestamp = QDateTime::fromTime_t(
+ call_log->getStartDate() + call_log->getDuration()
+ );
-
+ dest["type"] = EntryType::CallEntry;
+ dest["timestamp"] = timestamp;
+ dest["isOutgoing"] = call_log->getDir() == linphone::CallDirOutgoing;
+ dest["status"] = call_log->getStatus();
+ dest["isStart"] = false;
}
+// -------------------------------------------------------------------
+
void ChatModel::removeEntry (ChatEntryData &pair) {
int type = pair.first["type"].toInt();
@@ -124,12 +135,32 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
);
break;
case ChatModel::CallEntry:
+ if (pair.first["status"].toInt() == linphone::CallStatusSuccess) {
+ // WARNING: Unable to remove symmetric call here. (start/end)
+ // We are between `beginRemoveRows` and `endRemoveRows`.
+ // A solution is to schedule a `removeEntry` call in the Qt main loop.
+ std::shared_ptr linphone_ptr = pair.second;
+ QTimer::singleShot(0, this, [this, linphone_ptr]() {
+ auto it = find_if(
+ m_entries.begin(), m_entries.end(),
+ [linphone_ptr](const ChatEntryData &pair) {
+ return pair.second == linphone_ptr;
+ }
+ );
+
+ if (it == m_entries.end())
+ qWarning("Unable to find symmetric call.");
+ else
+ removeEntry(distance(m_entries.begin(), it));
+ });
+ }
+
CoreManager::getInstance()->getCore()->removeCallLog(
static_pointer_cast(pair.second)
);
break;
default:
- qWarning() << "Unknown chat entry type:" << type;
+ qWarning() << QStringLiteral("Unknown chat entry type: %1.").arg(type);
}
}
@@ -165,28 +196,38 @@ void ChatModel::setSipAddress (const QString &sip_address) {
}
// Get calls.
+ auto insert_entry = [this](
+ const ChatEntryData &pair,
+ const QList::iterator *start = NULL
+ ) {
+ auto it = lower_bound(
+ start ? *start : m_entries.begin(), m_entries.end(), pair,
+ [](const ChatEntryData &a, const ChatEntryData &b) {
+ return a.first["timestamp"] < b.first["timestamp"];
+ }
+ );
+
+ return m_entries.insert(it, pair);
+ };
+
for (auto &call_log : core->getCallHistoryForAddress(m_chat_room->getPeerAddress())) {
+ linphone::CallStatus status = call_log->getStatus();
+
// Ignore aborted calls.
- if (call_log->getStatus() == linphone::CallStatusAborted)
+ if (status == linphone::CallStatusAborted)
continue;
// Add start call.
QVariantMap start;
fillCallStartEntry(start, call_log);
-
- ChatEntryData pair = qMakePair(start, static_pointer_cast(call_log));
-
- auto it = lower_bound(
- m_entries.begin(), m_entries.end(), pair,
- [](const ChatEntryData &a, const ChatEntryData &b) {
- return a.first["timestamp"] < b.first["timestamp"];
- }
- );
-
- m_entries.insert(it, pair);
+ auto it = insert_entry(qMakePair(start, static_pointer_cast(call_log)));
// Add end call. (if necessary)
-
+ if (status == linphone::CallStatusSuccess) {
+ QVariantMap end;
+ fillCallEndEntry(end, call_log);
+ insert_entry(qMakePair(end, static_pointer_cast(call_log)), &it);
+ }
}
endResetModel();
diff --git a/tests/ui/modules/Linphone/Chat/Event.qml b/tests/ui/modules/Linphone/Chat/Event.qml
index f36bc75f7..f072f30ad 100644
--- a/tests/ui/modules/Linphone/Chat/Event.qml
+++ b/tests/ui/modules/Linphone/Chat/Event.qml
@@ -11,19 +11,20 @@ Row {
property string _type: {
var status = $chatEntry.status
- if ($chatEntry.status === ChatModel.CallStatusSuccess) {
+ if (status === ChatModel.CallStatusSuccess) {
+ if (!$chatEntry.isStart) {
+ return 'ended_call'
+ }
return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call'
}
-
- if ($chatEntry.status === ChatModel.CallStatusDeclined) {
+ if (status === ChatModel.CallStatusDeclined) {
return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call'
}
-
- if ($chatEntry.status === ChatModel.CallStatusMissed) {
+ if (status === ChatModel.CallStatusMissed) {
return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call'
}
- return 'ended_call'
+ return 'unknown_call_event'
}
height: ChatStyle.entry.lineHeight