Search in sources :

Example 11 with MessageRecord

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

the class ConversationFragment method handleResendMessage.

private void handleResendMessage(final MessageRecord message) {
    final Context context = getActivity().getApplicationContext();
    new AsyncTask<MessageRecord, Void, Void>() {

        @Override
        protected Void doInBackground(MessageRecord... messageRecords) {
            MessageSender.resend(context, masterSecret, messageRecords[0]);
            return null;
        }
    }.execute(message);
}
Also used : Context(android.content.Context) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)

Example 12 with MessageRecord

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

the class MasterSecretDecryptJob method onRun.

@Override
public void onRun(MasterSecret masterSecret) {
    EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
    SmsDatabase.Reader smsReader = smsDatabase.getDecryptInProgressMessages(masterSecret);
    SmsMessageRecord smsRecord;
    while ((smsRecord = smsReader.getNext()) != null) {
        try {
            String body = getAsymmetricDecryptedBody(masterSecret, smsRecord.getBody().getBody());
            smsDatabase.updateMessageBody(new MasterSecretUnion(masterSecret), smsRecord.getId(), body);
        } catch (InvalidMessageException e) {
            Log.w(TAG, e);
        }
    }
    MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context);
    MmsDatabase.Reader mmsReader = mmsDatabase.getDecryptInProgressMessages(masterSecret);
    MessageRecord mmsRecord;
    while ((mmsRecord = mmsReader.getNext()) != null) {
        try {
            String body = getAsymmetricDecryptedBody(masterSecret, mmsRecord.getBody().getBody());
            mmsDatabase.updateMessageBody(new MasterSecretUnion(masterSecret), mmsRecord.getId(), body);
        } catch (InvalidMessageException e) {
            Log.w(TAG, e);
        }
    }
    smsReader.close();
    mmsReader.close();
    MessageNotifier.updateNotification(context, masterSecret);
}
Also used : MasterSecretUnion(org.thoughtcrime.securesms.crypto.MasterSecretUnion) InvalidMessageException(org.whispersystems.libsignal.InvalidMessageException) SmsMessageRecord(org.thoughtcrime.securesms.database.model.SmsMessageRecord) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase) SmsDatabase(org.thoughtcrime.securesms.database.SmsDatabase) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) SmsMessageRecord(org.thoughtcrime.securesms.database.model.SmsMessageRecord) MmsDatabase(org.thoughtcrime.securesms.database.MmsDatabase)

Aggregations

MessageRecord (org.thoughtcrime.securesms.database.model.MessageRecord)12 MediaMmsMessageRecord (org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)6 MmsMessageRecord (org.thoughtcrime.securesms.database.model.MmsMessageRecord)5 Cursor (android.database.Cursor)3 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 ClipboardManager (android.text.ClipboardManager)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)1 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)1 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)1 MmsSmsDatabase (org.thoughtcrime.securesms.database.MmsSmsDatabase)1 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)1 SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)1 SlideDeck (org.thoughtcrime.securesms.mms.SlideDeck)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1 Recipients (org.thoughtcrime.securesms.recipients.Recipients)1 ProgressDialogAsyncTask (org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask)1