From: David ‘Bombe’ Roden Date: Fri, 23 May 2008 14:47:23 +0000 (+0000) Subject: forward generated URI to listeners X-Git-Tag: v0.1.1~120 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c6d398abde5664ea2c8c01532e53d634a67bcc09;p=jFCPlib.git forward generated URI to listeners git-svn-id: http://trooper/svn/projects/jFCPlib/branch/high-level-client@936 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java b/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java index b7064d0..11a4c98 100644 --- a/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java +++ b/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java @@ -1237,7 +1237,13 @@ public class HighLevelClient { * net.pterodactylus.fcp.URIGenerated) */ public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated) { - /* TODO */ + if (fcpConnection != HighLevelClient.this.fcpConnection) { + return; + } + String identifier = uriGenerated.getIdentifier(); + /* TODO - check inserts */ + HighLevelProgress highLevelProgress = new HighLevelProgress(identifier, uriGenerated.getURI()); + fireProgressReceived(identifier, highLevelProgress); } /** diff --git a/src/net/pterodactylus/fcp/highlevel/HighLevelProgress.java b/src/net/pterodactylus/fcp/highlevel/HighLevelProgress.java index 403ac30..32f0884 100644 --- a/src/net/pterodactylus/fcp/highlevel/HighLevelProgress.java +++ b/src/net/pterodactylus/fcp/highlevel/HighLevelProgress.java @@ -30,10 +30,12 @@ package net.pterodactylus.fcp.highlevel; * request has failed or succeeded. Other fields are not set. If the request is * not yet finished, {@link #isFetchable()} will tell you whether the request * has progressed to a state that allows other clients to fetch the inserted - * data. This is of course only valid for Put and PutDir requests. If none of - * those methods return true, you can use the block count - * methods to get detailed progress statistics. When progress you received is a - * {@link DownloadResult} you do not need to check + * data. This is of course only valid for Put and PutDir requests. Alternatively + * {@link #getURI()} can return a non-null value which signals + * that the request generated a URI. If none of those methods return + * true, you can use the block count methods to get detailed + * progress statistics. When progress you received is a {@link DownloadResult} + * you do not need to check * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ @@ -46,6 +48,9 @@ public class HighLevelProgress extends HighLevelResult { /** Whether a Put request should be fetchable now. */ private boolean fetchable; + /** The generated URI, in case of a Put request. */ + private String uri; + /** The number of total blocks. */ private int totalBlocks; @@ -90,6 +95,20 @@ public class HighLevelProgress extends HighLevelResult { } /** + * Creates a new high-level progress for a Put or PutDir request that + * generated a URI. + * + * @param identifier + * The identifier of the request + * @param uri + * The URI of the request + */ + public HighLevelProgress(String identifier, String uri) { + this(identifier); + this.uri = uri; + } + + /** * Creates a new high-level progress with the given values. * * @param identifier @@ -164,6 +183,26 @@ public class HighLevelProgress extends HighLevelResult { } /** + * Returns the URI that was generated by the request. Of course only Put and + * PutDir requests will generated URIs. + * + * @return The generated URI + */ + public String getURI() { + return uri; + } + + /** + * Sets the URI generated by the request. + * + * @param uri + * The generated URI + */ + void setURI(String uri) { + this.uri = uri; + } + + /** * Returns the number of total blocks. * * @return The number of total blocks