From 0ee6abf930f33b27f64be202e3ffeefb3972ecf0 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 5 Aug 2008 21:03:50 +0000 Subject: Client: Added IP Check Timer Now the Client contacts the Central Server at a regular basis to ensure that its IP is always correct. Closes #21. --- .../fourisland/instadisc/AdvancedSettingsForm.form | 72 ++++++++++++++++++--- .../fourisland/instadisc/AdvancedSettingsForm.java | 73 +++++++++++++++++++--- .../com/fourisland/instadisc/FirstRun/Step2.java | 2 + .../com/fourisland/instadisc/InstaDiscView.java | 27 ++++++++ .../resources/AdvancedSettingsForm.properties | 2 + 5 files changed, 158 insertions(+), 18 deletions(-) (limited to 'client/trunk') diff --git a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form index 6fb22bd..f561077 100644 --- a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form +++ b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form @@ -24,6 +24,10 @@ + + + + @@ -40,16 +44,28 @@ - - - - - + + + + + + + + + + + + + + + + + @@ -75,18 +91,26 @@ - - - + + + - + + + + + + + + + - + @@ -148,5 +172,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java index 753bbe3..14469ea 100644 --- a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java +++ b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java @@ -33,6 +33,20 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { sm2.setMinimum(1); sm2.setStepSize(1); jSpinner2.setModel(sm2); + + SpinnerNumberModel sm3 = new SpinnerNumberModel(); + sm3.setValue(Integer.decode(Wrapper.getConfig("ipCheckValue"))); + sm3.setMaximum(23); + sm3.setMinimum(1); + sm3.setStepSize(1); + jSpinner3.setModel(sm3); + + if (Wrapper.getConfig("ipCheckUnit").equals("day")) + { + jComboBox1.setSelectedIndex(0); + } else { + jComboBox1.setSelectedIndex(1); + } } /** This method is called from within the constructor to @@ -52,6 +66,10 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { jSpinner2 = new javax.swing.JSpinner(); jLabel6 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); + jLabel7 = new javax.swing.JLabel(); + jSpinner3 = new javax.swing.JSpinner(); + jComboBox1 = new javax.swing.JComboBox(); + jLabel8 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setName("Form"); // NOI18N @@ -88,12 +106,26 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { } }); + jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N + jLabel7.setName("jLabel7"); // NOI18N + + jSpinner3.setName("jSpinner3"); // NOI18N + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "day", "hour" })); + jComboBox1.setName("jComboBox1"); // NOI18N + + jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N + jLabel8.setName("jLabel8"); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGap(36, 36, 36) + .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGap(36, 36, 36) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)) @@ -108,11 +140,20 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { .addComponent(jLabel3) .addGap(18, 18, 18) .addComponent(jSpinner1, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSpinner2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGap(24, 24, 24) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel7) + .addGap(18, 18, 18) + .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBox1, 0, 121, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSpinner2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)))) .addGroup(layout.createSequentialGroup() .addContainerGap(341, Short.MAX_VALUE) .addComponent(jButton1)) @@ -133,16 +174,23 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { .addComponent(jLabel3) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5) - .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7) + .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) - .addContainerGap()) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); @@ -151,6 +199,11 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed Wrapper.setConfig("itemBufferSize", ((Integer) jSpinner1.getValue()).toString()); Wrapper.setConfig("verIDBufferSize", ((Integer) jSpinner2.getValue()).toString()); + Wrapper.setConfig("ipCheckValue", ((Integer) jSpinner3.getValue()).toString()); + Wrapper.setConfig("ipCheckUnit", (String) jComboBox1.getSelectedItem()); + + ((InstaDiscView) InstaDiscApp.getApplication().getMainView()).updateTimer(); + setVisible(false); }//GEN-LAST:event_jButton1ActionPerformed @@ -173,14 +226,18 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; + private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; 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 jLabel8; private javax.swing.JSpinner jSpinner1; private javax.swing.JSpinner jSpinner2; + private javax.swing.JSpinner jSpinner3; // End of variables declaration//GEN-END:variables } diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java index 719f27d..01a3c02 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java @@ -168,6 +168,8 @@ public class Step2 extends javax.swing.JDialog { Wrapper.setConfig("itemBufferSize", "10"); Wrapper.setConfig("verIDBufferSize", "100"); Wrapper.setConfig("nextFilterID", "0"); + Wrapper.setConfig("ipCheckValue", "1"); + Wrapper.setConfig("ipCheckUnit", "day"); Wrapper.setConfig("initCheck", "done"); StepEndResults.ok = true; diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index be96e8a..b706126 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java @@ -115,6 +115,8 @@ public class InstaDiscView extends FrameView { XmlRpc xmlrpc = new XmlRpc("requestRetained"); xmlrpc.execute(); + + updateTimer(); } @Action @@ -367,10 +369,35 @@ public class InstaDiscView extends FrameView { private final Icon[] busyIcons = new Icon[15]; private int busyIconIndex = 0; private JDialog aboutBox; + private Timer ipCheckTimer; public void refreshItemPane() { Item items[] = Wrapper.getAllItem(); jList1.setListData(items); jList1.repaint(); } + + public void updateTimer() { + int delay = 0; + + if (ipCheckTimer.isRunning()) { + ipCheckTimer.stop(); + } + + if (Wrapper.getConfig("ipCheckUnit").equals("day")) { + delay = 1000 * 60 * 60 * 24 * Integer.decode(Wrapper.getConfig("ipCheckValue")); + } else if (Wrapper.getConfig("ipCheckUnit").equals("hour")) { + delay = 1000 * 60 * 60 * Integer.decode(Wrapper.getConfig("ipCheckValue")); + } + + ipCheckTimer = new Timer(delay, new ActionListener() { + + public void actionPerformed(ActionEvent arg0) { + XmlRpc xmlrpc = new XmlRpc("checkRegistration"); + xmlrpc.execute(); + } + }); + + ipCheckTimer.start(); + } } diff --git a/client/trunk/src/com/fourisland/instadisc/resources/AdvancedSettingsForm.properties b/client/trunk/src/com/fourisland/instadisc/resources/AdvancedSettingsForm.properties index 55acc2a..e05a8fb 100644 --- a/client/trunk/src/com/fourisland/instadisc/resources/AdvancedSettingsForm.properties +++ b/client/trunk/src/com/fourisland/instadisc/resources/AdvancedSettingsForm.properties @@ -7,3 +7,5 @@ jLabel4.text=This is the number of items that you would like to keep on th jLabel5.text=VerID Buffer Size: jLabel6.text=If this is a higher value, less viral Items will get in, but there'd be more chance of re-contacting the server, and thus more Internet usage. jButton1.text=Done +jLabel7.text=IP Timer Interval: +jLabel8.text=This is how often InstaDisc contacts the Central Server to see if your IP Address has changed. If your IP Address has changed and the Central Server doesn't know about it yet, you won't be able to recieve InstaDisc Items. -- cgit 1.4.1