Make default name and device type customizable
This commit is contained in:
parent
bb5539c8c3
commit
a39a2d562d
4 changed files with 33 additions and 11 deletions
|
@ -55,6 +55,8 @@ public:
|
||||||
virtual void quit() = 0;
|
virtual void quit() = 0;
|
||||||
virtual QNetworkAccessManager* networkAccessManager();
|
virtual QNetworkAccessManager* networkAccessManager();
|
||||||
virtual KJobTrackerInterface* jobTracker() = 0;
|
virtual KJobTrackerInterface* jobTracker() = 0;
|
||||||
|
virtual QString defaultName() const = 0;
|
||||||
|
virtual QString deviceType() const = 0;
|
||||||
|
|
||||||
Device* getDevice(const QString& deviceId);
|
Device* getDevice(const QString& deviceId);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QHostInfo>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSslCertificate>
|
#include <QSslCertificate>
|
||||||
#include <QtCrypto>
|
#include <QtCrypto>
|
||||||
|
@ -53,6 +52,9 @@ struct KdeConnectConfigPrivate {
|
||||||
QSettings* m_config;
|
QSettings* m_config;
|
||||||
QSettings* m_trustedDevices;
|
QSettings* m_trustedDevices;
|
||||||
|
|
||||||
|
QString m_defaultName;
|
||||||
|
QString m_deviceType;
|
||||||
|
|
||||||
#ifdef USE_PRIVATE_DBUS
|
#ifdef USE_PRIVATE_DBUS
|
||||||
QString m_privateDBusAddress; // Private DBus Address cache
|
QString m_privateDBusAddress; // Private DBus Address cache
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,21 +86,16 @@ KdeConnectConfig::KdeConnectConfig()
|
||||||
d->m_config = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("config")), QSettings::IniFormat);
|
d->m_config = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("config")), QSettings::IniFormat);
|
||||||
d->m_trustedDevices = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("trusted_devices")), QSettings::IniFormat);
|
d->m_trustedDevices = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("trusted_devices")), QSettings::IniFormat);
|
||||||
|
|
||||||
|
d->m_defaultName = Daemon::instance()->defaultName();
|
||||||
|
d->m_deviceType = Daemon::instance()->deviceType();
|
||||||
|
|
||||||
loadPrivateKey();
|
loadPrivateKey();
|
||||||
loadCertificate();
|
loadCertificate();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KdeConnectConfig::name()
|
QString KdeConnectConfig::name()
|
||||||
{
|
{
|
||||||
QString username;
|
return d->m_config->value(QStringLiteral("name"), d->m_defaultName).toString();
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
username = QString::fromLatin1(qgetenv("USERNAME"));
|
|
||||||
#else
|
|
||||||
username = QString::fromLatin1(qgetenv("USER"));
|
|
||||||
#endif
|
|
||||||
QString defaultName = username + QStringLiteral("@") + QHostInfo::localHostName();
|
|
||||||
QString name = d->m_config->value(QStringLiteral("name"), defaultName).toString();
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectConfig::setName(const QString& name)
|
void KdeConnectConfig::setName(const QString& name)
|
||||||
|
@ -109,7 +106,7 @@ void KdeConnectConfig::setName(const QString& name)
|
||||||
|
|
||||||
QString KdeConnectConfig::deviceType()
|
QString KdeConnectConfig::deviceType()
|
||||||
{
|
{
|
||||||
return QStringLiteral("desktop"); // TODO
|
return d->m_deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KdeConnectConfig::deviceId()
|
QString KdeConnectConfig::deviceId()
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QHostInfo>
|
||||||
|
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KDBusService>
|
#include <KDBusService>
|
||||||
|
@ -95,6 +96,20 @@ public:
|
||||||
return KIO::getJobTracker();
|
return KIO::getJobTracker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString defaultName() const override {
|
||||||
|
QString username;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
username = QString::fromLatin1(qgetenv("USERNAME"));
|
||||||
|
#else
|
||||||
|
username = QString::fromLatin1(qgetenv("USER"));
|
||||||
|
#endif
|
||||||
|
return username + QLatin1Char('@') + QHostInfo::localHostName();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString deviceType() const override {
|
||||||
|
return QStringLiteral("desktop");
|
||||||
|
}
|
||||||
|
|
||||||
Q_SCRIPTABLE void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override
|
Q_SCRIPTABLE void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override
|
||||||
{
|
{
|
||||||
KNotification* notification = new KNotification(eventId); //KNotification::Persistent
|
KNotification* notification = new KNotification(eventId); //KNotification::Persistent
|
||||||
|
|
|
@ -80,6 +80,14 @@ public:
|
||||||
qDebug() << "quit was called";
|
qDebug() << "quit was called";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString defaultName() const override {
|
||||||
|
return QStringLiteral("test@localhost");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString deviceType() const override {
|
||||||
|
return QStringLiteral("desktop");
|
||||||
|
}
|
||||||
|
|
||||||
KJobTrackerInterface* jobTracker() override
|
KJobTrackerInterface* jobTracker() override
|
||||||
{
|
{
|
||||||
if (!m_jobTrackerInterface) {
|
if (!m_jobTrackerInterface) {
|
||||||
|
|
Loading…
Reference in a new issue