diff --git a/linphone-app/src/components/chat-room/ChatRoomListener.cpp b/linphone-app/src/components/chat-room/ChatRoomListener.cpp index a77d97eaa..8fbc7edb2 100644 --- a/linphone-app/src/components/chat-room/ChatRoomListener.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomListener.cpp @@ -28,7 +28,9 @@ ChatRoomListener::ChatRoomListener(QObject * parent): QObject(parent){ } - +ChatRoomListener::~ChatRoomListener(){ + qDebug() << "Destroying ChatRoomListener " << this; +} //--------------------------------------------------------------------------------------------------- void ChatRoomListener::onIsComposingReceived(const std::shared_ptr & chatRoom, const std::shared_ptr & remoteAddress, bool isComposing){ diff --git a/linphone-app/src/components/chat-room/ChatRoomListener.hpp b/linphone-app/src/components/chat-room/ChatRoomListener.hpp index 71fa167d2..e4866f54d 100644 --- a/linphone-app/src/components/chat-room/ChatRoomListener.hpp +++ b/linphone-app/src/components/chat-room/ChatRoomListener.hpp @@ -34,7 +34,7 @@ class ChatRoomListener : public QObject, public linphone::ChatRoomListener { Q_OBJECT public: ChatRoomListener(QObject * parent = nullptr); - virtual ~ChatRoomListener(){} + virtual ~ChatRoomListener(); virtual void onIsComposingReceived(const std::shared_ptr & chatRoom, const std::shared_ptr & remoteAddress, bool isComposing) override; virtual void onMessageReceived(const std::shared_ptr & chatRoom, const std::shared_ptr & message) override; diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index 004aaf193..43c885547 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -439,15 +439,15 @@ bool ChatRoomModel::isOneToOne() const{ } bool ChatRoomModel::isMeAdmin() const{ - return mChatRoom->getMe()->isAdmin(); + return mChatRoom && mChatRoom->getMe()->isAdmin(); } bool ChatRoomModel::isCurrentAccount() const{ - return Utils::isMe(mChatRoom->getLocalAddress()); + return mChatRoom && Utils::isMe(mChatRoom->getLocalAddress()); } bool ChatRoomModel::canHandleParticipants() const{ - return mChatRoom->canHandleParticipants(); + return mChatRoom && mChatRoom->canHandleParticipants(); } bool ChatRoomModel::getIsRemoteComposing () const { @@ -601,6 +601,8 @@ void ChatRoomModel::markAsToDelete(){ void ChatRoomModel::deleteChatRoom(){ qInfo() << "Deleting ChatRoom : " << getSubject() << ", address=" << getFullPeerAddress(); CoreManager::getInstance()->getCore()->deleteChatRoom(mChatRoom); + mChatRoom->removeListener(mChatRoomListener); + emit chatRoomDeleted(); } void ChatRoomModel::leaveChatRoom (){ @@ -702,10 +704,13 @@ void ChatRoomModel::compose () { void ChatRoomModel::resetMessageCount () { if(mChatRoom && !mDeleteChatRoom && markAsReadEnabled()){ - if (mChatRoom->getUnreadMessagesCount() > 0){ - mChatRoom->markAsRead();// Marking as read is only for messages. Not for calls. - } - setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount()); + if( mChatRoom->getState() != linphone::ChatRoom::State::Deleted){ + if (mChatRoom->getUnreadMessagesCount() > 0){ + mChatRoom->markAsRead();// Marking as read is only for messages. Not for calls. + } + setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount()); + }else + setUnreadMessagesCount(0); setMissedCallsCount(0); emit messageCountReset(); CoreManager::getInstance()->updateUnreadMessageCount(); diff --git a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp index 4b7ea4488..ec1b15942 100644 --- a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp @@ -269,7 +269,8 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) { QObject::disconnect(ChatRoomModel, &ChatRoomModel::messageReceived, this, &ChatRoomProxyModel::handleMessageReceived); QObject::disconnect(ChatRoomModel, &ChatRoomModel::messageSent, this, &ChatRoomProxyModel::handleMessageSent); QObject::disconnect(ChatRoomModel, &ChatRoomModel::markAsReadEnabledChanged, this, &ChatRoomProxyModel::markAsReadEnabledChanged); - QObject::disconnect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded); + QObject::disconnect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded); + QObject::disconnect(ChatRoomModel, &ChatRoomModel::chatRoomDeleted, this, &ChatRoomProxyModel::chatRoomDeleted); if(mIsCall) mChatRoomModel->removeBindingCall(); } @@ -287,6 +288,7 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) { QObject::connect(ChatRoomModel, &ChatRoomModel::messageSent, this, &ChatRoomProxyModel::handleMessageSent); QObject::connect(ChatRoomModel, &ChatRoomModel::markAsReadEnabledChanged, this, &ChatRoomProxyModel::markAsReadEnabledChanged); QObject::connect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded); + QObject::connect(ChatRoomModel, &ChatRoomModel::chatRoomDeleted, this, &ChatRoomProxyModel::chatRoomDeleted); mChatRoomModel->initEntries();// This way, we don't load huge chat rooms (that lead to freeze GUI) } } diff --git a/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp b/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp index 7b3111cbd..39a5dc675 100644 --- a/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp +++ b/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp @@ -88,6 +88,7 @@ signals: //bool isSecureChanged(bool secure); void chatRoomModelChanged(); + void chatRoomDeleted(); void moreEntriesLoaded (int n); diff --git a/linphone-app/src/components/conferenceScheduler/ConferenceScheduler.cpp b/linphone-app/src/components/conferenceScheduler/ConferenceScheduler.cpp index 62aa35479..000f91e4a 100644 --- a/linphone-app/src/components/conferenceScheduler/ConferenceScheduler.cpp +++ b/linphone-app/src/components/conferenceScheduler/ConferenceScheduler.cpp @@ -25,6 +25,7 @@ #include "app/App.hpp" #include "components/core/CoreHandlers.hpp" #include "components/core/CoreManager.hpp" +#include "components/settings/SettingsModel.hpp" void ConferenceScheduler::connectTo(ConferenceSchedulerListener * listener){ connect(listener, &ConferenceSchedulerListener::stateChanged, this, &ConferenceScheduler::onStateChanged); @@ -61,7 +62,10 @@ void ConferenceScheduler::onStateChanged(linphone::ConferenceScheduler::State st emit CoreManager::getInstance()->getHandlers()->conferenceInfoReceived(mConferenceScheduler->getInfo()); if( (mSendInvite & 1) == 1){ std::shared_ptr params = CoreManager::getInstance()->getCore()->createDefaultChatRoomParams(); - params->setBackend(linphone::ChatRoomBackend::Basic); + if( CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled()) + params->setBackend(linphone::ChatRoomBackend::FlexisipChat); + else + params->setBackend(linphone::ChatRoomBackend::Basic); mConferenceScheduler->sendInvitations(params); } } diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index 4a318c0d4..2384984ad 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -68,6 +68,7 @@ TimelineListModel::TimelineListModel(const TimelineListModel* model){ for(auto item : model->mList) { auto newItem = qobject_cast(item)->clone(); connect(newItem.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); + connect(newItem.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted); connect(newItem->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); mList << newItem; } @@ -295,6 +296,7 @@ void TimelineListModel::updateTimelines () { void TimelineListModel::add (QSharedPointer timeline){ auto chatRoomModel = timeline->getChatRoomModel(); auto chatRoom = chatRoomModel->getChatRoom(); + connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted); if( !chatRoomModel->haveConferenceAddress() || chatRoom->getHistoryEventsSize() != 0) { connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated); ProxyListModel::add(timeline); @@ -398,3 +400,7 @@ void TimelineListModel::onCallCreated(const std::shared_ptr &cal } } } + +void TimelineListModel::onChatRoomDeleted(){ + remove(sender()); +} diff --git a/linphone-app/src/components/timeline/TimelineListModel.hpp b/linphone-app/src/components/timeline/TimelineListModel.hpp index 7314a10b6..271e85cdf 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.hpp +++ b/linphone-app/src/components/timeline/TimelineListModel.hpp @@ -65,6 +65,7 @@ public slots: void onChatRoomStateChanged(const std::shared_ptr &chatRoom,linphone::ChatRoom::State state); void onCallStateChanged (const std::shared_ptr &call, linphone::Call::State state) ; void onCallCreated(const std::shared_ptr &call); + void onChatRoomDeleted(); signals: void countChanged(); diff --git a/linphone-app/src/components/timeline/TimelineModel.cpp b/linphone-app/src/components/timeline/TimelineModel.cpp index 9f49c665c..9e3d92a6e 100644 --- a/linphone-app/src/components/timeline/TimelineModel.cpp +++ b/linphone-app/src/components/timeline/TimelineModel.cpp @@ -113,6 +113,7 @@ TimelineModel::TimelineModel (std::shared_ptr chatRoom, QObj CoreManager::getInstance()->handleChatRoomCreated(mChatRoomModel); QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount); QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged); + QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted); } if(chatRoom){ mChatRoomListener = std::make_shared(this); @@ -128,6 +129,7 @@ TimelineModel::TimelineModel(const TimelineModel * model){ if( mChatRoomModel ){ QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount); QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged); + QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted); } if(mChatRoomModel->getChatRoom()){ mChatRoomListener = model->mChatRoomListener; @@ -201,7 +203,7 @@ void TimelineModel::onDefaultAccountChanged(){ } void TimelineModel::disconnectChatRoomListener(){ - if( mChatRoomModel && mChatRoomListener){ + if( mChatRoomModel && mChatRoomListener && mChatRoomModel->getChatRoom()){ mChatRoomModel->getChatRoom()->removeListener(mChatRoomListener); } } @@ -251,3 +253,7 @@ void TimelineModel::onParticipantRegistrationSubscriptionRequested(const std::sh void TimelineModel::onParticipantRegistrationUnsubscriptionRequested(const std::shared_ptr & chatRoom, const std::shared_ptr & participantAddress){} void TimelineModel::onChatMessageShouldBeStored(const std::shared_ptr & chatRoom, const std::shared_ptr & message){} void TimelineModel::onChatMessageParticipantImdnStateChanged(const std::shared_ptr & chatRoom, const std::shared_ptr & message, const std::shared_ptr & state){} + +void TimelineModel::onChatRoomDeleted(){ + emit chatRoomDeleted(); +} \ No newline at end of file diff --git a/linphone-app/src/components/timeline/TimelineModel.hpp b/linphone-app/src/components/timeline/TimelineModel.hpp index 5f16faf95..492ff8f02 100644 --- a/linphone-app/src/components/timeline/TimelineModel.hpp +++ b/linphone-app/src/components/timeline/TimelineModel.hpp @@ -100,6 +100,7 @@ public: public slots: void updateUnreadCount(); void onDefaultAccountChanged(); + void onChatRoomDeleted(); signals: void fullPeerAddressChanged(); @@ -109,6 +110,7 @@ signals: void presenceStatusChanged(); void selectedChanged(bool selected); void conferenceLeft(); + void chatRoomDeleted(); private: diff --git a/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml b/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml index fca32b6ce..3e8f34e42 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml @@ -67,7 +67,7 @@ Item { titleColor: isSelected ? TimelineStyle.contact.title.color.selected : TimelineStyle.contact.title.color.normal - showSubtitle: mainItem.timelineModel.chatRoomModel && (mainItem.timelineModel.chatRoomModel.isOneToOne || !mainItem.timelineModel.chatRoomModel.isConference) + showSubtitle: mainItem.timelineModel && (mainItem.timelineModel.chatRoomModel && (mainItem.timelineModel.chatRoomModel.isOneToOne || !mainItem.timelineModel.chatRoomModel.isConference)) TooltipArea { id: contactTooltip text: mainItem.timelineModel && UtilsCpp.toDateTimeString(mainItem.timelineModel.chatRoomModel.lastUpdateTime) diff --git a/linphone-app/ui/views/App/Calls/Incall.qml b/linphone-app/ui/views/App/Calls/Incall.qml index 74759c2c0..59134bbcf 100644 --- a/linphone-app/ui/views/App/Calls/Incall.qml +++ b/linphone-app/ui/views/App/Calls/Incall.qml @@ -184,8 +184,13 @@ Rectangle { Item{ Layout.fillWidth: true Layout.preferredHeight: title.contentHeight + address.contentHeight + property int centerOffset: mapFromItem(mainItem, mainItem.width/2,0).x - width/2 // Compute center from mainItem ColumnLayout{ - anchors.fill: parent + anchors.top: parent.top + anchors.bottom: parent.bottom + width: parent.width + x: parent.centerOffset + Text{ id: title Layout.alignment: Qt.AlignHCenter