use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by WhisperSystems.
the class PushMediaSendJob method onPushSend.
@Override
public void onPushSend(MasterSecret masterSecret) throws RetryLaterException, MmsException, NoSuchMessageException, UndeliverableMessageException {
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
OutgoingMediaMessage message = database.getOutgoingMessage(masterSecret, messageId);
try {
deliver(masterSecret, message);
database.markAsSent(messageId, true);
markAttachmentsUploaded(messageId, message.getAttachments());
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
database.markExpireStarted(messageId);
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
}
} catch (InsecureFallbackApprovalException ifae) {
Log.w(TAG, ifae);
database.markAsPendingInsecureSmsFallback(messageId);
notifyMediaMessageDeliveryFailed(context, messageId);
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context));
} catch (UntrustedIdentityException uie) {
Log.w(TAG, uie);
Recipients recipients = RecipientFactory.getRecipientsFromString(context, uie.getE164Number(), false);
long recipientId = recipients.getPrimaryRecipient().getRecipientId();
database.addMismatchedIdentity(messageId, recipientId, uie.getIdentityKey());
database.markAsSentFailed(messageId);
}
}
use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by WhisperSystems.
the class PushTextSendJob method onPushSend.
@Override
public void onPushSend(MasterSecret masterSecret) throws NoSuchMessageException, RetryLaterException {
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
try {
Log.w(TAG, "Sending message: " + messageId);
deliver(record);
database.markAsSent(messageId, true);
if (record.getExpiresIn() > 0) {
database.markExpireStarted(messageId);
expirationManager.scheduleDeletion(record.getId(), record.isMms(), record.getExpiresIn());
}
} catch (InsecureFallbackApprovalException e) {
Log.w(TAG, e);
database.markAsPendingInsecureSmsFallback(record.getId());
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context));
} catch (UntrustedIdentityException e) {
Log.w(TAG, e);
Recipients recipients = RecipientFactory.getRecipientsFromString(context, e.getE164Number(), false);
long recipientId = recipients.getPrimaryRecipient().getRecipientId();
database.addMismatchedIdentity(record.getId(), recipientId, e.getIdentityKey());
database.markAsSentFailed(record.getId());
database.markAsPush(record.getId());
}
}
use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by WhisperSystems.
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());
}
}
use of org.thoughtcrime.securesms.service.ExpiringMessageManager in project Signal-Android by signalapp.
the class MessageSender method sendTextSelf.
private static void sendTextSelf(Context context, long messageId, long expiresIn) {
SmsDatabase database = DatabaseFactory.getSmsDatabase(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 ConversationItem method setExpiration.
@SuppressLint("StaticFieldLeak")
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;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
} else {
this.expirationTimer.setVisibility(View.GONE);
}
}
Aggregations