Search in sources :

Example 11 with ExpiringMessageManager

use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by signalapp.

the class MessageSender method sendLocalTextSelf.

private static void sendLocalTextSelf(Context context, long messageId) {
    try {
        ExpiringMessageManager expirationManager = ApplicationDependencies.getExpiringMessageManager();
        MessageDatabase smsDatabase = SignalDatabase.sms();
        MmsSmsDatabase mmsSmsDatabase = SignalDatabase.mmsSms();
        SmsMessageRecord message = smsDatabase.getSmsMessage(messageId);
        SyncMessageId syncId = new SyncMessageId(Recipient.self().getId(), message.getDateSent());
        smsDatabase.markAsSent(messageId, true);
        smsDatabase.markUnidentified(messageId, true);
        mmsSmsDatabase.incrementDeliveryReceiptCount(syncId, System.currentTimeMillis());
        mmsSmsDatabase.incrementReadReceiptCount(syncId, System.currentTimeMillis());
        if (message.getExpiresIn() > 0) {
            smsDatabase.markExpireStarted(messageId);
            expirationManager.scheduleDeletion(message.getId(), message.isMms(), message.getExpiresIn());
        }
    } catch (NoSuchMessageException e) {
        Log.w(TAG, "Failed to update self-sent message.", e);
    }
}
Also used : MessageDatabase(org.thoughtcrime.securesms.database.MessageDatabase) NoSuchMessageException(org.thoughtcrime.securesms.database.NoSuchMessageException) SmsMessageRecord(org.thoughtcrime.securesms.database.model.SmsMessageRecord) MmsSmsDatabase(org.thoughtcrime.securesms.database.MmsSmsDatabase) ExpiringMessageManager(org.thoughtcrime.securesms.service.ExpiringMessageManager) SyncMessageId(org.thoughtcrime.securesms.database.MessageDatabase.SyncMessageId)

Example 12 with ExpiringMessageManager

use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by WhisperSystems.

the class ConversationItem method setExpiration.

private void setExpiration(final MessageRecord messageRecord) {
    if (messageRecord.getExpiresIn() > 0) {
        this.expirationTimer.setVisibility(View.VISIBLE);
        this.expirationTimer.setPercentage(0);
        if (messageRecord.getExpireStarted() > 0) {
            this.expirationTimer.setExpirationTime(messageRecord.getExpireStarted(), messageRecord.getExpiresIn());
            this.expirationTimer.startAnimation();
        } else if (!messageRecord.isOutgoing() && !messageRecord.isMediaPending()) {
            new AsyncTask<Void, Void, Void>() {

                @Override
                protected Void doInBackground(Void... params) {
                    ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
                    long id = messageRecord.getId();
                    boolean mms = messageRecord.isMms();
                    if (mms)
                        DatabaseFactory.getMmsDatabase(context).markExpireStarted(id);
                    else
                        DatabaseFactory.getSmsDatabase(context).markExpireStarted(id);
                    expirationManager.scheduleDeletion(id, mms, messageRecord.getExpiresIn());
                    return null;
                }
            }.execute();
        }
    } else {
        this.expirationTimer.setVisibility(View.GONE);
    }
}
Also used : AsyncTask(android.os.AsyncTask) ExpiringMessageManager(org.thoughtcrime.securesms.service.ExpiringMessageManager)

Example 13 with ExpiringMessageManager

use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by WhisperSystems.

the class MessageSender method sendMediaSelf.

private static void sendMediaSelf(Context context, MasterSecret masterSecret, long messageId, long expiresIn) throws MmsException {
    ExpiringMessageManager expiringMessageManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
    MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
    database.markAsSent(messageId, true);
    database.copyMessageInbox(masterSecret, messageId);
    if (expiresIn > 0) {
        database.markExpireStarted(messageId);
        expiringMessageManager.scheduleDeletion(messageId, true, expiresIn);
    }
}
Also used : ExpiringMessageManager(org.thoughtcrime.securesms.service.ExpiringMessageManager) MmsDatabase(org.thoughtcrime.securesms.database.MmsDatabase)

Example 14 with ExpiringMessageManager

use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by WhisperSystems.

the class MessageSender method sendTextSelf.

private static void sendTextSelf(Context context, long messageId, long expiresIn) {
    EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
    database.markAsSent(messageId, true);
    Pair<Long, Long> messageAndThreadId = database.copyMessageInbox(messageId);
    database.markAsPush(messageAndThreadId.first);
    if (expiresIn > 0) {
        ExpiringMessageManager expiringMessageManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
        database.markExpireStarted(messageId);
        expiringMessageManager.scheduleDeletion(messageId, false, expiresIn);
    }
}
Also used : EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase) ExpiringMessageManager(org.thoughtcrime.securesms.service.ExpiringMessageManager)

Example 15 with ExpiringMessageManager

use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by signalapp.

the class MarkReadReceiver method scheduleDeletion.

private static void scheduleDeletion(Context context, ExpirationInfo expirationInfo) {
    if (expirationInfo.getExpiresIn() > 0 && expirationInfo.getExpireStarted() <= 0) {
        ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
        if (expirationInfo.isMms())
            DatabaseFactory.getMmsDatabase(context).markExpireStarted(expirationInfo.getId());
        else
            DatabaseFactory.getSmsDatabase(context).markExpireStarted(expirationInfo.getId());
        expirationManager.scheduleDeletion(expirationInfo.getId(), expirationInfo.isMms(), expirationInfo.getExpiresIn());
    }
}
Also used : ExpiringMessageManager(org.thoughtcrime.securesms.service.ExpiringMessageManager)

Aggregations

ExpiringMessageManager (org.thoughtcrime.securesms.service.ExpiringMessageManager)20 MessageDatabase (org.thoughtcrime.securesms.database.MessageDatabase)8 SyncMessageId (org.thoughtcrime.securesms.database.MessageDatabase.SyncMessageId)8 SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)7 Recipient (org.thoughtcrime.securesms.recipients.Recipient)6 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)6 InsecureFallbackApprovalException (org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)6 UntrustedIdentityException (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException)6 OutgoingMediaMessage (org.thoughtcrime.securesms.mms.OutgoingMediaMessage)5 MmsSmsDatabase (org.thoughtcrime.securesms.database.MmsSmsDatabase)4 NoSuchMessageException (org.thoughtcrime.securesms.database.NoSuchMessageException)4 UnidentifiedAccessMode (org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode)4 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)3 Context (android.content.Context)2 Parcel (android.os.Parcel)2 Parcelable (android.os.Parcelable)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 WorkerThread (androidx.annotation.WorkerThread)2 Stream (com.annimon.stream.Stream)2