From 4359afacb4a6ff52134485265b4c4a3b68542c11 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 14 Sep 2016 12:26:38 +0200 Subject: store jid if it was changed during bind --- src/main/java/eu/siacs/conversations/entities/Account.java | 6 ++++-- src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index 23001de7..38b5a999 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -277,8 +277,10 @@ public class Account extends AbstractEntity { return jid.getLocalpart(); } - public void setJid(final Jid jid) { - this.jid = jid; + public boolean setJid(final Jid next) { + final Jid prev = this.jid != null ? this.jid.toBareJid() : null; + this.jid = next; + return prev == null || (next != null && !prev.equals(next.toBareJid())); } public Jid getServer() { diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index fca5c566..e3af48e3 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -981,7 +981,10 @@ public class XmppConnection implements Runnable { final Element jid = bind.findChild("jid"); if (jid != null && jid.getContent() != null) { try { - account.setJid(Jid.fromString(jid.getContent())); + if (account.setJid(Jid.fromString(jid.getContent()))) { + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": bare jid changed during bind. updating database"); + mXmppConnectionService.databaseBackend.updateAccount(account); + } if (streamFeatures.hasChild("session") && !streamFeatures.findChild("session").hasChild("optional")) { sendStartSession(); -- cgit v1.2.3