use of org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream in project libsignal-service-java by signalapp.
the class DeviceGroupsInputStream method read.
public DeviceGroup read() throws IOException {
long detailsLength = readRawVarint32();
byte[] detailsSerialized = new byte[(int) detailsLength];
Util.readFully(in, detailsSerialized);
SignalServiceProtos.GroupDetails details = SignalServiceProtos.GroupDetails.parseFrom(detailsSerialized);
if (!details.hasId()) {
throw new IOException("ID missing on group record!");
}
byte[] id = details.getId().toByteArray();
Optional<String> name = Optional.fromNullable(details.getName());
List<String> members = details.getMembersList();
Optional<SignalServiceAttachmentStream> avatar = Optional.absent();
boolean active = details.getActive();
Optional<Integer> expirationTimer = Optional.absent();
if (details.hasAvatar()) {
long avatarLength = details.getAvatar().getLength();
InputStream avatarStream = new ChunkedInputStream.LimitedInputStream(in, avatarLength);
String avatarContentType = details.getAvatar().getContentType();
avatar = Optional.of(new SignalServiceAttachmentStream(avatarStream, avatarContentType, avatarLength, Optional.<String>absent(), false, null));
}
if (details.hasExpireTimer() && details.getExpireTimer() > 0) {
expirationTimer = Optional.of(details.getExpireTimer());
}
return new DeviceGroup(id, name, members, avatar, active, expirationTimer);
}
use of org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream in project Signal-Android by signalapp.
the class MultiDeviceContactUpdateJob method sendUpdate.
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile, boolean complete) throws IOException, UntrustedIdentityException, NetworkException {
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder().withStream(contactsFileStream).withContentType("application/octet-stream").withLength(contactsFile.length()).build();
try {
messageSender.sendMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
use of org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream in project Signal-Android by signalapp.
the class MultiDeviceGroupUpdateJob method sendUpdate.
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile) throws IOException, UntrustedIdentityException {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder().withStream(contactsFileStream).withContentType("application/octet-stream").withLength(contactsFile.length()).build();
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
}
use of org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream in project Signal-Android by WhisperSystems.
the class MultiDeviceContactUpdateJob method sendUpdate.
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile) throws IOException, UntrustedIdentityException, NetworkException {
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder().withStream(contactsFileStream).withContentType("application/octet-stream").withLength(contactsFile.length()).build();
try {
messageSender.sendMessage(SignalServiceSyncMessage.forContacts(attachmentStream));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
use of org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream in project Signal-Android by WhisperSystems.
the class MultiDeviceGroupUpdateJob method sendUpdate.
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile) throws IOException, UntrustedIdentityException {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder().withStream(contactsFileStream).withContentType("application/octet-stream").withLength(contactsFile.length()).build();
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
}
Aggregations