Merge branch 'fix/chat_creation' into 'release/6.2'

Open chat in right panel on state Created (fix #LINQT-2500)

See merge request BC/public/linphone-desktop!1804
This commit is contained in:
Gaëlle Braud 2026-04-09 14:13:45 +00:00
commit 3ce17d6643
8 changed files with 1180 additions and 1131 deletions

View file

@ -249,6 +249,25 @@ void ChatCore::setSelf(const QSharedPointer<ChatCore> &me) {
emit lUpdateLastUpdatedTime(); emit lUpdateLastUpdatedTime();
}); });
}); });
mChatModelConnection->makeConnectToModel(
&ChatModel::chatMessageSent, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<const linphone::EventLog> &eventLog) {
if (!mChatModel) {
lWarning() << log().arg("Chat model is null !");
return;
} else if (!mChatModelConnection) {
lWarning() << log().arg("Connection between Core and Model is null !");
return;
}
if (mChatModel->getMonitor() != chatRoom) return;
lInfo() << log().arg("Chat message sent in chatroom") << this << mChatModel->getTitle();
QList<QSharedPointer<EventLogCore>> list;
if (eventLog) {
emit CoreModel::getInstance()->messageSent(CoreModel::getInstance()->getCore(), chatRoom, eventLog);
} else {
lWarning() << log().arg("message sent : event log is null");
}
});
mChatModelConnection->makeConnectToCore(&ChatCore::lMarkAsRead, [this]() { mChatModelConnection->makeConnectToCore(&ChatCore::lMarkAsRead, [this]() {
auto lastActiveWindow = Utils::getLastActiveWindow(); auto lastActiveWindow = Utils::getLastActiveWindow();

View file

@ -154,10 +154,8 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
[this](std::shared_ptr<linphone::Core> core, std::shared_ptr<linphone::Account> account) { lUpdate(); }); [this](std::shared_ptr<linphone::Core> core, std::shared_ptr<linphone::Account> account) { lUpdate(); });
auto addChatToList = [this](const std::shared_ptr<linphone::Core> &core, auto addChatToList = [this](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room, bool sendAddSignal = false) {
const std::shared_ptr<linphone::ChatMessage> &message, bool sendAddSignal = false) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
// if (!message) return;
if (!core->getDefaultAccount()) return; if (!core->getDefaultAccount()) return;
if (room->getAccount() != core->getDefaultAccount()) { if (room->getAccount() != core->getDefaultAccount()) {
qInfo() << log().arg("Chat room to add does not refer to current account, return"); qInfo() << log().arg("Chat room to add does not refer to current account, return");
@ -182,27 +180,28 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
auto chatCore = ChatCore::create(room); auto chatCore = ChatCore::create(room);
mModelConnection->invokeToCore([this, chatCore, sendAddSignal] { addChatInList(chatCore, sendAddSignal); }); mModelConnection->invokeToCore([this, chatCore, sendAddSignal] { addChatInList(chatCore, sendAddSignal); });
}; };
mModelConnection->makeConnectToModel(&CoreModel::messageReceived, mModelConnection->makeConnectToModel(
&CoreModel::messageReceived,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core, [this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message) { const std::shared_ptr<linphone::ChatMessage> &message) { addChatToList(core, room); });
addChatToList(core, room, message);
});
mModelConnection->makeConnectToModel( mModelConnection->makeConnectToModel(
&CoreModel::messagesReceived, &CoreModel::messagesReceived,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core, [this, addChatToList](
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) { addChatToList(core, room); });
mModelConnection->makeConnectToModel(
&CoreModel::messageSent, [this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) { const std::shared_ptr<const linphone::EventLog> &eventLog) {
addChatToList(core, room, messages.front()); addChatToList(core, room, true);
}); });
mModelConnection->makeConnectToModel( mModelConnection->makeConnectToModel(
&CoreModel::newMessageReaction, &CoreModel::newMessageReaction,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core, [this, addChatToList](
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message, const std::shared_ptr<linphone::ChatMessage> &message,
const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) { const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) { addChatToList(core, room); });
addChatToList(core, room, message);
});
mModelConnection->makeConnectToModel(&CoreModel::chatRoomStateChanged, mModelConnection->makeConnectToModel(&CoreModel::chatRoomStateChanged,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core, [this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &chatRoom, const std::shared_ptr<linphone::ChatRoom> &chatRoom,
@ -212,8 +211,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
if (chatRoom == CoreModel::getInstance()->mChatRoomBeingCreated) { if (chatRoom == CoreModel::getInstance()->mChatRoomBeingCreated) {
sendAddSignal = true; sendAddSignal = true;
} }
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr; addChatToList(core, chatRoom, sendAddSignal);
addChatToList(core, chatRoom, nullptr, sendAddSignal);
} }
}); });
@ -248,7 +246,10 @@ bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSign
connectItem(chatCore); connectItem(chatCore);
lInfo() << "Add ChatRoom" << chatCore->getTitle(); lInfo() << "Add ChatRoom" << chatCore->getTitle();
add(chatCore); add(chatCore);
if (emitAddSignal) emit chatAdded(chatCore); if (emitAddSignal) {
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr;
emit chatAdded(chatCore);
}
return true; return true;
} }
return false; return false;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -274,6 +274,9 @@ signals:
void messageReceived(const std::shared_ptr<linphone::Core> &core, void messageReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message); const std::shared_ptr<linphone::ChatMessage> &message);
void messageSent(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<const linphone::EventLog> &message);
void messagesReceived(const std::shared_ptr<linphone::Core> &core, void messagesReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room, const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages); const std::list<std::shared_ptr<linphone::ChatMessage>> &messages);

View file

@ -99,6 +99,8 @@ ListView {
if (index === -1 && force === true && chatGui) { if (index === -1 && force === true && chatGui) {
if (chatProxy.addChatInList(chatGui)) { if (chatProxy.addChatInList(chatGui)) {
var index = chatProxy.findChatIndex(chatGui) var index = chatProxy.findChatIndex(chatGui)
} else {
console.log("could not add chat in list !")
} }
} }
mainItem.currentIndex = index mainItem.currentIndex = index

View file

@ -52,6 +52,9 @@ AbstractMainPage {
UtilsCpp.showInformationPopup(qsTr("info_popup_error_title"), UtilsCpp.showInformationPopup(qsTr("info_popup_error_title"),
//: Chat room creation failed ! //: Chat room creation failed !
qsTr("info_popup_chatroom_creation_failed"), false) qsTr("info_popup_chatroom_creation_failed"), false)
} else if (remoteChat.core.state === LinphoneEnums.ChatRoomState.Created) {
console.log("chat room state Created, open chat in right panel")
mainItem.selectedChatGui = remoteChat
} }
} }
} }