Search in sources :

Example 16 with SmsMessageRecord

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

the class SmsSentJob method handleSentResult.

private void handleSentResult(long messageId, int result) {
    try {
        MessageDatabase database = SignalDatabase.sms();
        SmsMessageRecord record = database.getSmsMessage(messageId);
        switch(result) {
            case Activity.RESULT_OK:
                database.markAsSent(messageId, false);
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                if (isMultipart) {
                    Log.w(TAG, "Service connectivity problem, but not retrying due to multipart");
                    database.markAsSentFailed(messageId);
                    ApplicationDependencies.getMessageNotifier().notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
                } else {
                    Log.w(TAG, "Service connectivity problem, requeuing...");
                    ApplicationDependencies.getJobManager().add(new SmsSendJob(messageId, record.getIndividualRecipient(), runAttempt + 1));
                }
                break;
            default:
                database.markAsSentFailed(messageId);
                ApplicationDependencies.getMessageNotifier().notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
        }
    } catch (NoSuchMessageException e) {
        Log.w(TAG, e);
    }
}
Also used : MessageDatabase(org.thoughtcrime.securesms.database.MessageDatabase) NoSuchMessageException(org.thoughtcrime.securesms.database.NoSuchMessageException) SmsMessageRecord(org.thoughtcrime.securesms.database.model.SmsMessageRecord)

Example 17 with SmsMessageRecord

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

the class SmsDatabase method getSmsMessage.

@Override
public SmsMessageRecord getSmsMessage(long messageId) throws NoSuchMessageException {
    SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, MESSAGE_PROJECTION, ID_WHERE, new String[] { messageId + "" }, null, null, null);
    Reader reader = new Reader(cursor);
    SmsMessageRecord record = reader.getNext();
    reader.close();
    if (record == null)
        throw new NoSuchMessageException("No message for ID: " + messageId);
    else
        return record;
}
Also used : SmsMessageRecord(org.thoughtcrime.securesms.database.model.SmsMessageRecord) Cursor(android.database.Cursor)

Aggregations

SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)17 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)4 MessageDatabase (org.thoughtcrime.securesms.database.MessageDatabase)4 NoSuchMessageException (org.thoughtcrime.securesms.database.NoSuchMessageException)4 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)4 ExpiringMessageManager (org.thoughtcrime.securesms.service.ExpiringMessageManager)4 Cursor (android.database.Cursor)3 InsecureFallbackApprovalException (org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)3 UndeliverableMessageException (org.thoughtcrime.securesms.transport.UndeliverableMessageException)3 UntrustedIdentityException (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException)3 ContentValues (android.content.ContentValues)2 Pair (android.util.Pair)2 SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)2 SyncMessageId (org.thoughtcrime.securesms.database.MessageDatabase.SyncMessageId)2 TrimThreadJob (org.thoughtcrime.securesms.jobs.TrimThreadJob)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)1 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)1 MmsSmsDatabase (org.thoughtcrime.securesms.database.MmsSmsDatabase)1 UnidentifiedAccessMode (org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode)1