diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/MucOptions.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/MucOptions.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 52a862ef..cf49cf65 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -23,7 +23,7 @@ public class MucOptions { OUTCAST("outcast", 0, R.string.outcast), NONE("none", 1, R.string.no_affiliation); - private Affiliation(String string, int rank, int resId) { + Affiliation(String string, int rank, int resId) { this.string = string; this.resId = resId; this.rank = rank; @@ -52,18 +52,20 @@ public class MucOptions { } public enum Role { - MODERATOR("moderator", R.string.moderator), - VISITOR("visitor", R.string.visitor), - PARTICIPANT("participant", R.string.participant), - NONE("none", R.string.no_role); + MODERATOR("moderator", R.string.moderator,3), + VISITOR("visitor", R.string.visitor,1), + PARTICIPANT("participant", R.string.participant,2), + NONE("none", R.string.no_role,0); - private Role(String string, int resId) { + private Role(String string, int resId, int rank) { this.string = string; this.resId = resId; + this.rank = rank; } private String string; private int resId; + private int rank; public int getResId() { return resId; @@ -73,6 +75,10 @@ public class MucOptions { public String toString() { return this.string; } + + public boolean ranks(Role role) { + return rank >= role.rank; + } } public static final int ERROR_NO_ERROR = 0; @@ -233,6 +239,10 @@ public class MucOptions { return !membersOnly() || self.getAffiliation().ranks(Affiliation.ADMIN); } + public boolean participating() { + return !online() || self.getRole().ranks(Role.PARTICIPANT); + } + public boolean membersOnly() { return hasFeature("muc_membersonly"); } @@ -245,6 +255,10 @@ public class MucOptions { return hasFeature("muc_persistent"); } + public boolean moderated() { + return hasFeature("muc_moderated"); + } + public void deleteUser(String name) { for (int i = 0; i < users.size(); ++i) { if (users.get(i).getName().equals(name)) { |