| Summary: | partfileimportplugin's .torrent fetcher should be network-transparent | ||
|---|---|---|---|
| Product: | [Applications] ktorrent | Reporter: | Stefan Monov <logixoul> |
| Component: | general | Assignee: | Joris Guisson <joris.guisson> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Stefan Monov
2006-10-21 01:35:35 UTC
We do not support this at the moment, don't know when we can add this. SVN commit 666284 by guisson:
Made import dialog network transparent for the torrent file
BUG: 136063
M +1 -0 ChangeLog
M +67 -21 plugins/partfileimport/importdialog.cpp
M +8 -0 plugins/partfileimport/importdialog.h
--- trunk/extragear/network/ktorrent/ChangeLog #666283:666284
@@ -26,6 +26,7 @@
- Improved system tray popup icon : we now use boxed style KPassivePopup instead of Qt tooltips, it also only disappears when the cursor
is moved away from the tray icon and the text can be updated
- The log now gets autorotated when it gets larger then 10 MB
+- Import dialog is now network transparent for the torrent file
Changes in 2.1.4
- Fixed crash in parsing of DHT messages
--- trunk/extragear/network/ktorrent/plugins/partfileimport/importdialog.cpp #666283:666284
@@ -23,6 +23,8 @@
#include <kurlrequester.h>
#include <kpushbutton.h>
#include <kmessagebox.h>
+#include <kio/job.h>
+#include <kio/jobclasses.h>
#include <util/log.h>
#include <util/error.h>
#include <util/file.h>
@@ -74,32 +76,12 @@
// only used for check in separate thread, so does not apply for the import plugin
}
- void ImportDialog::onImport()
+ void ImportDialog::import(Torrent & tor)
{
- m_progress->setEnabled(true);
- m_import_btn->setEnabled(false);
- m_cancel_btn->setEnabled(false);
- m_torrent_url->setEnabled(false);
- m_data_url->setEnabled(false);
-
// get the urls
KURL tor_url = KURL::fromPathOrURL(m_torrent_url->url());
KURL data_url = KURL::fromPathOrURL(m_data_url->url());
- Torrent tor;
- // try to load the torrent
- try
- {
- tor.load(tor_url.path(),false);
- }
- catch (Error & e)
- {
- KMessageBox::error(this,i18n("Cannot load the torrent file : %1").arg(e.toString()),
- i18n("Error"));
- reject();
- return;
- }
-
// now we need to check the data
DataChecker* dc = 0;
if (tor.isMultiFile())
@@ -203,6 +185,70 @@
accept();
}
+ void ImportDialog::onTorrentGetReult(KIO::Job* j)
+ {
+ if (j->error())
+ {
+ j->showErrorDialog(this);
+ reject();
+ }
+ else
+ {
+ KIO::StoredTransferJob* stj = (KIO::StoredTransferJob*)j;
+ Torrent tor;
+
+ // try to load the torrent
+ try
+ {
+ tor.load(stj->data(),false);
+ }
+ catch (Error & e)
+ {
+ KMessageBox::error(this,i18n("Cannot load the torrent file : %1").arg(e.toString()),
+ i18n("Error"));
+ reject();
+ return;
+ }
+ import(tor);
+ }
+ }
+
+ void ImportDialog::onImport()
+ {
+ m_progress->setEnabled(true);
+ m_import_btn->setEnabled(false);
+ m_cancel_btn->setEnabled(false);
+ m_torrent_url->setEnabled(false);
+ m_data_url->setEnabled(false);
+
+ KURL tor_url = KURL::fromPathOrURL(m_torrent_url->url());
+ if (!tor_url.isLocalFile())
+ {
+ // download the torrent file
+ KIO::StoredTransferJob* j = KIO::storedGet(tor_url);
+ connect(j,SIGNAL(result(KIO::Job* )),this,SLOT(onTorrentGetReult(KIO::Job*)));
+ }
+ else
+ {
+ KURL tor_url = KURL::fromPathOrURL(m_torrent_url->url());
+ Torrent tor;
+
+ // try to load the torrent
+ try
+ {
+ tor.load(tor_url.path(),false);
+ }
+ catch (Error & e)
+ {
+ KMessageBox::error(this,i18n("Cannot load the torrent file : %1").arg(e.toString()),
+ i18n("Error"));
+ reject();
+ return;
+ }
+ import(tor);
+ }
+ }
+
void ImportDialog::writeIndex(const QString & file,const BitSet & chunks)
{
// first try to open it
--- trunk/extragear/network/ktorrent/plugins/partfileimport/importdialog.h #666283:666284
@@ -33,7 +33,12 @@
class Torrent;
}
+namespace KIO
+{
+ class Job;
+}
+
namespace kt
{
class CoreInterface;
@@ -48,6 +53,7 @@
public slots:
void onImport();
+ void onTorrentGetReult(KIO::Job* j);
private:
void writeIndex(const QString & file,const bt::BitSet & chunks);
@@ -61,6 +67,8 @@
virtual void status(bt::Uint32 num_failed,bt::Uint32 num_downloaded);
virtual void finished();
+ void import(bt::Torrent & tor);
+
private:
CoreInterface* core;
};
|