tcpslavebase.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _TCP_SLAVEBASE_H
00025 #define _TCP_SLAVEBASE_H
00026
00027 #include <sys/types.h>
00028 #include <stdio.h>
00029
00030 #include <kextsock.h>
00031 #include <kio/slavebase.h>
00032
00033
00034 namespace KIO {
00035
00045 class KIO_EXPORT TCPSlaveBase : public SlaveBase
00046 {
00047 public:
00048 TCPSlaveBase(unsigned short int defaultPort, const QCString &protocol,
00049 const QCString &poolSocket, const QCString &appSocket);
00050
00051 TCPSlaveBase(unsigned short int defaultPort, const QCString &protocol,
00052 const QCString &poolSocket, const QCString &appSocket,
00053 bool useSSL);
00054
00055 virtual ~TCPSlaveBase();
00056
00057 protected:
00058
00059 #ifndef KDE_NO_COMPAT
00060
00063 KDE_DEPRECATED ssize_t Write(const void *data, ssize_t len) { return write( data, len ); }
00064
00068 KDE_DEPRECATED ssize_t Read(void *data, ssize_t len) { return read( data, len ); }
00069
00073 KDE_DEPRECATED ssize_t ReadLine(char *data, ssize_t len) { return readLine( data, len ); }
00074
00078 KDE_DEPRECATED unsigned short int GetPort(unsigned short int p) { return port(p); }
00079
00083 KDE_DEPRECATED bool ConnectToHost( const QString &host, unsigned int port,
00084 bool sendError ) { return connectToHost( host, port, sendError ); }
00085
00089 KDE_DEPRECATED void CloseDescriptor() { closeDescriptor(); }
00090
00094 KDE_DEPRECATED bool AtEOF() { return atEnd(); }
00095
00099 KDE_DEPRECATED bool InitializeSSL() { return initializeSSL(); }
00100
00104 KDE_DEPRECATED void CleanSSL() { cleanSSL(); }
00105 #endif
00106
00117 ssize_t write(const void *data, ssize_t len);
00118
00129 ssize_t read(void *data, ssize_t len);
00130
00134 ssize_t readLine(char *data, ssize_t len);
00135
00143 void setBlockSize(int sz);
00144
00153 unsigned short int port(unsigned short int _port);
00154
00173 bool connectToHost( const QString &host, unsigned int port,
00174 bool sendError = true );
00175
00183 bool usingSSL() const { return m_bIsSSL; }
00184
00192 bool usingTLS() const;
00193
00201 bool usingTLS();
00202
00209 bool canUseTLS();
00210
00220 int startTLS();
00221
00225 void stopTLS();
00226
00234 void closeDescriptor();
00235
00236
00240 bool atEnd();
00241
00242
00249 void setSSLMetaData();
00250
00251
00255 bool initializeSSL();
00256
00257
00261 void cleanSSL();
00262
00272 bool isConnectionValid();
00273
00284 int connectResult();
00285
00296 bool waitForResponse( int t );
00297
00307 void setBlockConnection( bool b );
00308
00319 void setConnectTimeout( int t );
00320
00326 bool isSSLTunnelEnabled();
00327
00343 void setEnableSSLTunnel( bool enable );
00344
00355 void setRealHost( const QString& realHost );
00356
00357
00358 void doConstructorStuff();
00359
00360
00361 int verifyCertificate();
00362
00363
00364 void certificatePrompt();
00365
00366
00367 bool userAborted() const;
00368
00369 protected:
00370 int m_iSock;
00371 bool m_bIsSSL;
00372 unsigned short int m_iPort;
00373 unsigned short int m_iDefaultPort;
00374 QCString m_sServiceName;
00375 FILE *fp;
00376
00377 private:
00378 bool doSSLHandShake( bool sendError );
00379
00380 protected:
00381 virtual void virtual_hook( int id, void* data );
00382 private:
00383 class TcpSlaveBasePrivate;
00384 TcpSlaveBasePrivate *d;
00385 };
00386
00387 }
00388
00389 #endif
|