Add “unknown” Sone state, initialize local and remote Sones differently.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 19 Oct 2010 07:19:09 +0000 (09:19 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 19 Oct 2010 07:19:09 +0000 (09:19 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
src/main/resources/static/css/sone.css
src/main/resources/templates/include/viewSone.html

index 76881ef..0f733b6 100644 (file)
@@ -59,6 +59,9 @@ public class Core extends AbstractService {
         */
        public enum SoneStatus {
 
+               /** The Sone is unknown, i.e. not yet downloaded. */
+               unknown,
+
                /** The Sone is idle, i.e. not being downloaded or inserted. */
                idle,
 
@@ -159,7 +162,7 @@ public class Core extends AbstractService {
                if (!soneCache.containsKey(soneId)) {
                        Sone sone = new Sone(soneId);
                        soneCache.put(soneId, sone);
-                       setSoneStatus(sone, SoneStatus.idle);
+                       setSoneStatus(sone, SoneStatus.unknown);
                }
                return soneCache.get(soneId);
        }
@@ -302,6 +305,7 @@ public class Core extends AbstractService {
         */
        public void addLocalSone(Sone sone) {
                if (localSones.add(sone)) {
+                       setSoneStatus(sone, SoneStatus.idle);
                        SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone);
                        soneInserter.start();
                        soneInserters.put(sone, soneInserter);
@@ -443,7 +447,7 @@ public class Core extends AbstractService {
                                                addSone(parsedSone);
                                        }
                                } finally {
-                                       setSoneStatus(sone, SoneStatus.idle);
+                                       setSoneStatus(sone, (sone.getTime() == 0) ? SoneStatus.unknown : SoneStatus.idle);
                                }
                        }
                }, "Sone Downloader").start();
index 07a3755..b7663e5 100644 (file)
@@ -125,7 +125,7 @@ public class SoneDownloader extends AbstractService {
                                core.addSone(parsedSone);
                        }
                } finally {
-                       core.setSoneStatus(sone, SoneStatus.idle);
+                       core.setSoneStatus(sone, (sone.getTime() == 0) ? SoneStatus.unknown : SoneStatus.idle);
                }
        }
 
index e22738a..ebf2f82 100644 (file)
@@ -78,6 +78,8 @@ public class SoneAccessor extends ReflectionAccessor {
                        return sone.getModificationCounter() > 0;
                } else if (member.equals("status")) {
                        return core.getSoneStatus(sone).toString();
+               } else if (member.equals("unknown")) {
+                       return core.getSoneStatus(sone) == SoneStatus.unknown;
                } else if (member.equals("idle")) {
                        return core.getSoneStatus(sone) == SoneStatus.idle;
                } else if (member.equals("inserting")) {
index cc94ce0..25e61c9 100644 (file)
        display: inline;
 }
 
-#sone .sone .download-marker, #sone .sone .insert-marker, #sone .sone .idle-marker {
-       display: inline;
+#sone .sone .unknown-marker, #sone .sone .download-marker, #sone .sone .insert-marker, #sone .sone .idle-marker, #sone .sone .modified-marker {
+       display: none;
 }
 
-#sone .sone.idle .download-marker, #sone .sone.idle .insert-marker {
-       display: none;
+#sone .sone.unknown .unknown-marker {
+       display: inline;
 }
 
-#sone .sone.downloading .insert-marker, #sone .sone.downloading .idle-marker {
-       display: none;
+#sone .sone.idle .idle-marker {
+       display: inline;
 }
 
-#sone .sone.inserting .download-marker, #sone .sone.inserting .idle-marker {
-       display: none;
+#sone .sone.downloading .download-marker {
+       display: inline;
 }
 
-#sone .sone .modified-marker {
-       display: none;
+#sone .sone.inserting .insert-marker {
+       display: inline;
 }
 
 #sone .sone.modified .modified-marker {
index 868cd70..615510a 100644 (file)
@@ -1,6 +1,7 @@
 <div class="sone <% sone.status><%if sone.modified> modified<%/if>">
        <div class="profile-link"><a href="viewSone.html?sone=<% sone.id>" title="<% sone.requestUri|html>"><% sone.niceName|html></a></div>
        <div class="last-update">(<%= View.Sone.Label.LastUpdate|l10n|html> <% sone.time|date format="MMM d, yyyy, HH:mm:ss">)</div>
+       <div class="unknown-marker">?</div>
        <div class="modified-marker">!</div>
        <div class="download-marker">⬊</div>
        <div class="insert-marker">⬈</div>