KIO
slave.h
Go to the documentation of this file.
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 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License version 2 as published by the Free Software Foundation. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 **/ 00021 00022 #ifndef KIO_SLAVE_H 00023 #define KIO_SLAVE_H 00024 00025 #define KIO_SLAVE_EXPORT KIO_EXPORT 00026 00027 #include <time.h> 00028 #include <unistd.h> 00029 00030 #include <QtCore/QObject> 00031 00032 #include <kurl.h> 00033 00034 #include "kio/slaveinterface.h" 00035 00036 namespace KIO { 00037 00038 class SlavePrivate; 00039 class SimpleJob; 00040 // Attention developers: If you change the implementation of KIO::Slave, 00041 // do *not* use connection() or slaveconn but the respective KIO::Slave 00042 // accessor methods. Otherwise classes derived from Slave might break. (LS) 00043 // 00044 // Do not use this class directly, outside of KIO. Only use the Slave pointer 00045 // that is returned by the scheduler for passing it around. 00046 // 00047 // TODO: KDE5: Separate public API and private stuff for this better 00048 class KIO_SLAVE_EXPORT Slave : public KIO::SlaveInterface 00049 { 00050 Q_OBJECT 00051 public: 00052 explicit Slave(const QString &protocol, QObject *parent = 0); 00053 00054 virtual ~Slave(); 00055 00056 void setPID(pid_t); 00057 00058 int slave_pid(); 00059 00060 void setJob(KIO::SimpleJob *job); 00061 KIO::SimpleJob *job() const; 00062 00066 void kill(); 00067 00071 bool isAlive(); 00072 00080 virtual void setHost( const QString &host, quint16 port, 00081 const QString &user, const QString &passwd); 00082 00086 void resetHost(); 00087 00091 virtual void setConfig(const MetaData &config); 00092 00098 QString protocol(); 00099 00100 void setProtocol(const QString & protocol); 00113 QString slaveProtocol(); 00114 00118 QString host(); 00119 00123 quint16 port(); 00124 00128 QString user(); 00129 00133 QString passwd(); 00134 00145 static Slave* createSlave( const QString &protocol, const KUrl& url, int& error, QString& error_text ); 00146 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 virtual void suspend(); 00163 virtual void resume(); 00168 virtual bool suspended(); 00174 virtual void send(int cmd, const QByteArray &arr = QByteArray()); 00175 00176 // == end communication with connected kioslave == 00185 virtual void hold(const KUrl &url); // TODO KDE5: no reason to be virtual 00186 00190 time_t idleTime(); 00191 00195 void setIdle(); 00196 00197 /* 00198 * @returns Whether the slave is connected 00199 * (Connection oriented slaves only) 00200 */ 00201 bool isConnected(); 00202 void setConnected(bool c); 00203 00204 void ref(); 00205 void deref(); 00206 00207 public Q_SLOTS: 00208 void accept(); 00209 void gotInput(); 00210 void timeout(); 00211 00212 Q_SIGNALS: 00213 void slaveDied(KIO::Slave *slave); 00214 00215 private: 00216 Q_DECLARE_PRIVATE(Slave) 00217 }; 00218 00219 } 00220 00221 #undef KIO_SLAVE_EXPORT 00222 00223 #endif
KDE 4.6 API Reference