QXmpp  Version:0.4.91
 All Classes Functions Enumerations Enumerator Properties Groups
QXmppSocks.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 QXMPPSOCKS_H
25 #define QXMPPSOCKS_H
26 
27 #include <QHostAddress>
28 #include <QTcpSocket>
29 
30 #include "QXmppGlobal.h"
31 
32 class QTcpServer;
33 
34 class QXMPP_EXPORT QXmppSocksClient : public QTcpSocket
35 {
36  Q_OBJECT
37 
38 public:
39  QXmppSocksClient(const QHostAddress &proxyAddress, quint16 proxyPort, QObject *parent=0);
40  void connectToHost(const QString &hostName, quint16 hostPort);
41  bool waitForReady(int msecs = 30000);
42 
43 signals:
44  void ready();
45 
46 private slots:
47  void slotConnected();
48  void slotReadyRead();
49 
50 private:
51  QHostAddress m_proxyAddress;
52  quint16 m_proxyPort;
53  QString m_hostName;
54  quint16 m_hostPort;
55  int m_step;
56 };
57 
58 class QXMPP_EXPORT QXmppSocksServer : public QObject
59 {
60  Q_OBJECT
61 
62 public:
63  QXmppSocksServer(QObject *parent=0);
64  void close();
65  bool isListening() const;
66  bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
67 
68  QHostAddress serverAddress() const;
69  quint16 serverPort() const;
70 
71 signals:
72  void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
73 
74 private slots:
75  void slotNewConnection();
76  void slotReadyRead();
77 
78 private:
79  QTcpServer *m_server;
80  QMap<QTcpSocket*, int> m_states;
81 };
82 
83 #endif