use of net.java.otr4j.session.Session in project Conversations by siacs.
the class VerifyOTRActivity method abortSmp.
protected boolean abortSmp() {
final Session session = mConversation.getOtrSession();
if (session != null) {
try {
session.abortSmp();
mConversation.smp().status = Conversation.Smp.STATUS_NONE;
mConversation.smp().hint = null;
mConversation.smp().secret = null;
return true;
} catch (OtrException e) {
return false;
}
} else {
return false;
}
}
use of net.java.otr4j.session.Session in project xabber-android by redsolution.
the class OTRManager method onContactUnAvailable.
public void onContactUnAvailable(String account, String user) {
Session session = sessions.get(account, user);
if (session == null) {
return;
}
if (session.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
LogManager.i(this, "onContactUnAvailable. Refresh session for " + user);
session.refreshSession();
} catch (OtrException e) {
LogManager.exception(this, e);
}
}
}
use of net.java.otr4j.session.Session 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);
}
}
use of net.java.otr4j.session.Session in project Conversations by siacs.
the class XmppConnectionService method onOtrSessionEstablished.
public void onOtrSessionEstablished(Conversation conversation) {
final Account account = conversation.getAccount();
final Session otrSession = conversation.getOtrSession();
Log.d(Config.LOGTAG, account.getJid().toBareJid() + " otr session established with " + conversation.getJid() + "/" + otrSession.getSessionID().getUserID());
conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
SessionID id = otrSession.getSessionID();
try {
message.setCounterpart(Jid.fromString(id.getAccountID() + "/" + id.getUserID()));
} catch (InvalidJidException e) {
return;
}
if (message.needsUploading()) {
mJingleConnectionManager.createNewConnection(message);
} else {
MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
if (outPacket != null) {
mMessageGenerator.addDelay(outPacket, message.getTimeSent());
message.setStatus(Message.STATUS_SEND);
databaseBackend.updateMessage(message);
sendMessagePacket(account, outPacket);
}
}
updateConversationUi();
}
});
}
use of net.java.otr4j.session.Session 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;
}
}
Aggregations