use of org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage in project Signal-Android by WhisperSystems.
the class ConversationActivity method handleResetSecureSession.
private void handleResetSecureSession() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.ConversationActivity_reset_secure_session_question);
builder.setIconAttribute(R.attr.dialog_alert_icon);
builder.setCancelable(true);
builder.setMessage(R.string.ConversationActivity_this_may_help_if_youre_having_encryption_problems);
builder.setPositiveButton(R.string.ConversationActivity_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (isSingleConversation()) {
final Context context = getApplicationContext();
OutgoingEndSessionMessage endSessionMessage = new OutgoingEndSessionMessage(new OutgoingTextMessage(getRecipients(), "TERMINATE", 0, -1));
new AsyncTask<OutgoingEndSessionMessage, Void, Long>() {
@Override
protected Long doInBackground(OutgoingEndSessionMessage... messages) {
return MessageSender.send(context, masterSecret, messages[0], threadId, false);
}
@Override
protected void onPostExecute(Long result) {
sendComplete(result);
}
}.execute(endSessionMessage);
}
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
}
use of org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage in project Signal-Android by WhisperSystems.
the class PushDecryptJob method handleSynchronizeSentEndSessionMessage.
private long handleSynchronizeSentEndSessionMessage(@NonNull MasterSecretUnion masterSecret, @NonNull SentTranscriptMessage message, @NonNull Optional<Long> smsMessageId) {
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
Recipients recipients = getSyncMessageDestination(message);
OutgoingTextMessage outgoingTextMessage = new OutgoingTextMessage(recipients, "", -1);
OutgoingEndSessionMessage outgoingEndSessionMessage = new OutgoingEndSessionMessage(outgoingTextMessage);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
if (recipients.isSingleRecipient() && !recipients.isGroupRecipient()) {
SessionStore sessionStore = new TextSecureSessionStore(context);
sessionStore.deleteAllSessions(recipients.getPrimaryRecipient().getNumber());
SecurityEvent.broadcastSecurityUpdateEvent(context);
long messageId = database.insertMessageOutbox(masterSecret, threadId, outgoingEndSessionMessage, false, message.getTimestamp());
database.markAsSent(messageId, true);
}
if (smsMessageId.isPresent()) {
database.deleteMessage(smsMessageId.get());
}
return threadId;
}
Aggregations