From: David ‘Bombe’ Roden Date: Mon, 18 Oct 2010 14:00:23 +0000 (+0200) Subject: Persist list of blocked Sone IDs. X-Git-Tag: 0.1-RC1~232 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;ds=sidebyside;h=5e0e559e4b81028f4e93056c181cb426de67786f;p=Sone.git Persist list of blocked Sone IDs. --- 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);