fire onContactStatusChanged only on online/offline changes. not on status changes

This commit is contained in:
iNPUTmice 2014-06-12 18:27:50 +02:00
parent 18871230e1
commit b1482212b8
3 changed files with 4 additions and 13 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -1194,6 +1194,7 @@ public class XmppConnectionService extends Service {
Account account = conversation.getAccount();
List<Message> 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)