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;
}
}
}
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;
}
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;
}
}
}
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;
}
}
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;
}
}
Aggregations