diff --git a/daemon b/daemon index a7e2c494d1d16bec68b7e098734884062a4b2505..a5a46c0385a224f27456c9b0d271cede9622ea72 160000 --- a/daemon +++ b/daemon @@ -1 +1 @@ -Subproject commit a7e2c494d1d16bec68b7e098734884062a4b2505 +Subproject commit a5a46c0385a224f27456c9b0d271cede9622ea72 diff --git a/src/libclient/api/callmodel.h b/src/libclient/api/callmodel.h index 5ac5920211733bb9b23c53b548bc10f9c68334ed..b3d18867368e9fd1d633b118814373c68885ccb6 100644 --- a/src/libclient/api/callmodel.h +++ b/src/libclient/api/callmodel.h @@ -451,11 +451,13 @@ Q_SIGNALS: * @param callId * @param displayname * @param isOutgoing + * @param toUri Generally account's uri for 1:1 calls, rdv uri for swarm-call */ void newCall(const QString& peerId, const QString& callId, const QString& displayname, - bool isOutgoing) const; + bool isOutgoing, + const QString& toUri) const; /** * Emitted when a call is added to a conference * @param callId diff --git a/src/libclient/api/contactmodel.h b/src/libclient/api/contactmodel.h index 9cae1fdcade260fb88608fffe97b0f71b95481f8..572e53092826f78e6a5b0260852ee00221fa71fd 100644 --- a/src/libclient/api/contactmodel.h +++ b/src/libclient/api/contactmodel.h @@ -156,8 +156,9 @@ Q_SIGNALS: * @param fromId peer profile uri * @param callId call id * @param isOutgoing + * @param toUri */ - void newCall(const QString& from, const QString& callId, bool isOutgoing) const; + void newCall(const QString& from, const QString& callId, bool isOutgoing, const QString& toUri) const; /** * Connect this signal to know when a text message arrives for this account * @param accountId diff --git a/src/libclient/callmodel.cpp b/src/libclient/callmodel.cpp index f9c3a4105e600622952de64ea721f32cdc253765..cb4cca9e04880b47dd71215a2daac8b0b515e10a 100644 --- a/src/libclient/callmodel.cpp +++ b/src/libclient/callmodel.cpp @@ -1440,7 +1440,7 @@ CallModelPimpl::slotCallStateChanged(const QString& accountId, qDebug() << displayname; qDebug() << peerId; - Q_EMIT linked.newCall(peerId, callId, displayname, details["CALL_TYPE"] == "1"); + Q_EMIT linked.newCall(peerId, callId, displayname, details["CALL_TYPE"] == "1", details["TO_USERNAME"]); // NOTE: signal emission order matters, always emit CallStatusChanged before CallEnded Q_EMIT linked.callStatusChanged(callId, code); diff --git a/src/libclient/contactmodel.cpp b/src/libclient/contactmodel.cpp index 22ae05e6a195f7635d6813c7eb4de25dadd85025..78893a496e7e93b5545ba220bf6c0a7dd58527cb 100644 --- a/src/libclient/contactmodel.cpp +++ b/src/libclient/contactmodel.cpp @@ -164,8 +164,9 @@ public Q_SLOTS: * @param callId * @param displayName * @param isOutgoing + * @param toUri */ - void slotNewCall(const QString& fromId, const QString& callId, const QString& displayname, bool isOutgoing); + void slotNewCall(const QString& fromId, const QString& callId, const QString& displayname, bool isOutgoing, const QString& toUri); /** * Listen from callbacksHandler for new account interaction and add pending contact if not present @@ -1022,9 +1023,10 @@ void ContactModelPimpl::slotNewCall(const QString& fromId, const QString& callId, const QString& displayname, - bool isOutgoing) + bool isOutgoing, + const QString& toUri) { - if (!isOutgoing) { + if (!isOutgoing && toUri == linked.owner.profileInfo.uri) { bool emitContactAdded = false; { std::lock_guard<std::mutex> lk(contactsMtx_); @@ -1053,7 +1055,7 @@ ContactModelPimpl::slotNewCall(const QString& fromId, } else Q_EMIT linked.profileUpdated(fromId); } - Q_EMIT linked.newCall(fromId, callId, isOutgoing); + Q_EMIT linked.newCall(fromId, callId, isOutgoing, toUri); } void diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp index 4031eb97f8d2500c70518341b5a3cfa64d67897b..831cac57d286c70607817d3c5f0d9199c134dd26 100644 --- a/src/libclient/conversationmodel.cpp +++ b/src/libclient/conversationmodel.cpp @@ -271,8 +271,9 @@ public Q_SLOTS: * @param fromId caller uri * @param callId * @param isOutgoing + * @param toUri */ - void slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing = false); + void slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing, const QString& toUri); /** * Listen from callmodel for calls status changed. * @param callId @@ -3367,7 +3368,7 @@ ConversationModelPimpl::getIndicesForContact(const QString& uri) const } void -ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing) +ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing, const QString& toUri) { if (isOutgoing) { // search contact @@ -3379,33 +3380,35 @@ ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId Q_EMIT linked.filterChanged(); } - auto convIds = storage::getConversationsWithPeer(db, fromId); - if (convIds.empty()) { - // in case if we receive call after removing contact add conversation request; - try { - auto contact = linked.owner.contactModel->getContact(fromId); - if (!isOutgoing && !contact.isBanned && fromId != linked.owner.profileInfo.uri) { - addContactRequest(fromId); - } - if (isOutgoing && contact.profileInfo.type == profile::Type::TEMPORARY) { - linked.owner.contactModel->addContact(contact); + if (toUri == linked.owner.profileInfo.uri) { + auto convIds = storage::getConversationsWithPeer(db, fromId); + if (convIds.empty()) { + // in case if we receive call after removing contact add conversation request; + try { + auto contact = linked.owner.contactModel->getContact(fromId); + if (!isOutgoing && !contact.isBanned && fromId != linked.owner.profileInfo.uri) { + addContactRequest(fromId); + } + if (isOutgoing && contact.profileInfo.type == profile::Type::TEMPORARY) { + linked.owner.contactModel->addContact(contact); + } + } catch (const std::out_of_range&) { } - } catch (const std::out_of_range&) { } - } - auto conversationIndices = getIndicesForContact(fromId); - if (conversationIndices.empty()) { - qDebug() << "ConversationModelPimpl::slotNewCall, but conversation not found"; - return; // Not a contact - } + auto conversationIndices = getIndicesForContact(fromId); + if (conversationIndices.empty()) { + qDebug() << "ConversationModelPimpl::slotNewCall, but conversation not found"; + return; // Not a contact + } - auto& conversation = conversations.at(conversationIndices.at(0)); - qDebug() << "Add call to conversation " << conversation.uid << " - " << callId; - conversation.callId = callId; + auto& conversation = conversations.at(conversationIndices.at(0)); + qDebug() << "Add call to conversation " << conversation.uid << " - " << callId; + conversation.callId = callId; - addOrUpdateCallMessage(callId, fromId, true); - Q_EMIT behaviorController.showIncomingCallView(linked.owner.id, conversation.uid); + addOrUpdateCallMessage(callId, fromId, true); + Q_EMIT behaviorController.showIncomingCallView(linked.owner.id, conversation.uid); + } } void