mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
fix crash
fix add chat to list if first message received
This commit is contained in:
parent
61fecd8c93
commit
a7e39ab276
6 changed files with 82 additions and 19 deletions
|
|
@ -206,7 +206,7 @@ set(ENABLE_CSHARP_WRAPPER OFF CACHE BOOL "Build the CSharp wrapper for Liblinpho
|
|||
set(ENABLE_THEORA OFF)
|
||||
set(ENABLE_QT_GL ${ENABLE_VIDEO})
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Core5Compat)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Quick Widgets Core5Compat)
|
||||
|
||||
if(NOT Qt6_FOUND)
|
||||
message(FATAL_ERROR "Minimum supported Qt6!")
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ void ChatList::connectItem(QSharedPointer<ChatCore> chat) {
|
|||
};
|
||||
connect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, dataChange);
|
||||
connect(chat.get(), &ChatCore::lastUpdatedTimeChanged, this, dataChange);
|
||||
connect(chat.get(), &ChatCore::lastMessageChanged, this, dataChange);
|
||||
}
|
||||
|
||||
void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||
|
|
@ -80,6 +81,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
|||
// Avoid copy to lambdas
|
||||
QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>();
|
||||
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||
if (!currentAccount) return;
|
||||
auto linphoneChatRooms = currentAccount->filterChatRooms(Utils::appStringToCoreString(mFilter));
|
||||
for (auto it : linphoneChatRooms) {
|
||||
auto model = createChatCore(it);
|
||||
|
|
@ -91,6 +93,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
|||
disconnect(chat.get(), &ChatCore::deleted, this, nullptr);
|
||||
disconnect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, nullptr);
|
||||
disconnect(chat.get(), &ChatCore::lastUpdatedTimeChanged, this, nullptr);
|
||||
disconnect(chat.get(), &ChatCore::lastMessageChanged, this, nullptr);
|
||||
}
|
||||
}
|
||||
for (auto &chat : *chats) {
|
||||
|
|
@ -106,6 +109,64 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
|||
mModelConnection->makeConnectToModel(
|
||||
&CoreModel::defaultAccountChanged,
|
||||
[this](std::shared_ptr<linphone::Core> core, std::shared_ptr<linphone::Account> account) { lUpdate(); });
|
||||
mModelConnection->makeConnectToModel(
|
||||
&CoreModel::messageReceived,
|
||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::ChatRoom> &room,
|
||||
const std::shared_ptr<linphone::ChatMessage> &message) {
|
||||
auto chatCore = ChatCore::create(room);
|
||||
mModelConnection->invokeToCore([this, chatCore] {
|
||||
auto chatList = getSharedList<ChatCore>();
|
||||
auto it =
|
||||
std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
|
||||
return item && chatCore && item->getModel() && chatCore->getModel() &&
|
||||
item->getModel()->getMonitor() == chatCore->getModel()->getMonitor();
|
||||
});
|
||||
if (it == chatList.end()) {
|
||||
connectItem(chatCore);
|
||||
add(chatCore);
|
||||
emit chatAdded();
|
||||
}
|
||||
});
|
||||
});
|
||||
mModelConnection->makeConnectToModel(
|
||||
&CoreModel::messagesReceived,
|
||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::ChatRoom> &room,
|
||||
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) {
|
||||
auto chatCore = ChatCore::create(room);
|
||||
mModelConnection->invokeToCore([this, chatCore] {
|
||||
auto chatList = getSharedList<ChatCore>();
|
||||
auto it =
|
||||
std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
|
||||
return item && chatCore && item->getModel() && chatCore->getModel() &&
|
||||
item->getModel()->getMonitor() == chatCore->getModel()->getMonitor();
|
||||
});
|
||||
if (it == chatList.end()) {
|
||||
connectItem(chatCore);
|
||||
add(chatCore);
|
||||
emit chatAdded();
|
||||
}
|
||||
});
|
||||
});
|
||||
mModelConnection->makeConnectToModel(
|
||||
&CoreModel::newMessageReaction,
|
||||
[this](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<const linphone::ChatMessageReaction> &reaction) {
|
||||
auto chatCore = ChatCore::create(room);
|
||||
mModelConnection->invokeToCore([this, chatCore] {
|
||||
auto chatList = getSharedList<ChatCore>();
|
||||
auto it =
|
||||
std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
|
||||
return item && chatCore && item->getModel() && chatCore->getModel() &&
|
||||
item->getModel()->getMonitor() == chatCore->getModel()->getMonitor();
|
||||
});
|
||||
if (it == chatList.end()) {
|
||||
connectItem(chatCore);
|
||||
add(chatCore);
|
||||
emit chatAdded();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
connect(this, &ChatList::filterChanged, [this](QString filter) {
|
||||
mFilter = filter;
|
||||
|
|
@ -128,7 +189,8 @@ void ChatList::addChatInList(ChatGui *chatGui) {
|
|||
auto chatCore = chatGui->mCore;
|
||||
auto chatList = getSharedList<ChatCore>();
|
||||
auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer<ChatCore> item) {
|
||||
return item->getIdentifier() == chatCore->getIdentifier();
|
||||
return item && chatCore && item->getModel() && chatCore->getModel() &&
|
||||
item->getModel()->getMonitor() == chatCore->getModel()->getMonitor();
|
||||
});
|
||||
if (it == chatList.end()) {
|
||||
connectItem(chatCore);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,6 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
|||
engine->deleteLater();
|
||||
exit(-1);
|
||||
} else {
|
||||
lDebug() << engine->rootObjects()[0];
|
||||
auto window = qobject_cast<QQuickWindow *>(obj);
|
||||
if (window) {
|
||||
window->setProperty(NotificationPropertyData, data);
|
||||
|
|
|
|||
|
|
@ -64,16 +64,16 @@ void ConferenceInfoModel::setConferenceScheduler(const std::shared_ptr<Conferenc
|
|||
if (mConferenceSchedulerModel->getConferenceInfo())
|
||||
mConferenceInfo = mConferenceSchedulerModel->getConferenceInfo()->clone();
|
||||
if (state == linphone::ConferenceScheduler::State::Ready && mInviteEnabled) {
|
||||
auto params = CoreModel::getInstance()->getCore()->createConferenceParams(nullptr);
|
||||
params->enableChat(true);
|
||||
params->enableGroup(false);
|
||||
params->setAccount(mConferenceSchedulerModel->getMonitor()->getAccount());
|
||||
// set to basic cause FlexisipChat force to set a subject
|
||||
params->getChatParams()->setBackend(linphone::ChatRoom::Backend::Basic);
|
||||
// Lime si chiffré, si non None
|
||||
params->getChatParams()->setEncryptionBackend(linphone::ChatRoom::EncryptionBackend::None);
|
||||
mConferenceSchedulerModel->getMonitor()->sendInvitations(params);
|
||||
}
|
||||
auto params = CoreModel::getInstance()->getCore()->createConferenceParams(nullptr);
|
||||
params->enableChat(true);
|
||||
params->enableGroup(false);
|
||||
params->setAccount(mConferenceSchedulerModel->getMonitor()->getAccount());
|
||||
// set to basic cause FlexisipChat force to set a subject
|
||||
params->getChatParams()->setBackend(linphone::ChatRoom::Backend::Basic);
|
||||
// Lime si chiffré, si non None
|
||||
params->getChatParams()->setEncryptionBackend(linphone::ChatRoom::EncryptionBackend::None);
|
||||
mConferenceSchedulerModel->getMonitor()->sendInvitations(params);
|
||||
}
|
||||
emit schedulerStateChanged(state);
|
||||
});
|
||||
connect(mConferenceSchedulerModel.get(), &ConferenceSchedulerModel::invitationsSent, this,
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@ QString LinphoneEnums::toString(const LinphoneEnums::ChatMessageState &data) {
|
|||
case LinphoneEnums::ChatMessageState::StateFileTransferCancelling:
|
||||
//: file transfer canceled
|
||||
return QObject::tr("message_state_file_transfer_cancelling");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ Notification {
|
|||
|
||||
property var chat: notificationData ? notificationData.chat : null
|
||||
|
||||
property string avatarUri: notificationData ? notificationData.avatarUri : ""
|
||||
property string chatRoomName: notificationData ? notificationData.chatRoomName : ""
|
||||
property string remoteAddress: notificationData ? notificationData.remoteAddress : ""
|
||||
property string chatRoomAddress: notificationData ? notificationData.chatRoomAddress : ""
|
||||
property bool isGroupChat: notificationData ? notificationData.isGroupChat : false
|
||||
property string message: notificationData ? notificationData.message : ""
|
||||
property string avatarUri: notificationData?.avatarUri? notificationData.avatarUri : ""
|
||||
property string chatRoomName: notificationData?.chatRoomName ? notificationData.chatRoomName : ""
|
||||
property string remoteAddress: notificationData?.remoteAddress ? notificationData.remoteAddress : ""
|
||||
property string chatRoomAddress: notificationData?.chatRoomAddress ? notificationData.chatRoomAddress : ""
|
||||
property bool isGroupChat: notificationData?.isGroupChat ? notificationData.isGroupChat : false
|
||||
property string message: notificationData?.message ? notificationData.message : ""
|
||||
Connections {
|
||||
enabled: chat
|
||||
target: chat ? chat.core : null
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue