diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2014-05-23 10:54:40 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2014-05-23 10:54:40 +0200 |
commit | a0dde05ee59058bfd71968eb4072aaaa9be5c090 (patch) | |
tree | 4f9f2a6eee8ed3de918fd48bf11a5d2e4b071860 /src/eu/siacs/conversations/services | |
parent | 8133dcd881af0d89b0ed32d7da944b425975597a (diff) |
end otr sessions earlier / more often. can lead to unesessary handshakes but can improve reliabilty
Diffstat (limited to 'src/eu/siacs/conversations/services')
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 764e139f0..e31d28e02 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -36,6 +36,7 @@ import eu.siacs.conversations.utils.PhoneHelper; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.OnBindListener; +import eu.siacs.conversations.xmpp.OnContactStatusChanged; import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.OnMessagePacketReceived; import eu.siacs.conversations.xmpp.OnPresencePacketReceived; @@ -95,6 +96,16 @@ public class XmppConnectionService extends Service { private int convChangedListenerCount = 0; private OnAccountListChangedListener accountChangedListener = null; private OnTLSExceptionReceived tlsException = null; + private OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() { + + @Override + public void onContactStatusChanged(Contact contact) { + Conversation conversation = findActiveConversation(contact); + if (conversation!=null) { + conversation.endOtrIfNeeded(); + } + } + }; public void setOnTLSExceptionReceivedListener( OnTLSExceptionReceived listener) { @@ -325,8 +336,7 @@ public class XmppConnectionService extends Service { msg, x.getContent())); } } - } else { - // Log.d(LOGTAG,"presence without resource "+packet.toString()); + onContactStatusChanged.onContactStatusChanged(contact); } } else if (type.equals("unavailable")) { if (fromParts.length != 2) { @@ -334,6 +344,7 @@ public class XmppConnectionService extends Service { } else { contact.removePresence(fromParts[1]); } + onContactStatusChanged.onContactStatusChanged(contact); } else if (type.equals("subscribe")) { Log.d(LOGTAG, "received subscribe packet from " + packet.getFrom()); @@ -947,6 +958,15 @@ public class XmppConnectionService extends Service { public List<Account> getAccounts() { return this.accounts; } + + public Conversation findActiveConversation(Contact contact) { + for (Conversation conversation : this.getConversations()) { + if (conversation.getContact() == contact) { + return conversation; + } + } + return null; + } public Conversation findOrCreateConversation(Account account, String jid, boolean muc) { |