QXmpp
Version:0.9.3
|
00001 /* 00002 * Copyright (C) 2008-2014 The QXmpp developers 00003 * 00004 * Author: 00005 * Jeremy Lainé 00006 * 00007 * Source: 00008 * https://github.com/qxmpp-project/qxmpp 00009 * 00010 * This file is a part of QXmpp library. 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2.1 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 */ 00023 00024 #ifndef QXMPPSERVER_H 00025 #define QXMPPSERVER_H 00026 00027 #include <QTcpServer> 00028 #include <QVariantMap> 00029 00030 #include "QXmppLogger.h" 00031 00032 class QDomElement; 00033 class QSslCertificate; 00034 class QSslKey; 00035 class QSslSocket; 00036 00037 class QXmppDialback; 00038 class QXmppIncomingClient; 00039 class QXmppOutgoingServer; 00040 class QXmppPasswordChecker; 00041 class QXmppPresence; 00042 class QXmppServerExtension; 00043 class QXmppServerPrivate; 00044 class QXmppSslServer; 00045 class QXmppStanza; 00046 class QXmppStream; 00047 00058 00059 class QXMPP_EXPORT QXmppServer : public QXmppLoggable 00060 { 00061 Q_OBJECT 00062 Q_PROPERTY(QXmppLogger* logger READ logger WRITE setLogger NOTIFY loggerChanged) 00063 00064 public: 00065 QXmppServer(QObject *parent = 0); 00066 ~QXmppServer(); 00067 00068 void addExtension(QXmppServerExtension *extension); 00069 QList<QXmppServerExtension*> extensions(); 00070 00071 QString domain() const; 00072 void setDomain(const QString &domain); 00073 00074 QXmppLogger *logger(); 00075 void setLogger(QXmppLogger *logger); 00076 00077 QXmppPasswordChecker *passwordChecker(); 00078 void setPasswordChecker(QXmppPasswordChecker *checker); 00079 00080 QVariantMap statistics() const; 00081 00082 void addCaCertificates(const QString &caCertificates); 00083 void setLocalCertificate(const QString &path); 00084 void setLocalCertificate(const QSslCertificate &certificate); 00085 void setPrivateKey(const QString &path); 00086 void setPrivateKey(const QSslKey &key); 00087 00088 void close(); 00089 bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222); 00090 bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269); 00091 00092 bool sendElement(const QDomElement &element); 00093 bool sendPacket(const QXmppStanza &stanza); 00094 00095 void addIncomingClient(QXmppIncomingClient *stream); 00096 00097 signals: 00099 void clientConnected(const QString &jid); 00100 00102 void clientDisconnected(const QString &jid); 00103 00105 void loggerChanged(QXmppLogger *logger); 00106 00107 public slots: 00108 void handleElement(const QDomElement &element); 00109 00110 private slots: 00111 void _q_clientConnection(QSslSocket *socket); 00112 void _q_clientConnected(); 00113 void _q_clientDisconnected(); 00114 void _q_dialbackRequestReceived(const QXmppDialback &dialback); 00115 void _q_outgoingServerDisconnected(); 00116 void _q_serverConnection(QSslSocket *socket); 00117 void _q_serverDisconnected(); 00118 00119 private: 00120 friend class QXmppServerPrivate; 00121 QXmppServerPrivate *d; 00122 }; 00123 00124 class QXmppSslServerPrivate; 00125 00128 00129 class QXMPP_EXPORT QXmppSslServer : public QTcpServer 00130 { 00131 Q_OBJECT 00132 00133 public: 00134 QXmppSslServer(QObject *parent = 0); 00135 ~QXmppSslServer(); 00136 00137 void addCaCertificates(const QList<QSslCertificate> &certificates); 00138 void setLocalCertificate(const QSslCertificate &certificate); 00139 void setPrivateKey(const QSslKey &key); 00140 00141 signals: 00143 void newConnection(QSslSocket *socket); 00144 00145 private: 00146 #if QT_VERSION < 0x050000 00147 void incomingConnection(int socketDescriptor); 00148 #else 00149 void incomingConnection(qintptr socketDescriptor); 00150 #endif 00151 QXmppSslServerPrivate * const d; 00152 }; 00153 00154 #endif