2015-03-02 04:16:07 +00:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2015 Albert Vaca <albertvaka@gmail.com>
|
2015-03-02 04:16:07 +00:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2015-03-02 04:16:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KDECONNECTCONFIG_H
|
|
|
|
#define KDECONNECTCONFIG_H
|
|
|
|
|
|
|
|
#include <QDir>
|
2024-05-19 11:04:43 +01:00
|
|
|
#include <QSslKey>
|
2015-03-02 04:16:07 +00:00
|
|
|
|
2023-06-27 12:10:59 +01:00
|
|
|
#include "deviceinfo.h"
|
2015-03-02 04:16:07 +00:00
|
|
|
#include "kdeconnectcore_export.h"
|
|
|
|
|
2015-11-30 18:36:01 +00:00
|
|
|
class QSslCertificate;
|
|
|
|
|
2015-03-02 04:16:07 +00:00
|
|
|
class KDECONNECTCORE_EXPORT KdeConnectConfig
|
|
|
|
{
|
|
|
|
public:
|
2022-09-10 22:23:52 +01:00
|
|
|
static KdeConnectConfig &instance();
|
2015-03-02 04:16:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Our own info
|
|
|
|
*/
|
|
|
|
|
|
|
|
QString deviceId();
|
|
|
|
QString name();
|
2023-06-27 12:10:59 +01:00
|
|
|
DeviceType deviceType();
|
2024-05-19 11:04:43 +01:00
|
|
|
QSslKey privateKey();
|
2023-06-27 12:10:59 +01:00
|
|
|
QSslCertificate certificate();
|
|
|
|
DeviceInfo deviceInfo();
|
2024-05-19 11:04:43 +01:00
|
|
|
QSsl::KeyAlgorithm privateKeyAlgorithm();
|
2015-03-02 04:16:07 +00:00
|
|
|
QString privateKeyPath();
|
2015-07-05 14:23:53 +01:00
|
|
|
QString certificatePath();
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
void setName(const QString &name);
|
2024-11-03 21:10:51 +00:00
|
|
|
void setDisabledLinkProviders(const QStringList disabledProviders);
|
|
|
|
QStringList disabledLinkProviders() const;
|
2015-03-02 04:16:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Trusted devices
|
|
|
|
*/
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
QStringList trustedDevices(); // list of ids
|
|
|
|
void removeTrustedDevice(const QString &id);
|
2023-06-27 12:10:59 +01:00
|
|
|
void addTrustedDevice(const DeviceInfo &deviceInfo);
|
|
|
|
void updateTrustedDeviceInfo(const DeviceInfo &deviceInfo);
|
|
|
|
DeviceInfo getTrustedDevice(const QString &id);
|
|
|
|
QSslCertificate getTrustedDeviceCertificate(const QString &id);
|
2015-11-30 18:36:01 +00:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
void setDeviceProperty(const QString &deviceId, const QString &name, const QString &value);
|
|
|
|
QString getDeviceProperty(const QString &deviceId, const QString &name, const QString &defaultValue = QString());
|
2015-03-02 04:16:07 +00:00
|
|
|
|
2020-08-18 15:55:48 +01:00
|
|
|
// Custom devices
|
2022-09-10 22:23:52 +01:00
|
|
|
void setCustomDevices(const QStringList &addresses);
|
2020-08-18 15:55:48 +01:00
|
|
|
QStringList customDevices() const;
|
|
|
|
|
2015-03-14 04:19:39 +00:00
|
|
|
/*
|
|
|
|
* Paths for config files, there is no guarantee the directories already exist
|
|
|
|
*/
|
2015-03-02 04:16:07 +00:00
|
|
|
QDir baseConfigDir();
|
2022-09-10 22:23:52 +01:00
|
|
|
QDir deviceConfigDir(const QString &deviceId);
|
|
|
|
QDir pluginConfigDir(const QString &deviceId, const QString &pluginName); // Used by KdeConnectPluginConfig
|
2015-03-02 04:16:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
KdeConnectConfig();
|
|
|
|
|
2023-07-12 17:54:16 +01:00
|
|
|
void loadOrGeneratePrivateKeyAndCertificate(const QString &keyPath, const QString &certPath);
|
|
|
|
bool loadPrivateKey(const QString &path);
|
|
|
|
bool loadCertificate(const QString &path);
|
2022-09-10 22:23:52 +01:00
|
|
|
void generatePrivateKey(const QString &path);
|
|
|
|
void generateCertificate(const QString &path);
|
2015-03-14 04:19:39 +00:00
|
|
|
|
2024-08-26 18:42:08 +01:00
|
|
|
void removeAllTrustedDevices();
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
struct KdeConnectConfigPrivate *d;
|
2015-03-02 04:16:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|