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 int slave_pid(); 00058 00059 void setJob(KIO::SimpleJob *job); 00060 KIO::SimpleJob *job() const; 00061 00065 void kill(); 00066 00070 bool isAlive(); 00071 00079 virtual void setHost( const QString &host, quint16 port, 00080 const QString &user, const QString &passwd); 00081 00085 void resetHost(); 00086 00090 virtual void setConfig(const MetaData &config); 00091 00097 QString protocol(); 00098 00099 void setProtocol(const QString & protocol); 00100 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 00158 static bool checkForHeldSlave(const KUrl& url); 00159 00160 // == communication with connected kioslave == 00161 // whenever possible prefer these methods over the respective 00162 // methods in connection() 00166 virtual void suspend(); 00167 00171 virtual void resume(); 00172 00177 virtual bool suspended(); 00178 00184 virtual void send(int cmd, const QByteArray &arr = QByteArray()); 00185 00186 // == end communication with connected kioslave == 00195 virtual void hold(const KUrl &url); // TODO KDE5: no reason to be virtual 00196 00200 time_t idleTime(); 00201 00205 void setIdle(); 00206 00207 /* 00208 * @returns Whether the slave is connected 00209 * (Connection oriented slaves only) 00210 */ 00211 bool isConnected(); 00212 void setConnected(bool c); 00213 00214 void ref(); 00215 void deref(); 00216 00217 public Q_SLOTS: 00218 void accept(); 00219 void gotInput(); 00220 void timeout(); 00221 00222 Q_SIGNALS: 00223 void slaveDied(KIO::Slave *slave); 00224 00225 private: 00226 Q_DECLARE_PRIVATE(Slave) 00227 }; 00228 00229 } 00230 00231 #undef KIO_SLAVE_EXPORT 00232 00233 #endif
KDE 4.7 API Reference