[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/ioslaves/kio_magnet
From: Christian Weilbach <christian () whiletaker ! homeip ! net>
Date: 2010-09-15 13:51:56
Message-ID: 20100915135156.F31C2AC88C () svn ! kde ! org
[Download RAW message or body]
SVN commit 1175656 by weilbach:
Ask on unkown licenses and wait on loaded but unfinished torrents.
M +1 -1 kio_magnet.cpp
M +18 -5 ktorrentdbusinterface.cpp
--- trunk/playground/ioslaves/kio_magnet/kio_magnet.cpp #1175655:1175656
@@ -136,7 +136,7 @@
return;
}
- int ps = 0;
+ qulonglong ps = 0;
while (!file.atEnd()) {
QByteArray d = file.read(max_ipc_size);
data(d);
--- trunk/playground/ioslaves/kio_magnet/ktorrentdbusinterface.cpp #1175655:1175656
@@ -33,6 +33,7 @@
#include <kstandarddirs.h>
#include <KUrl>
#include <kdebug.h>
+#include <kmessagebox.h>
const int timeout = 5000;
const int repeat = 6;
@@ -171,7 +172,14 @@
m_lic = (licIndex!=-1 && aSize>licIndex ) ? args[licIndex+1] : "unkown";
if ( !MagnetSettings::allowedLicenses().contains(m_lic) ) {
if (MagnetSettings::recheckUnknownLicense()) {
- kDebug() << "TODO find the right gui way to ask";
+ if ( m_slave->messageBox(KIO::SlaveBase::WarningYesNo,
+ i18n("The magnet-link for \"%1\" has the \
license \"%2\". When you proceed you might break the\ + \
law of your country, as you start distributing the file yourself.\ + \
Would you like to continue?").arg(url.queryItemValue("dn")).arg(m_lic), + \
i18n("License issue")) != KMessageBox::Yes ) { + kDebug()<<"license \
rejected."; + m_slave->close();
+ }
} else {
m_slave->error(KIO::ERR_ABORTED,i18n("The license\"%1\" is not enabled.\
You can reconfigure the licenses at \
@@ -187,15 +195,18 @@
QDBusReply<QString>name = m_torrentInt->name();
if (name.isValid()) {
kDebug() << "Torrent " + name.value() + "("+ m_tor + ") already loaded in \
KTorrent.";
- if (m_file==-1&&m_torrentInt->bytesLeftToDownload().value()==0) {
+ if (m_file==-1&&m_torrentInt->bytesLeftToDownload()==0) {
m_slave->setPath(m_torrentInt->pathOnDisk());
m_slave->setSize(m_torrentInt->totalSize());
- } else {
+ } else if (m_torrentInt->filePercentage(m_file)==100) {
+ m_torrentInt->setDoNotDownload(m_file, false);
m_slave->setPath(m_torrentInt->filePathOnDisk(m_file));
m_slave->setSize(m_torrentInt->fileSize(m_file));
+ } else { // still downloading
+ m_mutex.unlock();
+ return;
}
- m_torrentInt->setDoNotDownload(m_file, false);
m_slave->finish();
} else {
QString u;
@@ -232,11 +243,13 @@
KTorrentTorrentInterface* torrentInt = new \
org::ktorrent::torrent("org.ktorrent.ktorrent", "/torrent/"+(*it), \
QDBusConnection::sessionBus()); if (!torrentInt->isValid() || // remove \
finished/broken torrents
- (torrentInt->bytesLeft()==0 && MagnetSettings::maxShareRatio())) {
+ (torrentInt->bytesLeft()==0 && \
torrentInt->shareRatio()>=MagnetSettings::maxShareRatio())) { QStringList mt = \
MagnetSettings::managedTorrents(); mt.removeAll((*it));
MagnetSettings::setManagedTorrents( mt );
+ delete torrentInt;
m_coreInt->remove((*it),true);
+ kDebug() << "remove " << (*it) << " torrent.";
continue;
}
totalSize+=torrentInt->bytesDownloaded(); // TODO might get wrong results if \
network connection is buggy
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic