fix logic
[personal-kdelibs.git] / kdecore / network / k3sockssocketdevice.h
blobd415ea432317e664e070398708ac5aef7541646f
1 /* -*- C++ -*-
2 * Copyright (C) 2004,2005 Thiago Macieira <thiago@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef KSOCKSSOCKETDEVICE_H
21 #define KSOCKSSOCKETDEVICE_H
23 #include "k3socketdevice.h"
25 namespace KNetwork {
27 class KSocksSocketDevicePrivate;
28 /**
29 * @class KSocksSocketDevice k3sockssocketdevice.h k3sockssocketdevice.h
30 * @brief The low-level class for SOCKS proxying.
32 * This class reimplements several functions from KSocketDevice in order
33 * to implement SOCKS support.
35 * This works by using KSocks.
37 * @author Thiago Macieira <thiago@kde.org>
39 * @warning This code is untested!
40 * @deprecated Use KSocketFactory or KLocalSocket instead
42 class KDECORE_EXPORT KSocksSocketDevice: public KSocketDevice
44 public:
45 /**
46 * Constructor.
48 KSocksSocketDevice(const KSocketBase* = 0L);
50 /**
51 * Construct from a file descriptor.
53 explicit KSocksSocketDevice(int fd);
55 /**
56 * Destructor.
58 virtual ~KSocksSocketDevice();
60 /**
61 * Sets our capabilities.
63 virtual int capabilities() const;
65 /**
66 * Overrides binding.
68 virtual bool bind(const KResolverEntry& address);
70 /**
71 * Overrides listening.
73 virtual bool listen(int backlog);
75 /**
76 * Overrides connection.
78 virtual bool connect(const KResolverEntry& address);
80 /**
81 * Overrides accepting. The return type is specialized.
83 virtual KSocksSocketDevice* accept();
85 /**
86 * Overrides reading.
88 virtual qint64 readBlock(char *data, quint64 maxlen);
90 /**
91 * Overrides reading.
93 * @todo (Thiago, you saw this coming) Actually document this.
94 * What is the @p from for?
96 virtual qint64 readBlock(char *data, quint64 maxlen, KSocketAddress& from);
98 /**
99 * Overrides peeking.
101 virtual qint64 peekBlock(char *data, quint64 maxlen);
104 * Overrides peeking.
106 virtual qint64 peekBlock(char *data, quint64 maxlen, KSocketAddress& from);
109 * Overrides writing.
111 virtual qint64 writeBlock(const char *data, quint64 len);
114 * Overrides writing.
116 virtual qint64 writeBlock(const char *data, quint64 len, const KSocketAddress& to);
119 * Overrides getting socket address.
121 virtual KSocketAddress localAddress() const;
124 * Overrides getting peer address.
126 virtual KSocketAddress peerAddress() const;
129 * Overrides getting external address.
131 virtual KSocketAddress externalAddress() const;
134 * Overrides polling.
136 virtual bool poll(bool* input, bool* output, bool* exception = 0L,
137 int timeout = -1, bool* timedout = 0L);
139 private:
140 static void initSocks();
141 friend class KSocketDevice;
142 KSocksSocketDevicePrivate * const d;
145 } // namespace KNetwork
147 #endif