KIO
dataslave.h
Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 **/ 00021 00022 #ifndef KIO_DATASLAVE_H 00023 #define KIO_DATASLAVE_H 00024 00025 #include "global.h" 00026 #include "slave.h" 00027 00028 class QTimer; 00029 00030 // don't forget to sync DISPATCH_IMPL in dataslave.h 00031 #define DISPATCH_DECL(type) \ 00032 void dispatch_##type(); 00033 00034 // don't forget to sync DISPATCH_IMPL1 in dataslave.h 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, quint16 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 &arr = QByteArray()); 00064 00065 virtual void hold(const KUrl &url); 00066 00067 // pure virtual methods that are defined by the actual protocol 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 // queuing methods 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 QList<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 Q_SLOTS: 00112 void dispatchNext(); 00113 private: 00114 MetaData meta_data; 00115 bool _suspended; 00116 QTimer *timer; 00117 }; 00118 00119 } 00120 00121 #undef DISPATCH_DECL 00122 #undef DISPATCH_DECL1 00123 00124 #endif
KDE 4.6 API Reference