Merge branch 'next' into edit-wot-trust
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 Dec 2010 11:10:49 +0000 (12:10 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 Dec 2010 11:10:49 +0000 (12:10 +0100)
pom.xml
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java

diff --git a/pom.xml b/pom.xml
index fdf98e2..0eda605 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>net.pterodactylus</groupId>
        <artifactId>sone</artifactId>
-       <version>0.3.4</version>
+       <version>0.3.5-1</version>
        <dependencies>
                <dependency>
                        <groupId>net.pterodactylus</groupId>
index 8e1c35b..1c7e26d 100644 (file)
@@ -78,7 +78,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
        }
 
        /** The version. */
-       public static final Version VERSION = new Version(0, 3, 4);
+       public static final Version VERSION = new Version(0, 3, 5, 1);
 
        /** The logger. */
        private static final Logger logger = Logging.getLogger(SonePlugin.class);
index 9a8bd9b..ccd0d05 100644 (file)
@@ -124,6 +124,21 @@ public class SoneTemplatePage extends TemplatePage {
        }
 
        /**
+        * Returns the currently logged in Sone.
+        *
+        * @param toadletContext
+        *            The toadlet context
+        * @param create
+        *            {@code true} to create a new session if no session exists,
+        *            {@code false} to not create a new session
+        * @return The currently logged in Sone, or {@code null} if no Sone is
+        *         currently logged in
+        */
+       protected Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
+               return webInterface.getCurrentSone(toadletContext, create);
+       }
+
+       /**
         * Sets the currently logged in Sone.
         *
         * @param toadletContext
@@ -192,7 +207,7 @@ public class SoneTemplatePage extends TemplatePage {
        @Override
        public boolean isEnabled(ToadletContext toadletContext) {
                if (requiresLogin()) {
-                       return getCurrentSone(toadletContext) != null;
+                       return getCurrentSone(toadletContext, false) != null;
                }
                return true;
        }
index 2ea755b..c1c0653 100644 (file)
@@ -249,7 +249,22 @@ public class WebInterface implements CoreListener {
         *         currently logged in
         */
        public Sone getCurrentSone(ToadletContext toadletContext) {
-               return getCurrentSone(getCurrentSession(toadletContext));
+               return getCurrentSone(toadletContext, true);
+       }
+
+       /**
+        * Returns the currently logged in Sone.
+        *
+        * @param toadletContext
+        *            The toadlet context
+        * @param create
+        *            {@code true} to create a new session if no session exists,
+        *            {@code false} to not create a new session
+        * @return The currently logged in Sone, or {@code null} if no Sone is
+        *         currently logged in
+        */
+       public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
+               return getCurrentSone(getCurrentSession(toadletContext, create));
        }
 
        /**
@@ -672,6 +687,7 @@ public class WebInterface implements CoreListener {
                        @SuppressWarnings("synthetic-access")
                        public void run() {
                                lockedSonesNotification.add(sone);
+                               lockedSonesTickerObjects.remove(sone);
                                notificationManager.addNotification(lockedSonesNotification);
                        }
                }, "Sone Locked Notification");
@@ -683,12 +699,8 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void soneUnlocked(Sone sone) {
-               Object tickerObject = lockedSonesTickerObjects.remove(sone);
-               if (tickerObject == null) {
-                       return;
-               }
                lockedSonesNotification.remove(sone);
-               Ticker.getInstance().deregisterEvent(tickerObject);
+               Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(sone));
        }
 
        /**