feat(GODT-2295): notifications for IMAP login when signed out.

This commit is contained in:
Xavier Michelon
2023-02-02 18:19:40 +01:00
parent a36dbbf422
commit c3d5a0b8f8
26 changed files with 1519 additions and 624 deletions

View File

@ -34,7 +34,8 @@ SPUser User::newUser(QObject *parent) {
/// \param[in] parent The parent object.
//****************************************************************************************************************************************************
User::User(QObject *parent)
: QObject(parent) {
: QObject(parent)
, imapFailureCooldownEndTime_(QDateTime::currentDateTime()) {
}
@ -311,4 +312,24 @@ QString User::stateToString(UserState state) {
}
//****************************************************************************************************************************************************
/// We display a notification and pop the application window if an IMAP client tries to connect to a signed out account, but we do not want to
/// do it repeatedly, as it's an intrusive action. This function let's you define a period of time during which the notification should not be
/// displayed.
///
/// \param durationMSecs The duration of the period in milliseconds.
//****************************************************************************************************************************************************
void User::startImapLoginFailureCooldown(qint64 durationMSecs) {
imapFailureCooldownEndTime_ = QDateTime::currentDateTime().addMSecs(durationMSecs);
}
//****************************************************************************************************************************************************
/// \return true if we currently are in a cooldown period for the notification
//****************************************************************************************************************************************************
bool User::isInIMAPLoginFailureCooldown() const {
return QDateTime::currentDateTime() < imapFailureCooldownEndTime_;
}
} // namespace bridgepp

View File

@ -74,6 +74,8 @@ public: // member functions.
User &operator=(User &&) = delete; ///< Disabled move assignment operator.
void update(User const &user); ///< Update the user.
Q_INVOKABLE QString primaryEmailOrUsername() const; ///< Return the user primary email, or, if unknown its username.
void startImapLoginFailureCooldown(qint64 durationMSecs); ///< Start the user cooldown period for the IMAP login attempt while signed-out notification.
bool isInIMAPLoginFailureCooldown() const; ///< Check if the user in a IMAP login failure notification.
public slots:
// slots for QML generated calls
@ -137,6 +139,7 @@ private: // member functions.
User(QObject *parent); ///< Default constructor.
private: // data members.
QDateTime imapFailureCooldownEndTime_; ///< The end date/time for the IMAP login failure notification cooldown period.
QString id_; ///< The userID.
QString username_; ///< The username
QString password_; ///< The IMAP password of the user.