diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-07-15 23:03:45 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-07-15 23:03:45 +0200 |
commit | c991d31c15119490939df81a0566d58ec75f5fc1 (patch) | |
tree | f0579a8b6241da1dd96a7aa69d001396b7f69830 /src/main/java/de/pixart | |
parent | 9018eabd6d6477d8cf66d7cc9728c42607ff225c (diff) |
display propper toast after room has been destroyed
Diffstat (limited to '')
3 files changed, 32 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java index cf12a9533..774620707 100644 --- a/src/main/java/de/pixart/messenger/entities/MucOptions.java +++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java @@ -169,6 +169,7 @@ public class MucOptions { RESOURCE_CONSTRAINT, KICKED, SHUTDOWN, + DESTROYED, INVALID_NICK, UNKNOWN } diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java index 4091e34cd..6602e8aef 100644 --- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java +++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java @@ -18,6 +18,7 @@ import de.pixart.messenger.generator.IqGenerator; import de.pixart.messenger.generator.PresenceGenerator; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.utils.Namespace; +import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.InvalidJid; import de.pixart.messenger.xmpp.OnPresencePacketReceived; @@ -121,7 +122,15 @@ public class PresenceParser extends AbstractParser implements } } } else if (type.equals("unavailable")) { - if (codes.contains(MucOptions.STATUS_CODE_SHUTDOWN) && from.equals(mucOptions.getSelf().getFullJid())) { + final boolean fullJidMatches = from.equals(mucOptions.getSelf().getFullJid()); + if (x.hasChild("destroy") && fullJidMatches) { + Element destroy = x.findChild("destroy"); + final Jid alternate = destroy == null ? null : InvalidJid.getNullForInvalid(destroy.getAttributeAsJid("jid")); + mucOptions.setError(MucOptions.Error.DESTROYED); + if (alternate != null) { + Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": muc destroyed. alternate location " + alternate); + } + } else if (codes.contains(MucOptions.STATUS_CODE_SHUTDOWN) && fullJidMatches) { mucOptions.setError(MucOptions.Error.SHUTDOWN); } else if (codes.contains(MucOptions.STATUS_CODE_SELF_PRESENCE)) { if (codes.contains(MucOptions.STATUS_CODE_KICKED)) { @@ -167,6 +176,23 @@ public class PresenceParser extends AbstractParser implements mucOptions.setError(MucOptions.Error.MEMBERS_ONLY); } else if (error.hasChild("resource-constraint")) { mucOptions.setError(MucOptions.Error.RESOURCE_CONSTRAINT); + } else if (error.hasChild("gone")) { + final String gone = error.findChildContent("gone"); + final Jid alternate; + if (gone != null) { + final XmppUri xmppUri = new XmppUri(gone); + if (xmppUri.isJidValid()) { + alternate = xmppUri.getJid(); + } else { + alternate = null; + } + } else { + alternate = null; + } + mucOptions.setError(MucOptions.Error.DESTROYED); + if (alternate != null) { + Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": muc destroyed. alternate location " + alternate); + } } else { final String text = error.findChildContent("text"); if (text != null && text.contains("attribute 'to'")) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index f32aa26ed..bc98e06e3 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -2355,13 +2355,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke showSnackbar(R.string.conference_kicked, R.string.join, joinMuc); break; case UNKNOWN: - showSnackbar(R.string.conference_unknown_error, R.string.leave, leaveMuc); + showSnackbar(R.string.conference_unknown_error, R.string.leave, joinMuc); break; case INVALID_NICK: showSnackbar(R.string.invalid_muc_nick, R.string.edit, clickToMuc); case SHUTDOWN: showSnackbar(R.string.conference_shutdown, R.string.try_again, joinMuc); break; + case DESTROYED: + showSnackbar(R.string.conference_destroyed, R.string.leave, leaveMuc); + break; default: hideSnackbar(); break; |