From 5b54d9007b20d2cd8f52decdeb2baaf1445f33cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 14 Nov 2010 12:01:17 +0100 Subject: [PATCH] Parse client information from downloaded Sones. --- .../java/net/pterodactylus/sone/core/SoneDownloader.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 7133797..42f6702 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -26,6 +26,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.pterodactylus.sone.core.Core.SoneStatus; +import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Reply; @@ -215,6 +216,17 @@ public class SoneDownloader extends AbstractService { return null; } + SimpleXML clientXml = soneXml.getNode("client"); + if (clientXml != null) { + String clientName = clientXml.getValue("name", null); + String clientVersion = clientXml.getValue("version", null); + if ((clientName == null) || (clientVersion == null)) { + logger.log(Level.WARNING, "Download Sone %s with client XML but missing name or version!", sone); + return null; + } + sone.setClient(new Client(clientName, clientVersion)); + } + String soneRequestUri = soneXml.getValue("request-uri", null); if (soneRequestUri != null) { try { -- 2.7.4