From 5e0e559e4b81028f4e93056c181cb426de67786f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Oct 2010 16:00:23 +0200 Subject: [PATCH] Persist list of blocked Sone IDs. --- src/main/java/net/pterodactylus/sone/core/Core.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index c861fd1..9917e11 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -559,6 +559,17 @@ public class Core extends AbstractService { sone.addFriend(friendSone); } + /* load blocked Sone IDs. */ + int blockedSoneCounter = 0; + while (true) { + String blockedSonePrefix = sonePrefix + "/BlockedSone." + blockedSoneCounter++; + String blockedSoneId = configuration.getStringValue(blockedSonePrefix + "/ID").getValue(null); + if (blockedSoneId == null) { + break; + } + sone.addBlockedSoneId(blockedSoneId); + } + sone.setModificationCounter(modificationCounter); addLocalSone(sone); } catch (MalformedURLException mue1) { @@ -626,6 +637,14 @@ public class Core extends AbstractService { /* write null ID as terminator. */ configuration.getStringValue(sonePrefix + "/Friend." + friendId + "/ID").setValue(null); + /* write all blocked Sones. */ + int blockedSoneCounter = 0; + for (String blockedSoneId : sone.getBlockedSoneIds()) { + String blockedSonePrefix = sonePrefix + "/BlockedSone." + blockedSoneCounter++; + configuration.getStringValue(blockedSonePrefix + "/ID").setValue(blockedSoneId); + } + configuration.getStringValue(sonePrefix + "/BlockedSone." + blockedSoneCounter + "/ID").setValue(null); + } /* write null ID as terminator. */ configuration.getStringValue("Sone/Sone." + soneId + "/ID").setValue(null); -- 2.7.4