Search in sources :

Example 1 with NoSuchMessageException

use of org.thoughtcrime.securesms.database.NoSuchMessageException in project Signal-Android by WhisperSystems.

the class SmsSentJob method handleSentResult.

private void handleSentResult(MasterSecret masterSecret, long messageId, int result) {
    try {
        EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
        SmsMessageRecord record = database.getMessage(masterSecret, messageId);
        switch(result) {
            case Activity.RESULT_OK:
                database.markAsSent(messageId, false);
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                Log.w(TAG, "Service connectivity problem, requeuing...");
                ApplicationContext.getInstance(context).getJobManager().add(new SmsSendJob(context, messageId, record.getIndividualRecipient().getNumber()));
                break;
            default:
                database.markAsSentFailed(messageId);
                MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
        }
    } catch (NoSuchMessageException e) {
        Log.w(TAG, e);
    }
}
Also used : NoSuchMessageException(org.thoughtcrime.securesms.database.NoSuchMessageException) SmsMessageRecord(org.thoughtcrime.securesms.database.model.SmsMessageRecord) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase)

Aggregations

EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)1 NoSuchMessageException (org.thoughtcrime.securesms.database.NoSuchMessageException)1 SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)1