use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.
the class SignalServiceMessageSender method resendContent.
/**
* Resend a previously-sent message.
*/
public SendMessageResult resendContent(SignalServiceAddress address, Optional<UnidentifiedAccessPair> unidentifiedAccess, long timestamp, Content content, ContentHint contentHint, Optional<byte[]> groupId) throws UntrustedIdentityException, IOException {
EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, contentHint, groupId);
Optional<UnidentifiedAccess> access = unidentifiedAccess.isPresent() ? unidentifiedAccess.get().getTargetUnidentifiedAccess() : Optional.absent();
return sendMessage(address, access, timestamp, envelopeContent, false, null);
}
use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.
the class SignalServiceMessageSender method sendTyping.
/**
* Send a typing indicator.
*
* @param recipient The destination
* @param message The typing indicator to deliver
*/
public void sendTyping(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceTypingMessage message) throws IOException, UntrustedIdentityException {
Content content = createTypingContent(message);
EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), envelopeContent, true, null);
}
use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.
the class SignalServiceMessageSender method sendDataMessage.
/**
* Sends a message to a group using client-side fanout.
*
* @param partialListener A listener that will be called when an individual send is completed. Will be invoked on an arbitrary background thread, *not*
* the calling thread.
*/
public List<SendMessageResult> sendDataMessage(List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, boolean isRecipientUpdate, ContentHint contentHint, SignalServiceDataMessage message, LegacyGroupEvents sendEvents, PartialSendCompleteListener partialListener, CancelationSignal cancelationSignal) throws IOException, UntrustedIdentityException {
Log.d(TAG, "[" + message.getTimestamp() + "] Sending a data message to " + recipients.size() + " recipients.");
Content content = createMessageContent(message);
EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, contentHint, message.getGroupId());
long timestamp = message.getTimestamp();
List<SendMessageResult> results = sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, envelopeContent, false, partialListener, cancelationSignal);
boolean needsSyncInResults = false;
sendEvents.onMessageSent();
for (SendMessageResult result : results) {
if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) {
needsSyncInResults = true;
break;
}
}
if (needsSyncInResults || store.isMultiDevice()) {
Optional<SignalServiceAddress> recipient = Optional.absent();
if (!message.getGroupContext().isPresent() && recipients.size() == 1) {
recipient = Optional.of(recipients.get(0));
}
Content syncMessage = createMultiDeviceSentTranscriptContent(content, recipient, timestamp, results, isRecipientUpdate);
EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
sendMessage(localAddress, Optional.absent(), timestamp, syncMessageContent, false, null);
}
sendEvents.onSyncMessageSent();
return results;
}
use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.
the class SignalServiceMessageSender method sendVerifiedSyncMessage.
private SendMessageResult sendVerifiedSyncMessage(VerifiedMessage message) throws IOException, UntrustedIdentityException {
byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
Content content = Content.newBuilder().setNullMessage(nullMessage).build();
EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
SendMessageResult result = sendMessage(message.getDestination(), Optional.absent(), message.getTimestamp(), envelopeContent, false, null);
if (result.getSuccess().isNeedsSync()) {
Content syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray());
EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
sendMessage(localAddress, Optional.absent(), message.getTimestamp(), syncMessageContent, false, null);
}
return result;
}
use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.
the class SignalServiceMessageSender method sendCallMessage.
public List<SendMessageResult> sendCallMessage(List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, SignalServiceCallMessage message) throws IOException {
Content content = createCallContent(message);
EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.DEFAULT, Optional.absent());
return sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), System.currentTimeMillis(), envelopeContent, false, null, null);
}
Aggregations