From e4b91a6a66fa1762e0a42a05057f42a2f24bbc7e Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 31 May 2023 14:28:45 +0200 Subject: [PATCH] Fix end date time on conferences. --- .../conferenceInfo/ConferenceInfoModel.cpp | 38 +++++++++++++++++++ .../conferenceInfo/ConferenceInfoModel.hpp | 9 +++++ .../ConferenceInfoProxyModel.cpp | 6 +-- .../Linphone/Chat/ChatCalendarMessage.qml | 2 +- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.cpp b/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.cpp index 4c97f815d..8438e6432 100644 --- a/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.cpp +++ b/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.cpp @@ -81,6 +81,12 @@ ConferenceInfoModel::ConferenceInfoModel (QObject * parent) : QObject(parent){ connect(this, &ConferenceInfoModel::conferenceInfoChanged, this, &ConferenceInfoModel::inviteModeChanged); connect(this, &ConferenceInfoModel::conferenceInfoChanged, this, &ConferenceInfoModel::conferenceInfoStateChanged); connect(this, &ConferenceInfoModel::conferenceInfoChanged, this, &ConferenceInfoModel::conferenceSchedulerStateChanged); + + mCheckEndTimer.callOnTimeout(this, [this]()mutable{setIsEnded(getIsEnded());}); + mCheckEndTimer.setInterval(10000); // 10s of reaction in order to not overload processes if many calendar + mIsEnded = getIsEnded(); + if(!mIsEnded) + mCheckEndTimer.start(); } // Callable from C++ @@ -100,9 +106,16 @@ ConferenceInfoModel::ConferenceInfoModel (std::shared_ptr ConferenceInfoModel::getConferenceInfo(){ @@ -139,6 +152,10 @@ int ConferenceInfoModel::getDuration() const{ } QDateTime ConferenceInfoModel::getEndDateTime() const{ + return getDateTimeSystem().addSecs(getDuration()*60); +} + +QDateTime ConferenceInfoModel::getEndDateTimeUtc() const{ return getDateTimeUtc().addSecs(getDuration()*60); } @@ -175,6 +192,14 @@ bool ConferenceInfoModel::isScheduled() const{ return mIsScheduled; } +bool ConferenceInfoModel::isEnded() const{ + return mIsEnded; +} + +bool ConferenceInfoModel::getIsEnded() const{ + return getEndDateTimeUtc() < QDateTime::currentDateTimeUtc(); +} + int ConferenceInfoModel::getInviteMode() const{ return mInviteMode; } @@ -234,6 +259,7 @@ LinphoneEnums::ConferenceSchedulerState ConferenceInfoModel::getConferenceSchedu // Datetime is in Custom (Locale/UTC/System). Convert into UTC for conference info void ConferenceInfoModel::setDateTime(const QDateTime& dateTime){ mConferenceInfo->setDateTime(dateTime.toMSecsSinceEpoch() / 1000);// toMSecsSinceEpoch() is UTC + setIsEnded(getIsEnded()); emit dateTimeChanged(); } @@ -244,6 +270,7 @@ void ConferenceInfoModel::setDateTime(const QDate& date, const QTime& time, Time void ConferenceInfoModel::setDuration(const int& duration){ mConferenceInfo->setDuration(duration); + setIsEnded(getIsEnded()); emit durationChanged(); } @@ -274,6 +301,17 @@ void ConferenceInfoModel::setIsScheduled(const bool& on){ } } +void ConferenceInfoModel::setIsEnded(const bool& end){ + if( mIsEnded != end){ + mIsEnded = end; + if(mIsEnded) + mCheckEndTimer.stop();// No need to run the timer. + else + mCheckEndTimer.start(); + emit isEndedChanged(); + } +} + void ConferenceInfoModel::setInviteMode(const int& mode){ if( mode != mInviteMode){ mInviteMode = mode; diff --git a/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp b/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp index 520b2d657..8a8a5a3f7 100644 --- a/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp +++ b/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "utils/LinphoneEnums.hpp" @@ -48,6 +49,7 @@ public: Q_PROPERTY(QString displayNamesToString READ displayNamesToString NOTIFY participantsChanged) Q_PROPERTY(QString uri READ getUri NOTIFY uriChanged) Q_PROPERTY(bool isScheduled READ isScheduled WRITE setIsScheduled NOTIFY isScheduledChanged) + Q_PROPERTY(bool isEnded READ isEnded WRITE setIsEnded NOTIFY isEndedChanged) Q_PROPERTY(int inviteMode READ getInviteMode WRITE setInviteMode NOTIFY inviteModeChanged) Q_PROPERTY(int participantCount READ getParticipantCount NOTIFY participantsChanged) Q_PROPERTY(int allParticipantCount READ getAllParticipantCount NOTIFY participantsChanged) @@ -68,12 +70,15 @@ public: QDateTime getDateTimeSystem() const; int getDuration() const; QDateTime getEndDateTime() const; + QDateTime getEndDateTimeUtc() const; QString getOrganizer() const; QString getSubject() const; QString getDescription() const; Q_INVOKABLE QString displayNamesToString()const; QString getUri() const; bool isScheduled() const; + bool isEnded() const; + bool getIsEnded() const; int getInviteMode() const; Q_INVOKABLE QVariantList getParticipants() const; Q_INVOKABLE QVariantList getAllParticipants() const; @@ -90,6 +95,7 @@ public: void setOrganizer(const QString& organizerAddress); void setDescription(const QString& description); void setIsScheduled(const bool& on); + void setIsEnded(const bool& end); void setInviteMode(const int& modes); Q_INVOKABLE void setDateTime(const QDate& date, const QTime& time, TimeZoneModel * model); @@ -116,6 +122,7 @@ signals: void participantsChanged(); void uriChanged(); void isScheduledChanged(); + void isEndedChanged(); void inviteModeChanged(); void conferenceInfoStateChanged(); void conferenceSchedulerStateChanged(); @@ -131,6 +138,8 @@ private: QSharedPointer mConferenceScheduler= nullptr; bool mIsScheduled = true; + bool mIsEnded = false; + QTimer mCheckEndTimer; int mInviteMode = 0; bool mRemoveRequested = false;// true if user has request its deletion from DB linphone::ConferenceScheduler::State mLastConferenceSchedulerState = linphone::ConferenceScheduler::State::Idle;// Workaround for missing getter in scheduler. diff --git a/linphone-app/src/components/conferenceInfo/ConferenceInfoProxyModel.cpp b/linphone-app/src/components/conferenceInfo/ConferenceInfoProxyModel.cpp index c3eb602ec..e4e59cd9d 100644 --- a/linphone-app/src/components/conferenceInfo/ConferenceInfoProxyModel.cpp +++ b/linphone-app/src/components/conferenceInfo/ConferenceInfoProxyModel.cpp @@ -56,11 +56,11 @@ bool ConferenceInfoProxyModel::filterAcceptsRow (int sourceRow, const QModelInde if(ics){ if(ics->getDuration() == 0) return false; - QDateTime currentDateTime = QDateTime::currentDateTime(); + QDateTime currentDateTime = QDateTime::currentDateTimeUtc(); if( mFilterType == 0){ - return ics->getEndDateTime() < currentDateTime; + return ics->getEndDateTimeUtc() < currentDateTime; }else if( mFilterType == 1){ - return ics->getEndDateTime() >= currentDateTime; + return ics->getEndDateTimeUtc() >= currentDateTime; }else if( mFilterType == 2){ return !Utils::isMe(ics->getOrganizer()); }else diff --git a/linphone-app/ui/modules/Linphone/Chat/ChatCalendarMessage.qml b/linphone-app/ui/modules/Linphone/Chat/ChatCalendarMessage.qml index b06553210..2f183f0d3 100644 --- a/linphone-app/ui/modules/Linphone/Chat/ChatCalendarMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/ChatCalendarMessage.qml @@ -360,7 +360,7 @@ Loader{ colorSet: ChatCalendarMessageStyle.editButton backgroundRadius: width/2 visible: UtilsCpp.isMe(mainItem.conferenceInfoModel.organizer) - && mainItem.conferenceInfoModel.endDateTime >= new Date() + && !mainItem.conferenceInfoModel.isEnded && !mainItem.isCancelled onClicked: { window.detachVirtualWindow()