Search in sources :

Example 6 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method sendTyping.

public void sendTyping(List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, SignalServiceTypingMessage message, CancelationSignal cancelationSignal) throws IOException {
    Content content = createTypingContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), envelopeContent, true, null, cancelationSignal);
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 7 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method sendGroupDataMessage.

/**
 * Sends a {@link SignalServiceDataMessage} to a group using sender keys.
 */
public List<SendMessageResult> sendGroupDataMessage(DistributionId distributionId, List<SignalServiceAddress> recipients, List<UnidentifiedAccess> unidentifiedAccess, boolean isRecipientUpdate, ContentHint contentHint, SignalServiceDataMessage message, SenderKeyGroupEvents sendEvents) throws IOException, UntrustedIdentityException, NoSessionException, InvalidKeyException, InvalidRegistrationIdException {
    Log.d(TAG, "[" + message.getTimestamp() + "] Sending a group data message to " + recipients.size() + " recipients using DistributionId " + distributionId);
    Content content = createMessageContent(message);
    Optional<byte[]> groupId = message.getGroupId();
    List<SendMessageResult> results = sendGroupMessage(distributionId, recipients, unidentifiedAccess, message.getTimestamp(), content, contentHint, groupId.orNull(), false, sendEvents);
    sendEvents.onMessageSent();
    if (store.isMultiDevice()) {
        Content syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.absent(), message.getTimestamp(), results, isRecipientUpdate);
        EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
        sendMessage(localAddress, Optional.absent(), message.getTimestamp(), syncMessageContent, false, null);
    }
    sendEvents.onSyncMessageSent();
    return results;
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 8 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method sendDataMessage.

/**
 * Send a message to a single recipient.
 *
 * @param recipient The message's destination.
 * @param message The message.
 * @throws UntrustedIdentityException
 * @throws IOException
 */
public SendMessageResult sendDataMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, ContentHint contentHint, SignalServiceDataMessage message, IndividualSendEvents sendEvents) throws UntrustedIdentityException, IOException {
    Log.d(TAG, "[" + message.getTimestamp() + "] Sending a data message.");
    Content content = createMessageContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, contentHint, message.getGroupId());
    sendEvents.onMessageEncrypted();
    long timestamp = message.getTimestamp();
    SendMessageResult result = sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, envelopeContent, false, null);
    sendEvents.onMessageSent();
    if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) {
        Content syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.of(recipient), timestamp, Collections.singletonList(result), false);
        EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
        sendMessage(localAddress, Optional.absent(), timestamp, syncMessageContent, false, null);
    }
    sendEvents.onSyncMessageSent();
    return result;
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 9 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

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);
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 10 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendDataMessage.

/**
 * Send a message to a single recipient.
 *
 * @param recipient The message's destination.
 * @param message The message.
 * @throws UntrustedIdentityException
 * @throws IOException
 */
public SendMessageResult sendDataMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, ContentHint contentHint, SignalServiceDataMessage message, IndividualSendEvents sendEvents) throws UntrustedIdentityException, IOException {
    Log.d(TAG, "[" + message.getTimestamp() + "] Sending a data message.");
    Content content = createMessageContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, contentHint, message.getGroupId());
    sendEvents.onMessageEncrypted();
    long timestamp = message.getTimestamp();
    SendMessageResult result = sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, envelopeContent, false, null);
    sendEvents.onMessageSent();
    if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) {
        Content syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.of(recipient), timestamp, Collections.singletonList(result), false);
        EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
        sendMessage(localAddress, Optional.absent(), timestamp, syncMessageContent, false, null);
    }
    sendEvents.onSyncMessageSent();
    return result;
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Aggregations

EnvelopeContent (org.whispersystems.signalservice.api.crypto.EnvelopeContent)28 PlaintextContent (org.whispersystems.libsignal.protocol.PlaintextContent)26 Content (org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content)24 SendMessageResult (org.whispersystems.signalservice.api.messages.SendMessageResult)8 NullMessage (org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage)4 ByteString (com.google.protobuf.ByteString)2 IOException (java.io.IOException)2 UnidentifiedAccess (org.whispersystems.signalservice.api.crypto.UnidentifiedAccess)2 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)2