Added an initial and pre alpha implementation of the the configuration panel.
This commit is contained in:
@ -28,7 +28,7 @@ import net.i2p.itoopie.i2pcontrol.JSONRPC2Interface;
|
|||||||
import net.i2p.itoopie.i2pcontrol.methods.GetEcho;
|
import net.i2p.itoopie.i2pcontrol.methods.GetEcho;
|
||||||
import net.i2p.itoopie.i2pcontrol.methods.GetNetworkSetting;
|
import net.i2p.itoopie.i2pcontrol.methods.GetNetworkSetting;
|
||||||
import net.i2p.itoopie.i2pcontrol.methods.GetRateStat;
|
import net.i2p.itoopie.i2pcontrol.methods.GetRateStat;
|
||||||
import net.i2p.itoopie.i2pcontrol.methods.NetworkInfo.NETWORK_INFO;
|
import net.i2p.itoopie.i2pcontrol.methods.NetworkSetting.NETWORK_SETTING;
|
||||||
import net.i2p.itoopie.i2pcontrol.methods.SetNetworkSetting;
|
import net.i2p.itoopie.i2pcontrol.methods.SetNetworkSetting;
|
||||||
import net.i2p.itoopie.security.CertificateHelper;
|
import net.i2p.itoopie.security.CertificateHelper;
|
||||||
|
|
||||||
@ -77,21 +77,12 @@ public class Main {
|
|||||||
|
|
||||||
final Main main = new Main();
|
final Main main = new Main();
|
||||||
main.launchForeverLoop();
|
main.launchForeverLoop();
|
||||||
//We'll be doing GUI work, so let's stay in the event dispatcher thread.
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
main.startUp();
|
main.startUp();
|
||||||
|
} catch (Exception e) {
|
||||||
|
_log.error("Error during TrayManager launch.", e);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
testStuff(); // Delete Me
|
||||||
//log.error("Failed while running desktopgui!", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
@ -129,6 +120,7 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
// Test basic echo method
|
// Test basic echo method
|
||||||
|
System.out.println("GetEcho");
|
||||||
try {
|
try {
|
||||||
String str = GetEcho.execute("Echo this mofo!");
|
String str = GetEcho.execute("Echo this mofo!");
|
||||||
System.out.println("Echo response: " + str);
|
System.out.println("Echo response: " + str);
|
||||||
@ -139,6 +131,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test reading a rateStat
|
// Test reading a rateStat
|
||||||
|
System.out.println("GetRateStat");
|
||||||
try {
|
try {
|
||||||
Double dbl = GetRateStat.execute("bw.sendRate", 3600000L);
|
Double dbl = GetRateStat.execute("bw.sendRate", 3600000L);
|
||||||
System.out.println("rateStat: " + dbl);
|
System.out.println("rateStat: " + dbl);
|
||||||
@ -151,15 +144,16 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test reading all settings
|
// Test reading all settings
|
||||||
|
System.out.println("GetNetworkSetting");
|
||||||
try {
|
try {
|
||||||
HashMap hm = GetNetworkSetting.execute(NETWORK_INFO.values());
|
HashMap hm = GetNetworkSetting.execute(NETWORK_SETTING.values());
|
||||||
System.out.println("getNetworkInfo: All: ");
|
System.out.println("getNetworkInfo: All: ");
|
||||||
Set<Entry> set = hm.entrySet();
|
Set<Entry> set = hm.entrySet();
|
||||||
for (Entry e : set){
|
for (Entry e : set){
|
||||||
System.out.println(e.getKey() +":"+ e.getValue());
|
System.out.println(e.getKey() +":"+ e.getValue());
|
||||||
}
|
}
|
||||||
} catch (InvalidPasswordException e1) {
|
} catch (InvalidPasswordException e1) {
|
||||||
//e1.printStackTrace();
|
System.out.println("Invalid password..");
|
||||||
} catch (JSONRPC2SessionException e) {
|
} catch (JSONRPC2SessionException e) {
|
||||||
System.out.println("Connection failed..");
|
System.out.println("Connection failed..");
|
||||||
}
|
}
|
||||||
@ -167,11 +161,12 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
// Test saving all settings
|
// Test saving all settings
|
||||||
|
System.out.println("SetNetworkSetting - fail");
|
||||||
try {
|
try {
|
||||||
HashMap<NETWORK_INFO, String> hm = new HashMap<NETWORK_INFO,String>();
|
HashMap<NETWORK_SETTING, String> hm = new HashMap<NETWORK_SETTING,String>();
|
||||||
|
|
||||||
List<NETWORK_INFO> list = Arrays.asList(NETWORK_INFO.values());
|
List<NETWORK_SETTING> list = Arrays.asList(NETWORK_SETTING.values());
|
||||||
for (NETWORK_INFO i : list){
|
for (NETWORK_SETTING i : list){
|
||||||
hm.put(i, "66"); // 66 is an arbitrary number that should work for most fields.
|
hm.put(i, "66"); // 66 is an arbitrary number that should work for most fields.
|
||||||
}
|
}
|
||||||
HashMap nextHM= SetNetworkSetting.execute(hm);
|
HashMap nextHM= SetNetworkSetting.execute(hm);
|
||||||
@ -190,20 +185,21 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Manually test saving all(?) settings
|
// Manually test saving all(?) settings
|
||||||
|
System.out.println("SetNetworkSetting");
|
||||||
try {
|
try {
|
||||||
HashMap<NETWORK_INFO, String> hm = new HashMap<NETWORK_INFO,String>();
|
HashMap<NETWORK_SETTING, String> hm = new HashMap<NETWORK_SETTING,String>();
|
||||||
hm.put(NETWORK_INFO.BW_IN, "666");
|
hm.put(NETWORK_SETTING.BW_IN, "666");
|
||||||
hm.put(NETWORK_INFO.BW_OUT, "666");
|
hm.put(NETWORK_SETTING.BW_OUT, "666");
|
||||||
hm.put(NETWORK_INFO.BW_SHARE, "66");
|
hm.put(NETWORK_SETTING.BW_SHARE, "66");
|
||||||
hm.put(NETWORK_INFO.DETECTED_IP, "66.66.66.66");
|
hm.put(NETWORK_SETTING.DETECTED_IP, "66.66.66.66");
|
||||||
hm.put(NETWORK_INFO.LAPTOP_MODE, "true");
|
hm.put(NETWORK_SETTING.LAPTOP_MODE, "true");
|
||||||
hm.put(NETWORK_INFO.TCP_AUTOIP, "always");
|
hm.put(NETWORK_SETTING.TCP_AUTOIP, "always");
|
||||||
hm.put(NETWORK_INFO.TCP_HOSTNAME, "66.66.66.66");
|
hm.put(NETWORK_SETTING.TCP_HOSTNAME, "66.66.66.66");
|
||||||
hm.put(NETWORK_INFO.TCP_PORT, "66");
|
hm.put(NETWORK_SETTING.TCP_PORT, "66");
|
||||||
hm.put(NETWORK_INFO.UDP_AUTO_IP, "local,upnp,ssu");
|
hm.put(NETWORK_SETTING.UDP_AUTO_IP, "local,upnp,ssu");
|
||||||
hm.put(NETWORK_INFO.UDP_HOSTNAME, "66.66.66.66");
|
hm.put(NETWORK_SETTING.UDP_HOSTNAME, "66.66.66.66");
|
||||||
hm.put(NETWORK_INFO.UDP_PORT, "66");
|
hm.put(NETWORK_SETTING.UDP_PORT, "66");
|
||||||
hm.put(NETWORK_INFO.UPNP, "true");
|
hm.put(NETWORK_SETTING.UPNP, "true");
|
||||||
|
|
||||||
HashMap nextHM= SetNetworkSetting.execute(hm);
|
HashMap nextHM= SetNetworkSetting.execute(hm);
|
||||||
System.out.println("setNetworkInfo: Manual: ");
|
System.out.println("setNetworkInfo: Manual: ");
|
||||||
|
@ -1,36 +1,230 @@
|
|||||||
package net.i2p.itoopie.gui;
|
package net.i2p.itoopie.gui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
|
||||||
|
|
||||||
|
import net.i2p.itoopie.gui.StatusHandler.DEFAULT_STATUS;
|
||||||
import net.i2p.itoopie.gui.component.LogoPanel;
|
import net.i2p.itoopie.gui.component.LogoPanel;
|
||||||
import net.i2p.itoopie.i18n.Transl;
|
import net.i2p.itoopie.i18n.Transl;
|
||||||
|
import net.i2p.itoopie.i2pcontrol.InvalidPasswordException;
|
||||||
|
import net.i2p.itoopie.i2pcontrol.methods.GetNetworkSetting;
|
||||||
|
import net.i2p.itoopie.i2pcontrol.methods.NetworkSetting.NETWORK_SETTING;
|
||||||
|
|
||||||
|
// The width of this panel (on ubuntu) will be the width of the main menu -24px.
|
||||||
public class ConfigurationPanel extends LogoPanel {
|
public class ConfigurationPanel extends LogoPanel {
|
||||||
|
// Components for the network panel
|
||||||
|
private JLabel lblNetwork;
|
||||||
|
private JLabel lblTCPPort;
|
||||||
|
private JTextField txtTCPPort;
|
||||||
|
private JLabel lblUDPPort;
|
||||||
|
private JTextField txtUDPPort;
|
||||||
|
private JLabel lblUPNP;
|
||||||
|
private JCheckBox chkbxUPNP;
|
||||||
|
// Components for the bandwidth panel
|
||||||
|
private JLabel lblBW;
|
||||||
|
private JLabel lblDownload;
|
||||||
|
private JTextField txtDownload;
|
||||||
|
private JLabel lblDownloadUnit;
|
||||||
|
private JLabel lblUpload;
|
||||||
|
private JTextField txtUpload;
|
||||||
|
private JLabel lblUploadUnit;
|
||||||
|
private JLabel lblShare;
|
||||||
|
private JTextField txtShare;
|
||||||
|
private JLabel lblShareUnit;
|
||||||
|
|
||||||
private static final long serialVersionUID = 328657255717753899L;
|
private static final long serialVersionUID = 328657255717753899L;
|
||||||
|
|
||||||
|
|
||||||
public ConfigurationPanel(String imageName) {
|
public ConfigurationPanel(String imageName) {
|
||||||
super(imageName);
|
super(imageName);
|
||||||
setLayout(new BorderLayout());
|
setLayout(null);
|
||||||
|
|
||||||
JPanel buttonArea = new JPanel();
|
JPanel networkPanel = new JPanel();
|
||||||
buttonArea.setLayout(new BorderLayout());
|
add(networkPanel);
|
||||||
add(buttonArea, BorderLayout.NORTH);
|
networkPanel.setLayout(null);
|
||||||
|
networkPanel.setOpaque(false);
|
||||||
|
networkPanel.setBounds(0, 110, 262, 115);
|
||||||
|
setupNetworkPanel(networkPanel);
|
||||||
|
|
||||||
JPanel configArea = new JPanel();
|
JPanel bwPanel = new JPanel();
|
||||||
add(configArea, BorderLayout.CENTER);
|
add(bwPanel);
|
||||||
|
bwPanel.setLayout(null);
|
||||||
|
bwPanel.setOpaque(false);
|
||||||
|
bwPanel.setBounds(0, 5, 262, 105);
|
||||||
|
setupBandwidthPanel(bwPanel);
|
||||||
|
|
||||||
JPanel positionedButtonArea = new JPanel();
|
|
||||||
positionedButtonArea.setLayout(new BorderLayout());
|
|
||||||
buttonArea.add(positionedButtonArea, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
JButton btnApply = new JButton();
|
final JButton btnApply = new JButton(Transl._("Apply"));
|
||||||
btnApply.setText(Transl._("Apply"));
|
add(btnApply);
|
||||||
positionedButtonArea.add(btnApply, BorderLayout.EAST);
|
btnApply.setBounds(450, 272, 75, 24);
|
||||||
|
btnApply.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
System.out.println("Clicked");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
System.out.println("Running populate thread.");
|
||||||
|
populate();
|
||||||
|
System.out.println("Populate thread done.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup bandwidth panel
|
||||||
|
*/
|
||||||
|
private void setupBandwidthPanel(JPanel bwPanel){
|
||||||
|
lblBW = new JLabel();
|
||||||
|
bwPanel.add(lblBW);
|
||||||
|
lblBW.setBounds(10, 10, 120, 15);
|
||||||
|
lblBW.setText(Transl._("Bandwidth:"));
|
||||||
|
|
||||||
|
lblDownload = new JLabel();
|
||||||
|
bwPanel.add(lblDownload);
|
||||||
|
lblDownload.setBounds(40, 35, 100, 15);
|
||||||
|
lblDownload.setText(Transl._("Download:"));
|
||||||
|
|
||||||
|
txtDownload = new JTextField();
|
||||||
|
bwPanel.add(txtDownload);
|
||||||
|
txtDownload.setBounds(130, 35, 55, 20);
|
||||||
|
|
||||||
|
lblDownloadUnit = new JLabel();
|
||||||
|
bwPanel.add(lblDownloadUnit);
|
||||||
|
lblDownloadUnit.setBounds(190, 37, 35, 15);
|
||||||
|
lblDownloadUnit.setText(Transl._("KB/s"));
|
||||||
|
|
||||||
|
lblUpload = new JLabel();
|
||||||
|
bwPanel.add(lblUpload);
|
||||||
|
lblUpload.setBounds(40, 60, 100, 15);
|
||||||
|
lblUpload.setText(Transl._("Upload:"));
|
||||||
|
|
||||||
|
txtUpload = new JTextField();
|
||||||
|
bwPanel.add(txtUpload);
|
||||||
|
txtUpload.setBounds(130, 60, 55, 20);
|
||||||
|
|
||||||
|
lblUploadUnit = new JLabel();
|
||||||
|
bwPanel.add(lblUploadUnit);
|
||||||
|
lblUploadUnit.setBounds(190, 62, 35, 15);
|
||||||
|
lblUploadUnit.setText(Transl._("KB/s"));
|
||||||
|
|
||||||
|
lblShare = new JLabel();
|
||||||
|
bwPanel.add(lblShare);
|
||||||
|
lblShare.setBounds(40, 85, 100, 15);
|
||||||
|
lblShare.setText(Transl._("Share:"));
|
||||||
|
|
||||||
|
txtShare = new JTextField();
|
||||||
|
bwPanel.add(txtShare);
|
||||||
|
txtShare.setBounds(130, 85, 55, 20);
|
||||||
|
|
||||||
|
lblShareUnit = new JLabel();
|
||||||
|
bwPanel.add(lblShareUnit);
|
||||||
|
lblShareUnit.setBounds(190, 87, 35, 15);
|
||||||
|
lblShareUnit.setText(Transl._("%"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup network panel
|
||||||
|
*/
|
||||||
|
private void setupNetworkPanel(JPanel networkPanel){
|
||||||
|
lblNetwork = new JLabel();
|
||||||
|
networkPanel.add(lblNetwork);
|
||||||
|
lblNetwork.setBounds(10, 10, 75, 15);
|
||||||
|
lblNetwork.setText(Transl._("Network:"));
|
||||||
|
|
||||||
|
lblTCPPort = new JLabel();
|
||||||
|
networkPanel.add(lblTCPPort);
|
||||||
|
lblTCPPort.setBounds(40, 35, 75, 15);
|
||||||
|
lblTCPPort.setText(Transl._("TCP port:"));
|
||||||
|
|
||||||
|
txtTCPPort = new JTextField();
|
||||||
|
networkPanel.add(txtTCPPort);
|
||||||
|
txtTCPPort.setBounds(130, 35, 55, 20);
|
||||||
|
txtTCPPort.setColumns(5);
|
||||||
|
|
||||||
|
lblUDPPort = new JLabel();
|
||||||
|
networkPanel.add(lblUDPPort);
|
||||||
|
lblUDPPort.setBounds(40, 60, 75, 15);
|
||||||
|
lblUDPPort.setText(Transl._("UDP port:"));
|
||||||
|
|
||||||
|
txtUDPPort = new JTextField();
|
||||||
|
networkPanel.add(txtUDPPort);
|
||||||
|
txtUDPPort.setBounds(130, 60, 55, 20);
|
||||||
|
|
||||||
|
|
||||||
|
lblUPNP = new JLabel();
|
||||||
|
networkPanel.add(lblUPNP);
|
||||||
|
lblUPNP.setBounds(40, 85, 75, 15);
|
||||||
|
lblUPNP.setText(Transl._("UPNP:"));
|
||||||
|
|
||||||
|
chkbxUPNP = new JCheckBox(Transl._("Enable UPNP"));
|
||||||
|
networkPanel.add(chkbxUPNP);
|
||||||
|
chkbxUPNP.setBounds(127, 85, 120, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populate(){
|
||||||
|
try {
|
||||||
|
HashMap hm = GetNetworkSetting.execute(NETWORK_SETTING.TCP_PORT, NETWORK_SETTING.UDP_PORT,
|
||||||
|
NETWORK_SETTING.UPNP, NETWORK_SETTING.BW_IN, NETWORK_SETTING.BW_OUT);
|
||||||
|
|
||||||
|
System.out.println("TCP_PORT: " + (String) hm.get(NETWORK_SETTING.TCP_PORT.toString()));
|
||||||
|
System.out.println("UDP_PORT: " + (String) hm.get(NETWORK_SETTING.UDP_PORT.toString()));
|
||||||
|
|
||||||
|
txtTCPPort.setText((String) hm.get(NETWORK_SETTING.TCP_PORT.toString()));
|
||||||
|
txtUDPPort.setText((String) hm.get(NETWORK_SETTING.UDP_PORT.toString()));
|
||||||
|
boolean upnpValue = Boolean.parseBoolean((String) hm.get(NETWORK_SETTING.UPNP));
|
||||||
|
chkbxUPNP.setSelected(upnpValue);
|
||||||
|
txtDownload.setText((String) hm.get(NETWORK_SETTING.BW_IN));
|
||||||
|
txtUpload.setText((String) hm.get(NETWORK_SETTING.BW_OUT));
|
||||||
|
txtShare.setText((String) hm.get(NETWORK_SETTING.BW_SHARE));
|
||||||
|
txtShare.setText("TEST");
|
||||||
|
} catch (InvalidPasswordException e) {
|
||||||
|
StatusHandler.setDefaultStatus(DEFAULT_STATUS.INVALID_PASSWORD);
|
||||||
|
} catch (JSONRPC2SessionException e) {
|
||||||
|
StatusHandler.setDefaultStatus(DEFAULT_STATUS.NOT_CONNECTED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch the application.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
JFrame frame = new JFrame();
|
||||||
|
frame.setBounds(0, 0, Main.FRAME_WIDTH, Main.FRAME_HEIGHT);
|
||||||
|
ConfigurationPanel window = new ConfigurationPanel("itoopie-opaque12");
|
||||||
|
frame.add(window);
|
||||||
|
frame.setVisible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -38,6 +38,8 @@ public class Main {
|
|||||||
private final static Color LIGHT = new Color(215,215,215);
|
private final static Color LIGHT = new Color(215,215,215);
|
||||||
private final static Color MEDIUM = new Color (175,175,175);
|
private final static Color MEDIUM = new Color (175,175,175);
|
||||||
private final static Color DARK = new Color(145,145,145);
|
private final static Color DARK = new Color(145,145,145);
|
||||||
|
public final static int FRAME_WIDTH = 550;
|
||||||
|
public final static int FRAME_HEIGHT = 400;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
@ -70,7 +72,7 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
frame = new RegisteredFrame();
|
frame = new RegisteredFrame();
|
||||||
frame.setBounds(100, 100, 550, 400);
|
frame.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
WindowHandler.registerMain(frame);
|
WindowHandler.registerMain(frame);
|
||||||
|
|
||||||
@ -98,39 +100,7 @@ public class Main {
|
|||||||
|
|
||||||
JPanel configPanel = new ConfigurationPanel("itoopie-opaque12");
|
JPanel configPanel = new ConfigurationPanel("itoopie-opaque12");
|
||||||
tabbedPane.addTab("Configuration", null, configPanel, null);
|
tabbedPane.addTab("Configuration", null, configPanel, null);
|
||||||
configPanel.setLayout(new BorderLayout(0, 0));
|
|
||||||
|
|
||||||
JPanel configArea = new JPanel();
|
|
||||||
configArea.setOpaque(false);
|
|
||||||
configPanel.add(configArea, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
|
|
||||||
JPanel buttonArea = new JPanel();
|
|
||||||
buttonArea.setOpaque(false);
|
|
||||||
buttonArea.setLayout(new BorderLayout(0, 0));
|
|
||||||
configPanel.add(buttonArea, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
JPanel buttonAreaEast = new JPanel();
|
|
||||||
buttonAreaEast.setLayout(new BorderLayout(0, 0));
|
|
||||||
buttonAreaEast.setOpaque(false);
|
|
||||||
buttonArea.add(buttonAreaEast, BorderLayout.EAST);
|
|
||||||
|
|
||||||
JPanel applyBtnWrapper = new JPanel();
|
|
||||||
applyBtnWrapper.setOpaque(false);
|
|
||||||
FlowLayout flowApplyBtnWrapper = new FlowLayout();
|
|
||||||
flowApplyBtnWrapper.setVgap(0);
|
|
||||||
flowApplyBtnWrapper.setHgap(3);
|
|
||||||
applyBtnWrapper.setLayout(flowApplyBtnWrapper);
|
|
||||||
buttonAreaEast.add(applyBtnWrapper);
|
|
||||||
|
|
||||||
|
|
||||||
FlowLayout flowLayout = (FlowLayout) applyBtnWrapper.getLayout();
|
|
||||||
flowLayout.setHgap(10);
|
|
||||||
flowLayout.setVgap(3);
|
|
||||||
|
|
||||||
JButton btnApply = new JButton("Apply");
|
|
||||||
btnApply.setOpaque(true);
|
|
||||||
applyBtnWrapper.add(btnApply, BorderLayout.EAST);
|
|
||||||
|
|
||||||
JPanel logPanel = new LogoPanel("itoopie-opaque12");
|
JPanel logPanel = new LogoPanel("itoopie-opaque12");
|
||||||
tabbedPane.addTab("Logs", null, logPanel, null);
|
tabbedPane.addTab("Logs", null, logPanel, null);
|
||||||
@ -146,9 +116,9 @@ public class Main {
|
|||||||
statusPanel.add(statusLbl, BorderLayout.CENTER);
|
statusPanel.add(statusLbl, BorderLayout.CENTER);
|
||||||
|
|
||||||
JPanel buttonWrapper = new JPanel();
|
JPanel buttonWrapper = new JPanel();
|
||||||
flowLayout = (FlowLayout) buttonWrapper.getLayout();
|
FlowLayout flowLayout = (FlowLayout) buttonWrapper.getLayout();
|
||||||
flowLayout.setHgap(10);
|
flowLayout.setHgap(10);
|
||||||
flowLayout.setVgap(3);
|
flowLayout.setVgap(0);
|
||||||
statusPanel.add(buttonWrapper, BorderLayout.EAST);
|
statusPanel.add(buttonWrapper, BorderLayout.EAST);
|
||||||
|
|
||||||
JButton settingsBtn = new JButton("Settings");
|
JButton settingsBtn = new JButton("Settings");
|
||||||
|
@ -6,6 +6,7 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
@ -6,6 +6,13 @@ public class StatusHandler {
|
|||||||
private static final JLabel statusLbl;
|
private static final JLabel statusLbl;
|
||||||
private static final String DEFAULT_STATUS = "Status";
|
private static final String DEFAULT_STATUS = "Status";
|
||||||
|
|
||||||
|
private interface StatusMessage{ public String getStatusMessage(); };
|
||||||
|
public static enum DEFAULT_STATUS implements StatusMessage {
|
||||||
|
CONNECTED { public String getStatusMessage(){ return "Connected to I2P router."; }},
|
||||||
|
NOT_CONNECTED { public String getStatusMessage(){ return "Unable to connect to I2P router."; }},
|
||||||
|
INVALID_PASSWORD { public String getStatusMessage(){ return "I2P router rejected password."; }}
|
||||||
|
}
|
||||||
|
|
||||||
static{
|
static{
|
||||||
statusLbl = new JLabel();
|
statusLbl = new JLabel();
|
||||||
statusLbl.setText(DEFAULT_STATUS);
|
statusLbl.setText(DEFAULT_STATUS);
|
||||||
@ -23,4 +30,8 @@ public class StatusHandler {
|
|||||||
return statusLbl;
|
return statusLbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setDefaultStatus(DEFAULT_STATUS status){
|
||||||
|
statusLbl.setText(status.getStatusMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class JSONRPC2Interface {
|
|||||||
public static void setupSession() {
|
public static void setupSession() {
|
||||||
URL srvURL = null;
|
URL srvURL = null;
|
||||||
String srvHost = _conf.getConf("server.hostname", "localhost");
|
String srvHost = _conf.getConf("server.hostname", "localhost");
|
||||||
int srvPort = _conf.getConf("server.port", 7656);
|
int srvPort = _conf.getConf("server.port", 7650);
|
||||||
String srvTarget = _conf.getConf("server.target", "jsonrpc");
|
String srvTarget = _conf.getConf("server.target", "jsonrpc");
|
||||||
try {
|
try {
|
||||||
srvURL = new URL("https://" + srvHost + ":" + srvPort + "/"
|
srvURL = new URL("https://" + srvHost + ":" + srvPort + "/"
|
||||||
|
@ -14,7 +14,7 @@ import net.i2p.itoopie.i2pcontrol.InvalidParametersException;
|
|||||||
import net.i2p.itoopie.i2pcontrol.InvalidPasswordException;
|
import net.i2p.itoopie.i2pcontrol.InvalidPasswordException;
|
||||||
import net.i2p.itoopie.i2pcontrol.JSONRPC2Interface;
|
import net.i2p.itoopie.i2pcontrol.JSONRPC2Interface;
|
||||||
import net.i2p.itoopie.i2pcontrol.UnrecoverableFailedRequestException;
|
import net.i2p.itoopie.i2pcontrol.UnrecoverableFailedRequestException;
|
||||||
import net.i2p.itoopie.i2pcontrol.methods.NetworkInfo.NETWORK_INFO;
|
import net.i2p.itoopie.i2pcontrol.methods.NetworkSetting.NETWORK_SETTING;
|
||||||
|
|
||||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
|
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
|
||||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
|
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
|
||||||
@ -23,15 +23,15 @@ import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
|
|||||||
public class GetNetworkSetting {
|
public class GetNetworkSetting {
|
||||||
private final static Log _log = LogFactory.getLog(GetNetworkSetting.class);
|
private final static Log _log = LogFactory.getLog(GetNetworkSetting.class);
|
||||||
|
|
||||||
public static HashMap execute(NETWORK_INFO ... options)
|
public static HashMap execute(NETWORK_SETTING ... options)
|
||||||
throws InvalidPasswordException, JSONRPC2SessionException{
|
throws InvalidPasswordException, JSONRPC2SessionException{
|
||||||
|
|
||||||
JSONRPC2Request req = new JSONRPC2Request("NetworkSetting", JSONRPC2Interface.incrNonce());
|
JSONRPC2Request req = new JSONRPC2Request("NetworkSetting", JSONRPC2Interface.incrNonce());
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Map outParams = new HashMap();
|
Map outParams = new HashMap();
|
||||||
List<NETWORK_INFO> list = Arrays.asList(options);
|
List<NETWORK_SETTING> list = Arrays.asList(options);
|
||||||
|
|
||||||
for (NETWORK_INFO i : list){
|
for (NETWORK_SETTING i : list){
|
||||||
outParams.put(i.toString(), null);
|
outParams.put(i.toString(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class GetNetworkSetting {
|
|||||||
Set<Entry> set = map.entrySet();
|
Set<Entry> set = map.entrySet();
|
||||||
HashMap output = new HashMap();
|
HashMap output = new HashMap();
|
||||||
for (Entry e: set){
|
for (Entry e: set){
|
||||||
output.put(NetworkInfo.enumMap.get(e.getKey()), e.getValue());
|
output.put(NetworkSetting.enumMap.get(e.getKey()), e.getValue());
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,15 +19,15 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class NetworkInfo{
|
public class NetworkSetting{
|
||||||
public final static HashMap<String,NETWORK_INFO> enumMap;
|
public final static HashMap<String,NETWORK_SETTING> enumMap;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the most common network related settings and their API key.
|
* Describes the most common network related settings and their API key.
|
||||||
* @author hottuna
|
* @author hottuna
|
||||||
*/
|
*/
|
||||||
public enum NETWORK_INFO implements RemoteSetable{
|
public enum NETWORK_SETTING implements RemoteSetable{
|
||||||
DETECTED_IP { public boolean isSetable(){ return false;} public String toString() { return "i2p.router.net.ssu.detectedip"; }},
|
DETECTED_IP { public boolean isSetable(){ return false;} public String toString() { return "i2p.router.net.ssu.detectedip"; }},
|
||||||
TCP_PORT { public boolean isSetable(){ return true;} public String toString() { return "i2p.router.net.ntcp.port"; }},
|
TCP_PORT { public boolean isSetable(){ return true;} public String toString() { return "i2p.router.net.ntcp.port"; }},
|
||||||
TCP_HOSTNAME { public boolean isSetable(){ return true;} public String toString() { return "i2p.router.net.ntcp.hostname"; }},
|
TCP_HOSTNAME { public boolean isSetable(){ return true;} public String toString() { return "i2p.router.net.ntcp.hostname"; }},
|
||||||
@ -43,8 +43,8 @@ public class NetworkInfo{
|
|||||||
};
|
};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
enumMap = new HashMap<String,NETWORK_INFO>();
|
enumMap = new HashMap<String,NETWORK_SETTING>();
|
||||||
for (NETWORK_INFO n : NETWORK_INFO.values()){
|
for (NETWORK_SETTING n : NETWORK_SETTING.values()){
|
||||||
enumMap.put(n.toString(), n);
|
enumMap.put(n.toString(), n);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ import net.i2p.itoopie.i2pcontrol.InvalidParametersException;
|
|||||||
import net.i2p.itoopie.i2pcontrol.InvalidPasswordException;
|
import net.i2p.itoopie.i2pcontrol.InvalidPasswordException;
|
||||||
import net.i2p.itoopie.i2pcontrol.JSONRPC2Interface;
|
import net.i2p.itoopie.i2pcontrol.JSONRPC2Interface;
|
||||||
import net.i2p.itoopie.i2pcontrol.UnrecoverableFailedRequestException;
|
import net.i2p.itoopie.i2pcontrol.UnrecoverableFailedRequestException;
|
||||||
import net.i2p.itoopie.i2pcontrol.methods.NetworkInfo.NETWORK_INFO;
|
import net.i2p.itoopie.i2pcontrol.methods.NetworkSetting.NETWORK_SETTING;
|
||||||
|
|
||||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
|
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
|
||||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
|
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
|
||||||
@ -22,15 +22,15 @@ public class SetNetworkSetting {
|
|||||||
private final static Log _log = LogFactory.getLog(SetNetworkSetting.class);
|
private final static Log _log = LogFactory.getLog(SetNetworkSetting.class);
|
||||||
|
|
||||||
|
|
||||||
public static HashMap<NETWORK_INFO, Boolean> execute(Map<NETWORK_INFO,String> settings)
|
public static HashMap<NETWORK_SETTING, Boolean> execute(Map<NETWORK_SETTING,String> settings)
|
||||||
throws InvalidPasswordException, JSONRPC2SessionException, InvalidParametersException{
|
throws InvalidPasswordException, JSONRPC2SessionException, InvalidParametersException{
|
||||||
|
|
||||||
JSONRPC2Request req = new JSONRPC2Request("NetworkSetting", JSONRPC2Interface.incrNonce());
|
JSONRPC2Request req = new JSONRPC2Request("NetworkSetting", JSONRPC2Interface.incrNonce());
|
||||||
|
|
||||||
Map outParams = new HashMap();
|
Map outParams = new HashMap();
|
||||||
|
|
||||||
Set<Entry<NETWORK_INFO,String>> set = settings.entrySet();
|
Set<Entry<NETWORK_SETTING,String>> set = settings.entrySet();
|
||||||
for (Entry<NETWORK_INFO,String> e : set){
|
for (Entry<NETWORK_SETTING,String> e : set){
|
||||||
if(e.getKey().isSetable()){
|
if(e.getKey().isSetable()){
|
||||||
outParams.put(e.getKey().toString(), e.getValue());
|
outParams.put(e.getKey().toString(), e.getValue());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user