mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-26 17:03:08 +00:00
src: migrate InputServiceClient to generated Input1 proxy
This commit is contained in:
parent
a893d4fd71
commit
d254b272fe
1 changed files with 38 additions and 24 deletions
|
|
@ -3,11 +3,13 @@
|
|||
|
||||
#include "inputserviceclient.h"
|
||||
|
||||
#include "input1interface.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusConnectionInterface>
|
||||
#include <QDBusError>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusPendingReply>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QDBusVariant>
|
||||
|
|
@ -243,17 +245,21 @@ void InputServiceClient::refreshControllers()
|
|||
return;
|
||||
}
|
||||
|
||||
QDBusInterface i(kInputService, kInputPath, kInputInterface, QDBusConnection::sessionBus());
|
||||
i.setTimeout(2000);
|
||||
org::kde::ALaKarte::Input1 iface(kInputService, kInputPath, QDBusConnection::sessionBus());
|
||||
iface.setTimeout(2000);
|
||||
|
||||
const QDBusReply<bool> rescanReply = i.call(QStringLiteral("Rescan"));
|
||||
if (!rescanReply.isValid()) {
|
||||
setLastError(rescanReply.error().message());
|
||||
{
|
||||
QDBusPendingReply<bool> rescanReply = iface.Rescan();
|
||||
rescanReply.waitForFinished();
|
||||
if (rescanReply.isError()) {
|
||||
setLastError(rescanReply.error().message());
|
||||
}
|
||||
}
|
||||
|
||||
const QDBusReply<QVariantList> reply = i.call(QStringLiteral("ListControllers"));
|
||||
QDBusPendingReply<QVariantList> reply = iface.ListControllers();
|
||||
reply.waitForFinished();
|
||||
|
||||
if (!reply.isValid()) {
|
||||
if (reply.isError()) {
|
||||
setLastError(reply.error().message());
|
||||
return;
|
||||
}
|
||||
|
|
@ -274,11 +280,13 @@ void InputServiceClient::refreshProfiles()
|
|||
return;
|
||||
}
|
||||
|
||||
QDBusInterface i(kInputService, kInputPath, kInputInterface, QDBusConnection::sessionBus());
|
||||
i.setTimeout(2000);
|
||||
const QDBusReply<QVariantList> reply = i.call(QStringLiteral("ListProfiles"));
|
||||
org::kde::ALaKarte::Input1 iface(kInputService, kInputPath, QDBusConnection::sessionBus());
|
||||
iface.setTimeout(2000);
|
||||
|
||||
if (!reply.isValid()) {
|
||||
QDBusPendingReply<QVariantList> reply = iface.ListProfiles();
|
||||
reply.waitForFinished();
|
||||
|
||||
if (reply.isError()) {
|
||||
setLastError(reply.error().message());
|
||||
return;
|
||||
}
|
||||
|
|
@ -300,11 +308,13 @@ bool InputServiceClient::setActiveProfile(const QString &controllerId, const QSt
|
|||
return false;
|
||||
}
|
||||
|
||||
QDBusInterface i(kInputService, kInputPath, kInputInterface, QDBusConnection::sessionBus());
|
||||
i.setTimeout(2000);
|
||||
const QDBusReply<bool> reply = i.call(QStringLiteral("SetActiveProfile"), controllerId, profileId);
|
||||
org::kde::ALaKarte::Input1 iface(kInputService, kInputPath, QDBusConnection::sessionBus());
|
||||
iface.setTimeout(2000);
|
||||
|
||||
if (!reply.isValid()) {
|
||||
QDBusPendingReply<bool> reply = iface.SetActiveProfile(controllerId, profileId);
|
||||
reply.waitForFinished();
|
||||
|
||||
if (reply.isError()) {
|
||||
setLastError(reply.error().message());
|
||||
return false;
|
||||
}
|
||||
|
|
@ -319,11 +329,13 @@ QString InputServiceClient::createProfile(const QString &name)
|
|||
return {};
|
||||
}
|
||||
|
||||
QDBusInterface i(kInputService, kInputPath, kInputInterface, QDBusConnection::sessionBus());
|
||||
i.setTimeout(2000);
|
||||
const QDBusReply<QString> reply = i.call(QStringLiteral("CreateProfile"), name);
|
||||
org::kde::ALaKarte::Input1 iface(kInputService, kInputPath, QDBusConnection::sessionBus());
|
||||
iface.setTimeout(2000);
|
||||
|
||||
if (!reply.isValid()) {
|
||||
QDBusPendingReply<QString> reply = iface.CreateProfile(name);
|
||||
reply.waitForFinished();
|
||||
|
||||
if (reply.isError()) {
|
||||
setLastError(reply.error().message());
|
||||
return {};
|
||||
}
|
||||
|
|
@ -339,11 +351,13 @@ bool InputServiceClient::deleteProfile(const QString &profileId)
|
|||
return false;
|
||||
}
|
||||
|
||||
QDBusInterface i(kInputService, kInputPath, kInputInterface, QDBusConnection::sessionBus());
|
||||
i.setTimeout(2000);
|
||||
const QDBusReply<bool> reply = i.call(QStringLiteral("DeleteProfile"), profileId);
|
||||
org::kde::ALaKarte::Input1 iface(kInputService, kInputPath, QDBusConnection::sessionBus());
|
||||
iface.setTimeout(2000);
|
||||
|
||||
if (!reply.isValid()) {
|
||||
QDBusPendingReply<bool> reply = iface.DeleteProfile(profileId);
|
||||
reply.waitForFinished();
|
||||
|
||||
if (reply.isError()) {
|
||||
setLastError(reply.error().message());
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue