kio Library API Documentation

slave.h

00001 // -*- c++ -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (c) 2000 Waldo Bastian <bastian@kde.org> 00005 * 2000 Stephan Kulow <coolo@kde.org> 00006 * 00007 * $Id: slave.h,v 1.36 2003/09/16 18:16:13 savernik Exp $ 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Library General Public 00011 * License version 2 as published by the Free Software Foundation. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Library General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Library General Public License 00019 * along with this library; see the file COPYING.LIB. If not, write to 00020 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00021 * Boston, MA 02111-1307, USA. 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 // Attention developers: If you change the implementation of KIO::Slave, 00043 // do *not* use connection() or slaveconn but the respective KIO::Slave 00044 // accessor methods. Otherwise classes derived from Slave might break. (LS) 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); // TODO(BIC): Remove in KDE 4 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); // TODO(BIC): make virtual 00088 00092 void resetHost(); 00093 00097 void setConfig(const MetaData &config); // TODO(BIC): make virtual 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 // == communication with connected kioslave == 00154 // whenever possible prefer these methods over the respective 00155 // methods in connection() 00159 void suspend(); // TODO(BIC): make virtual 00163 void resume(); // TODO(BIC): make virtual 00169 bool suspended(); // TODO(BIC): make virtual 00176 void send(int cmd, const QByteArray &arr = QByteArray());// TODO(BIC): make virtual 00177 // == end communication with connected kioslave == 00178 00182 void hold(const KURL &url); // TODO(BIC): make virtual 00183 00187 time_t idleTime(); 00188 00192 void setIdle(); 00193 00194 /* 00195 * @returns Whether the slave is connected 00196 * (Connection oriented slaves only) 00197 */ 00198 bool isConnected() { return contacted; } 00199 void setConnected(bool c) { contacted = c; } 00200 00205 KDE_DEPRECATED Connection *connection() { return &slaveconn; } // TODO(BIC): remove before KDE 4 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 // grant SlaveInterface all IDs < 0x200 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
KDE Logo
This file is part of the documentation for kio Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:43:55 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003