kget
btcache.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 00003 Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de> 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 */ 00010 #ifndef KGETBTCACHE_H 00011 #define KGETBTCACHE_H 00012 00013 #include <diskio/cache.h> 00014 #include <interfaces/cachefactory.h> 00015 #include <kio/job.h> 00016 00017 #include <QString> 00018 #include <QByteArray> 00019 00020 class QStringList; 00021 class KJob; 00022 00023 namespace bt 00024 { 00025 class Torrent; 00026 class TorrentFile; 00027 class Chunk; 00028 class PreallocationThread; 00029 } 00030 00031 using namespace bt; 00032 00033 class BTCache : public QObject, public bt::Cache 00034 { 00035 Q_OBJECT 00036 public: 00037 BTCache(bt::Torrent & tor,const QString & tmpdir,const QString & datadir); 00038 ~BTCache(); 00039 00044 virtual void loadFileMap() {} 00045 00049 virtual void saveFileMap() {} 00050 00055 virtual QString getOutputPath() const {return QString();} 00056 00062 virtual void changeTmpDir(const QString & ndir) {Q_UNUSED(ndir)} 00063 00069 virtual void changeOutputPath(const QString & outputpath) {Q_UNUSED(outputpath)} 00070 00076 virtual KJob* moveDataFiles(const QString & ndir) {return 0;} 00077 00082 virtual void moveDataFilesFinished(KJob* job) {Q_UNUSED(job)} 00083 00089 virtual void load(Chunk* c); 00090 00096 virtual void save(Chunk* c); 00097 00103 virtual bool prep(Chunk* c); 00104 00108 virtual void create() {} 00109 00113 virtual void close() {} 00114 00118 virtual void open() {} 00119 00121 virtual void downloadStatusChanged(TorrentFile*, bool) {} 00122 00127 virtual void preallocateDiskSpace(PreallocationThread* prealloc) {Q_UNUSED(prealloc)} 00128 00133 virtual bool hasMissingFiles(QStringList & sl) {return false;} //We never have missing files, cause we don't have files :P 00134 00139 virtual void deleteDataFiles(); 00140 00144 virtual Uint64 diskUsage() {return 0;};//We always use 0 Bytes on HDD, cause we don't write to HDD 00145 00146 signals: 00147 void dataArrived(const KIO::fileoffset_t &offset, const QByteArray &data); 00148 00149 private: 00150 Torrent *m_tor; 00151 }; 00152 00153 class BTCacheFactory : public QObject, public CacheFactory 00154 { 00155 Q_OBJECT 00156 public: 00157 BTCacheFactory() {} 00158 ~BTCacheFactory() {} 00159 00160 virtual Cache* create(Torrent & tor,const QString & tmpdir,const QString & datadir); 00161 00162 signals: 00163 void cacheAdded(BTCache* cache); 00164 }; 00165 00166 #endif
KDE 4.2 API Reference