mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
never add chat room to chat list if has conference info
This commit is contained in:
parent
c2f8dac06d
commit
e0c8e8ec20
1 changed files with 22 additions and 31 deletions
|
|
@ -148,13 +148,17 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
|
|
||||||
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,
|
||||||
const std::shared_ptr<linphone::ChatMessage> &message) {
|
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 (!message) 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");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (room->getConferenceInfo()) {
|
||||||
|
lWarning() << log().arg("Chatroom to add is a conference, return");
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool canAdd = false;
|
bool canAdd = false;
|
||||||
auto linphoneChatRooms = core->getDefaultAccount()->filterChatRooms(Utils::appStringToCoreString(mFilter));
|
auto linphoneChatRooms = core->getDefaultAccount()->filterChatRooms(Utils::appStringToCoreString(mFilter));
|
||||||
for (auto it : linphoneChatRooms) {
|
for (auto it : linphoneChatRooms) {
|
||||||
|
|
@ -166,7 +170,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto chatCore = ChatCore::create(room);
|
auto chatCore = ChatCore::create(room);
|
||||||
mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore, false); });
|
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,
|
||||||
|
|
@ -189,33 +193,19 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||||
const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) {
|
const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) {
|
||||||
addChatToList(core, room, message);
|
addChatToList(core, room, message);
|
||||||
});
|
});
|
||||||
mModelConnection->makeConnectToModel(
|
mModelConnection->makeConnectToModel(&CoreModel::chatRoomStateChanged,
|
||||||
&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, linphone::ChatRoom::State state) {
|
linphone::ChatRoom::State state) {
|
||||||
if (state == linphone::ChatRoom::State::Created) {
|
if (state == linphone::ChatRoom::State::Created) {
|
||||||
bool sendAddSignal = false;
|
bool sendAddSignal = false;
|
||||||
if (chatRoom == CoreModel::getInstance()->mChatRoomBeingCreated) {
|
if (chatRoom == CoreModel::getInstance()->mChatRoomBeingCreated) {
|
||||||
sendAddSignal = true;
|
sendAddSignal = true;
|
||||||
}
|
}
|
||||||
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr;
|
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr;
|
||||||
if (chatRoom->getConferenceInfo()) {
|
addChatToList(core, chatRoom, nullptr, sendAddSignal);
|
||||||
qWarning() << log().arg("Chatroom created during a conference, return");
|
}
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
auto chatAccount = chatRoom->getAccount();
|
|
||||||
auto defaultAccount = core->getDefaultAccount();
|
|
||||||
if (!chatAccount || !defaultAccount) return;
|
|
||||||
if (!chatAccount->getParams()->getIdentityAddress()->weakEqual(
|
|
||||||
defaultAccount->getParams()->getIdentityAddress())) {
|
|
||||||
qWarning() << log().arg("Chatroom does not refer to current account, return");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto chatCore = ChatCore::create(chatRoom);
|
|
||||||
mModelConnection->invokeToCore(
|
|
||||||
[this, chatCore, sendAddSignal] { addChatInList(chatCore, sendAddSignal); });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(this, &ChatList::filterChanged, [this](QString filter) {
|
connect(this, &ChatList::filterChanged, [this](QString filter) {
|
||||||
mFilter = filter;
|
mFilter = filter;
|
||||||
|
|
@ -237,7 +227,7 @@ int ChatList::findChatIndex(ChatGui *chatGui) {
|
||||||
bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSignal) {
|
bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSignal) {
|
||||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||||
if (chatCore->getIdentifier().isEmpty()) {
|
if (chatCore->getIdentifier().isEmpty()) {
|
||||||
qWarning() << "ChatRoom with invalid identifier cannot be added to the list, return";
|
lWarning() << "ChatRoom with invalid identifier cannot be added to the list, return";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto chatList = getSharedList<ChatCore>();
|
auto chatList = getSharedList<ChatCore>();
|
||||||
|
|
@ -246,6 +236,7 @@ bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSign
|
||||||
});
|
});
|
||||||
if (it == chatList.end()) {
|
if (it == chatList.end()) {
|
||||||
connectItem(chatCore);
|
connectItem(chatCore);
|
||||||
|
lInfo() << "Add ChatRoom" << chatCore->getTitle();
|
||||||
add(chatCore);
|
add(chatCore);
|
||||||
if (emitAddSignal) emit chatAdded(chatCore);
|
if (emitAddSignal) emit chatAdded(chatCore);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue