From 54e9235bfcbfc22250bd9a14eb8575003856b91d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Oct 2014 12:31:49 +0200 Subject: [PATCH] MUC: differentiated a few more errors. --- res/values-de/strings.xml | 3 +++ res/values/strings.xml | 3 +++ .../conversations/entities/MucOptions.java | 23 +++++++++++++++++++ .../ui/ConversationFragment.java | 14 ++++++++++- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 6f21a71f5..72121774b 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -262,5 +262,8 @@ Konferenz-Name Konferenz-Thema statt Raum-JID als Name verwenden OTR Fingerabdruck in die Zwischenablage kopiert! + Du wurdest aus dem Konferenzraum verbannt + Der Konferenzraum ist nur für Mitglieder + Du wurdest aus dem Konferenzraum geworfen diff --git a/res/values/strings.xml b/res/values/strings.xml index b6e5e15c3..089a678b1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -262,5 +262,8 @@ Conference name Use room’s subject instead of JID to identify conferences OTR fingerprint copied to clipboard! + You were been banned from the conference room + The conference room is only for members + You were been kicked from the conference room diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java index 0294c8aae..595d9058a 100644 --- a/src/eu/siacs/conversations/entities/MucOptions.java +++ b/src/eu/siacs/conversations/entities/MucOptions.java @@ -15,6 +15,13 @@ public class MucOptions { public static final int ERROR_NICK_IN_USE = 1; public static final int ERROR_ROOM_NOT_FOUND = 2; public static final int ERROR_PASSWORD_REQUIRED = 3; + public static final int ERROR_BANNED = 4; + public static final int ERROR_MEMBERS_ONLY = 5; + + public static final int KICKED_FROM_ROOM = 9; + + public static final String STATUS_CODE_BANNED = "301"; + public static final String STATUS_CODE_KICKED = "307"; public interface OnRenameListener { public void onRename(boolean success); @@ -179,6 +186,18 @@ public class MucOptions { x.getContent())); } } + } else if (type.equals("unavailable") && name.equals(this.joinnick)) { + Element status = packet.findChild("x", + "http://jabber.org/protocol/muc#user").findChild( + "status"); + String code = status.getAttribute("code"); + if (code.equals(STATUS_CODE_KICKED)) { + this.isOnline = false; + this.error = KICKED_FROM_ROOM; + } else if (code.equals(STATUS_CODE_BANNED)) { + this.isOnline = false; + this.error = ERROR_BANNED; + } } else if (type.equals("unavailable")) { deleteUser(packet.getAttribute("from").split("/", 2)[1]); } else if (type.equals("error")) { @@ -199,6 +218,10 @@ public class MucOptions { this.passwordChanged = true; } this.error = ERROR_PASSWORD_REQUIRED; + } else if (error.hasChild("forbidden")) { + this.error = ERROR_BANNED; + } else if (error.hasChild("registration-required")) { + this.error = ERROR_MEMBERS_ONLY; } } } diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index c324eb320..2fa6b4544 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -485,6 +485,18 @@ public class ConversationFragment extends Fragment { showSnackbar(R.string.conference_requires_password, R.string.enter_password, enterPassword); break; + case MucOptions.ERROR_BANNED: + showSnackbar(R.string.conference_banned, + R.string.leave, leaveMuc); + break; + case MucOptions.ERROR_MEMBERS_ONLY: + showSnackbar(R.string.conference_members_only, + R.string.leave, leaveMuc); + break; + case MucOptions.KICKED_FROM_ROOM: + showSnackbar(R.string.conference_kicked, + R.string.leave, leaveMuc); + break; default: break; } @@ -493,7 +505,7 @@ public class ConversationFragment extends Fragment { getActivity().invalidateOptionsMenu(); updateChatMsgHint(); if (!activity.shouldPaneBeOpen()) { - activity.xmppConnectionService.markRead(conversation,true); + activity.xmppConnectionService.markRead(conversation, true); activity.updateConversationList(); } this.updateSendButton();