From: David ‘Bombe’ Roden Date: Sat, 18 Dec 2010 11:10:49 +0000 (+0100) Subject: Merge branch 'next' into edit-wot-trust X-Git-Tag: 0.4^2~8^2~42 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=316b9c2b3d16792975434644ae39a9b1814f32c4;hp=0da3fe68ecd25fdfc5eca94f939288c9f6273940 Merge branch 'next' into edit-wot-trust --- diff --git a/pom.xml b/pom.xml index fdf98e2..0eda605 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.pterodactylus sone - 0.3.4 + 0.3.5-1 net.pterodactylus diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 8e1c35b..1c7e26d 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -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); diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 9a8bd9b..ccd0d05 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -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; } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 2ea755b..c1c0653 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -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)); } /**