Author: nextgens
Date: 2008-01-06 10:30:47 +0000 (Sun, 06 Jan 2008)
New Revision: 16937

Added:
   trunk/freenet/src/freenet/node/useralerts/ClockProblemDetectedUserAlert.java
Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/PeerManager.java
Log:
Add a new user alert to tell the user to update his clock if needed

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-01-05 
22:55:10 UTC (rev 16936)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-01-06 
10:30:47 UTC (rev 16937)
@@ -56,6 +56,8 @@
 BooleanOption.parseError=Unrecognized boolean: ${val} - try true or false
 BuildOldAgeUserAlert.tooOld=This node's software is older than the oldest 
version (Build #${lastgood}) allowed by the newest peers we try to connect to.  
Please update your node as soon as possible as you will not be able to connect 
to peers labeled "TOO NEW" until you do. (Freenet may leave your node in the 
dust of the past if you don't upgrade.)
 BuildOldAgeUserAlert.tooOldTitle=Build too old
+ClockProblemDetectedUserAlert.title=Your computer's clock isn't on time.
+ClockProblemDetectedUserAlert.text=Freenet has detected that your computer's 
clock (time and date) isn't on time. It won't work properly until you fix it 
and restart the node.
 CSSTokenizerFilter.deletedDisallowedString=Deleted disallowed string
 CSSTokenizerFilter.deletedUnmatchedChar=ignored unmatched char:
 CSSTokenizerFilter.deletedUnofficialIdent=Deleted unofficial ident

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-01-05 22:55:10 UTC (rev 
16936)
+++ trunk/freenet/src/freenet/node/Node.java    2008-01-06 10:30:47 UTC (rev 
16937)
@@ -78,6 +78,7 @@
 import freenet.node.updater.NodeUpdateManager;
 import freenet.node.useralerts.AbstractUserAlert;
 import freenet.node.useralerts.BuildOldAgeUserAlert;
+import freenet.node.useralerts.ClockProblemDetectedUserAlert;
 import freenet.node.useralerts.ExtOldAgeUserAlert;
 import freenet.node.useralerts.MeaningfulNodeNameUserAlert;
 import freenet.node.useralerts.OpennetUserAlert;
@@ -124,6 +125,7 @@
        private static MeaningfulNodeNameUserAlert nodeNameUserAlert;
        private static BuildOldAgeUserAlert buildOldAgeUserAlert;
        private static TimeSkewDetectedUserAlert timeSkewDetectedUserAlert;
+       private final static ClockProblemDetectedUserAlert 
clockProblemDetectedUserAlert = new ClockProblemDetectedUserAlert();

        public class NodeNameCallback implements StringCallback{
                        GetPubkey node;
@@ -2945,4 +2947,11 @@
        public boolean wantAnonAuth() {
                return opennet != null && acceptSeedConnections;
        }
+       
+       public void displayClockProblemUserAlert(boolean value) {
+               if(value)
+                       
clientCore.alerts.register(clockProblemDetectedUserAlert);
+               else
+                       
clientCore.alerts.unregister(clockProblemDetectedUserAlert);
+       }
 }

Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java     2008-01-05 22:55:10 UTC 
(rev 16936)
+++ trunk/freenet/src/freenet/node/PeerManager.java     2008-01-06 10:30:47 UTC 
(rev 16937)
@@ -1113,6 +1113,7 @@
                }
                Logger.normal(this, "Connected: "+numberOfConnected+"  Routing 
Backed Off: "+numberOfRoutingBackedOff+"  Too New: "+numberOfTooNew+"  Too Old: 
"+numberOfTooOld+"  Disconnected: "+numberOfDisconnected+"  Never Connected: 
"+numberOfNeverConnected+"  Disabled: "+numberOfDisabled+"  Bursting: 
"+numberOfBursting+"  Listening: "+numberOfListening+"  Listen Only: 
"+numberOfListenOnly+"  Clock Problem: "+numberOfClockProblem+"  Connection 
Problem: "+numberOfConnError+"  Disconnecting: "+numberOfDisconnecting);
                nextPeerNodeStatusLogTime = now + peerNodeStatusLogInterval;
+               node.displayClockProblemUserAlert(numberOfClockProblem > 2);
                }
        }


Added: 
trunk/freenet/src/freenet/node/useralerts/ClockProblemDetectedUserAlert.java
===================================================================
--- 
trunk/freenet/src/freenet/node/useralerts/ClockProblemDetectedUserAlert.java    
                            (rev 0)
+++ 
trunk/freenet/src/freenet/node/useralerts/ClockProblemDetectedUserAlert.java    
    2008-01-06 10:30:47 UTC (rev 16937)
@@ -0,0 +1,44 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+package freenet.node.useralerts;
+
+import freenet.l10n.L10n;
+import freenet.support.HTMLNode;
+
+/**
+ * A useralert to tell the user to update his computer's clock
+ *
+ * This useralert is SET only and can be triggered from NodeStarter
+ *
+ * @author Florent Daignière <nextgens at freenetproject.org>
+ */
+public class ClockProblemDetectedUserAlert extends AbstractUserAlert {
+       
+       /**
+        * 
+        */
+       public ClockProblemDetectedUserAlert() {
+               super(false, null, null, null, UserAlert.CRITICAL_ERROR, true, 
null, false, null);
+       }
+
+       public String getTitle() {
+               return l10n("title");
+       }
+       
+       private String l10n(String key) {
+               return L10n.getString("ClockProblemDetectedUserAlert."+key);
+       }
+
+       public String getText() {
+               return l10n("text");
+       }
+
+       public HTMLNode getHTMLText() {
+               return new HTMLNode("div", getText());
+       }
+
+       public boolean userCanDismiss() {
+               return false;
+       }
+}


Reply via email to