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);
}
}
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);
}
}
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);
}
}
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);
}
}
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());
}
}
Aggregations