Search in sources :

Example 11 with Recipient

use of org.thoughtcrime.securesms.recipients.Recipient in project Signal-Android by WhisperSystems.

the class WebRtcCallService method getRemoteRecipient.

///
@NonNull
private Recipient getRemoteRecipient(Intent intent) {
    String remoteNumber = intent.getStringExtra(EXTRA_REMOTE_NUMBER);
    if (TextUtils.isEmpty(remoteNumber))
        throw new AssertionError("No recipient in intent!");
    Recipients recipients = RecipientFactory.getRecipientsFromString(this, remoteNumber, true);
    Recipient result = recipients.getPrimaryRecipient();
    if (result == null)
        throw new AssertionError("Recipient lookup failed!");
    else
        return result;
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NonNull(android.support.annotation.NonNull)

Example 12 with Recipient

use of org.thoughtcrime.securesms.recipients.Recipient in project Signal-Android by WhisperSystems.

the class MessageSender method isPushMediaSend.

private static boolean isPushMediaSend(Context context, Recipients recipients) {
    try {
        if (!TextSecurePreferences.isPushRegistered(context)) {
            return false;
        }
        if (recipients.getRecipientsList().size() > 1) {
            return false;
        }
        Recipient recipient = recipients.getPrimaryRecipient();
        String destination = Util.canonicalizeNumber(context, recipient.getNumber());
        return isPushDestination(context, destination);
    } catch (InvalidNumberException e) {
        Log.w(TAG, e);
        return false;
    }
}
Also used : InvalidNumberException(org.whispersystems.signalservice.api.util.InvalidNumberException) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Example 13 with Recipient

use of org.thoughtcrime.securesms.recipients.Recipient in project Signal-Android by WhisperSystems.

the class WebRtcCallService method handleBusyMessage.

private void handleBusyMessage(Intent intent) {
    Log.w(TAG, "handleBusyMessage...");
    Recipient recipient = getRemoteRecipient(intent);
    long callId = getCallId(intent);
    if (callState != CallState.STATE_DIALING || !Util.isEquals(this.callId, callId) || !recipient.equals(this.recipient)) {
        Log.w(TAG, "Got busy message for inactive session...");
        return;
    }
    sendMessage(WebRtcViewModel.State.CALL_BUSY, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
    audioManager.startOutgoingRinger(OutgoingRinger.Type.BUSY);
    serviceHandler.postDelayed(new Runnable() {

        @Override
        public void run() {
            WebRtcCallService.this.terminate();
        }
    }, WebRtcCallActivity.BUSY_SIGNAL_DELAY_FINISH);
}
Also used : Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Example 14 with Recipient

use of org.thoughtcrime.securesms.recipients.Recipient in project Signal-Android by WhisperSystems.

the class MessageSender method isPushTextSend.

private static boolean isPushTextSend(Context context, Recipients recipients, boolean keyExchange) {
    try {
        if (!TextSecurePreferences.isPushRegistered(context)) {
            return false;
        }
        if (keyExchange) {
            return false;
        }
        Recipient recipient = recipients.getPrimaryRecipient();
        String destination = Util.canonicalizeNumber(context, recipient.getNumber());
        return isPushDestination(context, destination);
    } catch (InvalidNumberException e) {
        Log.w(TAG, e);
        return false;
    }
}
Also used : InvalidNumberException(org.whispersystems.signalservice.api.util.InvalidNumberException) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Example 15 with Recipient

use of org.thoughtcrime.securesms.recipients.Recipient in project Signal-Android by WhisperSystems.

the class PushGroupSendJob method onPushSend.

@Override
public void onPushSend(MasterSecret masterSecret) throws MmsException, IOException, NoSuchMessageException {
    MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
    OutgoingMediaMessage message = database.getOutgoingMessage(masterSecret, messageId);
    try {
        deliver(masterSecret, message, filterRecipientId);
        database.markAsSent(messageId, true);
        markAttachmentsUploaded(messageId, message.getAttachments());
        if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
            database.markExpireStarted(messageId);
            ApplicationContext.getInstance(context).getExpiringMessageManager().scheduleDeletion(messageId, true, message.getExpiresIn());
        }
    } catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
        Log.w(TAG, e);
        database.markAsSentFailed(messageId);
        notifyMediaMessageDeliveryFailed(context, messageId);
    } catch (EncapsulatedExceptions e) {
        Log.w(TAG, e);
        List<NetworkFailure> failures = new LinkedList<>();
        for (NetworkFailureException nfe : e.getNetworkExceptions()) {
            Recipient recipient = RecipientFactory.getRecipientsFromString(context, nfe.getE164number(), false).getPrimaryRecipient();
            failures.add(new NetworkFailure(recipient.getRecipientId()));
        }
        for (UntrustedIdentityException uie : e.getUntrustedIdentityExceptions()) {
            Recipient recipient = RecipientFactory.getRecipientsFromString(context, uie.getE164Number(), false).getPrimaryRecipient();
            database.addMismatchedIdentity(messageId, recipient.getRecipientId(), uie.getIdentityKey());
        }
        database.addFailures(messageId, failures);
        if (e.getNetworkExceptions().isEmpty() && e.getUntrustedIdentityExceptions().isEmpty()) {
            database.markAsSent(messageId, true);
            markAttachmentsUploaded(messageId, message.getAttachments());
        } else {
            database.markAsSentFailed(messageId);
            notifyMediaMessageDeliveryFailed(context, messageId);
        }
    }
}
Also used : EncapsulatedExceptions(org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) InvalidNumberException(org.whispersystems.signalservice.api.util.InvalidNumberException) OutgoingMediaMessage(org.thoughtcrime.securesms.mms.OutgoingMediaMessage) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NetworkFailure(org.thoughtcrime.securesms.database.documents.NetworkFailure) UndeliverableMessageException(org.thoughtcrime.securesms.transport.UndeliverableMessageException) LinkedList(java.util.LinkedList) List(java.util.List) NetworkFailureException(org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException) RecipientFormattingException(org.thoughtcrime.securesms.recipients.RecipientFormattingException) MmsDatabase(org.thoughtcrime.securesms.database.MmsDatabase)

Aggregations

Recipient (org.thoughtcrime.securesms.recipients.Recipient)26 View (android.view.View)5 Recipients (org.thoughtcrime.securesms.recipients.Recipients)5 InvalidNumberException (org.whispersystems.signalservice.api.util.InvalidNumberException)5 RecipientFormattingException (org.thoughtcrime.securesms.recipients.RecipientFormattingException)3 Intent (android.content.Intent)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 File (java.io.File)2 RecipientsAdapter (org.thoughtcrime.securesms.contacts.RecipientsAdapter)2 IdentityKey (org.whispersystems.libsignal.IdentityKey)2 SignalProtocolAddress (org.whispersystems.libsignal.SignalProtocolAddress)2 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 UiThread (android.support.annotation.UiThread)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1