1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-06 07:45:51 +02:00

conversation model: split logic for SIP and Jami

GitLab: #1794
Change-Id: Ief688df6778fe2758882ff1538371def8ba75d64
This commit is contained in:
Adrien Béraud 2024-07-23 10:29:27 -04:00
parent 69400bee2a
commit 89354a07e1

View file

@ -200,7 +200,7 @@ public:
QString& conversationId);
void awaitingHost(const QString& fileId, datatransfer::Info info);
bool hasOneOneSwarmWith(const QString& participant);
bool hasOneOneSwarmWith(const contact::Info& participant);
/**
* accept a file transfer
@ -2009,6 +2009,9 @@ ConversationModelPimpl::initConversations()
if (accountDetails.empty())
return;
auto isJami = linked.owner.profileInfo.type == profile::Type::JAMI;
if (isJami) {
// Fill swarm conversations
QStringList swarms = ConfigurationManager::instance().getConversations(linked.owner.id);
for (auto& swarmConv : swarms) {
@ -2021,11 +2024,20 @@ ConversationModelPimpl::initConversations()
addConversationRequest(request);
}
for (auto const& c : linked.owner.contactModel->getAllContacts()) {
if (hasOneOneSwarmWith(c))
continue;
bool isRequest = c.profileInfo.type == profile::Type::PENDING;
// Can't find a conversation with this contact
// add pending not swarm conversation
if (isRequest) {
addContactRequest(c.profileInfo.uri);
}
}
} else {
// Fill conversations
for (auto const& c : linked.owner.contactModel->getAllContacts().toStdMap()) {
auto conv = storage::getConversationsWithPeer(db, c.second.profileInfo.uri);
if (hasOneOneSwarmWith(c.second.profileInfo.uri))
continue;
bool isRequest = c.second.profileInfo.type == profile::Type::PENDING;
if (conv.empty()) {
// Can't find a conversation with this contact
@ -2061,6 +2073,7 @@ ConversationModelPimpl::initConversations()
}
});
}
}
invalidateModel();
filteredConversations.reset(conversations).sort();
@ -3848,14 +3861,16 @@ ConversationModelPimpl::slotTransferStatusAwaitingHost(const QString& fileId,
}
bool
ConversationModelPimpl::hasOneOneSwarmWith(const QString& participant)
ConversationModelPimpl::hasOneOneSwarmWith(const contact::Info& participant)
{
try {
auto& conversation = getConversationForPeerUri(participant).get();
if (!participant.conversationId.isEmpty()) {
auto& conversation = getConversationForUid(participant.conversationId).get();
return conversation.mode == conversation::Mode::ONE_TO_ONE;
} catch (std::out_of_range&) {
return false;
}
} catch (std::out_of_range&) {
}
return false;
}
void