KUnifiedPush

distributor.h
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KUNIFIEDPUSH_DISTRIBUTOR_H
7#define KUNIFIEDPUSH_DISTRIBUTOR_H
8
9#include "abstractpushprovider.h"
10#include "command.h"
11
12#include "../shared/clientinfo_p.h"
13#include "../shared/distributorstatus_p.h"
14
15#include <QDBusContext>
16#include <QObject>
17
18#include <deque>
19#include <memory>
20#include <vector>
21
22namespace KUnifiedPush {
23
24class Client;
25class Message;
26
27/** UnifiedPush distributor service. */
28class Distributor : public QObject, public QDBusContext
29{
31public:
32 explicit Distributor(QObject *parent = nullptr);
34
35 // UnifiedPush D-Bus interface
36 QString Register(const QString &serviceName, const QString &token, const QString &description, QString &registrationResultReason);
37 void Unregister(const QString &token);
38
39 // KCM D-Bus interface
40 int status() const;
41 QString pushProviderId() const;
42 QVariantMap pushProviderConfiguration(const QString &pushProviderId) const;
43 void setPushProvider(const QString &pushProviderId, const QVariantMap &config);
44 QList<KUnifiedPush::ClientInfo> registeredClients() const;
45 void forceUnregisterClient(const QString &token);
46
48 void statusChanged();
49 void pushProviderChanged();
50 void registeredClientsChanged();
51
52private:
53 void messageReceived(const Message &msg) const;
54 void clientRegistered(const Client &client, AbstractPushProvider::Error error, const QString &errorMsg);
55 void clientUnregistered(const Client &client, AbstractPushProvider::Error error);
56 void providerConnected();
57 void providerDisconnected(AbstractPushProvider::Error error, const QString &errorMsg);
58
59 QStringList clientTokens() const;
60
61 bool setupPushProvider();
62 void purgeUnavailableClients();
63
64 bool hasCurrentCommand() const;
65 void processNextCommand();
66
67 void setStatus(DistributorStatus::Status status);
68
69 bool isNetworkAvailable() const;
70
71 std::unique_ptr<AbstractPushProvider> m_pushProvider;
72 std::vector<Client> m_clients;
73 Command m_currentCommand;
74 std::deque<Command> m_commandQueue;
75 DistributorStatus::Status m_status = DistributorStatus::Unknown;
76};
77
78}
79
80#endif // KUNIFIEDPUSH_DISTRIBUTOR_H
Information about a registered client.
Definition client.h:19
Distributor command queue entries.
Definition command.h:17
UnifiedPush distributor service.
Definition distributor.h:29
A received push notification message.
Definition message.h:15
Client-side integration with UnifiedPush.
Definition connector.h:16
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 12:02:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.