Search in sources :

Example 1 with UnregisteredUserException

use of org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException in project Signal-Android by WhisperSystems.

the class PushMediaSendJob method deliver.

private void deliver(MasterSecret masterSecret, OutgoingMediaMessage message) throws RetryLaterException, InsecureFallbackApprovalException, UntrustedIdentityException, UndeliverableMessageException {
    if (message.getRecipients() == null || message.getRecipients().getPrimaryRecipient() == null || message.getRecipients().getPrimaryRecipient().getNumber() == null) {
        throw new UndeliverableMessageException("No destination address.");
    }
    SignalServiceMessageSender messageSender = messageSenderFactory.create();
    try {
        SignalServiceAddress address = getPushAddress(message.getRecipients().getPrimaryRecipient().getNumber());
        List<Attachment> scaledAttachments = scaleAttachments(masterSecret, MediaConstraints.PUSH_CONSTRAINTS, message.getAttachments());
        List<SignalServiceAttachment> attachmentStreams = getAttachmentsFor(masterSecret, scaledAttachments);
        SignalServiceDataMessage mediaMessage = SignalServiceDataMessage.newBuilder().withBody(message.getBody()).withAttachments(attachmentStreams).withTimestamp(message.getSentTimeMillis()).withExpiration((int) (message.getExpiresIn() / 1000)).asExpirationUpdate(message.isExpirationUpdate()).build();
        messageSender.sendMessage(address, mediaMessage);
    } catch (InvalidNumberException | UnregisteredUserException e) {
        Log.w(TAG, e);
        throw new InsecureFallbackApprovalException(e);
    } catch (FileNotFoundException e) {
        Log.w(TAG, e);
        throw new UndeliverableMessageException(e);
    } catch (IOException e) {
        Log.w(TAG, e);
        throw new RetryLaterException(e);
    }
}
Also used : UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) InvalidNumberException(org.whispersystems.signalservice.api.util.InvalidNumberException) FileNotFoundException(java.io.FileNotFoundException) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) SignalServiceAttachment(org.whispersystems.signalservice.api.messages.SignalServiceAttachment) Attachment(org.thoughtcrime.securesms.attachments.Attachment) IOException(java.io.IOException) InsecureFallbackApprovalException(org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException) SignalServiceAttachment(org.whispersystems.signalservice.api.messages.SignalServiceAttachment) SignalServiceDataMessage(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage) UndeliverableMessageException(org.thoughtcrime.securesms.transport.UndeliverableMessageException) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) RetryLaterException(org.thoughtcrime.securesms.transport.RetryLaterException)

Example 2 with UnregisteredUserException

use of org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException in project Signal-Android by WhisperSystems.

the class PushTextSendJob method deliver.

private void deliver(SmsMessageRecord message) throws UntrustedIdentityException, InsecureFallbackApprovalException, RetryLaterException {
    try {
        SignalServiceAddress address = getPushAddress(message.getIndividualRecipient().getNumber());
        SignalServiceMessageSender messageSender = messageSenderFactory.create();
        SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder().withTimestamp(message.getDateSent()).withBody(message.getBody().getBody()).withExpiration((int) (message.getExpiresIn() / 1000)).asEndSessionMessage(message.isEndSession()).build();
        messageSender.sendMessage(address, textSecureMessage);
    } catch (InvalidNumberException | UnregisteredUserException e) {
        Log.w(TAG, e);
        throw new InsecureFallbackApprovalException(e);
    } catch (IOException e) {
        Log.w(TAG, e);
        throw new RetryLaterException(e);
    }
}
Also used : SignalServiceDataMessage(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) InvalidNumberException(org.whispersystems.signalservice.api.util.InvalidNumberException) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) RetryLaterException(org.thoughtcrime.securesms.transport.RetryLaterException) IOException(java.io.IOException) InsecureFallbackApprovalException(org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)

Example 3 with UnregisteredUserException

use of org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException in project Signal-Android by WhisperSystems.

the class WebRtcCallService method handleOutgoingCall.

private void handleOutgoingCall(Intent intent) {
    Log.w(TAG, "handleOutgoingCall...");
    if (callState != CallState.STATE_IDLE)
        throw new IllegalStateException("Dialing from non-idle?");
    try {
        this.callState = CallState.STATE_DIALING;
        this.recipient = getRemoteRecipient(intent);
        this.callId = SecureRandom.getInstance("SHA1PRNG").nextLong();
        this.pendingIceUpdates = new LinkedList<>();
        initializeVideo();
        sendMessage(WebRtcViewModel.State.CALL_OUTGOING, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
        lockManager.updatePhoneState(LockManager.PhoneState.IN_CALL);
        audioManager.initializeAudioForCall();
        audioManager.startOutgoingRinger(OutgoingRinger.Type.SONAR);
        bluetoothStateManager.setWantsConnection(true);
        setCallInProgressNotification(TYPE_OUTGOING_RINGING, recipient);
        DatabaseFactory.getSmsDatabase(this).insertOutgoingCall(recipient.getNumber());
        timeoutExecutor.schedule(new TimeoutRunnable(this.callId), 2, TimeUnit.MINUTES);
        retrieveTurnServers().addListener(new SuccessOnlyListener<List<PeerConnection.IceServer>>(this.callState, this.callId) {

            @Override
            public void onSuccessContinue(List<PeerConnection.IceServer> result) {
                try {
                    boolean isAlwaysTurn = TextSecurePreferences.isTurnOnly(WebRtcCallService.this);
                    WebRtcCallService.this.peerConnection = new PeerConnectionWrapper(WebRtcCallService.this, peerConnectionFactory, WebRtcCallService.this, localRenderer, result, isAlwaysTurn);
                    WebRtcCallService.this.dataChannel = WebRtcCallService.this.peerConnection.createDataChannel(DATA_CHANNEL_NAME);
                    WebRtcCallService.this.dataChannel.registerObserver(WebRtcCallService.this);
                    SessionDescription sdp = WebRtcCallService.this.peerConnection.createOffer(new MediaConstraints());
                    WebRtcCallService.this.peerConnection.setLocalDescription(sdp);
                    Log.w(TAG, "Sending offer: " + sdp.description);
                    ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forOffer(new OfferMessage(WebRtcCallService.this.callId, sdp.description)));
                    listenableFutureTask.addListener(new FailureListener<Boolean>(callState, callId) {

                        @Override
                        public void onFailureContinue(Throwable error) {
                            Log.w(TAG, error);
                            if (error instanceof UntrustedIdentityException) {
                                sendMessage(WebRtcViewModel.State.UNTRUSTED_IDENTITY, recipient, ((UntrustedIdentityException) error).getIdentityKey(), localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
                            } else if (error instanceof UnregisteredUserException) {
                                sendMessage(WebRtcViewModel.State.NO_SUCH_USER, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
                            } else if (error instanceof IOException) {
                                sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
                            }
                            terminate();
                        }
                    });
                } catch (PeerConnectionException e) {
                    Log.w(TAG, e);
                    terminate();
                }
            }
        });
    } catch (NoSuchAlgorithmException e) {
        throw new AssertionError(e);
    }
}
Also used : SessionDescription(org.webrtc.SessionDescription) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) PeerConnection(org.webrtc.PeerConnection) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) PeerConnectionWrapper(org.thoughtcrime.securesms.webrtc.PeerConnectionWrapper) MediaConstraints(org.webrtc.MediaConstraints) ListenableFutureTask(org.thoughtcrime.securesms.util.ListenableFutureTask) PeerConnectionException(org.thoughtcrime.securesms.webrtc.PeerConnectionWrapper.PeerConnectionException) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

IOException (java.io.IOException)3 UnregisteredUserException (org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException)3 InsecureFallbackApprovalException (org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)2 RetryLaterException (org.thoughtcrime.securesms.transport.RetryLaterException)2 SignalServiceMessageSender (org.whispersystems.signalservice.api.SignalServiceMessageSender)2 SignalServiceDataMessage (org.whispersystems.signalservice.api.messages.SignalServiceDataMessage)2 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)2 InvalidNumberException (org.whispersystems.signalservice.api.util.InvalidNumberException)2 FileNotFoundException (java.io.FileNotFoundException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Attachment (org.thoughtcrime.securesms.attachments.Attachment)1 UndeliverableMessageException (org.thoughtcrime.securesms.transport.UndeliverableMessageException)1 ListenableFutureTask (org.thoughtcrime.securesms.util.ListenableFutureTask)1 PeerConnectionWrapper (org.thoughtcrime.securesms.webrtc.PeerConnectionWrapper)1 PeerConnectionException (org.thoughtcrime.securesms.webrtc.PeerConnectionWrapper.PeerConnectionException)1 MediaConstraints (org.webrtc.MediaConstraints)1 PeerConnection (org.webrtc.PeerConnection)1 SessionDescription (org.webrtc.SessionDescription)1