Search in sources :

Example 1 with SessionImpl

use of net.java.otr4j.session.SessionImpl in project Pix-Art-Messenger by kriztan.

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 2 with SessionImpl

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

the class OTRManager method getOrCreateSession.

private Session getOrCreateSession(String account, String user) {
    Session session = sessions.get(account, user);
    if (session != null) {
        LogManager.i(this, "Found session with id " + session.getSessionID() + " with status " + session.getSessionStatus() + " for user " + user);
        return session;
    }
    LogManager.i(this, "Creating new session for " + user);
    session = new SessionImpl(new SessionID(account, user, "xmpp"), this);
    session.addOtrEngineListener(this);
    sessions.put(account, user, session);
    return session;
}
Also used : SessionImpl(net.java.otr4j.session.SessionImpl) SessionID(net.java.otr4j.session.SessionID) Session(net.java.otr4j.session.Session)

Example 3 with SessionImpl

use of net.java.otr4j.session.SessionImpl 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 4 with SessionImpl

use of net.java.otr4j.session.SessionImpl in project Zom-Android by zom.

the class OtrEngineImpl method getSession.

public Session getSession(SessionID sessionID) {
    if (sessionID == null || sessionID.equals(SessionID.Empty))
        throw new IllegalArgumentException();
    if (!sessions.containsKey(sessionID.toString())) {
        Session session = new SessionImpl(sessionID, getHost());
        sessions.put(sessionID.toString(), session);
        session.addOtrEngineListener(new OtrEngineListener() {

            public void sessionStatusChanged(SessionID sessionID) {
                for (int i = 0; i < listeners.size(); i++) listeners.get(i).sessionStatusChanged(sessionID);
            }
        });
        return session;
    } else {
        SessionImpl session = (SessionImpl) sessions.get(sessionID.toString());
        // make sure latest instance is stored in session (in case JIDs get updated)
        session.setSessionID(sessionID);
        return session;
    }
}
Also used : SessionImpl(net.java.otr4j.session.SessionImpl) SessionID(net.java.otr4j.session.SessionID) Session(net.java.otr4j.session.Session)

Example 5 with SessionImpl

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

the class OTRManager method transformReceivingIfSessionExist.

public String transformReceivingIfSessionExist(AccountJid account, UserJid user, String content) throws OtrException {
    LogManager.i(this, "transform incoming message... " + content, "transform incoming message... ***");
    Session session = getSession(account.toString(), user.toString());
    SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
    if (session != null && (securityLevel == SecurityLevel.encrypted || securityLevel == SecurityLevel.verified)) {
        try {
            String s = ((SessionImpl) session).transformReceivingWithoutInject(content);
            LogManager.i(this, "transformed incoming message: " + s + " session status: " + session.getSessionStatus(), "transformed incoming message: " + "***" + " session status: " + session.getSessionStatus());
            return s;
        } catch (UnsupportedOperationException e) {
            throw new OtrException(e);
        }
    } else {
        return content;
    }
}
Also used : SessionImpl(net.java.otr4j.session.SessionImpl) OtrException(net.java.otr4j.OtrException) Session(net.java.otr4j.session.Session)

Aggregations

SessionImpl (net.java.otr4j.session.SessionImpl)6 SessionID (net.java.otr4j.session.SessionID)4 OtrException (net.java.otr4j.OtrException)3 Session (net.java.otr4j.session.Session)3 XmppAxolotlMessage (de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage)1 Account (de.pixart.messenger.entities.Account)1 Conversation (de.pixart.messenger.entities.Conversation)1 Message (de.pixart.messenger.entities.Message)1 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)1 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)1