QXmppSocks.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (C) 2008-2012 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 QXMPPSOCKS_H
  24. #define QXMPPSOCKS_H
  25. #include <QHostAddress>
  26. #include <QTcpSocket>
  27. #include "QXmppGlobal.h"
  28. class QTcpServer;
  29. class QXMPP_EXPORT QXmppSocksClient : public QTcpSocket
  30. {
  31. Q_OBJECT
  32. public:
  33. QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent=0);
  34. void connectToHost(const QString &hostName, quint16 hostPort);
  35. signals:
  36. void ready();
  37. private slots:
  38. void slotConnected();
  39. void slotReadyRead();
  40. private:
  41. QString m_proxyHost;
  42. quint16 m_proxyPort;
  43. QString m_hostName;
  44. quint16 m_hostPort;
  45. int m_step;
  46. };
  47. class QXMPP_EXPORT QXmppSocksServer : public QObject
  48. {
  49. Q_OBJECT
  50. public:
  51. QXmppSocksServer(QObject *parent=0);
  52. void close();
  53. bool listen(quint16 port = 0);
  54. quint16 serverPort() const;
  55. signals:
  56. void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
  57. private slots:
  58. void slotNewConnection();
  59. void slotReadyRead();
  60. private:
  61. QTcpServer *m_server;
  62. QTcpServer *m_server_v6;
  63. QMap<QTcpSocket*, int> m_states;
  64. };
  65. #endif