org.whispersystems.textsecure.api.messages.TextSecureAttachmentPointer Maven / Gradle / Ivy
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package org.whispersystems.textsecure.api.messages;
import org.whispersystems.libaxolotl.util.guava.Optional;
/**
* Represents a received TextSecureMessage attachment "handle." This
* is a pointer to the actual attachment content, which needs to be
* retrieved using {@link org.whispersystems.textsecure.api.TextSecureMessageReceiver#retrieveAttachment(TextSecureAttachmentPointer, java.io.File)}
*
* @author Moxie Marlinspike
*/
public class TextSecureAttachmentPointer extends TextSecureAttachment {
private final long id;
private final byte[] key;
private final Optional relay;
private final Optional size;
private final Optional preview;
public TextSecureAttachmentPointer(long id, String contentType, byte[] key, String relay) {
this(id, contentType, key, relay, Optional.absent(), Optional.absent());
}
public TextSecureAttachmentPointer(long id, String contentType, byte[] key, String relay,
Optional size, Optional preview)
{
super(contentType);
this.id = id;
this.key = key;
this.relay = Optional.fromNullable(relay);
this.size = size;
this.preview = preview;
}
public long getId() {
return id;
}
public byte[] getKey() {
return key;
}
@Override
public boolean isStream() {
return false;
}
@Override
public boolean isPointer() {
return true;
}
public Optional getRelay() {
return relay;
}
public Optional getSize() {
return size;
}
public Optional getPreview() {
return preview;
}
}