KUnifiedPush

client.cpp
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "client.h"
7#include "connector1iface.h"
8#include "logging.h"
9
10#include "../shared/unifiedpush-constants.h"
11
12#include <QDBusConnection>
13#include <QDBusConnectionInterface>
14#include <QSettings>
15
16using namespace KUnifiedPush;
17
18Client Client::load(const QString &token, QSettings &settings)
19{
20 settings.beginGroup(token);
21 Client client;
22 client.token = token;
23 client.remoteId = settings.value(QStringLiteral("RemoteId"), QString()).toString();
24 client.serviceName = settings.value(QStringLiteral("ServiceName"), QString()).toString();
25 client.endpoint = settings.value(QStringLiteral("Endpoint"), QString()).toString();
26 client.description = settings.value(QStringLiteral("Description"), QString()).toString();
27 settings.endGroup();
28 return client;
29}
30
31void Client::store(QSettings& settings) const
32{
33 settings.beginGroup(token);
34 settings.setValue(QStringLiteral("RemoteId"), remoteId);
35 settings.setValue(QStringLiteral("ServiceName"), serviceName);
36 settings.setValue(QStringLiteral("Endpoint"), endpoint);
37 settings.setValue(QStringLiteral("Description"), description);
38 settings.endGroup();
39}
40
41bool Client::isValid() const
42{
43 return !token.isEmpty() && !serviceName.isEmpty();
44}
45
46void Client::activate() const
47{
48 qCDebug(Log) << "activating" << serviceName;
50}
51
52OrgUnifiedpushConnector1Interface Client::connector() const
53{
54 return OrgUnifiedpushConnector1Interface(serviceName, QLatin1String(UP_CONNECTOR_PATH), QDBusConnection::sessionBus());
55}
Information about a registered client.
Definition client.h:19
OrgUnifiedpushConnector1Interface connector() const
D-Bus UnifiedPush connector interface.
Definition client.cpp:52
void activate() const
Activate client on D-Bus.
Definition client.cpp:46
bool isValid() const
Contains all required information for a client.
Definition client.cpp:41
Client-side integration with UnifiedPush.
Definition connector.h:16
QDBusConnectionInterface * interface() const const
QDBusConnection sessionBus()
QDBusReply< void > startService(const QString &name)
void beginGroup(QAnyStringView prefix)
void endGroup()
void setValue(QAnyStringView key, const QVariant &value)
QVariant value(QAnyStringView key) const const
bool isEmpty() const const
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:47 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.