QXmpp Version:0.3.0
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 
00029 #include "QXmppLogger.h"
00030 
00031 class QDomElement;
00032 class QSslCertificate;
00033 class QSslKey;
00034 class QSslSocket;
00035 
00036 class QXmppDialback;
00037 class QXmppIncomingClient;
00038 class QXmppOutgoingServer;
00039 class QXmppPasswordChecker;
00040 class QXmppPresence;
00041 class QXmppServerExtension;
00042 class QXmppServerPrivate;
00043 class QXmppSslServer;
00044 class QXmppStanza;
00045 class QXmppStream;
00046 
00057 
00058 class QXmppServer : public QXmppLoggable
00059 {
00060     Q_OBJECT
00061 
00062 public:
00063     QXmppServer(QObject *parent = 0);
00064     ~QXmppServer();
00065 
00066     void addExtension(QXmppServerExtension *extension);
00067     QList<QXmppServerExtension*> extensions();
00068 
00069     QString domain() const;
00070     void setDomain(const QString &domain);
00071 
00072     QXmppLogger *logger();
00073     void setLogger(QXmppLogger *logger);
00074 
00075     QXmppPasswordChecker *passwordChecker();
00076     void setPasswordChecker(QXmppPasswordChecker *checker);
00077 
00078     void addCaCertificates(const QString &caCertificates);
00079     void setLocalCertificate(const QString &path);
00080     void setPrivateKey(const QString &path);
00081 
00082     void close();
00083     bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
00084     bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
00085 
00086     bool sendElement(const QDomElement &element);
00087     bool sendPacket(const QXmppStanza &stanza);
00088 
00089     void addIncomingClient(QXmppIncomingClient *stream);
00090     QList<QXmppPresence> availablePresences(const QString &bareJid);
00091 
00092 signals:
00094     void streamAdded(QXmppStream *stream);
00095 
00097     void streamConnected(QXmppStream *stream);
00098 
00100     void streamRemoved(QXmppStream *stream);
00101 
00102 private slots:
00103     void slotClientConnection(QSslSocket *socket);
00104     void slotDialbackRequestReceived(const QXmppDialback &dialback);
00105     void slotElementReceived(const QDomElement &element);
00106     void slotServerConnection(QSslSocket *socket);
00107     void slotStreamConnected();
00108     void slotStreamDisconnected();
00109 
00110 private:
00111     friend class QXmppServerPrivate;
00112     QXmppServerPrivate *d;
00113 };
00114 
00115 class QXmppSslServerPrivate;
00116 
00119 
00120 class QXmppSslServer : public QTcpServer
00121 {
00122     Q_OBJECT
00123 
00124 public:
00125     QXmppSslServer(QObject *parent = 0);
00126     ~QXmppSslServer();
00127 
00128     void addCaCertificates(const QList<QSslCertificate> &certificates);
00129     void setLocalCertificate(const QSslCertificate &certificate);
00130     void setPrivateKey(const QSslKey &key);
00131 
00132 signals:
00134     void newConnection(QSslSocket *socket);
00135 
00136 private:
00137     void incomingConnection(int socketDescriptor);
00138     QXmppSslServerPrivate * const d;
00139 };
00140 
00141 #endif
 All Classes Functions Enumerations Enumerator Properties