Merge branch 'release-0.3.6' 0.3.6
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 30 Dec 2010 21:25:23 +0000 (22:25 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 30 Dec 2010 21:25:23 +0000 (22:25 +0100)
pom.xml
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/core/FreenetInterface.java
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/resources/static/javascript/sone.js

diff --git a/pom.xml b/pom.xml
index 0eda605..640c1e4 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.5-1</version>
+       <version>0.3.6</version>
        <dependencies>
                <dependency>
                        <groupId>net.pterodactylus</groupId>
@@ -18,7 +18,7 @@
                <dependency>
                        <groupId>org.freenetproject</groupId>
                        <artifactId>fred</artifactId>
-                       <version>0.7.5.1305</version>
+                       <version>0.7.5.1311</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
index 2ef2d57..1a92901 100644 (file)
@@ -86,6 +86,9 @@ public class Core implements IdentityListener {
        /** The configuration. */
        private Configuration configuration;
 
+       /** Whether we’re currently saving the configuration. */
+       private boolean storingConfiguration = false;
+
        /** The identity manager. */
        private final IdentityManager identityManager;
 
@@ -1306,6 +1309,7 @@ public class Core implements IdentityListener {
                        if (newPosts.remove(post.getId())) {
                                knownPosts.add(post.getId());
                                coreListenerManager.fireMarkPostKnown(post);
+                               saveConfiguration();
                        }
                }
        }
@@ -1386,6 +1390,7 @@ public class Core implements IdentityListener {
                        if (newReplies.remove(reply.getId())) {
                                knownReplies.add(reply.getId());
                                coreListenerManager.fireMarkReplyKnown(reply);
+                               saveConfiguration();
                        }
                }
        }
@@ -1406,6 +1411,7 @@ public class Core implements IdentityListener {
                                soneInserter.stop();
                        }
                }
+               soneDownloader.stop();
                saveConfiguration();
                stopped = true;
        }
@@ -1413,7 +1419,15 @@ public class Core implements IdentityListener {
        /**
         * Saves the current options.
         */
-       public synchronized void saveConfiguration() {
+       public void saveConfiguration() {
+               synchronized (configuration) {
+                       if (storingConfiguration) {
+                               logger.log(Level.FINE, "Already storing configuration…");
+                               return;
+                       }
+                       storingConfiguration = true;
+               }
+
                /* store the options first. */
                try {
                        configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal());
@@ -1453,6 +1467,10 @@ public class Core implements IdentityListener {
 
                } catch (ConfigurationException ce1) {
                        logger.log(Level.SEVERE, "Could not store configuration!", ce1);
+               } finally {
+                       synchronized (configuration) {
+                               storingConfiguration = false;
+                       }
                }
        }
 
index f5d7b66..6737d63 100644 (file)
@@ -65,12 +65,10 @@ public class FreenetInterface {
         *
         * @param node
         *            The node to interact with
-        * @param client
-        *            The high-level client
         */
-       public FreenetInterface(Node node, HighLevelSimpleClient client) {
+       public FreenetInterface(Node node) {
                this.node = node;
-               this.client = client;
+               this.client = node.clientCore.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, false, true);
        }
 
        //
index 2980b68..e5b6482 100644 (file)
@@ -78,7 +78,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
        }
 
        /** The version. */
-       public static final Version VERSION = new Version(0, 3, 5, 1);
+       public static final Version VERSION = new Version(0, 3, 6);
 
        /** The logger. */
        private static final Logger logger = Logging.getLogger(SonePlugin.class);
@@ -167,7 +167,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
                }
 
                /* create freenet interface. */
-               FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode(), pluginRespirator.getHLSimpleClient());
+               FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode());
 
                /* create web of trust connector. */
                PluginConnector pluginConnector = new PluginConnector(pluginRespirator);
index 7562526..a33072f 100644 (file)
@@ -54,15 +54,22 @@ public class IndexPage extends SoneTemplatePage {
        @Override
        protected void processTemplate(Request request, Template template) throws RedirectException {
                super.processTemplate(request, template);
-               Sone sone = getCurrentSone(request.getToadletContext());
+               Sone currentSone = getCurrentSone(request.getToadletContext());
                List<Post> allPosts = new ArrayList<Post>();
-               allPosts.addAll(sone.getPosts());
-               for (String friendSoneId : sone.getFriends()) {
+               allPosts.addAll(currentSone.getPosts());
+               for (String friendSoneId : currentSone.getFriends()) {
                        if (!webInterface.getCore().hasSone(friendSoneId)) {
                                continue;
                        }
                        allPosts.addAll(webInterface.getCore().getSone(friendSoneId).getPosts());
                }
+               for (Sone sone : webInterface.getCore().getSones()) {
+                       for (Post post : sone.getPosts()) {
+                               if (currentSone.equals(post.getRecipient()) && !allPosts.contains(post)) {
+                                       allPosts.add(post);
+                               }
+                       }
+               }
                Collections.sort(allPosts, Post.TIME_COMPARATOR);
                template.set("posts", allPosts);
        }
index acb1d46..77d401a 100644 (file)
@@ -672,19 +672,39 @@ function isKnownSonesPage() {
        return getPageId() == "known-sones";
 }
 
-var loadedPosts = {};
-var loadedReplies = {};
+/**
+ * Returns whether a post with the given ID exists on the current page.
+ *
+ * @param postId
+ *            The post ID to check for
+ * @returns {Boolean} <code>true</code> if a post with the given ID already
+ *          exists on the page, <code>false</code> otherwise
+ */
+function hasPost(postId) {
+       return $(".post#" + postId).length > 0;
+}
+
+/**
+ * Returns whether a reply with the given ID exists on the current page.
+ *
+ * @param replyId
+ *            The reply ID to check for
+ * @returns {Boolean} <code>true</code> if a reply with the given ID already
+ *          exists on the page, <code>false</code> otherwise
+ */
+function hasReply(replyId) {
+       return $("#sone .reply#" + replyId).length > 0;
+}
 
 function loadNewPost(postId) {
-       if (postId in loadedPosts) {
+       if (hasPost(postId)) {
                return;
        }
        $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) {
                if ((data != null) && data.success) {
-                       if (data.post.id in loadedPosts) {
+                       if (hasPost(data.post.id)) {
                                return;
                        }
-                       loadedPosts[data.post.id] = true;
                        if (!isIndexPage() && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) {
                                return;
                        }
@@ -709,16 +729,15 @@ function loadNewPost(postId) {
 }
 
 function loadNewReply(replyId) {
-       if (replyId in loadedReplies) {
+       if (hasReply(replyId)) {
                return;
        }
        $.getJSON("getReply.ajax", { "reply": replyId }, function(data, textStatus) {
                /* find post. */
                if ((data != null) && data.success) {
-                       if (data.reply.id in loadedReplies) {
+                       if (hasReply(data.reply.id)) {
                                return;
                        }
-                       loadedReplies[data.reply.id] = true;
                        $("#sone .post#" + data.reply.postId).each(function() {
                                var firstNewerReply = null;
                                $(this).find(".replies .reply").each(function() {
@@ -823,6 +842,9 @@ $(document).ready(function() {
        getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) {
                registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false);
                $("#sone #update-status").submit(function() {
+                       if ($(this).find(":input").hasClass("default")) {
+                               return false;
+                       }
                        text = $(this).find(":input:enabled").val();
                        $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) {
                                if ((data != null) && data.success) {