QXmpp Version:0.3.91
QXmppServer.h
00001 /*
00002  * Copyright (C) 2008-2011 The QXmpp developers
00003  *
00004  * Author:
00005  *  Jeremy Lainé
00006  *
00007  * Source:
00008  *  http://code.google.com/p/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 QXmppServer : public QXmppLoggable
00060 {
00061     Q_OBJECT
00062 
00063 public:
00064     QXmppServer(QObject *parent = 0);
00065     ~QXmppServer();
00066 
00067     void addExtension(QXmppServerExtension *extension);
00068     QList<QXmppServerExtension*> extensions();
00069 
00070     QString domain() const;
00071     void setDomain(const QString &domain);
00072 
00073     QXmppLogger *logger();
00074     void setLogger(QXmppLogger *logger);
00075 
00076     QXmppPasswordChecker *passwordChecker();
00077     void setPasswordChecker(QXmppPasswordChecker *checker);
00078 
00079     QVariantMap statistics() const;
00080 
00081     void addCaCertificates(const QString &caCertificates);
00082     void setLocalCertificate(const QString &path);
00083     void setPrivateKey(const QString &path);
00084 
00085     void close();
00086     bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
00087     bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
00088 
00089     bool sendElement(const QDomElement &element);
00090     bool sendPacket(const QXmppStanza &stanza);
00091 
00093     // FIXME: this method should not be public, but it is needed to
00094     // implement BOSH support as an extension.
00095     void addIncomingClient(QXmppIncomingClient *stream);
00097 
00098 signals:
00100     void clientConnected(const QString &jid);
00101 
00103     void clientDisconnected(const QString &jid);
00104 
00105 public slots:
00106     void handleElement(const QDomElement &element);
00107 
00108 private slots:
00109     void _q_clientConnection(QSslSocket *socket);
00110     void _q_clientConnected();
00111     void _q_clientDisconnected();
00112     void _q_dialbackRequestReceived(const QXmppDialback &dialback);
00113     void _q_outgoingServerDisconnected();
00114     void _q_serverConnection(QSslSocket *socket);
00115     void _q_serverDisconnected();
00116 
00117 private:
00118     friend class QXmppServerPrivate;
00119     QXmppServerPrivate *d;
00120 };
00121 
00122 class QXmppSslServerPrivate;
00123 
00126 
00127 class QXmppSslServer : public QTcpServer
00128 {
00129     Q_OBJECT
00130 
00131 public:
00132     QXmppSslServer(QObject *parent = 0);
00133     ~QXmppSslServer();
00134 
00135     void addCaCertificates(const QList<QSslCertificate> &certificates);
00136     void setLocalCertificate(const QSslCertificate &certificate);
00137     void setPrivateKey(const QSslKey &key);
00138 
00139 signals:
00141     void newConnection(QSslSocket *socket);
00142 
00143 private:
00144     void incomingConnection(int socketDescriptor);
00145     QXmppSslServerPrivate * const d;
00146 };
00147 
00148 #endif
 All Classes Functions Enumerations Enumerator Properties