kio
dataslave.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_DATASLAVE_H__
00023 #define __KIO_DATASLAVE_H__
00024
00025 #include <kio/global.h>
00026 #include <kio/slave.h>
00027
00028 class QTimer;
00029
00030
00031 #define DISPATCH_DECL(type) \
00032 void dispatch_##type();
00033
00034
00035 #define DISPATCH_DECL1(type, paramtype, param) \
00036 void dispatch_##type(paramtype param);
00037
00038 namespace KIO {
00039
00049 class DataSlave : public KIO::Slave {
00050 Q_OBJECT
00051 public:
00052 DataSlave();
00053
00054 virtual ~DataSlave();
00055
00056 virtual void setHost(const QString &host, int port,
00057 const QString &user, const QString &passwd);
00058 virtual void setConfig(const MetaData &config);
00059
00060 virtual void suspend();
00061 virtual void resume();
00062 virtual bool suspended();
00063 virtual void send(int cmd, const QByteArray &data = QByteArray());
00064
00065 virtual void hold(const KURL &url);
00066
00067
00068 virtual void get(const KURL &url) = 0;
00069 virtual void mimetype(const KURL &url) = 0;
00070
00071 protected:
00076 void setAllMetaData(const MetaData &);
00081 void sendMetaData();
00082
00083
00085 enum QueueType { Queue_mimeType = 1, Queue_totalSize,
00086 Queue_sendMetaData, Queue_data, Queue_finished };
00090 struct QueueStruct {
00091 QueueType type;
00092 QString s;
00093 KIO::filesize_t size;
00094 QByteArray ba;
00095
00096 QueueStruct() {}
00097 QueueStruct(QueueType type) : type(type) {}
00098 };
00099 typedef QValueList<QueueStruct> DispatchQueue;
00100 DispatchQueue dispatchQueue;
00101
00102 DISPATCH_DECL1(mimeType, const QString &, s)
00103 DISPATCH_DECL1(totalSize, KIO::filesize_t, size)
00104 DISPATCH_DECL(sendMetaData)
00105 DISPATCH_DECL1(data, const QByteArray &, ba)
00106 DISPATCH_DECL(finished)
00107
00108 protected slots:
00112 void dispatchNext();
00113 protected:
00114 virtual void virtual_hook( int id, void* data );
00115 private:
00116 MetaData meta_data;
00117 bool _suspended;
00118 QTimer *timer;
00119 };
00120
00121 }
00122
00123 #undef DISPATCH_DECL
00124 #undef DISPATCH_DECL1
00125
00126 #endif