Java Code Examples for org.whispersystems.signalservice.api.messages.SignalServiceAttachment#asPointer()
The following examples show how to use
org.whispersystems.signalservice.api.messages.SignalServiceAttachment#asPointer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonAttachment.java From signald with GNU General Public License v3.0 | 5 votes |
JsonAttachment(SignalServiceAttachment attachment, String username) throws IOException, NoSuchAccountException { this.contentType = attachment.getContentType(); final SignalServiceAttachmentPointer pointer = attachment.asPointer(); if (attachment.isPointer()) { this.id = pointer.getId(); this.key = Base64.encodeBytes(pointer.getKey()); if (pointer.getSize().isPresent()) { this.size = pointer.getSize().get(); } if(pointer.getPreview().isPresent()) { this.preview = Base64.encodeBytes(pointer.getPreview().get()); } if(pointer.getDigest().isPresent()) { this.digest = Base64.encodeBytes(pointer.getDigest().get()); } this.voiceNote = pointer.getVoiceNote(); this.width = pointer.getWidth(); this.height = pointer.getHeight(); if(pointer.getCaption().isPresent()) { this.caption = pointer.getCaption().get(); } if(pointer.getBlurHash().isPresent()) { this.blurhash = pointer.getBlurHash().get(); } File file = Manager.get(username).getAttachmentFile(pointer.getId()); if(file.exists()) { this.storedFilename = file.toString(); } } }
Example 2
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
private File retrieveContactAvatarAttachment(SignalServiceAttachment attachment, String number) throws IOException, InvalidMessageException, MissingConfigurationException { IOUtils.createPrivateDirectories(pathConfig.getAvatarsPath()); if (attachment.isPointer()) { SignalServiceAttachmentPointer pointer = attachment.asPointer(); return retrieveAttachment(pointer, getContactAvatarFile(number), false); } else { SignalServiceAttachmentStream stream = attachment.asStream(); return Utils.retrieveAttachment(stream, getContactAvatarFile(number)); } }
Example 3
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
private File retrieveGroupAvatarAttachment(SignalServiceAttachment attachment, byte[] groupId) throws IOException, InvalidMessageException, MissingConfigurationException { IOUtils.createPrivateDirectories(pathConfig.getAvatarsPath()); if (attachment.isPointer()) { SignalServiceAttachmentPointer pointer = attachment.asPointer(); return retrieveAttachment(pointer, getGroupAvatarFile(groupId), false); } else { SignalServiceAttachmentStream stream = attachment.asStream(); return Utils.retrieveAttachment(stream, getGroupAvatarFile(groupId)); } }
Example 4
Source File: JsonAttachment.java From signal-cli with GNU General Public License v3.0 | 5 votes |
JsonAttachment(SignalServiceAttachment attachment) { this.contentType = attachment.getContentType(); final SignalServiceAttachmentPointer pointer = attachment.asPointer(); if (attachment.isPointer()) { this.id = String.valueOf(pointer.getRemoteId()); if (pointer.getFileName().isPresent()) { this.filename = pointer.getFileName().get(); } if (pointer.getSize().isPresent()) { this.size = pointer.getSize().get(); } } }
Example 5
Source File: ReceiveMessageHandler.java From signal-cli with GNU General Public License v3.0 | 5 votes |
private void printAttachment(SignalServiceAttachment attachment) { System.out.println("- " + attachment.getContentType() + " (" + (attachment.isPointer() ? "Pointer" : "") + (attachment.isStream() ? "Stream" : "") + ")"); if (attachment.isPointer()) { final SignalServiceAttachmentPointer pointer = attachment.asPointer(); System.out.println(" Id: " + pointer.getRemoteId() + " Key length: " + pointer.getKey().length); System.out.println(" Filename: " + (pointer.getFileName().isPresent() ? pointer.getFileName().get() : "-")); System.out.println(" Size: " + (pointer.getSize().isPresent() ? pointer.getSize().get() + " bytes" : "<unavailable>") + (pointer.getPreview().isPresent() ? " (Preview is available: " + pointer.getPreview().get().length + " bytes)" : "")); System.out.println(" Voice note: " + (pointer.getVoiceNote() ? "yes" : "no")); System.out.println(" Dimensions: " + pointer.getWidth() + "x" + pointer.getHeight()); File file = m.getAttachmentFile(pointer.getRemoteId()); if (file.exists()) { System.out.println(" Stored plaintext in: " + file); } } }