use of org.thoughtcrime.securesms.database.SmsDatabase in project Signal-Android by WhisperSystems.
the class PushDecryptJob method handleCallOfferMessage.
private void handleCallOfferMessage(@NonNull SignalServiceEnvelope envelope, @NonNull OfferMessage message, @NonNull Optional<Long> smsMessageId) {
Log.w(TAG, "handleCallOfferMessage...");
if (smsMessageId.isPresent()) {
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
database.markAsMissedCall(smsMessageId.get());
} else {
Intent intent = new Intent(context, WebRtcCallService.class);
intent.setAction(WebRtcCallService.ACTION_INCOMING_CALL);
intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId());
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_NUMBER, envelope.getSource());
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_DESCRIPTION, message.getDescription());
intent.putExtra(WebRtcCallService.EXTRA_TIMESTAMP, envelope.getTimestamp());
context.startService(intent);
}
}
use of org.thoughtcrime.securesms.database.SmsDatabase in project Signal-Android by WhisperSystems.
the class IdentityUpdateJob method onRun.
@Override
public void onRun(MasterSecret masterSecret) throws Exception {
Recipient recipient = RecipientFactory.getRecipientForId(context, recipientId, true);
Recipients recipients = RecipientFactory.getRecipientsFor(context, recipient, true);
String number = recipient.getNumber();
long time = System.currentTimeMillis();
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupDatabase.Reader reader = groupDatabase.getGroups();
GroupDatabase.GroupRecord groupRecord;
while ((groupRecord = reader.getNext()) != null) {
if (groupRecord.getMembers().contains(number) && groupRecord.isActive()) {
SignalServiceGroup group = new SignalServiceGroup(groupRecord.getId());
IncomingTextMessage incoming = new IncomingTextMessage(number, 1, time, null, Optional.of(group), 0);
IncomingIdentityUpdateMessage groupUpdate = new IncomingIdentityUpdateMessage(incoming);
smsDatabase.insertMessageInbox(groupUpdate);
}
}
if (threadDatabase.getThreadIdIfExistsFor(recipients) != -1) {
IncomingTextMessage incoming = new IncomingTextMessage(number, 1, time, null, Optional.<SignalServiceGroup>absent(), 0);
IncomingIdentityUpdateMessage individualUpdate = new IncomingIdentityUpdateMessage(incoming);
smsDatabase.insertMessageInbox(individualUpdate);
}
}
use of org.thoughtcrime.securesms.database.SmsDatabase 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.database.SmsDatabase in project Signal-Android by signalapp.
the class ConversationItem method handleMessageApproval.
private void handleMessageApproval() {
final int title;
final int message;
if (messageRecord.isMms())
title = R.string.ConversationItem_click_to_approve_unencrypted_mms_dialog_title;
else
title = R.string.ConversationItem_click_to_approve_unencrypted_sms_dialog_title;
message = R.string.ConversationItem_click_to_approve_unencrypted_dialog_message;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
if (message > -1)
builder.setMessage(message);
builder.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
if (messageRecord.isMms()) {
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
database.markAsInsecure(messageRecord.getId());
database.markAsOutbox(messageRecord.getId());
database.markAsForcedSms(messageRecord.getId());
ApplicationContext.getInstance(context).getJobManager().add(new MmsSendJob(context, messageRecord.getId()));
} else {
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
database.markAsInsecure(messageRecord.getId());
database.markAsOutbox(messageRecord.getId());
database.markAsForcedSms(messageRecord.getId());
ApplicationContext.getInstance(context).getJobManager().add(new SmsSendJob(context, messageRecord.getId(), messageRecord.getIndividualRecipient().getAddress().serialize()));
}
});
builder.setNegativeButton(R.string.no, (dialogInterface, i) -> {
if (messageRecord.isMms()) {
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageRecord.getId());
} else {
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(messageRecord.getId());
}
});
builder.show();
}
use of org.thoughtcrime.securesms.database.SmsDatabase in project Signal-Android by signalapp.
the class PushDecryptJob method handleCorruptMessage.
private void handleCorruptMessage(@NonNull SignalServiceEnvelope envelope, @NonNull Optional<Long> smsMessageId) {
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
if (!smsMessageId.isPresent()) {
Optional<InsertResult> insertResult = insertPlaceholder(envelope);
if (insertResult.isPresent()) {
smsDatabase.markAsDecryptFailed(insertResult.get().getMessageId());
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
}
} else {
smsDatabase.markAsDecryptFailed(smsMessageId.get());
}
}
Aggregations