MUC: differentiated a few more errors.

This commit is contained in:
Michael 2014-10-05 12:31:49 +02:00
parent 5371dd025a
commit 54e9235bfc
4 changed files with 42 additions and 1 deletions

View file

@ -262,5 +262,8 @@
<string name="pref_conference_name">Konferenz-Name</string> <string name="pref_conference_name">Konferenz-Name</string>
<string name="pref_conference_name_summary">Konferenz-Thema statt Raum-JID als Name verwenden</string> <string name="pref_conference_name_summary">Konferenz-Thema statt Raum-JID als Name verwenden</string>
<string name="toast_message_otr_fingerprint">OTR Fingerabdruck in die Zwischenablage kopiert!</string> <string name="toast_message_otr_fingerprint">OTR Fingerabdruck in die Zwischenablage kopiert!</string>
<string name="conference_banned">Du wurdest aus dem Konferenzraum verbannt</string>
<string name="conference_members_only">Der Konferenzraum ist nur für Mitglieder</string>
<string name="conference_kicked">Du wurdest aus dem Konferenzraum geworfen</string>
</resources> </resources>

View file

@ -262,5 +262,8 @@
<string name="pref_conference_name">Conference name</string> <string name="pref_conference_name">Conference name</string>
<string name="pref_conference_name_summary">Use rooms subject instead of JID to identify conferences</string> <string name="pref_conference_name_summary">Use rooms subject instead of JID to identify conferences</string>
<string name="toast_message_otr_fingerprint">OTR fingerprint copied to clipboard!</string> <string name="toast_message_otr_fingerprint">OTR fingerprint copied to clipboard!</string>
<string name="conference_banned">You were been banned from the conference room</string>
<string name="conference_members_only">The conference room is only for members</string>
<string name="conference_kicked">You were been kicked from the conference room</string>
</resources> </resources>

View file

@ -15,6 +15,13 @@ public class MucOptions {
public static final int ERROR_NICK_IN_USE = 1; public static final int ERROR_NICK_IN_USE = 1;
public static final int ERROR_ROOM_NOT_FOUND = 2; public static final int ERROR_ROOM_NOT_FOUND = 2;
public static final int ERROR_PASSWORD_REQUIRED = 3; 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 interface OnRenameListener {
public void onRename(boolean success); public void onRename(boolean success);
@ -179,6 +186,18 @@ public class MucOptions {
x.getContent())); 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")) { } else if (type.equals("unavailable")) {
deleteUser(packet.getAttribute("from").split("/", 2)[1]); deleteUser(packet.getAttribute("from").split("/", 2)[1]);
} else if (type.equals("error")) { } else if (type.equals("error")) {
@ -199,6 +218,10 @@ public class MucOptions {
this.passwordChanged = true; this.passwordChanged = true;
} }
this.error = ERROR_PASSWORD_REQUIRED; 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;
} }
} }
} }

View file

@ -485,6 +485,18 @@ public class ConversationFragment extends Fragment {
showSnackbar(R.string.conference_requires_password, showSnackbar(R.string.conference_requires_password,
R.string.enter_password, enterPassword); R.string.enter_password, enterPassword);
break; 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: default:
break; break;
} }