QXmppOutgoingClient.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 2008-2012 The QXmpp developers
  3. *
  4. * Authors:
  5. * Manjeet Dahiya
  6. * Jeremy Lainé
  7. *
  8. * Source:
  9. * http://code.google.com/p/qxmpp
  10. *
  11. * This file is a part of QXmpp library.
  12. *
  13. * This library is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU Lesser General Public
  15. * License as published by the Free Software Foundation; either
  16. * version 2.1 of the License, or (at your option) any later version.
  17. *
  18. * This library is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * Lesser General Public License for more details.
  22. *
  23. */
  24. #ifndef QXMPPOUTGOINGCLIENT_H
  25. #define QXMPPOUTGOINGCLIENT_H
  26. #include "QXmppClient.h"
  27. #include "QXmppStanza.h"
  28. #include "QXmppStream.h"
  29. class QDomElement;
  30. class QSslError;
  31. class QXmppConfiguration;
  32. class QXmppPresence;
  33. class QXmppIq;
  34. class QXmppMessage;
  35. class QXmppOutgoingClientPrivate;
  36. /// \brief The QXmppOutgoingClient class represents an outgoing XMPP stream
  37. /// to an XMPP server.
  38. ///
  39. class QXMPP_EXPORT QXmppOutgoingClient : public QXmppStream
  40. {
  41. Q_OBJECT
  42. public:
  43. QXmppOutgoingClient(QObject *parent);
  44. ~QXmppOutgoingClient();
  45. void connectToHost();
  46. bool isAuthenticated() const;
  47. bool isConnected() const;
  48. QSslSocket *socket() const { return QXmppStream::socket(); };
  49. QXmppStanza::Error::Condition xmppStreamError();
  50. QXmppConfiguration& configuration();
  51. signals:
  52. /// This signal is emitted when an error is encountered.
  53. void error(QXmppClient::Error);
  54. /// This signal is emitted when an element is received.
  55. void elementReceived(const QDomElement &element, bool &handled);
  56. /// This signal is emitted when a presence is received.
  57. void presenceReceived(const QXmppPresence&);
  58. /// This signal is emitted when a message is received.
  59. void messageReceived(const QXmppMessage&);
  60. /// This signal is emitted when an IQ is received.
  61. void iqReceived(const QXmppIq&);
  62. protected:
  63. /// \cond
  64. // Overridable methods
  65. virtual void handleStart();
  66. virtual void handleStanza(const QDomElement &element);
  67. virtual void handleStream(const QDomElement &element);
  68. /// \endcond
  69. private slots:
  70. void _q_dnsLookupFinished();
  71. void _q_socketDisconnected();
  72. void socketError(QAbstractSocket::SocketError);
  73. void socketSslErrors(const QList<QSslError>&);
  74. void pingStart();
  75. void pingStop();
  76. void pingSend();
  77. void pingTimeout();
  78. private:
  79. void sendNonSASLAuth(bool plaintext);
  80. void sendNonSASLAuthQuery();
  81. friend class QXmppOutgoingClientPrivate;
  82. QXmppOutgoingClientPrivate * const d;
  83. };
  84. #endif // QXMPPOUTGOINGCLIENT_H