mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
fire onContactStatusChanged only on online/offline changes. not on status changes
This commit is contained in:
parent
18871230e1
commit
b1482212b8
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user