PK wC8 META-INF/PK vC8_ivMETA-INF/MANIFEST.MFManifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 1.6.0_02-b06 (Sun Microsystems Inc.) Main-Class: BJTorrent.GUI.Principal Class-Path: X-COMMENT: Main-Class will be added automatically by build PK wC8 BJTorrent/PK wC8BJTorrent/ConexionServer/PK wC8BJTorrent/ControlDescarga/PK wC8BJTorrent/FicheroTorrent/PK wC8BJTorrent/GUI/PK wC8BJTorrent/GUI/iconos/PK wC8BJTorrent/GUI/properties/PK wC8BJTorrent/P2P/PK vC8BJTorrent/Tracker/PK wC8BJTorrent/Traker/PK vC8z{P= = -BJTorrent/ConexionServer/ConexionServer.class2 'V &W &X &YZ V &[\ ] &^ &_` ab Vc d e f gh i &j &kl mnop q rO s &tu vwxy server_socketLjava/net/ServerSocket;runZpuertoI escuchadores%Ljavax/swing/event/EventListenerList;()VCodeLineNumberTableLocalVariableTablethis)LBJTorrent/ConexionServer/ConexionServer;conectar(I)ZioeLjava/io/IOException; StackMapTable`pararie Ljava/lang/InterruptedException;b[BAncreaConexionServerEscuchador.(LBJTorrent/ControlDescarga/DownloadTorrent;)V escuchador+LBJTorrent/ControlDescarga/DownloadTorrent;leeConexionServerEscuchadores.()[LBJTorrent/ControlDescarga/DownloadTorrent;eliminaConexionServerEscuchadorlanzaConexionAceptada(Ljava/net/Socket;)V4LBJTorrent/ControlDescarga/ConexionServerEscuchador;arr$,[LBJTorrent/ControlDescarga/DownloadTorrent;len$i$sLjava/net/Socket; SourceFileConexionServer.java 01 () *+ ,-#javax/swing/event/EventListenerList ./java/net/ServerSocket 0z {| }1java/io/IOException ~1java/lang/StringBuilder0No se pudo cerrar el socket daemon por el puerto    KL Error en ConexionServer: java/lang/InterruptedExceptionCerrado el socket daemon)BJTorrent/ControlDescarga/DownloadTorrent HIAceptada Conexion por puerto  L'BJTorrent/ConexionServer/ConexionServerjava/lang/Thread(I)V setDaemon(Z)Vstartcloseappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;BJTorrent/Salidaescribe(Ljava/lang/String;)Vaccept()Ljava/net/Socket;sleep(J)V getMessageadd-(Ljava/lang/Class;Ljava/util/EventListener;)V getListeners-(Ljava/lang/Class;)[Ljava/util/EventListener;remove2BJTorrent/ControlDescarga/ConexionServerEscuchadorconexionAceptada!&'()*+,-./012]*****Y3-# %')14 56782**Y * * M 3;<=>?@A4 9:56,-;\<=12*** LY*  3HJ MKL)N49:*56;O<*12GL***!MY,M #  @3. WY [\ e#`$a=e@cAgFh4*$9:A>?G56C@A;BB<\CDE2D *+3 r s4 56 FGHI28* !3z4 56!JE2D *+"3  4 56 FGKL2?*#M,>60,2:Y$*+%б308>4>!FM9NO6P- 3Q-?56?RS;  !2TUPK wC8,BJTorrent/ConexionServer/ConexionServer.java/* * ConexionesServer.java * * Created on 18 de noviembre de 2007, 17:39 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.ConexionServer; import BJTorrent.ControlDescarga.DownloadTorrent; import BJTorrent.Salida; import BJTorrent.ControlDescarga.ConexionServerEscuchador; /** * * @author Benjamn Muiz Garca */ import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import javax.swing.event.EventListenerList; /** * * Subclase de Thread que acepta conexiones por el puerto indicado en VentanaPreferencias * y que cuando se conecta con un peer lanza un evento a la clase DownloadTorrent. * */ public class ConexionServer extends Thread{ //Socket servidor por el que aceptamos conexiones de peers private ServerSocket server_socket = null; //Atributo que indica si el hilo debe seguir ejecutndose private boolean run = true; //Nmero de puerto por el que escucha y acepta conexiones el socker servidor. private int puerto=0; //Lista de objetos que esperan eventos private final EventListenerList escuchadores = new EventListenerList(); /** * Crea una nueva instancia de ConexionServer */ public ConexionServer() { } /** * Crea el socket servidor por el puerto pasado como argumento y arranca la ejecucin del hilo. * @param puerto int Nmero de puerto por el se crea el socket servidor que escucha */ public boolean conectar(int puerto){ try { this.puerto=puerto; this.server_socket = new ServerSocket(puerto); this.setDaemon(true); this.start(); return true; } catch (IOException ioe) {} return false; } /** * * Mtodo que para el hilo y cierra el socket del servidor */ public void parar() { this.run=false; try{ this.server_socket.close(); } catch (IOException ioe){ Salida.escribe("No se pudo cerrar el socket daemon por el puerto"+this.puerto); } } /** * * Mientras corre el hilo acepta conexiones, cada vez que es aceptada una conexin * con un peer se llama al mtodo lanzaConexionAceptada() * */ public void run() { byte[] b = new byte[0]; try { while (this.run==true) { this.lanzaConexionAceptada(this.server_socket.accept()); sleep(1000); } } catch (IOException ioe) { Salida.escribe("Error en ConexionServer: "+ioe.getMessage()); } catch(InterruptedException ie){ } Salida.escribe("Cerrado el socket daemon"); } /** * * Guarda un objeto de la clase DonwloadTorrent en la lista de escuchadores que esperan * un evento. * @param escuchador DownloadTorrent Objeto que almacenamos en la lista de escuchadores */ public void creaConexionServerEscuchador(DownloadTorrent escuchador) { escuchadores.add(DownloadTorrent.class, escuchador); } /** * * Devuelve la lista de escuchadores que son objetos DownloadTorrent que esperan un evento. * @return DownloadTorrent[] Objetos de la clase DownloadTorrrent que llamarn al mtodo creaConexinServerEscuchador. */ public DownloadTorrent[] leeConexionServerEscuchadores() { return escuchadores.getListeners(DownloadTorrent.class); } /** * * Quita un objeto de la lista de escuchadores de esta instancia de ConexionServer * @param escuchador DownloadTorrent Objeto a ser eliminado de la lista de escuchadores * */ public synchronized void eliminaConexionServerEscuchador(DownloadTorrent escuchador) { escuchadores.remove(DownloadTorrent.class, escuchador); } /** * * Mtodo que llama al mtodo conexionAceptada() de los objetos la clase DownloadTorrent * almacenados en la lista de escuchadores. * @param s Socket conectado al peer remoto */ public void lanzaConexionAceptada(Socket s){ for (ConexionServerEscuchador escuchador : leeConexionServerEscuchadores()) { //Salida.escribeVentana("Aceptada Conexion por puerto "+this.puerto); Salida.escribe("Aceptada Conexion por puerto "+this.puerto); escuchador.conexionAceptada(s); } } }PK wC8~BJTorrent/Constantes.class2r UVWXYZ[\]^_`abcdef g hi jklDEBUGZ ConstantValueERRORICHOKEUNCHOKE INTERESTEDNOT_INTERESTEDHAVEBITFIELDREQUESTPIECECANCEL KEEP_ALIVE  PEER_CON_COLAd PEER_SIN_COLAeHAVE_ALL HAVE_NONE SUGGEST_PIECE REJECT_REQUEST ALLOWED_FASTMENSAJE[Ljava/lang/String; TAM_BLOQUE@BYTES_TAM_BLOQUE[BPROGRAMALjava/lang/String;mVERSIONn()VCodeLineNumberTableLocalVariableTablethisLBJTorrent/Constantes; SourceFileConstantes.java KLjava/lang/String Choke/BANNED Unchoke/UNBAN Interesado No_Interesado Have/TengoBitfieldPeticion BloqueTransmitiendo BloqueCancelar Peticion Keep_Alive Suggest PieceHave ALL Have NONEReject Request Allowed Fast @Ao pq DEBJTorrent/Constantesjava/lang/ObjectBJBT0.3.0.0BJTorrent/UtilsintToByteArray(I)[B! !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIGJKLM/*NO PQRLMxYSYSYSYSYSYSY SY SY SY  SY  SY  SY  SY SYSYSYSYS@N <nESTPK wC8RՌ BJTorrent/Constantes.java/* * ProtocoloPeers.java * * Created on 1 de noviembre de 2007, 16:08 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Benjamn Muiz Garca */ package BJTorrent; /** * * Declara constantes usadas en el programa, como el nmero entero y cadena de caracteres * que sirve para identificar cada mensaje del protocolo, el tamao del bloque en bytes, etc... * * */ public class Constantes { public static final boolean DEBUG = true; public static final int ERROR = -1; public static final int CHOKE = 0; public static final int UNCHOKE = 1; public static final int INTERESTED = 2; public static final int NOT_INTERESTED = 3; public static final int HAVE = 4; public static final int BITFIELD = 5; public static final int REQUEST = 6; public static final int PIECE = 7; public static final int CANCEL = 8; public static final int KEEP_ALIVE = 9; //indica que el peer puede almacenar varias peticiones de bloques y podemos pedir //un bloque sin haber recibido el anterior. public static final int PEER_CON_COLA = 100; //indica que el peer no tiene cola y no recuerda las peticiones por lo que //slo podemos pedirle un bloque de cada vez public static final int PEER_SIN_COLA = 101; //Have All: public static final int HAVE_ALL = 0x0E; //Have None: public static final int HAVE_NONE = 0x0F; //Suggest Piece: public static final int SUGGEST_PIECE = 0x0D; //Reject Request: public static final int REJECT_REQUEST = 0x10; //Allowed Fast: public static final int ALLOWED_FAST = 0x11; public static final String[] MENSAJE = {"Choke/BANNED", "Unchoke/UNBAN", "Interesado", "No_Interesado", "Have/Tengo", "Bitfield", "Peticion Bloque", "Transmitiendo Bloque", "Cancelar Peticion", "Keep_Alive","","","","Suggest Piece","Have ALL", "Have NONE","Reject Request","Allowed Fast"}; //Tamo en bytes de cada bloque que compone una pieza public static final int TAM_BLOQUE = 16384; public static final byte[] BYTES_TAM_BLOQUE = Utils.intToByteArray(16384); public static final String PROGRAMA = "BJBT"; public static final String VERSION = "0.3.0.0"; } PK vC8m8BJTorrent/ControlDescarga/ConexionServerEscuchador.class2   conexionAceptada(Ljava/net/Socket;)V SourceFileConexionServerEscuchador.java2BJTorrent/ControlDescarga/ConexionServerEscuchadorjava/lang/Objectjava/util/EventListenerPK wC8'q>7BJTorrent/ControlDescarga/ConexionServerEscuchador.java/* * ConexionesServerEscuchador.java * * Created on 18 de noviembre de 2007, 17:48 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.ControlDescarga; import BJTorrent.ConexionServer.ConexionServer; /** * * @author Benjamn Muiz Garca */ import java.util.EventListener; import java.net.Socket; /** * Interface implementado en la clase DownloadTorrent */ public interface ConexionServerEscuchador extends EventListener{ /** * * Evento que nos informa que el socket servidor * acept una conexin de un peer, lanzado por un objeto ConexionServer. * @param s Socket conectado al peer */ public void conexionAceptada(Socket s); }PK vC8ƌ@@/BJTorrent/ControlDescarga/DownloadTorrent.class2                                $  '                7           7 D  7 D D 7 '     R D D $  ' $,  a a ] a  g  g g $ T'  '         ~   i       7    R ] ] ] ] R    !  " ]#$ %&' ( ) *e + ,  %   -. / 0 1 23 456 27 a8 ]9:;< = > ? @ gABCD ]EF ZF ]GHI@Y JK ZLM ]N O P Q ]R 'ST 'UVWXY ListaPiezas[LBJTorrent/Pieza; id_cliente[Btorrente*LBJTorrent/FicheroTorrent/FicheroTorrente; num_piezasI tam_piezatrackerLBJTorrent/Tracker/Tracker; ListaTrackersLjava/util/LinkedList; Signature*Ljava/util/LinkedList;intervalo_trackertracker_elegidoLjava/lang/String; infohashURL num_ficheroslongitudJfaltanbajadosbajados_sesionsubidos ListaPeersLjava/util/LinkedHashMap;=Ljava/util/LinkedHashMap;tam_ultima_piezaFicheroCompletado(Ljava/util/LinkedList;PeersDisponiblesLjava/util/TreeMap;@Ljava/util/TreeMap; peersdownloadpeersnointeresados peerschocked ListaChocked1Ljava/util/LinkedList;unchokeoptimistarunZparandosumaDLDsumaULsemillasclientessalidaLBJTorrent/Salida;prefs#LBJTorrent/GUI/VentanaPreferencias;conexLBJTorrent/P2P/Conexion; KBenviados KBrecibidos KBpedidostiempoULlimiteULlimiteDLpath proxyhost proxypuertopuerto handshakeLBJTorrent/Handshake; escuchadores%Ljavax/swing/event/EventListenerList;Y([BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/util/LinkedList;JJ)VCodeLineNumberTableLocalVariableTablethis+LBJTorrent/ControlDescarga/DownloadTorrent;torrentLocalVariableTypeTablek([BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/util/LinkedList;JJ)V pararDownload()VeLjava/lang/Exception;cpLBJTorrent/P2P/Protocolo;itLjava/util/Iterator;b lconexionesLjava/util/List;+Ljava/util/List; StackMapTableWZ[actualizaIntervaloTracker(I)V intervaloactualizaListaPeers.(Ljava/util/LinkedHashMap;Ljava/lang/String;)VpLBJTorrent/Peer;listatrackerElegido conexiones peerstring(Ljava/util/Iterator;ie Ljava/lang/InterruptedException;ioeLjava/io/IOException; primeravez unchokePeers peerschokediunchokeOptimistadownloadCompleto()Z leeFaltan()J leeSubidosleeBajadosSesioncreaEscuchador"(LBJTorrent/GUI/VentanaDownload;)V escuchadorLBJTorrent/GUI/VentanaDownload;eliminaEscuchadorleeEscuchadores"()[LBJTorrent/GUI/VentanaDownload;actualizaTablasGUIY([[Ljava/lang/String;IJJLjava/util/LinkedList;Ljava/util/LinkedList;Ljava/lang/String;I)Varr$ [LBJTorrent/GUI/VentanaDownload;len$i$cadenas[[Ljava/lang/String;num_cad fichcompleto fichlongitudintervaloTrackeractualizaFicheroCompletadokauxLjava/lang/Long;pieza faltanleerleidosposbuff ficheroleidos[JposicionposfichjwconexionAceptada(Ljava/net/Socket;)VsocketLjava/net/Socket;idcreaTorrenteAbiertoEscuchador(LBJTorrent/GUI/Principal;)VLBJTorrent/GUI/Principal; eliminaTorrenteAbiertoEscuchadorleeTorrenteAbiertoEscuchadores()[LBJTorrent/GUI/Principal;actualizaVelocidadesactualizaTorrenteAbierto[LBJTorrent/GUI/Principal; recibidaPieza enviadoBloquetamconexionActiva.(Ljava/lang/String;LBJTorrent/P2P/Protocolo;)V conexionFin(Ljava/lang/String;)V SourceFileDownloadTorrent.java )  java/util/LinkedList        !BJTorrent/GUI/VentanaPreferencias     #javax/swing/event/EventListenerList  java/util/LinkedHashMap java/util/TreeMap \ ]^ _^ `a bX cd ef g^BJTorrent/Salida h    if j^  k^  lf m^ n^ BJTorrent/Tracker/Tracker op q r st u)Parando Torrente vw xy zZ {|[ }V ~BJTorrent/P2P/Protocolo )java/lang/ExceptionProblema parando hilo Protocolo  java/lang/String  BJTorrent/Peer java/lang/StringBuilderLanzado  fBJTorrent/P2P/Conexion    t Error lanzando conexiones Terminamos de esperar 10 segs f ^)TORRENTE PARADO - Todos los peers parados Q) ) )    X java/lang/InterruptedExceptionError en run() DownloadTorrent UVDescarga completada  bc ) )java/io/IOException%No se pudo Cerrar el fichero de traza v3BJTorrent/ControlDescarga/VelocidadSubidaComparador 3BJTorrent/ControlDescarga/VelocidadBajadaComparador @A V V V   <   T)  f unchoke optimista VBJTorrent/GUI/VentanaDownload     `a java/lang/Long ^    f: ^  Pendiente conexion con peer  por el puerto BJTorrent/Handshake     Aceptada conexion con peer HANDSHAKE fallido con el peer BJTorrent/GUI/Principal    Total:    Kb/seg V   n< <%Llegamos a añadir el peer disponibleConexion fin- final &Llegamos a eliminar el peer disponible)BJTorrent/ControlDescarga/DownloadTorrentjava/lang/Thread2BJTorrent/ControlDescarga/ConexionServerEscuchadorjava/util/Listjava/util/Iterator(BJTorrent/FicheroTorrent/FicheroTorrente leeNumPiezas()I leeTamPieza leeLongitud()Ljava/lang/Long; longValue leeTrackers()Ljava/util/LinkedList;leeInfoHashURL()Ljava/lang/String;leeNumFicherosnombrelee_directorioCompartidoleeLimiteVelocidadULleeLimiteVelocidadDL leeProxySOCKSleeProxySOCKSPuerto leePuertotrazaLjava/io/BufferedWriter;H(Ljava/util/LinkedList;[BLjava/lang/String;JJJLjava/io/BufferedWriter;)VescribeVentanacreaTrackerEscuchador.(LBJTorrent/ControlDescarga/DownloadTorrent;)Vstartescribe-(Ljava/lang/String;Ljava/io/BufferedWriter;)Vvalues()Ljava/util/Collection;(Ljava/util/Collection;)Viterator()Ljava/util/Iterator;hasNextnext()Ljava/lang/Object;pararstopkeySet()Ljava/util/Set; java/util/Set containsKey(Ljava/lang/Object;)Zget&(Ljava/lang/Object;)Ljava/lang/Object;sleep(J)Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString info_hash(LBJTorrent/Peer;[B[BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/io/BufferedWriter;Ljava/lang/String;Ljava/lang/String;I)VcreaConexionEscuchadorput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;getNamesizejava/lang/SystemcurrentTimeMillisListaLongitudesjava/io/BufferedWriterflushclosejava/util/Collectionssort)(Ljava/util/List;Ljava/util/Comparator;)Vlee_hecho_Bitfieldlee_El_Interesado lee_El_Chokedpon_El_Chocked(Z)VenviaLBJTorrent/P2P/EnviarMensaje;BJTorrent/P2P/EnviarMensajeescribeMensajecontainsadd removeFirst leeIdClienteBJTorrent/Pieza leeCompleta-(Ljava/lang/Class;Ljava/util/EventListener;)Vremove getListeners-(Ljava/lang/Class;)[Ljava/util/EventListener;getListenerCount(Ljava/lang/Class;)I(I)Ljava/lang/Object;intValuevalueOf(J)Ljava/lang/Long;set'(ILjava/lang/Object;)Ljava/lang/Object;java/net/SocketgetInetAddress()Ljava/net/InetAddress;java/net/InetAddressgetHostAddressgetPort(I)Ljava/lang/StringBuilder;(Ljava/lang/String;I)V<(LBJTorrent/Peer;Ljava/net/Socket;Ljava/io/BufferedWriter;)V leeHandShake([B[B)ZescribeHandShake([B[B)V(LBJTorrent/Peer;Ljava/net/Socket;[B[BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/io/BufferedWriter;Ljava/lang/String;LBJTorrent/Handshake;)VleeVelocidadUL(Z)F(F)Ljava/lang/String;leeVelocidadDLjava/lang/Mathround(D)J(D)Ljava/lang/String; esSemillaactualizaTorrrenteAbiertoD(Ljava/lang/String;JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)VescribeListaHave!.             **x**** * * * * * * ***Y********Y***8* Y!"*+#*$Y%&*'Y()*,**,+,*,-.*,/0*,12*,3*-4*5* **,6*7Y**89:**W;*W*W<=*W*W>?**W@**WA**WBC*DY*2+** * *:EFG*:W*H*G*I*GJ!5C EGJL N%P*R/T4]9g>iCkHmSoXq]sbugwlyq{v '4AMYe"H#$%& '() NjLK*:ELY*)MNN-O:P&QRM,S:U*:EL*GV*GW*<@CT!. 1<@T\di">E *+<,-'-./j#$f0K12& K134@'567856978:567!;< >*! "#$=!>?  *,>:+XY:PQZ:*)[+\]:*W^`aYbcdedf*:EL*gY*#**h***4*:E***ij*j*k*jl*&emW&:aYbndodf*:EL3CT!J+,- . 0,384C7K:l;<=>C@AFK"R!*+C@A./#$BCD E& .F4/G85HGG8I:")  <**Wp`aYbrd*sdf*:EL**)t*u*:EL*v*w*xyz{|}*Y d$MaYbd,df*:EL*^ZH6Y*)MN:*YYO:PQR::T&* *W*Y`E*YZd **!!  /;NZailq|"\ Z,-a@AD./#$R S12& 134N /57 8' 59I782" 57T) Q*I*RL+6++aYb+ddf*:EL+!" !)LP";,-Q#$4  A9UV t <*,*42! "S #$4 WX /*!" #$YX /* ! " #$ZX /* !" #$[\ D *"+!  " #$ ]^_\ D *"+! ' )" #$ ]^`a 8*"!1" #$bc  C*"*:  6 6   "  2:+!  ݱ!E FH*J<HBP" *]^.de )f &g C#$ChiCjCCCkClCC Cm 4 %!n< C *42=>6** :**h776 ** +** e77 P  6  **J P** d>  P Pd= 7  6  **5*5 0 /a: *5  W P ű!zZ [ \]^&_*`-bFc^dbehgnj~knoqsvxz|}j"z rSo pq >o #$r s tuvw&x*y-z 4)- 5{@7=!|} # *aYb+dd+fM*),[T]Y++NaYbd-edd+f*:EL*Y-+*:E**#**h**#**h*&-e-mW*gY-+*#**h***4*:E**j*j*k*jlaYbd-edd*WBfHaYbd-edd*WBf*:EL3aYbd-edd*WBf*:EL!F)4Gs"U"*G>@A#$~)]4LGI/ D *"+!  " #$ ] D *"+!  " #$ ] 8*"!" #$)  }*)t`L6Y*)MN:*YY**O:PsQRM,N+2-S+2-eS+2-nS+2-nS*Y-nc*Y-nc+2S+2S**k**Ɋo**k**Ɋo+2aYb*ʶd˶dfS+2aYb*ʶd˶dfS*+* * *5****!v")8DINalq{ 8WZ | "Hle,-q`@AWz./}#$nhikS"[12& "[134857 8y) Y*)MNM**,ON-P2-QRL+*Y`*Y`>*:66@2:**8** * *****4*5΄!6 )3>KX!Z#v$#*"\ 3%,- 8./v0]`LdeGfhDg#$12ZSS& 134D 78*5978 5757C!< %z*Y *42a *Y *42a *Y*42e*ϻY*)MNN-O:PQRM,:Ч߱!. 56&799>>MA_BjCpDvGyJ">p@Aj,-U$./z#$zrM-12& M-134U78#!< D *Y a ! Q R" #$  u"*)+[ *)+,W*:EL!^ _a!c" "#$"",-4 z-*:EL*)+[*)+W*:EL!l no p,s"-#$-4,) 5yz{ }! PK wC8kzbb.BJTorrent/ControlDescarga/DownloadTorrent.java/* * DownloadTorrent.java * * Created on 16 de noviembre de 2007, 14:35 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.ControlDescarga; import BJTorrent.Peer; import BJTorrent.Pieza; import BJTorrent.Handshake; import BJTorrent.Salida; import BJTorrent.Constantes; import BJTorrent.GUI.VentanaPreferencias; import BJTorrent.GUI.Principal; import BJTorrent.GUI.VentanaDownload; import BJTorrent.ConexionServer.ConexionServer; import BJTorrent.FicheroTorrent.FicheroTorrente; import BJTorrent.Tracker.Tracker; import BJTorrent.P2P.Conexion; import BJTorrent.P2P.Protocolo; /** * * @author Benjamn Muiz Garca */ import java.util.BitSet; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.io.IOException; import java.util.Iterator; import java.util.Collections; import java.util.TreeMap; import java.security.MessageDigest; import java.net.Socket; import javax.swing.event.EventListenerList; import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; /** * Clase que maneja los peers devueltos por el tracker creando un hilo conexin para cada peer * , tambin cada cierto intervalo actualiza el interfaz de la ventana principal y VentanaDownload. * */ public class DownloadTorrent extends Thread implements ConexionServerEscuchador{ //Array de piezas que componen el torrente public Pieza[] ListaPiezas; //ID de nuestro cliente generada al arrancar la aplicacin private byte[] id_cliente; //Objeto que almacena la informacin del fichero .torrent private FicheroTorrente torrente; //Nmero de piezas que componen el torrente private int num_piezas; //Tamao de la pieza excepto la ltima private int tam_pieza; //Hilo del tracker private Tracker tracker; //Lista de Trackers private LinkedList ListaTrackers; //Segundos de intervalo entre actualizaciones con el tracker private int intervalo_tracker=2 * 60; //IP o dominio del Tracker private String tracker_elegido=""; //Hash SHA1 del torrente en codificacin URL private String infohashURL=""; //Nmero de ficheros del torrente private int num_ficheros = 0; //tamao total en bytes del torrente private long longitud = 0; //Nmero de bytes que faltan para completar el download private long faltan = 0; //Nmero de bytes descargados de otros peer en este torrente private long bajados=0; //Nmero de bytes bajados de otros peer en esta descarga o sesin private long bajados_sesion=0; //Nmero de bytes subidos a otros peer en esta descarga o sesin private long subidos=0; //Mapa que almacena los peers devueltos por el Tracker private LinkedHashMap ListaPeers; //Tamao de la ultima pieza private int tam_ultima_pieza=0; //Lista con el nmero de bytes descargados de cada fichero del torrente private LinkedList FicheroCompletado; //Mapa con los PeersDisponibles, peers con los que estamos conectados private TreeMap PeersDisponibles; //Nmero de peers que estn descargando de nuestro cliente en este torrente private int peersdownload=0; //Nmero de peers que no interesados en nuestras piezas de nuestro cliente en este torrente private int peersnointeresados=0; //Nmero de peers que tenemos CHOKE. Cade 30 segundos hacemos un UNCHOKE optimista a un peer, eso si tenemos mas de 4 peers downloaders private int peerschocked=0; //peers downloaders que tenemos CHOKE private LinkedList ListaChocked = new LinkedList(); //indica el intervalo entre un UNCHOKE optimista cuando tenemos ms downloaders de los permitidos. private int unchokeoptimista = 3; //Indica si este objeto sigue ejecutndose public boolean run=true; //Indica que se quiere parar el download, este hilo private boolean parando=false; //Suma de la velocidades de download de todos los peers private double sumaDL=0; //Suma de la velocidades de upload de todos los peers private double sumaUL=0; //Nmero de semillas del torrente private int semillas=0; //Nmero de cliente del torrente private int clientes=0; //Fichero por el que escribimos la traza de ejecucin del programa private Salida salida; private VentanaPreferencias prefs=new VentanaPreferencias(); //Objeto con el que instanciamos hilos Conexion para cada peer private Conexion conex; //Nmero de KB enviados mientras el atributo tiempoUL no supera un cierto lmite de tiempo. public static int KBenviados=0; //Nmero de KB recibidos para comprobar el limite de velocidad de bajada de la aplicacin. public static int KBrecibidos=0; //Nmero de KB pedidos con el mensaje REQUESTS nunca rebasa el limiteDL, para fijar el limte maximo de download public static int KBpedidos=0; //Tiempo en el que medimos la velocidad de Upload, antes de poner el atributo KBenviados a cero. public static long tiempoUL=0; //Velocidad mxima de Upload establecida en VentanaPreferencias public static int limiteUL; //Velocidad mxima de Download establecida en VentanaPreferencias public static int limiteDL; //ruta o path desde donde almacenamos los ficheros que componen el torrente private String path=""; //IP o nombre del host que hace como proxy private String proxyhost=""; //Nmero de puerto SOCKS del proxy private int proxypuerto=1080; //Puerto de VentanaPreferencias por el que aceptamos conexiones private int puerto; //Objeto con el que se realiza el handshake con el peer remoto, cuando se acepta una conexin por el socket servidor. Handshake handshake; //Lista de objetos que esperan eventos private final EventListenerList escuchadores = new EventListenerList(); /** * Crea una nueva instancia de DownloadTorrent. * Almacena las preferencias de VentanaPreferencias en atributos del objeto. * Arranca el hilo que se anuncia con el tracker. * @param id_cliente byte ID con el cdigo el programa versin. * @param torrent FicheroTorrente Objeto que almacena los datos del fichero METAINFO .torrent * @param ListaPiezas Pieza[] Array con las piezas del torrente * @param FicheroCompletado LinkedList * @param faltan long Nmero de bytes que faltan para completar el download * @param bajados long Nmero de bytes bajados de otros peer en este torrente */ public DownloadTorrent(byte[] id_cliente, FicheroTorrente torrent,Pieza[] ListaPiezas, LinkedList FicheroCompletado,long faltan,long bajados){ this.id_cliente = id_cliente; this.ListaPeers =new LinkedHashMap(); this.PeersDisponibles = new TreeMap (); this.torrente=torrent; this.num_piezas = torrent.leeNumPiezas(); this.tam_pieza=torrent.leeTamPieza(); this.longitud=torrent.leeLongitud(); this.ListaTrackers=torrent.leeTrackers(); this.infohashURL=torrent.leeInfoHashURL(); // this.faltan = this.longitud; //this.ListaPiezas = new Pieza[this.num_piezas]; this.ListaPiezas = ListaPiezas; this.FicheroCompletado=FicheroCompletado; this.bajados=bajados; this.faltan=faltan; this.num_ficheros = torrent.leeNumFicheros(); this.salida= new Salida(this.torrente.nombre); this.path=prefs.lee_directorioCompartido(); this.limiteUL=prefs.leeLimiteVelocidadUL(); this.limiteDL=prefs.leeLimiteVelocidadDL(); this.proxyhost=prefs.leeProxySOCKS(); this.proxypuerto=prefs.leeProxySOCKSPuerto(); this.puerto=prefs.leePuerto(); this.tracker=new Tracker(ListaTrackers,id_cliente,infohashURL,faltan,bajados_sesion,subidos,salida.traza); salida.escribeVentana(infohashURL); this.tracker.creaTrackerEscuchador(this); this.tracker.start(); } /** * Mtodo que para la ejecucin los hilos Protocolo que envan y reciben mensajes de los peers, * tambin para la ejecucin del hilo tracker y cierra el fichero de traza de este torrente. */ public void pararDownload(){ byte []b=new byte[0]; Salida.escribe("Parando Torrente",salida.traza); //anunciarse(this.trackerElegido, this.id_cliente,this.infohashURL,this.faltan,this.bajados,this.subidos,"&event=Stopped"); Protocolo cp; List lconexiones = new LinkedList(this.PeersDisponibles.values()); for (Iterator it = lconexiones.iterator();it.hasNext(); ) { cp = (Protocolo) it.next(); try{ cp.parar(); //Salida.escribe("Parando el hilo "+cp.getName(),salida.traza); } catch (Exception e) {Salida.escribe("Problema parando hilo Protocolo",salida.traza);} } //tracker.TrackerSTOPPEDCOMPLETED(this.id_cliente,this.infohashURL,this.faltan,this.bajados,this.subidos,"stopped"); tracker.stop=true; tracker.run=false; this.parando=true; //this.run=false; /*do { try{ this.sleep(1000); Salida.escribe("Esperamos 1 segundo antes de cerrar",salida.traza); } catch (InterruptedException ie){} } while(this.PeersDisponibles.size()>0); */ //this.PeersDisponibles=null; //this.ListaPeers=null; } /** * Almacena los segundos de intervalo entre actualizaciones con el Tracker * en un atributo de la clase. Mtodo invocado desde el objeto Tracker cuando el host tracker * nos responde positivamente. * @param intervalo int Segundos que deben pasar para actualizar el tracker. */ public synchronized void actualizaIntervaloTracker(int intervalo){ this.intervalo_tracker=intervalo; //en segundos } /** * * Mtodo invocado desde el objeto Tracker cuando un host Tracker responde * con la lista de peers del torrente. * @param lista LinkedHashMap Lista con los peers disponibles en el torrente * @param trackerElegido String Tracker que nos respondi */ public synchronized void actualizaListaPeers(LinkedHashMap lista,String trackerElegido) { this.tracker_elegido=trackerElegido; int conexiones=0; String peerstring=""; for (Iterator it = lista.keySet().iterator(); it.hasNext(); ) { peerstring = (String) it.next(); if (!this.PeersDisponibles.containsKey(peerstring)) { Peer p = (Peer) lista.get(peerstring); try{ this.sleep(300); // Salida.escribeVentana("Lanzado "+p.toString(),2); Salida.escribe("Lanzado "+p.toString(),salida.traza); conex=new Conexion(p,this.id_cliente,this.torrente.info_hash,this.torrente,this.ListaPiezas,salida.traza,this.path,this.proxyhost,this.proxypuerto); conex.creaConexionEscuchador(this); conex.start(); this.ListaPeers.put(p.toString(), p); } catch (Exception e) { Salida.escribe("Error lanzando conexiones "+e.toString(),salida.traza); //this.run=false; } }//fin if }//fin for //ultimaActualizacion=System.currentTimeMillis(); } /** * Mientras el hilo corre, cada 10 segundos hace unchoke de los peers y actualiza * el interfaz. Actualiza el componente JTable de la ventana Principal y * la ventana VentanaDownload del GUI. Llama a los mtodos unchokePeers(), actualizaVelocidades(), * y actualizaTorrenteAbierto(). * Mtodo sobre-escrito. */ public void run() { //byte[] b = new byte[0]; boolean primeravez=true; while (this.run) { //actualizamos Velocidades cado 10 segundos // Y damos CHOKE/UNCHOKE cada 10 try { this.sleep(10000); Salida.escribe("Terminamos de esperar 10 segs "+this.getName(),salida.traza); //synchronized (lock) { // lock.wait(10000); if (this.parando && this.PeersDisponibles.size()==0) { this.run=false; Salida.escribe("TORRENTE PARADO - Todos los peers parados",salida.traza); } unchokePeers(); actualizaVelocidades(); actualizaTorrenteAbierto(); KBenviados=0; KBrecibidos=0; KBpedidos=0; tiempoUL=System.currentTimeMillis();; intervalo_tracker-=10; //lock.notifyAll(); //} } catch (InterruptedException ie) { Salida.escribe("Error en run() DownloadTorrent"+ie.toString(),salida.traza); //this.run=false; } if (downloadCompleto() && primeravez) { // tracker.TrackerSTOPPEDCOMPLETED(this.id_cliente,this.infohashURL,this.faltan,this.bajados,this.subidos,"completed"); Salida.escribeVentana("Descarga completada"); primeravez=false; } }//fin while run actualizaTablasGUI(null,0,this.bajados,this.subidos,this.FicheroCompletado,this.torrente.ListaLongitudes,"",0); try{ salida.traza.flush(); salida.traza.close(); } catch(IOException ioe) { Salida.escribe("No se pudo Cerrar el fichero de traza"); } } /** * Pone UNCHOKE a los peers, y slo permite que tengamos 4 peers bajndose * piezas de nuestro cliente poniendo el resto de peers que bajan piezas a CHOKE. * Slo permite 4 peers downloaders quedndose con los que tienen mayor velocidad * de subida y al resto de downloaders los pone a CHOKE y los mete en la listaChoked. */ public void unchokePeers(){ int peersnointeresados = 0; int peersdownload = 0; int peerschoked = 0; Protocolo cp; Peer p; int i=0; //Salida.escribe("Enviando Unchokes cada 10 segundos\n\n\n"); List lconexiones = new LinkedList(this.PeersDisponibles.values()); if (downloadCompleto()) Collections.sort(lconexiones, new VelocidadSubidaComparador()); else Collections.sort(lconexiones, new VelocidadBajadaComparador()); //Iterator itp = lpeers.iterator(); for (Iterator it = lconexiones.iterator();it.hasNext(); ) { cp = (Protocolo) it.next(); p=(Peer) cp.p; if (!p.lee_hecho_Bitfield()) break; if (peersdownload < 4) { if (!cp.p.lee_El_Interesado()) { if (cp.p.lee_El_Choked()) { cp.p.pon_El_Chocked(false); cp.envia.escribeMensaje(Constantes.UNCHOKE); peersnointeresados++; } } else if (cp.p.lee_El_Choked()) { // this.Unchoke.put(p.toString(), p); cp.p.pon_El_Chocked(false); cp.envia.escribeMensaje(Constantes.UNCHOKE); peersdownload++; } } else { if (!cp.p.lee_El_Choked()) { cp.p.pon_El_Chocked(true); cp.envia.escribeMensaje(Constantes.CHOKE); } if (!this.ListaChocked.contains(cp)) this.ListaChocked.add(cp); peerschocked++; } } if (this.unchokeoptimista-- == 0) { this.unchokeOptimista(); this.unchokeoptimista = 3; } } /** * Cada 30 segundos hacemos un UNCHOKE optimista a un peer downloader de la listaChoked, * para ello tenemos que tener mas de 4 peers downloaders. */ private void unchokeOptimista() { if (this.ListaChocked.size()>0) { Protocolo cp; do { cp = this.ListaChocked.removeFirst(); if (cp!=null) { cp.envia.escribeMensaje(Constantes.UNCHOKE); cp.p.pon_El_Chocked(false); Salida.escribe(cp.p.leeIdCliente() + " unchoke optimista",salida.traza); } } while (cp==null); } } /** * Indica si se han descargado todas las piezas * @return boolean true si el torrente se ha descargado por completo y false si quedan * piezas por recibir. */ public boolean downloadCompleto(){ for (int i=0;i=this.torrente.ListaLongitudes.get(j).intValue()) { posicion=posicion -this.torrente.ListaLongitudes.get(j).intValue(); posfich=posicion; ficheroleidos[j]=0; j++; } for (int k = j; k < this.torrente.num_ficheros; k++) { ficheroleidos[k]=0; leidos=(int)this.torrente.ListaLongitudes.get(k).intValue()-(int)posfich; if (faltanleer<=leidos) { ficheroleidos[k]=faltanleer; break; } else { if (leidos<=0) break; ficheroleidos[k]=leidos; faltanleer=faltanleer-leidos; posfich=0; } } for (int k = j; k < this.torrente.num_ficheros; k++) { Long aux=this.FicheroCompletado.get(k)+ficheroleidos[k]; FicheroCompletado.set(k,aux); //Salida.escribe("Completado->"+FicheroCompletado[k]); ficheroleidos[k]=0; } } /** * Mtodo llamado por un objeto de la clase ConexionServer cuando el socket servidor * acepta una conexin de un peer. * Hacemos el handshake para comprobar que el peer comparte este torrente * y no otros que estemos descargando. Si hacemos correctamente el handshake el peer * remoto comparte este torrente y creamos el hilo conexin como si se tratase * de un peer devuelto por el tracker. * @param socket Socket conectado al peer */ public synchronized void conexionAceptada(Socket socket){ if (this.run==false) return; String id = socket.getInetAddress().getHostAddress() +":" + socket.getPort(); if (PeersDisponibles.containsKey(id)==false) { Peer p=new Peer(socket.getInetAddress().getHostAddress(),socket.getPort()); Salida.escribe("Pendiente conexion con peer "+p.toString()+" por el puerto "+socket.getPort(),salida.traza); handshake=new Handshake(p,socket,salida.traza); if (handshake.leeHandShake(this.id_cliente,this.torrente.info_hash)) { handshake.escribeHandShake(this.id_cliente,this.torrente.info_hash); ListaPeers.put(p.toString(), p); conex=new Conexion(p,socket,this.id_cliente,this.torrente.info_hash,this.torrente,this.ListaPiezas,salida.traza,this.path,handshake); conex.creaConexionEscuchador(this); conex.start(); Salida.escribeVentana("Aceptada conexion con peer "+p.toString()+" por el puerto "+this.prefs.leePuerto()); Salida.escribe("Aceptada conexion con peer "+p.toString()+" por el puerto "+this.prefs.leePuerto(),salida.traza); } else Salida.escribe("HANDSHAKE fallido con el peer "+p.toString()+" por el puerto "+this.prefs.leePuerto(),salida.traza); } } /** * Guarda en la lista de escuchadores al objeto de la ventana Principal pasado como argumento * @param escuchador Objeto Principal */ public void creaTorrenteAbiertoEscuchador(Principal escuchador) { //Salida.escribe("Aadido Listener DownloadTorrent"); escuchadores.add(Principal.class, escuchador); } /** * Elimima de la lista de escuchadores al objeto Principal pasado como argumento * @param escuchador Objeto Principal */ public void eliminaTorrenteAbiertoEscuchador(Principal escuchador) { escuchadores.remove(Principal.class, escuchador); } /** * Devuelve el objeto de la clase Principal de la lista de * escuchadores. * @return Principal[] Objetos de la lista de escuchadores */ public Principal[] leeTorrenteAbiertoEscuchadores() { return escuchadores.getListeners(Principal.class); } /** * * Mtodo que bsicamente prepara los datos para ser mostrados por el interfaz y * despus llama al mtodo ActivualizaTablasGUI(). * */ public void actualizaVelocidades(){ String [][]cadenas=new String[this.PeersDisponibles.size()+1][4]; Protocolo cp; Peer p; int i=0; List lconexiones = new LinkedList(this.PeersDisponibles.values()); if (!this.downloadCompleto()) Collections.sort(lconexiones, new VelocidadSubidaComparador()); else Collections.sort(lconexiones, new VelocidadBajadaComparador()); this.sumaUL=0; this.sumaDL=0; //Iterator itp = lpeers.iterator(); for (Iterator it = lconexiones.iterator();it.hasNext(); ) { cp = (Protocolo) it.next(); p=(Peer) cp.p; cadenas[i][0]=p.leeIdCliente(); cadenas[i][1]=p.toString(); cadenas[i][2]=String.valueOf(p.leeVelocidadUL(false) / (1024 * 10)); cadenas[i][3]=String.valueOf(p.leeVelocidadDL(false) / (1024 * 10)); this.sumaUL+=(p.leeVelocidadUL(true) / (1024 * 10)); this.sumaDL+=(p.leeVelocidadDL(true) / (1024 * 10)); i++; } cadenas[i][0]=" "; cadenas[i][1]="Total: "; sumaUL=sumaUL*100; sumaUL=(Math.round(sumaUL)/100.0); sumaDL=sumaDL*100; sumaDL=(Math.round(sumaDL)/100.0); cadenas[i][2]=String.valueOf(sumaUL)+" Kb/seg"; cadenas[i][3]=String.valueOf(sumaDL)+" Kb/seg"; i++; actualizaTablasGUI(cadenas,i,this.bajados,this.subidos,this.FicheroCompletado,this.torrente.ListaLongitudes,this.tracker_elegido,this.intervalo_tracker); } /** * Mtodo que llama al mtodo actualizaTorrrenteAbierto() del objeto Principal que * est en la lista de escuchadores. * Sirve para actualizar el interfaz de la ventana Principal. */ public void actualizaTorrenteAbierto(){ Protocolo cp; List lconexiones = new LinkedList(this.PeersDisponibles.values()); this.semillas=0; this.clientes=0; for (Iterator it = lconexiones.iterator();it.hasNext(); ) { cp = (Protocolo) it.next(); if (cp.p.esSemilla()==true) this.semillas++; else this.clientes++; } int i=0; //quitar for (Principal escuchador : leeTorrenteAbiertoEscuchadores()) { escuchador.actualizaTorrrenteAbierto(this.torrente.nombre,this.faltan,this.bajados,this.subidos, this.sumaUL, this.sumaDL, this.semillas, this.clientes, this.ListaPiezas,this.FicheroCompletado); } } /** * Indica que hemos recibido una pieza. * Actualiza el nmero de bytes 'bajados', bytes que 'faltan' por descargar, * en este torrente. Tambin llama al mtodo a actualizaFicheroCompletado(pieza). * @param pieza int Nmero de pieza recibida. */ public synchronized void recibidaPieza(int pieza){ this.bajados+=ListaPiezas[pieza].leeTamPieza(); this.bajados_sesion+=ListaPiezas[pieza].leeTamPieza(); this.faltan-=ListaPiezas[pieza].leeTamPieza(); actualizaFicheroCompletado(pieza);//interfaz - progreso del torrente y ficheros Protocolo cp; List lconexiones = new LinkedList(this.PeersDisponibles.values()); for (Iterator it = lconexiones.iterator();it.hasNext(); ) { cp = (Protocolo) it.next(); Peer p=cp.p; p.escribeListaHave(pieza); } } /** * Indica que se ha enviado un bloque. Actualiza el nmero de bytes 'subidos' * por el cliente en este torrente. * @param tam int Tamao en bytes del bloque */ public synchronized void enviadoBloque(int tam){ this.subidos+=tam; } /** * * Indica que estamos conectados a un peer y se ha realizado correctamente el handshake. * Almacenamos el peer en el mapa PeersDisponibles. * @param id String ID del peer * @param cp Protocolo Objeto que enva/recibe mensajes del peer. */ public void conexionActiva(String id,Protocolo cp) { if (!this.PeersDisponibles.containsKey(id)) this.PeersDisponibles.put(id, cp); Salida.escribe("Llegamos a aadir el peer disponible",salida.traza); } /** * Indica que se ha realizado mal el handshake o que hemos perdidos la conexin con el * peer. Borramos el peer del mapa PeersDisponibles. * @param id String ID del peer */ public void conexionFin(String id){ Salida.escribe("Conexion fin- final\n",salida.traza); if (this.PeersDisponibles.containsKey(id)) { this.PeersDisponibles.remove(id); Salida.escribe("Llegamos a eliminar el peer disponible",salida.traza); } } } PK wC8g[%//9BJTorrent/ControlDescarga/VelocidadBajadaComparador.class2'    !"()VCodeLineNumberTableLocalVariableTablethis5LBJTorrent/ControlDescarga/VelocidadBajadaComparador;compare'(Ljava/lang/Object;Ljava/lang/Object;)IaLBJTorrent/Peer;bxLjava/lang/Object;y StackMapTable# SourceFileVelocidadBajadaComparador.java  BJTorrent/P2P/Protocolo $# %&3BJTorrent/ControlDescarga/VelocidadBajadaComparadorjava/lang/Objectjava/util/ComparatorBJTorrent/PeerpleeVelocidadDL(Z)F!  /*    C+=,6+N,:-- "&(),.-0.?/A2 4+"C CC0PK wC8-#N8BJTorrent/ControlDescarga/VelocidadBajadaComparador.java/* * VelocidadBajadaComparador.java * * Created on 10 de noviembre de 2007, 15:43 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.ControlDescarga; import BJTorrent.Peer; import BJTorrent.P2P.Protocolo; import java.util.Comparator; /** * * Clase que implementa el interfaz Comparator. Sirve para ordenar los peers por su velocidad * de bajada. * */ public class VelocidadBajadaComparador implements Comparator { /** * Compara la velocidad de bajada de 2 objetos Peer desde nuestro cliente. * * @param x Object el primer objeto Peer que va a ser comparado * @param y Object el segundo objeto Peer que va a ser comparado * @return int -1 si el primer objeto tiene una velocidad de bajada mayor que el segundo, * 1 si el primer objeto Peer tiene una velocidad de bajada inferior al segundo, * y 0 en caso de igualdad. */ public int compare(Object x, Object y) { if (x instanceof Protocolo && y instanceof Protocolo) { Peer a=((Protocolo) x).p; Peer b=((Protocolo) y).p; if (((Peer) a).leeVelocidadDL(false) > ((Peer) b).leeVelocidadDL(false)) return -1; else if (((Peer) a).leeVelocidadDL(false) < ((Peer) b).leeVelocidadDL(false)) return 1; } return 0; } } PK wC8r//9BJTorrent/ControlDescarga/VelocidadSubidaComparador.class2'    !"()VCodeLineNumberTableLocalVariableTablethis5LBJTorrent/ControlDescarga/VelocidadSubidaComparador;compare'(Ljava/lang/Object;Ljava/lang/Object;)IaLBJTorrent/Peer;bxLjava/lang/Object;y StackMapTable# SourceFileVelocidadSubidaComparador.java  BJTorrent/P2P/Protocolo $# %&3BJTorrent/ControlDescarga/VelocidadSubidaComparadorjava/lang/Objectjava/util/ComparatorBJTorrent/PeerpleeVelocidadUL(Z)F!  /*    C+=,6+N,:-- "')*-..0/?0A3 4+"C CC0PK wC8m8BJTorrent/ControlDescarga/VelocidadSubidaComparador.java/* * VelocidadSubidaComparador.java * * Created on 10 de noviembre de 2007, 14:43 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.ControlDescarga; import BJTorrent.Peer; import BJTorrent.P2P.Protocolo; import java.util.Comparator; /** * * Clase que implementa el interfaz Comparator. * Sirve para ordenar los peers por su velocidad de bajada. * */ public class VelocidadSubidaComparador implements Comparator { /** * Compara la velocidad de subida de 2 objetos Peer a nuestro cliente * * @param x Object el primer objeto Peer que va a ser comparado * @param y Object el segundo objeto Peer que va a ser comparado * @return int -1 si el primer objeto tiene una velocidad de subida mayor que el segundo, * 1 si el primer objeto Peer tiene una velocidad de subida inferior al segundo, * y 0 en caso de igualdad. */ public int compare(Object x, Object y) { if (x instanceof Protocolo && y instanceof Protocolo) { Peer a=((Protocolo) x).p; Peer b=((Protocolo) y).p; if (((Peer) a).leeVelocidadUL(false) > ((Peer) b).leeVelocidadUL(false)) return -1; else if (((Peer) a).leeVelocidadUL(false) < ((Peer) b).leeVelocidadUL(false)) return 1; } return 0; } } PK vC8m!!.BJTorrent/FicheroTorrent/FicheroTorrente.class2 r q q q q q q q q q q q q q q q q q q q  q ? q q   %  %  % % %   K q    q   ? q q K q !" q# $% $&' () (* +,- U. T/ T %0 T123 45 46 47 489 a :; d <= <>? K@A (BC KD KE KFGHIdatos[Binfo info_hash infohashURLLjava/lang/String; infohashhex datos_cadenaposI pos_ini_info pos_fin_info pos_ini_hash ListaTrackersLjava/util/LinkedList; Signature*Ljava/util/LinkedList; ListaFicheros ListaRutasListaLongitudes(Ljava/util/LinkedList; num_ficherosanuncionombrelongitudJ tam_pieza num_piezasfLjava/io/File;ficherotorrentLjava/io/RandomAccessFile;(Ljava/io/File;)VCodeLineNumberTableLocalVariableTableioeLjava/io/IOException;this*LBJTorrent/FicheroTorrent/FicheroTorrente; StackMapTableHJleeInfoHashURL()Ljava/lang/String; leeAnnounce leeNumPiezas()I leeTamPieza leeLongitud()Ljava/lang/Long;leeNumFicheros leePiezaSHA1(I)[Bjindiceinihash20t leeNombre leeTrackers()Ljava/util/LinkedList;,()Ljava/util/LinkedList; parseTorrent()Zi leerBytes()VbBtambytes f_in_torrentLjava/io/DataInputStream;, hash_SHA1()[BmdLjava/security/MessageDigest;nsae(Ljava/security/NoSuchAlgorithmException;eLjava/lang/Exception;9; leeBEntero()Jvalor leeBCadena valor_cad! leeBTrackers leeBFicherostamsepauxaux2 SourceFileFicheroTorrente.java st ut vt wx yx zx }| ~|java/util/LinkedList | x x | | java/io/RandomAccessFiler K java/io/IOException3Error accediendo aleatoriamente al fichero torrenteL MN OP | {| QR STjava/lang/StringBuilder U VW- XY VZ [Pos Ini piezas: V\ pos ] ^_!Fallo leyendo la SHA1 de la pieza` aN d8:announce bc  announce: de4:nameNombre del Torrente: 4:info5:files f ghjava/lang/Long i6:length  piece length6:pieces jk13:announce-list Tracker : java/lang/String 7:private l mn on HASH SHA1: J p ? qrjava/io/DataInputStreamjava/io/FileInputStream s Vt u%Problema leyendo el fichero .torrent SHA-1v wx y z{ |&java/security/NoSuchAlgorithmException }Njava/lang/Exception~ O length path  N ? Path->(BJTorrent/FicheroTorrent/FicheroTorrentejava/lang/Object java/io/File#(Ljava/io/File;Ljava/lang/String;)VBJTorrent/SalidaescribeVentana(Ljava/lang/String;)VvalueOf(J)Ljava/lang/Long;seek(J)VreadByte()B getMessageappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;getCause()Ljava/lang/Throwable;-(Ljava/lang/Object;)Ljava/lang/StringBuilder;toString(I)Ljava/lang/StringBuilder;java/lang/SystemerrLjava/io/PrintStream;java/io/PrintStreamprintlnindexOf(Ljava/lang/String;)Iadd(ILjava/lang/Object;)Vsizeget(I)Ljava/lang/Object; longValuecharAt(I)CBJTorrent/Utils bytesToHex([B)Ljava/lang/String;byteArrayToURLStringexistsexit(I)V(Ljava/io/InputStream;)V(C)Ljava/lang/StringBuilder;closejava/security/MessageDigest getInstance1(Ljava/lang/String;)Ljava/security/MessageDigest;resetupdate([BII)Vdigestescribejava/lang/Integer(I)Ljava/lang/Integer;intValueequalsIgnoreCase(Ljava/lang/String;)Z separatorCharC substring(II)Ljava/lang/String;!qrstutvtwxyxzx{|}|~| ||xx||`******* * * * Y * Y * Y * Y **** ***+*Y+ MfN "$"&((.,3.82C4N6Y8d:i=o?uAzCEPRUSTV /*\ /*d /*l /*u 2* ~ /* I*!"*"h`=N*#6-*$TW:%Y&'()(*+,%Y&-(!./(.,0121-:=>)4:=?a>"|?R||}t"BS/* /* 5** 34"*Y" `"**5%Y&6(*(,**7** 84"*Y"`"**5%Y&9(*(,**** :4Z"*Y"`"**" ** ;4Z"J*Y"`"*<**=<*= *Y*>?@aۧT** A4"*"*Y"`"***B**C7*7** 7** D4"*Y" `"**B** E4"*"J*Y"`"**Bl* *Y"Z`"F:**"*h` *"!* *** G4"*"N*Y"`"*H<*=2%Y&I(.J(*>K(,** L4"*"*Y" `"*BX**" * <* `**3T**M**N**O%Y&P(*(,>  9ER]e~"-2:FP_lw    ! "#$D#J&W'^(i)n*v,-,4789:*(|:|{|#P'1d$9+P @*Q*R@STYUY*VWN63-X6*T%Y&*Z (Y, -Z L0%Y&[(+'(,2mp>IJ LNY.[9\?]H_c[icmipeqfk>?*18|k.?q 7;\]L+^+** * * d`_+`L+bc L+ec%&a%1d*  !&'.129* '2; fJ @>* *"Fi *Y"`"* *"F0;* *"F9+i* *Y"Z`"F0dfga@ >* *"Fe *Y"`"* >`fv ~| Gj @N*B@* *"F:*Y"`"*"6*"a$%Y&-(* FY,N*Y"a"-*  ';V\h*-/|jhex .X<=* *"Fl*Y"`"**57* *"Fe*Y"`"2 $0@CPSW XV|T|  maLMN666* *"Fl* *"Fd*Y"`"*5L+hi**B 7+jiϻ%Y&kY*C(,M* *Y"Z`"Fl>* *"Fe$*5N%Y&,(kY-(,M*Y"`"KY%Y&l(kY,m:,,n-ndnd`oM%Y&p(,(,c*,7*-7* *"Fe*Y"`"z  25BGPfo$.8; K N [`RDxa^x[x Xx U|R|O|" #70 a!0PK wC8LfCC-BJTorrent/FicheroTorrent/FicheroTorrente.java/* * FicheroTorrente.java * * Created on 27 de octubre de 2007, 5:11 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.FicheroTorrent; import BJTorrent.Salida; import BJTorrent.Utils; import java.io.*; import java.util.LinkedList; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * Clase que almacena los datos del fichero .torrent que leemos y parsemanos */ public class FicheroTorrente { //Buffer en el que almacenamos los bytes del fichero .torrent public byte[] datos = new byte[200 * 1024]; //Buffer en el que almacenamos la clave info del fichero METAINFO del .torrent sobre el que calcularemos la clave SHA1 del torrente public byte[] info = new byte[200 * 1024]; //Clave SHA1 del torrente public byte[] info_hash = new byte[20]; //URL que codifica la SHA1 del torrente y que ser usada por la clase Tracker private String infohashURL = ""; //La clave SHA1 del torrente en formato hexadecimal public String infohashhex = ""; //String que almacena todo el fichero METAINFO .torrent para buscar claves y parsear. private String datos_cadena = ""; //posicin actual en la que leemos de datos_cadena; private int pos; //Posicin o byte de inicio de la clave info del METAFILE .torrent private int pos_ini_info = 0; //Posicin o byte final de la clave info del METAINFO .torrent que ciframos para hallar la clave SHA1 del torrente private int pos_fin_info = 0; //Posicin de inicio de las hash SHA1 en el METAINFO .torrent private static int pos_ini_hash =0; //Lista de trackers que aparecen en el fichero METAINFO private LinkedList ListaTrackers = new LinkedList (); //Nombre de los ficheros del torrente public LinkedList ListaFicheros = new LinkedList (); //Rutas o paths de cada uno de los ficheros del torrente public LinkedList ListaRutas = new LinkedList (); //Tamao en bytes o longitud de cada uno de los ficheros del torrente public LinkedList ListaLongitudes = new LinkedList (); //Nmero de ficheros que componen el torrente public int num_ficheros=0; //clave anuncio del fichero METAINFO .torrent public String anuncio=""; //nombre del torrente public String nombre=""; //longitud -> sumatorio total de la longitud de todos los ficheros public long longitud=0; //Tamao de la pieza, suele ser mltiplo de 16KB public int tam_pieza=0; //nmero de piezas del torrente public int num_piezas=0; //Fichero .torrent que leemos y parseamos private File f; public RandomAccessFile ficherotorrent; /** * Crea una nueva instancia de FicheroTorrente * @param f File Fichero .torrent que leemos y parseamos */ public FicheroTorrente(File f) { this.f = f; try { this.ficherotorrent = new RandomAccessFile(f,"r"); } catch (IOException ioe) { Salida.escribeVentana("Error accediendo aleatoriamente al fichero torrente"); } } /** * Devuelve la SHA-1 del torrente en formato URL * @return String SHA-1 del torrente en codificacin URL */ public String leeInfoHashURL() { return infohashURL; } /** * Devuelve la clave announce del .torrent * @return String Clave announce */ public String leeAnnounce() { return anuncio; } /** * Devuelve el nmero de piezas del .torrent * @return int Nmero de piezas */ public int leeNumPiezas() { return num_piezas; } /** * Devuelve el tamao de la pieza excepto la ltima * @return int Tamao de la pieza en bytes */ public int leeTamPieza() { return tam_pieza; } /** * * Devuelve el tamao en bytes total de los ficheros del torrente a descargar * @return Long Tamao en bytes del torrente a descargar */ public Long leeLongitud() { return longitud; } /** * * Devuelve el nmero de ficheros del torrente * @return int Nmero de ficheros que componen el torrente */ public int leeNumFicheros() { return num_ficheros; } /** * Devuelve la hash SHA1 de una pieza pasada como argumento leyndola del fichero .torrent * @param indice int Nmero de pieza * @return byte[] hash SHA1 de la pieza segn aparece en el fichero METAINFO .torrent */ public byte[] leePiezaSHA1(int indice){ pos=pos_ini_hash; int ini=pos+indice*20; byte []hash20=new byte[20]; try { ficherotorrent.seek(ini); for (int j=0;j<20;j++) hash20[j]=ficherotorrent.readByte(); } catch (IOException ioe) { Salida.escribeVentana(ioe.getMessage()+"-"+ioe.getCause()); Salida.escribeVentana("Pos Ini piezas:"+pos_ini_hash+" pos "+ini); System.err.println("Fallo leyendo la SHA1 de la pieza"); Salida.escribeVentana("Fallo leyendo la SHA1 de la pieza"); return null; } // Salida.escribe(Utils.byteArrayToByteString(hash20)); return hash20; } /** * Devuelve el nombre del torrente * @return String Nombre del Torrente */ public String leeNombre() { return nombre; } /** * * Devuelve la lista de Trackers del METAINFO .torrent * @return LinkedList Lista de trackers */ public LinkedList leeTrackers() { return ListaTrackers; } /** * * Mtodo que busca las claves 'announce', 'info', 'files', 'path', 'length', 'pieces' * 'announce-list', etc.. en el String que almacena todo el .torrent y llama a los mtodos leeBCadena() * leeBEntero() para almacenar los valores de las claves en los atributos de la clase adecuados. * */ public boolean parseTorrent() { pos = datos_cadena.indexOf("d8:announce"); pos += 11; anuncio=leeBCadena(); Salida.escribeVentana("announce: "+anuncio); ListaTrackers.add(0,anuncio); pos = datos_cadena.indexOf("4:name"); pos += 6; nombre=leeBCadena(); Salida.escribeVentana("Nombre del Torrente: "+nombre); if (nombre=="" && anuncio=="") //System.out.println("Fichero .torrent de entrada con formato incorrecto"); return false; if ((pos = datos_cadena.indexOf("4:info")) > 0) { pos += 6; pos_ini_info = pos; if ((pos = datos_cadena.indexOf("5:files")) >0) { pos += 7; leeBFicheros(); num_ficheros=ListaFicheros.size(); for (int j = 0; j < ListaFicheros.size(); j++) { // Salida.escribeVentana("Fichero: " + j + ": " // + ListaFicheros.get(j)+" bytes",0); // Salida.escribeVentana("Ruta: " + j + ": " // + ListaRutas.get(j),0); longitud+=ListaLongitudes.get(j); // Salida.escribeVentana("Longitud: " + j + ": " // + ListaLongitudes.get(j)+" bytes",0); } } else { pos = datos_cadena.indexOf("6:length"); if (pos> 0) pos += 8; num_ficheros=1; longitud=leeBEntero(); ListaFicheros.add(0, leeNombre()); ListaRutas.add(0,""); ListaLongitudes.add(0,longitud); //Salida.escribeVentana("Fichero: "+leeNombre(),0); //Salida.escribeVentana("Longitud: "+longitud+" bytes",0); } } pos = datos_cadena.indexOf("piece length"); pos += 12; tam_pieza=(int)leeBEntero(); //Salida.escribe("Tam Pieza"+tam_pieza); //Salida.escribeVentana("Tam Pieza: "+(tam_pieza/1024)+"Kb",0); pos = datos_cadena.indexOf("6:pieces"); if (pos > 0) { pos += 8; num_piezas =(int) leeBEntero() /20; //Salida.escribeVentana("Numero de Piezas: "+num_piezas,0); if (datos_cadena.charAt(pos++) != ':') return false; //System.exit(100); pos_fin_info = pos + (int) num_piezas*20; pos_ini_hash =pos; //Ahora leemos la hash SHA1 de cada pieza // long mipos=leePiezasHash(pos); // if (mipos!=pos_fin_info) // System.exit(100); } if (this.tam_pieza==0 && this.num_piezas==0) return false; pos = datos_cadena.indexOf("13:announce-list"); if (pos > 0) { pos += 16; leeBTrackers(); for (int i = 0; i < ListaTrackers.size(); i++) Salida.escribeVentana("Tracker "+i+": "+ListaTrackers.get(i)); } pos = datos_cadena.indexOf("7:private"); if (pos > 0) { pos += 9; leeBEntero(); pos_fin_info=pos; } for (int j = pos_ini_info; j < pos_fin_info + 1; j++) { info[j] = datos[j]; // Salida.escribe("pos :"+j+"-val :"+info[j]); } //Salida.escribe("pos ini: " + pos_ini_info + "pos fin"+ pos_fin_info); info_hash = hash_SHA1(); //Salida.escribe("SHA1->" + info_hash.toString()); infohashhex = Utils.bytesToHex(info_hash); infohashURL = Utils.byteArrayToURLString(info_hash); Salida.escribeVentana("HASH SHA1: "+infohashhex); return true; //Salida.escribe("INFOHASH->" + infohashhex); //Salida.escribe("INFOHASHURL->" + infohashURL); } /** * * Lee los bytes del fichero .torrent y los almacena en byte[] datos y en un String * datos_cadena */ public void leerBytes() { try { long tambytes = 0; if (f.exists()) { tambytes = f.length(); } else System.exit(1); DataInputStream f_in_torrent; //if (datos_cadena.contains("6:pieces") == true // && datos_cadena.length() > datos_cadena // .indexOf("6:pieces") + 20) // break; f_in_torrent = new DataInputStream(new FileInputStream(f)); byte b; for (int i = 0; i < tambytes; i++) { b = f_in_torrent.readByte(); datos[i] = b; datos_cadena += (char) b; } f_in_torrent.close(); } catch (IOException ioe) { System.err.println("Problema leyendo el fichero .torrent " + ioe.getMessage()); } } /* public long leePiezasHash(int posicion){ byte []hash20=new byte[20]; PiezasHash= new LinkedList(); for (int i=0; i= '0' && datos_cadena.charAt(pos) <= '9') { valor = valor * j + Integer.valueOf(datos_cadena.charAt(pos++) - '0'); j = 10; } if (datos_cadena.charAt(pos) == 'e') pos++; return valor; } /** * Devuelve el String ledo, en la posicin indicada por el atributo de la clase 'pos' ,del String que almacena * todo el .torrent. * Lee una cadena Bcode y la traduce a String. * @return String Cadena leida. */ public String leeBCadena() { long valor = 0; String valor_cad = ""; valor = leeBEntero(); while (datos_cadena.charAt(pos) == ':') pos++; for (int i = pos; i < pos + valor; i++) valor_cad += datos_cadena.charAt(i); // Salida.escribe("pos:"+pos+" "+valor_cad); pos += valor; return valor_cad; } /** * Almacena los trackers de la clave 'announce-list' del .torrent en la lista * ListaTrackers. */ public void leeBTrackers() { int i = 0; int e = 0; do { while (datos_cadena.charAt(pos) == 'l') { e--; pos++; } ListaTrackers.add(i, leeBCadena()); while (datos_cadena.charAt(pos) == 'e') { e++; pos++; } i++; } while (e != 0); } /** * * Lee los valores de las claves 'path' y 'length' de cada unos de los ficheros que * componen el .torrent. Almacena los nombres de los ficheros en ListaFicheros, sus rutas * en ListaRutas y su tamao en bytes en ListaLongitudes. */ public void leeBFicheros() { String aux = ""; String aux2 = ""; String nombre=""; int i = 0; int j = 0; int e = 0; do { while (datos_cadena.charAt(pos) == 'l' || datos_cadena.charAt(pos) == 'd') { e--; pos++; } aux = leeBCadena();// clave if (aux.equalsIgnoreCase("length")) ListaLongitudes.add(i++, leeBEntero()); else if (aux.equalsIgnoreCase("path")) { aux2 = File.separatorChar+this.leeNombre(); if (datos_cadena.charAt(pos++) == 'l') { while (datos_cadena.charAt(pos) != 'e') { nombre=leeBCadena(); aux2 = aux2 + File.separatorChar+ nombre ; } pos++; } String tamsep=new String(" "+File.separatorChar); aux2 = aux2.substring(0, aux2.length()-nombre.length()-tamsep.length()+1); Salida.escribe("Path->" + aux2); ListaRutas.add(j, aux2); ListaFicheros.add(j,nombre); j++; } // aux=leeBCadena(); //valor while (datos_cadena.charAt(pos) == 'e') { e++; pos++; } } while (e != 0); } }PK wC8- 1BJTorrent/FicheroTorrent/VentanaPiezasDisco.class2 } |  | | | | | | | | | | |   | | `  ` ` ` | | |  |  | b " %    : :   : 9 9 9 :  9  %  % | |   " | % %   " :!" # "$%& `' b |()* e+ b,-. |/ j0 12 34 j5 j6 78 79 :; 7< 7= 7> j? 3@ :A jB |CDE ListaPiezas[LBJTorrent/Pieza;torrente*LBJTorrent/FicheroTorrent/FicheroTorrente; num_piezasI tam_piezapathLjava/lang/String;prefs#LBJTorrent/GUI/VentanaPreferencias; num_ficheroslongitudJfaltanbajadosprogresoficheros_bajadosjava/io/RandomAccessFile;ficheroLjava/io/RandomAccessFile;tam_ultima_piezaFicheroCompletadoLjava/util/LinkedList; Signature(Ljava/util/LinkedList;graphLjava/awt/Graphics; jProgressBar1Ljavax/swing/JProgressBar; labeltituloLjavax/swing/JLabel;-(LBJTorrent/FicheroTorrent/FicheroTorrente;)VCodeLineNumberTableLocalVariableTablethis-LBJTorrent/FicheroTorrent/VentanaPiezasDisco;torrentmaximoLjava/lang/Long; creaPiezas()ViioeLjava/io/IOException;ltempLjava/io/File; StackMapTableDleePiezasBajadaskauxj datospieza[Btampiezaposicionposfichleidosposbuff faltanleer ficheroleidos[JinitComponentslayoutLjavax/swing/GroupLayout; SourceFileVentanaPiezasDisco.java  !BJTorrent/GUI/VentanaPreferencias java/util/LinkedList F GH IH JK LMjava/lang/Long N OP QH RP SP TU VW BJTorrent/Pieza ~ XHjava/io/RandomAccessFile YZ 130[ \] ^_ `a b c d e fjava/io/IOException9Error cerrando el fichero de acceso aleatorio al .torrentg h_ ij kl java/io/Filejava/lang/StringBuilder mn o pqjava/lang/String rZ _ st uv mw x ytrw z { |N }~  ,No se pudieron crear los ficheros temporales _ N !No se pudo leer la pieza en disco _ P Pieza m leida de disco y validada  U NO VALIDAjavax/swing/JProgressBarjavax/swing/JLabel U java/awt/FontTahoma  #Leyendo Piezas descargadas en Discojavax/swing/GroupLayout                 +BJTorrent/FicheroTorrent/VentanaPiezasDiscojavax/swing/JFrame(BJTorrent/FicheroTorrent/FicheroTorrente leeNumPiezas()I leeTamPieza leeLongitud()Ljava/lang/Long; longValue()J(J)V setMinimum(I)VintValue setMaximumsetValuesetStringPainted(Z)V getGraphics()Ljava/awt/Graphics;leeNumFicheroslee_directorioCompartido()Ljava/lang/String;BJTorrent/GUI/IdiomaleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;setText(Ljava/lang/String;)V leePiezaSHA1(I)[B(III[B)VficherotorrentcloseinfodatosBJTorrent/SalidaescribeVentanavalueOf(J)Ljava/lang/Long;add(ILjava/lang/Object;)Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder; ListaRutasget(I)Ljava/lang/Object;toStringmkdirs()Z separatorCharC(C)Ljava/lang/StringBuilder; ListaFicherosexists#(Ljava/io/File;Ljava/lang/String;)VListaLongitudes setLengthupdate(Ljava/awt/Graphics;)Vjava/lang/SystemerrLjava/io/PrintStream;java/io/PrintStreamprintlnseekread([BII)Iescribeexit validaSHA1([B)Z(I)Ljava/lang/StringBuilder;set'(ILjava/lang/Object;)Ljava/lang/Object;escribeCompletasetAlwaysOnTop(Ljava/lang/String;II)VsetFont(Ljava/awt/Font;)VgetContentPane()Ljava/awt/Container;(Ljava/awt/Container;)Vjava/awt/Container setLayout(Ljava/awt/LayoutManager;)V!javax/swing/GroupLayout$Alignment Alignment InnerClassesLEADING#Ljavax/swing/GroupLayout$Alignment;createParallelGroup ParallelGroupL(Ljavax/swing/GroupLayout$Alignment;)Ljavax/swing/GroupLayout$ParallelGroup;createSequentialGroupSequentialGroup+()Ljavax/swing/GroupLayout$SequentialGroup;'javax/swing/GroupLayout$SequentialGroupaddGap.(III)Ljavax/swing/GroupLayout$SequentialGroup; addComponentB(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$SequentialGroup;%javax/swing/GroupLayout$ParallelGroupaddGroupGroupH(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;?(Ljava/awt/Component;)Ljavax/swing/GroupLayout$SequentialGroup;J(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$SequentialGroup;addContainerGap-(II)Ljavax/swing/GroupLayout$SequentialGroup;setHorizontalGroup"(Ljavax/swing/GroupLayout$Group;)VTRAILINGk(Ljavax/swing/GroupLayout$Alignment;Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;setVerticalGrouppackjavax/swing/GroupLayout$Group!|}~v***Y** * * * * * Y*+*+*+*+Y*M***,**** !**"#*+$**%&**W'*()*+nO, .135$7)9.?3A>QCRKSST^WjYnZv[\]abdfghj jf **,*p <*>*#"Y*d ***q@*-.S*/0*1*2 L45<*6* 78<*9Y:Y;*<*=>?<@ABW9Y:Y;*<*=>?<CD*E>?<@AM,F*&%Y,GHS*&2*I>J*Y *I>a *Y *I>` *&20** **!K *L NMNOVps33~tuwPuV`hpsty'A[u~HCt{W"     \B*P@ 7 766 6 *6 : 6  *6  P 6  *Q*# 2R6  N66  i776 *I >%*I >e77  6*6H  P*I>d6 ~9Y:Y;*<*=>?<CD*E>?<@A:*%YGHS*ST*S-  UW*S0  P9Y:Y;*<*=>?<CD*E>?<@A:*%YGHS*ST*S- UW*S0 P `6  d6 7:VWX*# 2-Y:Y;Z< [\<@W*Y *# 2Ra *Y *# 2R` ** **!K 6*65*> /a7:*]W  P*# 2^d:Y;Z< [_<@W*Y *# 2Ra *# 2^*Y *# 2R` ** **!K &Z3]b3e3E #28>MY^adkor&5>KRZ]be- A T _ gw"& &7E Qk>r ^A      # h& 0 : h= ` H *`Ya*bYc(*d*(eYfgh*(i+jY*klL*k+m++no+p+no+p)))q*rs+p111q*(tsu,vsw++nox+pCv*(tq*$rZZZqyz*{. ' (*,.-7/C0K1=FGC"3j@:j7jjPK wC82 0BJTorrent/FicheroTorrent/VentanaPiezasDisco.form
PK wC8 7.4.40BJTorrent/FicheroTorrent/VentanaPiezasDisco.java/* * VentanaPiezasDisco.java * * Created on 19 de noviembre de 2007, 16:33 */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.FicheroTorrent; import BJTorrent.Pieza; import BJTorrent.Salida; //import BJTorrent.Utils; import BJTorrent.GUI.Idioma; import BJTorrent.GUI.VentanaPreferencias; import java.io.RandomAccessFile; import java.io.File; import java.io.IOException; import java.util.LinkedList; import javax.swing.JProgressBar; //import javax.swing.event.EventListenerList; /** * Subclase de JFrame. * Crea la estructura de directorios y ficheros que componen el torrente * en el sistema de archivos si esta no hubiese sido creada. * Tambin indica la lectura de las piezas previamente descargadas. */ public class VentanaPiezasDisco extends javax.swing.JFrame { //Array de piezas que forman el torrente public Pieza[] ListaPiezas; //Objeto que almacena la informacin del fichero .torrent public FicheroTorrente torrente; //Nmero de piezas del torrente private int num_piezas; //Tamao en bytes de las piezas excepto la ltima private int tam_pieza; //Ruta o path del directorio compartido que leemos de VentanaPreferencias private String path=""; //Objeto que almacena las preferencias de la aplicacin private VentanaPreferencias prefs=new VentanaPreferencias(); //Nmero de ficheros del torrente private int num_ficheros = 0; //Tamao en bytes del torrente private long longitud = 0; //Nmero de bytes que faltan por descargar para completar el download. public long faltan = 0; //Nmero de bytes descargados public long bajados=0; //Progreso del componente JProgessBar private int progreso=0; //Array usado para crear en disco los ficheros y directorios del torrente private RandomAccessFile[] ficheros_bajados; //Objeto con el que leemos las piezas descargadas de los ficheros que componen el torrente private RandomAccessFile fichero; //Tamao en bytes de la ltima pieza private int tam_ultima_pieza=0; //Lista con el nmero de bytes descargados de cada fichero que compone el torrente public LinkedList FicheroCompletado=new LinkedList(); //objeto usado para actualizar y repintar esta ventana private java.awt.Graphics graph; /** * * Constructor de la clase VentanaPiezasDisco * @param torrent FicheroTorrente El fichero .torrent que abrimos lo parseamos almacenando la * informacin del torrente, que ser el argumento para el constructor de esta clase. */ public VentanaPiezasDisco(FicheroTorrente torrent ) { this.torrente=torrent; this.num_piezas = torrent.leeNumPiezas(); this.tam_pieza=torrent.leeTamPieza(); this.longitud=torrent.leeLongitud(); Long maximo=new Long(this.longitud); initComponents(); this.jProgressBar1.setMinimum(0); this.jProgressBar1.setMaximum(maximo.intValue()); this.jProgressBar1.setValue(0); jProgressBar1.setStringPainted(true); this.graph=this.getGraphics(); this.ListaPiezas = new Pieza[this.num_piezas]; this.num_ficheros = torrent.leeNumFicheros(); this.ficheros_bajados = new RandomAccessFile[this.num_ficheros]; this.path=prefs.lee_directorioCompartido(); this.labeltitulo.setText(Idioma.leeEtiquetaIdioma("130")); } /** * Mtodo que crea los directorio y ficheros y les asigna el tamao adecuado indicado en FicheroTorrente. * En el caso de que los ficheros del torrente ya existiesen este mtodo llama a leePiezasBajadas() */ public void creaPiezas(){ this.tam_ultima_pieza=(int)this.torrente.longitud % tam_pieza; for (int i=0; i=this.torrente.ListaLongitudes.get(j).intValue()) { posicion=posicion -this.torrente.ListaLongitudes.get(j).intValue(); posfich=posicion; j++; } for (int k = j; k < this.torrente.num_ficheros; k++) { ficheroleidos[k]=0; //Salida.escribe("posfich "+posfich+" longitud fichero"+this.torrente.ListaLongitudes.get(k).intValue()); try { leidos=(int)this.torrente.ListaLongitudes.get(k).intValue()-(int)posfich; if (faltanleer<=leidos) { File temp = new File(this.path+torrente.ListaRutas.get(k)+File.separatorChar+torrente.ListaFicheros.get(k)); this.fichero = new RandomAccessFile(temp, "rw"); this.fichero.seek(posfich); this.fichero.read(datospieza,posbuff,faltanleer); this.fichero.close(); ficheroleidos[k]=faltanleer; break; } else { if (leidos<=0) break; File temp = new File(this.path+torrente.ListaRutas.get(k)+File.separatorChar+torrente.ListaFicheros.get(k)); this.fichero= new RandomAccessFile(temp, "rw"); this.fichero.seek(posfich); this.fichero.read(datospieza,posbuff,leidos); //Salida.escribe("Lectura de una pieza dividida en varios ficheros"); this.fichero.close(); ficheroleidos[k]=leidos; posbuff=posbuff+leidos; faltanleer=faltanleer-leidos; posfich=0; } } catch (IOException ioe) { Salida.escribe("No se pudo leer la pieza en disco"); System.exit(1); } } if (this.ListaPiezas[i].validaSHA1(datospieza)==true) { Salida.escribe("Pieza "+i+" leida de disco y validada"); // Salida.escribeVentana("Pieza "+i+" leida de disco y validada",0); bajados+=this.ListaPiezas[i].leeTamPieza(); progreso+=this.ListaPiezas[i].leeTamPieza(); this.jProgressBar1.setValue(progreso); this.update(graph); for (int k = j; k < this.torrente.num_ficheros; k++) { Long aux=this.FicheroCompletado.get(k)+ficheroleidos[k]; FicheroCompletado.set(k,aux); // Salida.escribe("Leidos :"+ficheroleidos[k] +" Completado->"+FicheroCompletado.get(k).intValue()); ficheroleidos[k]=0; } this.ListaPiezas[i].escribeCompleta(true); } else { Salida.escribe("Pieza "+i+" NO VALIDA"); faltan+=this.ListaPiezas[i].leeTamPieza(); this.ListaPiezas[i].escribeCompleta(false); progreso+=this.ListaPiezas[i].leeTamPieza(); this.jProgressBar1.setValue(progreso); this.update(graph); } }//fin for } // //GEN-BEGIN:initComponents private void initComponents() { jProgressBar1 = new javax.swing.JProgressBar(); labeltitulo = new javax.swing.JLabel(); setAlwaysOnTop(true); labeltitulo.setFont(new java.awt.Font("Tahoma", 1, 14)); labeltitulo.setText("Leyendo Piezas descargadas en Disco"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(41, 41, 41) .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(49, 49, 49) .addComponent(labeltitulo))) .addContainerGap(44, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(67, Short.MAX_VALUE) .addComponent(labeltitulo) .addGap(14, 14, 14) .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(90, 90, 90)) ); pack(); }// //GEN-END:initComponents // Declaracin de varibales -no modificar//GEN-BEGIN:variables private javax.swing.JProgressBar jProgressBar1; private javax.swing.JLabel labeltitulo; // Fin de declaracin de variables//GEN-END:variables } PK wC8 88BJTorrent/GUI/Idioma.class2i 56 7 89: 5 ; <= >? @A B CDE 5F G H H IJK <LMNO PQRidiomaLjava/lang/String; propidiomaLjava/util/Properties; propStreamLjava/io/InputStream;()VCodeLineNumberTableLocalVariableTableioeLjava/io/IOException;thisLBJTorrent/GUI/Idioma; StackMapTableQDleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;clave SourceFile Idioma.java $%ESPAÑOL S TUjava/util/Properties !V WX YZproperties/spanish.properties[ \] "# ^_java/io/IOExceptionjava/lang/StringBuilderError IO Clase Preferencias `a bUc deENGLISH fgproperties/english.propertiesFRANCAISproperties/francais.properties h1BJTorrent/GUI/Idiomajava/lang/Object!BJTorrent/GUI/VentanaPreferencias leeIdioma()Ljava/lang/String;java/lang/Stringcontains(Ljava/lang/CharSequence;)ZgetClass()Ljava/lang/Class;java/lang/ClassgetResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream;load(Ljava/io/InputStream;)Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toStringBJTorrent/Salidaescribe(Ljava/lang/String;)Vequals(Ljava/lang/Object;)Z getProperty! !"#$%&***Y*:**  * LY+*:**  * `LY+C*7**  * LY+4>Aw'^% )?@'B4E>IAHBI^ajdwgkjk(*B)*)*)*+,-A./e/e/ 01&2*'( 234PK wC8PջgBJTorrent/GUI/Idioma.java/* * Idioma.java * * Created on 26 de noviembre de 2007, 16:33 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; import BJTorrent.Salida; /** * * @author Benjamn Muiz Garca */ import java.io.InputStream; import java.io.IOException; import java.util.Properties; /** * Clase que determina el Idioma que usa nuestra aplicacin en las etiquetas de texto JLabel */ public class Idioma { //Cadena que indica el idioma seleccionado private String idioma="ESPAOL"; //Objeto del que leemos las propiedades private static Properties propidioma; //Stream usado leer el fichero .properties private InputStream propStream; /** * Crea una nueva instancia de Idioma. * Segn el idioma seleccionado en VentanaPreferencias carga el fichero properties que almacena * las claves/valores en el idioma adecuado, para ser mostradas por las etiquetas Jlabel de nuestro * programa. */ public Idioma() { //prop=new Properties(); this.idioma=VentanaPreferencias.leeIdioma(); /* fichero=new File("preferencias.properties"); try { if (fichero.exists()==true) { //in=new DataInputStream( fichero); //out=new DataOutputStream(fichero); in= new BufferedReader(new FileReader(fichero)); prop.load(in); idioma=prop.getProperty("idioma"); } } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString()); } */ //Salida.escribe("Idioma "+idioma); propidioma=new Properties(); if (idioma.contains("ESPAOL")) { propStream = getClass().getResourceAsStream("properties/spanish.properties"); try { propidioma.load(propStream); } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString());} /*fichero=new File("spanish.properties"); try { if (fichero.exists()==true) { //in=new DataInputStream( fichero); //out=new DataOutputStream(fichero); in= new BufferedReader(new FileReader(fichero)); propidioma.load(in); Salida.escribe("Leimos las propiedades"); } } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString()); } */ } else if (idioma.equals("ENGLISH")) { propStream = getClass().getResourceAsStream("properties/english.properties"); try { propidioma.load(propStream); } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString());} /* fichero=new File("english.properties"); try { if (fichero.exists()==true) { //in=new DataInputStream( fichero); //out=new DataOutputStream(fichero); in= new BufferedReader(new FileReader(fichero)); propidioma.load(in); } } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString()); } */ } else if (idioma.equals("FRANCAIS")) { propStream = getClass().getResourceAsStream("properties/francais.properties"); try { propidioma.load(propStream); } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString());} /* fichero=new File("francais.properties"); try { if (fichero.exists()==true) { //in=new DataInputStream( fichero); //out=new DataOutputStream(fichero); in= new BufferedReader(new FileReader(fichero)); propidioma.load(in); } } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString()); } */ } } /** * Devuelve el literal en el Idioma adecuado para ser mostrado en la etiqueta JLabel del GUI. * @param clave String Cadena que es la clave de la propiedad almacenada en un fichero .properties * @return String Devuelve el literal en el idioma seleccionado en VentanaPreferencias que se mostrara en el texto * de la etiqueta JLabel que hizo la llamada al mtodo. */ public static String leeEtiquetaIdioma(String clave){ return propidioma.getProperty(clave); } } PK wC8ҵlBJTorrent/GUI/MiFiltro.class2@ $ %& %' () (* (+ (,- (./01()VCodeLineNumberTableLocalVariableTablethisLBJTorrent/GUI/MiFiltro;accept(Ljava/io/File;)Z extensionLjava/lang/String;fLjava/io/File;siI StackMapTable2getDescription()Ljava/lang/String;type SourceFile MiFiltro.java 3 45 6 2 78 9: ;< = torrent >?Fichero BitTorrentBJTorrent/GUI/MiFiltro"javax/swing/filechooser/FileFilterjava/lang/String java/io/File isDirectory()ZgetName lastIndexOf(I)Ilength()I substring(I)Ljava/lang/String; toLowerCaseequals(Ljava/lang/Object;)Z!  /* ?++M,.>',d,`: * ! $%'#(/)9*;,=04/??1* 1 = L+ :<!"#PK wC8BJTorrent/GUI/MiFiltro.java/* * MiFiltro.java * * Created on 8 de octubre de 2007, 18:01 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; import java.io.File; /** * * @author Benjamn Muiz Garca */ /** * * Subclase de FileFilter que sirve para redefinir el filtro por el * que selecciona los ficheros el componente JFileChooser de nuestro GUI. */ public class MiFiltro extends javax.swing.filechooser.FileFilter { /** * Filtra o determina que tipos de ficheros (extensiones) se pueden seleccionar en un componente JFileChooser. *@param f File Fichero el cual filtramos su extensin. *@return boolean Cierto si se trata de un directorio o un fichero con extensin .torrent
* Falso en caso contrario. */ public boolean accept(File f) { if (f.isDirectory()) { return true; } String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) { String extension = s.substring(i+1).toLowerCase(); if ("torrent".equals(extension) ) { return true; } else { return false; } } return false; } /** * Mtodo sobre-escrito. * @return String Devuelve como descripcin "Fichero BitTorrent". */ public String getDescription() { String type = "Fichero BitTorrent"; return type; } }PK wC82gxxBJTorrent/GUI/ModeloTabla.class2* $ % & '()data[[Ljava/lang/Object; columnNames[Ljava/lang/String;longitudI()VCodeLineNumberTableLocalVariableTablethisLBJTorrent/GUI/ModeloTabla;+([[Ljava/lang/Object;I[Ljava/lang/String;)VdatoscolumnasgetColumnCount()I getRowCount getColumnName(I)Ljava/lang/String;col getValueAt(II)Ljava/lang/Object;filaisCellEditable(II)Z SourceFileModeloTabla.java   BJTorrent/GUI/ModeloTabla$javax/swing/table/AbstractTableModel!   3* !"  l**+*-*-/ 012*  0*9 /*B ;*2K G *22W       !@a   "#PK wC8sAi i BJTorrent/GUI/ModeloTabla.java/* * ModeloTabla.java * * Created on 27 de noviembre de 2007, 5:31 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; /** * * @author Benjamn Muiz Garca */ import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; /** * * Subclase de AbstractTableModel que sobre-escribe mtodos de la interfaz TableModel. */ public class ModeloTabla extends AbstractTableModel{ //Array bidimensional que contiene los datos a ser mostrados por la tabla. public Object[][] data; //Array de Strings que contiene las etiquetas de las columnas de la tabla. public String[] columnNames; //Nmero de filas de la tabla. public int longitud; /** * Constructor de la clase */ public ModeloTabla() { } /** * * Crea una instancia de ModeloTabla para definir un modelo para los componentes JTable. * Subclase de AbstractTableModel. * @param datos Object[][] Los elementos de tipo Object que componen las filas y columnas * de la tabla. * @param longitud int Nmero de filas de la tabla. * @param columnas String[] Array con las cadenas que etiquetan cada columna de la tabla. */ public ModeloTabla(Object[][]datos,int longitud,String []columnas){ this.data=datos; this.columnNames=columnas; this.longitud=longitud; } /** * Devuelve el nmero de columnas de la tabla. * @return int Nmero de columnas de la tabla. */ public int getColumnCount() { return columnNames.length; } /** * Devuelve el nmero de filas de la tabla. * @return int Nmero de filas de la tabla. */ public int getRowCount() { // return data.length; return longitud; } /** * Mtodo sobre-escrito. * @param col int Nmero de columna de la tabla. * @return String Devuelve la etiqueta de la columna que le pasamos como argumento */ public String getColumnName(int col) { return columnNames[col]; } /** * Devuelve un elemento de la tabla. * @param fila int Nmero de fila de la tabla. * @param col int Nmero de columna de la tabla. * @return String Devuelve el valor del elemento de la tabla situado en la posicin * fila y columna determinada por los argumentos. */ public Object getValueAt(int fila, int col) { return data[fila][col]; } /** * Mtodo sobre-escrito. * @param fila int Nmero de fila de la tabla. * @param col int Nmero de columna de la tabla. * @return boolean Impide que se edite el contenido de cualquier celda de cada unas de las tablas * de nuestro GUI. */ public boolean isCellEditable(int fila, int col) { return false; } }PK wC8xkccBJTorrent/GUI/Principal$1.class2'    !this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$1;windowGainedFocus(Ljava/awt/event/WindowEvent;)VevtLjava/awt/event/WindowEvent;windowLostFocus SourceFilePrincipal.javaEnclosingMethod" #$  $ %&BJTorrent/GUI/Principal$1java/lang/Object"java/awt/event/WindowFocusListenerBJTorrent/GUI/PrincipalinitComponents()V access$0008(LBJTorrent/GUI/Principal;Ljava/awt/event/WindowEvent;)V0  4 *+*    A *+     5   PK wC8y"s   BJTorrent/GUI/Principal$10.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$10;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$10java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$9008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* ]   A *+ _`    PK wC8   BJTorrent/GUI/Principal$11.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$11;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$11java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$10008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* i   A *+ kl    PK wC8cd   BJTorrent/GUI/Principal$12.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$12;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$12java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$11008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* u   A *+ wx    PK wC84C   BJTorrent/GUI/Principal$13.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$13;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$13java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$12008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+*    A *+     PK wC8"RR BJTorrent/GUI/Principal$14.class2*   !"#$this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$14; mouseClicked(Ljava/awt/event/MouseEvent;)VeLjava/awt/event/MouseEvent; mouseEntered mouseExited mousePressed mouseReleased SourceFilePrincipal.javaEnclosingMethod% &'  ' ()BJTorrent/GUI/Principal$14java/lang/Objectjava/awt/event/MouseListenerBJTorrent/GUI/PrincipalactualizaTablaTorrentes()V access$13007(LBJTorrent/GUI/Principal;Ljava/awt/event/MouseEvent;)V0  4 *+* a   A *+ cd    5 f  5 h  5 j  5 l  PK wC8  BJTorrent/GUI/Principal$15.class2R & '( &) *+ ,- ,. / 0 1 2 34 5 6789()VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$15;runventanaLBJTorrent/GUI/Principal;imgURLLjava/net/URL; SourceFilePrincipal.javaEnclosingMethod :;  <BJTorrent/GUI/Principaliconos/icono-programa.jpg= >?@ AB CD EF GH IJ KL MN BJBT 0.3.0.0 OP QNBJTorrent/GUI/Principal$15java/lang/Objectjava/lang/Runnablemain([Ljava/lang/String;)V access$1600java/lang/Class getResource"(Ljava/lang/String;)Ljava/net/URL;java/awt/ToolkitgetDefaultToolkit()Ljava/awt/Toolkit;getImage (Ljava/net/URL;)Ljava/awt/Image; access$1702"(Ljava/awt/Image;)Ljava/awt/Image; access$1700()Ljava/awt/Image; setIconImage(Ljava/awt/Image;)VsetSize(II)V setResizable(Z)VsetTitle(Ljava/lang/String;)V setVisible0/*+ AYLM, W+ + X + ++* -0 234&50657;8@: A 6- !"#$% PK wC87BJTorrent/GUI/Principal$2.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$2;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$2java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$1008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+*    A *+     PK wC8lyBJTorrent/GUI/Principal$3.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$3;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$3java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$2008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+*    A *+     PK wC8;BJTorrent/GUI/Principal$4.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$4;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$4java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$3008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+*    A *+ "#    PK wC89hBJTorrent/GUI/Principal$5.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$5;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$5java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$4008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* *   A *+ ,-    PK wC8yboBJTorrent/GUI/Principal$6.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$6;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$6java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$5008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* 3   A *+ 56    PK wC8(KyBJTorrent/GUI/Principal$7.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$7;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$7java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$6008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* ;   A *+ =>    PK wC8aBJTorrent/GUI/Principal$8.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$8;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$8java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$7008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* F   A *+ HI    PK wC8IBJTorrent/GUI/Principal$9.class2&    this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLBJTorrent/GUI/Principal$9;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFilePrincipal.javaEnclosingMethod! "#  # $%BJTorrent/GUI/Principal$9java/lang/Objectjava/awt/event/ActionListenerBJTorrent/GUI/PrincipalinitComponents()V access$8008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V0  4 *+* S   A *+ UV    PK wC8H\PP*BJTorrent/GUI/Principal$ProgRenderer.class22 ' ( )*,-.this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis ProgRenderer InnerClasses&LBJTorrent/GUI/Principal$ProgRenderer;getTableCellRendererComponent@(Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/awt/Component;tableLjavax/swing/JTable;valueLjava/lang/Object; isSelectedZhasFocusrowIcolumn/7(LBJTorrent/GUI/Principal;LBJTorrent/GUI/Principal$1;)Vx0x1LBJTorrent/GUI/Principal$1; SourceFilePrincipal.java  0javax/swing/JProgressBar1$BJTorrent/GUI/Principal$ProgRendererjava/lang/Object#javax/swing/table/TableCellRendererBJTorrent/GUI/Principal$1()VBJTorrent/GUI/Principal    4 *+*    k, H ! D*+  " #$%&+PK wC8Y瀚MM+BJTorrent/GUI/Principal$ProgRenderer2.class22 ' ( )*,-.this$0LBJTorrent/GUI/Principal;(LBJTorrent/GUI/Principal;)VCodeLineNumberTableLocalVariableTablethis ProgRenderer2 InnerClasses'LBJTorrent/GUI/Principal$ProgRenderer2;getTableCellRendererComponent@(Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/awt/Component;tableLjavax/swing/JTable;valueLjava/lang/Object; isSelectedZhasFocusrowIcolumn/7(LBJTorrent/GUI/Principal;LBJTorrent/GUI/Principal$1;)Vx0x1LBJTorrent/GUI/Principal$1; SourceFilePrincipal.java  0javax/swing/JLabel1%BJTorrent/GUI/Principal$ProgRenderer2java/lang/Object#javax/swing/table/TableCellRendererBJTorrent/GUI/Principal$1()VBJTorrent/GUI/Principal    4 *+*    k, !H ! D*+  " #$%&+PK wC8 O[O[BJTorrent/GUI/Principal.class2= 4 5 6 7 8 9 : ; < = > ? @ A B C jD EF D G H I J K LMN OPQ R S T U gV gW X aY Z[ _\ _] ^_ `a .D b c d ef .g gh ij ih kl mn op qr st uv wx yz {| }~ ]h     _    ]D _D aD  dD  gD iD kD    p  s ]  ] { ] ]      i g g  d i                            D     D      D   D                                        D ! "#  D $ %& ' (  ) *+, - .     /  0 1   2 3 45 g6 7 089 : ;< -= >? 0D 0@A 3 0B 0CD 0EF 9G HIJK =G 0L MN HO 0P 0QRS T UV UWXYZ[  \] ^_ U`abc SD Xde VDf XD Ughijklmnopq dD rst gD uvw ProgRenderer2 InnerClasses ProgRenderer id_cliente[BpanelLjavax/swing/JScrollPane;textareaLjavax/swing/JTextArea;iconLjavax/swing/ImageIcon;iconoLjava/awt/Image; listmodelLjavax/swing/DefaultListModel;ListaVentanasDLLjava/util/LinkedList; Signature7Ljava/util/LinkedList;ventanaLBJTorrent/GUI/VentanaDownload; ventanaprefs#LBJTorrent/GUI/VentanaPreferencias;torrente*LBJTorrent/FicheroTorrent/FicheroTorrente;download+LBJTorrent/ControlDescarga/DownloadTorrent;ListaDownloadsCLjava/util/LinkedList;pd-LBJTorrent/FicheroTorrent/VentanaPiezasDisco;conexion_servidor)LBJTorrent/ConexionServer/ConexionServer;puertoITorrentesAbiertos7Ljava/util/LinkedList;taLBJTorrent/GUI/TorrenteAbierto;filasel conexionesjtable_torrentesLjavax/swing/JTable;idiomaLBJTorrent/GUI/Idioma;modeloLBJTorrent/GUI/TablaTorrentes;aboutLBJTorrent/GUI/VentanaAbout; LOOKANDFEELLjava/lang/String; ConstantValueTHEME boton_borrarLjavax/swing/JButton;boton_conectarboton_desconectar boton_detalle boton_torrent jScrollPane1 jSeparator1Ljavax/swing/JSeparator; jSeparator2 jTabbedPane2Ljavax/swing/JTabbedPane;menuLjavax/swing/JMenuBar; menu_aboutLjavax/swing/JMenuItem;menu_abrir_archivo menu_archivoLjavax/swing/JMenu; menu_ayuda menu_comenzar menu_detalle menu_opciones menu_pararmenu_preferencias menu_salir menu_torrente()VCodeLineNumberTableLocalVariableTablethisLBJTorrent/GUI/Principal;imgURLLjava/net/URL;ponerTextoEtiquetasgeneraIdCliente()[Bposicadenaid StackMapTablexpinitComponentslayoutLjavax/swing/GroupLayout;menu_aboutActionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent;formWindowGainedFocus(Ljava/awt/event/WindowEvent;)VLjava/awt/event/WindowEvent; menu_preferenciasActionPerformedboton_borrarActionPerformedeLjava/lang/Exception;boton_detalleActionPerformedmenu_detalleActionPerformedmenu_pararActionPerformedmenu_comenzarActionPerformed!menu_abrir_archivoActionPerformedmenu_salirActionPerformed boton_desconectarActionPerformedboton_conectarActionPerformedfilaboton_torrentActionPerformedPATHfLjava/io/File;fcLjavax/swing/JFileChooser;filterLBJTorrent/GUI/MiFiltro;My #escribeTextArea(Ljava/lang/String;)VTablaTorrentesClick(Ljava/awt/event/MouseEvent;)VLjava/awt/event/MouseEvent;actualizaTorrrenteAbiertoD(Ljava/lang/String;JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)VnombrefaltanJbajadossubidos velocidadDLD velocidadULsemillasclientes ListaPiezas[LBJTorrent/Pieza;FicheroCompletadoLocalVariableTypeTable(Ljava/util/LinkedList;V(Ljava/lang/String;JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)VactualizaTablaTorrentescolumnLjavax/swing/table/TableColumn;zinitLookAndFeel"Ljava/lang/ClassNotFoundException;-Ljavax/swing/UnsupportedLookAndFeelException; lookAndFeelhlmain([Ljava/lang/String;)Vargs[Ljava/lang/String; access$0008(LBJTorrent/GUI/Principal;Ljava/awt/event/WindowEvent;)Vx0x1 access$1008(LBJTorrent/GUI/Principal;Ljava/awt/event/ActionEvent;)V access$200 access$300 access$400 access$500 access$600 access$700 access$800 access$900 access$1000 access$1100 access$1200 access$13007(LBJTorrent/GUI/Principal;Ljava/awt/event/MouseEvent;)V access$1600 access$1702"(Ljava/awt/Image;)Ljava/awt/Image; access$1700()Ljava/awt/Image; SourceFilePrincipal.java wx                 opjava/util/LinkedList {|  |  | BJTorrent/GUI/Principaliconos/item.gif{ |}javax/swing/ImageIcon ~ uv  st   qr  Avisos   ESPAÑOL BJTorrent/GUI/Idioma     0   1 2 10 11 12 13 20 21 30 31 40 41 42 43 4460 >abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 x  javax/swing/JButtonjavax/swing/JTabbedPanejavax/swing/JScrollPane rjavax/swing/JMenuBar javax/swing/JMenujavax/swing/JMenuItemjavax/swing/JSeparator   BJTorrent/GUI/Principal$1   java/awt/FontArial   /BJTorrent/GUI/iconos/open.gif AbrirBJTorrent/GUI/Principal$2 /BJTorrent/GUI/iconos/play.gifComenzar BJTorrent/GUI/Principal$3/BJTorrent/GUI/iconos/stop.gifPararBJTorrent/GUI/Principal$4/BJTorrent/GUI/iconos/eye.gif Ver DetallesBJTorrent/GUI/Principal$5 /BJTorrent/GUI/iconos/borrar.gifBorrarBJTorrent/GUI/Principal$6ArchivoAbiri Fichero TorrentBJTorrent/GUI/Principal$7  SalirBJTorrent/GUI/Principal$8  TorrentesBJTorrent/GUI/Principal$9BJTorrent/GUI/Principal$10BJTorrent/GUI/Principal$11Opciones PreferenciasBJTorrent/GUI/Principal$12Ayuda Acerca DeBJTorrent/GUI/Principal$13 javax/swing/GroupLayout                java/awt/Component     BJTorrent/GUI/VentanaAbout  BJBT 0.1.3.5   !BJTorrent/GUI/VentanaPreferencias  'BJTorrent/ConexionServer/ConexionServer  java/lang/StringBuilderNo se puede abrir el puerto (  ) para aceptar conexiones  Abierto el puerto ( BJTorrent/GUI/TorrenteAbierto   )BJTorrent/ControlDescarga/DownloadTorrent   java/lang/Exception BJTorrent/GUI/VentanaDownload   java/awt/Cursor        |          java/io/File javax/swing/JFileChooser  BJTorrent/GUI/MiFiltro    (BJTorrent/FicheroTorrent/FicheroTorrente      2Fichero .torrent de entrada con formato incorrecto+BJTorrent/FicheroTorrent/VentanaPiezasDisco           detectamos fila  BJTorrent/GUI/TablaTorrentes  javax/swing/JTable BJTorrent/GUI/Principal$14  52 $BJTorrent/GUI/Principal$ProgRenderer  z !"50%BJTorrent/GUI/Principal$ProgRenderer2 #$% & ' ( )*SystemMetal +,- . /Motif.com.sun.java.swing.plaf.motif.MotifLookAndFeelGTK*com.sun.java.swing.plaf.gtk.GTKLookAndFeel 011Unexpected value of LOOKANDFEEL specified: System2 3 4Ocean DefaultMetal(javax/swing/plaf/metal/DefaultMetalTheme 56!javax/swing/plaf/metal/OceanTheme'javax/swing/plaf/metal/MetalLookAndFeel 47 java/lang/ClassNotFoundException+Clase no encontrada para el Look and Feel: /Incluye la libreria Look & Feel en el CLASSPATH#Usando el Look and Feel por defecto+javax/swing/UnsupportedLookAndFeelExceptionEste Look and Feel (&) no se puede usar en esta plataforma.#No se puede usar el look and feel (), por alguna razon.BJTorrent/GUI/Principal$158 9:javax/swing/JTextArea javax/swing/JFrame!BJTorrent/GUI/PrincipalEscuchadorjava/lang/Stringjava/awt/event/ActionEventjavax/swing/table/TableColumnjava/lang/Class getResource"(Ljava/lang/String;)Ljava/net/URL;(Ljava/net/URL;)V setColumns(I)VsetRowssetViewportView(Ljava/awt/Component;)VaddTabM(Ljava/lang/String;Ljavax/swing/Icon;Ljava/awt/Component;Ljava/lang/String;)VsetSelectedIndexpackleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;setText setTitleAt(ILjava/lang/String;)Vjava/lang/Mathrandom()Dlength()IcharAt(I)CsetDefaultCloseOperation(LBJTorrent/GUI/Principal;)VaddWindowFocusListener'(Ljava/awt/event/WindowFocusListener;)V(Ljava/lang/String;II)VsetFont(Ljava/awt/Font;)Vjava/lang/ObjectgetClass()Ljava/lang/Class;setIcon(Ljavax/swing/Icon;)VaddActionListener"(Ljava/awt/event/ActionListener;)V setEnabled(Z)Vadd0(Ljavax/swing/JMenuItem;)Ljavax/swing/JMenuItem;*(Ljava/awt/Component;)Ljava/awt/Component;((Ljavax/swing/JMenu;)Ljavax/swing/JMenu; setJMenuBar(Ljavax/swing/JMenuBar;)VgetContentPane()Ljava/awt/Container;(Ljava/awt/Container;)Vjava/awt/Container setLayout(Ljava/awt/LayoutManager;)V!javax/swing/GroupLayout$Alignment AlignmentLEADING#Ljavax/swing/GroupLayout$Alignment;createParallelGroup ParallelGroupL(Ljavax/swing/GroupLayout$Alignment;)Ljavax/swing/GroupLayout$ParallelGroup;TRAILINGcreateSequentialGroupSequentialGroup+()Ljavax/swing/GroupLayout$SequentialGroup;'javax/swing/GroupLayout$SequentialGroupaddContainerGap addComponentB(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$SequentialGroup;%javax/swing/GroupLayout$ParallelGroupaddGroup;Groupk(Ljavax/swing/GroupLayout$Alignment;Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;addGap.(III)Ljavax/swing/GroupLayout$SequentialGroup;<*javax/swing/LayoutStyle$ComponentPlacementComponentPlacementRELATED,Ljavax/swing/LayoutStyle$ComponentPlacement;addPreferredGapW(Ljavax/swing/LayoutStyle$ComponentPlacement;)Ljavax/swing/GroupLayout$SequentialGroup;?(Ljava/awt/Component;)Ljavax/swing/GroupLayout$SequentialGroup;J(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$SequentialGroup;setHorizontalGroup"(Ljavax/swing/GroupLayout$Group;)VlinkSize(I[Ljava/awt/Component;)VBASELINE=(Ljava/awt/Component;)Ljavax/swing/GroupLayout$ParallelGroup;H(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;setVerticalGroupsetTitle setIconImage(Ljava/awt/Image;)V setVisible setResizable leePuertoconectar(I)Zappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;BJTorrent/SalidaescribeVentanaget(I)Ljava/lang/Object; leeParado()Zremove pararDownloadrunZjava/lang/Threadsleep(J)Vsizejava/lang/Systemexit setCursor(Ljava/awt/Cursor;)VeliminaConexionServerEscuchador.(LBJTorrent/ControlDescarga/DownloadTorrent;)V escribeParado leefaltan()J leeBajadosY([BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/util/LinkedList;JJ)VcreaConexionServerEscuchadorcreaTorrenteAbiertoEscuchadorcreaEscuchador"(LBJTorrent/GUI/VentanaDownload;)Vstartset'(ILjava/lang/Object;)Ljava/lang/Object;setDialogTitlesetCurrentDirectory(Ljava/io/File;)V setFileFilter'(Ljavax/swing/filechooser/FileFilter;)VshowOpenDialog(Ljava/awt/Component;)IgetSelectedFile()Ljava/io/File; leerBytes parseTorrent-(LBJTorrent/FicheroTorrent/FicheroTorrente;)V creaPiezasW(LBJTorrent/FicheroTorrent/FicheroTorrente;JJ[LBJTorrent/Pieza;Ljava/util/LinkedList;)V(ILjava/lang/Object;)VT(LBJTorrent/FicheroTorrent/FicheroTorrente;Ljava/util/LinkedList;Ljava/awt/Frame;Z)VgetSelectedRowescribeactualizaTorrenteAbierto2(JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)V(Ljava/util/LinkedList;)VsetModel!(Ljavax/swing/table/TableModel;)VaddMouseListener!(Ljava/awt/event/MouseListener;)V setRowHeight getColumn3(Ljava/lang/Object;)Ljavax/swing/table/TableColumn;7(LBJTorrent/GUI/Principal;LBJTorrent/GUI/Principal$1;)VsetCellRenderer((Ljavax/swing/table/TableCellRenderer;)VgetColumnModel&()Ljavax/swing/table/TableColumnModel;"javax/swing/table/TableColumnModel"(I)Ljavax/swing/table/TableColumn;setPreferredWidthsetSelectionModesetRowSelectionInterval(II)Vequals(Ljava/lang/Object;)Zjavax/swing/UIManager$getCrossPlatformLookAndFeelClassNamegetSystemLookAndFeelClassNameerrLjava/io/PrintStream;java/io/PrintStreamprintlnsetLookAndFeelsetCurrentTheme&(Ljavax/swing/plaf/metal/MetalTheme;)V(Ljavax/swing/LookAndFeel;)Vjava/awt/EventQueue invokeLater(Ljava/lang/Runnable;)Vjavax/swing/GroupLayout$Groupjavax/swing/LayoutStyle!jk.op qr st uv wxyz{|}~|}|} DQr)****Y**Y**Y*LY+ *!"#"$%"&*'( %()*'**+,-*.Y/0*1*2Z|< IMT'X,Z7^<EPT\cl}E]<*3456*7859*:;59*<=56*>?59*@A59*BC59*DE56*FG59*HI56*JK59*LM5N*OP5N*QR5N*ST5N*UV5N*'W5XJ $0<HT`lx "YLY-TYBTYJTY0TY3TY0TY0TY-TY0TY 0TY 0TY 0TY 0TY 0TY0TY0TY0TY0TY0TY0TM> "Z+[k6,`+\T,z4 |%z)p|$ Q*]Y^L*]Y^O*]Y^Q*_Y`'*]Y^S*aYbc*]Y^U*dYef*gYh3*iYj7*kYlm*iYj:*gYh<*iYj>*iYj@*kYln*iYjB*gYhD*iYjF*gYhH*iYjJ*o*pY*qr*LsYt uv*LY*wxy*LzN*L{Y*|}*OY*w~y*ON*O*OY*}*QY*wy*QN*Q*QY*}*SsYt uv*SY*wy*SN*S*SY*}*UY*wy*UN*U*UY*}*36*79*7Y**3*7W*3*mW*:9*:Y**3*:W*f*3W*<6*>9*>*>Y**<*>W*@9*@*@Y**<*@W*<*nW*B9*B*BY**<*BW*f*<W*D6*F9*FY**D*FW*f*DW*H6*J9*JY**H*JW*f*HW**fY*L*++++++*'+*Ln*O*Qw*S*U+*c+Y*USY*OSY*QSY*SSY*LS++++*L*O*Q*S*U*co*'<+Y*USY*OSY*QSY*SSY*LS*+^W !,7BMXcny   " +:QZbq &'()*0 123)92:;;JAVCbEkFzLNPQRSY[\]ceghio+q7s@tIuX{d}py LPQk'*Yõ*Ŷ*IJ*ȱ &''<*<*Yʵ**0WG5***Χl*ϟb*ϵ*Yѵ**Ӛ$Yֶ*ٶ׶ڸۧ!Yܶ*ٶ׶ڸ*.Y/0*1*2B#+5@JQ\j @J7*Yʵ**0WG5***α $.677E***޵*߶Q**W****M**W**W**W**>*O*U**2NTWF(9NT[j v!$%&'*/1 X 9] -M***޵*****ߴ***=>$?2@:ADBLFMM>*+  PR>*+  \]>*+ gh>*+ rs= ~*Y****M***޵******Y28;.  28?Qfns <] *=****޵*Y**ߴ*ߴ*ߴ*߶*߶***********W**6  NYhp{ K WMY,NY:*0W85 -  Y : *W*Y** ۱*L*Y*Y********Y*** *!*"#***߶$**$*Y*ߴ*ߴ*%***$*2*Y*Lz %+4;HX_iopx,>BNV>WWS JA4#p I"Y*&׶ڶ'  ;+**()**޶>*O*>*Q*@*S*B*U;*O*>*Q*@*S*B*UY**ضڸ+N$,4<DLT_g o!w"#$%)*O7M6*<**޵*ߴ+*    ,*2@AB*CB@HHLKz EMMMMMMM M M MM| M  >}  *-Y*./*0Y1(*(*/2*(3Y*45*(6*(7589Y*:;*(<58=Y*>;*c*(&L= ~*(?@Lf1:DNNWW``+(A/+A%+A+<A+PA +(A*(B*c*(&**(**C**޶>*O*>*Q*@*S*B*U;*O*>*Q*@*S*B*U,[\]%a4n=pVqoszz|{|}{+@HPX`hp{ ~|8   ~E {7 75KD/DEF GKIDDF HK6DIF JK#DKF LKMNOGK*PDEF<QRFSYTUQQF VYWUXYYZLMY\*׶ڶOM]OM^OZLMY`*a׶ڶOM^O-LMYb*c׶ڶOM^Oa[a_a !'.:AMT]aeq}  +4*,) )3  ( Bol) 9 dYef + <  :*+;:*+;:*+; :*+ ;!:*+ ;":*+ ;#:*+ ;$:*+ ;%:*+;&:*+;':*+;(:*+;):*+;*+:*+;,;-.0*Y; x/0;19aYb%gYh"i? Ab23m=l9np{3d@@PK wC8( 22BJTorrent/GUI/Principal.form
PK wC8l=cBJTorrent/GUI/Principal.java/* * Principal.java * * Created on 27 de octubre de 2007, 4:54 */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.GUI; import BJTorrent.Pieza; import BJTorrent.Salida; import BJTorrent.Constantes; import BJTorrent.FicheroTorrent.FicheroTorrente; import BJTorrent.FicheroTorrent.VentanaPiezasDisco; import BJTorrent.ControlDescarga.DownloadTorrent; import BJTorrent.ConexionServer.ConexionServer; import java.awt.event.MouseEvent; import javax.swing.JFileChooser; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.JProgressBar; import java.awt.Component; import javax.swing.table.TableCellRenderer; import java.awt.Frame; import java.util.LinkedList; //import java.io.IOException; //import java.io.BufferedWriter; import java.io.File; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.metal.DefaultMetalTheme; import javax.swing.plaf.metal.OceanTheme; import java.util.Random; import javax.swing.JTextArea; import javax.swing.JScrollPane; import javax.swing.JPanel; import javax.swing.JList; import javax.swing.DefaultListModel; import java.awt.GridLayout; import javax.swing.ImageIcon; import javax.swing.JTabbedPane; import java.awt.Cursor; /** * Subclase de JFrame que implementa la ventana principal de la aplicacin. */ public class Principal extends javax.swing.JFrame implements PrincipalEscuchador{ private byte[] id_cliente=new byte[20]; //panel donde mostramos los algunos eventos que forman parte de la traza de ejecucin private static JScrollPane panel=new JScrollPane(); //JTextArera donde mostramos los algunos eventos que forman parte de la traza de ejecucin private static JTextArea textarea=new JTextArea(); //icono de la pestaa de la JTabbedPane private static ImageIcon icon; //icono .jpg de la aplicacin private static java.awt.Image icono; private DefaultListModel listmodel ; //Lista que almacena los objetos VentanaDownload asociados a cada torrente que tenemos abierto private LinkedList ListaVentanasDL=new LinkedList (); //VentanaDownload seleccionada, vendr determinada por la fila seleccionada en la tabla // JTable que muestra los torrentes. private VentanaDownload ventana; private VentanaPreferencias ventanaprefs=null; //Objeto que almacena los datos del fichero .torrent private FicheroTorrente torrente; //objeto DownloadTorrent seleccionado, vendr determinado por la fila seleccionada en la tabla // JTable que muestra los torrentes. private DownloadTorrent download; //Lista que guarda los objetos DownloadTorrent o torrentes que tenemos activos en descarga private LinkedList ListaDownloads=new LinkedList(); private VentanaPiezasDisco pd; private ConexionServer conexion_servidor; //Puerto por el que aceptamos conexiones ledo de VentanaPreferencias private int puerto=0; //Lista de Objetos de la clase TorrenteAbierto, que almacena el estado de cada torrente private LinkedList TorrentesAbiertos=new LinkedList(); //Objeto TorrenteAbierto seleccionado en el interfaz private TorrenteAbierto ta; //fila seleccionada de la tabla de la ventana principal, nmero de torrente seleccionado private int filasel=0; //Nmero de peers conectados al cliente en todos los torrentes. //Atributo static global public static int conexiones=0; //Tabla que muestra el estado de los torrentes en la ventana Principal private JTable jtable_torrentes; private Idioma idioma; TablaTorrentes modelo; VentanaAbout about; //copiado del tutorial de SUN - JAVA GUI Look and feel // Specify the look and feel to use by defining the LOOKANDFEEL constant // Valid values are: null (use the default), "Metal", "System", "Motif", // and "GTK" final static String LOOKANDFEEL = "System"; // If you choose the Metal L&F, you can also choose a theme. // Specify the theme to use by defining the THEME constant // Valid values are: "DefaultMetal", "Ocean" final static String THEME = "Ocean"; //no lo usamos /** * * Constructor que crea la ventana Principal. En esta ventana se abrirn los torrentes a descargar * y compartir. Habr una JTable que muestre la informacin y estado de los torrentes. * Habr botones y mens para comenzar y parar la descarga de un torrente. * */ public Principal() { java.net.URL imgURL = Principal.class.getResource("iconos/item.gif"); icon= new ImageIcon(imgURL); initComponents(); textarea.setColumns(20); textarea.setRows(5); panel.setViewportView(textarea); jTabbedPane2.addTab("Avisos", icon,panel,"Avisos"); //jTabbedPane2.addTab("Tracker", icon,paneles[1],"Tracker"); //jTabbedPane2.addTab("Datos entre Peers", icon,paneles[2],"Datos entre Peers"); jTabbedPane2.setSelectedIndex(0); pack(); VentanaPreferencias.idioma="ESPAOL"; idioma=new Idioma(); ponerTextoEtiquetas(); actualizaTablaTorrentes(); } /** * Mtodo que pone al idioma establecido en VentanaPreferencias el texto de las etiquetas * JLabel de la ventana Principal. */ public void ponerTextoEtiquetas(){ this.menu_archivo.setText(Idioma.leeEtiquetaIdioma("0")); this.menu_abrir_archivo.setText(Idioma.leeEtiquetaIdioma("1")); this.menu_salir.setText(Idioma.leeEtiquetaIdioma("2")); this.menu_torrente.setText(Idioma.leeEtiquetaIdioma("10")); this.menu_comenzar.setText(Idioma.leeEtiquetaIdioma("11")); this.menu_parar.setText(Idioma.leeEtiquetaIdioma("12")); this.menu_detalle.setText(Idioma.leeEtiquetaIdioma("13")); this.menu_opciones.setText(Idioma.leeEtiquetaIdioma("20")); this.menu_preferencias.setText(Idioma.leeEtiquetaIdioma("21")); this.menu_ayuda.setText(Idioma.leeEtiquetaIdioma("30")); this.menu_about.setText(Idioma.leeEtiquetaIdioma("31")); this.boton_torrent.setText(Idioma.leeEtiquetaIdioma("40")); this.boton_conectar.setText(Idioma.leeEtiquetaIdioma("41")); this.boton_desconectar.setText(Idioma.leeEtiquetaIdioma("42")); this.boton_detalle.setText(Idioma.leeEtiquetaIdioma("43")); this.boton_borrar.setText(Idioma.leeEtiquetaIdioma("44")); jTabbedPane2.setTitleAt(0,Idioma.leeEtiquetaIdioma("60")); // jTabbedPane2.setTitleAt(1,Idioma.leeEtiquetaIdioma("61")); // jTabbedPane2.setTitleAt(2,Idioma.leeEtiquetaIdioma("62")); } /** * * Mtodo que genera la ID de cliente, con su cdigo de programa de 2 bytes, su versin 4 bytes * y otros bytes aleatorios que hacen que la ID sea nica. * Se contruye al arrancar la aplicacin *@return byte[] Un array de 20 bytes que constituyen la ID nuestro cliente */ public byte[] generaIdCliente() { //Cadena para generar la ID del cliente al arrancar el programa String cadena = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; byte id[] = {'-','B','J','0','3','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0'}; //Programa BJ //Versin 0.2.2.3 //ao 0, mes 2, semana 2, da 3 //For example: '-AZ2060-'.. for (int i = 0; i < 12; i++) { int pos = (int) ( Math.random() * cadena.length()); id[i+8]= (byte) cadena.charAt(pos); } return id; } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { boton_torrent = new javax.swing.JButton(); boton_conectar = new javax.swing.JButton(); boton_desconectar = new javax.swing.JButton(); jTabbedPane2 = new javax.swing.JTabbedPane(); boton_detalle = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); boton_borrar = new javax.swing.JButton(); menu = new javax.swing.JMenuBar(); menu_archivo = new javax.swing.JMenu(); menu_abrir_archivo = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); menu_salir = new javax.swing.JMenuItem(); menu_torrente = new javax.swing.JMenu(); menu_comenzar = new javax.swing.JMenuItem(); menu_parar = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JSeparator(); menu_detalle = new javax.swing.JMenuItem(); menu_opciones = new javax.swing.JMenu(); menu_preferencias = new javax.swing.JMenuItem(); menu_ayuda = new javax.swing.JMenu(); menu_about = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); addWindowFocusListener(new java.awt.event.WindowFocusListener() { public void windowGainedFocus(java.awt.event.WindowEvent evt) { formWindowGainedFocus(evt); } public void windowLostFocus(java.awt.event.WindowEvent evt) { } }); boton_torrent.setFont(new java.awt.Font("Arial", 0, 10)); boton_torrent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/GUI/iconos/open.gif"))); boton_torrent.setText("Abrir"); boton_torrent.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boton_torrentActionPerformed(evt); } }); boton_conectar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/GUI/iconos/play.gif"))); boton_conectar.setText("Comenzar"); boton_conectar.setEnabled(false); boton_conectar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boton_conectarActionPerformed(evt); } }); boton_desconectar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/GUI/iconos/stop.gif"))); boton_desconectar.setText("Parar"); boton_desconectar.setEnabled(false); boton_desconectar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boton_desconectarActionPerformed(evt); } }); boton_detalle.setFont(new java.awt.Font("Arial", 0, 10)); boton_detalle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/GUI/iconos/eye.gif"))); boton_detalle.setText("Ver Detalles"); boton_detalle.setEnabled(false); boton_detalle.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boton_detalleActionPerformed(evt); } }); boton_borrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/GUI/iconos/borrar.gif"))); boton_borrar.setText("Borrar"); boton_borrar.setEnabled(false); boton_borrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boton_borrarActionPerformed(evt); } }); menu_archivo.setText("Archivo"); menu_abrir_archivo.setText("Abiri Fichero Torrent"); menu_abrir_archivo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_abrir_archivoActionPerformed(evt); } }); menu_archivo.add(menu_abrir_archivo); menu_archivo.add(jSeparator1); menu_salir.setText("Salir"); menu_salir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_salirActionPerformed(evt); } }); menu_archivo.add(menu_salir); menu.add(menu_archivo); menu_torrente.setText("Torrentes"); menu_comenzar.setText("Comenzar"); menu_comenzar.setEnabled(false); menu_comenzar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_comenzarActionPerformed(evt); } }); menu_torrente.add(menu_comenzar); menu_parar.setText("Parar"); menu_parar.setEnabled(false); menu_parar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_pararActionPerformed(evt); } }); menu_torrente.add(menu_parar); menu_torrente.add(jSeparator2); menu_detalle.setText("Ver Detalles"); menu_detalle.setEnabled(false); menu_detalle.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_detalleActionPerformed(evt); } }); menu_torrente.add(menu_detalle); menu.add(menu_torrente); menu_opciones.setText("Opciones"); menu_preferencias.setText("Preferencias"); menu_preferencias.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_preferenciasActionPerformed(evt); } }); menu_opciones.add(menu_preferencias); menu.add(menu_opciones); menu_ayuda.setText("Ayuda"); menu_about.setText("Acerca De"); menu_about.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menu_aboutActionPerformed(evt); } }); menu_ayuda.add(menu_about); menu.add(menu_ayuda); setJMenuBar(menu); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addContainerGap() .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 760, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(boton_torrent, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(boton_conectar, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(boton_desconectar, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(boton_detalle, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(boton_borrar)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 760, Short.MAX_VALUE))) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {boton_borrar, boton_conectar, boton_desconectar, boton_detalle, boton_torrent}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(boton_torrent) .addComponent(boton_conectar) .addComponent(boton_desconectar) .addComponent(boton_detalle) .addComponent(boton_borrar)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE) .addGap(17, 17, 17) .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 316, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {boton_borrar, boton_conectar, boton_desconectar, boton_detalle, boton_torrent}); pack(); }// //GEN-END:initComponents /** * Crea una instancia de VentanaAbout. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_aboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_aboutActionPerformed // TODO: Agrege su codigo aqui: about=new VentanaAbout(); about.setTitle("BJBT 0.1.3.5"); about.setIconImage(icono); about.setVisible(true); }//GEN-LAST:event_menu_aboutActionPerformed /** * * Mtodo que es invocado cada vez que la ventana Principal consigue el foco de entrada. * Actualiza las preferencias de la aplicacin, establecidas en VentanaPreferencias, * como el idioma y el puerto que acepta las conexiones de los peers. * @param evt WindowEvent Evento que activo la ejecucin de este mtodo */ private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowGainedFocus // TODO: Agrege su codigo aqui: if (ventanaprefs==null) { ventanaprefs= new VentanaPreferencias(); ventanaprefs.setTitle(idioma.leeEtiquetaIdioma("21")); ventanaprefs.setResizable(false); ventanaprefs.setIconImage(icono); ventanaprefs.setVisible(true); } else if (this.puerto!=VentanaPreferencias.leePuerto()) { this.puerto=VentanaPreferencias.leePuerto(); conexion_servidor=new ConexionServer(); if (conexion_servidor.conectar(this.puerto)==false) Salida.escribeVentana("No se puede abrir el puerto ("+this.puerto+") para aceptar conexiones"); else Salida.escribeVentana("Abierto el puerto ("+this.puerto+") para aceptar conexiones"); } idioma=new Idioma(); //Salida.escribe("Ganamos FOCUS"); this.ponerTextoEtiquetas(); actualizaTablaTorrentes(); }//GEN-LAST:event_formWindowGainedFocus /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JMenuItem MenuPreferencias. * Crea y muestra la ventana VentanaPreferencias. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_preferenciasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_preferenciasActionPerformed // TODO: Agrege su codigo aqui: ventanaprefs= new VentanaPreferencias(); ventanaprefs.setTitle(idioma.leeEtiquetaIdioma("21")); ventanaprefs.setResizable(false); ventanaprefs.setIconImage(icono); ventanaprefs.setVisible(true); }//GEN-LAST:event_menu_preferenciasActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JButton boton_borrar. * Este Botn si el torrente estuviese en descarga llama al mtodo parar() * de la clase DownloadTorrent. Elimina el torrente de la lista de TorrentesAbiertos * y lo borra de la JTable de la ventana Principal. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void boton_borrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_borrarActionPerformed // TODO: Agrege su codigo aqui: ta=(TorrenteAbierto)TorrentesAbiertos.get(this.filasel); if (ta.leeParado()==false) { TorrentesAbiertos.remove(this.filasel); ListaDownloads.get(this.filasel).pararDownload(); while (ListaDownloads.get(this.filasel).run==true) { try{ Thread.sleep(1000); } catch (Exception e) {} } ListaDownloads.remove(this.filasel); } else TorrentesAbiertos.remove(this.filasel); this.ListaVentanasDL.remove(this.filasel); if (this.TorrentesAbiertos.size()==0) { this.menu_comenzar.setEnabled(false); this.boton_conectar.setEnabled(false); this.boton_borrar.setEnabled(false); } this.filasel=0; this.actualizaTablaTorrentes(); }//GEN-LAST:event_boton_borrarActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JButton BotnDetalle. Este botn hace que se instancie y se haga visible * la ventana VentanaDownload mientrs el torrente se encuentre abierto mirando en la lista * TorrentesAbiertos. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void boton_detalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_detalleActionPerformed // TODO: Agrege su codigo aqui: ta=(TorrenteAbierto)this.TorrentesAbiertos.get(this.filasel); ventana=this.ListaVentanasDL.get(this.filasel); ventana.setTitle(ta.nombre); ventana.setResizable(false); ventana.setIconImage(icono); ventana.setVisible(true); }//GEN-LAST:event_boton_detalleActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JMenuItem menu_detalle. Invoca al mtodo boton_detalleActionPerformed. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_detalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_detalleActionPerformed // TODO: Agrege su codigo aqui: boton_detalleActionPerformed(evt); }//GEN-LAST:event_menu_detalleActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JMenuItem menu_parar. Invoca al mtodo boton_desconectar. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_pararActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_pararActionPerformed // TODO: Agrege su codigo aqui: boton_desconectarActionPerformed(evt); }//GEN-LAST:event_menu_pararActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JMenuItem menu_comenzar. Invoca al mtodo boton_conectarActionPerformed. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_comenzarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_comenzarActionPerformed // TODO: Agrege su codigo aqui: boton_conectarActionPerformed(evt); }//GEN-LAST:event_menu_comenzarActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JMenuItem MenuAbrirArchivo. Invoca al mtodo boton_torrentActionPerformed. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_abrir_archivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_abrir_archivoActionPerformed // TODO: Agrege su codigo aqui: boton_torrentActionPerformed(evt); }//GEN-LAST:event_menu_abrir_archivoActionPerformed /** * * Cierra la aplicacin. * Mtodo que es invocado cuando se produce una accin sobre el * componente JMenuItem MenuSalir. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void menu_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_salirActionPerformed // TODO: Agrege su codigo aqui: System.exit(0); }//GEN-LAST:event_menu_salirActionPerformed /** * * Mtodo que es invocado cuando se produce una accin sobre el * componente JButton boton_desconectar. * Pone como parado el torrente en la clase TorrentesAbiertos y llama al mtodo parar() * de la clase DownloadTorrent. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void boton_desconectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_desconectarActionPerformed // TODO: Agrege su codigo aqui: this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); ListaDownloads.get(this.filasel).pararDownload(); while (ListaDownloads.get(this.filasel).run==true) { try{ Thread.sleep(1000); } catch (Exception e) {} } ta=(TorrenteAbierto)TorrentesAbiertos.get(this.filasel); conexion_servidor.eliminaConexionServerEscuchador(ListaDownloads.get(this.filasel)); ta.escribeParado(true); this.TablaTorrentesClick(null); this.setCursor(new java.awt.Cursor(Cursor.DEFAULT_CURSOR)); }//GEN-LAST:event_boton_desconectarActionPerformed /** * Mtodo que es invocado cuando se produce una accin sobre el * componente JButton boton_conectar. * Lee la ID del cliente, pone como activo el torrente en la clase TorrentesAbiertos y crea una instancia de DownloadTorrent * ,que dirige la descarga del torrente, y ser almacenada en la lista ListaDownloads. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void boton_conectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_conectarActionPerformed // TODO: Agrege su codigo aqui: int fila=this.filasel; id_cliente=generaIdCliente(); //Consigue la fila seleccionada ta=(TorrenteAbierto)this.TorrentesAbiertos.get(fila); download= new DownloadTorrent(this.id_cliente,ta.torrente,ta.ListaPiezas,ta.FicheroCompletado,ta.leefaltan(),ta.leeBajados()); conexion_servidor.creaConexionServerEscuchador(download); this.ventana=(VentanaDownload)this.ListaVentanasDL.get(fila); download.creaTorrenteAbiertoEscuchador(this); download.creaEscuchador(this.ventana); download.start(); ListaDownloads.set(fila,download); ta.escribeParado(false); this.TablaTorrentesClick(null); }//GEN-LAST:event_boton_conectarActionPerformed /** * Mtodo que es invocado cuando se produce una accin sobre el * componente JButton boton_torrent. * Crea un componente JFileChooser y el fichero .torrent seleccionado se parsea * y se crea una instancia de la clase VentanaPiezasDisco que crea los directorios y ficheros * del torrente o lee las piezas guardadas previamente en disco. * Tambin se guarda el torrente en una Lista de objetos de la clase TorrenteAbierto. * Despus crea una instancia de VentanaDownload y la almacena en la lista ListaVentanasDL. * @param evt ActionEvent Evento que activo la ejecucin de este mtodo */ private void boton_torrentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_torrentActionPerformed // TODO: Agrege su codigo aqui: String PATH=""; File f= new File(PATH); JFileChooser fc = new JFileChooser(); fc.setDialogTitle(idioma.leeEtiquetaIdioma("1")); fc.setCurrentDirectory(f); MiFiltro filter= new MiFiltro(); fc.setFileFilter(filter); if (fc.showOpenDialog(Principal.this)==fc.APPROVE_OPTION) { this.torrente=new FicheroTorrente(fc.getSelectedFile()); this.torrente.leerBytes(); if (!this.torrente.parseTorrent()) { Salida.escribeVentana("Fichero .torrent de entrada con formato incorrecto"); return; } this.boton_torrent.setEnabled(false); this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); pd=new VentanaPiezasDisco(this.torrente); pd.setTitle(this.torrente.nombre); pd.setIconImage(icono); pd.setVisible(true); pd.creaPiezas(); pd.setVisible(false); ta=new TorrenteAbierto(pd.torrente,pd.faltan,pd.bajados,pd.ListaPiezas,pd.FicheroCompletado); //int num_torrentes=TorrentesAbiertos.size(); TorrentesAbiertos.add(TorrentesAbiertos.size(),ta); ListaDownloads.add(ListaDownloads.size(),null); ventana=new VentanaDownload(ta.torrente,ta.FicheroCompletado,this,true); this.ListaVentanasDL.add(this.ListaVentanasDL.size(),ventana); actualizaTablaTorrentes(); this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); this.boton_torrent.setEnabled(true); } }//GEN-LAST:event_boton_torrentActionPerformed /** * Mtodo que escribe una cadena de texto de la traza de ejecucin del programa en * el la JTextArea del componente JTabbedPane de la ventana principal. * @param cadena String La cadena que ser mostrada en la ventana Principal. * */ public static void escribeTextArea(String cadena){ textarea.append(cadena+"\n"); } /** * Mtodo que habilita o deshabilita tanto opciones de men como botones dependiendo * del estado del torrente seleccionado en la JTable de la ventana Principal. * El estado del torrente esta almacenado en la lista de TorrentesAbiertos. * @param evt MouseEvent Evento que origina la invocacin del mtodo */ private void TablaTorrentesClick(java.awt.event.MouseEvent evt) { if (evt!=null) { this.filasel=this.jtable_torrentes.getSelectedRow(); } if (TorrentesAbiertos.get(this.filasel).leeParado()==true) { this.boton_conectar.setEnabled(true); this.menu_comenzar.setEnabled(true); this.boton_desconectar.setEnabled(false); this.menu_parar.setEnabled(false); this.boton_detalle.setEnabled(false); this.menu_detalle.setEnabled(false); this.boton_borrar.setEnabled(true); } else { this.boton_conectar.setEnabled(false); this.menu_comenzar.setEnabled(false); this.boton_desconectar.setEnabled(true); this.menu_parar.setEnabled(true); this.boton_detalle.setEnabled(true); this.menu_detalle.setEnabled(true); this.boton_borrar.setEnabled(true); } Salida.escribe("detectamos fila "+this.filasel); } /** * * Mtodo que actualiza la informacin de un objeto TorrenteAbierto y llama al mtodo actualizaTablaTorrentes() * que muestra la JTable con el estado de la lista de TorrentesAbiertos. * @param nombre String Nombre del torrente * @param faltan long Nmero de bytes que restan para completar la descarga * @param bajados long Nmero de bytes descargados * @param subidos long Nmero de bytes subidos a otros peers. * @param velocidadDL double Velocidad de bajada en Kb/seg * @param velocidadUL double Velocidad de subida en Kb/seg * @param semillas int Nmero de semillas, es decir peers con todas las piezas disponibles. * @param clientes int Nmero de peers que no tienen el torrente descargado en su totalidad * @param ListaPiezas Pieza[] Array de piezas del torrente * @param FicheroCompletado LinkedList Lista con los bytes descargados de cada fichero que * compone el torrente. */ public void actualizaTorrrenteAbierto(String nombre,long faltan,long bajados,long subidos, double velocidadDL, double velocidadUL, int semillas, int clientes,Pieza[] ListaPiezas,LinkedList FicheroCompletado){ for (int i=0;i0) { this.jtable_torrentes.setRowSelectionInterval(this.filasel,this.filasel); if (TorrentesAbiertos.get(this.filasel).leeParado()==true) { this.boton_conectar.setEnabled(true); this.menu_comenzar.setEnabled(true); this.boton_desconectar.setEnabled(false); this.menu_parar.setEnabled(false); this.boton_detalle.setEnabled(false); this.menu_detalle.setEnabled(false); this.boton_borrar.setEnabled(true); } else { this.boton_conectar.setEnabled(false); this.menu_comenzar.setEnabled(false); this.boton_desconectar.setEnabled(true); this.menu_parar.setEnabled(true); this.boton_detalle.setEnabled(true); this.menu_detalle.setEnabled(true); this.boton_borrar.setEnabled(true); } } } /** * * Mtodo que sirve para inicializar el Look and Feel del interfaz grafico de la aplicacin, * es decir el aspecto y funcionalidad de los controles, Usaremos el Look and feel por defecto * del sistema en el que corre nuestra aplicacin. * * Sacado del captutulo 'Creating a GUI with JFC/Swing' de los tutoriales de java en * sun microsystems - http://java.sun.com/docs/books/tutorial/ */ private static void initLookAndFeel() { String lookAndFeel = null; if (LOOKANDFEEL != null) { if (LOOKANDFEEL.equals("Metal")) { lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); } else if (LOOKANDFEEL.equals("System")) { lookAndFeel = UIManager.getSystemLookAndFeelClassName(); } else if (LOOKANDFEEL.equals("Motif")) { lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } else if (LOOKANDFEEL.equals("GTK")) { lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; } else { System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL); lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); } try { UIManager.setLookAndFeel(lookAndFeel); // If L&F = "Metal", set the theme if (LOOKANDFEEL.equals("Metal")) { if (THEME.equals("DefaultMetal")) MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); else if (THEME.equals("Ocean")) MetalLookAndFeel.setCurrentTheme(new OceanTheme()); UIManager.setLookAndFeel(new MetalLookAndFeel()); } } catch (ClassNotFoundException e) { System.err.println("Clase no encontrada para el Look and Feel: " + lookAndFeel); System.err.println("Incluye la libreria Look & Feel en el CLASSPATH"); System.err.println("Usando el Look and Feel por defecto"); } catch (UnsupportedLookAndFeelException e) { System.err.println("Este Look and Feel (" + lookAndFeel + ") no se puede usar en esta plataforma."); System.err.println("Usando el Look and Feel por defecto"); } catch (Exception e) { System.err.println("No se puede usar el look and feel (" + lookAndFeel + "), por alguna razon."); System.err.println("Usando el Look and Feel por defecto"); } } } /** * Clase que implementa el interfaz TableCellRenderer, llamado cuando se dibuja un componente JProgressBar * en una celda de una JTable. */ private class ProgRenderer implements TableCellRenderer{ /** * Mtodo sobre-escrito. * Devuelve el componente JProgressBar usado para dibujar la celda de la tabla * */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ return (JProgressBar)value; } } /** * Clase que implementa el interfaz TableCellRenderer, llamado cuando se dibuja un componente JLabel * en una celda de una JTable. */ private class ProgRenderer2 implements TableCellRenderer{ /** * Mtodo sobre-escrito. * Devuelve el componente JLabel usado para dibujar los iconos de estado en la tabla * de la ventana Principal. * */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ return (javax.swing.JLabel)value; } } /** * Punto de entrada a la aplicacin. Muestra en pantalla la ventana Principal. * @param args String[] Los argumentos pasados a la aplicacin en lnea de comandos */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { initLookAndFeel(); Principal ventana; ventana=new Principal(); java.net.URL imgURL = Principal.class.getResource("iconos/icono-programa.jpg"); icono = java.awt.Toolkit.getDefaultToolkit().getImage(imgURL); ventana.setIconImage(icono); ventana.setSize(800,600); ventana.setResizable(false); ventana.setTitle(Constantes.PROGRAMA+" "+Constantes.VERSION); ventana.setVisible(true); } }); } // Declaracin de varibales -no modificar//GEN-BEGIN:variables private javax.swing.JButton boton_borrar; private javax.swing.JButton boton_conectar; private javax.swing.JButton boton_desconectar; private javax.swing.JButton boton_detalle; private javax.swing.JButton boton_torrent; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator2; private javax.swing.JTabbedPane jTabbedPane2; private javax.swing.JMenuBar menu; private javax.swing.JMenuItem menu_about; private javax.swing.JMenuItem menu_abrir_archivo; private javax.swing.JMenu menu_archivo; private javax.swing.JMenu menu_ayuda; private javax.swing.JMenuItem menu_comenzar; private javax.swing.JMenuItem menu_detalle; private javax.swing.JMenu menu_opciones; private javax.swing.JMenuItem menu_parar; private javax.swing.JMenuItem menu_preferencias; private javax.swing.JMenuItem menu_salir; private javax.swing.JMenu menu_torrente; // Fin de declaracin de variables//GEN-END:variables } PK wC8q>?||'BJTorrent/GUI/PrincipalEscuchador.class2    actualizaTorrrenteAbiertoD(Ljava/lang/String;JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)V SignatureV(Ljava/lang/String;JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)V SourceFilePrincipalEscuchador.java!BJTorrent/GUI/PrincipalEscuchadorjava/lang/Objectjava/util/EventListener PK wC8&BJTorrent/GUI/PrincipalEscuchador.java/* * PrincipalEscuchador.java * * Created on 20 de noviembre de 2007, 5:08 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; import BJTorrent.Pieza; /** * * @author Benjamn Muiz Garca */ import java.util.LinkedList; import java.util.EventListener; /** * Interface implementado en la clase Principal */ public interface PrincipalEscuchador extends EventListener{ /** * * Evento que actualiza la informacin de la ventana Principal * asociada a un TorrenteAbierto, invocado * por un objeto DownloadTorrent. * @param nombre String Nombre del torrente * @param faltan long Nmero de bytes que restan para completar la descarga * @param bajados long Nmero de bytes descargados * @param subidos long Nmero de bytes subidos a otros peers. * @param velocidadDL double Velocidad de bajada en Kb/seg * @param velocidadUL double Velocidad de subida en Kb/seg * @param semillas int Nmero de semillas, es decir peers con todas las piezas disponibles. * @param clientes int Nmero de peers que no tienen el torrente descargado en su totalidad * @param ListaPiezas Pieza[] Array de piezas del torrente * @param FicheroCompletado LinkedList Lista con los bytes descargados de cada fichero que * compone el torrente. */ public void actualizaTorrrenteAbierto(String nombre,long faltan,long bajados,long subidos, double velocidadDL, double velocidadUL, int semillas, int clientes,Pieza[] ListaPiezas,LinkedList FicheroCompletado); } PK wC8sD//"BJTorrent/GUI/TablaDescargas.class2U -. /0 123 45 67 8 49:; < = > ?@AE(Ljava/util/LinkedList;Ljava/util/LinkedList;Ljava/util/LinkedList;)VCodeLineNumberTableLocalVariableTable progressBarLjavax/swing/JProgressBar;iIthisLBJTorrent/GUI/TablaDescargas; ListaFicherosLjava/util/LinkedList;fichDescargado fichLongitudLocalVariableTypeTable*Ljava/util/LinkedList;(Ljava/util/LinkedList; StackMapTable@B Signature}(Ljava/util/LinkedList;Ljava/util/LinkedList;Ljava/util/LinkedList;)V SourceFileTablaDescargas.java Cjava/lang/String DE101F GH102B IJ K[[Ljava/lang/Object; L7 MNjavax/swing/JProgressBarjava/lang/Long OJ P QR STBJTorrent/GUI/TablaDescargasBJTorrent/GUI/ModeloTablajava/util/LinkedList()V columnNames[Ljava/lang/String;BJTorrent/GUI/IdiomaleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;size()Ilongituddataget(I)Ljava/lang/Object;intValue(II)VsetValue(I)VsetStringPainted(Z)V!f***S*S*+*-  6-P* 2+ S Y- :, * 2S:)* +,".*073C5R8h9y:<3C>h":V ! " # $!%"%&:'(((U)*+,PK wC8y !BJTorrent/GUI/TablaDescargas.java/* * TablaDescargas.java * * Created on 20 de noviembre de 2007, 9:18 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; import javax.swing.JProgressBar; import java.util.LinkedList; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; /** * * @author Benjamn Muiz Garca */ /** * * Subclase de ModeloTabla para crear una TableModel y mostrar los datos del componente * JTable que presenta el porcentaje de descarga de los ficheros del torrente. * Clase invocada por la clase VentanaDownload. * */ public class TablaDescargas extends ModeloTabla{ //String[] columnas = {"Fichero","Progreso"}; /** * * Crea una instancia de TablaDescargas * @param ListaFicheros LinkedList Lista con los nombres de los ficheros en descarga o compartidos. * @param fichDescargado LinkedList Lista con el tamao en bytes que hemos descargado de cada fichero * @param fichLongitud LinkedList Lista con la longitud total de los ficheros en descarga. */ public TablaDescargas(LinkedList ListaFicheros,LinkedList fichDescargado,LinkedList fichLongitud) { super(); columnNames=new String[2]; columnNames[0]=Idioma.leeEtiquetaIdioma("101"); columnNames[1]=Idioma.leeEtiquetaIdioma("102"); longitud=ListaFicheros.size(); data=new Object[fichLongitud.size()][2]; for (int i=0;i"+fichDescargado.get(i).intValue()); JProgressBar progressBar = new JProgressBar(0,fichLongitud.get(i).intValue()); progressBar.setValue(fichDescargado.get(i).intValue()); progressBar.setStringPainted(true); data[i][1]= progressBar; } } } PK wC8!BJTorrent/GUI/TablaFicheros.class2e 23 45 678 9:; < = 9>? 2 @ AB C DE F GHIJE(Ljava/util/LinkedList;Ljava/util/LinkedList;Ljava/util/LinkedList;)VCodeLineNumberTableLocalVariableTabletamintIithisLBJTorrent/GUI/TablaFicheros; ListaFicherosLjava/util/LinkedList; ListaRutasListaLongitudesLocalVariableTypeTable*Ljava/util/LinkedList;(Ljava/util/LinkedList; StackMapTableIK Signature(Ljava/util/LinkedList;Ljava/util/LinkedList;Ljava/util/LinkedList;)V SourceFileTablaFicheros.java Ljava/lang/String MN85O PQ86K RS[[Ljava/lang/String; TU V WXjava/lang/StringBuilder YZ[ \] Y^ _`java/lang/Long ab cd KBBJTorrent/GUI/TablaFicherosBJTorrent/GUI/ModeloTablajava/util/LinkedList()V columnNames[Ljava/lang/String;BJTorrent/GUI/IdiomaleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;size()Idata[[Ljava/lang/Object;longitudget(I)Ljava/lang/Object;append-(Ljava/lang/String;)Ljava/lang/StringBuilder; java/io/File separatorCharC(C)Ljava/lang/StringBuilder;toString()Ljava/lang/String; longValue()JvalueOf(I)Ljava/lang/String;!***S*S*+ *+ 6+, 7* 2 Y , + S* 2+ S- m6* 2 Y Su:,- ./"2/374C6L79;<4C>  :! "#$%&%'%( $)&)'*+:,---E8./01PK wC8CE BJTorrent/GUI/TablaFicheros.java/* * TablaFicheros.java * * Created on 20 de noviembre de 2007, 9:18 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; /** * * @author Benjamn Muiz Garca */ import javax.swing.JProgressBar; import java.util.LinkedList; import java.io.File; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; /** * * @author Benjamn Muiz Garca */ /** * * Subclase de ModeloTabla para crear una TableModel y mostrar los datos del componente * JTable que presenta la ruta y el tamao final de los ficheros en descarga. * Clase invocada por la clase VentanaDownload. * */ public class TablaFicheros extends ModeloTabla{ /** * * Crea una instancia de TablaFicheros * @param ListaFicheros LinkedList Lista con los nombres de los ficheros en descarga o compartidos. * @param ListaRutas LinkedList Lista con la ruta de directorios de cada fichero en descarga. * @param ListaLongitudes LinkedList Lista con el tamao total de cada fichero en descarga o compartido. */ public TablaFicheros(LinkedList ListaFicheros,LinkedList ListaRutas,LinkedList ListaLongitudes) { super(); columnNames=new String[2]; columnNames[0] = Idioma.leeEtiquetaIdioma("85"); columnNames[1]= Idioma.leeEtiquetaIdioma("86"); data=new String[ListaFicheros.size()][2]; longitud=ListaFicheros.size(); for (int i=0;i(Ljava/util/LinkedList;)VCodeLineNumberTableLocalVariableTablebajadosDauxLjava/lang/String;faltanaux2 labeliconoLjavax/swing/JLabel;imgURLLjava/net/URL; progressBarLjavax/swing/JProgressBar;taLBJTorrent/GUI/TorrenteAbierto;iIthisLBJTorrent/GUI/TablaTorrentes;TorrentesAbiertosLjava/util/LinkedList;LocalVariableTypeTable7Ljava/util/LinkedList; StackMapTablev Signature:(Ljava/util/LinkedList;)V SourceFileTablaTorrentes.java Njava/lang/String 50 5152535455565758 [[Ljava/lang/Object; b BJTorrent/GUI/TorrenteAbierto V  MB  KB javax/swing/JLabel BJTorrent/GUI/Principaliconos/sadsmiley.gif iconos/con-semillas.gif iconos/sin-semillas.gif iconos/sin-peers.gifjavax/swing/ImageIcon N LM javax/swing/JProgressBar N  100%99% java/lang/StringBuilder      BJTorrent/GUI/TablaTorrentesBJTorrent/GUI/ModeloTablajava/util/LinkedList java/net/URL()V columnNames[Ljava/lang/String;BJTorrent/GUI/IdiomaleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;size()Idatalongitudget(I)Ljava/lang/Object;nombre leeBajados()Jjava/lang/Mathfloor(D)D leefaltansetText(Ljava/lang/String;)Vjava/lang/Class getResource"(Ljava/lang/String;)Ljava/net/URL; leeSemillas leeClientes leeParado()Zjava/awt/ToolkitgetDefaultToolkit()Ljava/awt/Toolkit;getImage (Ljava/net/URL;)Ljava/awt/Image;(Ljava/awt/Image;)VsetIcon(Ljavax/swing/Icon;)VsetHorizontalTextPosition(I)V(II)VsetValuejava/awt/ColorGREENLjava/awt/Color; setForeground(Ljava/awt/Color;)VBLUE getString()Ljava/lang/String; setStringWHITE setBackgroundsetStringPainted(Z)Vappend(D)Ljava/lang/StringBuilder;-(Ljava/lang/String;)Ljava/lang/StringBuilder;toStringjava/lang/LongvalueOf(J)Ljava/lang/Long;leeVelocidadDL()Djava/lang/Double(D)Ljava/lang/Double;leeVelocidadULjava/lang/Integer(I)Ljava/lang/Integer;!JKLMNOP ** *S*S*S*S* S* S* S* S* S*+ *+>+n+M*2,S,9:oo%ook9:o9)ook9:o9,9: oo%ook9: o9)ook9: o9Y :  !"#$%: ,&#'%: (,(#)%: ,* #+%: *,Y- ./0 *01 2*2 S3Y,,`4:  ,5,  67 87 9:  ;< => ?*2 S"*2@YABCDS*2,ES "*2@YAB CDS*2,ES*2,FGS*2,HGS*2,&IS*2,(ISQG23 45#6.798D9O:[;g<s?@BDEHJKLMNPQRS UVW$X4Y8ZF\Q]]^a_ldue|ghiklmnqrstvw xy|&}0~7?EOVuBRp ISTEUVWTXV uYZ r[\ ]^ b_`sabcdefg ehiRjkXjklm%;m%-no^p=%DjkqrstPK wC8CQ22!BJTorrent/GUI/TablaTorrentes.java/* * TablaTorrentes.java * * Created on 20 de noviembre de 2007, 13:42 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; /** * * @author Benjamn Muiz Garca */ import javax.swing.JProgressBar; import java.util.LinkedList; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; /** * * Subclase de ModeloTabla para crear una TableModel y mostrar los datos del componente * JTable que presenta el estado de cada objeto de la clase TorrenteAbierto. * Clase invocada por la clase Principal. * */ public class TablaTorrentes extends ModeloTabla{ ImageIcon icono; // "Nombre Torrente","Progreso","Bajados","Bajada KB/seg", // "Subida KB/Seg","Semillas","Clientes" /** * * Crea una nueva instancia de la clase TablaTorrentes. * @param TorrentesAbiertos LinkedList Lista que almacena objetos de la clase * TorrenteAbierto donde se almacena la velocidad de subida y de bajada del Torrente, * n de semillas, nmero de bytes descargados, etc... * */ public TablaTorrentes(LinkedList TorrentesAbiertos) { super(); columnNames=new String[9]; columnNames[0] = Idioma.leeEtiquetaIdioma("50"); columnNames[1] = Idioma.leeEtiquetaIdioma("51"); columnNames[2]= Idioma.leeEtiquetaIdioma("52"); columnNames[3] = Idioma.leeEtiquetaIdioma("53"); columnNames[4]= Idioma.leeEtiquetaIdioma("54"); columnNames[5] = Idioma.leeEtiquetaIdioma("55"); columnNames[6]= Idioma.leeEtiquetaIdioma("56"); columnNames[7] = Idioma.leeEtiquetaIdioma("57"); columnNames[8] = Idioma.leeEtiquetaIdioma("58"); data=new Object[TorrentesAbiertos.size()][9] ; longitud=TorrentesAbiertos.size(); TorrenteAbierto ta; for (int i=0;i1) { bajados=(bajados/1024/1024*100); aux=" MB"; bajados=(Math.floor(bajados))/100; } else if (bajados / 1024 >1) { bajados=(bajados/1024*100.0); aux=" KB"; bajados=(Math.floor(bajados))/100; } double faltan=((double)ta.leefaltan()); String aux2=""; if (faltan / 1024 / 1024 >1) { faltan=(faltan/1024/1024*100); aux2=" MB"; faltan=(Math.floor(faltan))/100; } else if (faltan / 1024 >1) { faltan=(faltan/1024*100.0); aux2=" KB"; faltan=(Math.floor(faltan))/100; } JLabel labelicono=new JLabel(); labelicono.setText(" "); java.net.URL imgURL; imgURL = Principal.class.getResource("iconos/sadsmiley.gif"); if (ta.leeSemillas()>0) imgURL = Principal.class.getResource("iconos/con-semillas.gif"); else if (ta.leeClientes()>0) imgURL = Principal.class.getResource("iconos/sin-semillas.gif"); else if (ta.leeParado()==false) imgURL = Principal.class.getResource("iconos/sin-peers.gif"); icono = new ImageIcon (java.awt.Toolkit.getDefaultToolkit().getImage(imgURL)); labelicono.setIcon(icono); labelicono.setHorizontalTextPosition(JLabel.LEFT); data[i][0]=labelicono; JProgressBar progressBar = new JProgressBar(0,(int)ta.leefaltan()+(int)ta.leeBajados()); progressBar.setValue((int)ta.leeBajados()); if (ta.leefaltan()==0) progressBar.setForeground(java.awt.Color.GREEN); else { progressBar.setForeground(java.awt.Color.BLUE); if (progressBar.getString()=="100%") progressBar.setString("99%"); } progressBar.setBackground(java.awt.Color.WHITE); progressBar.setStringPainted(true); data[i][2]= progressBar; if (aux!="") data[i][3]=bajados+aux; else data[i][3]=ta.leeBajados(); if (aux2!="") data[i][4]=faltan+aux2; else data[i][4]=ta.leefaltan(); data[i][5]=ta.leeVelocidadDL(); data[i][6]=ta.leeVelocidadUL(); data[i][7]=ta.leeSemillas(); data[i][8]=ta.leeClientes(); //Salida.escribe(data[0][0]+"-"+data[0][2]+"-"+data[0][3]+"-"+data[0][4]+"-"+data[0][5]+"-"+data[0][6]); } } } PK wC8uII$BJTorrent/GUI/TablaVelocidades.class23   !"#$% & '()([[Ljava/lang/String;I)VCodeLineNumberTableLocalVariableTablethis LBJTorrent/GUI/TablaVelocidades;cadenas[[Ljava/lang/String; num_cadenasI StackMapTable( SourceFileTablaVelocidades.java *java/lang/String +,91- ./929394 01 2BJTorrent/GUI/TablaVelocidadesBJTorrent/GUI/ModeloTabla()V columnNames[Ljava/lang/String;BJTorrent/GUI/IdiomaleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;data[[Ljava/lang/Object;longitud! [***S*S*S*S+  L *  * *+ 2 /0 12"3-487<8F9P:U;Z@ [[[F  PK wC8QCmLL#BJTorrent/GUI/TablaVelocidades.java/* * TablaVelocidades.java * * Created on 20 de noviembre de 2007, 9:19 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; /** * * @author Benjamn Muiz Garca */ import java.util.LinkedList; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; /** * * Subclase de ModeloTabla para crear una TableModel y mostrar los datos del componente * JTable que presenta cada Peer con su ID, "IP:puerto", velocidad de subida y velocidad de * bajada. * Clase invocada por la clase VentanaDownload. * */ public class TablaVelocidades extends ModeloTabla{ //{"ID Cliente","IP","Velocidad UL","Velocidad DL"}; /** * * Crea una instancia de TablaVelocidades * @param cadenas String[][] Cada fila de este array bidimensional se corresponde con un peer. * En las columnas guardamos su ID cliente, su "IP:puerto" y sus velocidades de subida y bajada. * @param num_cadenas int Nmero de peers a los que estamos conectados + 1. La ltima fila se corresponde * con el sumatorio de velocidades de subida y bajada de todos los peers. * */ public TablaVelocidades(String [][]cadenas,int num_cadenas) { super(); columnNames=new String[4]; columnNames[0]=Idioma.leeEtiquetaIdioma("91"); columnNames[1]=Idioma.leeEtiquetaIdioma("92"); columnNames[2]=Idioma.leeEtiquetaIdioma("93"); columnNames[3]=Idioma.leeEtiquetaIdioma("94"); if (cadenas==null) { cadenas=new String[1][4]; } else data=new String[num_cadenas][4]; longitud=num_cadenas; data=cadenas; } } PK wC8z. . #BJTorrent/GUI/TorrenteAbierto.class2Y FG H I J K L M N O PH Q R S TUVnombreLjava/lang/String;torrente*LBJTorrent/FicheroTorrent/FicheroTorrente;faltanJbajadossubidos velocidadDLD velocidadULsemillasIclientesparadoZ ListaPiezas[LBJTorrent/Pieza;FicheroCompletadoLjava/util/LinkedList; Signature(Ljava/util/LinkedList;W(LBJTorrent/FicheroTorrent/FicheroTorrente;JJ[LBJTorrent/Pieza;Ljava/util/LinkedList;)VCodeLineNumberTableLocalVariableTablethisLBJTorrent/GUI/TorrenteAbierto;LocalVariableTypeTablei(LBJTorrent/FicheroTorrent/FicheroTorrente;JJ[LBJTorrent/Pieza;Ljava/util/LinkedList;)V leefaltan()J leeBajados leeSubidosleeVelocidadDL()DleeVelocidadUL leeSemillas()I leeClientes leeParado()Z escribeParado(Z)Vval StackMapTableactualizaTorrenteAbierto2(JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)VD(JJJDDII[LBJTorrent/Pieza;Ljava/util/LinkedList;)V SourceFileTorrenteAbierto.java (W       ! X "# $%  BJTorrent/GUI/TorrenteAbiertojava/lang/Object()V(BJTorrent/FicheroTorrent/FicheroTorrente!  !"#$%&' ()*P*** * * *** *+ ** * ** * +>< !')#+(=->8?=@CAIBOC,>P-.PPPP"#P$%/ P$'&012*/*+J, -.32*/*+Q, -.42*/*+X, -.56*/*+_, -.76*/*+g, -.89*/*+o, -.:9*/*+x, -.;<*/* +, -.=>*t* ****+ ,-.?!@AB*,Q* ******!*** * * * * +B !&,28>DJP,f Q-.QQQQQ Q Q Q"# Q$%/ Q$'@&CDEPK wC8f"BJTorrent/GUI/TorrenteAbierto.java/* * TorrenteAbierto.java * * Created on 20 de noviembre de 2007, 4:54 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; import BJTorrent.FicheroTorrent.FicheroTorrente; import BJTorrent.Pieza; /** * * @author Benjamn Muiz Garca */ import java.util.LinkedList; /** * * La ventana Principal maneja una Lista de objetos de esta clase * Sirve para mostrar por pantalla la informacin actualizada de todos los torrentes abiertos por el usuario. * Esta clase esta de apoyo al interfaz. */ public class TorrenteAbierto{ //String con el nombre del torrente public String nombre=""; //Objeto que almacena la informacin del fichero .torrent public FicheroTorrente torrente; //Nmero de bytes que faltan para completar la descarga del torrente private long faltan=0; //Nmero de bytes subidos de los peers de este torrente private long bajados=0; //Nmero de bytes subidos a los peers de este torrente private long subidos=0; //Velocidad de bajada de nuestro cliente desde los peers en este torrente private double velocidadDL; //Velocidad de subida de nuestro cliente hacia los peers en este torrente private double velocidadUL; //Nmero de semillas del torrente abierto o en descarga private int semillas=0; //Nmero de clientes del torrente abierto o en descarga private int clientes=0; //Indica si el torrente abierto o en descarga, o por el contrario esta parado private boolean parado=true; //Array de piezas que componen el torrente public Pieza[] ListaPiezas ; //Lista con el nmero de bytes descargados de cada fichero que compone el torrente public LinkedList FicheroCompletado; //Objeto que espera por eventos /** * Crea una nueva instancia de TorrenteAbierto * @param torrente FicheroTorrente Objeto que almacena la informacin del torrente como su * nmero de piezas, longitud en bytes, nombres y rutas de los ficheros, etc... * @param faltan long Nmero de bytes que faltan por descargar * @param bajados long Nmero de bytes descargados. * @param ListaPiezas Pieza[] Array con la informacin de las piezas que componen el torrente. * @param FicheroCompletado LinkedList Lista que contiene el nmero de bytes descargados de cada fichero * que compone el torrente. */ public TorrenteAbierto(FicheroTorrente torrente,long faltan,long bajados,Pieza[] ListaPiezas,LinkedList FicheroCompletado) { this.torrente=torrente; this.nombre=this.torrente.nombre; this.faltan=faltan; this.bajados=bajados; this.ListaPiezas=ListaPiezas; this.FicheroCompletado=FicheroCompletado; } /** * Devuelve el nmero de bytes que faltan para completar la descarga del torrente. * @return long Nmero de bytes que faltan para terminar el download. */ public long leefaltan(){ return this.faltan; } /** * Devuelve el nmero de bytes bajados del torrente. * @return long Nmero de bytes descargados y validados. */ public long leeBajados(){ return this.bajados; } /** * Devuelve el nmero de bytes subidos a otros peers del torrente. * @return long Nmero de bytes subidos a otros peers. */ public long leeSubidos(){ return this.subidos; } /** * Devuelve la velocidad de bajada de nuestro cliente en el torrente * @return double Velocidda bajada en Kb/seg */ public double leeVelocidadDL(){ return this.velocidadDL; } /** * Devuelve la velocidad de subida de nuestro cliente en el torrente * @return double Velocidad subida en Kb/seg */ public double leeVelocidadUL(){ return this.velocidadUL; } /** * Devuelve el nmero de semillas en el torrente * @return int Nmero de semillas con el torrente completo */ public int leeSemillas(){ return this.semillas; } /** * Devuelve el nmero de clientes en el torrente * @return int Nmero de clientes con el torrente incompleto */ public int leeClientes(){ return this.clientes; } /** * Devuelve el estado del torrente, si esta en descarga o est parado. * @return boolean true si el Torrente no esta activo y false si esta dispuesto para * subir o bajar piezas. */ public boolean leeParado(){ return this.parado; } /** * Pone el objeto TorrenteAbierto como inactivo o parado, o por el contrario como activo que indica * que puede compartir piezas con otros peers. * @param val boolean Escribimos en el atributo 'parado' el valor del argumento */ public void escribeParado(boolean val){ this.parado=val; if (val==true) { this.semillas=0; this.clientes=0; this.velocidadDL=0; this.velocidadUL=0; } } /** * * Mtodo que actualiza gran parte de la informacin de un objeto de la clase TorrenteAbierto. * Mtodo invocado por un evento de un objeto DownloadTorrent. * @param faltan long Nmero de bytes que faltan por descargar del torrente * @param bajados long Nmero de bytes descargados del torrente. * @param subidos long Nmero de bytes subidos a otros peers en este torrente. * @param velocidadDL double Velocidad de descarga de nuestro cliente en el torrente. * @param velocidadUL double Velocidad de subida de nuestro cliente en el torrente. * @param ListaPiezas Pieza[] Array con la informacin de las piezas que componen el torrente. * @param FicheroCompletado LinkedList Lista que contiene el nmero de bytes descargados de cada fichero * que componen el torrente. */ public void actualizaTorrenteAbierto(long faltan,long bajados,long subidos, double velocidadDL, double velocidadUL, int semillas, int clientes,Pieza[] ListaPiezas,LinkedList FicheroCompletado){ if (this.parado) { this.semillas=0; this.clientes=0; this.velocidadDL=0; this.velocidadUL=0; return; } this.faltan=faltan; this.bajados=bajados; this.subidos=subidos; this.velocidadDL=velocidadDL; this.velocidadUL=velocidadUL; this.semillas=semillas; this.clientes=clientes; this.ListaPiezas=ListaPiezas; this.FicheroCompletado=FicheroCompletado; //this.parado=false; } } PK wC8*<C C BJTorrent/GUI/VentanaAbout.class2 -> ,? ,@A BC > ,D ,E FG HIJ KL M NO P Q RSTU ,V W XY Z[ \ ] ^_ ^` ab ^c ^d ^e Zf ag h ^i jk ^l m ,nopjLabel1Ljavax/swing/JLabel; labelfoto txtprograma()VCodeLineNumberTableLocalVariableTablethisLBJTorrent/GUI/VentanaAbout;initComponentslayoutLjavax/swing/GroupLayout; SourceFileVentanaAbout.java 23 93 1/%Cliente de BitTorrent BJBT v 0.3.0.0 qrjavax/swing/JLabel 0/ ./ stjavax/swing/ImageIconu vw/BJTorrent/iconos/benjamin.jpgx yz 2{ |}Benjamín Muñiz García 95F066 ~t t t,Proyecto Fin de Carrera EPSIG - Informática$Cliente de BitTorrent BJBT V 0.2.2.3javax/swing/GroupLayout 2     3BJTorrent/GUI/VentanaAboutjavax/swing/JFramesetText(Ljava/lang/String;)VsetHorizontalAlignment(I)Vjava/lang/ObjectgetClass()Ljava/lang/Class;java/lang/Class getResource"(Ljava/lang/String;)Ljava/net/URL;(Ljava/net/URL;)VsetIcon(Ljavax/swing/Icon;)VsetVerticalAlignmentsetHorizontalTextPositionsetVerticalTextPositiongetContentPane()Ljava/awt/Container;(Ljava/awt/Container;)Vjava/awt/Container setLayout(Ljava/awt/LayoutManager;)V!javax/swing/GroupLayout$Alignment Alignment InnerClassesLEADING#Ljavax/swing/GroupLayout$Alignment;createParallelGroup ParallelGroupL(Ljavax/swing/GroupLayout$Alignment;)Ljavax/swing/GroupLayout$ParallelGroup;createSequentialGroupSequentialGroup+()Ljavax/swing/GroupLayout$SequentialGroup;'javax/swing/GroupLayout$SequentialGroupaddGap.(III)Ljavax/swing/GroupLayout$SequentialGroup; addComponentB(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$SequentialGroup;%javax/swing/GroupLayout$ParallelGroupaddGroupGroupH(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;?(Ljava/awt/Component;)Ljavax/swing/GroupLayout$SequentialGroup;J(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$SequentialGroup;addContainerGap-(II)Ljavax/swing/GroupLayout$SequentialGroup;TRAILINGk(Ljavax/swing/GroupLayout$Alignment;Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;setHorizontalGroup"(Ljavax/swing/GroupLayout$Group;)V*javax/swing/LayoutStyle$ComponentPlacementComponentPlacementRELATED,Ljavax/swing/LayoutStyle$ComponentPlacement;addPreferredGapW(Ljavax/swing/LayoutStyle$ComponentPlacement;)Ljavax/swing/GroupLayout$SequentialGroup;setVerticalGrouppackjavax/swing/GroupLayout$Groupjavax/swing/LayoutStyle!,-./0/1/234H***56 78934 H*Y*Y *Y* * Y*  ***** *Y*L*++++++$$$* +KKK*! "# $+A#* !***%&+++'*!*!()* !# **+5F# $%!')(@)I*Q+Y,a.j0s234DCOGP6H78:;<=*Z@a^j@PK wC88@3BJTorrent/GUI/VentanaAbout.form
PK wC8L:ggBJTorrent/GUI/VentanaAbout.java/* * VentanaAbout.java * * Created on 20 de diciembre de 2007, 16:45 */ package BJTorrent.GUI; import BJTorrent.Constantes; /** * * @author Benjamn Muiz Garca */ /** * Ventana que muestra la versin y autor del programa */ public class VentanaAbout extends javax.swing.JFrame { /** Crea una nueva instancia de * VentanaAbout */ public VentanaAbout() { initComponents(); this.txtprograma.setText("Cliente de BitTorrent "+ Constantes.PROGRAMA+" v "+Constantes.VERSION); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { labelfoto = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); txtprograma = new javax.swing.JLabel(); labelfoto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); labelfoto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/iconos/benjamin.jpg"))); labelfoto.setText("Benjam\u00edn Mu\u00f1iz Garc\u00eda 95F066"); labelfoto.setVerticalAlignment(javax.swing.SwingConstants.TOP); labelfoto.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); labelfoto.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jLabel1.setText("Proyecto Fin de Carrera EPSIG - Inform\u00e1tica"); txtprograma.setText("Cliente de BitTorrent BJBT V 0.2.2.3"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(36, 36, 36) .addComponent(labelfoto, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(75, 75, 75) .addComponent(txtprograma))) .addContainerGap(22, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(65, Short.MAX_VALUE) .addComponent(jLabel1) .addGap(42, 42, 42)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(labelfoto) .addGap(26, 26, 26) .addComponent(txtprograma) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1) .addContainerGap(26, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents // Declaracin de varibales -no modificar//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel labelfoto; private javax.swing.JLabel txtprograma; // Fin de declaracin de variables//GEN-END:variables } PK wC8Cpa##%BJTorrent/GUI/VentanaDownload$1.class2$   this$0LBJTorrent/GUI/VentanaDownload;"(LBJTorrent/GUI/VentanaDownload;)VCodeLineNumberTableLocalVariableTablethis InnerClasses!LBJTorrent/GUI/VentanaDownload$1;componentShown"(Ljava/awt/event/ComponentEvent;)VevtLjava/awt/event/ComponentEvent; SourceFileVentanaDownload.javaEnclosingMethod !  ! "#BJTorrent/GUI/VentanaDownload$1java/awt/event/ComponentAdapterBJTorrent/GUI/VentanaDownloadinitComponents()V access$100A(LBJTorrent/GUI/VentanaDownload;Ljava/awt/event/ComponentEvent;)V0  4 *+*    A *+     PK wC86Ӯ0BJTorrent/GUI/VentanaDownload$ProgRenderer.class22 ' ( )*,-.this$0LBJTorrent/GUI/VentanaDownload;"(LBJTorrent/GUI/VentanaDownload;)VCodeLineNumberTableLocalVariableTablethis ProgRenderer InnerClasses,LBJTorrent/GUI/VentanaDownload$ProgRenderer;getTableCellRendererComponent@(Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/awt/Component;tableLjavax/swing/JTable;valueLjava/lang/Object; isSelectedZhasFocusrowIcolumn/C(LBJTorrent/GUI/VentanaDownload;LBJTorrent/GUI/VentanaDownload$1;)Vx0x1!LBJTorrent/GUI/VentanaDownload$1; SourceFileVentanaDownload.java  0javax/swing/JProgressBar1*BJTorrent/GUI/VentanaDownload$ProgRendererjava/lang/Object#javax/swing/table/TableCellRendererBJTorrent/GUI/VentanaDownload$1()VBJTorrent/GUI/VentanaDownload    4 *+*    k, H ! D*+  " #$%&+PK wC8f: Q++#BJTorrent/GUI/VentanaDownload.class2                  T  @@Y          !  " # $% &  ' ( )*+,  -  . 0/ 01 5 2 53 54 56 78 9 ]:; >< = > ?@ C/ A BC DE 5FG JH 7I JK N LM Q NO T P Q R S T U VW ] X Y Z[ b\ ]^_`abcdefghijkl sm Qn op sq sr st ou vw sx yz s{ v| s} s~ v s s v s o s s N  n  N ProgRenderer InnerClassestorrente*LBJTorrent/FicheroTorrent/FicheroTorrente; ListaPiezas[LBJTorrent/Pieza;FicheroCompletadoLjava/util/LinkedList; Signature(Ljava/util/LinkedList;tracker_elegidoLjava/lang/String;intervalo_trackerImodelo_ficherosLBJTorrent/GUI/TablaFicheros;modelo_velocidades LBJTorrent/GUI/TablaVelocidades;modelo_descargasLBJTorrent/GUI/TablaDescargas;jPanel1Ljavax/swing/JPanel;jPanel4jPanel5 jScrollPane1Ljavax/swing/JScrollPane; jScrollPane2 jScrollPane3 jTabbedPane1Ljavax/swing/JTabbedPane;label5Ljavax/swing/JLabel;label_actualizacion label_nombrelabel_num_piezas label_tamlabel_tam_pieza label_trackerlabelactualizacion labelhash labelnombrelabelnumpiezaslabelrastreador labeltamano labeltampiezajtable_ficherosLjavax/swing/JTable;jtable_velocidadesjtable_descragasT(LBJTorrent/FicheroTorrent/FicheroTorrente;Ljava/util/LinkedList;Ljava/awt/Frame;Z)VCodeLineNumberTableLocalVariableTablethisLBJTorrent/GUI/VentanaDownload;padreLjava/awt/Frame;modalZcadenas[[Ljava/lang/String;LocalVariableTypeTablef(LBJTorrent/FicheroTorrent/FicheroTorrente;Ljava/util/LinkedList;Ljava/awt/Frame;Z)VescribePanelTorrente()VitamDcolumnLjavax/swing/table/TableColumn; StackMapTableactualizaTablasGUIY([[Ljava/lang/String;IJJLjava/util/LinkedList;Ljava/util/LinkedList;Ljava/lang/String;I)V num_cadenasbajadosJsubidos fichcompleto fichlongitud}([[Ljava/lang/String;IJJLjava/util/LinkedList;Ljava/util/LinkedList;Ljava/lang/String;I)VinitComponents jPanel1LayoutLjavax/swing/GroupLayout; jPanel4Layout jPanel5LayoutlayoutformComponentShown"(Ljava/awt/event/ComponentEvent;)VevtLjava/awt/event/ComponentEvent;ponerTextoEtiquetas access$100A(LBJTorrent/GUI/VentanaDownload;Ljava/awt/event/ComponentEvent;)Vx0x1 SourceFileVentanaDownload.java  Total: 0.0 Kb/seg      java/lang/StringBuilder    MB  KB     Bytes   segsActualizandoseBJTorrent/GUI/TablaFicheros    javax/swing/JTable     BJTorrent/GUI/TablaVelocidades  BJTorrent/GUI/TablaDescargas 102  *BJTorrent/GUI/VentanaDownload$ProgRenderer   javax/swing/JTabbedPane javax/swing/JPanel javax/swing/JLabel javax/swing/JScrollPane BJTorrent/GUI/VentanaDownload$1   TamañoPieza:Número de Piezas: Rastreador:Próxima Actuatlización:Nombre del Torrente: Hash SHA-1:Tamaño del Torrente:jLabel8jLabel9jLabel10jLabel11jLabel12jLabel1jLabel2javax/swing/GroupLayout                      Fichero Torrente Velocidad Peers Descargas  80 81828384878890100BJTorrent/GUI/VentanaDownloadjavax/swing/JDialog'BJTorrent/GUI/VentanaDownloadEscuchadorjavax/swing/table/TableColumn(Ljava/awt/Frame;Z)V(BJTorrent/FicheroTorrent/FicheroTorrenteListaLongitudesnombresetText(Ljava/lang/String;)Vlongitudjava/lang/Mathround(D)Jjava/lang/StringvalueOf(D)Ljava/lang/String;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/String; num_piezas(I)Ljava/lang/String; tam_pieza(J)Ljava/lang/String; infohashhex ListaFicheros ListaRutasE(Ljava/util/LinkedList;Ljava/util/LinkedList;Ljava/util/LinkedList;)VsetModel!(Ljavax/swing/table/TableModel;)VgetColumnModel&()Ljavax/swing/table/TableColumnModel;"javax/swing/table/TableColumnModel getColumn"(I)Ljavax/swing/table/TableColumn;setPreferredWidth(I)VsetViewportView(Ljava/awt/Component;)V([[Ljava/lang/String;I)VBJTorrent/GUI/IdiomaleeEtiquetaIdioma&(Ljava/lang/String;)Ljava/lang/String;3(Ljava/lang/Object;)Ljavax/swing/table/TableColumn;C(LBJTorrent/GUI/VentanaDownload;LBJTorrent/GUI/VentanaDownload$1;)VsetCellRenderer((Ljavax/swing/table/TableCellRenderer;)VsetDefaultCloseOperation"(LBJTorrent/GUI/VentanaDownload;)VaddComponentListener%(Ljava/awt/event/ComponentListener;)V(Ljava/awt/Container;)V setLayout(Ljava/awt/LayoutManager;)V!javax/swing/GroupLayout$Alignment AlignmentLEADING#Ljavax/swing/GroupLayout$Alignment;createParallelGroup ParallelGroupL(Ljavax/swing/GroupLayout$Alignment;)Ljavax/swing/GroupLayout$ParallelGroup;createSequentialGroupSequentialGroup+()Ljavax/swing/GroupLayout$SequentialGroup;'javax/swing/GroupLayout$SequentialGroupaddGap.(III)Ljavax/swing/GroupLayout$SequentialGroup;TRAILING%javax/swing/GroupLayout$ParallelGroup addComponent=(Ljava/awt/Component;)Ljavax/swing/GroupLayout$ParallelGroup;addGroupGroupJ(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$SequentialGroup;*javax/swing/LayoutStyle$ComponentPlacementComponentPlacementRELATED,Ljavax/swing/LayoutStyle$ComponentPlacement;addPreferredGapW(Ljavax/swing/LayoutStyle$ComponentPlacement;)Ljavax/swing/GroupLayout$SequentialGroup;@(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$ParallelGroup;B(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$SequentialGroup;?(Ljava/awt/Component;)Ljavax/swing/GroupLayout$SequentialGroup;H(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;Y(Ljavax/swing/LayoutStyle$ComponentPlacement;II)Ljavax/swing/GroupLayout$SequentialGroup;addContainerGapk(Ljavax/swing/GroupLayout$Alignment;Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;setHorizontalGroup"(Ljavax/swing/GroupLayout$Group;)VBASELINE-(II)Ljavax/swing/GroupLayout$SequentialGroup;setVerticalGroupaddTab)(Ljava/lang/String;Ljava/awt/Component;)VgetContentPane()Ljava/awt/Container;java/awt/Containerpack setTitleAt(ILjava/lang/String;)Vjavax/swing/GroupLayout$Groupjavax/swing/LayoutStyle!  m*-***+*,** *  :2S2 S2 S2 S* ****>:# %<=> @$B(C0D8E@FHGPIlK>mmmmm0= m***mH'7'okH'oH*Y' ! *Y'"!*#*$%*&H','oH*'Y'("!&*'Y*&%)!***+*,**&*-Y*%.! *-/*0Y*1*2*34*5Y67*7*48N6-*79:N -; -d;*<*7=zVWX#Y-Z7[W]t_abcefhmno%q.tNwYxdyfzo{~|}z*i0f? WJ"B:# m* * *>Y+?@*5Y6A*A*@8: 6  _*A9 ::  D)3= d; d; 2;  2; *B*A=*CY*1DE*5Y6F*F*E8*FGHIJY*KL*M*F=: 6  G*F9 ::  ,$ ;  ȶ; *,**-Y*%.!" $/2;Klsv} (03;ALlz 5b J mmmmmmmm m 2; mm 56 _0  J*NYOP*QYRS*TYUV*TYUW*TYUX*TYUY*TYUZ*TYU[*TYU\*TYU*TYU*TYU'*TYU**TYU#*TYU,*TYU-*]Y^<*QYR_*]Y^B*QYR`*]Y^M*a*bY*cd*Ve*Wf*Xg*Yh*Zi*[j*\k*l*m*'n**o*#p*,q*-rsY*StL*S+u++vw+x+vw+xy+zw*\{*V{*[{|}~+vw**W+x*'Gy*W}~*#*|}~+x+zw*Y{*X{|y+vw*-*,Y|+xy+vw*B*Z{|z+x*<M|++vw+x*Z}~*   y+w*\{*{|}~+w*V{*W{*'{*#{|y+w*[{**{|}~*<y+w*X{*,{|}~+w*Y{*-{|*P*SsY*_tM*_,u,,vw,xRRRy*B],,vw,x*BHG*P*_sY*`tN*`-u--vw-x*MM--vw-x*Mh'*P*`sY*t:*vwzx*Pfvwxy*P*: !,7BMXcny %.7@I R [dmv>_abc&jQq^sjtru|EI4J]jm=*  p*PH*ZH*\H*VH*WH*XH*YH*PH*PH*  %1=IUbo p:*+:Jbos@vssssy@PK wC8DydAA"BJTorrent/GUI/VentanaDownload.form
PK wC8gKQYY"BJTorrent/GUI/VentanaDownload.java/* * VentanaDownload.java * * Created on 16 de noviembre de 2007, 12:16 */ package BJTorrent.GUI; import BJTorrent.FicheroTorrent.FicheroTorrente; import BJTorrent.Pieza; /** * * @author Benjamn Muiz Garca */ import java.util.LinkedList; import javax.swing.JProgressBar; import javax.swing.JTable; import javax.swing.table.TableCellRenderer; import java.awt.Component; /** * * Clase VentanaDownload es una subclase de JDialog * */ public class VentanaDownload extends javax.swing.JDialog implements VentanaDownloadEscuchador{ //Objeto que almacena la informacin del fichero .torrent private FicheroTorrente torrente; //Array de piezas del torrente private Pieza[] ListaPiezas ; //Lista con el nmero de bytes descargados de cada fichero que compone el torrente private LinkedList FicheroCompletado; //Nombre del host al que hicimos el anuncio y nos devolvi la lista de Peers private String tracker_elegido=""; //Tiempo en segundos hasta la prxima actualizacin del tracker private int intervalo_tracker=0; private TablaFicheros modelo_ficheros; private TablaVelocidades modelo_velocidades; private TablaDescargas modelo_descargas; /** * * Crea un nuevo cuadro de dialogo * @param torrente FicheroTorrente Instancia de FicheroTorrente que parsea el fichero torrente * y tiene almacenados la lista de trackers, las SHA-1 de las piezas, tamao en bytes del torrente, etc * @param FicheroCompletado LinkedList Lista que contiene el numero de bytes descargado de * cada fichero del torrente * @param padre Frame Ventana padre * @param modal boolean Indica si el cuadro de dialogo es modal, es decir si siempre va a tener el focus * de la aplicacin antes de ser cerrada, o por el contrario el focus de la aplicacin lo puede tener otra * ventana. * */ public VentanaDownload(FicheroTorrente torrente,LinkedList FicheroCompletado,java.awt.Frame padre, boolean modal) { super(padre, modal); this.torrente=torrente; this.FicheroCompletado=FicheroCompletado; initComponents(); this.ponerTextoEtiquetas(); escribePanelTorrente(); String [][]cadenas=new String[1][4]; cadenas[0][0]=""; cadenas[0][1]="Total:"; cadenas[0][2]=" 0.0 Kb/seg"; cadenas[0][3]=" 0.0 Kb/seg"; actualizaTablasGUI(cadenas,1,0,0,this.FicheroCompletado,this.torrente.ListaLongitudes,this.tracker_elegido,this.intervalo_tracker); } /** * * Mtodo que muestra en pantalla en el objeto JTabbedPane una tabla con la informacin del Torrente, como * tamao del torrente, nmero de piezas, Tracker al que nos conectamos y los ficheros que componen * el torrente con su tamao en bytes. * */ public void escribePanelTorrente() { double tam; this.labelnombre.setText(this.torrente.nombre); tam=(this.torrente.longitud) / 1024; if (tam>1024) { tam=((tam/1024)*100); tam=(Math.round(tam)/100.0); this.labeltamano.setText(String.valueOf(tam)+" MB"); } else this.labeltamano.setText(String.valueOf(tam)+" KB"); this.labelnumpiezas.setText(String.valueOf(this.torrente.num_piezas)); tam=this.torrente.tam_pieza; if (tam >1024) { tam=tam / 1024; this.labeltampieza.setText(String.valueOf(Math.round(tam))+" KB"); } else this.labeltampieza.setText(String.valueOf(this.torrente.tam_pieza)+" Bytes"); this.labelhash.setText(this.torrente.infohashhex); this.labelrastreador.setText(this.tracker_elegido); if (this.intervalo_tracker>0) this.labelactualizacion.setText(String.valueOf(this.intervalo_tracker)+ " segs"); else this.labelactualizacion.setText("Actualizandose"); modelo_ficheros=new TablaFicheros(this.torrente.ListaFicheros,this.torrente.ListaRutas,this.torrente.ListaLongitudes); jtable_ficheros= new javax.swing.JTable(); jtable_ficheros.setModel(modelo_ficheros); javax.swing.table.TableColumn column = null; for (int i = 0; i < 2; i++) { column = jtable_ficheros.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(500); //third column is bigger } else { column.setPreferredWidth(100); } } jScrollPane1.setViewportView(jtable_ficheros); } /** * Mtodo invocado por un evento producido en el objeto DownloadTorrent cada cierto intervalo de tiempo. *
Actualiza en pantalla el tracker contactado y su intervalo hasta una nueva consulta. *
Actualiza en la pantalla la tabla de velocidades de los peers *
Actualiza en la tabla de descargas el progreso o bytes descargados de los ficheros del torrente. * @param cadenas String[][] Cada fila de este array bidimensional se corresponde con un peer. * En las columnas guardamos su ID cliente, su "IP:puerto" y sus velocidades de subida y bajada. * @param num_cadenas int Nmero de peers a los que estamos conectados + 1. La ltima fila se corresponde * con el sumatorio de velocidades de subida y bajada de todos los peers. * @param bajados long Nmero de bytes descargados hasta el momento * @param subidos long Nmero de bytes subidos a otros peers. * @param fichcompleto LinkedList Lista con los bytes descargados de los ficheros que componen el torrente * @param fichlongitud LinkedList Longitud total de todos los ficheros que componen el torrente. * @param tracker_elegido String Tracker que nos devolvi la lista de Peers que comparten el torrente. * @param intervalo_tracker int Nmero de segundos que restan para la nueva consulta de Peers al tracker. */ public void actualizaTablasGUI(String [][]cadenas,int num_cadenas,long bajados, long subidos,LinkedList fichcompleto,LinkedList fichlongitud,String tracker_elegido, int intervalo_tracker){ this.tracker_elegido=tracker_elegido; this.intervalo_tracker=intervalo_tracker; modelo_velocidades=new TablaVelocidades(cadenas,num_cadenas); jtable_velocidades= new javax.swing.JTable(); jtable_velocidades.setModel(modelo_velocidades); javax.swing.table.TableColumn column = null; for (int i = 0; i < 4; i++) { column = jtable_velocidades.getColumnModel().getColumn(i); switch (i) { case 0: column.setPreferredWidth(100); break; case 1: column.setPreferredWidth(100); break; case 2: column.setPreferredWidth(50); break; case 3: column.setPreferredWidth(50); break; } } jScrollPane2.setViewportView(jtable_velocidades); modelo_descargas=new TablaDescargas(this.torrente.ListaFicheros,fichcompleto,fichlongitud ); jtable_descragas= new javax.swing.JTable(); jtable_descragas.setModel(modelo_descargas); jtable_descragas.getColumn(Idioma.leeEtiquetaIdioma("102")).setCellRenderer(new ProgRenderer()); jScrollPane3.setViewportView(jtable_descragas); //jtable_descragas= new javax.swing.JTable(data3, columnas3); column = null; for (int i = 0; i < 2; i++) { column = jtable_descragas.getColumnModel().getColumn(i); switch (i) { case 0: column.setPreferredWidth(400); //third column is bigger break; case 1: column.setPreferredWidth(200); //third column is bigger break; } } this.labelrastreador.setText(this.tracker_elegido); this.labelactualizacion.setText(String.valueOf(this.intervalo_tracker)+ " segs"); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); label_tam_pieza = new javax.swing.JLabel(); label_num_piezas = new javax.swing.JLabel(); label_tracker = new javax.swing.JLabel(); label_actualizacion = new javax.swing.JLabel(); label_nombre = new javax.swing.JLabel(); label5 = new javax.swing.JLabel(); label_tam = new javax.swing.JLabel(); labelnombre = new javax.swing.JLabel(); labeltamano = new javax.swing.JLabel(); labeltampieza = new javax.swing.JLabel(); labelhash = new javax.swing.JLabel(); labelnumpiezas = new javax.swing.JLabel(); labelrastreador = new javax.swing.JLabel(); labelactualizacion = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jPanel4 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jPanel5 = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentShown(java.awt.event.ComponentEvent evt) { formComponentShown(evt); } }); label_tam_pieza.setText("Tama\u00f1oPieza:"); label_num_piezas.setText("N\u00famero de Piezas:"); label_tracker.setText("Rastreador:"); label_actualizacion.setText("Pr\u00f3xima Actuatlizaci\u00f3n:"); label_nombre.setText("Nombre del Torrente:"); label5.setText("Hash SHA-1:"); label_tam.setText("Tama\u00f1o del Torrente:"); labelnombre.setText("jLabel8"); labeltamano.setText("jLabel9"); labeltampieza.setText("jLabel10"); labelhash.setText("jLabel11"); labelnumpiezas.setText("jLabel12"); labelrastreador.setText("jLabel1"); labelactualizacion.setText("jLabel2"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(label_tam) .addComponent(label_tam_pieza) .addComponent(label5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelhash, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(labeltampieza, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(16, 16, 16) .addComponent(label_num_piezas) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelnumpiezas, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(labeltamano, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 126, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(label_actualizacion) .addComponent(label_tracker)) .addGap(14, 14, 14) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelactualizacion, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelrastreador, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(21, 21, 21) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelnombre, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE) .addComponent(label_nombre))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(label_nombre) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelnombre) .addGap(12, 12, 12) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(label_tam) .addComponent(labeltamano)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(label_tam_pieza) .addComponent(label_num_piezas) .addComponent(labeltampieza) .addComponent(labelnumpiezas)) .addGap(26, 26, 26) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(label5) .addComponent(labelhash)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(label_tracker) .addComponent(labelrastreador)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(label_actualizacion) .addComponent(labelactualizacion)) .addContainerGap(17, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Fichero Torrente", jPanel1); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(82, 82, 82) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 434, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(93, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(71, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Velocidad Peers", jPanel4); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE) .addContainerGap()) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(39, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Descargas", jPanel5); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 614, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(22, 22, 22) .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 435, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown // TODO: Agrege su codigo aqui: this.ponerTextoEtiquetas(); }//GEN-LAST:event_formComponentShown /** * Clase que implementa el interfaz TableCellRenderer, llamado cuando se dibuja un JProgressBar * en una celda de un JTable. */ private class ProgRenderer implements TableCellRenderer{ /** * * Devuelve el componente JProgressBar usado para dibujar la celda de la tabla * */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ return (JProgressBar)value; } } /** * * Mtodo que cambia el texto de todas las etiquetas de la ventana en funcin del Idioma seleccionado * en la clase VentanaPreferencias. */ public void ponerTextoEtiquetas(){ this.jTabbedPane1.setTitleAt(0,Idioma.leeEtiquetaIdioma("80")); this.label_nombre.setText(Idioma.leeEtiquetaIdioma("81")); this.label_tam.setText(Idioma.leeEtiquetaIdioma("82")); this.label_tam_pieza.setText(Idioma.leeEtiquetaIdioma("83")); this.label_num_piezas.setText(Idioma.leeEtiquetaIdioma("84")); this.label_tracker.setText(Idioma.leeEtiquetaIdioma("87")); this.label_actualizacion.setText(Idioma.leeEtiquetaIdioma("88")); this.jTabbedPane1.setTitleAt(1,Idioma.leeEtiquetaIdioma("90")); this.jTabbedPane1.setTitleAt(2,Idioma.leeEtiquetaIdioma("100")); } // Declaracin de varibales -no modificar//GEN-BEGIN:variables private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JLabel label5; private javax.swing.JLabel label_actualizacion; private javax.swing.JLabel label_nombre; private javax.swing.JLabel label_num_piezas; private javax.swing.JLabel label_tam; private javax.swing.JLabel label_tam_pieza; private javax.swing.JLabel label_tracker; private javax.swing.JLabel labelactualizacion; private javax.swing.JLabel labelhash; private javax.swing.JLabel labelnombre; private javax.swing.JLabel labelnumpiezas; private javax.swing.JLabel labelrastreador; private javax.swing.JLabel labeltamano; private javax.swing.JLabel labeltampieza; // Fin de declaracin de variables//GEN-END:variables private javax.swing.JTable jtable_ficheros; private javax.swing.JTable jtable_velocidades; private javax.swing.JTable jtable_descragas; } PK wC8J-BJTorrent/GUI/VentanaDownloadEscuchador.class2    actualizaTablasGUIY([[Ljava/lang/String;IJJLjava/util/LinkedList;Ljava/util/LinkedList;Ljava/lang/String;I)V Signature}([[Ljava/lang/String;IJJLjava/util/LinkedList;Ljava/util/LinkedList;Ljava/lang/String;I)V SourceFileVentanaDownloadEscuchador.java'BJTorrent/GUI/VentanaDownloadEscuchadorjava/lang/Objectjava/util/EventListener PK wC8C^K,BJTorrent/GUI/VentanaDownloadEscuchador.java/* * VentanaDownloadEscuchador.java * * Created on 16 de noviembre de 2007, 17:49 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent.GUI; /** * * @author Benjamn Muiz Garca */ import java.util.LinkedList; import java.util.EventListener; /** * Interface implementado en VentanaDownload */ public interface VentanaDownloadEscuchador extends EventListener{ /** * * Evento que nos informa, cada cierto intervalo de tiempo, de los * nuevos datos a mostrar por pantalla en las tres tablas JTable que componen la ventana VentanaDownload. * Evento lanzado por un objeto DownloadTorrent. * * @param cadenas String[][] Cada fila de este array bidimensional se corresponde con un peer. * En las columnas guardamos su ID cliente, su "IP:puerto" y sus velocidades de subida y bajada. * @param num_cadenas int Nmero de peers a los que estamos conectados + 1. La ltima fila se corresponde * con el sumatorio de velocidades de subida y bajada de todos los peers. * @param bajados long Nmero de bytes descargados hasta el momento * @param subidos long Nmero de bytes subidos a otros peers. * @param fichcompleto LinkedList Lista con los bytes descargados de los ficheros que componen el torrente * @param fichlongitud LinkedList Longitud total de todos los ficheros que componen el torrente. * @param tracker_elegido String Tracker que nos devolvi la lista de Peers que comparten el torrente. * @param intervalo_tracker int Nmero de segundos que restan para la nueva consulta de Peers al tracker. */ public void actualizaTablasGUI(String [][]cadenas,int num_cadenas, long bajados, long subidos, LinkedList fichcompleto,LinkedList fichlongitud, String tracker_elegido , int intervalo_tracker); } PK wC8#MM)BJTorrent/GUI/VentanaPreferencias$1.class2&    this$0#LBJTorrent/GUI/VentanaPreferencias;&(LBJTorrent/GUI/VentanaPreferencias;)VCodeLineNumberTableLocalVariableTablethis InnerClasses%LBJTorrent/GUI/VentanaPreferencias$1;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFileVentanaPreferencias.javaEnclosingMethod! "#  # $%#BJTorrent/GUI/VentanaPreferencias$1java/lang/Objectjava/awt/event/ActionListener!BJTorrent/GUI/VentanaPreferenciasinitComponents()V access$000B(LBJTorrent/GUI/VentanaPreferencias;Ljava/awt/event/ActionEvent;)V0  4 *+* <   A *+ >?    PK wC8V'MM)BJTorrent/GUI/VentanaPreferencias$2.class2&    this$0#LBJTorrent/GUI/VentanaPreferencias;&(LBJTorrent/GUI/VentanaPreferencias;)VCodeLineNumberTableLocalVariableTablethis InnerClasses%LBJTorrent/GUI/VentanaPreferencias$2;actionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent; SourceFileVentanaPreferencias.javaEnclosingMethod! "#  # $%#BJTorrent/GUI/VentanaPreferencias$2java/lang/Objectjava/awt/event/ActionListener!BJTorrent/GUI/VentanaPreferenciasinitComponents()V access$100B(LBJTorrent/GUI/VentanaPreferencias;Ljava/awt/event/ActionEvent;)V0  4 *+*    A *+     PK wC8.<66'BJTorrent/GUI/VentanaPreferencias.class2 B C DE D F G H I JK D L MNO PQ R STU DV W X X YZ [ \]^ _ ` ab cd ef g hi jk lm no p q r s et u v w xy z{|}~  a   MX a    UD  XD  [D  ^D  aD   eD                    Ut | U  X [t a ^  X                    P  U         D   e `       a  propLjava/util/Properties; prop_streamLjava/io/InputStream;puertoI directorioLjava/lang/String;proxy_host_SOCKSproxy_host_HTTPproxy_SOCKS_puertoproxy_HTTP_puerto max_peers velocidadUL velocidadDLidiomaIdiomasLjava/util/Vector; VelocidadesUL VelocidadesDLfcLjavax/swing/JFileChooser;botonprefsaplicarLjavax/swing/JButton;jButton1jLabel1Ljavax/swing/JLabel;jLabel2jLabel3jPanel1Ljavax/swing/JPanel;jPanel2jPanel3jPanel4jPanel5jPanel6jPanel7 jScrollPane1Ljavax/swing/JScrollPane; jScrollPane2 jScrollPane3labelcompartido labelexample labelidioma labelmaxpeerslabelproxySOCKSlabelproxySOCKSpuerto labelpuertolabelvelocidadDLlabelvelocidadUL lista_idiomasLjavax/swing/JList;lista_velocidadesDLlista_velocidadesULlista_velocidadesUL2txt_directorioLjavax/swing/JTextField; txt_max_peerstxt_proxy_SOCKStxt_proxy_SOCKS_puerto txt_puerto()VCodeLineNumberTableLocalVariableTableioeLjava/io/IOException;ithis#LBJTorrent/GUI/VentanaPreferencias; StackMapTableT leePuerto()Ilee_directorioCompartido()Ljava/lang/String; leeProxyHTTP leeProxySOCKSleeProxyHTTPPuertoleeProxySOCKSPuerto leeMaxPeersleeLimiteVelocidadULleeLimiteVelocidadDL leeIdiomainitComponents jPanel1LayoutLjavax/swing/GroupLayout; jPanel2Layout jPanel3Layout jPanel4Layout jPanel5Layout jPanel6Layout jPanel7LayoutlayoutjButton1ActionPerformed(Ljava/awt/event/ActionEvent;)VevtLjava/awt/event/ActionEvent;fLjava/io/File;  botonprefsaplicarActionPerformedponerTextoEtiquetas access$000B(LBJTorrent/GUI/VentanaPreferencias;Ljava/awt/event/ActionEvent;)Vx0x1 access$100 SourceFileVentanaPreferencias.java 01 81  java/util/Vector & 9java/util/Properties    "properties/preferencias.properties  java/io/IOExceptionjava/lang/StringBuilderError IO Clase Preferencias    java/lang/Integer     proxy SOCKS  proxy HTTP proxy SOCKS puerto  proxy HTTP puerto  max peers  velocidad UL  velocidad DL           8  12162432  !" # $% &'2550100150200300400 ESPAÑOLENGLISHFRANCAIS  ()javax/swing/JButton javax/swing/JPanel javax/swing/JLabel javax/swing/JScrollPane javax/swing/JList javax/swing/JTextField    Aplicar#BJTorrent/GUI/VentanaPreferencias$1 InnerClasses  * +,- ./ 01Idioma 2' 34javax/swing/GroupLayout  5 678 :; <> ?AB CAD EF GJ CK GL MN EOQ ST UV EW XN Proxy SOCKS Puerto SOCKS <Y EZ U[ \] ^;Directorio Compartidosjavax/swing/ImageIcon/BJTorrent/GUI/iconos/open.gif _`  a bc#BJTorrent/GUI/VentanaPreferencias$2 d; GePuerto Aceptar Conexiones ejemplo 6881Limite Velocidad UploadKb/segLimite Velocidad Download'Número Máximo de conexiones con peers fgh Ei Ej kjavax/swing/JFileChooser l' java/io/File m no pq rs tFallo IO clase Preferencias u vw xy z{java/lang/String |}110~ 111112113114117118119120121!BJTorrent/GUI/VentanaPreferenciasjavax/swing/JFramejava/awt/event/ActionEventjava/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream;load(Ljava/io/InputStream;)Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toStringBJTorrent/Salidaescribe(Ljava/lang/String;)V getProperty&(Ljava/lang/String;)Ljava/lang/String;intValuevalueOf'(Ljava/lang/String;)Ljava/lang/Integer;(I)Ljava/lang/String;setTextadd(ILjava/lang/Object;)V setListData(Ljava/util/Vector;)Vsizeget(I)Ljava/lang/Object;setSelectedIndex(I)Vequals(Ljava/lang/Object;)Z&(LBJTorrent/GUI/VentanaPreferencias;)VaddActionListener"(Ljava/awt/event/ActionListener;)Vjavax/swing/BorderFactorycreateBevelBorder(I)Ljavax/swing/border/Border; setBorder(Ljavax/swing/border/Border;)VsetSelectionModesetViewportView(Ljava/awt/Component;)V(Ljava/awt/Container;)V setLayout(Ljava/awt/LayoutManager;)V!javax/swing/GroupLayout$Alignment AlignmentLEADING#Ljavax/swing/GroupLayout$Alignment;createParallelGroup ParallelGroupL(Ljavax/swing/GroupLayout$Alignment;)Ljavax/swing/GroupLayout$ParallelGroup;createSequentialGroupSequentialGroup+()Ljavax/swing/GroupLayout$SequentialGroup;'javax/swing/GroupLayout$SequentialGroupaddContainerGap%javax/swing/GroupLayout$ParallelGroup addComponent@(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$ParallelGroup;addGroupGroupJ(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$SequentialGroup;-(II)Ljavax/swing/GroupLayout$SequentialGroup;H(Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;setHorizontalGroup"(Ljavax/swing/GroupLayout$Group;)V?(Ljava/awt/Component;)Ljavax/swing/GroupLayout$SequentialGroup;*javax/swing/LayoutStyle$ComponentPlacementComponentPlacementRELATED,Ljavax/swing/LayoutStyle$ComponentPlacement;addPreferredGapW(Ljavax/swing/LayoutStyle$ComponentPlacement;)Ljavax/swing/GroupLayout$SequentialGroup;B(Ljava/awt/Component;III)Ljavax/swing/GroupLayout$SequentialGroup;setVerticalGroupM(Ljavax/swing/GroupLayout$Alignment;Z)Ljavax/swing/GroupLayout$ParallelGroup;=(Ljava/awt/Component;)Ljavax/swing/GroupLayout$ParallelGroup;Y(Ljavax/swing/LayoutStyle$ComponentPlacement;II)Ljavax/swing/GroupLayout$SequentialGroup;addGap.(III)Ljavax/swing/GroupLayout$SequentialGroup;BASELINE getResource"(Ljava/lang/String;)Ljava/net/URL;(Ljava/net/URL;)VsetIcon(Ljavax/swing/Icon;)VTRAILINGk(Ljavax/swing/GroupLayout$Alignment;Ljavax/swing/GroupLayout$Group;)Ljavax/swing/GroupLayout$ParallelGroup;getContentPane()Ljava/awt/Container;java/awt/Containerc(Ljava/awt/Component;Ljavax/swing/GroupLayout$Alignment;III)Ljavax/swing/GroupLayout$ParallelGroup;`(Ljava/awt/Component;Ljavax/swing/GroupLayout$Alignment;)Ljavax/swing/GroupLayout$ParallelGroup;packsetFileSelectionModegetTextsetCurrentDirectory(Ljava/io/File;)VshowOpenDialog(Ljava/awt/Component;)IgetSelectedFile()Ljava/io/File;getCanonicalPathBJTorrent/UtilscadenaNumerica(Ljava/lang/String;)Z setProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;getSelectedValue()Ljava/lang/Object; setVisible(Z)VBJTorrent/GUI/IdiomaleeEtiquetaIdiomajavax/swing/GroupLayout$Groupjavax/swing/LayoutStyle!1      P**Y*Y*Y* * * Y *** *LY+*W*W*WY*  !"* # *W* $ %*W* & '*W* ( )"**W* + )",*W* - )".*W* / )"0*W* 1 )"2* 3 4*5*W67*87*9*W%7*:*W*67*;*W.67*:*W*67*<=*>=*?=*@=*A=*B*C<*D(0*EF)" *BG*>=*H=*I=*J=*K=*L=*M=*N=*O*C<*D(2*EF)" *OG*P=*Q=*R=*S*C<*D"4*ET *SGٱEPS=O8:<%P)R-V8WEZP^S]T^mdgiklnopqr#s/v>wHyTzc|r}",7BMZqy4T0O0*+ S)^)*#   ' %  , !* ". #0 $2 %6 4P4  & [ m*UYVW*XYYZ*[Y\]*^Y_`*aYbS*XYYc*[Y\d*eYf9*[Y\g*eYf:*XYYh*[Y\i*eYf8*UYVj*XYYk*[Y\l*eYf5*[Y\m*XYYn*[Y\o*[Y\p*^Y_q*aYbB*XYYr*[Y\s*[Y\t*^Y_u*aYbO*[Y\v*aYbw*XYYx*[Y\y*eYf;*Wz{*W|Y*}~*Z*]*S*`*SY*ZL*Z+++++*`*]D+++*]*`Y*c*d*gY*cM*c,,,,,*d*9t,*g*:,,,,,*d*g,*9*:*h*i*jY**jY*~Y*hN*h-----*i-*8*j&----*j-*i*8%*k*l*mY*k:*k*l*5M*m'*l*5*m1*n*o*p*q*BY*n:*n*qA*p*o*o*qY*p*r*s*t*u*OY*r:*r*s*uA*t,,,*s*t*uY*v*x*yY*x:*x*;)*y8*y*;Y*:**k*c*x*h*n*r*v*W *Z*w*h*k*c*x*Z*n*r*v*wBBB*W*z^ !,7BM X!c"n#y$%&'()*+,-./0123)445?6J7U8`9k;t<BCEFHIJS2]=^F`Ob[ccdq%09P_ks#,5BK "+c    [ h!q"o= hX lY\ m'([)(k*(B++("K,(o-(.(h/(01o*Y**WY*8M*,***W1*8*7NY-@QT* c df'g/i@mQpToUpnt*Uoo23'H45T6781E*5&* *5W*W*5)"* #*8W*W*8* $*9W*W*9%*:&* (*:W*W*:)"**;&* -*;W*W*;)".* /*BFW*W*BF)"0* 1*OFW*W*OF)"2* 3*SW*W*S4*±V 0AM^jw0?DEE230i/9y*løĶ*mŸĶ*iƸĶ*dǸĶ*gȸĶ*]ɸĶ*yʸĶ*o˸Ķ*s̸Ķ*W͸Ķ{.  $0<HT`lx y:;:*+<=3>;:*+<=3?&  !#@A:|9@=@HIPR@PK wC8aW.g.g&BJTorrent/GUI/VentanaPreferencias.form
PK wC8ߟ>&BJTorrent/GUI/VentanaPreferencias.java/* * VentanaPreferencias.java * * Created on 26 de noviembre de 2007, 13:51 */ package BJTorrent.GUI; import BJTorrent.Salida; import BJTorrent.Utils; /** * * @author Benjamn Muiz Garca */ import java.util.Properties; import java.util.Vector; import java.io.InputStream; import java.io.File; import java.io.IOException; import java.io.IOException; import javax.swing.JFileChooser; import java.io.InputStream; /** * Ventana que muestra y permite establecer * las Preferencias de la aplicacin. */ public class VentanaPreferencias extends javax.swing.JFrame { //Objeto para leer las propiedas private Properties prop; //Stream usado leer el fichero .properties private InputStream prop_stream; //Nmero de puerto por el que aceptamos las conexiones en la clase ConexionServer private static int puerto=0; //Ruta o path a partir del cual sern almacenados los directorios o ficheros descargados private static String directorio=""; //Nombre del host que hace de proxy SOCKS private static String proxy_host_SOCKS; //Nombre del host que hace de proxy HTTP private static String proxy_host_HTTP; //Nmero de puerto SOCKS del proxy private static int proxy_SOCKS_puerto; //Nmero de puerto HTTP del proxy private static int proxy_HTTP_puerto; //Limite de mximo de peers a los que nuestra aplicacin puede estar conectada private static int max_peers; //Limite de velocidad mxima de Upload de nuestro programa a todos los peers private static int velocidadUL; //Limite de velocidad mxima de Download de nuestro programa a todos los peers private static int velocidadDL; //String que indica el idioma seleccionado public static String idioma; //Lista con los idiomas que el usuario puede seleccionar private Vector Idiomas=new Vector(); //Lista de velocidades mximas de Upload que el usuario puede seleccionar private Vector VelocidadesUL=new Vector(); //Lista de velocidades mximas de Download que el usuario puede seleccionar private Vector VelocidadesDL=new Vector(); //componente GUI mediante el cual seleccionamos el directorio compartido private JFileChooser fc; /** * * * Crea una instancia de la clase VentanaPreferencias. * Muestra en la ventana las preferencias de la aplicacin.
* Leyendo los atributos de la clase o si es la primera vez que se llama al constructor * lee las preferencias de un fichero .properties * */ public VentanaPreferencias() { initComponents(); this.ponerTextoEtiquetas(); prop=new Properties(); prop_stream = getClass().getResourceAsStream("properties/preferencias.properties"); try { prop.load(prop_stream); } catch (IOException ioe) {Salida.escribe("Error IO Clase Preferencias "+ioe.toString());} // read stream here. Remember to close() it too. if (this.puerto==0 && this.directorio=="") { this.puerto=new Integer(prop.getProperty("puerto")); directorio=prop.getProperty("directorio"); this.proxy_host_SOCKS=prop.getProperty("proxy SOCKS"); this.proxy_host_HTTP=prop.getProperty("proxy HTTP"); this.proxy_SOCKS_puerto=Integer.valueOf(prop.getProperty("proxy SOCKS puerto")); this.proxy_HTTP_puerto=Integer.valueOf(prop.getProperty("proxy HTTP puerto")); this.max_peers=Integer.valueOf(prop.getProperty("max peers")); this.velocidadUL=Integer.valueOf(prop.getProperty("velocidad UL")); this.velocidadDL=Integer.valueOf(prop.getProperty("velocidad DL")); idioma=prop.getProperty("idioma"); } this.txt_puerto.setText(String.valueOf(this.puerto)); this.txt_directorio.setText(directorio); this.txt_proxy_SOCKS.setText(this.proxy_host_SOCKS); this.txt_proxy_SOCKS_puerto.setText(String.valueOf(this.proxy_SOCKS_puerto)); this.txt_max_peers.setText(String.valueOf(this.max_peers)); this.txt_proxy_SOCKS_puerto.setText(String.valueOf(this.proxy_SOCKS_puerto)); VelocidadesUL.add(0,"8"); VelocidadesUL.add(1,"12"); VelocidadesUL.add(2,"16"); VelocidadesUL.add(3,"24"); VelocidadesUL.add(4,"32"); this.lista_velocidadesUL.setListData(VelocidadesUL); for (int i=0;i//GEN-BEGIN:initComponents private void initComponents() { botonprefsaplicar = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); labelidioma = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); lista_idiomas = new javax.swing.JList(); jPanel2 = new javax.swing.JPanel(); labelproxySOCKS = new javax.swing.JLabel(); txt_proxy_SOCKS = new javax.swing.JTextField(); labelproxySOCKSpuerto = new javax.swing.JLabel(); txt_proxy_SOCKS_puerto = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); labelcompartido = new javax.swing.JLabel(); txt_directorio = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); labelpuerto = new javax.swing.JLabel(); txt_puerto = new javax.swing.JTextField(); labelexample = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); labelvelocidadUL = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); lista_velocidadesUL = new javax.swing.JList(); jPanel6 = new javax.swing.JPanel(); labelvelocidadDL = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); lista_velocidadesDL = new javax.swing.JList(); jLabel3 = new javax.swing.JLabel(); lista_velocidadesUL2 = new javax.swing.JList(); jPanel7 = new javax.swing.JPanel(); labelmaxpeers = new javax.swing.JLabel(); txt_max_peers = new javax.swing.JTextField(); botonprefsaplicar.setText("Aplicar"); botonprefsaplicar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { botonprefsaplicarActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelidioma.setText("Idioma"); lista_idiomas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane1.setViewportView(lista_idiomas); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelidioma, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(25, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(labelidioma) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE) .addContainerGap()) ); jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelproxySOCKS.setText("Proxy SOCKS"); labelproxySOCKSpuerto.setText("Puerto SOCKS"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(labelproxySOCKS) .addComponent(txt_proxy_SOCKS, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelproxySOCKSpuerto) .addComponent(txt_proxy_SOCKS_puerto, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(19, 19, 19) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(labelproxySOCKS) .addComponent(labelproxySOCKSpuerto)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txt_proxy_SOCKS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txt_proxy_SOCKS_puerto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(26, Short.MAX_VALUE)) ); jPanel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelcompartido.setText("Directorio Compartidos"); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BJTorrent/GUI/iconos/open.gif"))); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelcompartido) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addComponent(txt_directorio, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton1) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(labelcompartido) .addGap(18, 18, 18) .addComponent(txt_directorio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(37, Short.MAX_VALUE)) ); jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelpuerto.setText("Puerto Aceptar Conexiones"); labelexample.setText("ejemplo 6881"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelpuerto) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(txt_puerto, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(labelexample))) .addContainerGap(39, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(labelpuerto) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txt_puerto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelexample)) .addContainerGap(49, Short.MAX_VALUE)) ); jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelvelocidadUL.setText("Limite Velocidad Upload"); jLabel1.setText("Kb/seg"); jScrollPane2.setViewportView(lista_velocidadesUL); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1)) .addComponent(labelvelocidadUL)) .addContainerGap(19, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(labelvelocidadUL) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE) .addComponent(jLabel1)) .addContainerGap()) ); jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelvelocidadDL.setText("Limite Velocidad Download"); jLabel2.setText("Kb/seg"); jScrollPane3.setViewportView(lista_velocidadesDL); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addContainerGap() .addComponent(labelvelocidadDL) .addContainerGap(21, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2) .addGap(44, 44, 44)) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addContainerGap() .addComponent(labelvelocidadDL) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)) .addContainerGap()) ); jLabel3.setText("Kb/seg"); jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); labelmaxpeers.setText("N\u00famero M\u00e1ximo de conexiones con peers"); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txt_max_peers, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelmaxpeers)) .addContainerGap(56, Short.MAX_VALUE)) ); jPanel7Layout.setVerticalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(labelmaxpeers) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txt_max_peers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(26, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(23, 23, 23) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(21, 21, 21) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(botonprefsaplicar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lista_velocidadesUL2)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lista_velocidadesUL2, javax.swing.GroupLayout.Alignment.LEADING))) .addGap(66, 66, 66)) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 262, Short.MAX_VALUE) .addComponent(botonprefsaplicar) .addContainerGap()))) ); pack(); }// //GEN-END:initComponents /** * Establece un nuevo valor para el directorio compartido seleccionado a partir de un JFileChooser * @param evt ActionEvent Evento correspondiente al click del botn que selecciona la nueva ruta * del directorio compartido */ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO: Agrege su codigo aqui: fc = new JFileChooser(); fc.setFileSelectionMode(fc.DIRECTORIES_ONLY); File f= new File(this.txt_directorio.getText()); fc.setCurrentDirectory(f); if (fc.showOpenDialog(this)==fc.APPROVE_OPTION) try{ this.txt_directorio.setText(fc.getSelectedFile().getCanonicalPath()); } catch (IOException ioe) { Salida.escribe("Fallo IO clase Preferencias "+ioe.toString());} }//GEN-LAST:event_jButton1ActionPerformed /** * * Almacena los valores de los componentes de la ventana en atributos del objeto para que sean ledos * sus valores mediante llamadas a mtodos de la clase. * @param evt ActionEvent Evento correspondiente al click del botn sobre el botn de la ventana * que cierra la ventana y guarda las preferencias. */ private void botonprefsaplicarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonprefsaplicarActionPerformed // TODO: Agrege su codigo aqui: if (Utils.cadenaNumerica(this.txt_puerto.getText())) { prop.setProperty("puerto",this.txt_puerto.getText()); this.puerto=Integer.valueOf(this.txt_puerto.getText()); } prop.setProperty("directorio",this.txt_directorio.getText()); this.directorio=this.txt_directorio.getText(); prop.setProperty("proxy SOCKS",this.txt_proxy_SOCKS.getText()); this.proxy_host_SOCKS=this.txt_proxy_SOCKS.getText(); if (Utils.cadenaNumerica(this.txt_proxy_SOCKS_puerto.getText())) { prop.setProperty("proxy SOCKS puerto",this.txt_proxy_SOCKS_puerto.getText()); this.proxy_SOCKS_puerto=Integer.valueOf(this.txt_proxy_SOCKS_puerto.getText()); } if (Utils.cadenaNumerica(this.txt_max_peers.getText())) { prop.setProperty("max peers",this.txt_max_peers.getText()); this.max_peers=Integer.valueOf(this.txt_max_peers.getText()); } prop.setProperty("velocidad UL",this.lista_velocidadesUL.getSelectedValue().toString()); this.velocidadUL=Integer.valueOf(this.lista_velocidadesUL.getSelectedValue().toString()); prop.setProperty("velocidad DL",this.lista_velocidadesDL.getSelectedValue().toString()); this.velocidadDL=Integer.valueOf(this.lista_velocidadesDL.getSelectedValue().toString()); prop.setProperty("idioma",((String)this.lista_idiomas.getSelectedValue())); this.idioma=((String)this.lista_idiomas.getSelectedValue()); this.setVisible(false); }//GEN-LAST:event_botonprefsaplicarActionPerformed /** * * Mtodo que cambia el texto de todas las etiquetas de esta ventana en funcin del Idioma seleccionado. */ public void ponerTextoEtiquetas(){ this.labelpuerto.setText(Idioma.leeEtiquetaIdioma("110")); this.labelexample.setText(Idioma.leeEtiquetaIdioma("111")); this.labelcompartido.setText(Idioma.leeEtiquetaIdioma("112")); this.labelproxySOCKS.setText(Idioma.leeEtiquetaIdioma("113")); this.labelproxySOCKSpuerto.setText(Idioma.leeEtiquetaIdioma("114")); this.labelidioma.setText(Idioma.leeEtiquetaIdioma("117")); this.labelmaxpeers.setText(Idioma.leeEtiquetaIdioma("118")); this.labelvelocidadUL.setText(Idioma.leeEtiquetaIdioma("119")); this.labelvelocidadDL.setText(Idioma.leeEtiquetaIdioma("120")); this.botonprefsaplicar.setText(Idioma.leeEtiquetaIdioma("121")); //this.BotonPrefsCancelar.setText(Idioma.leeEtiquetaIdioma("119")); } // Declaracin de varibales -no modificar//GEN-BEGIN:variables private javax.swing.JButton botonprefsaplicar; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JLabel labelcompartido; private javax.swing.JLabel labelexample; private javax.swing.JLabel labelidioma; private javax.swing.JLabel labelmaxpeers; private javax.swing.JLabel labelproxySOCKS; private javax.swing.JLabel labelproxySOCKSpuerto; private javax.swing.JLabel labelpuerto; private javax.swing.JLabel labelvelocidadDL; private javax.swing.JLabel labelvelocidadUL; private javax.swing.JList lista_idiomas; private javax.swing.JList lista_velocidadesDL; private javax.swing.JList lista_velocidadesUL; private javax.swing.JList lista_velocidadesUL2; private javax.swing.JTextField txt_directorio; private javax.swing.JTextField txt_max_peers; private javax.swing.JTextField txt_proxy_SOCKS; private javax.swing.JTextField txt_proxy_SOCKS_puerto; private javax.swing.JTextField txt_puerto; // Fin de declaracin de variables//GEN-END:variables } PK wC87$&&BJTorrent/GUI/iconos/Thumbs.dbࡱ>  Root EntryP/d@12 3B  !"#$%&'()*+,-./0123456789:;<=>?@ACDEFGHIJKLMNOPQRTUVWXYZ[\]^_`abcdegh JFIF``C     C   " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ??:xR;[Y0X ުR]1T`{dhjspGSn R !rv)Q x'N1ck|)o&t ^8Fpڄ#g ªCP~|#?7ᾉmR:{ V2ű$BZC,U(诅li5/ isxdM=2G-FBSEzv^=?N;h"Ha# 0cP]67 .l$hibV zdsQǠiȒG$C+, #Q@袊  JFIF``C     C   6`" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?w,pyIH`?~$R˩3!M\B:ΑDK?19Qxԏ匛jfh[9K_?Tg+ Y佺8z[O_^3>&xW{O⵾۴Q_){ s][[<đ]s%H"2K05g /V.5 CxZ  Ok\xDdZ-++S#A'$W|kIEk'~~7x(M{:W-+)!$ y~uan2s^IdzMQFRfd;ZB!&]E"k\^jJ.`vѤYmQQ>Yt5(ŵKף}r۹iʏzOr@BͬJ}'+ڥ! |c&k$[ijPp; ̷I++20HRp ^cSeE_#LqZE-z;;OjRM3])vrX!\(j#CZ 0"Gss:Αbnlmg͞OK ]b#.VOW׷T5M=<Հ=(95Ai:W?fia<C 6vVcRTkΜ{]fA7> p 5uɵ;u)sm^\\j_ 1Y2Hd6] ?a2H~TS$Ȅ`e:r2Z]5R8o-vd l)'ʓsK O uz뷞g p7]O&t;]>82P=$>R_L-GؿumG?6~cgxCIVHKO wt$`_,R,@\#)efXGW|/n"~MuM u!..l< ϟɏ~}+\K=uRj^' U^H†8AsƝQEqiqͻX\:+:Z|th*}VyGťNofi#b%ٜʃ*omMQZW/Dpv&3[?*ym#NG=:Cp9<1O17[MO<]%#XbRqϿj<1}`֢1I}?*۝6崦{HbO F~^jzo5+ǎ]J@cY?8\=>Tܙ?{߈n N2@ s^J 4Zmy ")'Wk]+Iy R[Z]q޾f|N4K=1nU A\8<_#QFr\oቭ;vQiK9Y/eyp Bۋ3+4Hpyq} ">oH;*,3`TI9lOhph{g,9X3Tÿc%ʹ,JT@?' Nq_ErVjK[}:RJ0kTwaՂXP,ZW7\[{ tg9s(a>Z5+M$iM6ԓb|\cc6s^V'RU*12齎HO:;U/3g#aZ7ah7]XrO^y;z^MZ؜OVnKͷPF|3-@.Q*~jԵW5n768 }Wg?KsE_kRAk渙rUy{[?>7 NJ1\'eovQs#Bִ,"Cż, C2dpORY]K#+(!hy ~ x:[_%|w||آ UB[,^zjRI-/}EIr=C`fy0fiXU UTQ^cEF*UN)ASK?``"Teye.gif,wTbenjamin.jpg(wTborrar.gif4wTcon-semillas.gifPK wC8~KXX!BJTorrent/GUI/iconos/benjamin.jpgJFIF,,ExifMM*bj(1r2i,,Adobe Photoshop CS Windows2007:12:20 18:11:31e&(.HHJFIFHH Adobe_CMAdobed            Z" ?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?ޗI>♣sx0&ܸbɐJ_Nԧ=n>%)>*ٿxQ=?$O9IN`[czM{kvN8UHI|`?)W|J}9OwN0rv}}ә5//ߏڈ8[},6q]8Av] mߡ;}__B=l:L*nUj/nͳ'fSclnathoþLq7۞ql~_W{̓%0&9URqʤ56}Kw_ыݡ /;Y${Y=6X7`PNI>%}VS~~vlȮs#q^zowV \t3Bd l,UDqOu\~U+ W`lP\&U/ܒ}:kynwMy_sv+iո䱮1ikcFqS#ۍpucuxn;O,@'sXwjLͱ}gѕo#v̏?1g]ZZ8)H]cmcnKL˜}]ϋٴ?fPs;S?I2x~aza%:ñG^\p&(g*vOBΦ-uR4I;\ǻhkWAxYc*S C {p<B{c":ȴY[q7}5oܢb1KۘᑳgP}0 NC[.=y,] ;c1fx4;ӹ-m)̮ǽuLu{}jvuzU=o Vm-us(V Y_ӱhNK=F wrS%)bb<L{rK.L?ˬ@F'-GhpswY[g=uUsDF+0V}=l,[u0ʦe^2Žlo~-u΢NK?O?K6SgN e1 q=QC/o1+ۼ_;{~M1?I>gS5mӎM_}WVw2pk|Znv|̽kߝjĔ>GU2s>aGb`\&R&S??[em^;l$X {</]O>]-CZ5 -.0y\ٔN2ڪuFv{#B:1B#S.Ǣƍ,,k+,@G{hyi:cY{ i:`cZ}jΰ?uj_Tq _HΛ>='"1np?pkJײlt$i}^2a!.5Gwe7swv>3 =Ֆ@62{[]W+1߱yNkȲi |X*s ,XgS6NFQX'wE^ Qʲ G WˏcR>O~]^(sF<y/=UԚZ8jOMkKtKeۄ-׶ApKU{p]eUAH}[sVvT:}bH,i` 2wL|oϧac^UVWVC멗}oQd U#m{Z[>tk\Av,dsTG4kzwۏ|'c9{Cu5[\ژ6\Mfmm71i gfƵchWX d,EK0U{<8u;2jq'A-dzv;ۿ}vuݎcХ1,,{[ߣbZo߷w}8ݺ5ĵڼF\xD0eB?׷GG #O ̯[iZT% ݳw}d}M~+]}XQC6Tn.` h٧6!LgϷ=p'%|s2Um0 aԆZZ74ůa !קwmjsk`vΣi?wڗo^41c`};c5{*{J?EdУʫ]͏ls5N:n!D6>!AF<R]DvoW3Wlp̯_t_o揓\wӔeE.:sb|jinr.Y1:2F1-KWetH1!WgS_\fv3ε[py?2X}Ei h|g9<{@t&A]^E0s:.rn{76~}'{W!:RdL OKzW&%[:' d uLufXCAmv[Kms\5OWuJݴM ߬jK,,pJ eDhaߝvNCcc`;Oߣm/U*$Q[K^: ׽׺߆m[k6CÇò<)e0<1֏/DV~}稻d~˥,m~;kk] =R9}iXEvVCʋ]CKr+u?ҭAii;d)9ۜHy [k|||,vR汬`,sy&>2}>,T\~c\* w+ݒVO)gGo+['MpG JΏ Ô_HƟt?oU@xpדOO~ee]]q^nnO#a{c%}\1~nGp>'{/?[8i A xw:yf8ߣ?W6§~ -IO*V}39Q5RљvIN4ߎGk+ZRKN&!yDtCPhotoshop 3.08BIM%8BIM,,8BIM&?8BIM x8BIM8BIM 8BIM 8BIM' 8BIMH/fflff/ff2Z5-8BIMp8BIM8BIM8BIM@@8BIM8BIMMe Sin ttulo-2enullboundsObjcRct1Top longLeftlongBtomlongeRghtlongslicesVlLsObjcslicesliceIDlonggroupIDlongoriginenum ESliceOrigin autoGeneratedTypeenum ESliceTypeImg boundsObjcRct1Top longLeftlongBtomlongeRghtlongurlTEXTnullTEXTMsgeTEXTaltTagTEXTcellTextIsHTMLboolcellTextTEXT horzAlignenumESliceHorzAligndefault vertAlignenumESliceVertAligndefault bgColorTypeenumESliceBGColorTypeNone topOutsetlong leftOutsetlong bottomOutsetlong rightOutsetlong8BIM( ?8BIM8BIM8BIM ZJFIFHH Adobe_CMAdobed            Z" ?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?ޗI>♣sx0&ܸbɐJ_Nԧ=n>%)>*ٿxQ=?$O9IN`[czM{kvN8UHI|`?)W|J}9OwN0rv}}ә5//ߏڈ8[},6q]8Av] mߡ;}__B=l:L*nUj/nͳ'fSclnathoþLq7۞ql~_W{̓%0&9URqʤ56}Kw_ыݡ /;Y${Y=6X7`PNI>%}VS~~vlȮs#q^zowV \t3Bd l,UDqOu\~U+ W`lP\&U/ܒ}:kynwMy_sv+iո䱮1ikcFqS#ۍpucuxn;O,@'sXwjLͱ}gѕo#v̏?1g]ZZ8)H]cmcnKL˜}]ϋٴ?fPs;S?I2x~aza%:ñG^\p&(g*vOBΦ-uR4I;\ǻhkWAxYc*S C {p<B{c":ȴY[q7}5oܢb1KۘᑳgP}0 NC[.=y,] ;c1fx4;ӹ-m)̮ǽuLu{}jvuzU=o Vm-us(V Y_ӱhNK=F wrS%)bb<L{rK.L?ˬ@F'-GhpswY[g=uUsDF+0V}=l,[u0ʦe^2Žlo~-u΢NK?O?K6SgN e1 q=QC/o1+ۼ_;{~M1?I>gS5mӎM_}WVw2pk|Znv|̽kߝjĔ>GU2s>aGb`\&R&S??[em^;l$X {</]O>]-CZ5 -.0y\ٔN2ڪuFv{#B:1B#S.Ǣƍ,,k+,@G{hyi:cY{ i:`cZ}jΰ?uj_Tq _HΛ>='"1np?pkJײlt$i}^2a!.5Gwe7swv>3 =Ֆ@62{[]W+1߱yNkȲi |X*s ,XgS6NFQX'wE^ Qʲ G WˏcR>O~]^(sF<y/=UԚZ8jOMkKtKeۄ-׶ApKU{p]eUAH}[sVvT:}bH,i` 2wL|oϧac^UVWVC멗}oQd U#m{Z[>tk\Av,dsTG4kzwۏ|'c9{Cu5[\ژ6\Mfmm71i gfƵchWX d,EK0U{<8u;2jq'A-dzv;ۿ}vuݎcХ1,,{[ߣbZo߷w}8ݺ5ĵڼF\xD0eB?׷GG #O ̯[iZT% ݳw}d}M~+]}XQC6Tn.` h٧6!LgϷ=p'%|s2Um0 aԆZZ74ůa !קwmjsk`vΣi?wڗo^41c`};c5{*{J?EdУʫ]͏ls5N:n!D6>!AF<R]DvoW3Wlp̯_t_o揓\wӔeE.:sb|jinr.Y1:2F1-KWetH1!WgS_\fv3ε[py?2X}Ei h|g9<{@t&A]^E0s:.rn{76~}'{W!:RdL OKzW&%[:' d uLufXCAmv[Kms\5OWuJݴM ߬jK,,pJ eDhaߝvNCcc`;Oߣm/U*$Q[K^: ׽׺߆m[k6CÇò<)e0<1֏/DV~}稻d~˥,m~;kk] =R9}iXEvVCʋ]CKr+u?ҭAii;d)9ۜHy [k|||,vR汬`,sy&>2}>,T\~c\* w+ݒVO)gGo+['MpG JΏ Ô_HƟt?oU@xpדOO~ee]]q^nnO#a{c%}\1~nGp>'{/?[8i A xw:yf8ߣ?W6§~ -IO*V}39Q5RљvIN4ߎGk+ZRKN&!yDtC8BIM!SAdobe PhotoshopAdobe Photoshop CS8BIMhttp://ns.adobe.com/xap/1.0/ 4294967295 180 101 1 300/1 300/1 2 2007-12-20T18:11:31+01:00 2007-12-20T18:11:31+01:00 2007-12-20T18:11:31+01:00 Adobe Photoshop CS Windows adobe:docid:photoshop:2d2fa89a-af1e-11dc-9c41-e0762a98a8d9 image/jpeg Adobed            e" ?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?ޓ'Tn]Iā"l n>)n>) qqHw;(˱ERRR}1}spӻ'}{y:F_b}1m?7}ɍW4nsy:@y+=ڭ- 5/wN*\ߕU};#~ojŒ@1"$c_( FQ_]{OH#C- g%)>*r|R$JSDRҦ[[NKjOٹ0߿a ֵkDs :V$l.M71v5?Gt'J/d:`<sr2X9$r嵋QղUkO79pXw\dV;OIܹAP/XUHzNܒ[wۀ|/{Y}Oq߻y܂$úiV^mY5*ps\8!$5y|X]KNwܽN=*5d՗LoK$9c7~ u[8쇽`c\sOSB%Rk M>sv?ڵ1fEϻk28cIX42X ~j3!bq| xz?H"B7.\.{1(m6~Cuqkk6. Xƾ\LX̯NU] ~?qi31m7s^s1ֶ^[][Ic^6g}y>.,_z #Cߙ}m{}Wz{ jsrttmd9h&t|*8`{~x{MXOiR֒W~M&L\qhHe͚?S4P4,!rfޝrKM4 eջoگtmCaяc ;%wj(ihxXXYyL7_gik]wE׷n#ULn)k 1o S/13IHӞ6HJRiC%,3}}\ZiwZ>1Wh㱕=6Xm .\Nw[tI5ݮcqI.gC Ɵ)Z1K F_rldȦ6A깤ooF2[ W%}B:h[. ˌ}kXj1Ð一)p1c14'1C ?udmΰm`y 9k¹kuo_^wo7;خ3av!&._R=/]z9k,w$FV ?~05ʻ'U䙱Tw~Υ$Oo}m?ܬ~WSYTRCo[>E7nW9Kd#(֞{V,&)JL'_ (迵Rޭ/ڨhWISQ%G%t=_ YycA ܒ :ois Cx?wE/T@+\w;8Fl{#UTx}F')@ыqf_DNNHc:Þ^܄lyG~ϩ5VV%ܻK^>`I\/D>knnCXniPZ?XH|kOa?DySLr~Xw+kw?y⚛5n6555oڱ(N18߻oTvnS0,Z?Mew+R]Ѳ,_Q,0A}۔s 2p߅ӣ)J9{1Uю`:Lr)2\rNQ^vxW5:=+;dccl%z*:X?F'sl?ć#2k7SU{^sd6FT`̗u& QF.`cwOqWoج]x"Zg I}G;uziJVG8`u@`5[ͳ g[UpR%IɎ_mGIB}撎$a+?*qԬҷtX_ 'o>U7,7uu%Ft<\k``S%Li%iV3q {ې&Hfۈ'槏kÈ{|"?)̫wx` UomuY e,vt1k UZ}2n]F??tUu,OY+Q?q:k41TYKrt-fs8Rlklrz+k=eNY9yxk7t{\,P%#*y"8/>w@q6N 6z_}V8I!B8= H.35Z;eڹ[ɿ+3#, mPfѷ؃3ick'əV 징N^q=inߣXk]]*LfAţ4d ))IQJS),*2JI>ϚJ3!ҫ[??*.XtoԺIX O7xx/~[ sE+^Ma;uc:!H(0ƩkdJ;ɍ8)a @iX6:rX^Dl&P,GWMeM.5 #udJnmJ xq 1Z2VN1yMCOq:GWz8sN^姝VDʿcox9Ús⌡.BGyl9ʏYo`G$W>1B[p|qHwja)G"@|2F\IdItF5ŦAQlӪ@fpu 02e)MAJP2JI|Q|OVЫX~U/~G ,O|t9pu2Z]$UܟImj䎙OKuQ\Jў[?p]$)3<=$?LoIn_/. OW:H4cO?SenݗՇ07O#;l>?ԯIs\GPƼYQՎŢZ/ITffݎeCE'Kh-xIb_bOĒ/?KƒO>TPK wC8D55BJTorrent/GUI/iconos/borrar.gifGIF89af3̙f3f3ffffff3f3333f333f3f3̙f3̙̙̙̙f̙3̙ffffff3f3333f333f3̙f3̙̙f3̙f3ff̙ffff3f33̙33f333̙f3ffffff3ffff̙fff3fffffff3ffffffffffff3fff3f3f3f3ff33f3ffffff3f3333f333333̙3f3333333f3333f3f3f3ff3f33f33333333f333333333f333f3̙f3f3ffffff3f3333f333f34-1УQ20232--,('>/ 24Q(e?oLxVh-*/36 =F!,qNjc׍ueHlΡxn C9As:\ɲJl K&K\iNpZԦ=wv]p/ci=oz⓷-Cv8Jo3UiX0 ZSo|sMJ|wzSX Fko[Zc |V4Y( >|s;zߒ=kT+" ͞wڲgp_?Y:ԩqwLrCy7 $=†;PK wC8u:Q%BJTorrent/GUI/iconos/con-semillas.gifGIF89af3̙f3f3ffffff3f3333f333f3f3̙f3̙̙̙̙f̙3̙ffffff3f3333f333f3̙f3̙̙f3̙f3ff̙ffff3f33̙33f333̙f3ffffff3ffff̙fff3fffffff3ffffffffffff3fff3f3f3f3ff33f3ffffff3f3333f333333̙3f3333333f3333f3f3f3ff3f33f33333333f333333333f333f3̙f3f3ffffff3f3333f333f3>== 0 x# F78+&q"l c ].&  <71 J C W+   M _7:*  !, H o?~ ŋ%wEvy\z$I-ey],np3q7tybyၳht]솓k)q$.[J{RRV$ k(Is<bŕ]ܶ<|9 (=]kF'qm`V/ ;PK wC8]XBJTorrent/GUI/iconos/eye.gifGIF89a3"""T23f3222f2fee̙2ee̙2e̘233e2e3e2˘33fee˘213f212f233ee3f22ffe32ee˘˙22ee2e2e333ef3eefe˙˘2̘f3e3332e222e2eef2e22fee2e2e2efe32fe2f3ef̘e˘33e33eee2˘f̘3e233323fe˘˙222e333fe2ffe3ee22e22eff33e33eee22332e3fe2f3ffee2f3e3e3efeee˙˙23fe33eeDDDee2ffwwwUUUfff"DT2DDTfv"2"2vv!,@ H@HP8,p A3",i5f0\+@0DXkذ]ۂd/Z4ǰQ6Ç$!B,p CNf ; irdI 1[0Q%d.r-Ԋܢ䖦1lz ҤL")l˺kS{ymZʍ[{}a:a:-;PK wC8Ά//'BJTorrent/GUI/iconos/icono-programa.jpgJFIF,,ExifMM*bj(1r2i,,Adobe Photoshop CS Windows2007:11:22 15:23:17@@&(.HHJFIFHH Adobe_CMAdobed            @@"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?Eed 7*x(3q $rD*PRW@ԆHS}A_\)W2ncֽkx}3鏁_=}a>=E "IuO֯v^`PYjƗ<=E "IuO֯v^`PYjƗ< 4294967295 64 64 1 300/1 300/1 2 2007-11-22T15:23:17+01:00 2007-11-22T15:23:17+01:00 2007-11-22T15:23:17+01:00 Adobe Photoshop CS Windows adobe:docid:photoshop:373c186d-9905-11dc-9096-bb5af4f86f9a image/jpeg !Adobed            @@"51"26# !1"2Rt0Aqb#QaBrCScs!q @1 )9P||pg @uZ+U0E|Мٖ6ףh7Q#jVc@,/ G#BV6E,Fvb -G+M` p\#ࠏPώW\\&$L!$eeZsc}f:ilpE~ Xoc2哯V~{{WZM_Y. f~՟~&mT/ous.Zι/uՇ6}ܙNAqGCkrsQA ,qdAbr7G9 hoȳ:#igP2I" m[,]Jx>e2BQרRCp6SÌkgsg_],Hy#4t5~\ԝhyԍEjq1> *@ kPK wC8ǮLLBJTorrent/GUI/iconos/item.gifGIF89af!,k@x-g[:%ĀF QʶQ;PK wC8E@BJTorrent/GUI/iconos/open.gifGIF89a̙f3333!NThis art is in the public domain. Kevin Hughes, kevinh@eit.com, September 1995!,e(0Im&|`'g뺰#so uaJ:|ZQzuf=W p/sFmC9*:5 ;PK wC8 7[[#BJTorrent/GUI/iconos/play-start.gifGIF89a!,2 XzfTK#feg¡Q2W\iܭyOzB* ;PK wC8w[["BJTorrent/GUI/iconos/play-stop.gifGIF89a!,2 Pp뒚Y\|d9Xz ̒s[w|R;PK wC8Y^BJTorrent/GUI/iconos/play.gifGIF89af3̙f3f3ffffff3f3333f333f3f3̙f3̙̙̙̙f̙3̙ffffff3f3333f333f3̙f3̙̙f3̙f3ff̙ffff3f33̙33f333̙f3ffffff3ffff̙fff3fffffff3ffffffffffff3fff3f3f3f3ff33f3ffffff3f3333f333333̙3f3333333f3333f3f3f3ff3f33f33333333f333333333f333f3̙f3f3ffffff3f3333f333f3{ttnh__``ccghghhms{ Bwj St!, H*\Pq ^ .\DU8*B\x ܸp(CTxKrb,GsrLg:umH5JZnܞBUvmnWnkwߵwiKZl9G]ҳgo^zͶ7{Ƹ1LYۼO3?B ݰ쵲O_;PK wC8K>bb"BJTorrent/GUI/iconos/sadsmiley.gifGIF89a!,9m{@Vʎypcp}fJ,z/HL^y ZB܍`b'KDgS;PK wC8H7ę//"BJTorrent/GUI/iconos/sin-peers.gifGIF89a V &)* +b- Q/00c1m1 !'m 67Te 8 E# !0 ' . % '(())**++* , , - + - $ . / . " / / .8 0Z1232334,} 4656688899m =:_ D;*(%#!x h . % <<40)($  P - $ 9.,&$p *j _ ( Q ? 7/ '  !, H PL  2Y2d\$?ɲ%NT&:;IJK!aA Pp' AA,HaI S$I0f 2pq 9)MMgA0BXJ|p" xM: LiI ?}lvIą<=  2V&$5^(`<3RI3p H9<A悉GpR H DlH^g0̖ZDH LdQ!Dǫ;PK wC8 Dss%BJTorrent/GUI/iconos/sin-semillas.gifGIF89a== 0 x# F78+&q"l c ].&  <71 J C W+   M _7:*  !!(,@pH,Ȥ4F%p@0YQ2q^'Gwlb9deXH5̕s@ ]% W]V}VbWxd'i\iiind(VWBVmVkBWWyD|GunI']R}}p(A;PK wC8dhBJTorrent/GUI/iconos/stop.gifGIF89af3̙f3f3ffffff3f3333f333f3f3̙f3̙̙̙̙f̙3̙ffffff3f3333f333f3̙f3̙̙f3̙f3ff̙ffff3f33̙33f333̙f3ffffff3ffff̙fff3fffffff3ffffffffffff3fff3f3f3f3ff33f3ffffff3f3333f333333̙3f3333333f3333f3f3f3ff3f33f33333333f333333333f333f3̙f3f3ffffff3f3333f333f3l__`a`abeehhmlquv{!, Hk*\Ppy1ܷnݼ}ÌARQ7[ 8q/aRk,dzΞn;gТD)%zStܠ:*t7iʵŠ.lun[˶v7߹s\r{S^x 7+^xMzћ92nڻϞ=o|siN>}3>mc6;>7ƛGnb[˟dH];PK wC8:#N.+BJTorrent/GUI/properties/english.properties0: File 1: Open Torrent File 2: Exit 10: Torrents 11: Start 12: Stop 13: Details 20: Options 21: Preferences 26: Language 30: Help 31: About 40: Open 41: Start 42: Stop 43: Details 44: Delete 50: Status 51: Torrent Name 52: Progress 53: Downloaded 54: Left 55: Download KB/seg 56: Upload KB/seg 57: Seeds 58: Leechers 60: Events 61: Tracker 62: Data between Peers 70: Open Torrent File 80: Torrent File 81: Torrent Name 82: Torrents's Length 83: Piece Size 84: Number of Pieces 85: File 86: Length 87: Tracker 88: Next Update 90: Peer's Speed 91: Client ID 92: IP 93: UL Speed 94 DL Speed 100: Downloads 101: File 102: Progress 110: Accepting Connections Port 111: example 6881 112: Shared Folder 113: Proxy SOCKS 114: Port SOCKS 115: Proxy HTTP 116: Port HTTP 117: Language 118: Maximun Number of Peers 119: Upload Speed Limit 120: Download Speed Limit 121: Save 122: Cancel 130: Reading Downloaded Pieces PK wC8PP,BJTorrent/GUI/properties/francais.properties0: Fichier 1: Ouvrir fichier Torrent 2: Sortir 10: Torrents 11: Commencer 12: Arrter 13: Details 20: Options 21: Preferences 26: Langue 30: Aide 31: A propos de 40: Ouvrir 41: commencer 42: arrter 43: Details 44: Annuler 50: Statut 51: Nom Torrent 52: Progression 53: Tlchargements 54: Gauche 55: Tlchargement KB/seg 56: Chargement KB/seg 57: Semis 58: Clients 60: vnements 61: Tracker 62: Donnes entre Peers 70: Ouvrir ficher Torrent 80: Fichier Torrent 81: Nom Torrent 82: Mesures de Torrents 83: Taille Piece 84: Nombre de Pieces 85: Fichier 86: Mesure 87: Pisteur 88: Prochaine mise jour 90: Vitesse Peer 91: ID Client 92: IP 93: Vitesse UL 94 Vitesse DL 100: Tlchargements 101: Fichier 102: Progression 110: Accepter les ports de Connections 111: exemple 6881 112: Dictionnaire partag 113: Appareil SOCKS 114: Port SOCKS 115: Appareil HTTP 116: Port HTTP 117: Langue 118: Numer Maximum de Peers 119: Vitesse Limite Envoyez 120: Vitesse Limite Tlcharger 121: Sauvegarder 122: Annuler 130: Lecture des Pieces tlchargsPK wC8z0BJTorrent/GUI/properties/preferencias.properties#Preferencias BJBT #Fri Nov 30 18:57:01 GMT 2007 velocidad\ UL=16 velocidad\ DL=50 max\ peers=50 idioma=ESPAOL proxy\ SOCKS= proxy\ SOCKS\ puerto=1080 proxy\ HTTP= proxy\ HTTP\ puerto=80 directorio=C\:\\Compartidos puerto=6881 PK wC8VsGG+BJTorrent/GUI/properties/spanish.properties0: Archivo 1: Abrir Fichero Torrent 2: Salir 10: Torrentes 11: Comenzar 12: Parar 13: Ver Detalles 20: Opciones 21: Preferencias 26: Idioma 30: Ayuda 31: Acerca De 40: Abrir 41: Comenzar 42: Parar 43: Ver Detalles 44: Borrar 50: Estado 51: Nombre Torrente 52: Progreso 53: Bajados 54: Faltan 55: Bajada KB/seg 56: Subida KB/seg 57: Semillas 58: Sanguijuelas 60: Sucesos 61: Tracker 62: Datos entre Peers 70: Abrir Fichero Torrente 80: Fichero Torrente 81: Nombre del Torrente 82: Tamao del Torrente 83: Tamao Pieza 84: Nmero de Piezas 85: Fichero 86: Longitud 87: Rastreador 88: Prxima Actualizacin 90: Velocidad Peers 91: ID Cliente 92: IP 93: Velocidad UL 94: Velocidad DL 100: Descargas 101: Fichero 102: Progreso 110: Puerto Aceptar Conexiones 111: ejemplo 6881 112: Directorio Compartido 113: Proxy SOCKS 114: Puerto SOCKS 115: Proxy HTTP 116: Puerto HTTP 117: Idioma 118: Nmero mximo de peers 119: Limite Velocidad Upload 120: Limite Velocidad Download 121: Aplicar 122: Cancelar 130: Leyendo Piezas descargadas en Disco PK wC8ioBJTorrent/Handshake.class2 4h 3i 3j 3k lmno hp q r r 3s tuv lw x 3yz l{ | 3}~ r r t    )r 3   buffer[BmensajeoutLjava/io/DataOutputStream;inLjava/io/DataInputStream;pLBJTorrent/Peer; socket_peerLjava/net/Socket;trazaLjava/io/BufferedWriter;<(LBJTorrent/Peer;Ljava/net/Socket;Ljava/io/BufferedWriter;)VCodeLineNumberTableLocalVariableTableseLjava/net/SocketException;ioeLjava/io/IOException;thisLBJTorrent/Handshake; StackMapTablen~ leeHandShake([B[B)ZleidosIrapidoeLjava/lang/Exception; id_cliente info_hashlongitud protocolo6escribeHandShake([B[B)V reservadoscerrar()V SourceFileHandshake.java Be 56 <= >? java/net/SocketExceptionjava/lang/StringBuilder$Excepcion Fijando Timeout Handshake @A java/io/DataOutputStream B 89java/io/DataInputStream B :;java/io/IOExceptionClase Handshake error IO.  BitTorrent protocol  U FALLO HANDSHAKE por hash SHA1FALLO por ID cliente idéntica Excepcion IO Handshake java/lang/ExceptionError interno Handshake 76 Handshake IO timeout. Error interno. eBJTorrent/Handshakejava/lang/ObjectBJTorrent/Peerjava/net/Socketjava/io/BufferedWriter setSoTimeout(I)Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;BJTorrent/Salidaescribe-(Ljava/lang/String;Ljava/io/BufferedWriter;)VgetOutputStream()Ljava/io/OutputStream;(Ljava/io/OutputStream;)VgetInputStream()Ljava/io/InputStream;(Ljava/io/InputStream;)V(Ljava/lang/String;)Vjava/lang/StringgetBytes()[Bread([BII)IBJTorrent/UtilssubArray([BII)[B bytesCompare escribeRapido(Z)VbyteArrayToByteString([B)Ljava/lang/String;escribeIdClienteconcat([B[B)[Bwrite([B)Vclose!34567689:;<=>?@ABCD[**ȼ*+*,*u0#:Y  * *- *Y,*Y,+:Y +   !$IgjE>0 124!8$5&7D9I;X<g?j=l>AF>&GHl&IJKL<=>?@AM$NOPQReS'!TUDSYTN:**D6-* !* !* :3 *",* !#* +*0 !$* **0 %&:Y' * (  * #:Y* + * CD~C)D~)))E^K LP U0[B^DaQcZfbjtm}nqstx{}~F\ VWQcX6-IJYZKL[6\6 ]6^6M30___N____Sq`!abDYTN:YTYTYTYTYTYTYTYT:*-,,,,+,-**-.U:Y/ * (  * #:Y0 + * OZ]OZ)E2 8OZ]_FR_-IJYZKL[6\6 ]6^68xc6M#]N_____Sq`deD*1L*2L ) )E F  YZYZKLM J`I`fgPK wC8NBJTorrent/Handshake.java/* * Handshake.java * * Created on 2 de diciembre de 2007, 6:50 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package BJTorrent; /** * * @author Benjamn Muiz Garca */ import java.net.Socket; import java.net.SocketException; import java.io.IOException; import java.io.BufferedWriter; import java.io.DataOutputStream; import java.io.DataInputStream; /** * Clase que enva/recibe el handshake con el peer e indica si el handshake se ha realizado con * xito. */ public class Handshake { //buffer que usamos para leer del socket private byte []buffer=new byte [200]; //buffer que usamos para escribir en el socket private byte []mensaje; //Stream por el que escribimos en el socket private DataOutputStream out; //Stream por el que leemos del socket private DataInputStream in; //Peer con el que hacemos el handshake private Peer p; //socket private Socket socket_peer; //Fichero por el que escribimos la traza de ejecucin private BufferedWriter traza; /** * * Crea una nueva instancia de Handshake * @param p Peer Cliente o peer con el que hacemos el handshake * @param socket_peer Socket por el que escribimos o leemos * @param traza BufferedWriter Fichero por en el que escribimos la traza de ejecucin. */ public Handshake(Peer p,Socket socket_peer, BufferedWriter traza) { this.p=p; this.socket_peer=socket_peer; try{ this.socket_peer.setSoTimeout(30000); }catch (SocketException se) { Salida.escribe("Excepcion Fijando Timeout Handshake "+se.toString(),this.traza); } this.traza=traza; try{ out =new DataOutputStream(socket_peer.getOutputStream()); in = new DataInputStream(socket_peer.getInputStream()); }catch (IOException ioe) { Salida.escribe("Clase Handshake error IO. "+p.toString()+" "+ioe.toString()); } } /** * Lee del socket el mensaje de handshake que le enva el peer remoto *@param info_hash byte[] Clave SHA-1 de 20 bytes del torrente *@param id_cliente byte[] 20 bytes que indican el programa y versin de nuestro cliente. *@return boolean true si el handshake se realiza con xito y false si el handshake es * invalido. */ public synchronized boolean leeHandShake(byte[] id_cliente,byte[] info_hash){ byte [] longitud={19}; byte [] protocolo="BitTorrent protocol".getBytes(); // byte[] reservados = {0,0,0,0,0,0,0,4}; try{ int leidos=in.read(buffer,0,68); //Salida.escribe(new String(buffer)); if(Utils.bytesCompare(longitud,Utils.subArray(buffer,0,1))==false) { //return false; } if(Utils.bytesCompare(protocolo,Utils.subArray(buffer,1,19))==false) { //Salida.escribe("nombre protocolo: "+new String(Utils.subArray(buffer,1,19))); return false; } byte[] rapido=Utils.subArray(buffer,20,8); //Salida.escribe(Utils.bytesToHex(rapido)); if (rapido[7] ==0x04) { //Salida.escribe("Protocolo rapido\n\n"); p.escribeRapido(true); } if(Utils.bytesCompare(info_hash,Utils.subArray(buffer,28,20))==false) { //Salida.escribe(Utils.bytesToHex(info_hash),this.traza); Salida.escribe("FALLO HANDSHAKE por hash SHA1",this.traza); return false; } if(Utils.bytesCompare(id_cliente,Utils.subArray(buffer,48,20))==true) { Salida.escribe("FALLO por ID cliente idntica",this.traza); return false; } p.escribeIdCliente(Utils.byteArrayToByteString(Utils.subArray(buffer,48,8))); return true; } catch (IOException ioe) { Salida.escribe("Excepcion IO Handshake"+p.toString()+" "+ioe.toString(),this.traza); } catch (Exception e) { Salida.escribe("Error interno Handshake"+e.toString(),this.traza); } return false; } /** * Escribe en el socket el mensaje de handshake de nuestro cliente. *@param id_cliente byte[] 20 bytes que indican el programa y versin de nuestro cliente. *@param info_hash byte[] Clave SHA-1 de 20 bytes del torrente */ public synchronized void escribeHandShake(byte[] id_cliente ,byte[] info_hash){ byte [] longitud={19}; byte [] protocolo="BitTorrent protocol".getBytes(); // byte[] reservados = {0,0,0,0,0,0,0,0}; byte[] reservados = {0,0,0,0,0,0,0,0x04}; //extension FAST mensaje=Utils.concat(Utils.concat(Utils.concat(Utils.concat(longitud, protocolo), reservados),info_hash),id_cliente); //Salida.escribeVentana(Utils.byteArrayToByteString(mensaje)); try{ out.write(mensaje); } catch (IOException ioe) { Salida.escribe("Handshake IO timeout. "+p.toString()+" "+ioe.toString(),this.traza); } catch (Exception e) { Salida.escribe("Error interno. "+e.toString(),this.traza); } } /** * Mtodo que cierra los ficheros abiertos quen leen y escriben en el socket. */ public void cerrar(){ try{ this.in.close(); }catch(Exception e){} try{ this.out.close(); }catch(Exception e){} } } PK wC8LMA4(4(BJTorrent/P2P/Conexion.class2  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~  ~ ~ ~ J             ~   ~ & & % &  !" -#$ 0 ~% & '( )* +, -. /0 &123 4 -5 6 '78 E9 :; <= H> &? @ HABC OD ~E OF OG OHIJK ~L OM NOP QRS T UV NW UX 'A YZ[ &\] U^_` Ua Ub Ycd Uefg ~h Ui Uj Uk Ulm ~n opqrprotoLBJTorrent/P2P/Protocolo; socket_peerLjava/net/Socket;pLBJTorrent/Peer; id_cliente[B info_hashtorrente*LBJTorrent/FicheroTorrent/FicheroTorrente; ListaPiezas[LBJTorrent/Pieza; num_piezasItrazaLjava/io/BufferedWriter; SIN_PIEZA fichero_leeLjava/io/RandomAccessFile;fichero_escribepathLjava/lang/String;runZ proxyhost proxypuerto handshakeLBJTorrent/Handshake; escuchador+LBJTorrent/ControlDescarga/DownloadTorrent;(LBJTorrent/Peer;[B[BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/io/BufferedWriter;Ljava/lang/String;Ljava/lang/String;I)VCodeLineNumberTableLocalVariableTablethisLBJTorrent/P2P/Conexion;(LBJTorrent/Peer;Ljava/net/Socket;[B[BLBJTorrent/FicheroTorrent/FicheroTorrente;[LBJTorrent/Pieza;Ljava/io/BufferedWriter;Ljava/lang/String;LBJTorrent/Handshake;)Vsocket()VaddrLjava/net/SocketAddress;proxyLjava/net/Proxy;destLjava/net/InetSocketAddress;uheLjava/net/UnknownHostException;ioeLjava/io/IOException;eLjava/lang/Exception;b StackMapTable!# eligePieza(LBJTorrent/Peer;)IielegidanumpiezaintentosguardaPiezaDisco(I[B)VtempLjava/io/File;indice datosPiezatampiezaposicionescritosposfichjfaltanescribirposbuffqleeBloqueDisco(III)[Biniciolongitud datosBloqueleidos faltanleerlimiteVelocidadUL(I)Z tam_bloque tiempoauxJ velocidadULFlimiteVelocidadDL()Z velocidadDLcreaConexionEscuchador.(LBJTorrent/ControlDescarga/DownloadTorrent;)VleeConexionEscuchador-()LBJTorrent/ControlDescarga/DownloadTorrent; peerActivo.(Ljava/lang/String;LBJTorrent/P2P/Protocolo;)Vidp2ppeerFin(Ljava/lang/String;)V recibidaPieza(I)Vpieza enviadoBloquetampararfinalize Exceptionss SourceFile Conexion.java  t uvjava/net/InetSocketAddress wjava/net/Proxyx {| }java/net/Socket ~  v  BJTorrent/P2P/Protocolo    java/net/UnknownHostExceptionjava/lang/StringBuilder Fallo UnknownHostcalse Conexion   java/io/IOExceptionFallo IO conectandose java/lang/ExceptionFallo Interno clase Conexion   v Error en run() Conexion    Elegida Pieza Aleatoria Elegida Pieza Secuencial Estamos SIN_PIEZA  v  java/lang/Long v  java/io/File java/lang/String    java/io/RandomAccessFilerw    %No se pudo escribir la pieza en discoEscrita la Pieza  en disco  "No se pudo leer el bloque en disco Leido bloque de Pieza     v!Limite velocidad SUBIDA Invalido  KB/seg - Maximo permtido  KB/segLimite velocidad SUBIDA valido   v!Limite velocidad BAJADA Invalido Limite velocidad BAJADA valido  Kb/seg   Finalizado Hilo Conexion  BJTorrent/P2P/Conexionjava/lang/Threadjava/lang/Throwable(BJTorrent/FicheroTorrent/FicheroTorrentelength()I(Ljava/lang/String;I)Vjava/net/Proxy$TypeType InnerClassesSOCKSLjava/net/Proxy$Type;0(Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V(Ljava/net/Proxy;)VBJTorrent/PeerleeIP()Ljava/lang/String; leePuertoconnect(Ljava/net/SocketAddress;)V isConnectedh(LBJTorrent/Peer;Ljava/net/Socket;[B[B[LBJTorrent/Pieza;ILjava/io/BufferedWriter;LBJTorrent/Handshake;)VcreaProtocoloEscuchador(LBJTorrent/P2P/Conexion;)Vstartappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toStringBJTorrent/Salidaescribe-(Ljava/lang/String;Ljava/io/BufferedWriter;)Vsleep(J)VEnviosPendientesLjava/util/LinkedList;java/util/LinkedListsizeenviaPiezaColajava/lang/Mathrandom()DBJTorrent/Pieza leeCompleta leeTienePieza(I)Ljava/lang/StringBuilder; tam_pieza leeTamPiezaListaLongitudesget(I)Ljava/lang/Object;intValue num_ficheros ListaRutas separatorCharC(C)Ljava/lang/StringBuilder; ListaFicheros#(Ljava/io/File;Ljava/lang/String;)Vseekwrite([BII)Vcloseread([BII)Ijava/lang/SystemerrLjava/io/PrintStream;java/io/PrintStreamprintln)BJTorrent/ControlDescarga/DownloadTorrent KBenviadoscurrentTimeMillis()JtiempoUL!BJTorrent/GUI/VentanaPreferenciasleeLimiteVelocidadUL(F)Ljava/lang/StringBuilder;limiteUL KBpedidos KBrecibidosleeLimiteVelocidadDLlimiteDLconexionActiva conexionFingetNamejava/lang/Object!~+ c******8*+*, *- * * * **** *JbA GIKM!d&e+f0g6h<iBkKlQmWn]obpf cccccccccc " ^******8*+*- * * * * **,** FA GIKM!&+17=CLQW]f ^^^^^^^^^^  *p*LY**LY+M*Y,Y**N*-*Y***M*C*Y*** * * * * * !*!*"*!#*$oL&Y'()+*)+* ,*$JL&Y'.)+/)+* ,*$%L&Y'1)+2)+* ,*$*SL*W35*!*!67 *!8&M&Y'9),2)+* ,*%-0Dgj0%".:PX[t48@DL`gjk\ "6.*P!!!k"DI% [PBdd!.B"!`=>6JD:*k>* 2;+<=&Y'=)>+* ,6*>+<.* 2;!&Y'?)>+* ,@* ,*J  + 46PR^u#$>UDJ=!D * A>h6666* 2BY>66* CDEF$* CDEFd666 6  * G1* C DEFd6vHY&Y'*)* I DJ)KL* M DJ)+N: *OY PQR*RS*R, T*RUHY&Y'*)* I DJ)KL* M DJ)+N: *OY PQR*RS*R, T*RU `6 d66: V* , ɻ&Y'W)>X)+* ,r-- -%/0 1249#:';><U=Y>_@bArGHJKLMNPST VOW^XhYtZ{\]^dabAhk/ O=  f:  #b^ *' 7 !:* A6h`6666 6 6* C DEF$* C DEFd66 6  6  * G4* C DEFd6 xHY&Y'*)* I DJ)KL* M DJ)+N: *OY PQY*YS*Y  ZW*YUHY&Y'*)* I DJ)KL* M DJ)+N: *OY PQY*YS*Y ZW*YU `6  d6 6 : [\] ƻ&Y'^)>X)+* ,&Y'^)>X)+_q- - -'uvwxy~"&=TX^aq  P_iw~1 P?  e=  " a~ ,& 7 !`l``abeA cA`e mi8gn8h<`ld`&Y'i)jk)l>m)+* ,&Y'n)j+* ,2  +2<Hsu*~+g V!(abe@ c@opo`emjFp`emjF%gnF%q/&Y'r)%jk)s>m)+* ,&Y't)%ju)s>m)+* ,2 -<AJtv**<f 9!>*+v /*v !L *v+,w     !I *v+x*$%& ( !A *vy 13 !A *vz <> 4* DE T"&Y'{)*|)+* ,*}LM!O "z  y@PK wC8YYBJTorrent/P2P/Conexion.java /* * Conexion.java * * Created on 6 de noviembre de 2007, 8:12 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.P2P; import BJTorrent.Pieza; import BJTorrent.Peer; import BJTorrent.Handshake; import BJTorrent.Salida; import BJTorrent.Constantes; import BJTorrent.ControlDescarga.DownloadTorrent; import BJTorrent.FicheroTorrent.FicheroTorrente; import BJTorrent.GUI.VentanaPreferencias; import java.util.LinkedHashMap; import java.util.Iterator; import java.net.Socket; import java.net.SocketAddress; import java.net.InetSocketAddress; import java.net.InetAddress; import java.net.Proxy; import java.net.UnknownHostException; import java.io.IOException; import java.io.File; import java.io.BufferedWriter; import java.io.RandomAccessFile; import java.util.BitSet; /** * Subclase de Thread que crea las conexiones con los peers, es decir crea los sockets y los conecta * a cada Peer devuelto por el Tracker. Por cada socket conectado crea una instancia de Protocolo. */ public class Conexion extends Thread { //objeto Protocolo que instanciamos private Protocolo proto; //socket que conectamos con el peer. Puede haberse creado y conectado en ConexionServer private Socket socket_peer; //Peer al que nos conectamos private Peer p; //ID cliente de 20 bytes calculada al arrancar la aplicacin private byte []id_cliente; //SHA1 del torrente private byte []info_hash; //Objeto que almacena la informacin del fichero .torrent private FicheroTorrente torrente; //Array que contiene las piezas del torrente private Pieza[] ListaPiezas; //Nmero de piezas del torrente private int num_piezas; //Fichero por el que sacamos la traza de ejecucin private BufferedWriter traza; //Constante que indica que no tenemos pieza que descargar de un peer private int SIN_PIEZA=-1; //Usado para leer bloques en el sistema de ficheros private RandomAccessFile fichero_lee; //Usado para escribir piezas en el sistema de ficheros private RandomAccessFile fichero_escribe; //ruta o path con el que accedemos a los ficheros del torrente private String path=""; //Indica si el hilo sigue corriendo private boolean run=true; //IP o nombre del host que hace como proxy private String proxyhost=""; //Nmero de puerto SOCKS del proxy private int proxypuerto=1080; //Objeto con el que hacemos el handshake con el peer private Handshake handshake; //Guarda al objeto DownloadTorrent que creo este objeto private DownloadTorrent escuchador; /** * Crea una nueva instancia de Conexion para los peers que nos devuelve el tracker y con los que hay * que conectar un socket. * * @param p Peer Peer con el vamos a conectar. * @param id_cliente byte[] ID de nuestro cliente de 20 bytes, sirve para el handshake. * @param info_hash byte[] Clave SHA1 del torrente que sirve para hacer el handshake. * @param torrente FicheroTorrente Objeto que ley y almacena la informacin del fichero .torrent * @param ListaPiezas Pieza[] Array con las piezas del torrente * @param traza BufferedWriter Fichero en el que sacamos la traza de ejcucin del programa. * @param path String Ruta seleccionada en VentanaPreferencias y que ser el punto de inicio * donde almacenaremos los ficheros y directorios que componen el torrente. * @param proxyhost String IP o nombre del host que hace de proxy escogido en VentanaPreferencias * @param proxypuerto int Nmero de puerto SOCKS del proxy escogido en VentanaPreferencias */ public Conexion(Peer p,byte []id_cliente,byte[] info_hash,FicheroTorrente torrente,Pieza[] ListaPiezas,BufferedWriter traza,String path,String proxyhost, int proxypuerto) { this.p=p; this.id_cliente=id_cliente; this.info_hash=info_hash; this.torrente=torrente; this.ListaPiezas=ListaPiezas; this.traza=traza; this.num_piezas=torrente.num_piezas; this.path=path; this.proxyhost=proxyhost; this.proxypuerto=proxypuerto; this.handshake=null; } /** * Crea una nueva instancia de Conexin invocada cuando aceptamos una conexion en la clase * ConexionServer y ya tenemos el socket conectado. * * @param p Peer Peer con el que ya estamos conectados * @param socket Socket conetado con el peer. * @param id_cliente byte[] ID de nuestro cliente de 20 bytes * @param info_hash byte[] Clave SHA1 del torrente. * @param torrente FicheroTorrente Objeto que ley y almacena la informacin del fichero .torrent * @param ListaPiezas Pieza[] Array con las piezas del torrente * @param traza BufferedWriter Fichero en el que sacamos la traza de ejcucin del programa. * @param path String Ruta seleccionada en VentanaPreferencias y que ser el punto de inicio * donde almacenaremos los ficheros y directorios que componen el torrente. * @param handshake Handshake El objeto con el que ya hizo el handshake en la clase DownloadTorrent * */ public Conexion(Peer p,Socket socket,byte []id_cliente,byte[] info_hash,FicheroTorrente torrente,Pieza[] ListaPiezas,BufferedWriter traza,String path,Handshake handshake) { this.p=p; this.id_cliente=id_cliente; this.info_hash=info_hash; this.torrente=torrente; this.ListaPiezas=ListaPiezas; this.traza=traza; this.num_piezas=torrente.num_piezas; this.socket_peer=socket; this.path=path; this.handshake=handshake; } /** * * Este mtodo slo intenta una nica conexin con el peer remoto. Mira si usamos proxy para conectarnos al peer * y en ese caso usa la clase java.net.Proxy . * Si se crea el socket y se conecta al peer entonces lanzamos un hilo de la clase Protocolo para * enviar/recibir datos por el socket. * En el caso de que hubisemos creado ya la conexin en la * clase ConexionServer crea y ejecuta una instancia del hilo Protocolo. * Mientras corre el hilo comprobamos la velocidad mxima de Upload de nuestro cliente y si no se * rebasa el limite enviamos bloques pendientes de envio. * Sino se logra conectar el socket con el peer, el hilo se para y la JVM lo finalizar. */ public void run(){ try{ if (socket_peer==null) { // this.num_intentos++; if (proxyhost.length()>1) { SocketAddress addr = new InetSocketAddress(this.proxyhost, this.proxypuerto); Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr); socket_peer = new Socket(proxy); InetSocketAddress dest = new InetSocketAddress(p.leeIP(), p.leePuerto()); socket_peer.connect(dest); } else socket_peer=new Socket(p.leeIP(),p.leePuerto()); } //si el socket era null if (socket_peer!=null && socket_peer.isConnected()) { proto=new Protocolo(p,socket_peer,id_cliente,info_hash,this.ListaPiezas,this.torrente.num_piezas,this.traza,handshake); proto.creaProtocoloEscuchador(this); proto.start(); } else this.parar(); } catch (UnknownHostException uhe) { Salida.escribe("Fallo UnknownHostcalse Conexion "+uhe.toString(),this.traza); this.parar(); } catch (IOException ioe) { Salida.escribe("Fallo IO conectandose "+ioe.toString(),this.traza); this.parar(); } catch (Exception e) { Salida.escribe("Fallo Interno clase Conexion "+e.toString(),this.traza); this.parar(); } while (this.run==true) { byte []b=new byte[0]; try { //synchronized (b) { // b.wait(1000); this.sleep(1000); if (proto!=null && proto.EnviosPendientes.size()>0) proto.enviaPiezaCola(); //} } catch (Exception e) { Salida.escribe("Error en run() Conexion "+e.toString(),this.traza); this.run=false; } } } /** * * Mtodo que elige una pieza para ser descargada por completo del Peer pasado como argumento. * Primero intentamos elegir la pieza de forma aleatoria comprobando que el peer remoto la tenga * y no la tengamos ya descargada. * Despus de 5 intentos aleatorios, si aun no tenemos pieza, elegimos secuencialmente la pieza a descargar * empezando desde la pieza cero eligiendo la primera pieza * que tenga el peer remoto y nosotros no tengamos. * @param p Peer Cliente o peer con el que estamos enviando/recibiendo mensajes. * @return int Nmero de pieza que comenzaremos a descargar o constante entera SIN_PIEZA en caso de que ya no tengamos nada * que descargar del Peer pasado como argumento. */ public synchronized int eligePieza(Peer p){ //Primero miramos si el peer nos ofrece algna rapida /* int numpiezarapida; for (int i=0;i=this.torrente.ListaLongitudes.get(j).intValue()) { posicion=posicion -this.torrente.ListaLongitudes.get(j).intValue(); posfich=posicion; j++; } int posbuff=0; for (int i = j; i < this.torrente.num_ficheros; i++) { try { escritos=this.torrente.ListaLongitudes.get(i).intValue()-posfich; if (escritos>faltanescribir) { File temp = new File(this.path+torrente.ListaRutas.get(i)+File.separatorChar+torrente.ListaFicheros.get(i)); this.fichero_escribe = new RandomAccessFile(temp, "rw"); this.fichero_escribe.seek(posfich); this.fichero_escribe.write(datosPieza,posbuff,faltanescribir); this.fichero_escribe.close(); break; } else { if (escritos<=0) break; File temp = new File(this.path+torrente.ListaRutas.get(i)+File.separatorChar+torrente.ListaFicheros.get(i)); this.fichero_escribe= new RandomAccessFile(temp, "rw"); this.fichero_escribe.seek(posfich); this.fichero_escribe.write(datosPieza,posbuff,escritos); this.fichero_escribe.close(); // Salida.escribe("Escribiendo Pieza dividida. escritos"+escritos); posbuff=posbuff+escritos; faltanescribir=faltanescribir-escritos; posfich=0; } } catch (IOException ioe) { Salida.escribe("No se pudo escribir la pieza en disco",this.traza); } }//fin for Salida.escribe("Escrita la Pieza "+indice+" en disco",this.traza); } /** * Lee un bloque de datos del fichero o ficheros adecuados y en la posicin adecuada. * @param indice int Nmero de pieza * @param inicio int Desplazamiento en bytes dentro de la pieza * @param longitud int Tamao del bloque */ public synchronized byte[] leeBloqueDisco(int indice,int inicio,int longitud){ byte[] datosBloque=new byte[longitud]; int tampieza=this.torrente.tam_pieza; int posicion=(indice*tampieza)+inicio; int leidos=0; int posfich=0; int faltanleer=longitud; int j=0; posfich=posicion; while (posicion>=this.torrente.ListaLongitudes.get(j).intValue()) { posicion=posicion -this.torrente.ListaLongitudes.get(j).intValue(); posfich=posicion; j++; } int posbuff=0; for (int i = j; i < this.torrente.num_ficheros; i++) { try { leidos=this.torrente.ListaLongitudes.get(i).intValue()-posfich; if (leidos>faltanleer) { File temp = new File(this.path+torrente.ListaRutas.get(i)+File.separatorChar+torrente.ListaFicheros.get(i)); this.fichero_lee = new RandomAccessFile(temp, "rw"); this.fichero_lee.seek(posfich); this.fichero_lee.read(datosBloque,posbuff,faltanleer); this.fichero_lee.close(); // Salida.escribe("Escrita la Pieza en disco . leidos: "+faltanleer); break; } else { //leidos=this.torrente.ListaLongitudes.get(j).intValue()-posicion; if (leidos<=0) break; File temp = new File(this.path+torrente.ListaRutas.get(i)+File.separatorChar+torrente.ListaFicheros.get(i)); this.fichero_lee= new RandomAccessFile(temp, "rw"); this.fichero_lee.seek(posfich); this.fichero_lee.read(datosBloque,posbuff,leidos); this.fichero_lee.close(); //Salida.escribe("Leyendo Pieza dividida. leidos"+leidos); posbuff=posbuff+leidos; faltanleer=faltanleer-leidos; posfich=0; } } catch (IOException ioe) { System.err.println("No se pudo leer el bloque en disco"); } }//fin for Salida.escribe("Leido bloque de Pieza "+indice+" en disco",this.traza); Salida.escribe("Leido bloque de Pieza "+indice+" en disco"); return datosBloque; } /** * * Mtodo que a partir de la longitud de una peticin de un bloque, * indica si sirviendo ese bloque rebasamos el lmite mximo de velocidad * de subida de nuestro cliente. * @param tam_bloque int Tamao del bloque que nos piden enviar * @return boolean true si rebasamos el lmite de velocidad mximo de Upload, false en caso * contrario. */ public synchronized boolean limiteVelocidadUL(int tam_bloque){ DownloadTorrent.KBenviados+=(tam_bloque/1024); long tiempoaux=System.currentTimeMillis()-DownloadTorrent.tiempoUL; if (tiempoaux==0) tiempoaux=10; //para evitar division por cero //Salida.escribe("Tiempo en milis "+tiempoaux,this.traza); float velocidadUL=DownloadTorrent.KBenviados*(10000/tiempoaux); velocidadUL=velocidadUL/10; //velocidad por segundo if (velocidadUL>=VentanaPreferencias.leeLimiteVelocidadUL()) { DownloadTorrent.KBenviados-=(tam_bloque/1024); Salida.escribe("Limite velocidad SUBIDA Invalido "+velocidadUL+" KB/seg - Maximo permtido "+DownloadTorrent.limiteUL+" KB/seg",this.traza); return true; } else { Salida.escribe("Limite velocidad SUBIDA valido "+velocidadUL,this.traza); return false; } } /** * * Mtodo que indica si haciendo una nueva peticin de bloque REQUEST rebasamos el lmite mximo de velocidad * de bajada de nuestro cliente. * @return boolean true si rebasamos el lmite de velocidad mximo de Download, false en caso * contrario. */ public synchronized boolean limiteVelocidadDL(){ //DownloadTorrent.KBrecibidos+=(tam_bloque/1024); long tiempoaux=System.currentTimeMillis()-DownloadTorrent.tiempoUL; if (tiempoaux==0) tiempoaux=10; //para evitar division por cero float velocidadDL; if (DownloadTorrent.KBpedidos>DownloadTorrent.KBrecibidos) velocidadDL=(float)(DownloadTorrent.KBpedidos+(Constantes.TAM_BLOQUE/1024))*(10000/tiempoaux); else velocidadDL=(float)(DownloadTorrent.KBrecibidos+(Constantes.TAM_BLOQUE/1024))*(10000/tiempoaux); velocidadDL=velocidadDL/10; //cada 10 segundos if (velocidadDL>=VentanaPreferencias.leeLimiteVelocidadDL()) { Salida.escribe("Limite velocidad BAJADA Invalido "+velocidadDL+ " KB/seg - Maximo permtido "+DownloadTorrent.limiteDL+" KB/seg",this.traza); return true; } else { Salida.escribe("Limite velocidad BAJADA valido "+velocidadDL+" Kb/seg "+DownloadTorrent.limiteDL+" KB/seg",this.traza); return false; } } /** * Guarda el objeto DownloadTorrent pasado como argumento * y que fue el que creo una instancia de este hilo Conexion y la arranco. * @param escuchador DownloatTorrent Objeto que instancio y corrio este hilo Conexion */ public synchronized void creaConexionEscuchador(DownloadTorrent escuchador) { //System.out.println("Aadido Listener DownloadTorrent"); this.escuchador=escuchador; } /** * Devuelve el objeto de la clase DownloadTorrent que creo y arranco este hilo * @return DownloadTorrent Objeto que escucha eventos */ public DownloadTorrent leeConexionEscuchador() { return this.escuchador; } /** * Indica que se hizo correctamente el handshake. * Llama al mtodo ConexionActiva(id,p2p) del objeto DownloadTorrent * que instanci este objeto. * @param id String ID del Peer formada por la concatenacin de su IP y puerto * @param p2p Protocolo Objeto que maneja la comunicacin con el peer remoto */ public synchronized void peerActivo(String id, Protocolo p2p) { this.escuchador.conexionActiva(id,p2p); } /** * Invoca al mtodo ConexionFin(id) del objeto DownloadTorrent * que instanci este objeto y para la ejecucin de este objeto hilo. * Indica que hemos cerrado la conexin con un peer, generalmente por porque * el usuario par la descarga, fallo de handshake, * o bien porque ha habido un error al recibir un mensaje. * @param id String ID del peer formada por su "IP+puerto" */ public synchronized void peerFin(String id) { this.escuchador.conexionFin(id); this.parar(); } /** * * Invoca al mtodo recibidaPieza(pieza) del objeto DownloadTorrent * que instanci este objeto hilo. * @param pieza int Nmero de pieza recibida */ public synchronized void recibidaPieza(int pieza){ this.escuchador.recibidaPieza(pieza); } /** * * Invoca al mtodo enviadoBloque(tam) del objeto DownloadTorrent * que instanci este hilo. * @param tam int Longitud del bloque enviado */ public synchronized void enviadoBloque(int tam){ this.escuchador.enviadoBloque(tam); } /** * Mtodo que para la ejecucin del hilo */ public void parar(){ this.run=false; } /** * * Llama a finalize() de la super-clase. * Mtodo sobre-escrito */ protected void finalize() throws Throwable{ Salida.escribe("Finalizado Hilo Conexion "+this.getName(),this.traza); super.finalize(); } } PK wC82!BJTorrent/P2P/EnviarMensaje.class2 B A A A A A A A A A A A A     A A   A A A A  %   A mensaje[Bblen idmensajeBbindicebinicio blongitudpayloadidIlenoutLjava/io/DataOutputStream;indiceiniciolengthpLBJTorrent/Peer;trazaLjava/io/BufferedWriter;E(Ljava/io/DataOutputStream;LBJTorrent/Peer;Ljava/io/BufferedWriter;)VCodeLineNumberTableLocalVariableTablethisLBJTorrent/P2P/EnviarMensaje;escribeMensaje(I)VtipoescribeHave_AllowFast(II)VescribeBitfield(I[B)VescribeRequest(IIII)V escribePiece(III[B)Vdatos enviaBytesioeLjava/io/IOException;eLjava/lang/Exception;cadenaLjava/lang/String; StackMapTable generaMensaje()[BtoString()Ljava/lang/String; bitsString([Z)Ljava/lang/String;ibits[Z SourceFileEnviarMensaje.java X HD ID JD OP TU VW LM k` QM KD RM SMjava/lang/StringBuilderID mensaje enviado incorrecto yz ED FG  java/io/IOException Problema escribiendo en socket. NM wx CDENVIADO -Problema escribiendo en socket Clase Enviar. java/lang/ExceptionError interno Clase Enviar.  z ->    HAVE  Bitfield= {|REQUEST CANCELSUGGEST PIECE REJECT REQUEST  ALLOW FAST 10BJTorrent/P2P/EnviarMensajejava/lang/Objectjava/lang/String()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;BJTorrent/Salidaescribe-(Ljava/lang/String;Ljava/io/BufferedWriter;)VBJTorrent/UtilsintToByteArray(I)[Bconcat([B[B)[Bjava/io/DataOutputStreamwrite([B)VbyteArrayToInt([B)I(Ljava/lang/String;)V([BB)[BBJTorrent/Peer leeIdClienteBJTorrent/ConstantesMENSAJE[Ljava/lang/String;byteArray2BitArray([B)[ZsubArray([BII)[B!ABCDEDFGHDIDJDKDLMNMOPQMRMSMTUVW XYZ)*****+*,*-["C$ &(DE#F(G\*)]^)OP)TU)VW_`ZJ*** [QR T\]^aMbcZ]** ** [[\ ]_\ ]^aMQMdeZ]**, ** [hi jk\ ]^aMKDfgZ** * * ** [uv wxyz\4]^aMQMRMSMhiZ** * * ** [ \4]^aMQMRMjDk`Z Y*!Wvs!!!w*YTYTYTYT**YTYTYTYT**YTYTYTYT*p*YTYTYTYT*Q*YTYTYTYT*** ** ** `* *YTYTYTY T*** ** ** **** *** ** ****  ** `n*YTYTYTY T*** E*YTYTYTYT*%*YTYTYTYT**YTYTYTY T*** ** ** **** *YTYTYTYT* ** ** z*YTYTYTYT*** ** G*YTYTYTYT**!MY,***** *!MY",*Y",#** BNY$-*!NY&-'*$'%[JR $|'*8=@X^it!$;AD\bmx$'(EFQY^x      \>(lmlmno]^aM^~pqr7 W1WB(W22dsUtus`vwxZE*(****(* ***(*[- 4!@#\ E]^r-yzZY*)*L*+L*Y+,*2L*S*LFl&LLLLALLY+-* .LY+/** 01.LY+2LY+3* 4.LY+5* 4.LY+6* 4.L)Y+7LY+3* 4.LY+5* 4.LY+8* d9LY+:LY+3* 4.LY+5* 4.LY+6* 4.LY+;LY+3* 4.LϻY+<LY+3* 4.LY+5* 4.LY+6* 4.L?Y+=LY+3* 4.L+[%-/!0$1,2F4N579;<>?$@LAuBxDEFGHJK?LgMNPQRTUV6W_XbZv[b\]^pqr $u!Q%)>;{|Z9>M>*dh(Y,+3?@M,[mno1n7p\*2}M9]^9~6pqr'ubtuu PK wC8rg44 BJTorrent/P2P/EnviarMensaje.java/* * EnviarMensaje.java * * Created on 1 de noviembre de 2007, 14:37 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Benjamn Muiz Garca */ package BJTorrent.P2P; import BJTorrent.Peer; import BJTorrent.Salida; import BJTorrent.Utils; import BJTorrent.Constantes; import java.io.IOException; import java.io.BufferedWriter; import java.io.DataOutputStream; /** * * Clase que enva los mensajes. Cada objeto Protocolo crea una instancia de esta clase. */ public class EnviarMensaje { //almacena los bytes del mensaje a enviar al Peer byte []mensaje; //array que almacena el campo longitud del mensaje, primer campo del mensaje private byte[] blen; //byte ID o tipo de mensaje private byte idmensaje; //array que almacena el ndice o nmero de pieza del mensaje private byte[] bindice=new byte[4]; //array que almacena el campo inicio de un mensaje REQUEST o PIECE o CANCEL private byte[] binicio=new byte[4]; //array que almacena el campo longitud de un mensaje REQUEST o CANCEL private byte[] blongitud=new byte[4]; //array que almacena todo el mensaje a partir del campo ID private byte[] payload; //id o tipo del mensaje private int id; //Campo longitud, primer campo private int len; //Fichero por el que escribimos en el socket private DataOutputStream out; //campo ndice private int indice; //campo inicio private int inicio; //campo longitud (no es el primer campo) es la longitud de un bloque en un mensaje REQUEST o CANCEL private int length; //Peer al que enviamos los mensajes private Peer p; //Fichero por el que escribimos la traza de ejecucin private BufferedWriter traza; /** * Crea una instancia de EnviarMensaje * * @param out DataOutputStream Stream por el que escribimos en el socket * @param p Peer El cliente o peer remoto al que le enviamos los mensajes * @param traza BufferedWriter Fichero al que escribimos la traza de mensajes que enviamos */ public EnviarMensaje(DataOutputStream out, Peer p,BufferedWriter traza){ this.out=out; this.p=p; this.traza=traza; } /** * Escribe o crea un mensaje sin payload, es decir de longitud slo 5 bytes. * @param tipo int Tipo o id del mensaje * */ public void escribeMensaje(int tipo) { this.id=tipo; enviaBytes(this.id); } /** * Escribe o crea un mensaje de tipo HAVE * @param tipo int ID del mensaje * @param indice int Nmero de pieza */ public void escribeHave_AllowFast(int tipo,int indice) { this.id=tipo; this.indice=indice; enviaBytes(this.id); } /** * Escribe un mensaje de tipo BITFIELD * @param tipo int ID del mensaje * @param payload byte[] El bitfield codificado en bytes tal cual se enva */ public void escribeBitfield(int tipo, byte [] payload) { this.id=tipo; this.payload=payload; enviaBytes(this.id); } /** Escribe un mensaje de tipo REQUEST * @param tipo int ID del mensaje * @param indice int Nmero de pieza * @param inicio int Desplazamiento dentro de la pieza * @param length int Longitud del bloque de datos que estamos pidiendo al peer remoto */ public void escribeRequest(int tipo, int indice, int inicio, int length) { this.id=tipo; this.indice=indice; this.inicio=inicio; this.length=length; enviaBytes(this.id); } /** * Escribe un mensaje de tipo PIECE * @param tipo int ID del mensaje * @param indice int Nmero de pieza * @param inicio int Desplazamiento dentro de la pieza * @param datos byte[] Bloque de datos parte de una pieza que enviamos por el socket */ public void escribePiece(int tipo, int indice, int inicio, byte []datos) { this.id=tipo; this.indice=indice; this.inicio=inicio; this.payload=datos; enviaBytes(this.id); } /** * Enva a travs del socket el mensaje previamente creado. Llama al mtodo generaMensaje(). * @param tipo int ID o tipo del mensaje */ public void enviaBytes(int tipo){ if (tipo<0 || tipo>0x11) { Salida.escribe("ID mensaje enviado incorrecto "+tipo,this.traza); //System.exit(-1); } switch (tipo) { /*case 0: blen = new byte[] {0, 0, 0, 0}; break;*/ case Constantes.CHOKE: blen = new byte[] {0, 0, 0, 1}; idmensaje=0; break; case Constantes.UNCHOKE: blen = new byte[] {0, 0, 0, 1}; idmensaje=1; break; case Constantes.INTERESTED: blen = new byte[] {0, 0, 0, 1}; idmensaje=2; break; case Constantes.NOT_INTERESTED: blen = new byte[] {0, 0, 0, 1}; idmensaje=3; break; case Constantes.HAVE: // 4 have blen = new byte[] {0, 0, 0, 5}; idmensaje=4; bindice=Utils.intToByteArray(indice); this.payload = bindice; break; case Constantes.BITFIELD: //bitfield blen = Utils.intToByteArray(1 + payload.length); idmensaje=5; //this.payload = payload; break; case Constantes.REQUEST: //request blen = new byte[] {0, 0, 0, 13}; idmensaje=6; bindice=Utils.intToByteArray(indice); binicio=Utils.intToByteArray(inicio); blongitud=Utils.intToByteArray(length); payload=Utils.concat(Utils.concat(bindice,binicio),blongitud); break; case Constantes.PIECE: idmensaje=7; bindice=Utils.intToByteArray(indice); binicio=Utils.intToByteArray(inicio); payload=Utils.concat(Utils.concat(bindice,binicio),payload); blen = Utils.intToByteArray(payload.length+1); break; case Constantes.CANCEL: blen = new byte[] {0, 0, 0, 13}; idmensaje=8; this.payload = payload; break; case Constantes.HAVE_ALL: blen = new byte[] {0, 0, 0, 1}; idmensaje=0x0E; break; case Constantes.HAVE_NONE: blen = new byte[] {0, 0, 0, 1}; idmensaje=0x0F; break; case Constantes.REJECT_REQUEST: blen = new byte[] {0, 0, 0, 13}; idmensaje=0x10; bindice=Utils.intToByteArray(indice); binicio=Utils.intToByteArray(inicio); blongitud=Utils.intToByteArray(length); payload=Utils.concat(Utils.concat(bindice,binicio),blongitud); break; case Constantes.SUGGEST_PIECE: //Suggest Piece: blen = new byte[] {0, 0, 0, 5}; idmensaje=0x0D; bindice=Utils.intToByteArray(indice); this.payload = bindice; break; case Constantes.ALLOWED_FAST: //Allowed Fast: blen = new byte[] {0, 0, 0, 5}; idmensaje=0x11; bindice=Utils.intToByteArray(indice); this.payload = bindice; break; case Constantes.KEEP_ALIVE: blen = new byte[] {0, 0, 0, 0}; try{ out.write(blen); } catch (IOException ioe) { Salida.escribe("Problema escribiendo en socket. "+ioe.toString(),this.traza); } return; } len=Utils.byteArrayToInt(blen); mensaje=generaMensaje(); //Salida.escribe(Utils.byteArrayToByteString(mensaje)); String cadena=toString(); Salida.escribe("ENVIADO "+cadena,traza); Salida.escribe("ENVIADO "+cadena); try{ out.write(mensaje); } catch (IOExce