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;
}
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;
}
}
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);
}
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;
}
}
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);
}
}
}
Aggregations