QXmpp Version: 1.15.0
Loading...
Searching...
No Matches
QXmppServer.h
1// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPSERVER_H
6#define QXMPPSERVER_H
7
8#include "QXmppLogger.h"
9
10#include <QTcpServer>
11#include <QVariantMap>
12
13class QDomElement;
14class QSslCertificate;
15class QSslKey;
16class QSslSocket;
17
18class QXmppDialback;
22class QXmppPresence;
24class QXmppServerPrivate;
25class QXmppSslServer;
26class QXmppStanza;
27
40class QXMPP_EXPORT QXmppServer : public QXmppLoggable
41{
42 Q_OBJECT
44 Q_PROPERTY(QXmppLogger *logger READ logger WRITE setLogger NOTIFY loggerChanged)
45
46public:
47 QXmppServer(QObject *parent = nullptr);
48 ~QXmppServer() override;
49
50 void addExtension(QXmppServerExtension *extension);
51 QList<QXmppServerExtension *> extensions();
52
53 QString domain() const;
54 void setDomain(const QString &domain);
55
56 // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
60
63
64 QVariantMap statistics() const;
65
66 void addCaCertificates(const QString &caCertificates);
67 void setLocalCertificate(const QString &path);
68 void setLocalCertificate(const QSslCertificate &certificate);
69 void setPrivateKey(const QString &path);
70 void setPrivateKey(const QSslKey &key);
71
72 void close();
73 bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
74 bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
75
76 bool sendElement(const QDomElement &element);
77 bool sendPacket(const QXmppStanza &stanza);
78
80
82 Q_SIGNAL void clientConnected(const QString &jid);
83
85 Q_SIGNAL void clientDisconnected(const QString &jid);
86
89
90 Q_SLOT void handleElement(const QDomElement &element);
91
92private:
93 Q_SLOT void _q_clientConnection(QSslSocket *socket);
94 Q_SLOT void _q_clientConnected();
95 Q_SLOT void _q_clientDisconnected();
96 Q_SLOT void _q_dialbackRequestReceived(const QXmppDialback &dialback);
97 Q_SLOT void _q_outgoingServerDisconnected();
98 Q_SLOT void _q_serverConnection(QSslSocket *socket);
99 Q_SLOT void _q_serverDisconnected();
100
101 const std::unique_ptr<QXmppServerPrivate> d;
102
103 friend class QXmppServerPrivate;
104};
105
106class QXmppSslServerPrivate;
107
110
111class QXMPP_EXPORT QXmppSslServer : public QTcpServer
112{
113 Q_OBJECT
114
115public:
116 QXmppSslServer(QObject *parent = nullptr);
117 ~QXmppSslServer() override;
118
119 void addCaCertificates(const QList<QSslCertificate> &certificates);
120 void setLocalCertificate(const QSslCertificate &certificate);
121 void setPrivateKey(const QSslKey &key);
122
124 Q_SIGNAL void newConnection(QSslSocket *socket);
125
126private:
127 void incomingConnection(qintptr socketDescriptor) override;
128 const std::unique_ptr<QXmppSslServerPrivate> d;
129};
130
131#endif
The QXmppDialback class represents a stanza used for the Server Dialback protocol as specified by XEP...
Definition QXmppDialback.h:16
The QXmppIncomingClient class represents an incoming XMPP stream from an XMPP client.
Definition QXmppIncomingClient.h:27
QXmppLoggable(QObject *parent=nullptr)
Definition QXmppLogger.cpp:57
The QXmppLogger class represents a sink for logging messages.
Definition QXmppLogger.h:29
The QXmppOutgoingServer class represents an outgoing XMPP stream to another XMPP server.
Definition QXmppOutgoingServer.h:29
The QXmppPasswordChecker class represents an abstract password checker.
Definition QXmppPasswordChecker.h:81
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:22
The QXmppServerExtension class is the base class for QXmppServer extensions.
Definition QXmppServerExtension.h:29
QXmppLogger * logger
The QXmppLogger associated with the server.
Definition QXmppServer.h:44
QXmppLogger * logger()
Returns the QXmppLogger associated with the server.
bool listenForClients(const QHostAddress &address=QHostAddress::Any, quint16 port=5222)
Listen for incoming XMPP client connections.
Definition QXmppServer.cpp:506
void setPrivateKey(const QString &path)
Sets the path for the local SSL private key.
Definition QXmppServer.cpp:462
Q_SIGNAL void clientDisconnected(const QString &jid)
This signal is emitted when a client has disconnected.
QList< QXmppServerExtension * > extensions()
Returns the list of loaded extensions.
Definition QXmppServer.cpp:322
void close()
Closes the server.
Definition QXmppServer.cpp:540
bool listenForServers(const QHostAddress &address=QHostAddress::Any, quint16 port=5269)
Listen for incoming XMPP server connections.
Definition QXmppServer.cpp:571
Q_SIGNAL void loggerChanged(QXmppLogger *logger)
This signal is emitted when the logger changes.
QXmppServer(QObject *parent=nullptr)
Constructs a new XMPP server instance.
Definition QXmppServer.cpp:288
bool sendPacket(const QXmppStanza &stanza)
Route an XMPP packet.
Definition QXmppServer.cpp:617
bool sendElement(const QDomElement &element)
Route an XMPP stanza.
Definition QXmppServer.cpp:605
void setLogger(QXmppLogger *logger)
Sets the QXmppLogger associated with the server.
Definition QXmppServer.cpp:346
void addCaCertificates(const QString &caCertificates)
Sets the path for additional SSL CA certificates.
Definition QXmppServer.cpp:396
void setDomain(const QString &domain)
Sets the server's domain.
Definition QXmppServer.cpp:335
Q_SLOT void handleElement(const QDomElement &element)
Handle an incoming XML element.
Definition QXmppServer.cpp:752
void setLocalCertificate(const QString &path)
Sets the path for the local SSL certificate.
Definition QXmppServer.cpp:418
QString domain() const
Returns the server's domain.
Definition QXmppServer.cpp:329
void addIncomingClient(QXmppIncomingClient *stream)
Definition QXmppServer.cpp:634
void setPasswordChecker(QXmppPasswordChecker *checker)
Sets the password checker used to verify client credentials.
Definition QXmppServer.cpp:379
Q_SIGNAL void clientConnected(const QString &jid)
This signal is emitted when a client has connected.
QXmppPasswordChecker * passwordChecker()
Returns the password checker used to verify client credentials.
Definition QXmppServer.cpp:373
void addExtension(QXmppServerExtension *extension)
Registers a new extension with the server.
Definition QXmppServer.cpp:301
QVariantMap statistics() const
Returns the statistics for the server.
Definition QXmppServer.cpp:385
The QXmppSslServer class represents an SSL-enabled TCP server.
Definition QXmppServer.h:112
void addCaCertificates(const QList< QSslCertificate > &certificates)
Definition QXmppServer.cpp:853
Q_SIGNAL void newConnection(QSslSocket *socket)
This signal is emitted when a new connection is established.
void setLocalCertificate(const QSslCertificate &certificate)
Sets the local certificate to be used for incoming connections.
Definition QXmppServer.cpp:859
void setPrivateKey(const QSslKey &key)
Sets the local private key to be used for incoming connections.
Definition QXmppServer.cpp:865
QXmppSslServer(QObject *parent=nullptr)
Constructs a new SSL server instance.
Definition QXmppServer.cpp:821
The QXmppStanza class is the base class for all XMPP stanzas.
Definition QXmppStanza.h:106