slave.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KIO_SLAVE_H
00025 #define KIO_SLAVE_H
00026
00027 #include <time.h>
00028 #include <unistd.h>
00029
00030 #include <qobject.h>
00031
00032 #include <kurl.h>
00033
00034 #include "kio/slaveinterface.h"
00035 #include "kio/connection.h"
00036
00037 class KServerSocket;
00038 class KSocket;
00039
00040 namespace KIO {
00041
00042 class Slave : public KIO::SlaveInterface
00043 {
00044 Q_OBJECT
00045
00046 public:
00047 Slave(KServerSocket *unixdomain,
00048 const QString &protocol, const QString &socketname);
00049
00050 virtual ~Slave();
00051
00052 void setPID(pid_t);
00053
00054 int slave_pid() { return m_pid; }
00055
00059 void kill();
00060
00064 bool isAlive() { return !dead; }
00065
00073 void setHost( const QString &host, int port,
00074 const QString &user, const QString &passwd);
00075
00079 void resetHost();
00080
00084 void setConfig(const MetaData &config);
00085
00091 QString protocol() { return m_protocol; }
00092
00093 void setProtocol(const QString & protocol);
00106 QString slaveProtocol() { return m_slaveProtocol; }
00107
00111 QString host() { return m_host; }
00112
00116 int port() { return m_port; }
00117
00121 QString user() { return m_user; }
00122
00126 QString passwd() { return m_passwd; }
00127
00136 static Slave* createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text );
00137
00138 static Slave* holdSlave( const QString &protocol, const KURL& url );
00139
00140 void suspend();
00141 void resume();
00142 void hold(const KURL &url);
00143
00144 bool suspended();
00145
00149 time_t idleTime();
00150
00154 void setIdle();
00155
00156
00157
00158
00159
00160 bool isConnected() { return contacted; }
00161 void setConnected(bool c) { contacted = c; }
00162
00163 Connection *connection() { return &slaveconn; }
00164
00165 void ref() { m_refCount++; }
00166 void deref() { m_refCount--; if (!m_refCount) delete this; }
00167
00168 public slots:
00169 void accept(KSocket *socket);
00170 void gotInput();
00171 void timeout();
00172 signals:
00173 void slaveDied(KIO::Slave *slave);
00174
00175 protected:
00176 void unlinkSocket();
00177
00178 private:
00179 QString m_protocol;
00180 QString m_slaveProtocol;
00181 QString m_host;
00182 int m_port;
00183 QString m_user;
00184 QString m_passwd;
00185 KServerSocket *serv;
00186 QString m_socket;
00187 pid_t m_pid;
00188 bool contacted;
00189 bool dead;
00190 time_t contact_started;
00191 time_t idle_since;
00192 KIO::Connection slaveconn;
00193 int m_refCount;
00194 protected:
00195 virtual void virtual_hook( int id, void* data );
00196 private:
00197 class SlavePrivate* d;
00198 };
00199
00200 };
00201
00202 #endif
This file is part of the documentation for kdelibs Version 3.1.0.