kio Library API Documentation

tcpslavebase.h

00001 /*
00002  * $Id: tcpslavebase.h,v 1.41 2003/08/30 08:56:21 raabe Exp $
00003  *
00004  * Copyright (C) 2000 Alex Zepeda <zipzippy@sonic.net>
00005  * Copyright (C) 2001 George Staikos <staikos@kde.org>
00006  * Copyright (C) 2001 Dawit Alemayehu <adawit@kde.org>
00007  *
00008  * This file is part of the KDE project
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public License
00021  * along with this library; see the file COPYING.LIB.  If not, write to
00022  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef _TCP_SLAVEBASE_H
00027 #define _TCP_SLAVEBASE_H "$Id: tcpslavebase.h,v 1.41 2003/08/30 08:56:21 raabe Exp $"
00028 
00029 #include <sys/types.h>
00030 
00031 #include <stdio.h>
00032 
00033 #include <kextsock.h>
00034 #include <kio/slavebase.h>
00035 #include <kdemacros.h>
00036 
00037 
00038 namespace KIO {
00039 
00049 class TCPSlaveBase : public SlaveBase
00050 {
00051 public:
00052     TCPSlaveBase(unsigned short int defaultPort, const QCString &protocol,
00053                  const QCString &poolSocket, const QCString &appSocket);
00054 
00055     TCPSlaveBase(unsigned short int defaultPort, const QCString &protocol,
00056                  const QCString &poolSocket, const QCString &appSocket,
00057                  bool useSSL);
00058 
00059     virtual ~TCPSlaveBase();
00060 
00061 protected:
00062 
00063 #ifndef KDE_NO_COMPAT
00064 
00067     KDE_DEPRECATED ssize_t Write(const void *data, ssize_t len) { return write( data, len ); }
00068 
00072     KDE_DEPRECATED ssize_t Read(void *data, ssize_t len) { return read( data, len ); }
00073 
00077     KDE_DEPRECATED ssize_t ReadLine(char *data, ssize_t len) { return readLine( data, len ); }
00078 
00082     KDE_DEPRECATED unsigned short int GetPort(unsigned short int p) { return port(p); }
00083 
00087     KDE_DEPRECATED bool ConnectToHost( const QString &host, unsigned int port,
00088                         bool sendError ) { return connectToHost( host, port, sendError ); }
00089 
00093     KDE_DEPRECATED void CloseDescriptor() { closeDescriptor(); }
00094 
00098     KDE_DEPRECATED bool AtEOF() { return atEnd(); }
00099 
00103     KDE_DEPRECATED bool InitializeSSL() { return initializeSSL(); }
00104 
00108     KDE_DEPRECATED void CleanSSL() { cleanSSL(); }
00109 #endif
00110 
00121     ssize_t write(const void *data, ssize_t len);
00122 
00133     ssize_t read(void *data, ssize_t len);
00134 
00138     ssize_t readLine(char *data, ssize_t len);
00139  
00147     void setBlockSize(int sz);
00148 
00157     unsigned short int port(unsigned short int _port);
00158 
00177     bool connectToHost( const QString &host, unsigned int port,
00178                         bool sendError = true );
00179 
00187     bool usingSSL() const { return m_bIsSSL; }
00188 
00196     bool usingTLS() const;
00197 
00205     bool usingTLS();
00206 
00213     bool canUseTLS();
00214 
00224     int startTLS();
00225 
00229     void stopTLS();
00230 
00238     void closeDescriptor();
00239 
00240 
00244     bool atEnd();
00245 
00246 
00253     void setSSLMetaData();
00254 
00255 
00259     bool initializeSSL();
00260 
00261 
00265     void cleanSSL();
00266 
00276     bool isConnectionValid();
00277 
00288     int connectResult();
00289 
00300     bool waitForResponse( int t );
00301 
00311     void setBlockConnection( bool b );
00312 
00323     void setConnectTimeout( int t );
00324 
00330     bool isSSLTunnelEnabled();
00331 
00347     void setEnableSSLTunnel( bool enable );
00348 
00359     void setRealHost( const QString& realHost );
00360 
00361     // don't use me!
00362     void doConstructorStuff();
00363 
00364     // For the certificate verification code
00365     int verifyCertificate();
00366 
00367     // For prompting for the certificate to use
00368     void certificatePrompt();
00369 
00370     // Did the user abort (as the reason for connectToHost returning false)
00371     bool userAborted() const;
00372 
00373 protected:
00374     int m_iSock;
00375     bool m_bIsSSL;
00376     unsigned short int m_iPort;
00377     unsigned short int m_iDefaultPort;
00378     QCString m_sServiceName;
00379     FILE *fp;
00380 
00381 private:
00382     bool doSSLHandShake( bool sendError );
00383 
00384 protected:
00385     virtual void virtual_hook( int id, void* data );
00386 private:
00387     class TcpSlaveBasePrivate;
00388     TcpSlaveBasePrivate *d;
00389 };
00390 
00391 }
00392 
00393 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Aug 4 05:25:38 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003