KUnifiedPush

abstractpushprovider.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_ABSTRACTPUSHPROVIDER_H
7#define KUNIFIEDPUSH_ABSTRACTPUSHPROVIDER_H
8
9#include <QObject>
10
12class QSettings;
13
14namespace KUnifiedPush {
15
16class Client;
17class Message;
18
19/** Base class for push provider protocol implementations.
20 * Needed to support different push providers as that part of the
21 * protocol is not part of the UnifiedPush spec.
22 */
24{
26public:
28
29 enum Error {
30 NoError, ///< operation succeeded
31 ProviderRejected, ///< communication worked, but the provider refused to complete the operation
32 TransientNetworkError, ///< temporary network error, try again
33 };
35
36 /** Load connection settings.
37 * @param settings can be read on the top level, the correct group is already selected.
38 * @returns @c true if the settings are valid, @c false otherwise.
39 */
40 virtual bool loadSettings(const QSettings &settings) = 0;
41
42 /** Attempt to establish a connection to the push provider. */
43 virtual void connectToProvider() = 0;
44
45 /** Disconnect and existing connection to the push provider. */
46 virtual void disconnectFromProvider() = 0;
47
48 /** Register a new client with the provider. */
49 virtual void registerClient(const Client &client) = 0;
50
51 /** Unregister a client from the provider. */
52 virtual void unregisterClient(const Client &client) = 0;
53
54 /** Provider id used e.g. in settings. */
55 const char* providerId() const;
56
58 /** Inform about a received push notification. */
60
61 /** Emitted after successful client registration. */
62 void clientRegistered(const KUnifiedPush::Client &client, KUnifiedPush::AbstractPushProvider::Error error = NoError, const QString &errorMsg = {});
63
64 /** Emitted after successful client unregistration. */
66
67 /** Emitted after the connection to the push provider has been established successfully. */
68 void connected();
69
70 /** Emitted after the connection to the push provider disconnected or failed to be established. */
72
73protected:
74 explicit AbstractPushProvider(const char *providerId, QObject *parent);
76
77private:
78 const char *m_providerId = nullptr;
79 QNetworkAccessManager *m_nam = nullptr;
80};
81
82}
83
84#endif // KUNIFIEDPUSH_ABSTRACTPUSHPROVIDER_H
Base class for push provider protocol implementations.
virtual bool loadSettings(const QSettings &settings)=0
Load connection settings.
virtual void connectToProvider()=0
Attempt to establish a connection to the push provider.
void messageReceived(const KUnifiedPush::Message &msg)
Inform about a received push notification.
void connected()
Emitted after the connection to the push provider has been established successfully.
const char * providerId() const
Provider id used e.g.
void clientUnregistered(const KUnifiedPush::Client &client, KUnifiedPush::AbstractPushProvider::Error error=NoError)
Emitted after successful client unregistration.
void disconnected(KUnifiedPush::AbstractPushProvider::Error error, const QString &errorMsg={})
Emitted after the connection to the push provider disconnected or failed to be established.
virtual void disconnectFromProvider()=0
Disconnect and existing connection to the push provider.
virtual void unregisterClient(const Client &client)=0
Unregister a client from the provider.
virtual void registerClient(const Client &client)=0
Register a new client with the provider.
void clientRegistered(const KUnifiedPush::Client &client, KUnifiedPush::AbstractPushProvider::Error error=NoError, const QString &errorMsg={})
Emitted after successful client registration.
@ ProviderRejected
communication worked, but the provider refused to complete the operation
@ TransientNetworkError
temporary network error, try again
Information about a registered client.
Definition client.h:19
A received push notification message.
Definition message.h:15
Client-side integration with UnifiedPush.
Definition connector.h:16
Q_ENUM(...)
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 Tue Mar 26 2024 11:21:15 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.