diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index 3356525f3..e00db4af2 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -29,6 +29,7 @@ #include "tmainwindow.h" #include "mapplication.h" #include "../fervor/fvupdater.h" +#include "../vmisc/vsysexits.h" #include // For QT_REQUIRE_VERSION #include @@ -55,6 +56,17 @@ int main(int argc, char *argv[]) MApplication app(argc, argv); app.InitOptions(); + if (FvUpdater::IsStaledTestBuild()) + { + qWarning() << QApplication::translate("Tape", + "This test build is older than %1 days. To provide you with better " + "quality service we restrict the lifetime you can use a test build. " + "To continue using Tape please update to newer test build. The " + "application will be shut down.") + .arg(FvUpdater::testBuildLifetime); + return V_EX_UNAVAILABLE; + } + QTimer::singleShot(0, &app, &MApplication::ProcessCMD); return app.exec(); diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 89fed0acd..94f6f9158 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -66,6 +66,17 @@ int main(int argc, char *argv[]) app.InitOptions(); + if (FvUpdater::IsStaledTestBuild()) + { + qWarning() << QApplication::translate("Valentina", + "This test build is older than %1 days. To provide you with better " + "quality service we restrict the lifetime you can use a test build. " + "To continue using Valentina please update to newer test build. The " + "application will be shut down.") + .arg(FvUpdater::testBuildLifetime); + return V_EX_UNAVAILABLE; + } + if (VApplication::IsGUIMode()) { // Set feed URL before doing anything else diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 7c8cf6128..854dd46b3 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -53,6 +53,8 @@ #include "fvavailableupdate.h" #include "fvupdatewindow.h" +const int FvUpdater::testBuildLifetime = 90; + namespace { Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL, @@ -132,6 +134,20 @@ bool FvUpdater::IsTestBuild() return (version != 0x0 && version != APP_VERSION); } +//--------------------------------------------------------------------------------------------------------------------- +bool FvUpdater::IsStaledTestBuild() +{ + if (IsTestBuild()) + { + QDate builtDate = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy")); + return builtDate.daysTo(QDate::currentDate()) > testBuildLifetime; + } + else + { + return false; + } +} + //--------------------------------------------------------------------------------------------------------------------- FvUpdater::FvUpdater() : QObject(nullptr), diff --git a/src/libs/fervor/fvupdater.h b/src/libs/fervor/fvupdater.h index f02696a19..9ff720558 100644 --- a/src/libs/fervor/fvupdater.h +++ b/src/libs/fervor/fvupdater.h @@ -46,6 +46,7 @@ public: static QString CurrentFeedURL(); static int CurrentVersion(); static bool IsTestBuild(); + static bool IsStaledTestBuild(); // Set / get feed URL void SetFeedURL(const QUrl &feedURL); @@ -55,6 +56,8 @@ public: bool IsDropOnFinnish() const; void SetDropOnFinnish(bool value); + static const int testBuildLifetime; + public slots: // Check for updates bool CheckForUpdates(bool silentAsMuchAsItCouldGet = true);