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
00043
00044
00045 class Slave : public KIO::SlaveInterface
00046 {
00047 Q_OBJECT
00048
00049 protected:
00056 Slave(bool derived, KServerSocket *unixdomain, const QString &protocol,
00057 const QString &socketname);
00058
00059 public:
00060 Slave(KServerSocket *unixdomain,
00061 const QString &protocol, const QString &socketname);
00062
00063 virtual ~Slave();
00064
00065 void setPID(pid_t);
00066
00067 int slave_pid() { return m_pid; }
00068
00072 void kill();
00073
00077 bool isAlive() { return !dead; }
00078
00086 void setHost( const QString &host, int port,
00087 const QString &user, const QString &passwd);
00088
00092 void resetHost();
00093
00097 void setConfig(const MetaData &config);
00098
00104 QString protocol() { return m_protocol; }
00105
00106 void setProtocol(const QString & protocol);
00119 QString slaveProtocol() { return m_slaveProtocol; }
00120
00124 QString host() { return m_host; }
00125
00129 int port() { return m_port; }
00130
00134 QString user() { return m_user; }
00135
00139 QString passwd() { return m_passwd; }
00140
00149 static Slave* createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text );
00150
00151 static Slave* holdSlave( const QString &protocol, const KURL& url );
00152
00153
00154
00155
00159 void suspend();
00163 void resume();
00169 bool suspended();
00176 void send(int cmd, const QByteArray &arr = QByteArray());
00177
00178
00182 void hold(const KURL &url);
00183
00187 time_t idleTime();
00188
00192 void setIdle();
00193
00194
00195
00196
00197
00198 bool isConnected() { return contacted; }
00199 void setConnected(bool c) { contacted = c; }
00200
00205 KDE_DEPRECATED Connection *connection() { return &slaveconn; }
00206
00207 void ref() { m_refCount++; }
00208 void deref() { m_refCount--; if (!m_refCount) delete this; }
00209
00210 public slots:
00211 void accept(KSocket *socket);
00212 void gotInput();
00213 void timeout();
00214 signals:
00215 void slaveDied(KIO::Slave *slave);
00216
00217 protected:
00218 void unlinkSocket();
00219
00220 private:
00221 QString m_protocol;
00222 QString m_slaveProtocol;
00223 QString m_host;
00224 int m_port;
00225 QString m_user;
00226 QString m_passwd;
00227 KServerSocket *serv;
00228 QString m_socket;
00229 pid_t m_pid;
00230 bool contacted;
00231 bool dead;
00232 time_t contact_started;
00233 time_t idle_since;
00234 KIO::Connection slaveconn;
00235 int m_refCount;
00236 protected:
00237 virtual void virtual_hook( int id, void* data );
00238
00239 enum { VIRTUAL_SUSPEND = 0x200, VIRTUAL_RESUME, VIRTUAL_SEND,
00240 VIRTUAL_HOLD, VIRTUAL_SUSPENDED,
00241 VIRTUAL_SET_HOST, VIRTUAL_SET_CONFIG };
00242 struct SendParams {
00243 int cmd;
00244 const QByteArray *arr;
00245 };
00246 struct HoldParams {
00247 const KURL *url;
00248 };
00249 struct SuspendedParams {
00250 bool retval;
00251 };
00252 struct SetHostParams {
00253 const QString *host;
00254 int port;
00255 const QString *user;
00256 const QString *passwd;
00257 };
00258 struct SetConfigParams {
00259 const MetaData *config;
00260 };
00261 private:
00262 class SlavePrivate* d;
00263 };
00264
00265 }
00266
00267 #endif
This file is part of the documentation for kio Library Version 3.3.1.