Wiring up config and forcing implementation of enable/disable per
provider
This commit is contained in:
parent
44e85d73df
commit
21b081ad14
7 changed files with 80 additions and 2 deletions
|
@ -42,6 +42,14 @@ public:
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enable() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void onNetworkChange() override;
|
virtual void onNetworkChange() override;
|
||||||
virtual void onStart() override;
|
virtual void onStart() override;
|
||||||
|
|
|
@ -43,6 +43,13 @@ public:
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enable() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void disable() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void sendUdpIdentityPacket(const QList<QHostAddress> &addresses);
|
void sendUdpIdentityPacket(const QList<QHostAddress> &addresses);
|
||||||
|
|
||||||
static void configureSslSocket(QSslSocket *socket, const QString &deviceId, bool isDeviceTrusted);
|
static void configureSslSocket(QSslSocket *socket, const QString &deviceId, bool isDeviceTrusted);
|
||||||
|
|
|
@ -24,6 +24,9 @@ public:
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
virtual int priority() = 0;
|
virtual int priority() = 0;
|
||||||
|
|
||||||
|
virtual void enable() = 0;
|
||||||
|
virtual void disable() = 0;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void onStart() = 0;
|
virtual void onStart() = 0;
|
||||||
virtual void onStop() = 0;
|
virtual void onStop() = 0;
|
||||||
|
|
|
@ -27,6 +27,14 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enable() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void onStart() override;
|
void onStart() override;
|
||||||
void onStop() override;
|
void onStop() override;
|
||||||
void onNetworkChange() override;
|
void onNetworkChange() override;
|
||||||
|
|
|
@ -149,11 +149,19 @@ QSet<LinkProvider *> Daemon::getLinkProviders() const
|
||||||
|
|
||||||
QStringList Daemon::linkProviders() const
|
QStringList Daemon::linkProviders() const
|
||||||
{
|
{
|
||||||
|
auto configInstance = KdeConnectConfig::instance();
|
||||||
|
auto status = configInstance.getLinkProviderStatus();
|
||||||
QStringList returnValue;
|
QStringList returnValue;
|
||||||
|
|
||||||
for (LinkProvider *a : std::as_const(d->m_linkProviders)) {
|
for (LinkProvider *a : std::as_const(d->m_linkProviders)) {
|
||||||
QString line = QString(a->name());
|
QString line = QString(a->name());
|
||||||
line += QStringLiteral("|enabled");
|
|
||||||
|
if (status[QStringLiteral("enabled")].contains(a->name())) {
|
||||||
|
line += QStringLiteral("|enabled");
|
||||||
|
} else {
|
||||||
|
line += QStringLiteral("|disabled");
|
||||||
|
}
|
||||||
|
|
||||||
returnValue.append(line);
|
returnValue.append(line);
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
@ -162,9 +170,34 @@ QStringList Daemon::linkProviders() const
|
||||||
void Daemon::setProviderStatus(const QStringList &providerStatus)
|
void Daemon::setProviderStatus(const QStringList &providerStatus)
|
||||||
{
|
{
|
||||||
qCDebug(KDECONNECT_CORE) << "setProviderStatus called" << providerStatus;
|
qCDebug(KDECONNECT_CORE) << "setProviderStatus called" << providerStatus;
|
||||||
|
|
||||||
|
KdeConnectConfig configInstance = KdeConnectConfig::instance();
|
||||||
|
|
||||||
|
QStringList enabledProviders;
|
||||||
|
QStringList disabledProviders;
|
||||||
|
|
||||||
for (const auto &i : providerStatus) {
|
for (const auto &i : providerStatus) {
|
||||||
qCDebug(KDECONNECT_CORE) << "setProviderstatus with: " << i;
|
auto components = i.split(QStringLiteral("|"));
|
||||||
|
QString providerName = components.at(0);
|
||||||
|
QString providerStatus = components.at(1);
|
||||||
|
|
||||||
|
auto linkProviders = this->getLinkProviders();
|
||||||
|
for (LinkProvider *provider : linkProviders) {
|
||||||
|
if (provider->name() == providerName) {
|
||||||
|
if (providerStatus == QStringLiteral("enabled")) {
|
||||||
|
qCDebug(KDECONNECT_CORE) << "enabling " << providerName;
|
||||||
|
provider->enable();
|
||||||
|
enabledProviders.append(providerName);
|
||||||
|
} else {
|
||||||
|
qCDebug(KDECONNECT_CORE) << "disabling" << providerName;
|
||||||
|
provider->disable();
|
||||||
|
disabledProviders.append(providerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
configInstance.setLinkProviderStatus(enabledProviders, disabledProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
|
QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
|
||||||
|
|
|
@ -76,6 +76,23 @@ void KdeConnectConfig::setName(const QString &name)
|
||||||
d->m_config->sync();
|
d->m_config->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KdeConnectConfig::setLinkProviderStatus(const QStringList enabledProviders, const QStringList disabledProviders)
|
||||||
|
{
|
||||||
|
d->m_config->setValue(QStringLiteral("enabled_providers"), enabledProviders);
|
||||||
|
d->m_config->setValue(QStringLiteral("disabled_providers"), disabledProviders);
|
||||||
|
d->m_config->sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QStringList> KdeConnectConfig::getLinkProviderStatus()
|
||||||
|
{
|
||||||
|
QMap<QString, QStringList> result;
|
||||||
|
|
||||||
|
result[QStringLiteral("enabled")] = d->m_config->value(QStringLiteral("enabled_providers")).toStringList();
|
||||||
|
result[QStringLiteral("disabled")] = d->m_config->value(QStringLiteral("disabled_providers")).toStringList();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceType KdeConnectConfig::deviceType()
|
DeviceType KdeConnectConfig::deviceType()
|
||||||
{
|
{
|
||||||
const QByteArrayList platforms = qgetenv("PLASMA_PLATFORM").split(':');
|
const QByteArrayList platforms = qgetenv("PLASMA_PLATFORM").split(':');
|
||||||
|
|
|
@ -35,6 +35,8 @@ public:
|
||||||
QString certificatePath();
|
QString certificatePath();
|
||||||
|
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
void setLinkProviderStatus(const QStringList enabledProviders, const QStringList disabledProviders);
|
||||||
|
QMap<QString, QStringList> getLinkProviderStatus();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trusted devices
|
* Trusted devices
|
||||||
|
|
Loading…
Reference in a new issue