[1001] | 1 | /* |
---|
| 2 | * Jeti, a Java Jabber client, Copyright (C) 2004 E.S. de Boer |
---|
| 3 | * |
---|
| 4 | * This program is free software; you can redistribute it and/or modify |
---|
| 5 | * it under the terms of the GNU General Public License as published by |
---|
| 6 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | * (at your option) any later version. |
---|
| 8 | * |
---|
| 9 | * This program is distributed in the hope that it will be useful, |
---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | * GNU General Public License for more details. |
---|
| 13 | * |
---|
| 14 | * You should have received a copy of the GNU General Public License |
---|
| 15 | * along with this program; if not, write to the Free Software |
---|
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | * |
---|
| 18 | * For questions, comments etc, |
---|
| 19 | * use the website at http://jeti.jabberstudio.org |
---|
| 20 | * or mail me at eric@jeti.tk |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | package nu.fw.jeti.plugins.filetransfer; |
---|
| 24 | |
---|
| 25 | import java.awt.GridBagConstraints; |
---|
| 26 | import java.awt.GridBagLayout; |
---|
| 27 | import java.awt.Insets; |
---|
| 28 | import java.net.InetAddress; |
---|
| 29 | import java.net.UnknownHostException; |
---|
| 30 | |
---|
| 31 | import javax.swing.*; |
---|
| 32 | import javax.swing.Box; |
---|
| 33 | import javax.swing.JCheckBox; |
---|
| 34 | import javax.swing.JLabel; |
---|
| 35 | import javax.swing.JTextField; |
---|
| 36 | |
---|
| 37 | import nu.fw.jeti.jabber.Backend; |
---|
| 38 | import nu.fw.jeti.plugins.PreferencesPanel; |
---|
| 39 | import nu.fw.jeti.plugins.filetransfer.socks5.StreamHost; |
---|
| 40 | import nu.fw.jeti.util.I18N; |
---|
| 41 | import nu.fw.jeti.util.Preferences; |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | //7-2-2004 |
---|
| 45 | /** |
---|
| 46 | * @author E.S. de Boer |
---|
| 47 | */ |
---|
| 48 | |
---|
| 49 | public class PrefPanel extends PreferencesPanel |
---|
| 50 | { |
---|
| 51 | private JComboBox cmbIP; |
---|
| 52 | private JTextField txtPort = new JTextField(); |
---|
| 53 | private JCheckBox chkUseLocal; |
---|
| 54 | private JCheckBox chkCloseOnComplete; |
---|
| 55 | |
---|
| 56 | public PrefPanel(Backend backend) |
---|
| 57 | {//TODO add network config wizard with auto network detection (connect to php) |
---|
| 58 | setLayout(new GridBagLayout()); |
---|
| 59 | GridBagConstraints c = new GridBagConstraints(); |
---|
| 60 | c.gridwidth = GridBagConstraints.REMAINDER; |
---|
| 61 | c.anchor = GridBagConstraints.LINE_START; |
---|
| 62 | c.fill = GridBagConstraints.HORIZONTAL; |
---|
| 63 | c.insets = new Insets(3, 5, 0, 3); |
---|
| 64 | |
---|
| 65 | String choosen = Preferences.getString("filetransfer","ip",null); |
---|
| 66 | String ip = Plugin.getIP(); |
---|
| 67 | String[] ips; |
---|
| 68 | if(choosen!=null && !choosen.equals("automatic")) |
---|
| 69 | { |
---|
| 70 | if(ip!=null) ips = new String[]{choosen,ip |
---|
| 71 | ,I18N.gettext("filetransfer.automatic")+ " (" + ip + ")"}; |
---|
| 72 | else ips = new String[]{choosen}; |
---|
| 73 | } |
---|
| 74 | else if (ip!=null) ips = new String[]{I18N.gettext("filetransfer.automatic")+ " (" + ip + ")",ip}; |
---|
| 75 | else ips = new String[0]; |
---|
| 76 | cmbIP = new JComboBox(ips); |
---|
| 77 | cmbIP.setEditable(true); |
---|
| 78 | |
---|
| 79 | //cmbIP.setText(); |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | txtPort.setText(Preferences.getString("filetransfer","port", "7777")); |
---|
| 84 | chkUseLocal = new JCheckBox(I18N.gettext("filetransfer.behind_firewall_or_NAT")); |
---|
| 85 | chkUseLocal.setSelected(!Preferences.getBoolean("filetransfer", "useLocalIP", false)); |
---|
| 86 | add(chkUseLocal,c); |
---|
| 87 | |
---|
| 88 | c.gridwidth = 1; |
---|
| 89 | c.anchor=GridBagConstraints.LINE_START; |
---|
| 90 | add(new JLabel(I18N.gettext("filetransfer.ip")),c); |
---|
| 91 | c.gridwidth = GridBagConstraints.REMAINDER; |
---|
| 92 | add(cmbIP,c); |
---|
| 93 | c.gridwidth = 1; |
---|
| 94 | add(new JLabel(I18N.gettext("filetransfer.port")),c); |
---|
| 95 | c.gridwidth = GridBagConstraints.REMAINDER; |
---|
| 96 | add(txtPort,c); |
---|
| 97 | c.gridwidth = GridBagConstraints.REMAINDER; |
---|
| 98 | chkCloseOnComplete = new JCheckBox(I18N.gettext("filetransfer.close_download_windows_when_download_ready")); |
---|
| 99 | chkCloseOnComplete.setSelected(Preferences.getBoolean("filetransfer", "closeOnComplete", false)); |
---|
| 100 | add(chkCloseOnComplete,c); |
---|
| 101 | c.gridwidth = 2; |
---|
| 102 | c.weighty = 1.0; |
---|
| 103 | c.weightx = 1.0; |
---|
| 104 | add(Box.createVerticalGlue(), c); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | public void savePreferences() |
---|
| 108 | { |
---|
| 109 | Preferences.putBoolean("filetransfer", "useLocalIP", !chkUseLocal.isSelected()); |
---|
| 110 | Preferences.putBoolean("filetransfer", "closeOnComplete", chkCloseOnComplete.isSelected()); |
---|
| 111 | if(cmbIP.getSelectedIndex()!=-1 || (cmbIP.getSelectedItem()!=null && !cmbIP.getSelectedItem().equals(""))) |
---|
| 112 | { |
---|
| 113 | String ip =cmbIP.getSelectedItem().toString(); |
---|
| 114 | if(ip!=null) |
---|
| 115 | { |
---|
| 116 | if(ip.startsWith(I18N.gettext("filetransfer.automatic")))ip = "automatic"; |
---|
| 117 | Preferences.putString("filetransfer","ip",ip); |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | if(!txtPort.getText().equals("")) |
---|
| 121 | { |
---|
| 122 | try |
---|
| 123 | { |
---|
| 124 | int scrollTime = Integer.parseInt(txtPort.getText()); |
---|
| 125 | Preferences.putInteger("titlescroller","scrolltime", scrollTime); |
---|
| 126 | } |
---|
| 127 | catch(NumberFormatException e) {} |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | /* |
---|
| 133 | * Overrides for emacs |
---|
| 134 | * Local variables: |
---|
| 135 | * tab-width: 4 |
---|
| 136 | * End: |
---|
| 137 | */ |
---|