File indexing completed on 2024-04-21 04:59:41

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqola_private_export.h"
0010 #include <QDebug>
0011 #include <QObject>
0012 class RocketChatAccount;
0013 class LIBRUQOLACORE_TESTS_EXPORT AwayManager : public QObject
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit AwayManager(RocketChatAccount *const account, QObject *parent = nullptr);
0018     ~AwayManager() override;
0019 
0020     [[nodiscard]] bool enabled() const;
0021     void setEnabled(bool newEnabled);
0022 
0023     [[nodiscard]] int idleTiming() const;
0024     void setIdleTiming(int newIdleTiming);
0025 
0026     void updateSettings();
0027 
0028 Q_SIGNALS:
0029     void awayChanged(bool away);
0030 
0031 private:
0032     void slotResumeFromIdle();
0033     void slotIdleTimeoutReached(int timerId);
0034     [[nodiscard]] int calculateRemainingTime() const;
0035     [[nodiscard]] int timeValue() const;
0036     RocketChatAccount *const mRocketChatAccount;
0037     int mTimerId = -1;
0038     int mIdleTiming = -1;
0039     bool mEnabled = false;
0040 };
0041 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const AwayManager &t);