Search in sources :

Example 16 with AxolotlService

use of de.pixart.messenger.crypto.axolotl.AxolotlService in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method verifyFingerprints.

public boolean verifyFingerprints(Contact contact, List<XmppUri.Fingerprint> fingerprints) {
    boolean needsRosterWrite = false;
    boolean performedVerification = false;
    final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
    for (XmppUri.Fingerprint fp : fingerprints) {
        if (fp.type == XmppUri.FingerprintType.OTR) {
            performedVerification |= contact.addOtrFingerprint(fp.fingerprint);
            needsRosterWrite |= performedVerification;
        } else if (fp.type == XmppUri.FingerprintType.OMEMO) {
            String fingerprint = "05" + fp.fingerprint.replaceAll("\\s", "");
            FingerprintStatus fingerprintStatus = axolotlService.getFingerprintTrust(fingerprint);
            if (fingerprintStatus != null) {
                if (!fingerprintStatus.isVerified()) {
                    performedVerification = true;
                    axolotlService.setFingerprintTrust(fingerprint, fingerprintStatus.toVerified());
                }
            } else {
                axolotlService.preVerifyFingerprint(contact, fingerprint);
            }
        }
    }
    if (needsRosterWrite) {
        syncRosterToDisk(contact.getAccount());
    }
    return performedVerification;
}
Also used : AxolotlService(de.pixart.messenger.crypto.axolotl.AxolotlService) XmppUri(de.pixart.messenger.utils.XmppUri) FingerprintStatus(de.pixart.messenger.crypto.axolotl.FingerprintStatus)

Example 17 with AxolotlService

use of de.pixart.messenger.crypto.axolotl.AxolotlService in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method reconnectAccount.

private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
    synchronized (account) {
        XmppConnection connection = account.getXmppConnection();
        if (connection == null) {
            connection = createConnection(account);
            account.setXmppConnection(connection);
        }
        boolean hasInternet = hasInternetConnection();
        if (account.isEnabled() && hasInternet) {
            if (!force) {
                disconnect(account, false);
            }
            Thread thread = new Thread(connection);
            connection.setInteractive(interactive);
            connection.prepareNewConnection();
            connection.interrupt();
            thread.start();
            scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
        } else {
            disconnect(account, force || account.getTrueStatus().isError() || !hasInternet);
            account.getRoster().clearPresences();
            connection.resetEverything();
            final AxolotlService axolotlService = account.getAxolotlService();
            if (axolotlService != null) {
                axolotlService.resetBrokenness();
            }
            if (!hasInternet) {
                account.setStatus(Account.State.NO_INTERNET);
            }
        }
    }
}
Also used : XmppConnection(de.pixart.messenger.xmpp.XmppConnection) AxolotlService(de.pixart.messenger.crypto.axolotl.AxolotlService)

Aggregations

AxolotlService (de.pixart.messenger.crypto.axolotl.AxolotlService)17 Jid (de.pixart.messenger.xmpp.jid.Jid)7 Element (de.pixart.messenger.xml.Element)5 Contact (de.pixart.messenger.entities.Contact)4 XmppUri (de.pixart.messenger.utils.XmppUri)3 XmppConnection (de.pixart.messenger.xmpp.XmppConnection)3 Avatar (de.pixart.messenger.xmpp.pep.Avatar)3 SuppressLint (android.annotation.SuppressLint)2 PendingIntent (android.app.PendingIntent)2 Intent (android.content.Intent)2 ActionBar (android.support.v7.app.ActionBar)2 AlertDialog (android.support.v7.app.AlertDialog)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 ImageButton (android.widget.ImageButton)2 FingerprintStatus (de.pixart.messenger.crypto.axolotl.FingerprintStatus)2 Account (de.pixart.messenger.entities.Account)2 Activity (android.app.Activity)1 Builder (android.app.AlertDialog.Builder)1