• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • transfer-plugins
  • bittorrent
btcache.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 */
10 #ifndef KGETBTCACHE_H
11 #define KGETBTCACHE_H
12 
13 #include <diskio/cache.h>
14 #include <interfaces/cachefactory.h>
15 #include <kio/job.h>
16 
17 #include <QString>
18 #include <QByteArray>
19 
20 class QStringList;
21 class KJob;
22 
23 namespace bt
24 {
25  class Torrent;
26  class TorrentFile;
27  class Chunk;
28  class PreallocationThread;
29 }
30 
31 using namespace bt;
32 
33 class BTCache : public QObject, public bt::Cache
34 {
35  Q_OBJECT
36  public:
37  BTCache(bt::Torrent & tor,const QString & tmpdir,const QString & datadir);
38  ~BTCache();
39 
44  virtual void loadFileMap() {}
45 
49  virtual void saveFileMap() {}
50 
55  virtual QString getOutputPath() const {return QString();}
56 
62  virtual void changeTmpDir(const QString & ndir) {Q_UNUSED(ndir)}
63 
69  virtual void changeOutputPath(const QString & outputpath) {Q_UNUSED(outputpath)}
70 
76  virtual KJob* moveDataFiles(const QString & ndir) {return 0;}
77 
82  virtual void moveDataFilesFinished(KJob* job) {Q_UNUSED(job)}
83 
89  virtual void load(Chunk* c);
90 
96  virtual void save(Chunk* c);
97 
103  virtual bool prep(Chunk* c);
104 
108  virtual void create() {}
109 
113  virtual void close() {}
114 
118  virtual void open() {}
119 
121  virtual void downloadStatusChanged(TorrentFile*, bool) {}
122 
127  virtual void preallocateDiskSpace(PreallocationThread* prealloc) {Q_UNUSED(prealloc)}
128 
133  virtual bool hasMissingFiles(QStringList & sl) {return false;} //We never have missing files, cause we don't have files :P
134 
139  virtual KJob* deleteDataFiles() {return 0;}//TODO: Implement!!!
140  virtual bt::PieceData* loadPiece(bt::Chunk*, bt::Uint32, bt::Uint32) {return 0;}
141  virtual bt::PieceData* preparePiece(bt::Chunk*, bt::Uint32, bt::Uint32) {return 0;}
142  virtual void savePiece(bt::PieceData*) {}
143 
147  virtual Uint64 diskUsage() {return 0;};//We always use 0 Bytes on HDD, cause we don't write to HDD
148 
149  signals:
150  void dataArrived(const KIO::fileoffset_t &offset, const QByteArray &data);
151 
152  private:
153  Torrent *m_tor;
154 };
155 
156 class BTCacheFactory : public QObject, public CacheFactory
157 {
158  Q_OBJECT
159  public:
160  BTCacheFactory() {}
161  ~BTCacheFactory() {}
162 
163  virtual Cache* create(Torrent & tor,const QString & tmpdir,const QString & datadir);
164 
165  signals:
166  void cacheAdded(BTCache* cache);
167 };
168 
169 #endif
BTCache::loadFileMap
virtual void loadFileMap()
Load the file map of a torrent.
Definition: btcache.h:44
BTCache::downloadStatusChanged
virtual void downloadStatusChanged(TorrentFile *, bool)
Does nothing, can be overridden to be alerted of download status changes of a TorrentFile.
Definition: btcache.h:121
BTCache::changeOutputPath
virtual void changeOutputPath(const QString &outputpath)
Changes output path.
Definition: btcache.h:69
BTCacheFactory::BTCacheFactory
BTCacheFactory()
Definition: btcache.h:160
BTCache::create
virtual void create()
Create all the data files to store the data.
Definition: btcache.h:108
QObject
BTCache::close
virtual void close()
Close the cache file(s).
Definition: btcache.h:113
BTCache::preparePiece
virtual bt::PieceData * preparePiece(bt::Chunk *, bt::Uint32, bt::Uint32)
Definition: btcache.h:141
BTCache::saveFileMap
virtual void saveFileMap()
Save the file map of a torrent.
Definition: btcache.h:49
BTCache::hasMissingFiles
virtual bool hasMissingFiles(QStringList &sl)
Test all files and see if they are not missing.
Definition: btcache.h:133
BTCacheFactory
Definition: btcache.h:156
BTCache::moveDataFilesFinished
virtual void moveDataFilesFinished(KJob *job)
A move of a bunch of data files has finished.
Definition: btcache.h:82
BTCache::open
virtual void open()
Open the cache file(s)
Definition: btcache.h:118
BTCacheFactory::~BTCacheFactory
~BTCacheFactory()
Definition: btcache.h:161
BTCache::savePiece
virtual void savePiece(bt::PieceData *)
Definition: btcache.h:142
BTCache::changeTmpDir
virtual void changeTmpDir(const QString &ndir)
Changes the tmp dir.
Definition: btcache.h:62
BTCache::diskUsage
virtual Uint64 diskUsage()
Get the number of bytes all the files of this torrent are currently using on disk.
Definition: btcache.h:147
BTCache::loadPiece
virtual bt::PieceData * loadPiece(bt::Chunk *, bt::Uint32, bt::Uint32)
Definition: btcache.h:140
BTCache::moveDataFiles
virtual KJob * moveDataFiles(const QString &ndir)
Move the data files to a new directory.
Definition: btcache.h:76
BTCache::getOutputPath
virtual QString getOutputPath() const
Get the actual output path.
Definition: btcache.h:55
BTCache::deleteDataFiles
virtual KJob * deleteDataFiles()
Delete all data files, in case of multi file torrents empty directories should also be deleted...
Definition: btcache.h:139
CacheFactory
KJob
BTCache::preallocateDiskSpace
virtual void preallocateDiskSpace(PreallocationThread *prealloc)
Preallocate diskspace for all files.
Definition: btcache.h:127
BTCache
Definition: btcache.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal