1 16 package net.sf.jftp.gui.tasks; 17 18 import net.sf.jftp.JFtp; 19 import net.sf.jftp.config.Settings; 20 import net.sf.jftp.gui.base.UIUtils; 21 import net.sf.jftp.gui.framework.*; 22 import net.sf.jftp.net.*; 23 24 import java.awt.*; 25 import java.awt.event.*; 26 27 import java.io.*; 28 29 import java.lang.Integer ; 30 31 import java.util.*; 32 33 import javax.swing.*; 34 35 36 public class BookmarkItem extends JMenuItem 38 { 39 private String host = "localhost"; 40 private String user = "anonymous"; 41 private String pass = "j-ftp@sourceforge.net"; 42 private String protocol = "FTP"; 43 private int port = 21; 44 private String dirOrDom = "/"; 45 private boolean useLocal = false; 46 47 public BookmarkItem(String host) 48 { 49 super(host); 50 this.host = host; 51 } 52 53 public void setProtocol(String proto) 54 { 55 protocol = proto; 56 setLabel(proto + ": " + getLabel()); 57 } 58 59 public void setDirectory(String dir) 60 { 61 dirOrDom = dir; 62 } 63 64 public void setPort(int p) 65 { 66 port = p; 67 } 68 69 public void setLocal(boolean local) 70 { 71 useLocal = local; 72 } 73 74 public void setUserdata(String u, String p) 75 { 76 user = u; 77 pass = p; 78 } 79 80 public void connect() 81 { 82 if(protocol.equals("FTP")) 83 { 84 if(pass.equals(Settings.hiddenPassword)) 85 { 86 pass = UIUtils.getPasswordFromUser(JFtp.statusP.jftp); 87 } 88 89 int i = StartConnection.startFtpCon(host, user, pass, port, 90 dirOrDom, useLocal); 91 92 if(i < 0) 93 { 94 pass = Settings.hiddenPassword; 95 } 96 97 105 } 106 else 107 { 108 if(pass.equals(Settings.hiddenPassword)) 109 { 110 pass = UIUtils.getPasswordFromUser(JFtp.statusP.jftp); 111 } 112 113 boolean ok = StartConnection.startCon(protocol, host, user, pass, 114 port, dirOrDom, useLocal); 115 116 if(!ok) 117 { 118 pass = Settings.hiddenPassword; 119 } 120 } 121 } 122 } 123 | Popular Tags |