From b1482212b879123344ef8dcdc622ce095a4dc765 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 12 Jun 2014 18:27:50 +0200 Subject: [PATCH] fire onContactStatusChanged only on online/offline changes. not on status changes --- src/eu/siacs/conversations/parser/MessageParser.java | 11 ----------- src/eu/siacs/conversations/parser/PresenceParser.java | 5 +++-- .../conversations/services/XmppConnectionService.java | 1 + 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index 63e789a37..fdd7db642 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -1,10 +1,7 @@ package eu.siacs.conversations.parser; -import java.util.List; - import net.java.otr4j.session.Session; import net.java.otr4j.session.SessionStatus; -import android.util.Log; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; @@ -45,16 +42,10 @@ public class MessageParser extends AbstractParser { String body = packet.getBody(); if (!conversation.hasValidOtrSession()) { if (properlyAddressed) { - Log.d("xmppService", - "starting new otr session with " - + packet.getFrom() - + " because no valid otr session has been found"); conversation.startOtrSession( mXmppConnectionService.getApplicationContext(), fromParts[1], false); } else { - Log.d("xmppService", account.getJid() - + ": ignoring otr session with " + fromParts[0]); return null; } } else { @@ -63,8 +54,6 @@ public class MessageParser extends AbstractParser { if (!foreignPresence.equals(fromParts[1])) { conversation.resetOtrSession(); if (properlyAddressed) { - Log.d("xmppService", - "replacing otr session with " + packet.getFrom()); conversation.startOtrSession( mXmppConnectionService.getApplicationContext(), fromParts[1], false); diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index cf55f61fb..2003d4cd6 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -1,6 +1,5 @@ package eu.siacs.conversations.parser; -import android.util.Log; import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; @@ -54,6 +53,7 @@ public class PresenceParser extends AbstractParser { Contact contact = account.getRoster().getContact(packet.getFrom()); if (type == null) { if (fromParts.length == 2) { + int sizeBefore = contact.getPresences().size(); contact.updatePresence(fromParts[1], Presences.parseShow(packet.findChild("show"))); PgpEngine pgp = mXmppConnectionService.getPgpEngine(); @@ -71,9 +71,10 @@ public class PresenceParser extends AbstractParser { x.getContent())); } } + boolean online = sizeBefore < contact.getPresences().size(); updateLastseen(packet, account,true); mXmppConnectionService.onContactStatusChanged - .onContactStatusChanged(contact,true); + .onContactStatusChanged(contact,online); } } else if (type.equals("unavailable")) { if (fromParts.length != 2) { diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 20268574d..44964c7c2 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -1194,6 +1194,7 @@ public class XmppConnectionService extends Service { Account account = conversation.getAccount(); List messages = conversation.getMessages(); Session otrSession = conversation.getOtrSession(); + Log.d(LOGTAG,account.getJid()+" otr session established with "+conversation.getContactJid()+"/"+otrSession.getSessionID().getUserID()); for (int i = 0; i < messages.size(); ++i) { Message msg = messages.get(i); if ((msg.getStatus() == Message.STATUS_UNSEND)