kio Library API Documentation

dataslave.h

00001 // -*- c++ -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (c) 2003 Leo Savernik <l.savernik@aon.at> 00005 * Derived from slave.h 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., 59 Temple Place - Suite 330, 00019 * Boston, MA 02111-1307, USA. 00020 **/ 00021 00022 #ifndef __KIO_DATASLAVE_H__ 00023 #define __KIO_DATASLAVE_H__ 00024 00025 #include <kio/global.h> 00026 #include <kio/slave.h> 00027 00028 class QTimer; 00029 00030 namespace KIO { 00031 00041 class DataSlave : public KIO::Slave { 00042 Q_OBJECT 00043 public: 00044 DataSlave(); 00045 00046 virtual ~DataSlave(); 00047 00048 virtual void setHost(const QString &host, int port, 00049 const QString &user, const QString &passwd); 00050 virtual void setConfig(const MetaData &config); 00051 00052 virtual void suspend(); 00053 virtual void resume(); 00054 virtual bool suspended(); 00055 virtual void send(int cmd, const QByteArray &arr = QByteArray()); 00056 00057 virtual void hold(const KURL &url); 00058 00059 // pure virtual methods that are defined by the actual protocol 00060 virtual void get(const KURL &url) = 0; 00061 virtual void mimetype(const KURL &url) = 0; 00062 00063 protected: 00068 void setAllMetaData(const MetaData &); 00073 void sendMetaData(); 00074 00075 // queueing methods 00077 enum QueueType { QueueMimeType = 1, QueueTotalSize, QueueSendMetaData, 00078 QueueData, QueueFinished }; 00082 struct QueueStruct { 00083 QueueType type; 00084 QString s; 00085 KIO::filesize_t size; 00086 QByteArray ba; 00087 00088 QueueStruct() {} 00089 QueueStruct(QueueType type) : type(type) {} 00090 }; 00091 typedef QValueList<QueueStruct> DispatchQueue; 00092 DispatchQueue dispatchQueue; 00093 00094 void dispatch_mimeType(const QString &s) { 00095 if (_suspended) { 00096 QueueStruct q(QueueMimeType); 00097 q.s = s; 00098 dispatchQueue.push_back(q); 00099 } else 00100 mimeType(s); 00101 } 00102 void dispatch_totalSize(KIO::filesize_t size) { 00103 if (_suspended) { 00104 QueueStruct q(QueueTotalSize); 00105 q.size = size; 00106 dispatchQueue.push_back(q); 00107 } else 00108 totalSize(size); 00109 } 00110 void dispatch_sendMetaData() { 00111 if (_suspended) { 00112 QueueStruct q(QueueSendMetaData); 00113 dispatchQueue.push_back(q); 00114 } else 00115 sendMetaData(); 00116 } 00117 void dispatch_data(const QByteArray &ba) { 00118 if (_suspended) { 00119 QueueStruct q(QueueData); 00120 q.ba = ba; 00121 dispatchQueue.push_back(q); 00122 } else 00123 data(ba); 00124 } 00125 void dispatch_finished() { 00126 // Allways queue, since it will delete us 00127 QueueStruct q(QueueFinished); 00128 dispatchQueue.push_back(q); 00129 } 00130 00131 protected slots: 00135 void dispatchNext(); 00136 protected: 00137 virtual void virtual_hook( int id, void* data ); 00138 private: 00139 MetaData meta_data; 00140 bool _suspended; 00141 QTimer *timer; 00142 }; 00143 00144 } 00145 00146 #endif /*__KIO_DATASLAVE_H__*/
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 10 18:55:24 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003