QXmpp  Version: 1.7.1
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 
41 class QXMPP_EXPORT QXmppServer : public QXmppLoggable
42 {
43  Q_OBJECT
45  Q_PROPERTY(QXmppLogger *logger READ logger WRITE setLogger NOTIFY loggerChanged)
46 
47 public:
48  QXmppServer(QObject *parent = nullptr);
49  ~QXmppServer() override;
50 
51  void addExtension(QXmppServerExtension *extension);
52  QList<QXmppServerExtension *> extensions();
53 
54  QString domain() const;
55  void setDomain(const QString &domain);
56 
57  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
60  void setLogger(QXmppLogger *logger);
61 
62  QXmppPasswordChecker *passwordChecker();
63  void setPasswordChecker(QXmppPasswordChecker *checker);
64 
65  QVariantMap statistics() const;
66 
67  void addCaCertificates(const QString &caCertificates);
68  void setLocalCertificate(const QString &path);
69  void setLocalCertificate(const QSslCertificate &certificate);
70  void setPrivateKey(const QString &path);
71  void setPrivateKey(const QSslKey &key);
72 
73  void close();
74  bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
75  bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
76 
77  bool sendElement(const QDomElement &element);
78  bool sendPacket(const QXmppStanza &stanza);
79 
80  void addIncomingClient(QXmppIncomingClient *stream);
81 
82 Q_SIGNALS:
84  void clientConnected(const QString &jid);
85 
87  void clientDisconnected(const QString &jid);
88 
90  void loggerChanged(QXmppLogger *logger);
91 
92 public Q_SLOTS:
93  void handleElement(const QDomElement &element);
94 
95 private Q_SLOTS:
96  void _q_clientConnection(QSslSocket *socket);
97  void _q_clientConnected();
98  void _q_clientDisconnected();
99  void _q_dialbackRequestReceived(const QXmppDialback &dialback);
100  void _q_outgoingServerDisconnected();
101  void _q_serverConnection(QSslSocket *socket);
102  void _q_serverDisconnected();
103 
104 private:
105  friend class QXmppServerPrivate;
106  const std::unique_ptr<QXmppServerPrivate> d;
107 };
108 
109 class QXmppSslServerPrivate;
110 
113 
114 class QXMPP_EXPORT QXmppSslServer : public QTcpServer
115 {
116  Q_OBJECT
117 
118 public:
119  QXmppSslServer(QObject *parent = nullptr);
120  ~QXmppSslServer() override;
121 
122  void addCaCertificates(const QList<QSslCertificate> &certificates);
123  void setLocalCertificate(const QSslCertificate &certificate);
124  void setPrivateKey(const QSslKey &key);
125 
126 Q_SIGNALS:
128  void newConnection(QSslSocket *socket);
129 
130 private:
131  void incomingConnection(qintptr socketDescriptor) override;
132  const std::unique_ptr<QXmppSslServerPrivate> d;
133 };
134 
135 #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:110
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: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:42
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:115
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:27