aboutsummaryrefslogtreecommitdiff
path: root/src/server/mod_proxy65.h
blob: cf54ad3b10d9ffce973af50a44582570f728e6bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * Copyright (C) 2008-2010 The QXmpp developers
 *
 * Author:
 *  Jeremy Lainé
 *
 * Source:
 *  http://code.google.com/p/qxmpp
 *
 * This file is a part of QXmpp library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 */

#ifndef QXMPP_SERVER_PROXY65_H
#define QXMPP_SERVER_PROXY65_H

#include <QStringList>
#include <QTime>

#include "QXmppServerExtension.h"

class QTcpSocket;

class QTcpSocketPair : public QObject
{
    Q_OBJECT

public:
    QTcpSocketPair(const QString &hash);

    void activate();
    void addSocket(QTcpSocket *socket);

    QString key;
    QTime time;
    qint64 transfer;

signals:
    void finished();

private slots:
    void disconnected();
    void sendData();

private:
    QTcpSocket *target;
    QTcpSocket *source;
};

class QXmppServerProxy65Private;

/// \brief QXmppServer extension for XEP-0065: SOCKS5 Bytestreams.
///

class QXmppServerProxy65 : public QXmppServerExtension
{
    Q_OBJECT
    Q_CLASSINFO("ExtensionName", "proxy65");
    Q_PROPERTY(QStringList allowedDomains READ allowedDomains WRITE setAllowedDomains);
    Q_PROPERTY(QString jid READ jid WRITE setJid);
    Q_PROPERTY(QString host READ host WRITE setHost);
    Q_PROPERTY(quint16 port READ port WRITE setPort);

public:
    QXmppServerProxy65();
    ~QXmppServerProxy65();

    QStringList allowedDomains() const;
    void setAllowedDomains(const QStringList &allowedDomains);

    QString jid() const;
    void setJid(const QString &jid);

    QString host() const;
    void setHost(const QString &host);

    quint16 port() const;
    void setPort(quint16 port);

    /// \cond
    QStringList discoveryItems() const;
    bool handleStanza(QXmppStream *stream, const QDomElement &element);
    bool start();
    void stop();
    QVariantMap statistics() const;
    void setStatistics(const QVariantMap &statistics);
    /// \endcond

private slots:
    void slotPairFinished();
    void slotSocketConnected(QTcpSocket *socket, const QString &hostName, quint16 port);
    void slotUpdateStatistics();

private:
    QXmppServerProxy65Private * const d;
};

#endif