QXmpp  Version:0.4.91
 All Classes Functions Enumerations Enumerator Properties Groups
QXmppServer.h
1 /*
2  * Copyright (C) 2008-2011 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * http://code.google.com/p/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 <QTcpServer>
28 #include <QVariantMap>
29 
30 #include "QXmppLogger.h"
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
62 
63 public:
64  QXmppServer(QObject *parent = 0);
65  ~QXmppServer();
66 
67  void addExtension(QXmppServerExtension *extension);
68  QList<QXmppServerExtension*> extensions();
69 
70  QString domain() const;
71  void setDomain(const QString &domain);
72 
73  QXmppLogger *logger();
74  void setLogger(QXmppLogger *logger);
75 
76  QXmppPasswordChecker *passwordChecker();
77  void setPasswordChecker(QXmppPasswordChecker *checker);
78 
79  QVariantMap statistics() const;
80 
81  void addCaCertificates(const QString &caCertificates);
82  void setLocalCertificate(const QString &path);
83  void setPrivateKey(const QString &path);
84 
85  void close();
86  bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
87  bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
88 
89  bool sendElement(const QDomElement &element);
90  bool sendPacket(const QXmppStanza &stanza);
91 
93  // FIXME: this method should not be public, but it is needed to
94  // implement BOSH support as an extension.
95  void addIncomingClient(QXmppIncomingClient *stream);
97 
98 signals:
100  void clientConnected(const QString &jid);
101 
103  void clientDisconnected(const QString &jid);
104 
105 public slots:
106  void handleElement(const QDomElement &element);
107 
108 private slots:
109  void _q_clientConnection(QSslSocket *socket);
110  void _q_clientConnected();
111  void _q_clientDisconnected();
112  void _q_dialbackRequestReceived(const QXmppDialback &dialback);
113  void _q_outgoingServerDisconnected();
114  void _q_serverConnection(QSslSocket *socket);
115  void _q_serverDisconnected();
116 
117 private:
118  friend class QXmppServerPrivate;
119  QXmppServerPrivate *d;
120 };
121 
122 class QXmppSslServerPrivate;
123 
126 
127 class QXMPP_EXPORT QXmppSslServer : public QTcpServer
128 {
129  Q_OBJECT
130 
131 public:
132  QXmppSslServer(QObject *parent = 0);
133  ~QXmppSslServer();
134 
135  void addCaCertificates(const QList<QSslCertificate> &certificates);
136  void setLocalCertificate(const QSslCertificate &certificate);
137  void setPrivateKey(const QSslKey &key);
138 
139 signals:
141  void newConnection(QSslSocket *socket);
142 
143 private:
144  void incomingConnection(int socketDescriptor);
145  QXmppSslServerPrivate * const d;
146 };
147 
148 #endif