1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
SPDX-FileCopyrightText: 2005-2007 Joris Guisson <joris.guisson@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "monitor.h"
#include "chunkdownloadview.h"
#include "fileview.h"
#include "peerview.h"
#include <interfaces/chunkdownloadinterface.h>
#include <interfaces/peerinterface.h>
#include <interfaces/torrentfileinterface.h>
#include <interfaces/torrentinterface.h>
using namespace bt;
namespace kt
{
Monitor::Monitor(bt::TorrentInterface *tc, PeerView *pv, ChunkDownloadView *cdv, FileView *fv)
: tc(tc)
, pv(pv)
, cdv(cdv)
, fv(fv)
{
if (tc)
tc->setMonitor(this);
}
Monitor::~Monitor()
{
if (tc)
tc->setMonitor(nullptr);
}
void Monitor::downloadRemoved(bt::ChunkDownloadInterface *cd)
{
if (cdv)
cdv->downloadRemoved(cd);
}
void Monitor::downloadStarted(bt::ChunkDownloadInterface *cd)
{
if (cdv)
cdv->downloadAdded(cd);
}
void Monitor::peerAdded(bt::PeerInterface *peer)
{
if (pv)
pv->peerAdded(peer);
}
void Monitor::peerRemoved(bt::PeerInterface *peer)
{
if (pv)
pv->peerRemoved(peer);
}
void Monitor::stopped()
{
if (pv)
pv->removeAll();
if (cdv)
cdv->removeAll();
}
void Monitor::destroyed()
{
if (pv)
pv->removeAll();
if (cdv)
cdv->removeAll();
tc = nullptr;
}
void Monitor::filePercentageChanged(bt::TorrentFileInterface *file, float percentage)
{
if (fv)
fv->filePercentageChanged(file, percentage);
}
void Monitor::filePreviewChanged(bt::TorrentFileInterface *file, bool preview)
{
if (fv)
fv->filePreviewChanged(file, preview);
}
}
|