Search in sources :

Example 21 with OtrException

use of net.java.otr4j.OtrException in project xabber-android by redsolution.

the class OTRManager method transformReceiving.

/**
     * Transform incoming message after receiving.
     */
public String transformReceiving(String account, String user, String content) throws OtrException {
    LogManager.i(this, "transform incoming message... " + content);
    Session session = getOrCreateSession(account, user);
    try {
        String s = session.transformReceiving(content);
        LogManager.i(this, "transformed incoming message: " + s + " session status: " + session.getSessionStatus());
        return s;
    } catch (UnsupportedOperationException e) {
        throw new OtrException(e);
    }
}
Also used : OtrException(net.java.otr4j.OtrException) Session(net.java.otr4j.session.Session)

Example 22 with OtrException

use of net.java.otr4j.OtrException in project Conversations by siacs.

the class Conversation method startOtrSession.

public SessionImpl startOtrSession(String presence, boolean sendStart) {
    if (this.otrSession != null) {
        return this.otrSession;
    } else {
        final SessionID sessionId = new SessionID(this.getJid().toBareJid().toString(), presence, "xmpp");
        this.otrSession = new SessionImpl(sessionId, getAccount().getOtrService());
        try {
            if (sendStart) {
                this.otrSession.startSession();
                return this.otrSession;
            }
            return this.otrSession;
        } catch (OtrException e) {
            return null;
        }
    }
}
Also used : SessionImpl(net.java.otr4j.session.SessionImpl) OtrException(net.java.otr4j.OtrException) SessionID(net.java.otr4j.session.SessionID)

Example 23 with OtrException

use of net.java.otr4j.OtrException in project Conversations by siacs.

the class VerifyOTRActivity method initSmp.

protected boolean initSmp(final String question, final String secret) {
    final Session session = mConversation.getOtrSession();
    if (session != null) {
        try {
            session.initSmp(question, secret);
            mConversation.smp().status = Conversation.Smp.STATUS_WE_REQUESTED;
            mConversation.smp().secret = secret;
            mConversation.smp().hint = question;
            return true;
        } catch (OtrException e) {
            return false;
        }
    } else {
        return false;
    }
}
Also used : OtrException(net.java.otr4j.OtrException) Session(net.java.otr4j.session.Session)

Aggregations

OtrException (net.java.otr4j.OtrException)23 NetworkException (com.xabber.android.data.NetworkException)11 Session (net.java.otr4j.session.Session)9 AbstractChat (com.xabber.android.data.message.AbstractChat)3 Message (org.jivesoftware.smack.packet.Message)3 OTRUnencryptedException (com.xabber.android.data.extension.otr.OTRUnencryptedException)2 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)2 SessionImpl (net.java.otr4j.session.SessionImpl)2 Presence (org.jivesoftware.smack.packet.Presence)2 MUCUser (org.jivesoftware.smackx.muc.packet.MUCUser)2 RegularChat (com.xabber.android.data.message.RegularChat)1 Account (eu.siacs.conversations.entities.Account)1 PublicKey (java.security.PublicKey)1 OtrCryptoEngine (net.java.otr4j.crypto.OtrCryptoEngine)1 OtrCryptoEngineImpl (net.java.otr4j.crypto.OtrCryptoEngineImpl)1 OtrCryptoException (net.java.otr4j.crypto.OtrCryptoException)1 SessionID (net.java.otr4j.session.SessionID)1 SessionStatus (net.java.otr4j.session.SessionStatus)1 Resourcepart (org.jxmpp.jid.parts.Resourcepart)1