fix logic
[personal-kdelibs.git] / kdecore / network / k3httpproxysocketdevice.h
bloba4220dc446735a141e2f2fb48c9383adcc405aa6
1 /* -*- C++ -*-
2 * Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org>
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef KHTTPPROXYSOCKETDEVICE_H
26 #define KHTTPPROXYSOCKETDEVICE_H
28 #include "k3socketdevice.h"
30 namespace KNetwork {
32 class KHttpProxySocketDevicePrivate;
34 /**
35 * @class KHttpProxySocketDevice k3httpproxysocketdevice.h k3httproxysocketdevice.h
36 * @brief The low-level backend for HTTP proxying.
38 * This class derives from KSocketDevice and implements the necessary
39 * calls to make a connection through an HTTP proxy.
41 * @author Thiago Macieira <thiago@kde.org>
42 * @deprecated Use KSocketFactory or KLocalSocket instead
44 class KDECORE_EXPORT KHttpProxySocketDevice: public KSocketDevice
46 public:
47 /**
48 * Constructor.
50 KHttpProxySocketDevice(const KSocketBase* = 0L);
52 /**
53 * Constructor with proxy server's address.
55 explicit KHttpProxySocketDevice(const KResolverEntry& proxy);
57 /**
58 * Destructor
60 virtual ~KHttpProxySocketDevice();
62 /**
63 * Sets our capabilities.
65 virtual int capabilities() const;
67 /**
68 * Retrieves the proxy server address.
70 const KResolverEntry& proxyServer() const;
72 /**
73 * Sets the proxy server address.
75 void setProxyServer(const KResolverEntry& proxy);
77 /**
78 * Closes the socket.
80 virtual void close();
82 /**
83 * Overrides connection.
85 virtual bool connect(const KResolverEntry& address);
87 /**
88 * Name-based connection.
89 * We can tell the HTTP proxy server the full name.
91 virtual bool connect(const QString& name, const QString& service);
93 /**
94 * Return the peer address.
96 virtual KSocketAddress peerAddress() const;
98 /**
99 * Return the externally visible address. We can't tell what that address is,
100 * so this function always returns an empty object.
102 virtual KSocketAddress externalAddress() const;
104 private:
106 * Parses the server reply after sending the connect command.
107 * Returns true on success and false on failure.
109 bool parseServerReply();
110 KHttpProxySocketDevicePrivate* const d;
112 public:
114 * This is the default proxy server to be used.
115 * Applications may want to set this value so that calling setProxyServer()
116 * is unnecessary.
118 static KResolverEntry defaultProxy;
121 } // namespace KNetwork
123 #endif