QXmpp  Version:0.9.3
QXmppSocks.h
00001 /*
00002  * Copyright (C) 2008-2014 The QXmpp developers
00003  *
00004  * Author:
00005  *  Jeremy Lainé
00006  *
00007  * Source:
00008  *  https://github.com/qxmpp-project/qxmpp
00009  *
00010  * This file is a part of QXmpp library.
00011  *
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Lesser General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2.1 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Lesser General Public License for more details.
00021  *
00022  */
00023 
00024 #ifndef QXMPPSOCKS_H
00025 #define QXMPPSOCKS_H
00026 
00027 #include <QHostAddress>
00028 #include <QTcpSocket>
00029 
00030 #include "QXmppGlobal.h"
00031 
00032 class QTcpServer;
00033 
00034 class QXMPP_EXPORT QXmppSocksClient : public QTcpSocket
00035 {
00036     Q_OBJECT
00037 
00038 public:
00039     QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent=0);
00040     void connectToHost(const QString &hostName, quint16 hostPort);
00041 
00042 signals:
00043     void ready();
00044 
00045 private slots:
00046     void slotConnected();
00047     void slotReadyRead();
00048 
00049 private:
00050     QString m_proxyHost;
00051     quint16 m_proxyPort;
00052     QString m_hostName;
00053     quint16 m_hostPort;
00054     int m_step;
00055 };
00056 
00057 class QXMPP_EXPORT QXmppSocksServer : public QObject
00058 {
00059     Q_OBJECT
00060 
00061 public:
00062     QXmppSocksServer(QObject *parent=0);
00063     void close();
00064     bool listen(quint16 port = 0);
00065 
00066     quint16 serverPort() const;
00067 
00068 signals:
00069     void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
00070 
00071 private slots:
00072     void slotNewConnection();
00073     void slotReadyRead();
00074 
00075 private:
00076     QTcpServer *m_server;
00077     QTcpServer *m_server_v6;
00078     QMap<QTcpSocket*, int> m_states;
00079 };
00080 
00081 #endif
 All Classes Functions Enumerations Enumerator Properties