Search in sources :

Example 6 with CompatMmsConnection

use of org.thoughtcrime.securesms.mms.CompatMmsConnection in project Signal-Android by WhisperSystems.

the class MmsSendJob method onSend.

@Override
public void onSend() throws MmsException, NoSuchMessageException, IOException {
    MessageDatabase database = SignalDatabase.mms();
    OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
    if (database.isSent(messageId)) {
        Log.w(TAG, "Message " + messageId + " was already sent. Ignoring.");
        return;
    }
    try {
        Log.i(TAG, "Sending message: " + messageId);
        SendReq pdu = constructSendPdu(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);
        Log.i(TAG, "Sent message: " + messageId);
    } 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(com.google.android.mms.pdu_alt.SendConf) CompatMmsConnection(org.thoughtcrime.securesms.mms.CompatMmsConnection) MessageDatabase(org.thoughtcrime.securesms.database.MessageDatabase) MmsSendResult(org.thoughtcrime.securesms.mms.MmsSendResult) UndeliverableMessageException(org.thoughtcrime.securesms.transport.UndeliverableMessageException) OutgoingMediaMessage(org.thoughtcrime.securesms.mms.OutgoingMediaMessage) IOException(java.io.IOException) SendReq(com.google.android.mms.pdu_alt.SendReq) InsecureFallbackApprovalException(org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)

Aggregations

IOException (java.io.IOException)6 CompatMmsConnection (org.thoughtcrime.securesms.mms.CompatMmsConnection)6 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)4 ApnUnavailableException (org.thoughtcrime.securesms.mms.ApnUnavailableException)3 MmsRadioException (org.thoughtcrime.securesms.mms.MmsRadioException)3 MmsSendResult (org.thoughtcrime.securesms.mms.MmsSendResult)3 OutgoingMediaMessage (org.thoughtcrime.securesms.mms.OutgoingMediaMessage)3 InsecureFallbackApprovalException (org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)3 UndeliverableMessageException (org.thoughtcrime.securesms.transport.UndeliverableMessageException)3 RetrieveConf (com.google.android.mms.pdu_alt.RetrieveConf)2 SendConf (com.google.android.mms.pdu_alt.SendConf)2 SendReq (com.google.android.mms.pdu_alt.SendReq)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MessageDatabase (org.thoughtcrime.securesms.database.MessageDatabase)2 MmsException (org.thoughtcrime.securesms.mms.MmsException)2 DuplicateMessageException (org.whispersystems.libsignal.DuplicateMessageException)2 InvalidMessageException (org.whispersystems.libsignal.InvalidMessageException)2 LegacyMessageException (org.whispersystems.libsignal.LegacyMessageException)2 NoSessionException (org.whispersystems.libsignal.NoSessionException)2 Pair (android.util.Pair)1