2018-08-03 17:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2018-08-14 10:25:15 +00:00
|
|
|
#include "qPrefUpdateManager.h"
|
2018-08-03 17:24:53 +00:00
|
|
|
#include "qPrefPrivate.h"
|
|
|
|
|
|
|
|
|
|
|
|
static const QString group = QStringLiteral("UpdateManager");
|
|
|
|
|
2018-08-19 10:00:01 +00:00
|
|
|
QString qPrefUpdateManager::st_uuidString;
|
2019-04-01 21:17:17 +00:00
|
|
|
static const QString st_uuidString_default;
|
2018-08-19 10:00:01 +00:00
|
|
|
|
2018-08-03 17:24:53 +00:00
|
|
|
qPrefUpdateManager *qPrefUpdateManager::instance()
|
|
|
|
{
|
|
|
|
static qPrefUpdateManager *self = new qPrefUpdateManager;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void qPrefUpdateManager::loadSync(bool doSync)
|
|
|
|
{
|
|
|
|
disk_dont_check_for_updates(doSync);
|
|
|
|
disk_last_version_used(doSync);
|
|
|
|
disk_next_check(doSync);
|
2018-08-19 10:00:01 +00:00
|
|
|
if (!doSync) {
|
|
|
|
load_uuidString();
|
|
|
|
}
|
2018-08-03 17:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_BOOL_EXT(UpdateManager, "DontCheckForUpdates", dont_check_for_updates, update_manager.);
|
2018-08-03 17:24:53 +00:00
|
|
|
|
|
|
|
void qPrefUpdateManager::set_dont_check_exists(bool value)
|
|
|
|
{
|
|
|
|
if (value != prefs.update_manager.dont_check_exists) {
|
|
|
|
prefs.update_manager.dont_check_exists = value;
|
2018-09-02 11:58:04 +00:00
|
|
|
emit instance()->dont_check_existsChanged(value);
|
2018-08-03 17:24:53 +00:00
|
|
|
}
|
|
|
|
// DO NOT STORE ON DISK
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_TXT_EXT(UpdateManager, "LastVersionUsed", last_version_used, update_manager.);
|
2018-08-03 17:24:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
void qPrefUpdateManager::set_next_check(const QDate& value)
|
|
|
|
{
|
2018-08-15 15:19:29 +00:00
|
|
|
long time_value = value.toJulianDay();
|
|
|
|
if (time_value != prefs.update_manager.next_check) {
|
|
|
|
prefs.update_manager.next_check = time_value;
|
2018-08-03 17:24:53 +00:00
|
|
|
disk_next_check(true);
|
2018-09-02 11:58:04 +00:00
|
|
|
emit instance()->next_checkChanged(value);
|
2018-08-03 17:24:53 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-15 15:19:29 +00:00
|
|
|
void qPrefUpdateManager::disk_next_check(bool doSync)
|
|
|
|
{
|
|
|
|
if (doSync)
|
2018-09-07 16:06:00 +00:00
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, "NextCheck"), prefs.update_manager.next_check, default_prefs.update_manager.next_check);
|
2018-08-15 15:19:29 +00:00
|
|
|
else
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.update_manager.next_check = qPrefPrivate::propValue(keyFromGroupAndName(group, "NextCheck"), 0).toInt();
|
2018-08-15 15:19:29 +00:00
|
|
|
}
|
2018-08-19 10:00:01 +00:00
|
|
|
|
2018-08-28 19:10:37 +00:00
|
|
|
HANDLE_PROP_QSTRING(UpdateManager, "UpdateManager/UUID", uuidString);
|