001: /*
002: * This program is free software; you can redistribute it and/or
003: * modify it under the terms of the GNU General Public License
004: * as published by the Free Software Foundation; either version 2
005: * of the License, or (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU General Public License for more details.
011:
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package net.sf.jftp.gui.tasks;
017:
018: import net.sf.jftp.JFtp;
019: import net.sf.jftp.config.Settings;
020: import net.sf.jftp.gui.base.UIUtils;
021: import net.sf.jftp.gui.framework.*;
022: import net.sf.jftp.net.*;
023:
024: import java.awt.*;
025: import java.awt.event.*;
026:
027: import java.io.*;
028:
029: import java.lang.Integer;
030:
031: import java.util.*;
032:
033: import javax.swing.*;
034:
035: //***
036: public class BookmarkItem extends JMenuItem {
037: private String host = "localhost";
038: private String user = "anonymous";
039: private String pass = "j-ftp@sourceforge.net";
040: private String protocol = "FTP";
041: private int port = 21;
042: private String dirOrDom = "/";
043: private boolean useLocal = false;
044:
045: public BookmarkItem(String host) {
046: super (host);
047: this .host = host;
048: }
049:
050: public void setProtocol(String proto) {
051: protocol = proto;
052: setLabel(proto + ": " + getLabel());
053: }
054:
055: public void setDirectory(String dir) {
056: dirOrDom = dir;
057: }
058:
059: public void setPort(int p) {
060: port = p;
061: }
062:
063: public void setLocal(boolean local) {
064: useLocal = local;
065: }
066:
067: public void setUserdata(String u, String p) {
068: user = u;
069: pass = p;
070: }
071:
072: public void connect() {
073: if (protocol.equals("FTP")) {
074: if (pass.equals(Settings.hiddenPassword)) {
075: pass = UIUtils.getPasswordFromUser(JFtp.statusP.jftp);
076: }
077:
078: int i = StartConnection.startFtpCon(host, user, pass, port,
079: dirOrDom, useLocal);
080:
081: if (i < 0) {
082: pass = Settings.hiddenPassword;
083: }
084:
085: /*
086: FtpConnection con = StartConnection.con;
087:
088: if(con != null)
089: {
090: con.chdir(dirOrDom);
091: }
092: */
093: } else {
094: if (pass.equals(Settings.hiddenPassword)) {
095: pass = UIUtils.getPasswordFromUser(JFtp.statusP.jftp);
096: }
097:
098: boolean ok = StartConnection.startCon(protocol, host, user,
099: pass, port, dirOrDom, useLocal);
100:
101: if (!ok) {
102: pass = Settings.hiddenPassword;
103: }
104: }
105: }
106: }
|