File indexing completed on 2024-04-07 14:50:45

0001 /*
0002    SPDX-FileCopyrightText: 2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqolacore_export.h"
0010 #include <QDate>
0011 #include <QObject>
0012 class RocketChatAccount;
0013 class LIBRUQOLACORE_EXPORT PreviewUrlCacheManager : public QObject
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit PreviewUrlCacheManager(RocketChatAccount *account, QObject *parent = nullptr);
0018     ~PreviewUrlCacheManager() override;
0019 
0020     [[nodiscard]] int embedCacheExpirationDays() const;
0021     void setEmbedCacheExpirationDays(int newEmbedCacheExpirationDays);
0022 
0023     [[nodiscard]] QString cachePath() const;
0024     void setCachePath(const QString &newCachePath);
0025 
0026     [[nodiscard]] QDate currentDate() const;
0027     void setCurrentDate(const QDate &newCurrentDateTime);
0028 
0029 private:
0030     LIBRUQOLACORE_NO_EXPORT void saveLastCheckedDateTime();
0031     [[nodiscard]] LIBRUQOLACORE_NO_EXPORT bool needToCheck() const;
0032     LIBRUQOLACORE_NO_EXPORT void checkCache();
0033     QDate mCurrentDate = QDate::currentDate();
0034     QString mCachePath;
0035     int mEmbedCacheExpirationDays = -1;
0036     RocketChatAccount *const mRocketChatAccount;
0037 };