Skip to content
Snippets Groups Projects
Commit a5544675 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez
Browse files

fix for conferences


- bug : conferences ids are mixed with calls ids wich lead to several
bugs.

- fix : split conferences ids and calls ids.

Change-Id: Ia2e7985757c8ea8076858e16e48946ecc56acf7a
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 54364679
Branches
Tags
No related merge requests found
...@@ -40,6 +40,7 @@ struct Info ...@@ -40,6 +40,7 @@ struct Info
std::string accountId; std::string accountId;
std::vector<std::string> participants; std::vector<std::string> participants;
std::string callId; std::string callId;
std::string confId;
std::map<uint64_t, interaction::Info> interactions; std::map<uint64_t, interaction::Info> interactions;
uint64_t lastMessageUid = 0; uint64_t lastMessageUid = 0;
unsigned int unreadMessages = 0; unsigned int unreadMessages = 0;
......
...@@ -272,5 +272,4 @@ CallbacksHandler::slotAccountMessageStatusChanged(const QString& accountId, ...@@ -272,5 +272,4 @@ CallbacksHandler::slotAccountMessageStatusChanged(const QString& accountId,
to.toStdString(), status); to.toStdString(), status);
} }
} // namespace lrc } // namespace lrc
...@@ -187,6 +187,11 @@ public Q_SLOTS: ...@@ -187,6 +187,11 @@ public Q_SLOTS:
* @param confId * @param confId
*/ */
void slotCallAddedToConference(const std::string& callId, const std::string& confId); void slotCallAddedToConference(const std::string& callId, const std::string& confId);
/**
* Listen from CallbacksHandler when a conference is deleted.
* @param confId
*/
void slotConferenceRemoved(const std::string& confId);
}; };
...@@ -295,6 +300,9 @@ ConversationModel::selectConversation(const std::string& uid) const ...@@ -295,6 +300,9 @@ ConversationModel::selectConversation(const std::string& uid) const
auto& conversation = pimpl_->conversations.at(conversationIdx); auto& conversation = pimpl_->conversations.at(conversationIdx);
try { try {
if (not conversation.confId.empty()) {
emit pimpl_->behaviorController.showCallView(owner.id, conversation);
} else {
auto call = owner.callModel->getCall(conversation.callId); auto call = owner.callModel->getCall(conversation.callId);
switch (call.status) { switch (call.status) {
case call::Status::INCOMING_RINGING: case call::Status::INCOMING_RINGING:
...@@ -321,6 +329,7 @@ ConversationModel::selectConversation(const std::string& uid) const ...@@ -321,6 +329,7 @@ ConversationModel::selectConversation(const std::string& uid) const
// We are not in a call, show the chatview // We are not in a call, show the chatview
emit pimpl_->behaviorController.showChatView(owner.id, conversation); emit pimpl_->behaviorController.showChatView(owner.id, conversation);
} }
}
} catch (const std::out_of_range&) { } catch (const std::out_of_range&) {
emit pimpl_->behaviorController.showChatView(owner.id, conversation); emit pimpl_->behaviorController.showChatView(owner.id, conversation);
} }
...@@ -507,10 +516,26 @@ ConversationModel::joinConversations(const std::string& uidA, const std::string& ...@@ -507,10 +516,26 @@ ConversationModel::joinConversations(const std::string& uidA, const std::string&
return; return;
auto& conversationA = pimpl_->conversations[conversationAIdx]; auto& conversationA = pimpl_->conversations[conversationAIdx];
auto& conversationB = pimpl_->conversations[conversationBIdx]; auto& conversationB = pimpl_->conversations[conversationBIdx];
// NOTE: To create a conference, we must be in call for now.
if (conversationA.callId.empty() || conversationB.callId.empty()) if (conversationA.callId.empty() || conversationB.callId.empty())
return; return;
if (conversationA.confId.empty()) {
if(conversationB.confId.empty()){
owner.callModel->joinCalls(conversationA.callId, conversationB.callId); owner.callModel->joinCalls(conversationA.callId, conversationB.callId);
}else{
owner.callModel->joinCalls(conversationA.callId, conversationB.confId);
conversationA.confId = conversationB.confId;
}
} else {
if(conversationB.confId.empty()){
owner.callModel->joinCalls(conversationA.confId, conversationB.callId);
conversationB.confId = conversationA.confId;
}else{
owner.callModel->joinCalls(conversationA.confId, conversationB.confId);
conversationB.confId = conversationA.confId;
}
}
} }
void void
...@@ -600,6 +625,10 @@ ConversationModelPimpl::ConversationModelPimpl(const ConversationModel& linked, ...@@ -600,6 +625,10 @@ ConversationModelPimpl::ConversationModelPimpl(const ConversationModel& linked,
&lrc::api::NewCallModel::callAddedToConference, &lrc::api::NewCallModel::callAddedToConference,
this, this,
&ConversationModelPimpl::slotCallAddedToConference); &ConversationModelPimpl::slotCallAddedToConference);
connect(&callbacksHandler,
&CallbacksHandler::conferenceRemoved,
this,
&ConversationModelPimpl::slotConferenceRemoved);
} }
ConversationModelPimpl::~ConversationModelPimpl() ConversationModelPimpl::~ConversationModelPimpl()
...@@ -908,7 +937,7 @@ ConversationModelPimpl::slotIncomingCallMessage(const std::string& callId, const ...@@ -908,7 +937,7 @@ ConversationModelPimpl::slotIncomingCallMessage(const std::string& callId, const
if (call.type == call::Type::CONFERENCE) { if (call.type == call::Type::CONFERENCE) {
// Show messages in all conversations for conferences. // Show messages in all conversations for conferences.
for (const auto& conversation: conversations) { for (const auto& conversation: conversations) {
if (conversation.callId == callId) { if (conversation.confId == callId) {
if (conversation.participants.empty()) continue; if (conversation.participants.empty()) continue;
auto authorProfileId = database::getOrInsertProfile(db, from); auto authorProfileId = database::getOrInsertProfile(db, from);
addIncomingMessage(conversation.participants.front(), body, authorProfileId); addIncomingMessage(conversation.participants.front(), body, authorProfileId);
...@@ -955,7 +984,7 @@ ConversationModelPimpl::slotCallAddedToConference(const std::string& callId, con ...@@ -955,7 +984,7 @@ ConversationModelPimpl::slotCallAddedToConference(const std::string& callId, con
{ {
for (auto& conversation: conversations) { for (auto& conversation: conversations) {
if (conversation.callId == callId) { if (conversation.callId == callId) {
conversation.callId = confId; conversation.confId = confId;
dirtyConversations = true; dirtyConversations = true;
emit linked.selectConversation(conversation.uid); emit linked.selectConversation(conversation.uid);
} }
...@@ -1011,6 +1040,16 @@ ConversationModelPimpl::slotUpdateInteractionStatus(const std::string& accountId ...@@ -1011,6 +1040,16 @@ ConversationModelPimpl::slotUpdateInteractionStatus(const std::string& accountId
} }
} }
void
ConversationModelPimpl::slotConferenceRemoved(const std::string& confId)
{
// Get conversation
for(auto& i : conversations){
if (i.confId == confId)
i.confId = "";
}
}
} // namespace lrc } // namespace lrc
#include "api/moc_conversationmodel.cpp" #include "api/moc_conversationmodel.cpp"
......
...@@ -96,11 +96,6 @@ public Q_SLOTS: ...@@ -96,11 +96,6 @@ public Q_SLOTS:
* @param callId * @param callId
*/ */
void slotConferenceCreated(const std::string& callId); void slotConferenceCreated(const std::string& callId);
/**
* Listen from CallbacksHandler when a conference is deleted.
* @param callId
*/
void slotConferenceRemoved(const std::string& callId);
}; };
NewCallModel::NewCallModel(const account::Info& owner, const CallbacksHandler& callbacksHandler) NewCallModel::NewCallModel(const account::Info& owner, const CallbacksHandler& callbacksHandler)
...@@ -338,7 +333,6 @@ NewCallModelPimpl::NewCallModelPimpl(const NewCallModel& linked, const Callbacks ...@@ -338,7 +333,6 @@ NewCallModelPimpl::NewCallModelPimpl(const NewCallModel& linked, const Callbacks
connect(&VideoRendererManager::instance(), &VideoRendererManager::remotePreviewStarted, this, &NewCallModelPimpl::slotRemotePreviewStarted); connect(&VideoRendererManager::instance(), &VideoRendererManager::remotePreviewStarted, this, &NewCallModelPimpl::slotRemotePreviewStarted);
connect(&callbacksHandler, &CallbacksHandler::incomingVCardChunk, this, &NewCallModelPimpl::slotincomingVCardChunk); connect(&callbacksHandler, &CallbacksHandler::incomingVCardChunk, this, &NewCallModelPimpl::slotincomingVCardChunk);
connect(&callbacksHandler, &CallbacksHandler::conferenceCreated, this , &NewCallModelPimpl::slotConferenceCreated); connect(&callbacksHandler, &CallbacksHandler::conferenceCreated, this , &NewCallModelPimpl::slotConferenceCreated);
connect(&callbacksHandler, &CallbacksHandler::conferenceRemoved, this , &NewCallModelPimpl::slotConferenceRemoved);
} }
NewCallModelPimpl::~NewCallModelPimpl() NewCallModelPimpl::~NewCallModelPimpl()
...@@ -463,30 +457,18 @@ NewCallModel::hasCall(const std::string& callId) ...@@ -463,30 +457,18 @@ NewCallModel::hasCall(const std::string& callId)
} }
void void
NewCallModelPimpl::slotConferenceCreated(const std::string& callId) NewCallModelPimpl::slotConferenceCreated(const std::string& confId)
{ {
if (calls.find(callId) != calls.end()) return;
auto callInfo = std::make_shared<call::Info>(); auto callInfo = std::make_shared<call::Info>();
callInfo->id = callId; callInfo->id = confId;
callInfo->status = call::Status::IN_PROGRESS; callInfo->status = call::Status::IN_PROGRESS;
callInfo->type = call::Type::CONFERENCE; callInfo->type = call::Type::CONFERENCE;
callInfo->startTime = std::chrono::steady_clock::now(); callInfo->startTime = std::chrono::steady_clock::now();
calls[callId] = callInfo; calls[confId] = callInfo;
QStringList callList = CallManager::instance().getParticipantList(callId.c_str()); QStringList callList = CallManager::instance().getParticipantList(confId.c_str());
foreach(const auto& call, callList) { foreach(const auto& call, callList) {
emit linked.callAddedToConference(call.toStdString(), callId); emit linked.callAddedToConference(call.toStdString(), confId);
}
} }
void
NewCallModelPimpl::slotConferenceRemoved(const std::string& callId)
{
auto it = calls.find(callId);
if (it == calls.end()) return;
auto& call = it->second;
call->status = call::Status::ENDED;
emit linked.callEnded(callId);
emit linked.callStatusChanged(callId);
} }
} // namespace lrc } // namespace lrc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment