File indexing completed on 2025-01-05 03:56:35

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2020-12-31
0007  * Description : Online version checker
0008  *
0009  * SPDX-FileCopyrightText: 2020-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_ONLINE_VERSION_CHECKER_H
0016 #define DIGIKAM_ONLINE_VERSION_CHECKER_H
0017 
0018 // Qt includes
0019 
0020 #include <QObject>
0021 #include <QUrl>
0022 #include <QNetworkReply>
0023 #include <QDateTime>
0024 
0025 // Local includes
0026 
0027 #include "digikam_export.h"
0028 
0029 namespace Digikam
0030 {
0031 
0032 class DIGIKAM_EXPORT OnlineVersionChecker : public QObject
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037 
0038     explicit OnlineVersionChecker(QObject* const parent, bool checkPreRelease = false);
0039     ~OnlineVersionChecker();
0040 
0041     void setCurrentVersion(const QString& version);
0042     void setCurrentBuildDate(const QDateTime& dt);
0043 
0044     void checkForNewVersion();
0045     void cancelCheck();
0046 
0047     QString preReleaseFileName() const;
0048 
0049     /**
0050      * Return true if the system and architecture are supported by the bundle workflow.
0051      * 'arch' is the relevant prefix for the bundle architecture.
0052      * 'ext'  is the relevant bundle file extension.
0053      */
0054     static bool bundleProperties(QString& arch, QString& ext);
0055 
0056     /**
0057      * Return the last date as string when have been performed a check for new version.
0058      */
0059     static QString lastCheckDate();
0060 
0061 Q_SIGNALS:
0062 
0063     void signalNewVersionAvailable(const QString& version);
0064     void signalNewVersionCheckError(const QString& error);
0065 
0066 private Q_SLOTS:
0067 
0068     void slotDownloadFinished(QNetworkReply* reply);
0069 
0070 private:
0071 
0072     void download(const QUrl& url);
0073 
0074 private:
0075 
0076     class Private;
0077     Private* const d;
0078 };
0079 
0080 } // namespace Digikam
0081 
0082 #endif // DIGIKAM_ONLINE_VERSION_CHECKER_H