Search in sources :

Example 1 with OutgoingEndSessionMessage

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) GroupContext(org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext) Context(android.content.Context) OutgoingEndSessionMessage(org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage) OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) DialogInterface(android.content.DialogInterface) AsyncTask(android.os.AsyncTask)

Example 2 with OutgoingEndSessionMessage

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;
}
Also used : OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) OutgoingEndSessionMessage(org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage) SessionStore(org.whispersystems.libsignal.state.SessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) Recipients(org.thoughtcrime.securesms.recipients.Recipients) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase)

Aggregations

OutgoingEndSessionMessage (org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage)2 OutgoingTextMessage (org.thoughtcrime.securesms.sms.OutgoingTextMessage)2 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 AsyncTask (android.os.AsyncTask)1 AlertDialog (android.support.v7.app.AlertDialog)1 TextSecureSessionStore (org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore)1 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)1 Recipients (org.thoughtcrime.securesms.recipients.Recipients)1 SessionStore (org.whispersystems.libsignal.state.SessionStore)1 GroupContext (org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext)1