slave.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KIO_SLAVE_H
00023 #define KIO_SLAVE_H
00024
00025 #include <time.h>
00026 #include <unistd.h>
00027
00028 #include <qobject.h>
00029
00030 #include <kurl.h>
00031
00032 #include "kio/slaveinterface.h"
00033 #include "kio/connection.h"
00034
00035 class KServerSocket;
00036 class KSocket;
00037
00038 namespace KIO {
00039
00040
00041
00042
00043 class KIO_EXPORT Slave : public KIO::SlaveInterface
00044 {
00045 Q_OBJECT
00046
00047 protected:
00054 Slave(bool derived, KServerSocket *unixdomain, const QString &protocol,
00055 const QString &socketname);
00056
00057 public:
00058 Slave(KServerSocket *unixdomain,
00059 const QString &protocol, const QString &socketname);
00060
00061 virtual ~Slave();
00062
00063 void setPID(pid_t);
00064
00065 int slave_pid() { return m_pid; }
00066
00070 void kill();
00071
00075 bool isAlive() { return !dead; }
00076
00084 void setHost( const QString &host, int port,
00085 const QString &user, const QString &passwd);
00086
00090 void resetHost();
00091
00095 void setConfig(const MetaData &config);
00096
00102 QString protocol() { return m_protocol; }
00103
00104 void setProtocol(const QString & protocol);
00117 QString slaveProtocol() { return m_slaveProtocol; }
00118
00122 QString host() { return m_host; }
00123
00127 int port() { return m_port; }
00128
00132 QString user() { return m_user; }
00133
00137 QString passwd() { return m_passwd; }
00138
00147 static Slave* createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text );
00148
00149 static Slave* holdSlave( const QString &protocol, const KURL& url );
00150
00151
00152
00153
00157 void suspend();
00161 void resume();
00167 bool suspended();
00174 void send(int cmd, const QByteArray &arr = QByteArray());
00175
00176
00180 void hold(const KURL &url);
00181
00185 time_t idleTime();
00186
00190 void setIdle();
00191
00192
00193
00194
00195
00196 bool isConnected() { return contacted; }
00197 void setConnected(bool c) { contacted = c; }
00198
00203 KDE_DEPRECATED Connection *connection() { return &slaveconn; }
00204
00205 void ref() { m_refCount++; }
00206 void deref() { m_refCount--; if (!m_refCount) delete this; }
00207
00208 public slots:
00209 void accept(KSocket *socket);
00210 void gotInput();
00211 void timeout();
00212 signals:
00213 void slaveDied(KIO::Slave *slave);
00214
00215 protected:
00216 void unlinkSocket();
00217
00218 private:
00219 QString m_protocol;
00220 QString m_slaveProtocol;
00221 QString m_host;
00222 int m_port;
00223 QString m_user;
00224 QString m_passwd;
00225 KServerSocket *serv;
00226 QString m_socket;
00227 pid_t m_pid;
00228 bool contacted;
00229 bool dead;
00230 time_t contact_started;
00231 time_t idle_since;
00232 KIO::Connection slaveconn;
00233 int m_refCount;
00234 protected:
00235 virtual void virtual_hook( int id, void* data );
00236
00237 enum { VIRTUAL_SUSPEND = 0x200, VIRTUAL_RESUME, VIRTUAL_SEND,
00238 VIRTUAL_HOLD, VIRTUAL_SUSPENDED,
00239 VIRTUAL_SET_HOST, VIRTUAL_SET_CONFIG };
00240 struct SendParams {
00241 int cmd;
00242 const QByteArray *arr;
00243 };
00244 struct HoldParams {
00245 const KURL *url;
00246 };
00247 struct SuspendedParams {
00248 bool retval;
00249 };
00250 struct SetHostParams {
00251 const QString *host;
00252 int port;
00253 const QString *user;
00254 const QString *passwd;
00255 };
00256 struct SetConfigParams {
00257 const MetaData *config;
00258 };
00259 private:
00260 class SlavePrivate* d;
00261 };
00262
00263 }
00264
00265 #endif
This file is part of the documentation for kio Library Version 3.4.1.