aboutsummaryrefslogtreecommitdiff
path: root/lib/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/settings.cpp')
-rw-r--r--lib/settings.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/lib/settings.cpp b/lib/settings.cpp
index dd086d9c..510d253c 100644
--- a/lib/settings.cpp
+++ b/lib/settings.cpp
@@ -1,5 +1,9 @@
+// SPDX-FileCopyrightText: 2016 Kitsune Ral <kitsune-ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
#include "settings.h"
+#include "util.h"
#include "logging.h"
#include <QtCore/QUrl>
@@ -18,7 +22,9 @@ void Settings::setLegacyNames(const QString& organizationName,
Settings::Settings(QObject* parent) : QSettings(parent)
{
+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
setIniCodec("UTF-8");
+#endif
}
void Settings::setValue(const QString& key, const QVariant& value)
@@ -97,17 +103,18 @@ void SettingsGroup::remove(const QString& key)
Settings::remove(fullKey);
}
-QTNT_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {},
+QUO_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {},
setDeviceId)
-QTNT_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
+QUO_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
setDeviceName)
-QTNT_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
+QUO_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
setKeepLoggedIn)
-static const auto HomeserverKey = QStringLiteral("homeserver");
-static const auto AccessTokenKey = QStringLiteral("access_token");
-static const auto EncryptionAccountPickleKey =
- QStringLiteral("encryption_account_pickle");
+namespace {
+constexpr auto HomeserverKey = "homeserver"_ls;
+constexpr auto AccessTokenKey = "access_token"_ls;
+constexpr auto EncryptionAccountPickleKey = "encryption_account_pickle"_ls;
+}
QUrl AccountSettings::homeserver() const
{
@@ -121,19 +128,6 @@ void AccountSettings::setHomeserver(const QUrl& url)
QString AccountSettings::userId() const { return group().section('/', -1); }
-QString AccountSettings::accessToken() const
-{
- return value(AccessTokenKey).toString();
-}
-
-void AccountSettings::setAccessToken(const QString& accessToken)
-{
- qCWarning(MAIN) << "Saving access_token to QSettings is insecure."
- " Developers, do it manually or contribute to share "
- "QtKeychain logic to libQuotient.";
- setValue(AccessTokenKey, accessToken);
-}
-
void AccountSettings::clearAccessToken()
{
legacySettings.remove(AccessTokenKey);
@@ -144,18 +138,12 @@ void AccountSettings::clearAccessToken()
QByteArray AccountSettings::encryptionAccountPickle()
{
- QString passphrase = ""; // FIXME: add QtKeychain
return value("encryption_account_pickle", "").toByteArray();
}
void AccountSettings::setEncryptionAccountPickle(
const QByteArray& encryptionAccountPickle)
{
- qCWarning(MAIN)
- << "Saving encryption_account_pickle to QSettings is insecure."
- " Developers, do it manually or contribute to share QtKeychain "
- "logic to libQuotient.";
- QString passphrase = ""; // FIXME: add QtKeychain
setValue("encryption_account_pickle", encryptionAccountPickle);
}