From cd1bf20de75f12dbfca9f2a7c6dff11b9eb28ba2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 10 Apr 2011 20:08:45 +0200 Subject: [PATCH] Add methods to create and retrieve temporary images. --- .../java/net/pterodactylus/sone/core/Core.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 06a1467..70c0e7e 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -39,6 +39,7 @@ import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Profile.Field; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.data.TemporaryImage; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.IdentityListener; import net.pterodactylus.sone.freenet.wot.IdentityManager; @@ -173,6 +174,9 @@ public class Core implements IdentityListener, UpdateListener { /** All known images. */ private Map images = new HashMap(); + /** All temporary images. */ + private Map temporaryImages = new HashMap(); + /** * Creates a new core. * @@ -799,6 +803,20 @@ public class Core implements IdentityListener, UpdateListener { } } + /** + * Returns the temporary image with the given ID. + * + * @param imageId + * The ID of the temporary image + * @return The temporary image, or {@code null} if there is no temporary + * image with the given ID + */ + public TemporaryImage getTemporaryImage(String imageId) { + synchronized (temporaryImages) { + return temporaryImages.get(imageId); + } + } + // // ACTIONS // @@ -1775,6 +1793,24 @@ public class Core implements IdentityListener, UpdateListener { } /** + * Creates a new temporary image. + * + * @param mimeType + * The MIME type of the temporary image + * @param imageData + * The encoded data of the image + * @return The temporary image + */ + public TemporaryImage createTemporaryImage(String mimeType, byte[] imageData) { + TemporaryImage temporaryImage = new TemporaryImage(); + temporaryImage.setMimeType(mimeType).setImageData(imageData); + synchronized (temporaryImages) { + temporaryImages.put(temporaryImage.getId(), temporaryImage); + } + return temporaryImage; + } + + /** * Starts the core. */ public void start() { -- 2.7.4