2018-07-12 19:01:31 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef QPREFCLOUDSTORAGE_H
|
|
|
|
#define QPREFCLOUDSTORAGE_H
|
2018-07-21 16:12:59 +00:00
|
|
|
#include "core/pref.h"
|
2018-07-12 19:01:31 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class qPrefCloudStorage : public QObject {
|
|
|
|
Q_OBJECT
|
2019-02-11 19:27:30 +00:00
|
|
|
Q_PROPERTY(bool cloud_auto_sync READ cloud_auto_sync WRITE set_cloud_auto_sync NOTIFY cloud_auto_syncChanged)
|
|
|
|
Q_PROPERTY(QString cloud_base_url READ cloud_base_url WRITE set_cloud_base_url NOTIFY cloud_base_urlChanged)
|
|
|
|
Q_PROPERTY(QString cloud_storage_email READ cloud_storage_email WRITE set_cloud_storage_email NOTIFY cloud_storage_emailChanged)
|
|
|
|
Q_PROPERTY(QString cloud_storage_email_encoded READ cloud_storage_email_encoded WRITE set_cloud_storage_email_encoded NOTIFY cloud_storage_email_encodedChanged)
|
|
|
|
Q_PROPERTY(QString cloud_storage_password READ cloud_storage_password WRITE set_cloud_storage_password NOTIFY cloud_storage_passwordChanged)
|
|
|
|
Q_PROPERTY(QString cloud_storage_pin READ cloud_storage_pin WRITE set_cloud_storage_pin NOTIFY cloud_storage_pinChanged)
|
|
|
|
Q_PROPERTY(int cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_statusChanged)
|
|
|
|
Q_PROPERTY(int cloud_timeout READ cloud_timeout WRITE set_cloud_timeout NOTIFY cloud_timeoutChanged)
|
|
|
|
Q_PROPERTY(bool save_password_local READ save_password_local WRITE set_save_password_local NOTIFY save_password_localChanged)
|
2019-12-11 16:50:49 +00:00
|
|
|
Q_PROPERTY(QString diveshare_uid READ diveshare_uid WRITE set_diveshare_uid NOTIFY diveshare_uidChanged);
|
2019-12-08 12:27:03 +00:00
|
|
|
Q_PROPERTY(bool diveshare_private READ diveshare_private WRITE set_diveshare_private NOTIFY diveshare_privateChanged);
|
2019-11-27 17:32:57 +00:00
|
|
|
Q_PROPERTY(QString divelogde_user READ divelogde_user WRITE set_divelogde_user NOTIFY divelogde_userChanged);
|
|
|
|
Q_PROPERTY(QString divelogde_pass READ divelogde_pass WRITE set_divelogde_pass NOTIFY divelogde_passChanged);
|
2018-07-12 19:01:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static qPrefCloudStorage *instance();
|
|
|
|
|
|
|
|
// Load/Sync local settings (disk) and struct preference
|
2018-08-14 08:30:07 +00:00
|
|
|
static void loadSync(bool doSync);
|
|
|
|
static void load() { loadSync(false); }
|
|
|
|
static void sync() { loadSync(true); }
|
2018-07-12 19:01:31 +00:00
|
|
|
|
|
|
|
public:
|
2020-01-18 13:02:00 +00:00
|
|
|
// NOTE: these enums are duplicated in mobile-widgets/qmlinterface.h
|
2018-09-02 14:22:16 +00:00
|
|
|
enum cloud_status {
|
|
|
|
CS_UNKNOWN,
|
|
|
|
CS_INCORRECT_USER_PASSWD,
|
|
|
|
CS_NEED_TO_VERIFY,
|
|
|
|
CS_VERIFIED,
|
|
|
|
CS_NOCLOUD
|
|
|
|
};
|
|
|
|
Q_ENUM(cloud_status);
|
|
|
|
|
2018-10-08 14:15:53 +00:00
|
|
|
static bool cloud_auto_sync() { return prefs.cloud_auto_sync; }
|
2018-08-02 16:32:51 +00:00
|
|
|
static QString cloud_base_url() { return prefs.cloud_base_url; }
|
|
|
|
static QString cloud_storage_email() { return prefs.cloud_storage_email; }
|
|
|
|
static QString cloud_storage_email_encoded() { return prefs.cloud_storage_email_encoded; }
|
|
|
|
static QString cloud_storage_password() { return prefs.cloud_storage_password; }
|
|
|
|
static QString cloud_storage_pin() { return prefs.cloud_storage_pin; }
|
|
|
|
static int cloud_timeout() { return prefs.cloud_timeout; }
|
|
|
|
static int cloud_verification_status() { return prefs.cloud_verification_status; }
|
|
|
|
static bool save_password_local() { return prefs.save_password_local; }
|
2019-12-08 12:27:03 +00:00
|
|
|
static QString diveshare_uid();
|
|
|
|
static bool diveshare_private();
|
2019-11-27 17:32:57 +00:00
|
|
|
static QString divelogde_user();
|
|
|
|
static QString divelogde_pass();
|
2018-07-12 19:01:31 +00:00
|
|
|
|
|
|
|
public slots:
|
2018-10-08 14:15:53 +00:00
|
|
|
static void set_cloud_auto_sync(bool value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_cloud_base_url(const QString &value);
|
2021-04-11 20:53:39 +00:00
|
|
|
static void store_cloud_base_url(const QString &value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_cloud_storage_email(const QString &value);
|
|
|
|
static void set_cloud_storage_email_encoded(const QString &value);
|
|
|
|
static void set_cloud_storage_password(const QString &value);
|
|
|
|
static void set_cloud_storage_pin(const QString &value);
|
|
|
|
static void set_cloud_timeout(int value);
|
|
|
|
static void set_cloud_verification_status(int value);
|
|
|
|
static void set_save_password_local(bool value);
|
2019-12-08 12:27:03 +00:00
|
|
|
static void set_diveshare_uid(const QString &value);
|
|
|
|
static void set_diveshare_private(bool value);
|
2019-11-27 17:32:57 +00:00
|
|
|
static void set_divelogde_user(const QString &value);
|
|
|
|
static void set_divelogde_pass(const QString &value);
|
2018-07-12 19:01:31 +00:00
|
|
|
|
|
|
|
signals:
|
2018-10-08 14:15:53 +00:00
|
|
|
void cloud_auto_syncChanged(bool value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void cloud_base_urlChanged(const QString &value);
|
|
|
|
void cloud_storage_emailChanged(const QString &value);
|
|
|
|
void cloud_storage_email_encodedChanged(const QString &value);
|
|
|
|
void cloud_storage_passwordChanged(const QString &value);
|
|
|
|
void cloud_storage_pinChanged(const QString &value);
|
|
|
|
void cloud_timeoutChanged(int value);
|
|
|
|
void cloud_verification_statusChanged(int value);
|
|
|
|
void save_password_localChanged(bool value);
|
2019-12-08 12:27:03 +00:00
|
|
|
void diveshare_uidChanged(const QString &value);
|
|
|
|
void diveshare_privateChanged(bool value);
|
2019-11-27 17:32:57 +00:00
|
|
|
void divelogde_userChanged(const QString &value);
|
|
|
|
void divelogde_passChanged(const QString &value);
|
2018-07-12 19:01:31 +00:00
|
|
|
|
|
|
|
private:
|
2018-09-14 10:25:18 +00:00
|
|
|
qPrefCloudStorage() {}
|
|
|
|
|
2018-07-12 19:01:31 +00:00
|
|
|
// functions to load/sync variable with disk
|
2018-10-08 14:15:53 +00:00
|
|
|
static void disk_cloud_auto_sync(bool doSync);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void disk_cloud_base_url(bool doSync);
|
|
|
|
static void disk_cloud_storage_email(bool doSync);
|
|
|
|
static void disk_cloud_storage_email_encoded(bool doSync);
|
|
|
|
static void disk_cloud_storage_password(bool doSync);
|
|
|
|
static void disk_cloud_storage_pin(bool doSync);
|
|
|
|
static void disk_cloud_timeout(bool doSync);
|
|
|
|
static void disk_cloud_verification_status(bool doSync);
|
|
|
|
static void disk_save_password_local(bool doSync);
|
2018-07-12 19:01:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|