Search in sources :

Example 31 with Contact

use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.

the class VerifyOTRActivity method verifyWithUri.

protected boolean verifyWithUri(XmppUri uri) {
    Contact contact = mConversation.getContact();
    if (this.mConversation.getContact().getJid().equals(uri.getJid()) && uri.hasFingerprints()) {
        xmppConnectionService.verifyFingerprints(contact, uri.getFingerprints());
        Toast.makeText(this, R.string.verified, Toast.LENGTH_SHORT).show();
        updateView();
        return true;
    } else {
        Toast.makeText(this, R.string.could_not_verify_fingerprint, Toast.LENGTH_SHORT).show();
        return false;
    }
}
Also used : Contact(eu.siacs.conversations.entities.Contact)

Example 32 with Contact

use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.

the class XmppActivity method selectPresence.

public void selectPresence(final Conversation conversation, final OnPresenceSelected listener) {
    final Contact contact = conversation.getContact();
    if (conversation.hasValidOtrSession()) {
        SessionID id = conversation.getOtrSession().getSessionID();
        Jid jid;
        try {
            jid = Jid.fromString(id.getAccountID() + "/" + id.getUserID());
        } catch (InvalidJidException e) {
            jid = null;
        }
        conversation.setNextCounterpart(jid);
        listener.onPresenceSelected();
    } else if (!contact.showInRoster()) {
        showAddToRosterDialog(conversation);
    } else {
        final Presences presences = contact.getPresences();
        if (presences.size() == 0) {
            if (!contact.getOption(Contact.Options.TO) && !contact.getOption(Contact.Options.ASKING) && contact.getAccount().getStatus() == Account.State.ONLINE) {
                showAskForPresenceDialog(contact);
            } else if (!contact.getOption(Contact.Options.TO) || !contact.getOption(Contact.Options.FROM)) {
                warnMutalPresenceSubscription(conversation, listener);
            } else {
                conversation.setNextCounterpart(null);
                listener.onPresenceSelected();
            }
        } else if (presences.size() == 1) {
            String presence = presences.toResourceArray()[0];
            try {
                conversation.setNextCounterpart(Jid.fromParts(contact.getJid().getLocalpart(), contact.getJid().getDomainpart(), presence));
            } catch (InvalidJidException e) {
                conversation.setNextCounterpart(null);
            }
            listener.onPresenceSelected();
        } else {
            showPresenceSelectionDialog(presences, conversation, listener);
        }
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) Presences(eu.siacs.conversations.entities.Presences) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) SessionID(net.java.otr4j.session.SessionID) Contact(eu.siacs.conversations.entities.Contact)

Aggregations

Contact (eu.siacs.conversations.entities.Contact)32 Account (eu.siacs.conversations.entities.Account)9 Jid (eu.siacs.conversations.xmpp.jid.Jid)9 Conversation (eu.siacs.conversations.entities.Conversation)8 Element (eu.siacs.conversations.xml.Element)7 SuppressLint (android.annotation.SuppressLint)5 DialogInterface (android.content.DialogInterface)5 OnClickListener (android.content.DialogInterface.OnClickListener)4 AlertDialog (android.app.AlertDialog)3 Message (eu.siacs.conversations.entities.Message)3 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)3 Builder (android.app.AlertDialog.Builder)2 PendingIntent (android.app.PendingIntent)2 Intent (android.content.Intent)2 Point (android.graphics.Point)2 Uri (android.net.Uri)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 Toast (android.widget.Toast)2 AxolotlService (eu.siacs.conversations.crypto.axolotl.AxolotlService)2