Commit fa60a1ca authored by Moxie Marlinspike's avatar Moxie Marlinspike Committed by Bastien Le Querrec
parent 394eb521
Pipeline #192 passed with stages
in 8 minutes and 20 seconds
......@@ -489,23 +489,16 @@ public class ConversationItem extends LinearLayout
contactPhoto.setVisibility(View.VISIBLE);
}
private IdentityKeyMismatch getKeyMismatch(final MessageRecord record) {
if (record.isIdentityMismatchFailure()) {
Log.w(TAG, "isIdentityMismatchFailure(): true");
for (final IdentityKeyMismatch mismatch : record.getIdentityKeyMismatches()) {
if (mismatch.getRecipientId() == record.getIndividualRecipient().getRecipientId()) {
return mismatch;
}
}
}
Log.w(TAG, "Returning null IdentityKeyMismatch...");
return null;
}
/// Event handlers
private void handleKeyExchangeClicked() {
new ConfirmIdentityDialog(context, masterSecret, messageRecord, getKeyMismatch(messageRecord)).show();
private void handleApproveIdentity() {
List<IdentityKeyMismatch> mismatches = messageRecord.getIdentityKeyMismatches();
if (mismatches.size() != 1) {
throw new AssertionError("Identity mismatch count: " + mismatches.size());
}
new ConfirmIdentityDialog(context, masterSecret, messageRecord, mismatches.get(0)).show();
}
private void handleLegacyKeyExchangeClicked() {
......@@ -627,13 +620,8 @@ public class ConversationItem extends LinearLayout
intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT);
intent.putExtra(MessageDetailsActivity.RECIPIENTS_IDS_EXTRA, conversationRecipients.getIds());
context.startActivity(intent);
} else if (messageRecord.isKeyExchange() &&
!messageRecord.isOutgoing() &&
!messageRecord.isProcessedKeyExchange() &&
!messageRecord.isStaleKeyExchange() &&
!messageRecord.isLegacyMessage())
{
handleKeyExchangeClicked();
} else if (!messageRecord.isOutgoing() && messageRecord.isIdentityMismatchFailure()) {
handleApproveIdentity();
} else if (shouldInterceptKeyExchangeMessage(messageRecord)) {
handleLegacyKeyExchangeClicked();
}
......
......@@ -30,6 +30,27 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
protected abstract String getTableName();
public void setMismatchedIdentity(long messageId, final long recipientId, final IdentityKey identityKey) {
List<IdentityKeyMismatch> items = new ArrayList<IdentityKeyMismatch>() {{
add(new IdentityKeyMismatch(recipientId, identityKey));
}};
IdentityKeyMismatchList document = new IdentityKeyMismatchList(items);
SQLiteDatabase database = databaseHelper.getWritableDatabase();
database.beginTransaction();
try {
setDocument(database, messageId, MISMATCHED_IDENTITIES, document);
database.setTransactionSuccessful();
} catch (IOException ioe) {
Log.w(TAG, ioe);
} finally {
database.endTransaction();
}
}
public void addMismatchedIdentity(long messageId, long recipientId, IdentityKey identityKey) {
try {
addToDocument(messageId, MISMATCHED_IDENTITIES,
......@@ -133,7 +154,9 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
try {
return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException e) {
throw new AssertionError(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment