use of net.java.otr4j.OtrEngineListener in project Zom-Android by zom.
the class SessionImpl method setSessionStatus.
private void setSessionStatus(SessionStatus sessionStatusNew) throws OtrException {
boolean sessionStatusChanged = (sessionStatus != sessionStatusNew);
sessionStatus = sessionStatusNew;
switch(sessionStatus) {
case ENCRYPTED:
AuthContext auth = this.getAuthContext(false);
ess = auth.getS();
if (DEBUG_ENABLED)
Log.d(LOG_TAG, "Setting most recent session keys from auth.");
for (int i = 0; i < this.getSessionKeys()[0].length; i++) {
SessionKeys current = getSessionKeysByIndex(0, i);
current.setLocalPair(auth.getLocalDHKeyPair(), 1);
current.setRemoteDHPublicKey(auth.getRemoteDHPublicKey(), 1);
current.setS(auth.getS());
}
KeyPair nextDH = new OtrCryptoEngineImpl().generateDHKeyPair();
for (int i = 0; i < this.getSessionKeys()[1].length; i++) {
SessionKeys current = getSessionKeysByIndex(1, i);
current.setRemoteDHPublicKey(auth.getRemoteDHPublicKey(), 1);
current.setLocalPair(nextDH, 2);
}
this.setRemotePublicKey(auth.getRemoteLongTermPublicKey());
auth.reset();
break;
case PLAINTEXT:
// nothing here
break;
default:
}
if (sessionStatus == SessionStatus.ENCRYPTED && doTransmitLastMessage && lastSentMessage != null) {
// String retransmit = (isLastMessageRetransmit ? "[resent] " : "");
String msg = transformSending(lastSentMessage, null);
getHost().injectMessage(getSessionID(), msg);
sessionStatusChanged = true;
}
doTransmitLastMessage = false;
isLastMessageRetransmit = false;
lastSentMessage = null;
if (sessionStatusChanged) {
for (OtrEngineListener l : this.listeners) l.sessionStatusChanged(getSessionID());
}
}
Aggregations