<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>136063</bug_id>
          
          <creation_ts>2006-10-21 01:35:35 +0000</creation_ts>
          <short_desc>partfileimportplugin&apos;s .torrent fetcher should be network-transparent</short_desc>
          <delta_ts>2007-05-19 13:37:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>ktorrent</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Stefan Monov">logixoul</reporter>
          <assigned_to name="Joris Guisson">joris.guisson</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>478651</commentid>
    <comment_count>0</comment_count>
    <who name="Stefan Monov">logixoul</who>
    <bug_when>2006-10-21 01:35:35 +0000</bug_when>
    <thetext>Version:           2.0.3 (using KDE 3.5.5 &quot;release 19.1&quot; , openSUSE )
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.16.21-0.25-default

How to reproduce:
Try to import a partially downloaded torrent with the following descriptor file:
http://example.com/something.torrent

Observed result:
Cannot load the torrent file : Unable to open torrent file /something.torrent : No such file or directory</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>478695</commentid>
    <comment_count>1</comment_count>
    <who name="Joris Guisson">joris.guisson</who>
    <bug_when>2006-10-21 11:08:53 +0000</bug_when>
    <thetext>We do not support this at the moment, don&apos;t know when we can add this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>526764</commentid>
    <comment_count>2</comment_count>
    <who name="Joris Guisson">joris.guisson</who>
    <bug_when>2007-05-19 13:37:40 +0000</bug_when>
    <thetext>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 &lt;kurlrequester.h&gt;
 #include &lt;kpushbutton.h&gt;
 #include &lt;kmessagebox.h&gt;
+#include &lt;kio/job.h&gt;
+#include &lt;kio/jobclasses.h&gt;
 #include &lt;util/log.h&gt;
 #include &lt;util/error.h&gt;
 #include &lt;util/file.h&gt;
@@ -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 &amp; tor)
 	{
-		m_progress-&gt;setEnabled(true);
-		m_import_btn-&gt;setEnabled(false);
-		m_cancel_btn-&gt;setEnabled(false);
-		m_torrent_url-&gt;setEnabled(false);
-		m_data_url-&gt;setEnabled(false);
-		
 		// get the urls
 		KURL tor_url = KURL::fromPathOrURL(m_torrent_url-&gt;url());
 		KURL data_url = KURL::fromPathOrURL(m_data_url-&gt;url());
-		Torrent tor;
 		
-		// try to load the torrent
-		try
-		{
-			tor.load(tor_url.path(),false);
-		}
-		catch (Error &amp; e)
-		{
-			KMessageBox::error(this,i18n(&quot;Cannot load the torrent file : %1&quot;).arg(e.toString()),
-							   i18n(&quot;Error&quot;));
-			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-&gt;error())
+		{
+			j-&gt;showErrorDialog(this);
+			reject();
+		}
+		else
+		{
+			KIO::StoredTransferJob* stj = (KIO::StoredTransferJob*)j;
+			Torrent tor;
+		
+			// try to load the torrent
+			try
+			{
+				tor.load(stj-&gt;data(),false);
+			}
+			catch (Error &amp; e)
+			{
+				KMessageBox::error(this,i18n(&quot;Cannot load the torrent file : %1&quot;).arg(e.toString()),
+								   i18n(&quot;Error&quot;));
+				reject();
+				return;
+			}
+			import(tor);
+		}
+	}
+	
+	void ImportDialog::onImport()
+	{
+		m_progress-&gt;setEnabled(true);
+		m_import_btn-&gt;setEnabled(false);
+		m_cancel_btn-&gt;setEnabled(false);
+		m_torrent_url-&gt;setEnabled(false);
+		m_data_url-&gt;setEnabled(false);
+		
+		KURL tor_url = KURL::fromPathOrURL(m_torrent_url-&gt;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-&gt;url());
+			Torrent tor;
+		
+			// try to load the torrent
+			try
+			{
+				tor.load(tor_url.path(),false);
+			}
+			catch (Error &amp; e)
+			{
+				KMessageBox::error(this,i18n(&quot;Cannot load the torrent file : %1&quot;).arg(e.toString()),
+								   i18n(&quot;Error&quot;));
+				reject();
+				return;
+			}
+			import(tor);
+		}
+	}
+	
 	void ImportDialog::writeIndex(const QString &amp; file,const BitSet &amp; 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 &amp; file,const bt::BitSet &amp; chunks);
@@ -61,6 +67,8 @@
 		virtual void status(bt::Uint32 num_failed,bt::Uint32 num_downloaded);
 		virtual void finished();
 		
+		void import(bt::Torrent &amp; tor);
+		
 	private:
 		CoreInterface* core;
 	};
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>