KUnifiedPush

connector.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_CONNECTOR_H
7#define KUNIFIEDPUSH_CONNECTOR_H
8
9#include "kunifiedpush_export.h"
10
11#include <QObject>
12
13#include <memory>
14
15/** Client-side integration with UnifiedPush. */
16namespace KUnifiedPush {
17
18class ConnectorPrivate;
19
20/** Client connector to UnifiedPush.
21 * Registers with a local UnifedPush distributor if present
22 * and obtains an endpoint that can be used for push notifications.
23 */
24class KUNIFIEDPUSH_EXPORT Connector : public QObject
25{
26 Q_OBJECT
27 Q_PROPERTY(QString endpoint READ endpoint NOTIFY endpointChanged)
28 Q_PROPERTY(State state READ state NOTIFY stateChanged)
29public:
30 /** Create a new connector instance.
31 * @param serviceName The application identifier, same as used for registration
32 * on D-Bus and for D-Bus activation.
33 */
34 explicit Connector(const QString &serviceName, QObject *parent = nullptr);
35 ~Connector();
36
37 /** HTTP endpoint to trigger the push notification.
38 * This needs to be communicated to the corresponding server-side application.
39 * @see endpointChanged
40 */
41 QString endpoint() const;
42
43 /** Register this client.
44 * This is for subscribing to push notifications and is only needed the first
45 * time an application uses this, or after explicitly unregistering. The registration
46 * is persisted until explicitly changed.
47 * @param description A human-readable explanation what push notifications are used
48 * for by this application.
49 */
50 void registerClient(const QString &description);
51
52 /** Unregister this client.
53 * This is for permanently unsubscribing, do not use on regular application shutdown.
54 */
55 void unregisterClient();
56
57 /** Connector state. */
58 enum State {
59 Unregistered, ///< Connector is not yet registered, or explicitly unregistered.
60 Registering, ///< Connector is registering with the push provider.
61 Registered, ///< Connector is registered and thus operational.
62 NoDistributor, ///< Connector cannot find a UnifiedPush distributor to register at.
63 Error, ///< Any other error condition.
64 };
65 Q_ENUM(State)
66 /** State of the connector. */
67 State state() const;
68 // TODO error message
69
70Q_SIGNALS:
71 /** Emitted for each newly received push message. */
72 void messageReceived(const QByteArray &msg);
73
74 /** Emitted when a new endpoint URL has been received. */
75 void endpointChanged(const QString &endpoint);
76
77 /** Emitted when the connector state changes. */
79
80private:
81 ConnectorPrivate *const d;
82};
83
84}
85
86#endif
Client connector to UnifiedPush.
Definition connector.h:25
void endpointChanged(const QString &endpoint)
Emitted when a new endpoint URL has been received.
void messageReceived(const QByteArray &msg)
Emitted for each newly received push message.
State
Connector state.
Definition connector.h:58
@ Error
Any other error condition.
Definition connector.h:63
@ NoDistributor
Connector cannot find a UnifiedPush distributor to register at.
Definition connector.h:62
@ Registering
Connector is registering with the push provider.
Definition connector.h:60
@ Registered
Connector is registered and thus operational.
Definition connector.h:61
@ Unregistered
Connector is not yet registered, or explicitly unregistered.
Definition connector.h:59
void stateChanged(KUnifiedPush::Connector::State state)
Emitted when the connector state changes.
Client-side integration with UnifiedPush.
Definition connector.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Sep 27 2024 11:48:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.