diff --git a/core/daemon.h b/core/daemon.h index 31e4ebe87..9840e678a 100644 --- a/core/daemon.h +++ b/core/daemon.h @@ -55,8 +55,6 @@ public: virtual void quit() = 0; virtual QNetworkAccessManager* networkAccessManager(); virtual KJobTrackerInterface* jobTracker() = 0; - virtual QString defaultName() const = 0; - virtual QString deviceType() const = 0; Device* getDevice(const QString& deviceId); diff --git a/core/kdeconnectconfig.cpp b/core/kdeconnectconfig.cpp index b3ae200d2..a23f0924b 100644 --- a/core/kdeconnectconfig.cpp +++ b/core/kdeconnectconfig.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -52,9 +53,6 @@ struct KdeConnectConfigPrivate { QSettings* m_config; QSettings* m_trustedDevices; - QString m_defaultName; - QString m_deviceType; - #ifdef USE_PRIVATE_DBUS QString m_privateDBusAddress; // Private DBus Address cache #endif @@ -86,16 +84,21 @@ KdeConnectConfig::KdeConnectConfig() 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_defaultName = Daemon::instance()->defaultName(); - d->m_deviceType = Daemon::instance()->deviceType(); - loadPrivateKey(); loadCertificate(); } QString KdeConnectConfig::name() { - return d->m_config->value(QStringLiteral("name"), d->m_defaultName).toString(); + QString username; + #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) @@ -106,7 +109,7 @@ void KdeConnectConfig::setName(const QString& name) QString KdeConnectConfig::deviceType() { - return d->m_deviceType; + return QStringLiteral("desktop"); // TODO } QString KdeConnectConfig::deviceId() diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index 8977d589c..4aeba2a65 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -96,20 +95,6 @@ public: 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 { KNotification* notification = new KNotification(eventId); //KNotification::Persistent diff --git a/tests/testdaemon.h b/tests/testdaemon.h index 7a668770e..c42604429 100644 --- a/tests/testdaemon.h +++ b/tests/testdaemon.h @@ -80,14 +80,6 @@ public: qDebug() << "quit was called"; } - QString defaultName() const override { - return QStringLiteral("test@localhost"); - } - - QString deviceType() const override { - return QStringLiteral("desktop"); - } - KJobTrackerInterface* jobTracker() override { if (!m_jobTrackerInterface) {