dataslave.h
// -*- c++ -*-
/*
* This file is part of the KDE libraries
* Copyright (c) 2003 Leo Savernik <l.savernik@aon.at>
* Derived from slave.h
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef __KIO_DATASLAVE_H__
#define __KIO_DATASLAVE_H__
#include <kio/global.h>
#include <kio/slave.h>
class QTimer;
// don't forget to sync DISPATCH_IMPL in dataslave.h
#define DISPATCH_DECL(type) \
void dispatch_##type();
// don't forget to sync DISPATCH_IMPL1 in dataslave.h
#define DISPATCH_DECL1(type, paramtype, param) \
void dispatch_##type(paramtype param);
namespace KIO {
class DataSlave : public KIO::Slave {
Q_OBJECT
public:
DataSlave();
virtual ~DataSlave();
virtual void setHost(const QString &host, int port,
const QString &user, const QString &passwd);
virtual void setConfig(const MetaData &config);
virtual void suspend();
virtual void resume();
virtual bool suspended();
virtual void send(int cmd, const QByteArray &data = QByteArray());
virtual void hold(const KURL &url);
// pure virtual methods that are defined by the actual protocol
virtual void get(const KURL &url) = 0;
virtual void mimetype(const KURL &url) = 0;
protected:
void setAllMetaData(const MetaData &);
void sendMetaData();
// queueing methods
enum QueueType { Queue_mimeType = 1, Queue_totalSize,
Queue_sendMetaData, Queue_data, Queue_finished };
struct QueueStruct {
QueueType type;
QString s;
KIO::filesize_t size;
QByteArray ba;
QueueStruct() {}
QueueStruct(QueueType type) : type(type) {}
};
typedef QValueList<QueueStruct> DispatchQueue;
DispatchQueue dispatchQueue;
DISPATCH_DECL1(mimeType, const QString &, s)
DISPATCH_DECL1(totalSize, KIO::filesize_t, size)
DISPATCH_DECL(sendMetaData)
DISPATCH_DECL1(data, const QByteArray &, ba)
DISPATCH_DECL(finished)
protected slots:
void dispatchNext();
protected:
virtual void virtual_hook( int id, void* data );
private:
MetaData meta_data;
bool _suspended;
QTimer *timer;
};
}
#undef DISPATCH_DECL
#undef DISPATCH_DECL1
#endif /*__KIO_DATASLAVE_H__*/
KIO::DataSlave::sendMetaData
void sendMetaData()
Sends metadata set with setAllMetaData.
Definition: dataslave.cpp:167
KIO::Slave::passwd
QString passwd()
Definition: slave.h:138
KIO::DataSlave::QueueStruct
structure for queueing.
Definition: dataslave.h:90
KIO::Slave::host
QString host()
Definition: slave.h:123
KIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:512
KIO::Slave
Attention developers: If you change the implementation of KIO::Slave, do not use connection() or slav...
Definition: slave.h:44
KIO::DataSlave::setAllMetaData
void setAllMetaData(const MetaData &)
Sets metadata.
Definition: dataslave.cpp:163
KIO::DataSlave::QueueType
QueueType
identifiers of functions to be queued
Definition: dataslave.h:85
KIO::Slave::user
QString user()
Definition: slave.h:133
KIO::filesize_t
Q_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KIO::Slave::port
int port()
Definition: slave.h:128
KIO::DataSlave
This class provides a high performance implementation for the data url scheme (rfc2397).
Definition: dataslave.h:49
KIO::DataSlave::dispatchNext
void dispatchNext()
dispatches next queued method.
Definition: dataslave.cpp:99

KDE Home | KDE Accessibility Home | Description of Access Keys