Author: toad
Date: 2008-09-03 23:26:46 +0000 (Wed, 03 Sep 2008)
New Revision: 22398

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/SecurityLevels.java
Log:
Show the current security levels in a useralert (dismissable but doesn't 
remember across restarts).
Don't show the OpennetUserAlert (haven't actually deleted it yet though).


Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-09-03 
23:01:15 UTC (rev 22397)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-09-03 
23:26:46 UTC (rev 22398)
@@ -1096,6 +1096,11 @@
 SecurityLevels.physicalThreatLevel.desc.NORMAL=Freenet will encrypt temporary 
files etc, at a small performance cost, but you should take additional 
precautions such as disabling your browser cache when using the web interface. 
If you use persistent downloads (most tools do), you should encrypt the drive 
Freenet is running on.
 SecurityLevels.physicalThreatLevel.choice.LOW=I am not concerned.
 SecurityLevels.physicalThreatLevel.desc.LOW=Freenet will avoid disk encryption 
and leave traces of what you have visited on your hard disk, improving 
performance at the expense of lower security if your computer is seized.
+SecurityLevels.userAlertShortText=Security levels: Network: ${network}, 
Friends: ${friends}, Physical: ${physical}
+SecurityLevels.userAlertNetworkThreatLevel=Protection against a stranger 
attacking you over the Internet: ${level}
+SecurityLevels.userAlertFriendsThreatLevel=Protection if your friends attack 
your anonymity: ${level}
+SecurityLevels.userAlertPhysicalThreatLevel=Protection if your computer is 
seized or stolen: ${level}
+SecurityLevels.userAlertExtro=You can change these settings on ${link}the 
config page${/link}.
 ShortOption.parseError=Cannot parse value as a string array: ${error}
 ShortOption.parseError=The value specified can't be parsed as a 16-bit integer 
: ${val}
 SimpleToadletServer.advancedMode=Enable Advanced Mode?

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-09-03 23:01:15 UTC (rev 
22397)
+++ trunk/freenet/src/freenet/node/Node.java    2008-09-03 23:26:46 UTC (rev 
22398)
@@ -1822,6 +1822,8 @@
                        ((SaltedHashFreenetStore) 
sskDatacache.getStore()).setUserAlertManager(clientCore.alerts);
                }

+               securityLevels.registerUserAlert(clientCore.alerts);
+               
                nodeConfig.register("disableHangCheckers", false, sortOrder++, 
true, false, "Node.disableHangCheckers", "Node.disableHangCheckersLong", new 
BooleanCallback() {

                        public Boolean get() {
@@ -1935,8 +1937,6 @@
                if(!NativeThread.HAS_ENOUGH_NICE_LEVELS)
                        clientCore.alerts.register(new 
NotEnoughNiceLevelsUserAlert());

-               clientCore.alerts.register(new OpennetUserAlert(this));
-               
                this.clientCore.start(config);

                // After everything has been created, write the config file 
back to disk.

Modified: trunk/freenet/src/freenet/node/SecurityLevels.java
===================================================================
--- trunk/freenet/src/freenet/node/SecurityLevels.java  2008-09-03 23:01:15 UTC 
(rev 22397)
+++ trunk/freenet/src/freenet/node/SecurityLevels.java  2008-09-03 23:26:46 UTC 
(rev 22398)
@@ -5,12 +5,15 @@

 import java.util.ArrayList;

+import freenet.clients.http.ConfigToadlet;
 import freenet.config.EnumerableOptionCallback;
 import freenet.config.InvalidConfigValueException;
 import freenet.config.NodeNeedRestartException;
 import freenet.config.PersistentConfig;
 import freenet.config.SubConfig;
 import freenet.l10n.L10n;
+import freenet.node.useralerts.UserAlert;
+import freenet.node.useralerts.UserAlertManager;
 import freenet.support.HTMLNode;
 import freenet.support.Logger;
 import freenet.support.api.StringCallback;
@@ -370,5 +373,84 @@
        public static String localisedName(FRIENDS_THREAT_LEVEL 
newFriendsLevel) {
                return 
L10n.getString("SecurityLevels.friendsThreatLevel.name."+newFriendsLevel.name());
        }
+       
+       public static String localisedName(PHYSICAL_THREAT_LEVEL 
newPhysicalLevel) {
+               return 
L10n.getString("SecurityLevels.physicalThreatLevel.name."+newPhysicalLevel.name());
+       }

+       public void registerUserAlert(UserAlertManager alerts) {
+               alerts.register(new UserAlert() {
+
+                       public String anchor() {
+                               return "seclevels";
+                       }
+
+                       public String dismissButtonText() {
+                               return L10n.getString("UserAlert.hide");
+                       }
+
+                       public HTMLNode getHTMLText() {
+                               HTMLNode div = new HTMLNode("div");
+                               HTMLNode ul = div.addChild("ul");
+                               ul.addChild("li", 
l10n("userAlertNetworkThreatLevel", "level", 
localisedName(networkThreatLevel)));
+                               ul.addChild("li", 
l10n("userAlertFriendsThreatLevel", "level", 
localisedName(friendsThreatLevel)));
+                               ul.addChild("li", 
l10n("userAlertPhysicalThreatLevel", "level", 
localisedName(physicalThreatLevel)));
+                               div.addChild("br");
+                               L10n.addL10nSubstitution(div, 
"SecurityLevels.userAlertExtro",
+                                               new String[] { "link", "/link" 
},
+                                               new String[] { "<a 
href=\"/config/?mode="+ConfigToadlet.MODE_SECURITY_LEVELS+"\">", "</a>" });
+                               return div;
+                       }
+
+                       public short getPriorityClass() {
+                               return UserAlert.WARNING;
+                       }
+
+                       public String getShortText() {
+                               return l10n("userAlertShortText", new String[] 
{ "network", "friends", "physical" },
+                                               new String[] {
+                                                       
localisedName(networkThreatLevel),
+                                                       
localisedName(friendsThreatLevel),
+                                                       
localisedName(physicalThreatLevel)} );
+                       }
+
+                       public String getText() {
+                               return getHTMLText().getContent();
+                       }
+
+                       public String getTitle() {
+                               return l10n("title");
+                       }
+
+                       public Object getUserIdentifier() {
+                               return null;
+                       }
+
+                       public boolean isEventNotification() {
+                               return false;
+                       }
+
+                       public boolean isValid() {
+                               return true;
+                       }
+
+                       public void isValid(boolean validity) {
+                               // Ignore
+                       }
+
+                       public void onDismiss() {
+                               // Ignore
+                       }
+
+                       public boolean shouldUnregisterOnDismiss() {
+                               return true;
+                       }
+
+                       public boolean userCanDismiss() {
+                               return true;
+                       }
+                       
+               });
+       }
+
 }


Reply via email to