diff --git a/CMakeLists.txt b/CMakeLists.txt index 1652a1f3c..bc705a0c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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!") diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 50f6ae1df..bcb582379 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -69,6 +69,7 @@ void ChatList::connectItem(QSharedPointer 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 me) { @@ -80,6 +81,7 @@ void ChatList::setSelf(QSharedPointer me) { // Avoid copy to lambdas QList> *chats = new QList>(); 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 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 me) { mModelConnection->makeConnectToModel( &CoreModel::defaultAccountChanged, [this](std::shared_ptr core, std::shared_ptr account) { lUpdate(); }); + mModelConnection->makeConnectToModel( + &CoreModel::messageReceived, + [this](const std::shared_ptr &core, const std::shared_ptr &room, + const std::shared_ptr &message) { + auto chatCore = ChatCore::create(room); + mModelConnection->invokeToCore([this, chatCore] { + auto chatList = getSharedList(); + auto it = + std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer 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 &core, const std::shared_ptr &room, + const std::list> &messages) { + auto chatCore = ChatCore::create(room); + mModelConnection->invokeToCore([this, chatCore] { + auto chatList = getSharedList(); + auto it = + std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer 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 &core, const std::shared_ptr &room, + const std::shared_ptr &message, + const std::shared_ptr &reaction) { + auto chatCore = ChatCore::create(room); + mModelConnection->invokeToCore([this, chatCore] { + auto chatList = getSharedList(); + auto it = + std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer 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(); auto it = std::find_if(chatList.begin(), chatList.end(), [chatCore](const QSharedPointer 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); diff --git a/Linphone/core/notifier/Notifier.cpp b/Linphone/core/notifier/Notifier.cpp index 9b97ac93c..7ab8df069 100644 --- a/Linphone/core/notifier/Notifier.cpp +++ b/Linphone/core/notifier/Notifier.cpp @@ -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(obj); if (window) { window->setProperty(NotificationPropertyData, data); diff --git a/Linphone/model/conference/ConferenceInfoModel.cpp b/Linphone/model/conference/ConferenceInfoModel.cpp index 12c98d1cc..d211dda2c 100644 --- a/Linphone/model/conference/ConferenceInfoModel.cpp +++ b/Linphone/model/conference/ConferenceInfoModel.cpp @@ -64,16 +64,16 @@ void ConferenceInfoModel::setConferenceScheduler(const std::shared_ptrgetConferenceInfo()) 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, diff --git a/Linphone/tool/LinphoneEnums.cpp b/Linphone/tool/LinphoneEnums.cpp index 179df9f1a..77619551d 100644 --- a/Linphone/tool/LinphoneEnums.cpp +++ b/Linphone/tool/LinphoneEnums.cpp @@ -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(); } } diff --git a/Linphone/view/Control/Popup/Notification/NotificationReceivedMessage.qml b/Linphone/view/Control/Popup/Notification/NotificationReceivedMessage.qml index 139e23e3f..d1d3ed8f0 100644 --- a/Linphone/view/Control/Popup/Notification/NotificationReceivedMessage.qml +++ b/Linphone/view/Control/Popup/Notification/NotificationReceivedMessage.qml @@ -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