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

kget

btcache.cpp

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 #include "btcache.h"
00011 
00012 #include <diskio/chunk.h>
00013 
00014 #include <KDebug>
00015 #include <QDataStream>
00016 
00017 using namespace bt;
00018 //TODO: Support buffered mode?
00019 BTCache::BTCache(Torrent & tor,const QString & tmpdir,const QString & datadir)
00020   : Cache(tor, tmpdir, datadir),
00021     QObject(0)
00022 {
00023 }
00024 
00025 BTCache::~BTCache()
00026 {
00027 }
00028 
00029 void BTCache::load(Chunk* c)
00030 {
00031     c->setData(0, Chunk::MMAPPED);
00032 }
00033 
00034 void BTCache::save(Chunk* c)
00035 {
00036     /*if (c->getStatus() == Chunk::MMAPPED)
00037     {
00038         KIO::fileoffset_t off = c->getIndex() * tor.getChunkSize();
00039         kDebug(5001) << "Fileoffset is: " + QString::number(off);
00040         QByteArray data;
00041         QDataStream s(&data, QIODevice::WriteOnly | QIODevice::Unbuffered);
00042         s << c->getData();
00043         emit dataArrived(off, data);
00044         c->clear();
00045         c->setStatus(Chunk::ON_DISK);
00046     }
00047     else if (c->getStatus() == Chunk::BUFFERED)
00048     {*/
00049         KIO::fileoffset_t off = c->getIndex() * tor.getChunkSize();
00050         kDebug(5001) << "Fileoffset is: " + QString::number(off);
00051         QByteArray data;
00052         QDataStream s(&data, QIODevice::WriteOnly | QIODevice::Unbuffered);
00053         s << c->getData();
00054         emit dataArrived(off, data);
00055         //fd->write(c->getData(),c->getSize(),off);//Send a signal here that the signal has arrived
00056         c->clear();
00057         c->setStatus(Chunk::ON_DISK);
00058     //}
00059 }
00060 
00061 bool BTCache::prep(Chunk* c)
00062 {
00063     c->setData(0, Chunk::MMAPPED);
00064     return true;
00065 }
00066 
00067 void BTCache::deleteDataFiles()
00068 {
00069 }
00070 
00071 Cache* BTCacheFactory::create(Torrent & tor,const QString & tmpdir,const QString & datadir) 
00072 {
00073     BTCache *newcache = new BTCache(tor, tmpdir, datadir);
00074     emit cacheAdded(newcache);
00075     return newcache;
00076 }
00077 
00078 #include "btcache.moc"

kget

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

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal