Search in sources :

Example 16 with AxolotlService

use of eu.siacs.conversations.crypto.axolotl.AxolotlService in project Conversations by siacs.

the class MessageParser method parseAxolotlChat.

private Message parseAxolotlChat(Element axolotlMessage, Jid from, Conversation conversation, int status) {
    AxolotlService service = conversation.getAccount().getAxolotlService();
    XmppAxolotlMessage xmppAxolotlMessage;
    try {
        xmppAxolotlMessage = XmppAxolotlMessage.fromElement(axolotlMessage, from.toBareJid());
    } catch (Exception e) {
        Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": invalid omemo message received " + e.getMessage());
        return null;
    }
    XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage);
    if (plaintextMessage != null) {
        Message finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL, status);
        finishedMessage.setFingerprint(plaintextMessage.getFingerprint());
        Log.d(Config.LOGTAG, AxolotlService.getLogprefix(finishedMessage.getConversation().getAccount()) + " Received Message with session fingerprint: " + plaintextMessage.getFingerprint());
        return finishedMessage;
    } else {
        return null;
    }
}
Also used : AxolotlService(eu.siacs.conversations.crypto.axolotl.AxolotlService) XmppAxolotlMessage(eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage) Message(eu.siacs.conversations.entities.Message) XmppAxolotlMessage(eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)

Example 17 with AxolotlService

use of eu.siacs.conversations.crypto.axolotl.AxolotlService in project Conversations by siacs.

the class ConversationActivity method quickOmemoDebugger.

private boolean quickOmemoDebugger(Conversation c) {
    if (c != null) {
        boolean single = c.getMode() == Conversation.MODE_SINGLE;
        AxolotlService axolotlService = c.getAccount().getAxolotlService();
        Pair<AxolotlService.AxolotlCapability, Jid> capabilityJidPair = axolotlService.isConversationAxolotlCapableDetailed(c);
        switch(capabilityJidPair.first) {
            case MISSING_PRESENCE:
                Toast.makeText(ConversationActivity.this, single ? getString(R.string.missing_presence_subscription) : getString(R.string.missing_presence_subscription_with_x, capabilityJidPair.second.toBareJid().toString()), Toast.LENGTH_SHORT).show();
                return true;
            case MISSING_KEYS:
                Toast.makeText(ConversationActivity.this, single ? getString(R.string.missing_omemo_keys) : getString(R.string.missing_keys_from_x, capabilityJidPair.second.toBareJid().toString()), Toast.LENGTH_SHORT).show();
                return true;
            case WRONG_CONFIGURATION:
                Toast.makeText(ConversationActivity.this, R.string.wrong_conference_configuration, Toast.LENGTH_SHORT).show();
                return true;
            case NO_MEMBERS:
                Toast.makeText(ConversationActivity.this, R.string.this_conference_has_no_members, Toast.LENGTH_SHORT).show();
                return true;
        }
    }
    return false;
}
Also used : AxolotlService(eu.siacs.conversations.crypto.axolotl.AxolotlService) Jid(eu.siacs.conversations.xmpp.jid.Jid)

Example 18 with AxolotlService

use of eu.siacs.conversations.crypto.axolotl.AxolotlService in project Conversations by siacs.

the class ConversationActivity method trustKeysIfNeeded.

protected boolean trustKeysIfNeeded(int requestCode, int attachmentChoice) {
    AxolotlService axolotlService = mSelectedConversation.getAccount().getAxolotlService();
    final List<Jid> targets = axolotlService.getCryptoTargets(mSelectedConversation);
    boolean hasUnaccepted = !mSelectedConversation.getAcceptedCryptoTargets().containsAll(targets);
    boolean hasUndecidedOwn = !axolotlService.getKeysWithTrust(FingerprintStatus.createActiveUndecided()).isEmpty();
    boolean hasUndecidedContacts = !axolotlService.getKeysWithTrust(FingerprintStatus.createActiveUndecided(), targets).isEmpty();
    boolean hasPendingKeys = !axolotlService.findDevicesWithoutSession(mSelectedConversation).isEmpty();
    boolean hasNoTrustedKeys = axolotlService.anyTargetHasNoTrustedKeys(targets);
    if (hasUndecidedOwn || hasUndecidedContacts || hasPendingKeys || hasNoTrustedKeys || hasUnaccepted) {
        axolotlService.createSessionsIfNeeded(mSelectedConversation);
        Intent intent = new Intent(getApplicationContext(), TrustKeysActivity.class);
        String[] contacts = new String[targets.size()];
        for (int i = 0; i < contacts.length; ++i) {
            contacts[i] = targets.get(i).toString();
        }
        intent.putExtra("contacts", contacts);
        intent.putExtra(EXTRA_ACCOUNT, mSelectedConversation.getAccount().getJid().toBareJid().toString());
        intent.putExtra("choice", attachmentChoice);
        intent.putExtra("conversation", mSelectedConversation.getUuid());
        startActivityForResult(intent, requestCode);
        return true;
    } else {
        return false;
    }
}
Also used : AxolotlService(eu.siacs.conversations.crypto.axolotl.AxolotlService) Jid(eu.siacs.conversations.xmpp.jid.Jid) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint)

Aggregations

AxolotlService (eu.siacs.conversations.crypto.axolotl.AxolotlService)18 Jid (eu.siacs.conversations.xmpp.Jid)10 Contact (eu.siacs.conversations.entities.Contact)6 XmppUri (eu.siacs.conversations.utils.XmppUri)6 Element (eu.siacs.conversations.xml.Element)6 Intent (android.content.Intent)5 PendingIntent (android.app.PendingIntent)4 FingerprintStatus (eu.siacs.conversations.crypto.axolotl.FingerprintStatus)4 XmppConnection (eu.siacs.conversations.xmpp.XmppConnection)4 SuppressLint (android.annotation.SuppressLint)3 SharedPreferences (android.content.SharedPreferences)3 Uri (android.net.Uri)3 Build (android.os.Build)3 Bundle (android.os.Bundle)3 Account (eu.siacs.conversations.entities.Account)3 Avatar (eu.siacs.conversations.xmpp.pep.Avatar)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 PreferenceManager (android.preference.PreferenceManager)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2