Commit d90031c0 authored by Grigory Fedorov's avatar Grigory Fedorov

OTRManager refreshes session of contact become unavailable (goes offline). Should fix #413

parent a7e4a25f
......@@ -653,4 +653,20 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
// since this is not supported, we don't need to do anything
}
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);
}
}
}
}
......@@ -120,10 +120,15 @@ public class RegularChat extends AbstractChat {
final String resource = Jid.getResource(packet.getFrom());
if (packet instanceof Presence) {
final Presence presence = (Presence) packet;
if (this.resource != null
&& presence.getType() == Presence.Type.unavailable
&& this.resource.equals(resource))
if (this.resource != null && presence.getType() == Presence.Type.unavailable
&& this.resource.equals(resource)) {
this.resource = null;
}
if (presence.getType() == Presence.Type.unavailable) {
OTRManager.getInstance().onContactUnAvailable(account, user);
}
} else if (packet instanceof Message) {
final Message message = (Message) packet;
if (message.getType() == Message.Type.error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment