From 6b766ddf457077381e69a2ff0220222ad8da967e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 13 Nov 2011 19:49:20 +0100 Subject: [PATCH] Add Sone-following times. --- .../java/net/pterodactylus/sone/core/Core.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 37fdef9..d0898f1 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -136,6 +136,9 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis /* synchronize access on itself. */ private final Map soneStatuses = new HashMap(); + /** The times Sones were followed. */ + private final Map soneFollowingTimes = new HashMap(); + /** Locked local Sones. */ /* synchronize on itself. */ private final Set lockedSones = new HashSet(); @@ -2196,6 +2199,17 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis configuration.getStringValue("KnownSone/" + soneCounter + "/ID").setValue(null); } + /* save Sone following times. */ + soneCounter = 0; + synchronized (soneFollowingTimes) { + for (Entry soneFollowingTime : soneFollowingTimes.entrySet()) { + configuration.getStringValue("SoneFollowingTimes/" + soneCounter + "/Sone").setValue(soneFollowingTime.getKey().getId()); + configuration.getLongValue("SoneFollowingTimes/" + soneCounter + "/Time").setValue(soneFollowingTime.getValue()); + ++soneCounter; + } + configuration.getStringValue("SoneFollowingTimes/" + soneCounter + "/Sone").setValue(null); + } + /* save known posts. */ int postCounter = 0; synchronized (newPosts) { @@ -2312,6 +2326,20 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis } } + /* load Sone following times. */ + soneCounter = 0; + while (true) { + String soneId = configuration.getStringValue("SoneFollowingTimes/" + soneCounter + "/Sone").getValue(null); + if (soneId == null) { + break; + } + long time = configuration.getLongValue("SoneFollowingTimes/" + soneCounter + "/Time").getValue(Long.MAX_VALUE); + synchronized (soneFollowingTimes) { + soneFollowingTimes.put(getSone(soneId), time); + } + ++soneCounter; + } + /* load known posts. */ int postCounter = 0; while (true) { -- 2.7.4