mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
Merge pull request #1146 from BrianBlade/minor_otr_tweaks
OTR: Fix onContactStatusChanged & dont archive OTR
This commit is contained in:
commit
77caf73103
@ -182,7 +182,7 @@ public class OtrEngine extends OtrCryptoEngineImpl implements OtrEngineHost {
|
|||||||
packet.setBody(body);
|
packet.setBody(body);
|
||||||
packet.addChild("private", "urn:xmpp:carbons:2");
|
packet.addChild("private", "urn:xmpp:carbons:2");
|
||||||
packet.addChild("no-copy", "urn:xmpp:hints");
|
packet.addChild("no-copy", "urn:xmpp:hints");
|
||||||
packet.addChild("no-store", "urn:xmpp:hints");
|
packet.addChild("no-permanent-store", "urn:xmpp:hints");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Jid jid = Jid.fromSessionID(session);
|
Jid jid = Jid.fromSessionID(session);
|
||||||
|
@ -71,6 +71,7 @@ public class MessageGenerator extends AbstractGenerator {
|
|||||||
MessagePacket packet = preparePacket(message, addDelay);
|
MessagePacket packet = preparePacket(message, addDelay);
|
||||||
packet.addChild("private", "urn:xmpp:carbons:2");
|
packet.addChild("private", "urn:xmpp:carbons:2");
|
||||||
packet.addChild("no-copy", "urn:xmpp:hints");
|
packet.addChild("no-copy", "urn:xmpp:hints");
|
||||||
|
packet.addChild("no-permanent-store", "urn:xmpp:hints");
|
||||||
try {
|
try {
|
||||||
packet.setBody(otrSession.transformSending(message.getBody())[0]);
|
packet.setBody(otrSession.transformSending(message.getBody())[0]);
|
||||||
return packet;
|
return packet;
|
||||||
|
@ -36,6 +36,7 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -174,14 +175,23 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
public void onContactStatusChanged(Contact contact, boolean online) {
|
public void onContactStatusChanged(Contact contact, boolean online) {
|
||||||
Conversation conversation = find(getConversations(), contact);
|
Conversation conversation = find(getConversations(), contact);
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
if (online && contact.getPresences().size() > 1) {
|
if (online) {
|
||||||
conversation.endOtrIfNeeded();
|
conversation.endOtrIfNeeded();
|
||||||
} else {
|
if (contact.getPresences().size() == 1) {
|
||||||
conversation.resetOtrSession();
|
|
||||||
}
|
|
||||||
if (online && (contact.getPresences().size() == 1)) {
|
|
||||||
sendUnsentMessages(conversation);
|
sendUnsentMessages(conversation);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (contact.getPresences().size() >= 1) {
|
||||||
|
if (conversation.hasValidOtrSession()) {
|
||||||
|
String otrResource = conversation.getOtrSession().getSessionID().getUserID();
|
||||||
|
if (!(Arrays.asList(contact.getPresences().asStringArray()).contains(otrResource))) {
|
||||||
|
conversation.endOtrIfNeeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
conversation.endOtrIfNeeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user