Search in sources :

Example 6 with UndeliverableMessageException

use of org.thoughtcrime.securesms.transport.UndeliverableMessageException in project Signal-Android by WhisperSystems.

the class MmsSendJob method onSend.

@Override
public void onSend(MasterSecret masterSecret) throws MmsException, NoSuchMessageException, IOException {
    MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
    OutgoingMediaMessage message = database.getOutgoingMessage(masterSecret, messageId);
    try {
        SendReq pdu = constructSendPdu(masterSecret, message);
        validateDestinations(message, pdu);
        final byte[] pduBytes = getPduBytes(pdu);
        final SendConf sendConf = new CompatMmsConnection(context).send(pduBytes, message.getSubscriptionId());
        final MmsSendResult result = getSendResult(sendConf, pdu);
        database.markAsSent(messageId, false);
        markAttachmentsUploaded(messageId, message.getAttachments());
    } catch (UndeliverableMessageException | IOException e) {
        Log.w(TAG, e);
        database.markAsSentFailed(messageId);
        notifyMediaMessageDeliveryFailed(context, messageId);
    } catch (InsecureFallbackApprovalException e) {
        Log.w(TAG, e);
        database.markAsPendingInsecureSmsFallback(messageId);
        notifyMediaMessageDeliveryFailed(context, messageId);
    }
}
Also used : SendConf(ws.com.google.android.mms.pdu.SendConf) CompatMmsConnection(org.thoughtcrime.securesms.mms.CompatMmsConnection) MmsSendResult(org.thoughtcrime.securesms.mms.MmsSendResult) UndeliverableMessageException(org.thoughtcrime.securesms.transport.UndeliverableMessageException) OutgoingMediaMessage(org.thoughtcrime.securesms.mms.OutgoingMediaMessage) IOException(java.io.IOException) SendReq(ws.com.google.android.mms.pdu.SendReq) InsecureFallbackApprovalException(org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException) MmsDatabase(org.thoughtcrime.securesms.database.MmsDatabase)

Example 7 with UndeliverableMessageException

use of org.thoughtcrime.securesms.transport.UndeliverableMessageException in project Signal-Android by WhisperSystems.

the class SendJob method scaleAttachments.

protected List<Attachment> scaleAttachments(@NonNull MasterSecret masterSecret, @NonNull MediaConstraints constraints, @NonNull List<Attachment> attachments) throws UndeliverableMessageException {
    AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
    List<Attachment> results = new LinkedList<>();
    for (Attachment attachment : attachments) {
        try {
            if (constraints.isSatisfied(context, masterSecret, attachment)) {
                results.add(attachment);
            } else if (constraints.canResize(attachment)) {
                MediaStream resized = constraints.getResizedMedia(context, masterSecret, attachment);
                results.add(attachmentDatabase.updateAttachmentData(masterSecret, attachment, resized));
            } else {
                throw new UndeliverableMessageException("Size constraints could not be met!");
            }
        } catch (IOException | MmsException e) {
            throw new UndeliverableMessageException(e);
        }
    }
    return results;
}
Also used : MmsException(ws.com.google.android.mms.MmsException) MediaStream(org.thoughtcrime.securesms.mms.MediaStream) UndeliverableMessageException(org.thoughtcrime.securesms.transport.UndeliverableMessageException) Attachment(org.thoughtcrime.securesms.attachments.Attachment) IOException(java.io.IOException) AttachmentDatabase(org.thoughtcrime.securesms.database.AttachmentDatabase) LinkedList(java.util.LinkedList)

Example 8 with UndeliverableMessageException

use of org.thoughtcrime.securesms.transport.UndeliverableMessageException in project Signal-Android by WhisperSystems.

the class OutgoingLegacyMmsConnection method send.

@Override
@Nullable
public SendConf send(@NonNull byte[] pduBytes, int subscriptionId) throws UndeliverableMessageException {
    try {
        MmsRadio radio = MmsRadio.getInstance(context);
        if (isDirectConnect()) {
            Log.w(TAG, "Sending MMS directly without radio change...");
            try {
                return send(pduBytes, false, false);
            } catch (IOException e) {
                Log.w(TAG, e);
            }
        }
        Log.w(TAG, "Sending MMS with radio change and proxy...");
        radio.connect();
        try {
            try {
                return send(pduBytes, true, true);
            } catch (IOException e) {
                Log.w(TAG, e);
            }
            Log.w(TAG, "Sending MMS with radio change and without proxy...");
            try {
                return send(pduBytes, true, false);
            } catch (IOException ioe) {
                Log.w(TAG, ioe);
                throw new UndeliverableMessageException(ioe);
            }
        } finally {
            radio.disconnect();
        }
    } catch (MmsRadioException e) {
        Log.w(TAG, e);
        throw new UndeliverableMessageException(e);
    }
}
Also used : UndeliverableMessageException(org.thoughtcrime.securesms.transport.UndeliverableMessageException) IOException(java.io.IOException) Nullable(android.support.annotation.Nullable)

Aggregations

UndeliverableMessageException (org.thoughtcrime.securesms.transport.UndeliverableMessageException)8 IOException (java.io.IOException)5 Nullable (android.support.annotation.Nullable)2 LinkedList (java.util.LinkedList)2 Attachment (org.thoughtcrime.securesms.attachments.Attachment)2 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)2 OutgoingMediaMessage (org.thoughtcrime.securesms.mms.OutgoingMediaMessage)2 InsecureFallbackApprovalException (org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)2 InvalidNumberException (org.whispersystems.signalservice.api.util.InvalidNumberException)2 SendConf (ws.com.google.android.mms.pdu.SendConf)2 TargetApi (android.annotation.TargetApi)1 SmsManager (android.telephony.SmsManager)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 List (java.util.List)1 TimeoutException (java.util.concurrent.TimeoutException)1 AttachmentDatabase (org.thoughtcrime.securesms.database.AttachmentDatabase)1 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)1 NetworkFailure (org.thoughtcrime.securesms.database.documents.NetworkFailure)1 SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)1