kio
slave.h
Go to the documentation of this file.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
00044 class KIO_EXPORT Slave : public KIO::SlaveInterface
00045 {
00046 Q_OBJECT
00047
00048 protected:
00055 Slave(bool derived, KServerSocket *unixdomain, const QString &protocol,
00056 const QString &socketname);
00057
00058 public:
00059 Slave(KServerSocket *unixdomain,
00060 const QString &protocol, const QString &socketname);
00061
00062 virtual ~Slave();
00063
00064 void setPID(pid_t);
00065
00066 int slave_pid() { return m_pid; }
00067
00071 void kill();
00072
00076 bool isAlive() { return !dead; }
00077
00085 void setHost( const QString &host, int port,
00086 const QString &user, const QString &passwd);
00087
00091 void resetHost();
00092
00096 void setConfig(const MetaData &config);
00097
00103 QString protocol() { return m_protocol; }
00104
00105 void setProtocol(const QString & protocol);
00118 QString slaveProtocol() { return m_slaveProtocol; }
00119
00123 QString host() { return m_host; }
00124
00128 int port() { return m_port; }
00129
00133 QString user() { return m_user; }
00134
00138 QString passwd() { return m_passwd; }
00139
00151 static Slave* createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text );
00152
00153 static Slave* holdSlave( const QString &protocol, const KURL& url );
00154
00155
00156
00157
00161 void suspend();
00165 void resume();
00171 bool suspended();
00178 void send(int cmd, const QByteArray &data = QByteArray());
00179
00180
00184 void hold(const KURL &url);
00185
00189 time_t idleTime();
00190
00194 void setIdle();
00195
00196
00197
00198
00199
00200 bool isConnected() { return contacted; }
00201 void setConnected(bool c) { contacted = c; }
00202
00207 KDE_DEPRECATED Connection *connection() { return &slaveconn; }
00208
00209 void ref() { m_refCount++; }
00210 void deref() { m_refCount--; if (!m_refCount) delete this; }
00211
00212 public slots:
00213 void accept(KSocket *socket);
00214 void gotInput();
00215 void timeout();
00216 signals:
00217 void slaveDied(KIO::Slave *slave);
00218
00219 protected:
00220 void unlinkSocket();
00221
00222 private:
00223 QString m_protocol;
00224 QString m_slaveProtocol;
00225 QString m_host;
00226 int m_port;
00227 QString m_user;
00228 QString m_passwd;
00229 KServerSocket *serv;
00230 QString m_socket;
00231 pid_t m_pid;
00232 bool contacted;
00233 bool dead;
00234 time_t contact_started;
00235 time_t idle_since;
00236 KIO::Connection slaveconn;
00237 int m_refCount;
00238 protected:
00239 virtual void virtual_hook( int id, void* data );
00240
00241 enum { VIRTUAL_SUSPEND = 0x200, VIRTUAL_RESUME, VIRTUAL_SEND,
00242 VIRTUAL_HOLD, VIRTUAL_SUSPENDED,
00243 VIRTUAL_SET_HOST, VIRTUAL_SET_CONFIG };
00244 struct SendParams {
00245 int cmd;
00246 const QByteArray *arr;
00247 };
00248 struct HoldParams {
00249 const KURL *url;
00250 };
00251 struct SuspendedParams {
00252 bool retval;
00253 };
00254 struct SetHostParams {
00255 const QString *host;
00256 int port;
00257 const QString *user;
00258 const QString *passwd;
00259 };
00260 struct SetConfigParams {
00261 const MetaData *config;
00262 };
00263 private:
00264 class SlavePrivate* d;
00265 };
00266
00267 }
00268
00269 #endif