From f10bfda1153e65245d0dd6af1086f2fa1dd6613f Mon Sep 17 00:00:00 2001 From: mathiasdm Date: Wed, 20 May 2009 19:58:55 +0000 Subject: [PATCH 1/6] * General configuration enabled by default * General configuration speed tab works completely --- .../desktopgui/gui/GeneralConfiguration.form | 44 ++-- .../desktopgui/gui/GeneralConfiguration.java | 193 +++++++++++++----- .../src/net/i2p/desktopgui/gui/Tray.java | 2 +- .../resources/GeneralConfiguration.properties | 10 +- .../router/configuration/SpeedHelper.java | 4 + history.txt | 4 + 6 files changed, 183 insertions(+), 74 deletions(-) diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form index 7c0fc8edcd..8e0acbb14a 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form @@ -81,12 +81,18 @@ + + + + + + @@ -141,7 +147,7 @@ - + @@ -155,7 +161,7 @@ - + @@ -201,10 +207,10 @@ - + - - + + @@ -212,10 +218,10 @@ - + - - + + @@ -229,7 +235,7 @@ - + @@ -243,7 +249,7 @@ - + @@ -251,10 +257,10 @@ - + - - + + @@ -262,10 +268,10 @@ - + - - + + @@ -273,10 +279,10 @@ - + - - + + diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java index 910ca21fb5..b0dbccabca 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java @@ -7,6 +7,9 @@ package net.i2p.desktopgui.gui; import net.i2p.desktopgui.router.configuration.SpeedHelper; +import javax.swing.JComboBox; +import javax.swing.JTextField; +import net.i2p.desktopgui.router.configuration.SpeedHandler; /** * @@ -23,7 +26,23 @@ public class GeneralConfiguration extends javax.swing.JFrame { } private void extraInitComponents() { - downloadspeed.setText(SpeedHelper.getInboundBandwidth()); + initSpeedTab(); + } + + private void initSpeedTab() { + try { + String inbound = SpeedHelper.getInboundBandwidth(); + String outbound = SpeedHelper.getOutboundBandwidth(); + + initSpeeds(inbound, outbound); + initUsage("" + Integer.parseInt(inbound)/8, "" + Integer.parseInt(outbound)/8); + } + catch(Exception e) { + e.printStackTrace(); + System.out.println("Exception noticed, probably running desktopgui in a debugger instead of along with I2P!?"); + initSpeeds("100", "100"); + initUsage("12", "12"); + } } /** This method is called from within the constructor to @@ -47,13 +66,13 @@ public class GeneralConfiguration extends javax.swing.JFrame { downloadspeed = new javax.swing.JTextField(); uploadkbps = new javax.swing.JComboBox(); downloadkbps = new javax.swing.JComboBox(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); + uploadUsageLabel = new javax.swing.JLabel(); + downloadUsageLabel = new javax.swing.JLabel(); uploadgb = new javax.swing.JTextField(); downloadgb = new javax.swing.JTextField(); - jLabel5 = new javax.swing.JLabel(); - jLabel6 = new javax.swing.JLabel(); - jLabel7 = new javax.swing.JLabel(); + gbUploadLabel = new javax.swing.JLabel(); + gbDownloadLabel = new javax.swing.JLabel(); + uploadDownloadExplanation = new javax.swing.JLabel(); updatesPanel = new javax.swing.JPanel(); updateMethod = new javax.swing.JLabel(); updateInform = new javax.swing.JRadioButton(); @@ -80,9 +99,19 @@ public class GeneralConfiguration extends javax.swing.JFrame { cancel.setText(resourceMap.getString("cancel.text")); // NOI18N cancel.setName("cancel"); // NOI18N + cancel.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + cancelMouseClicked(evt); + } + }); ok.setText(resourceMap.getString("ok.text")); // NOI18N ok.setName("ok"); // NOI18N + ok.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + okMouseClicked(evt); + } + }); javax.swing.GroupLayout applyPanelLayout = new javax.swing.GroupLayout(applyPanel); applyPanel.setLayout(applyPanelLayout); @@ -122,8 +151,8 @@ public class GeneralConfiguration extends javax.swing.JFrame { uploadspeed.setText(resourceMap.getString("uploadspeed.text")); // NOI18N uploadspeed.setName("uploadspeed"); // NOI18N uploadspeed.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - speedKeyTyped(evt); + public void keyReleased(java.awt.event.KeyEvent evt) { + speedKeyReleased(evt); } }); speedPanel.add(uploadspeed); @@ -132,8 +161,8 @@ public class GeneralConfiguration extends javax.swing.JFrame { downloadspeed.setText(resourceMap.getString("downloadspeed.text")); // NOI18N downloadspeed.setName("downloadspeed"); // NOI18N downloadspeed.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - speedKeyTyped(evt); + public void keyReleased(java.awt.event.KeyEvent evt) { + speedKeyReleased(evt); } }); speedPanel.add(downloadspeed); @@ -159,21 +188,21 @@ public class GeneralConfiguration extends javax.swing.JFrame { speedPanel.add(downloadkbps); downloadkbps.setBounds(240, 60, 68, 27); - jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N - jLabel3.setName("jLabel3"); // NOI18N - speedPanel.add(jLabel3); - jLabel3.setBounds(330, 20, 97, 30); + uploadUsageLabel.setText(resourceMap.getString("uploadUsageLabel.text")); // NOI18N + uploadUsageLabel.setName("uploadUsageLabel"); // NOI18N + speedPanel.add(uploadUsageLabel); + uploadUsageLabel.setBounds(330, 20, 97, 30); - jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N - jLabel4.setName("jLabel4"); // NOI18N - speedPanel.add(jLabel4); - jLabel4.setBounds(330, 60, 97, 30); + downloadUsageLabel.setText(resourceMap.getString("downloadUsageLabel.text")); // NOI18N + downloadUsageLabel.setName("downloadUsageLabel"); // NOI18N + speedPanel.add(downloadUsageLabel); + downloadUsageLabel.setBounds(330, 60, 97, 30); uploadgb.setText(resourceMap.getString("uploadgb.text")); // NOI18N uploadgb.setName("uploadgb"); // NOI18N uploadgb.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - uploadgbKeyTyped(evt); + public void keyReleased(java.awt.event.KeyEvent evt) { + monthKeyReleased(evt); } }); speedPanel.add(uploadgb); @@ -182,27 +211,27 @@ public class GeneralConfiguration extends javax.swing.JFrame { downloadgb.setText(resourceMap.getString("downloadgb.text")); // NOI18N downloadgb.setName("downloadgb"); // NOI18N downloadgb.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - downloadgbKeyTyped(evt); + public void keyReleased(java.awt.event.KeyEvent evt) { + monthKeyReleased(evt); } }); speedPanel.add(downloadgb); downloadgb.setBounds(440, 60, 60, 27); - jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N - jLabel5.setName("jLabel5"); // NOI18N - speedPanel.add(jLabel5); - jLabel5.setBounds(510, 20, 19, 30); + gbUploadLabel.setText(resourceMap.getString("gbUploadLabel.text")); // NOI18N + gbUploadLabel.setName("gbUploadLabel"); // NOI18N + speedPanel.add(gbUploadLabel); + gbUploadLabel.setBounds(510, 20, 19, 30); - jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N - jLabel6.setName("jLabel6"); // NOI18N - speedPanel.add(jLabel6); - jLabel6.setBounds(510, 60, 19, 30); + gbDownloadLabel.setText(resourceMap.getString("gbDownloadLabel.text")); // NOI18N + gbDownloadLabel.setName("gbDownloadLabel"); // NOI18N + speedPanel.add(gbDownloadLabel); + gbDownloadLabel.setBounds(510, 60, 19, 30); - jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N - jLabel7.setName("jLabel7"); // NOI18N - speedPanel.add(jLabel7); - jLabel7.setBounds(20, 100, 520, 70); + uploadDownloadExplanation.setText(resourceMap.getString("uploadDownloadExplanation.text")); // NOI18N + uploadDownloadExplanation.setName("uploadDownloadExplanation"); // NOI18N + speedPanel.add(uploadDownloadExplanation); + uploadDownloadExplanation.setBounds(20, 100, 520, 70); settingsPanel.addTab(resourceMap.getString("speedPanel.TabConstraints.tabTitle"), speedPanel); // NOI18N @@ -377,7 +406,7 @@ public class GeneralConfiguration extends javax.swing.JFrame { pack(); }// //GEN-END:initComponents -private void speedKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speedKeyTyped + private void speedKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speedKeyReleased try { String upload = ""; if(uploadkbps.getSelectedIndex() == KILOBIT) @@ -395,29 +424,95 @@ private void speedKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speed e.printStackTrace(); return; } -}//GEN-LAST:event_speedKeyTyped +}//GEN-LAST:event_speedKeyReleased private void uploadkbpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadkbpsActionPerformed - // TODO add your handling code here: + kbpsSwitchPerformed(uploadkbps, uploadspeed); }//GEN-LAST:event_uploadkbpsActionPerformed private void downloadkbpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadkbpsActionPerformed - // TODO add your handling code here: + kbpsSwitchPerformed(downloadkbps, downloadspeed); }//GEN-LAST:event_downloadkbpsActionPerformed -private void uploadgbKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_uploadgbKeyTyped - // TODO add your handling code here: -}//GEN-LAST:event_uploadgbKeyTyped +private void monthKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthKeyReleased + try { + int uploadMonthValue = Integer.parseInt(uploadgb.getText()); + int downloadMonthValue = Integer.parseInt(downloadgb.getText()); -private void downloadgbKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_downloadgbKeyTyped - // TODO add your handling code here: -}//GEN-LAST:event_downloadgbKeyTyped + String upload = ""; + String burstUpload = ""; + String download = ""; + String burstDownload = ""; + + if(uploadkbps.getSelectedIndex() == KILOBIT) + upload = "" + SpeedHelper.calculateSpeed(uploadMonthValue)*8; //kbit + else + upload = "" + SpeedHelper.calculateSpeed(uploadMonthValue); //kbyte + + if(downloadkbps.getSelectedIndex() == KILOBIT) + download = "" + SpeedHelper.calculateSpeed(downloadMonthValue)*8; //kbit + else + download = "" + SpeedHelper.calculateSpeed(downloadMonthValue); //kbyte + + initSpeeds(upload, download); + } + catch(NumberFormatException e) { + e.printStackTrace(); + return; + } +}//GEN-LAST:event_monthKeyReleased + +private void cancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cancelMouseClicked + this.dispose(); +}//GEN-LAST:event_cancelMouseClicked + +private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_okMouseClicked + saveSpeeds(); + this.dispose(); +}//GEN-LAST:event_okMouseClicked protected void initUsage(String upload, String download) { uploadgb.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(upload))); downloadgb.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(download))); } + protected void initSpeeds(String upload, String download) { + uploadspeed.setText(upload); + downloadspeed.setText(download); + } + + private void kbpsSwitchPerformed(JComboBox kbps, JTextField speed) { + int index = kbps.getSelectedIndex(); + int previous = Integer.parseInt(speed.getText()); + if(index == KILOBIT) { + speed.setText("" + previous*8); + } + else { + speed.setText("" + previous/8); + } + } + + protected void saveSpeeds() { + int maxDownload = Integer.parseInt(downloadspeed.getText()); + int maxUpload = Integer.parseInt(uploadspeed.getText()); + if(uploadkbps.getSelectedIndex() == KILOBIT) { + SpeedHandler.setOutboundBandwidth(maxUpload/8); + SpeedHandler.setOutboundBurstBandwidth(maxUpload/8); + } + else { + SpeedHandler.setOutboundBandwidth(maxUpload); + SpeedHandler.setOutboundBurstBandwidth(maxUpload); + } + if(downloadkbps.getSelectedIndex() == KILOBIT) { + SpeedHandler.setInboundBandwidth(maxDownload/8); + SpeedHandler.setInboundBurstBandwidth(maxDownload/8); + } + else { + SpeedHandler.setInboundBandwidth(maxDownload); + SpeedHandler.setInboundBurstBandwidth(maxDownload); + } + } + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel advancedPanel; private javax.swing.JToggleButton advancedUpdateConfig; @@ -428,14 +523,12 @@ private void downloadgbKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ private javax.swing.JScrollPane clientFrame; private javax.swing.JLabel clientTunnelLabel; private javax.swing.JLabel downloadSpeedLabel; + private javax.swing.JLabel downloadUsageLabel; private javax.swing.JTextField downloadgb; private javax.swing.JComboBox downloadkbps; private javax.swing.JTextField downloadspeed; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; + private javax.swing.JLabel gbDownloadLabel; + private javax.swing.JLabel gbUploadLabel; private javax.swing.JPanel networkPanel; private javax.swing.JToggleButton ok; private javax.swing.JScrollPane serverFrame; @@ -450,7 +543,9 @@ private void downloadgbKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ private javax.swing.JLabel updateMethod; private javax.swing.JToggleButton updateNow; private javax.swing.JPanel updatesPanel; + private javax.swing.JLabel uploadDownloadExplanation; private javax.swing.JLabel uploadSpeedLabel; + private javax.swing.JLabel uploadUsageLabel; private javax.swing.JTextField uploadgb; private javax.swing.JComboBox uploadkbps; private javax.swing.JTextField uploadspeed; diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java b/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java index b20a850f6d..42f720c27c 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java @@ -170,7 +170,7 @@ public class Tray { popup.addSeparator(); config.add(speedConfig); - //config.add(generalConfig); + config.add(generalConfig); config.add(advancedConfig); popup.add(config); diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/resources/GeneralConfiguration.properties b/apps/desktopgui/src/net/i2p/desktopgui/gui/resources/GeneralConfiguration.properties index e1c16a08cb..c6af27a514 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/resources/GeneralConfiguration.properties +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/resources/GeneralConfiguration.properties @@ -1,10 +1,5 @@ cancel.text=Cancel ok.text=OK -jLabel3.text=Monthly usage: -jLabel4.text=Monthly usage: -jLabel5.text=GB -jLabel6.text=GB -jLabel7.text=Explanation ... Form.title=General Configuration speedPanel.TabConstraints.tabTitle=Speed updatesPanel.TabConstraints.tabTitle=Updates @@ -27,3 +22,8 @@ advancedUpdateConfig.text=Advanced update configuration clientTunnelLabel.text=Client tunnels: serverTunnelLabel.text=Server tunnels: tunnelsExplanation.text=Tunnel explanation +uploadUsageLabel.text=Monthly usage: +downloadUsageLabel.text=Monthly usage: +gbUploadLabel.text=GB +gbDownloadLabel.text=GB +uploadDownloadExplanation.text=Explanation ... diff --git a/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/SpeedHelper.java b/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/SpeedHelper.java index 5d2074de2c..51b8b5a6f6 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/SpeedHelper.java +++ b/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/SpeedHelper.java @@ -36,4 +36,8 @@ public class SpeedHelper { public static String getInboundBandwidth() { return RouterHelper.getContext().router().getConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH); } + + public static String getOutboundBandwidth() { + return RouterHelper.getContext().router().getConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH); + } } diff --git a/history.txt b/history.txt index 895f2bfc30..350d25b36c 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,7 @@ +2009-05-20 Mathiasdm + * General configuration enabled by default + * General configuration speed tab works completely + 2009-05-17 zzz * Merge i2p.i2p.zzz.upnp branch * Major changes: From d7122cdad75b363b3e05d0dd0d276002d49074ae Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 21 May 2009 13:43:23 +0000 Subject: [PATCH 2/6] -2 --- history.txt | 31 +++++++++++++++++++ .../src/net/i2p/router/RouterVersion.java | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 350d25b36c..6a3e65017c 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,34 @@ +2009-05-21 zzz + * DataStore: + - Adjust interface to have persistent and non-persistent methods, + to prepare for partial storage in RAM + * ExpireRoutersJob: + - Rewrite, not enabled yet + * I2Punnel: + - Increase eepsite default to 3+0 for new installs + * PersistentDataStore: + - Cleanup, simplify, and concurrentify + - Tweak stats + - Remove write limit + - Flush to disk on shutdown + - Don't write out what we just read in + * Router and console: + - Bundle geoIP files and flags in new installs, + spiff up tunnels.jsp and profiles.jsp. + Existing installs can get files with 'ant updaterWIthGeoIP' + or in the console docs bundle 'ant consoleDocs' + - Use flags for shitlist and peers.jsp too + - Tweak tunnels.jsp to show class letters + - Hide in-progress details on tunnels.jsp + - Add a little color to confignav + - Remove 'no skew' message + - More message tweaks if no wrapper + * TunnelManager: + - Remove now-unused isInUse() + * UPnP: + - Fix up port binding, add some logging on bind fails + - Force IPv4 only for binds + 2009-05-20 Mathiasdm * General configuration enabled by default * General configuration speed tab works completely diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index b74a3a021a..bd644cee53 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 1; + public final static long BUILD = 2; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; From b4336fdec7b0bc6367f70de96dcce9999aaebbca Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 21 May 2009 15:44:05 +0000 Subject: [PATCH 3/6] -3 w/ watchdog changes --- history.txt | 6 ++++++ router/java/src/net/i2p/router/RouterVersion.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 6a3e65017c..99799e856a 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,9 @@ +2009-05-21 zzz + * Router Watchdog: + - Log memory stats + - Dump threads on linux + - Restart after 20 minutes (give the dog his teeth back) + 2009-05-21 zzz * DataStore: - Adjust interface to have persistent and non-persistent methods, diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index bd644cee53..ef84e9e97b 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 2; + public final static long BUILD = 3; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; From 3208b7289ec5437d7713d8fe4987b239ec1898ae Mon Sep 17 00:00:00 2001 From: mathiasdm Date: Thu, 21 May 2009 22:32:34 +0000 Subject: [PATCH 4/6] * desktopgui: - Updating works in general config - Switched to Swingworker threads for improved responsiveness - version increase to 0.1.3 --- LICENSE.txt | 4 + apps/desktopgui/build.xml | 2 + apps/desktopgui/nbproject/project.properties | 4 +- .../i2p/desktopgui/desktopgui/GUIVersion.java | 2 +- .../desktopgui/gui/GeneralConfiguration.form | 17 ++- .../desktopgui/gui/GeneralConfiguration.java | 142 +++++++++++++++++- .../src/net/i2p/desktopgui/gui/Tray.java | 2 +- .../router/configuration/UpdateHandler.java | 19 +++ .../router/configuration/UpdateHelper.java | 66 ++++++++ build.xml | 2 +- history.txt | 5 + 11 files changed, 250 insertions(+), 15 deletions(-) create mode 100644 apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHandler.java create mode 100644 apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHelper.java diff --git a/LICENSE.txt b/LICENSE.txt index 02b2862d89..f68af6e0cd 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -179,6 +179,10 @@ distributions. See the source package for the additional license information. Atalk: Public domain + Desktopgui + Copyright (c) Mathias De Maré + See apps/desktopgui/LICENSE + SAM C Library: Copyright (c) 2004, Matthew P. Cashdollar See apps/sam/c/doc/license.txt diff --git a/apps/desktopgui/build.xml b/apps/desktopgui/build.xml index 77bd6d7785..795edf046e 100644 --- a/apps/desktopgui/build.xml +++ b/apps/desktopgui/build.xml @@ -76,10 +76,12 @@ + + diff --git a/apps/desktopgui/nbproject/project.properties b/apps/desktopgui/nbproject/project.properties index e9f5d1a2a1..fb880932f7 100644 --- a/apps/desktopgui/nbproject/project.properties +++ b/apps/desktopgui/nbproject/project.properties @@ -23,6 +23,7 @@ excludes= file.reference.appframework.jar=lib/appframework.jar file.reference.i2p.jar=../../core/java/build/i2p.jar file.reference.router.jar=../../router/java/build/router.jar +file.reference.routerconsole.jar=../routerconsole/java/build/routerconsole.jar file.reference.swing-worker.jar=lib/swing-worker.jar includes=** jar.compress=false @@ -30,7 +31,8 @@ javac.classpath=\ ${file.reference.router.jar}:\ ${file.reference.appframework.jar}:\ ${file.reference.swing-worker.jar}:\ - ${file.reference.i2p.jar} + ${file.reference.i2p.jar}:\ + ${file.reference.routerconsole.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/apps/desktopgui/src/net/i2p/desktopgui/desktopgui/GUIVersion.java b/apps/desktopgui/src/net/i2p/desktopgui/desktopgui/GUIVersion.java index f4e948e52c..10a6e52939 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/desktopgui/GUIVersion.java +++ b/apps/desktopgui/src/net/i2p/desktopgui/desktopgui/GUIVersion.java @@ -10,5 +10,5 @@ package net.i2p.desktopgui.desktopgui; * @author mathias */ public class GUIVersion { - public static final String VERSION = "0.0.1.2"; + public static final String VERSION = "0.0.1.3"; } diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form index 8e0acbb14a..4c7cb5afce 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form @@ -2,7 +2,7 @@
- + @@ -371,7 +371,7 @@ - + @@ -380,7 +380,7 @@ - + @@ -389,7 +389,7 @@ - + @@ -400,18 +400,27 @@ + + + + + + + + + diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java index b0dbccabca..474e394731 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java @@ -6,10 +6,23 @@ package net.i2p.desktopgui.gui; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.logging.Level; +import java.util.logging.Logger; import net.i2p.desktopgui.router.configuration.SpeedHelper; import javax.swing.JComboBox; +import javax.swing.ButtonModel; import javax.swing.JTextField; +import net.i2p.desktopgui.router.RouterHelper; import net.i2p.desktopgui.router.configuration.SpeedHandler; +import net.i2p.desktopgui.router.configuration.UpdateHelper; +import net.i2p.router.web.NewsFetcher; +import net.i2p.desktopgui.router.configuration.UpdateHandler; +import java.util.Date; +import javax.swing.SwingWorker; /** * @@ -22,11 +35,14 @@ public class GeneralConfiguration extends javax.swing.JFrame { initComponents(); extraInitComponents(); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.requestFocus(); this.setVisible(true); } private void extraInitComponents() { initSpeedTab(); + initUpdateTab(); } private void initSpeedTab() { @@ -34,8 +50,8 @@ public class GeneralConfiguration extends javax.swing.JFrame { String inbound = SpeedHelper.getInboundBandwidth(); String outbound = SpeedHelper.getOutboundBandwidth(); - initSpeeds(inbound, outbound); - initUsage("" + Integer.parseInt(inbound)/8, "" + Integer.parseInt(outbound)/8); + initSpeeds("" + Integer.parseInt(inbound)*8, "" + Integer.parseInt(outbound)*8); + initUsage("" + Integer.parseInt(inbound), "" + Integer.parseInt(outbound)); } catch(Exception e) { e.printStackTrace(); @@ -45,6 +61,32 @@ public class GeneralConfiguration extends javax.swing.JFrame { } } + private void initUpdateTab() { + //Set update policy + String updatePolicy = UpdateHelper.getUpdatePolicy(); + if(updatePolicy.equals(UpdateHelper.NOTIFY_UPDATE_POLICY)) { + updateButtonGroup.setSelected(updateInform.getModel(), true); + } + else if(updatePolicy.equals(UpdateHelper.DOWNLOAD_UPDATE_POLICY)) { + updateButtonGroup.setSelected(updateDownload.getModel(), true); + } + else if(updatePolicy.equals(UpdateHelper.INSTALL_UPDATE_POLICY)) { + updateButtonGroup.setSelected(updateDownloadRestart.getModel(), true); + } + else { + System.out.println("desktopgui: no updates for you!"); + } + + //Check if an update is available + //TODO: move this method out of the routerconsole so desktopgui doesn't depend on routerconsole!!! + if(NewsFetcher.getInstance(RouterHelper.getContext()).updateAvailable()) { + updateNow.setVisible(true); + } + else { + updateNow.setVisible(false); + } + } + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is @@ -54,7 +96,7 @@ public class GeneralConfiguration extends javax.swing.JFrame { // //GEN-BEGIN:initComponents private void initComponents() { - buttonGroup1 = new javax.swing.ButtonGroup(); + updateButtonGroup = new javax.swing.ButtonGroup(); applyPanel = new javax.swing.JPanel(); cancel = new javax.swing.JToggleButton(); ok = new javax.swing.JToggleButton(); @@ -240,26 +282,41 @@ public class GeneralConfiguration extends javax.swing.JFrame { updateMethod.setText(resourceMap.getString("updateMethod.text")); // NOI18N updateMethod.setName("updateMethod"); // NOI18N - buttonGroup1.add(updateInform); + updateButtonGroup.add(updateInform); updateInform.setText(resourceMap.getString("updateInform.text")); // NOI18N updateInform.setName("updateInform"); // NOI18N - buttonGroup1.add(updateDownload); + updateButtonGroup.add(updateDownload); updateDownload.setText(resourceMap.getString("updateDownload.text")); // NOI18N updateDownload.setName("updateDownload"); // NOI18N - buttonGroup1.add(updateDownloadRestart); + updateButtonGroup.add(updateDownloadRestart); updateDownloadRestart.setText(resourceMap.getString("updateDownloadRestart.text")); // NOI18N updateDownloadRestart.setName("updateDownloadRestart"); // NOI18N checkUpdates.setText(resourceMap.getString("checkUpdates.text")); // NOI18N checkUpdates.setName("checkUpdates"); // NOI18N + checkUpdates.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkUpdatesActionPerformed(evt); + } + }); updateNow.setText(resourceMap.getString("updateNow.text")); // NOI18N updateNow.setName("updateNow"); // NOI18N + updateNow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + updateNowActionPerformed(evt); + } + }); advancedUpdateConfig.setText(resourceMap.getString("advancedUpdateConfig.text")); // NOI18N advancedUpdateConfig.setName("advancedUpdateConfig"); // NOI18N + advancedUpdateConfig.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + advancedUpdateConfigActionPerformed(evt); + } + }); javax.swing.GroupLayout updatesPanelLayout = new javax.swing.GroupLayout(updatesPanel); updatesPanel.setLayout(updatesPanelLayout); @@ -468,9 +525,65 @@ private void cancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:even private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_okMouseClicked saveSpeeds(); + saveUpdatePolicy(); this.dispose(); }//GEN-LAST:event_okMouseClicked +private void checkUpdatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkUpdatesActionPerformed + long current = new Date().getTime(); + if(current < newsLastFetched + 5*60*1000) { + return; + } + checkUpdates.setText("Checking for updates"); + checkUpdates.setEnabled(false); + newsLastFetched = current; + SwingWorker sw = new SwingWorker() { + + @Override + protected Object doInBackground() throws Exception { + NewsFetcher.getInstance(RouterHelper.getContext()).fetchNews(); + return null; + } + + @Override + protected void done() { + checkUpdates.setText("Check for updates now"); + checkUpdates.setEnabled(true); + if(NewsFetcher.getInstance(RouterHelper.getContext()).updateAvailable()) { + updateNow.setVisible(true); + } + } + + }; +}//GEN-LAST:event_checkUpdatesActionPerformed + +private void updateNowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateNowActionPerformed + SwingWorker sw = new SwingWorker() { + + @Override + protected Object doInBackground() throws Exception { + new net.i2p.router.web.UpdateHandler().update(); + return null; + } + + }; + updateNow.setEnabled(false); + updateNow.setText("Updating..."); + checkUpdates.setEnabled(false); + +}//GEN-LAST:event_updateNowActionPerformed + +private void advancedUpdateConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_advancedUpdateConfigActionPerformed + try { + Desktop.getDesktop().browse(new URI("http://127.0.0.1:7657/configupdate.jsp")); + } catch (URISyntaxException ex) { + Logger.getLogger(GeneralConfiguration.class.getName()).log(Level.SEVERE, null, ex); + } + catch (IOException ex) { + Logger.getLogger(GeneralConfiguration.class.getName()).log(Level.SEVERE, null, ex); + } +}//GEN-LAST:event_advancedUpdateConfigActionPerformed + protected void initUsage(String upload, String download) { uploadgb.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(upload))); downloadgb.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(download))); @@ -513,11 +626,23 @@ private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ok } } + protected void saveUpdatePolicy() { + ButtonModel policyButton = updateButtonGroup.getSelection(); + if(policyButton.equals(updateInform.getModel())) { + UpdateHandler.setUpdatePolicy(UpdateHelper.NOTIFY_UPDATE_POLICY); + } + else if(policyButton.equals(updateDownload.getModel())) { + UpdateHandler.setUpdatePolicy(UpdateHelper.DOWNLOAD_UPDATE_POLICY); + } + else if(policyButton.equals(updateDownloadRestart.getModel())) { + UpdateHandler.setUpdatePolicy(UpdateHelper.INSTALL_UPDATE_POLICY); + } + } + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel advancedPanel; private javax.swing.JToggleButton advancedUpdateConfig; private javax.swing.JPanel applyPanel; - private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JToggleButton cancel; private javax.swing.JToggleButton checkUpdates; private javax.swing.JScrollPane clientFrame; @@ -537,6 +662,7 @@ private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ok private javax.swing.JPanel speedPanel; private javax.swing.JPanel tunnelPanel; private javax.swing.JLabel tunnelsExplanation; + private javax.swing.ButtonGroup updateButtonGroup; private javax.swing.JRadioButton updateDownload; private javax.swing.JRadioButton updateDownloadRestart; private javax.swing.JRadioButton updateInform; @@ -553,4 +679,6 @@ private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ok public static final int KILOBIT = 0; public static final int KILOBYTE = 1; + + private long newsLastFetched = 0; } diff --git a/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java b/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java index 42f720c27c..02fb5b2df8 100644 --- a/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java +++ b/apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java @@ -151,7 +151,7 @@ public class Tray { public void actionPerformed(ActionEvent arg0) { RouterHandler.setStatus(RouterHandler.SHUTDOWN_GRACEFULLY); long shutdownTime = RouterHelper.getGracefulShutdownTimeRemaining(); - System.out.println(shutdownTime); + System.out.println("Shutdowntime remaining: " + shutdownTime); if(shutdownTime>0) { trayIcon.displayMessage("Shutting down...", "Shutdown time remaining: " + shutdownTime/1000 + " seconds." + System.getProperty("line.separator") + "Shutdown will not happen immediately, because we are still participating in the network.", TrayIcon.MessageType.INFO); diff --git a/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHandler.java b/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHandler.java new file mode 100644 index 0000000000..e913f5e518 --- /dev/null +++ b/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHandler.java @@ -0,0 +1,19 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package net.i2p.desktopgui.router.configuration; + +import net.i2p.desktopgui.router.RouterHelper; + +/** + * + * @author mathias + */ +public class UpdateHandler { + public static void setUpdatePolicy(String policy) { + RouterHelper.getContext().router().setConfigSetting(UpdateHelper.PROP_UPDATE_POLICY, policy); + RouterHelper.getContext().router().saveConfig(); + } +} diff --git a/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHelper.java b/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHelper.java new file mode 100644 index 0000000000..86db6f7080 --- /dev/null +++ b/apps/desktopgui/src/net/i2p/desktopgui/router/configuration/UpdateHelper.java @@ -0,0 +1,66 @@ +package net.i2p.desktopgui.router.configuration; + +import net.i2p.desktopgui.router.RouterHelper; + +/** + * + * @author mathias + */ +public class UpdateHelper { + + public static final String PROP_NEWS_URL = "router.newsURL"; + public static final String DEFAULT_NEWS_URL = "http://complication.i2p/news.xml"; + + public static final String PROP_REFRESH_FREQUENCY = "router.newsRefreshFrequency"; + public static final String DEFAULT_REFRESH_FREQUENCY = 24*60*60*1000 + ""; + + public static final String PROP_UPDATE_POLICY = "router.updatePolicy"; + public static final String NOTIFY_UPDATE_POLICY = "notify"; + public static final String DOWNLOAD_UPDATE_POLICY = "download"; + public static final String INSTALL_UPDATE_POLICY = "install"; + public static final String DEFAULT_UPDATE_POLICY = DOWNLOAD_UPDATE_POLICY; + + public static final String PROP_SHOULD_PROXY = "router.updateThroughProxy"; + public static final String DEFAULT_SHOULD_PROXY = Boolean.TRUE.toString(); + public static final String PROP_PROXY_HOST = "router.updateProxyHost"; + public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; + public static final String PROP_PROXY_PORT = "router.updateProxyPort"; + public static final String DEFAULT_PROXY_PORT = "4444"; + + public static final String PROP_UPDATE_URL = "router.updateURL"; + public static final String DEFAULT_UPDATE_URL = + "http://echelon.i2p/i2p/i2pupdate.sud\r\n" + + "http://stats.i2p/i2p/i2pupdate.sud\r\n" + + "http://complication.i2p/i2p/i2pupdate.sud\r\n" + + "http://www.i2p2.i2p/_static/i2pupdate.sud\r\n" + + "http://update.postman.i2p/i2pupdate.sud" ; + + public static final String PROP_TRUSTED_KEYS = "router.trustedUpdateKeys"; + + public static String getNewsURL() { + String url = RouterHelper.getContext().getProperty(PROP_NEWS_URL); + if(url == null) { + return DEFAULT_NEWS_URL; + } + else { + return url; + } + } + + public static String getUpdatePolicy() { + String policy = null; + try { + policy = RouterHelper.getContext().getProperty(PROP_UPDATE_POLICY); + } + catch(Exception e) { + e.printStackTrace(); + } + System.out.println("Policy: " + policy); + if(policy == null) { + return DEFAULT_UPDATE_POLICY; + } + else { + return policy; + } + } +} diff --git a/build.xml b/build.xml index 886ca438ce..d9abb0947a 100644 --- a/build.xml +++ b/build.xml @@ -524,7 +524,7 @@ - + diff --git a/history.txt b/history.txt index 99799e856a..7319ee2672 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,8 @@ +2009-05-22 Mathiasdm + * desktopgui: + - Updating works in general config + - Switched to Swingworker threads for improved responsiveness + 2009-05-21 zzz * Router Watchdog: - Log memory stats From eac45256aa0e65803b7df0f11a2e7c160d5844bd Mon Sep 17 00:00:00 2001 From: mathiasdm Date: Sat, 23 May 2009 16:40:18 +0000 Subject: [PATCH 5/6] * Router netDB: - Added flags to the netDB page --- history.txt | 4 ++++ .../networkdb/kademlia/KademliaNetworkDatabaseFacade.java | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/history.txt b/history.txt index 7319ee2672..de28b4f586 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,7 @@ +2009-05-23 Mathiasdm + * Router netDB: + - Added flags to the netDB page + 2009-05-22 Mathiasdm * desktopgui: - Updating works in general config diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index 436fc526e3..a2075e7119 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -1067,6 +1067,11 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { else buf.append("Published: in ").append(DataHelper.formatDuration(0-age)).append("???
\n"); buf.append("Address(es): "); + String country = _context.commSystem().getCountry(info.getIdentity().getHash()); + if(country != null) { + buf.append(" \"").append(country.toUpperCase()).append("\"");"); + } for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) { RouterAddress addr = (RouterAddress)iter.next(); buf.append(addr.getTransportStyle()).append(": "); From 29489ad1987a92717a35f5acbd7d12dea8fc759c Mon Sep 17 00:00:00 2001 From: mathiasdm Date: Sat, 23 May 2009 17:24:44 +0000 Subject: [PATCH 6/6] Error in the geoip html. --- .../networkdb/kademlia/KademliaNetworkDatabaseFacade.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index a2075e7119..4c935be544 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -1070,7 +1070,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { String country = _context.commSystem().getCountry(info.getIdentity().getHash()); if(country != null) { buf.append(" \"").append(country.toUpperCase()).append("\"");"); + buf.append(" src=\"/flags.jsp?c=").append(country).append("\">"); } for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) { RouterAddress addr = (RouterAddress)iter.next();