QXmpp  Version:1.3.1
QXmppServer.h
1 /*
2  * Copyright (C) 2008-2020 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * https://github.com/qxmpp-project/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPSERVER_H
25 #define QXMPPSERVER_H
26 
27 #include "QXmppLogger.h"
28 
29 #include <QTcpServer>
30 #include <QVariantMap>
31 
32 class QDomElement;
33 class QSslCertificate;
34 class QSslKey;
35 class QSslSocket;
36 
37 class QXmppDialback;
41 class QXmppPresence;
43 class QXmppServerPrivate;
44 class QXmppSslServer;
45 class QXmppStanza;
46 class QXmppStream;
47 
58 
59 class QXMPP_EXPORT QXmppServer : public QXmppLoggable
60 {
61  Q_OBJECT
63  Q_PROPERTY(QXmppLogger *logger READ logger WRITE setLogger NOTIFY loggerChanged)
64 
65 public:
66  QXmppServer(QObject *parent = nullptr);
67  ~QXmppServer() override;
68 
69  void addExtension(QXmppServerExtension *extension);
70  QList<QXmppServerExtension *> extensions();
71 
72  QString domain() const;
73  void setDomain(const QString &domain);
74 
75  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
77  QXmppLogger *logger();
78  void setLogger(QXmppLogger *logger);
79 
80  QXmppPasswordChecker *passwordChecker();
81  void setPasswordChecker(QXmppPasswordChecker *checker);
82 
83  QVariantMap statistics() const;
84 
85  void addCaCertificates(const QString &caCertificates);
86  void setLocalCertificate(const QString &path);
87  void setLocalCertificate(const QSslCertificate &certificate);
88  void setPrivateKey(const QString &path);
89  void setPrivateKey(const QSslKey &key);
90 
91  void close();
92  bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
93  bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
94 
95  bool sendElement(const QDomElement &element);
96  bool sendPacket(const QXmppStanza &stanza);
97 
98  void addIncomingClient(QXmppIncomingClient *stream);
99 
100 Q_SIGNALS:
102  void clientConnected(const QString &jid);
103 
105  void clientDisconnected(const QString &jid);
106 
108  void loggerChanged(QXmppLogger *logger);
109 
110 public Q_SLOTS:
111  void handleElement(const QDomElement &element);
112 
113 private Q_SLOTS:
114  void _q_clientConnection(QSslSocket *socket);
115  void _q_clientConnected();
116  void _q_clientDisconnected();
117  void _q_dialbackRequestReceived(const QXmppDialback &dialback);
118  void _q_outgoingServerDisconnected();
119  void _q_serverConnection(QSslSocket *socket);
120  void _q_serverDisconnected();
121 
122 private:
123  friend class QXmppServerPrivate;
124  QXmppServerPrivate *d;
125 };
126 
127 class QXmppSslServerPrivate;
128 
131 
132 class QXMPP_EXPORT QXmppSslServer : public QTcpServer
133 {
134  Q_OBJECT
135 
136 public:
137  QXmppSslServer(QObject *parent = nullptr);
138  ~QXmppSslServer() override;
139 
140  void addCaCertificates(const QList<QSslCertificate> &certificates);
141  void setLocalCertificate(const QSslCertificate &certificate);
142  void setPrivateKey(const QSslKey &key);
143 
144 Q_SIGNALS:
146  void newConnection(QSslSocket *socket);
147 
148 private:
149  void incomingConnection(qintptr socketDescriptor) override;
150  QXmppSslServerPrivate *const d;
151 };
152 
153 #endif
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:35
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:99
QXmppOutgoingServer
The QXmppOutgoingServer class represents an outgoing XMPP stream to another XMPP server.
Definition: QXmppOutgoingServer.h:40
QXmppDialback
The QXmppDialback class represents a stanza used for the Server Dialback protocol as specified by XEP...
Definition: QXmppDialback.h:34
QXmppSslServer
The QXmppSslServer class represents an SSL-enabled TCP server.
Definition: QXmppServer.h:132
QXmppLogger
The QXmppLogger class represents a sink for logging messages.
Definition: QXmppLogger.h:45
QXmppPasswordChecker
The QXmppPasswordChecker class represents an abstract password checker.
Definition: QXmppPasswordChecker.h:101
QXmppStream
The QXmppStream class is the base class for all XMPP streams.
Definition: QXmppStream.h:41
QXmppServer
The QXmppServer class represents an XMPP server.
Definition: QXmppServer.h:59
QXmppLoggable
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:123
QXmppIncomingClient
Interface for password checkers.
Definition: QXmppIncomingClient.h:39
QXmppServerExtension
The QXmppServerExtension class is the base class for QXmppServer extensions.
Definition: QXmppServerExtension.h:48