PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/QXmppServer.h

http://qxmpp.googlecode.com/
C Header | 148 lines | 77 code | 30 blank | 41 comment | 0 complexity | a0beed00eb2b3f802ed2a799ba59983d MD5 | raw file
Possible License(s): LGPL-2.1
  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. #ifndef QXMPPSERVER_H
  24. #define QXMPPSERVER_H
  25. #include <QTcpServer>
  26. #include <QVariantMap>
  27. #include "QXmppLogger.h"
  28. class QDomElement;
  29. class QSslCertificate;
  30. class QSslKey;
  31. class QSslSocket;
  32. class QXmppDialback;
  33. class QXmppIncomingClient;
  34. class QXmppOutgoingServer;
  35. class QXmppPasswordChecker;
  36. class QXmppPresence;
  37. class QXmppServerExtension;
  38. class QXmppServerPrivate;
  39. class QXmppSslServer;
  40. class QXmppStanza;
  41. class QXmppStream;
  42. /// \brief The QXmppServer class represents an XMPP server.
  43. ///
  44. /// It provides support for both client-to-server and server-to-server
  45. /// communications, SSL encryption and logging facilities.
  46. ///
  47. /// QXmppServer comes with a number of modules for service discovery,
  48. /// XMPP ping, statistics and file transfer proxy support. You can write
  49. /// your own extensions for QXmppServer by subclassing QXmppServerExtension.
  50. ///
  51. /// \ingroup Core
  52. class QXmppServer : public QXmppLoggable
  53. {
  54. Q_OBJECT
  55. public:
  56. QXmppServer(QObject *parent = 0);
  57. ~QXmppServer();
  58. void addExtension(QXmppServerExtension *extension);
  59. QList<QXmppServerExtension*> extensions();
  60. QString domain() const;
  61. void setDomain(const QString &domain);
  62. QXmppLogger *logger();
  63. void setLogger(QXmppLogger *logger);
  64. QXmppPasswordChecker *passwordChecker();
  65. void setPasswordChecker(QXmppPasswordChecker *checker);
  66. QVariantMap statistics() const;
  67. void addCaCertificates(const QString &caCertificates);
  68. void setLocalCertificate(const QString &path);
  69. void setPrivateKey(const QString &path);
  70. void close();
  71. bool listenForClients(const QHostAddress &address = QHostAddress::Any, quint16 port = 5222);
  72. bool listenForServers(const QHostAddress &address = QHostAddress::Any, quint16 port = 5269);
  73. bool sendElement(const QDomElement &element);
  74. bool sendPacket(const QXmppStanza &stanza);
  75. /// \cond
  76. // FIXME: this method should not be public, but it is needed to
  77. // implement BOSH support as an extension.
  78. void addIncomingClient(QXmppIncomingClient *stream);
  79. /// \endcond
  80. signals:
  81. /// This signal is emitted when a client has connected.
  82. void clientConnected(const QString &jid);
  83. /// This signal is emitted when a client has disconnected.
  84. void clientDisconnected(const QString &jid);
  85. public slots:
  86. void handleElement(const QDomElement &element);
  87. private slots:
  88. void _q_clientConnection(QSslSocket *socket);
  89. void _q_clientConnected();
  90. void _q_clientDisconnected();
  91. void _q_dialbackRequestReceived(const QXmppDialback &dialback);
  92. void _q_outgoingServerDisconnected();
  93. void _q_serverConnection(QSslSocket *socket);
  94. void _q_serverDisconnected();
  95. private:
  96. friend class QXmppServerPrivate;
  97. QXmppServerPrivate *d;
  98. };
  99. class QXmppSslServerPrivate;
  100. /// \brief The QXmppSslServer class represents an SSL-enabled TCP server.
  101. ///
  102. class QXmppSslServer : public QTcpServer
  103. {
  104. Q_OBJECT
  105. public:
  106. QXmppSslServer(QObject *parent = 0);
  107. ~QXmppSslServer();
  108. void addCaCertificates(const QList<QSslCertificate> &certificates);
  109. void setLocalCertificate(const QSslCertificate &certificate);
  110. void setPrivateKey(const QSslKey &key);
  111. signals:
  112. /// This signal is emitted when a new connection is established.
  113. void newConnection(QSslSocket *socket);
  114. private:
  115. void incomingConnection(int socketDescriptor);
  116. QXmppSslServerPrivate * const d;
  117. };
  118. #endif