send otr messages when contacts comes online

This commit is contained in:
iNPUTmice 2014-06-12 10:41:47 +02:00
parent e353a1c109
commit 18871230e1
3 changed files with 7 additions and 4 deletions

View File

@ -73,7 +73,7 @@ public class PresenceParser extends AbstractParser {
} }
updateLastseen(packet, account,true); updateLastseen(packet, account,true);
mXmppConnectionService.onContactStatusChanged mXmppConnectionService.onContactStatusChanged
.onContactStatusChanged(contact); .onContactStatusChanged(contact,true);
} }
} else if (type.equals("unavailable")) { } else if (type.equals("unavailable")) {
if (fromParts.length != 2) { if (fromParts.length != 2) {
@ -82,7 +82,7 @@ public class PresenceParser extends AbstractParser {
contact.removePresence(fromParts[1]); contact.removePresence(fromParts[1]);
} }
mXmppConnectionService.onContactStatusChanged mXmppConnectionService.onContactStatusChanged
.onContactStatusChanged(contact); .onContactStatusChanged(contact,false);
} else if (type.equals("subscribe")) { } else if (type.equals("subscribe")) {
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) { if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
mXmppConnectionService.sendPresenceUpdatesTo(contact); mXmppConnectionService.sendPresenceUpdatesTo(contact);

View File

@ -98,10 +98,13 @@ public class XmppConnectionService extends Service {
public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() { public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() {
@Override @Override
public void onContactStatusChanged(Contact contact) { public void onContactStatusChanged(Contact contact, boolean online) {
Conversation conversation = findActiveConversation(contact); Conversation conversation = findActiveConversation(contact);
if (conversation != null) { if (conversation != null) {
conversation.endOtrIfNeeded(); conversation.endOtrIfNeeded();
if (online&&(contact.getPresences().size() == 1)) {
sendUnsendMessages(conversation);
}
} }
} }
}; };

View File

@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
public interface OnContactStatusChanged { public interface OnContactStatusChanged {
public void onContactStatusChanged(Contact contact); public void onContactStatusChanged(Contact contact, boolean online);
} }