QXmppSocks.h

    00001 /*
    00002  * Copyright (C) 2008-2011 The QXmpp developers
    00003  *
    00004  * Author:
    00005  *  Jeremy Lainé
    00006  *
    00007  * Source:
    00008  *  http://code.google.com/p/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 class QTcpServer;
    00031
    00032 class QXmppSocksClient : public QTcpSocket
    00033 {
    00034     Q_OBJECT
    00035
    00036 public:
    00037     QXmppSocksClient(const QHostAddress &proxyAddress, quint16 proxyPort, QObject *parent=0);
    00038     void connectToHost(const QString &hostName, quint16 hostPort);
    00039     bool waitForReady(int msecs = 30000);
    00040
    00041 signals:
    00042     void ready();
    00043
    00044 private slots:
    00045     void slotConnected();
    00046     void slotReadyRead();
    00047
    00048 private:
    00049     QHostAddress m_proxyAddress;
    00050     quint16 m_proxyPort;
    00051     QString m_hostName;
    00052     quint16 m_hostPort;
    00053     int m_step;
    00054 };
    00055
    00056 class QXmppSocksServer : public QObject
    00057 {
    00058     Q_OBJECT
    00059
    00060 public:
    00061     QXmppSocksServer(QObject *parent=0);
    00062     void close();
    00063     bool isListening() const;
    00064     bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
    00065
    00066     QHostAddress serverAddress() const;
    00067     quint16 serverPort() const;
    00068
    00069 signals:
    00070     void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
    00071
    00072 private slots:
    00073     void slotNewConnection();
    00074     void slotReadyRead();
    00075
    00076 private:
    00077     QTcpServer *m_server;
    00078     QMap<QTcpSocket*, int> m_states;
    00079 };
    00080
    00081 #endif

All Classes Functions Enumerations Enumerator Properties