QXmpp  Version: 1.6.0
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 
13 class QDomElement;
14 class QSslCertificate;
15 class QSslKey;
16 class QSslSocket;
17 
18 class QXmppDialback;
22 class QXmppPresence;
24 class QXmppServerPrivate;
25 class QXmppSslServer;
26 class QXmppStanza;
27 class QXmppStream;
28 
39 
40 class QXMPP_EXPORT QXmppServer : public QXmppLoggable
41 {
42  Q_OBJECT
44  Q_PROPERTY(QXmppLogger *logger READ logger WRITE setLogger NOTIFY loggerChanged)
45 
46 public:
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/
59  void setLogger(QXmppLogger *logger);
60 
61  QXmppPasswordChecker *passwordChecker();
62  void setPasswordChecker(QXmppPasswordChecker *checker);
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 
79  void addIncomingClient(QXmppIncomingClient *stream);
80 
81 Q_SIGNALS:
83  void clientConnected(const QString &jid);
84 
86  void clientDisconnected(const QString &jid);
87 
89  void loggerChanged(QXmppLogger *logger);
90 
91 public Q_SLOTS:
92  void handleElement(const QDomElement &element);
93 
94 private Q_SLOTS:
95  void _q_clientConnection(QSslSocket *socket);
96  void _q_clientConnected();
97  void _q_clientDisconnected();
98  void _q_dialbackRequestReceived(const QXmppDialback &dialback);
99  void _q_outgoingServerDisconnected();
100  void _q_serverConnection(QSslSocket *socket);
101  void _q_serverDisconnected();
102 
103 private:
104  friend class QXmppServerPrivate;
105  QXmppServerPrivate *d;
106 };
107 
108 class QXmppSslServerPrivate;
109 
112 
113 class QXMPP_EXPORT QXmppSslServer : public QTcpServer
114 {
115  Q_OBJECT
116 
117 public:
118  QXmppSslServer(QObject *parent = nullptr);
119  ~QXmppSslServer() override;
120 
121  void addCaCertificates(const QList<QSslCertificate> &certificates);
122  void setLocalCertificate(const QSslCertificate &certificate);
123  void setPrivateKey(const QSslKey &key);
124 
125 Q_SIGNALS:
127  void newConnection(QSslSocket *socket);
128 
129 private:
130  void incomingConnection(qintptr socketDescriptor) override;
131  QXmppSslServerPrivate *const d;
132 };
133 
134 #endif
The QXmppDialback class represents a stanza used for the Server Dialback protocol as specified by XEP...
Definition: QXmppDialback.h:16
Interface for password checkers.
Definition: QXmppIncomingClient.h:21
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:105
The QXmppLogger class represents a sink for logging messages.
Definition: QXmppLogger.h:27
The QXmppOutgoingServer class represents an outgoing XMPP stream to another XMPP server.
Definition: QXmppOutgoingServer.h:22
The QXmppPasswordChecker class represents an abstract password checker.
Definition: QXmppPasswordChecker.h:83
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:21
The QXmppServerExtension class is the base class for QXmppServer extensions.
Definition: QXmppServerExtension.h:29
The QXmppServer class represents an XMPP server.
Definition: QXmppServer.h:41
void clientDisconnected(const QString &jid)
This signal is emitted when a client has disconnected.
void clientConnected(const QString &jid)
This signal is emitted when a client has connected.
QXmppLogger * logger()
Returns the QXmppLogger associated with the server.
void loggerChanged(QXmppLogger *logger)
This signal is emitted when the logger changes.
The QXmppSslServer class represents an SSL-enabled TCP server.
Definition: QXmppServer.h:114
void newConnection(QSslSocket *socket)
This signal is emitted when a new connection is established.
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:88
The QXmppStream class is the base class for all XMPP streams.
Definition: QXmppStream.h:36