diff --git a/java/src/main/java/org/whispersystems/textsecure/api/TextSecureMessageReceiver.java b/java/src/main/java/org/whispersystems/textsecure/api/TextSecureMessageReceiver.java index 6684eb2991..093cb1f5e8 100644 --- a/java/src/main/java/org/whispersystems/textsecure/api/TextSecureMessageReceiver.java +++ b/java/src/main/java/org/whispersystems/textsecure/api/TextSecureMessageReceiver.java @@ -90,6 +90,25 @@ public class TextSecureMessageReceiver { * @throws IOException * @throws InvalidMessageException */ + public InputStream retrieveAttachment(TextSecureAttachmentPointer pointer, File destination) + throws IOException, InvalidMessageException + { + return retrieveAttachment(pointer, destination, null); + } + + + /** + * Retrieves a TextSecure attachment. + * + * @param pointer The {@link org.whispersystems.textsecure.api.messages.TextSecureAttachmentPointer} + * received in a {@link TextSecureDataMessage}. + * @param destination The download destination for this attachment. + * @param listener An optional listener (may be null) to receive callbacks on download progress. + * + * @return An InputStream that streams the plaintext attachment contents. + * @throws IOException + * @throws InvalidMessageException + */ public InputStream retrieveAttachment(TextSecureAttachmentPointer pointer, File destination, ProgressListener listener) throws IOException, InvalidMessageException { diff --git a/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureAttachment.java b/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureAttachment.java index cb1cab82aa..acbc09c827 100644 --- a/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureAttachment.java +++ b/java/src/main/java/org/whispersystems/textsecure/api/messages/TextSecureAttachment.java @@ -83,7 +83,17 @@ public abstract class TextSecureAttachment { } } + /** + * An interface to receive progress information on upload/download of + * an attachment. + */ public interface ProgressListener { + /** + * Called on a progress change event. + * + * @param total The total amount to transmit/receive in bytes. + * @param progress The amount that has been transmitted/received in bytes thus far + */ public void onAttachmentProgress(long total, long progress); } }