use of net.java.otr4j.OtrException in project xabber-android by redsolution.
the class OTRManager method abortSmp.
/**
* Abort SM negotiation.
*/
public void abortSmp(AccountJid account, UserJid user) throws NetworkException {
LogManager.i(this, "aborting smp... " + user);
removeSMRequest(account.toString(), user.toString());
removeSMProgress(account.toString(), user.toString());
try {
getOrCreateSession(account.toString(), user.toString()).abortSmp();
} catch (OtrException e) {
throw new NetworkException(R.string.OTR_ERROR, e);
}
}
use of net.java.otr4j.OtrException in project xabber-android by redsolution.
the class OTRManager method refreshSession.
private void refreshSession(String account, String user) throws NetworkException {
LogManager.i(this, "Refreshing session for " + user);
try {
getOrCreateSession(account, user).refreshSession();
} catch (OtrException e) {
throw new NetworkException(R.string.OTR_ERROR, e);
}
LogManager.i(this, "Refreshed session for " + user);
}
use of net.java.otr4j.OtrException in project xabber-android by redsolution.
the class OTRManager method endSession.
private void endSession(String account, String user) throws NetworkException {
LogManager.i(this, "Ending session for " + user);
try {
getOrCreateSession(account, user).endSession();
} catch (OtrException e) {
throw new NetworkException(R.string.OTR_ERROR, e);
}
AbstractChat abstractChat = getChat(account, user);
if (abstractChat != null) {
SSNManager.getInstance().setSessionOtrMode(account, user, abstractChat.getThreadId(), OtrMode.concede);
LogManager.i(this, "Ended session for " + user);
}
}
use of net.java.otr4j.OtrException 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;
}
}
use of net.java.otr4j.OtrException in project xabber-android by redsolution.
the class OTRManager method injectMessage.
private void injectMessage(String account, String user, String msg) throws OtrException {
LogManager.i(this, "injectMessage. user: " + user + " message: " + msg);
AbstractChat abstractChat = getChat(account, user);
SSNManager.getInstance().setSessionOtrMode(account, user, abstractChat.getThreadId(), OtrMode.prefer);
Message message = abstractChat.createMessagePacket(msg);
CarbonManager.getInstance().setMessageToIgnoreCarbons(message);
try {
StanzaSender.sendStanza(abstractChat.getAccount(), message);
} catch (NetworkException e) {
throw new OtrException(e);
}
}
Aggregations