Merge branch 'master' of github.com:siacs/Conversations

This commit is contained in:
Daniel Gultsch 2015-12-02 16:38:33 +01:00
commit aa21797f43
4 changed files with 24 additions and 5 deletions

View file

@ -171,7 +171,7 @@ public class Message extends AbstractEntity {
} }
public static Message createStatusMessage(Conversation conversation, String body) { public static Message createStatusMessage(Conversation conversation, String body) {
Message message = new Message(); final Message message = new Message();
message.setType(Message.TYPE_STATUS); message.setType(Message.TYPE_STATUS);
message.setConversation(conversation); message.setConversation(conversation);
message.setBody(body); message.setBody(body);

View file

@ -6,6 +6,7 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.generator.PresenceGenerator; import eu.siacs.conversations.generator.PresenceGenerator;
@ -44,8 +45,8 @@ public class PresenceParser extends AbstractParser implements
} }
} }
public void parseContactPresence(PresencePacket packet, Account account) { public void parseContactPresence(final PresencePacket packet, final Account account) {
PresenceGenerator mPresenceGenerator = mXmppConnectionService.getPresenceGenerator(); final PresenceGenerator mPresenceGenerator = mXmppConnectionService.getPresenceGenerator();
final Jid from = packet.getFrom(); final Jid from = packet.getFrom();
if (from == null) { if (from == null) {
return; return;
@ -93,6 +94,17 @@ public class PresenceParser extends AbstractParser implements
mPresenceGenerator.sendPresenceUpdatesTo(contact)); mPresenceGenerator.sendPresenceUpdatesTo(contact));
} else { } else {
contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST); contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
final String statusMessage = packet.findChildContent("status");
if (statusMessage != null && !statusMessage.isEmpty()) {
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(
account, contact.getJid().toBareJid(), false);
conversation.add(new Message(
conversation,
statusMessage,
Message.ENCRYPTION_NONE,
Message.STATUS_RECEIVED
));
}
} }
} }
mXmppConnectionService.updateRosterUi(); mXmppConnectionService.updateRosterUi();

View file

@ -1322,6 +1322,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
leaveMuc(conversation); leaveMuc(conversation);
} else { } else {
conversation.endOtrIfNeeded(); conversation.endOtrIfNeeded();
if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
Log.d(Config.LOGTAG, "Canceling presence request from " + conversation.getJid().toString());
sendPresencePacket(
conversation.getAccount(),
mPresenceGenerator.stopPresenceUpdatesTo(conversation.getContact())
);
}
} }
this.databaseBackend.updateConversation(conversation); this.databaseBackend.updateConversation(conversation);
this.conversations.remove(conversation); this.conversations.remove(conversation);

View file

@ -218,7 +218,7 @@
<string name="this_device_omemo_fingerprint">Own OMEMO fingerprint</string> <string name="this_device_omemo_fingerprint">Own OMEMO fingerprint</string>
<string name="other_devices">Other devices</string> <string name="other_devices">Other devices</string>
<string name="trust_omemo_fingerprints">Trust OMEMO Fingerprints</string> <string name="trust_omemo_fingerprints">Trust OMEMO Fingerprints</string>
<string name="fetching_keys">Fetching keys...</string> <string name="fetching_keys">Fetching keys</string>
<string name="done">Done</string> <string name="done">Done</string>
<string name="verify">Verify</string> <string name="verify">Verify</string>
<string name="decrypt">Decrypt</string> <string name="decrypt">Decrypt</string>
@ -479,7 +479,7 @@
<string name="offering_x_file">Offering %s</string> <string name="offering_x_file">Offering %s</string>
<string name="hide_offline">Hide offline</string> <string name="hide_offline">Hide offline</string>
<string name="disable_account">Disable Account</string> <string name="disable_account">Disable Account</string>
<string name="contact_is_typing">%s is typing...</string> <string name="contact_is_typing">%s is typing</string>
<string name="contact_has_stopped_typing">%s has stopped typing</string> <string name="contact_has_stopped_typing">%s has stopped typing</string>
<string name="pref_chat_states">Typing notifications</string> <string name="pref_chat_states">Typing notifications</string>
<string name="pref_chat_states_summary">Let your contact know when you are writing a new message</string> <string name="pref_chat_states_summary">Let your contact know when you are writing a new message</string>