PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/QXmppSocks.h

http://qxmpp.googlecode.com/
C Header | 81 lines | 44 code | 15 blank | 22 comment | 0 complexity | b8b22c966e9f5c36491e2a0b03afea05 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 QXMPPSOCKS_H
  24. #define QXMPPSOCKS_H
  25. #include <QHostAddress>
  26. #include <QTcpSocket>
  27. class QTcpServer;
  28. class QXmppSocksClient : public QTcpSocket
  29. {
  30. Q_OBJECT
  31. public:
  32. QXmppSocksClient(const QHostAddress &proxyAddress, quint16 proxyPort, QObject *parent=0);
  33. void connectToHost(const QString &hostName, quint16 hostPort);
  34. bool waitForReady(int msecs = 30000);
  35. signals:
  36. void ready();
  37. private slots:
  38. void slotConnected();
  39. void slotReadyRead();
  40. private:
  41. QHostAddress m_proxyAddress;
  42. quint16 m_proxyPort;
  43. QString m_hostName;
  44. quint16 m_hostPort;
  45. int m_step;
  46. };
  47. class QXmppSocksServer : public QObject
  48. {
  49. Q_OBJECT
  50. public:
  51. QXmppSocksServer(QObject *parent=0);
  52. void close();
  53. bool isListening() const;
  54. bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
  55. QHostAddress serverAddress() const;
  56. quint16 serverPort() const;
  57. signals:
  58. void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
  59. private slots:
  60. void slotNewConnection();
  61. void slotReadyRead();
  62. private:
  63. QTcpServer *m_server;
  64. QMap<QTcpSocket*, int> m_states;
  65. };
  66. #endif