home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / khttpproxysocketdevice.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.3 KB  |  123 lines

  1. /*  -*- C++ -*-
  2.  *  Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
  3.  *
  4.  *
  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:
  12.  *
  13.  *  The above copyright notice and this permission notice shall be included 
  14.  *  in all copies or substantial portions of the Software.
  15.  *
  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.
  23.  */
  24.  
  25. #ifndef KHTTPPROXYSOCKETDEVICE_H
  26. #define KHTTPPROXYSOCKETDEVICE_H
  27.  
  28. #include "ksocketdevice.h"
  29.  
  30. namespace KNetwork {
  31.  
  32. class KHttpProxySocketDevicePrivate;
  33.  
  34. /**
  35.  * @class KHttpProxySocketDevice khttpproxysocketdevice.h khttproxysocketdevice.h
  36.  * @brief The low-level backend for HTTP proxying.
  37.  *
  38.  * This class derives from @ref KSocketDevice and implements the necessary
  39.  * calls to make a connection through an HTTP proxy.
  40.  *
  41.  * @author Thiago Macieira <thiago.macieira@kdemail.net>
  42.  */
  43. class KDECORE_EXPORT KHttpProxySocketDevice: public KSocketDevice
  44. {
  45. public:
  46.   /**
  47.    * Constructor.
  48.    */
  49.   KHttpProxySocketDevice(const KSocketBase* = 0L);
  50.  
  51.   /**
  52.    * Constructor with proxy server's address.
  53.    */
  54.   KHttpProxySocketDevice(const KResolverEntry& proxy);
  55.  
  56.   /**
  57.    * Destructor
  58.    */
  59.   virtual ~KHttpProxySocketDevice();
  60.  
  61.   /**
  62.    * Sets our capabilities.
  63.    */
  64.   virtual int capabilities() const;
  65.  
  66.   /**
  67.    * Retrieves the proxy server address.
  68.    */
  69.   const KResolverEntry& proxyServer() const;
  70.  
  71.   /**
  72.    * Sets the proxy server address.
  73.    */
  74.   void setProxyServer(const KResolverEntry& proxy);
  75.  
  76.   /**
  77.    * Closes the socket.
  78.    */
  79.   virtual void close();
  80.  
  81.   /**
  82.    * Overrides connection.
  83.    */
  84.   virtual bool connect(const KResolverEntry& address);
  85.  
  86.   /**
  87.    * Name-based connection.
  88.    * We can tell the HTTP proxy server the full name.
  89.    */
  90.   virtual bool connect(const QString& name, const QString& service);
  91.  
  92.   /**
  93.    * Return the peer address.
  94.    */
  95.   virtual KSocketAddress peerAddress() const;
  96.  
  97.   /**
  98.    * Return the externally visible address. We can't tell what that address is,
  99.    * so this function always returns an empty object.
  100.    */
  101.   virtual KSocketAddress externalAddress() const;
  102.  
  103. private:
  104.   /**
  105.    * Parses the server reply after sending the connect command.
  106.    * Returns true on success and false on failure.
  107.    */
  108.   bool parseServerReply();
  109.   KHttpProxySocketDevicePrivate *d;
  110.  
  111. public:
  112.   /**
  113.    * This is the default proxy server to be used.
  114.    * Applications may want to set this value so that calling @ref setProxyServer
  115.    * is unnecessary.
  116.    */
  117.   static KResolverEntry defaultProxy;
  118. };
  119.  
  120. }                // namespace KNetwork
  121.  
  122. #endif
  123.