[core-dev] Bittorrent patch
[email protected] (Gregorio Roper) Thu, 29 Jul 2004 05:18:43 +0200
| Newsgroups | gmane.network.gnutella.limewire.core.devel |
|---|---|
| Message-ID | <[email protected]> |
I spend the whole night making a version of BT that I could actually diff against the CVS HEAD branch, and finally it is working. My BT support isn't pretty but it works pretty well. You need to download the torrent and open it from the File menu to start it. This version is not backwards compatible to older LimeWire versions, so backup your downloads.dat file. Before you use it, you must add the line: "ACTIVATE_AUTO_REQUERIES=false" to your limewire.props file or all hell will break loose! mfg Gregorio _______________________________________________ core-dev mailing list [email protected] http://www.limewire.org/mailman/listinfo/core-dev
lib.diff
(text/plain, 2.2 KB)
Index: messagebundles/MessagesBundle.properties =================================================================== RCS file: /cvs/lib/messagebundles/MessagesBundle.properties,v retrieving revision 1.105 diff -u -r1.105 MessagesBundle.properties --- messagebundles/MessagesBundle.properties 23 Jul 2004 22:30:03 -0000 1.105 +++ messagebundles/MessagesBundle.properties 29 Jul 2004 02:42:37 -0000 @@ -179,6 +179,9 @@ MENU_FILE_DISCONNECT=Disconnect MENU_FILE_DISCONNECT_MNEMONIC=I MENU_FILE_DISCONNECT_ACCESSIBLE=Disconnect from the Network +MENU_FILE_OPEN_TORRENT=Open Torrent +MENU_FILE_OPEN_TORRENT_MNEMONIC=T +MENU_FILE_OPEN_TORRENT_ACCESSIBLE=Opens a .torrent file MENU_FILE_LIBRARY_ADD_SHARED_FOLDER=Add Folder to Share MENU_FILE_LIBRARY_ADD_SHARED_FOLDER_MNEMONIC=A MENU_FILE_LIBRARY_ADD_SHARED_FOLDER_ACCESSIBLE=Add a Folder that You Would Like to Share @@ -522,6 +525,8 @@ DOWNLOAD_MAGNET_DIALOG=Would you like to download DOWNLOAD_FROM=from DOWNLOAD_MAGNET_DIALOG_END=? + +TORRENTS_COULD_NOT_READ_SNAPSHOT=Sorry, but LimeWire was unable to restart your old torrents. ################################################################### # Key/value pairs for UploadView Index: .classpath =================================================================== RCS file: .classpath diff -N .classpath --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .classpath 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path=""/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path=""/> +</classpath> Index: .project =================================================================== RCS file: .project diff -N .project --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .project 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>lib</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription>
core.diff
(text/plain, 235.7 KB) - not displayed
gui.diff
(text/plain, 8.4 KB)
Index: compile.bat
===================================================================
RCS file: /cvs/gui/compile.bat,v
retrieving revision 1.10
diff -u -r1.10 compile.bat
--- compile.bat 25 Nov 2002 15:14:41 -0000 1.10
+++ compile.bat 29 Jul 2004 02:39:53 -0000
@@ -1 +1,5 @@
-ant
+set JAVA_HOME=c:\Programme\Java\jdk1.5.0
+
+set CLASSPATH=.;lib/collections.jar;lib/xerces.jar;lib/MRJToolkitStubs.jar
+
+c:\ant\bin\ant
Index: rl
===================================================================
RCS file: /cvs/gui/rl,v
retrieving revision 1.2
diff -u -r1.2 rl
--- rl 14 Jul 2004 20:39:16 -0000 1.2
+++ rl 29 Jul 2004 02:39:53 -0000
@@ -2,7 +2,7 @@
# NOTE: If you are using cygwin on Windows, the colons in the CLASSPATH
# should be replaced with semi-colons
-CLASSPATH=".;../core;../lib/messagebundles/;../lib/jars/collections.jar;../lib/jars/xerces.jar;../lib/jars/jl011.jar;../lib/jars/themes.jar;../lib/jars/logicrypto.jar;../lib/jars/mp3sp14.jar;../lib/jars/commons-httpclient.jar;../lib/jars/commons-logging.jar;../lib/jars/i18n.jar;../lib/jars/icu4j.jar;../lib/jars/ProgressTabs.jar;../lib/jars/id3v2.jar;../lib/jars/log4j.jar;../lib/jars/jcraft.jar;../lib/jars/looks.jar"
+CLASSPATH=".;../core;../lib/messagebundles/;../lib/jars/collections.jar;../lib/jars/xerces.jar;../lib/jars/jl011.jar;../lib/jars/themes.jar;../lib/jars/logicrypto.jar;../lib/jars/mp3sp14.jar;../lib/jars/commons-httpclient.jar;../lib/jars/commons-logging.jar;../lib/jars/i18n.jar;../lib/jars/icu4j.jar;../lib/jars/ProgressTabs.jar;../lib/jars/id3v2.jar;../lib/jars/log4j.jar;../lib/jars/jcraft.jar;../lib/jars/looks.jar;../lib/jars/MRJAdapter.jar"
export CLASSPATH
PATH=$PATH:../lib/native
Index: com/limegroup/gnutella/gui/GUIMediator.java
===================================================================
RCS file: /cvs/gui/com/limegroup/gnutella/gui/GUIMediator.java,v
retrieving revision 1.139
diff -u -r1.139 GUIMediator.java
--- com/limegroup/gnutella/gui/GUIMediator.java 26 Jul 2004 17:55:35 -0000 1.139
+++ com/limegroup/gnutella/gui/GUIMediator.java 29 Jul 2004 02:39:54 -0000
@@ -695,6 +695,13 @@
}
/**
+ * Tells the DownloadMediator to open a torrent
+ */
+ public final void openTorrent() {
+ DOWNLOAD_MEDIATOR.openTorrent();
+ }
+
+ /**
* Tells the library to add a new top-level (shared) folder.
*/
public final void addSharedLibraryFolder() {
Index: com/limegroup/gnutella/gui/download/DownloadDataLine.java
===================================================================
RCS file: /cvs/gui/com/limegroup/gnutella/gui/download/DownloadDataLine.java,v
retrieving revision 1.43
diff -u -r1.43 DownloadDataLine.java
--- com/limegroup/gnutella/gui/download/DownloadDataLine.java 21 Jul 2004 14:54:49 -0000 1.43
+++ com/limegroup/gnutella/gui/download/DownloadDataLine.java 29 Jul 2004 02:39:56 -0000
@@ -215,7 +215,7 @@
/**
* Variable for the amount of the file that has been read.
*/
- private int _amountRead = 0;
+ private long _amountRead = 0;
/**
* Variable for the progress made in the progressbar.
@@ -235,7 +235,7 @@
/**
* Variable for the size of the download.
*/
- private int _size = -1;
+ private long _size = -1;
/**
* Variable for the speed of the download.
@@ -532,7 +532,7 @@
*
* @return the total size in bytes of the file being downloaded
*/
- int getLength() {
+ long getLength() {
return _size;
}
Index: com/limegroup/gnutella/gui/download/DownloadMediator.java
===================================================================
RCS file: /cvs/gui/com/limegroup/gnutella/gui/download/DownloadMediator.java,v
retrieving revision 1.45
diff -u -r1.45 DownloadMediator.java
--- com/limegroup/gnutella/gui/download/DownloadMediator.java 21 Jul 2004 14:54:49 -0000 1.45
+++ com/limegroup/gnutella/gui/download/DownloadMediator.java 29 Jul 2004 02:39:56 -0000
@@ -3,6 +3,7 @@
import com.limegroup.gnutella.gui.tables.*;
import com.limegroup.gnutella.gui.GUIMediator;
import com.limegroup.gnutella.gui.PaddedPanel;
+import com.limegroup.gnutella.gui.FileChooserHandler;
import com.limegroup.gnutella.*;
import com.limegroup.gnutella.settings.QuestionsHandler;
import com.limegroup.gnutella.downloader.*;
@@ -235,6 +236,22 @@
DownloadDataLine ddl = (DownloadDataLine)DATA_MODEL.get(downloader);
if (ddl != null) ddl.setEndTime(System.currentTimeMillis());
}
+ }
+
+ public void openTorrent() {
+ File file = FileChooserHandler.getInputFile();
+ if (file == null)
+ return;
+ try {
+ java.io.FileInputStream fis = new java.io.FileInputStream(file);
+ add(RouterService.downloadTorrent(fis));
+ } catch (java.io.FileNotFoundException fnfe) {
+ ErrorService.error(fnfe);
+ } catch (Throwable t) {
+ ErrorService.error(t);
+ }
+
+
}
private File copyToThemeDir(File themeFile) {
Index: com/limegroup/gnutella/gui/library/LibraryTableModel.java
===================================================================
RCS file: /cvs/gui/com/limegroup/gnutella/gui/library/LibraryTableModel.java,v
retrieving revision 1.15
diff -u -r1.15 LibraryTableModel.java
--- com/limegroup/gnutella/gui/library/LibraryTableModel.java 21 Jul 2004 14:54:49 -0000 1.15
+++ com/limegroup/gnutella/gui/library/LibraryTableModel.java 29 Jul 2004 02:39:57 -0000
@@ -147,7 +147,7 @@
*
* @return A <code>int</code> object containing the size of the file
*/
- int getSize(int row) {
+ long getSize(int row) {
return ((SizeHolder)(
(ColoredCellImpl)get(row).getValueAt(
LibraryTableDataLine.SIZE_IDX)).getValue()).getSize();
Index: com/limegroup/gnutella/gui/menu/FileMenu.java
===================================================================
RCS file: /cvs/gui/com/limegroup/gnutella/gui/menu/FileMenu.java,v
retrieving revision 1.18
diff -u -r1.18 FileMenu.java
--- com/limegroup/gnutella/gui/menu/FileMenu.java 7 May 2004 22:59:40 -0000 1.18
+++ com/limegroup/gnutella/gui/menu/FileMenu.java 29 Jul 2004 02:39:58 -0000
@@ -80,6 +80,16 @@
ErrorService.error(t);
}
}
+ }));
+ MENU.add(getMenuItem("MENU_FILE_OPEN_TORRENT",
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ GUIMediator.instance().openTorrent();
+ } catch(Throwable t) {
+ ErrorService.error(t);
+ }
+ }
}));
MENU.addSeparator();
MENU.add(getMenuItem("MENU_FILE_LIBRARY_ADD_SHARED_FOLDER",
@@ -200,7 +210,17 @@
ErrorService.error(t);
}
}
- }));
+ }));
+ MENU.add(getMenuItem("MENU_FILE_OPEN_TORRENT",
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ GUIMediator.instance().openTorrent();
+ } catch(Throwable t) {
+ ErrorService.error(t);
+ }
+ }
+ }));
if(!CommonUtils.isMacOSX()) {
MENU.addSeparator();
MENU.add(getMenuItem("MENU_FILE_CLOSE",
Index: com/limegroup/gnutella/gui/tables/SizeHolder.java
===================================================================
RCS file: /cvs/gui/com/limegroup/gnutella/gui/tables/SizeHolder.java,v
retrieving revision 1.2
diff -u -r1.2 SizeHolder.java
--- com/limegroup/gnutella/gui/tables/SizeHolder.java 29 Oct 2002 01:35:30 -0000 1.2
+++ com/limegroup/gnutella/gui/tables/SizeHolder.java 29 Jul 2004 02:40:00 -0000
@@ -17,7 +17,7 @@
/**
* Variable for the size of the file in kilobytes.
*/
- private int _size;
+ private long _size;
/**
* The constructor sets the size and string variables, creating a
@@ -25,14 +25,19 @@
*
* @param size the size of the file in kilobytes
*/
- public SizeHolder(int size) {
+ public SizeHolder(long size) {
_string = GUIUtils.toUnitbytes(size);
_size = size;
}
public int compareTo(Object o) {
- int otherSize = ((SizeHolder)o).getSize();
- return _size - otherSize;
+ long otherSize = ((SizeHolder)o).getSize();
+ if (_size > otherSize)
+ return 1;
+ else if (_size < otherSize)
+ return -1;
+ else
+ return 0;
}
/**
@@ -50,7 +55,7 @@
*
* @param size the new size to hold
*/
- public void setSize(int size) {
+ public void setSize(long size) {
if(size == _size) return;
_string = GUIUtils.toUnitbytes(size);
_size = size;
@@ -61,7 +66,7 @@
*
* @return the size of the file in kilobytes
*/
- public int getSize() {
+ public long getSize() {
return _size;
}
}