2014-10-22 16:38:44 +00:00
|
|
|
package eu.siacs.conversations.entities;
|
|
|
|
|
2018-06-18 20:17:10 +00:00
|
|
|
import android.support.annotation.NonNull;
|
2018-07-08 18:52:55 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2015-07-20 12:26:29 +00:00
|
|
|
|
2014-10-22 16:38:44 +00:00
|
|
|
import java.util.ArrayList;
|
2018-06-18 20:17:10 +00:00
|
|
|
import java.util.Collections;
|
2016-02-29 12:18:07 +00:00
|
|
|
import java.util.HashSet;
|
2014-10-22 16:38:44 +00:00
|
|
|
import java.util.List;
|
2018-07-08 18:52:55 +00:00
|
|
|
import java.util.Locale;
|
2016-02-29 12:18:07 +00:00
|
|
|
import java.util.Set;
|
2014-10-22 16:38:44 +00:00
|
|
|
|
2017-03-07 13:36:05 +00:00
|
|
|
import eu.siacs.conversations.Config;
|
2015-01-05 14:06:39 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2018-07-07 09:20:39 +00:00
|
|
|
import eu.siacs.conversations.services.MessageArchiveService;
|
2017-10-27 13:46:12 +00:00
|
|
|
import eu.siacs.conversations.utils.JidHelper;
|
2017-11-19 00:53:04 +00:00
|
|
|
import eu.siacs.conversations.utils.UIHelper;
|
2017-03-07 13:36:05 +00:00
|
|
|
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
2015-11-26 16:44:29 +00:00
|
|
|
import eu.siacs.conversations.xmpp.forms.Data;
|
|
|
|
import eu.siacs.conversations.xmpp.forms.Field;
|
2015-12-03 17:18:34 +00:00
|
|
|
import eu.siacs.conversations.xmpp.pep.Avatar;
|
2018-03-05 17:30:40 +00:00
|
|
|
import rocks.xmpp.addr.Jid;
|
2015-01-05 14:06:39 +00:00
|
|
|
|
2014-10-22 16:38:44 +00:00
|
|
|
public class MucOptions {
|
2015-01-05 14:06:39 +00:00
|
|
|
|
2016-05-27 08:35:00 +00:00
|
|
|
private boolean mAutoPushConfiguration = true;
|
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
public Account getAccount() {
|
|
|
|
return this.conversation.getAccount();
|
|
|
|
}
|
|
|
|
|
2018-07-08 18:52:55 +00:00
|
|
|
public boolean setSelf(User user) {
|
2015-12-03 17:18:34 +00:00
|
|
|
this.self = user;
|
2018-07-08 18:52:55 +00:00
|
|
|
final boolean roleChanged = this.conversation.setAttribute("role",user.role.toString());
|
|
|
|
final boolean affiliationChanged = this.conversation.setAttribute("affiliation",user.affiliation.toString());
|
|
|
|
return roleChanged || affiliationChanged;
|
2015-12-03 17:18:34 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 12:10:40 +00:00
|
|
|
public void changeAffiliation(Jid jid, Affiliation affiliation) {
|
|
|
|
User user = findUserByRealJid(jid);
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
if (user != null && user.getRole() == Role.NONE) {
|
|
|
|
users.remove(user);
|
|
|
|
if (affiliation.ranks(Affiliation.MEMBER)) {
|
|
|
|
user.affiliation = affiliation;
|
|
|
|
users.add(user);
|
|
|
|
}
|
2016-05-16 13:50:57 +00:00
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-27 08:35:00 +00:00
|
|
|
public void flagNoAutoPushConfiguration() {
|
|
|
|
mAutoPushConfiguration = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean autoPushConfiguration() {
|
|
|
|
return mAutoPushConfiguration;
|
|
|
|
}
|
|
|
|
|
2017-03-07 13:36:05 +00:00
|
|
|
public boolean isSelf(Jid counterpart) {
|
2018-02-10 18:06:31 +00:00
|
|
|
return counterpart.equals(self.getFullJid());
|
2017-03-07 13:36:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void resetChatState() {
|
|
|
|
synchronized (users) {
|
2018-03-30 06:47:37 +00:00
|
|
|
for (User user : users) {
|
2017-03-07 13:36:05 +00:00
|
|
|
user.chatState = Config.DEFAULT_CHATSTATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 09:20:39 +00:00
|
|
|
public boolean mamSupport() {
|
|
|
|
return MessageArchiveService.Version.has(getFeatures());
|
|
|
|
}
|
|
|
|
|
2015-01-05 14:06:39 +00:00
|
|
|
public enum Affiliation {
|
2018-07-08 18:52:55 +00:00
|
|
|
OWNER(4, R.string.owner),
|
|
|
|
ADMIN(3, R.string.admin),
|
|
|
|
MEMBER(2, R.string.member),
|
|
|
|
OUTCAST(0, R.string.outcast),
|
|
|
|
NONE(1, R.string.no_affiliation);
|
|
|
|
|
|
|
|
Affiliation(int rank, int resId) {
|
2015-01-05 14:06:39 +00:00
|
|
|
this.resId = resId;
|
2015-01-07 14:03:29 +00:00
|
|
|
this.rank = rank;
|
2015-01-05 14:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private int resId;
|
2015-01-07 14:03:29 +00:00
|
|
|
private int rank;
|
2015-01-05 14:06:39 +00:00
|
|
|
|
|
|
|
public int getResId() {
|
|
|
|
return resId;
|
|
|
|
}
|
2015-01-07 14:03:29 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-07-08 18:52:55 +00:00
|
|
|
return name().toLowerCase(Locale.US);
|
2015-01-07 14:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean outranks(Affiliation affiliation) {
|
|
|
|
return rank > affiliation.rank;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean ranks(Affiliation affiliation) {
|
|
|
|
return rank >= affiliation.rank;
|
|
|
|
}
|
2018-07-08 18:52:55 +00:00
|
|
|
|
|
|
|
public static Affiliation of(@Nullable String value) {
|
|
|
|
if (value == null) {
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return Affiliation.valueOf(value.toUpperCase(Locale.US));
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
}
|
2015-01-05 14:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public enum Role {
|
2018-07-08 18:52:55 +00:00
|
|
|
MODERATOR(R.string.moderator, 3),
|
|
|
|
VISITOR(R.string.visitor, 1),
|
|
|
|
PARTICIPANT(R.string.participant, 2),
|
|
|
|
NONE(R.string.no_role, 0);
|
2015-01-05 14:06:39 +00:00
|
|
|
|
2018-07-08 18:52:55 +00:00
|
|
|
Role(int resId, int rank) {
|
2015-01-05 14:06:39 +00:00
|
|
|
this.resId = resId;
|
2015-09-13 15:13:46 +00:00
|
|
|
this.rank = rank;
|
2015-01-05 14:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private int resId;
|
2015-09-13 15:13:46 +00:00
|
|
|
private int rank;
|
2015-01-05 14:06:39 +00:00
|
|
|
|
|
|
|
public int getResId() {
|
|
|
|
return resId;
|
|
|
|
}
|
2015-01-07 14:03:29 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-07-08 18:52:55 +00:00
|
|
|
return name().toLowerCase(Locale.US);
|
2015-01-07 14:03:29 +00:00
|
|
|
}
|
2015-09-13 15:13:46 +00:00
|
|
|
|
|
|
|
public boolean ranks(Role role) {
|
|
|
|
return rank >= role.rank;
|
|
|
|
}
|
2018-07-08 18:52:55 +00:00
|
|
|
|
|
|
|
public static Role of(@Nullable String value) {
|
|
|
|
if (value == null) {
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return Role.valueOf(value.toUpperCase(Locale.US));
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
}
|
2015-01-05 14:06:39 +00:00
|
|
|
}
|
|
|
|
|
2016-02-22 19:19:58 +00:00
|
|
|
public enum Error {
|
|
|
|
NO_RESPONSE,
|
2016-09-09 09:04:05 +00:00
|
|
|
SERVER_NOT_FOUND,
|
2016-02-22 19:19:58 +00:00
|
|
|
NONE,
|
|
|
|
NICK_IN_USE,
|
|
|
|
PASSWORD_REQUIRED,
|
|
|
|
BANNED,
|
|
|
|
MEMBERS_ONLY,
|
2018-07-07 08:28:31 +00:00
|
|
|
RESOURCE_CONSTRAINT,
|
2016-02-22 19:19:58 +00:00
|
|
|
KICKED,
|
|
|
|
SHUTDOWN,
|
2017-12-11 14:55:10 +00:00
|
|
|
INVALID_NICK,
|
2016-02-22 19:19:58 +00:00
|
|
|
UNKNOWN
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
|
2014-11-20 20:31:29 +00:00
|
|
|
public static final String STATUS_CODE_SELF_PRESENCE = "110";
|
2016-05-26 10:39:31 +00:00
|
|
|
public static final String STATUS_CODE_ROOM_CREATED = "201";
|
2014-10-22 16:38:44 +00:00
|
|
|
public static final String STATUS_CODE_BANNED = "301";
|
2014-11-20 20:31:29 +00:00
|
|
|
public static final String STATUS_CODE_CHANGED_NICK = "303";
|
2014-10-22 16:38:44 +00:00
|
|
|
public static final String STATUS_CODE_KICKED = "307";
|
2016-02-22 19:19:58 +00:00
|
|
|
public static final String STATUS_CODE_AFFILIATION_CHANGE = "321";
|
|
|
|
public static final String STATUS_CODE_LOST_MEMBERSHIP = "322";
|
|
|
|
public static final String STATUS_CODE_SHUTDOWN = "332";
|
2014-10-22 16:38:44 +00:00
|
|
|
|
2014-11-20 17:20:42 +00:00
|
|
|
private interface OnEventListener {
|
2015-12-03 17:18:34 +00:00
|
|
|
void onSuccess();
|
2015-01-05 14:06:39 +00:00
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
void onFailure();
|
2014-11-20 17:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public interface OnRenameListener extends OnEventListener {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-17 13:01:56 +00:00
|
|
|
public static class User implements Comparable<User> {
|
2015-01-07 17:34:24 +00:00
|
|
|
private Role role = Role.NONE;
|
|
|
|
private Affiliation affiliation = Affiliation.NONE;
|
2016-05-16 12:10:40 +00:00
|
|
|
private Jid realJid;
|
2015-12-03 17:18:34 +00:00
|
|
|
private Jid fullJid;
|
2014-10-22 16:38:44 +00:00
|
|
|
private long pgpKeyId = 0;
|
2015-12-03 17:18:34 +00:00
|
|
|
private Avatar avatar;
|
|
|
|
private MucOptions options;
|
2017-03-07 13:36:05 +00:00
|
|
|
private ChatState chatState = Config.DEFAULT_CHATSTATE;
|
2014-10-22 16:38:44 +00:00
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
public User(MucOptions options, Jid from) {
|
|
|
|
this.options = options;
|
|
|
|
this.fullJid = from;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
public String getName() {
|
2018-03-05 17:30:40 +00:00
|
|
|
return fullJid == null ? null : fullJid.getResource();
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 12:10:40 +00:00
|
|
|
public void setRealJid(Jid jid) {
|
2018-03-05 17:30:40 +00:00
|
|
|
this.realJid = jid != null ? jid.asBareJid() : null;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 14:06:39 +00:00
|
|
|
public Role getRole() {
|
2014-10-22 16:38:44 +00:00
|
|
|
return this.role;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRole(String role) {
|
2018-07-08 18:52:55 +00:00
|
|
|
this.role = Role.of(role);
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 14:06:39 +00:00
|
|
|
public Affiliation getAffiliation() {
|
2014-10-22 16:38:44 +00:00
|
|
|
return this.affiliation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAffiliation(String affiliation) {
|
2018-07-08 18:52:55 +00:00
|
|
|
this.affiliation = Affiliation.of(affiliation);
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setPgpKeyId(long id) {
|
|
|
|
this.pgpKeyId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getPgpKeyId() {
|
2017-04-25 13:19:47 +00:00
|
|
|
if (this.pgpKeyId != 0) {
|
|
|
|
return this.pgpKeyId;
|
|
|
|
} else if (realJid != null) {
|
|
|
|
return getAccount().getRoster().getContact(realJid).getPgpKeyId();
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Contact getContact() {
|
2016-05-17 13:01:56 +00:00
|
|
|
if (fullJid != null) {
|
|
|
|
return getAccount().getRoster().getContactFromRoster(realJid);
|
2018-03-30 06:47:37 +00:00
|
|
|
} else if (realJid != null) {
|
2016-05-17 13:01:56 +00:00
|
|
|
return getAccount().getRoster().getContact(realJid);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2015-12-03 17:18:34 +00:00
|
|
|
}
|
|
|
|
|
2015-12-04 20:36:48 +00:00
|
|
|
public boolean setAvatar(Avatar avatar) {
|
|
|
|
if (this.avatar != null && this.avatar.equals(avatar)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
this.avatar = avatar;
|
|
|
|
return true;
|
|
|
|
}
|
2015-12-03 17:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getAvatar() {
|
|
|
|
return avatar == null ? null : avatar.getFilename();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Account getAccount() {
|
|
|
|
return options.getAccount();
|
|
|
|
}
|
|
|
|
|
2017-11-19 00:53:04 +00:00
|
|
|
public Conversation getConversation() {
|
|
|
|
return options.getConversation();
|
|
|
|
}
|
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
public Jid getFullJid() {
|
|
|
|
return fullJid;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
|
|
User user = (User) o;
|
|
|
|
|
|
|
|
if (role != user.role) return false;
|
|
|
|
if (affiliation != user.affiliation) return false;
|
|
|
|
if (realJid != null ? !realJid.equals(user.realJid) : user.realJid != null)
|
|
|
|
return false;
|
|
|
|
return fullJid != null ? fullJid.equals(user.fullJid) : user.fullJid == null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-22 18:25:50 +00:00
|
|
|
public boolean isDomain() {
|
|
|
|
return realJid != null && realJid.getLocal() == null && role == Role.NONE;
|
|
|
|
}
|
|
|
|
|
2016-05-16 12:10:40 +00:00
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
int result = role != null ? role.hashCode() : 0;
|
|
|
|
result = 31 * result + (affiliation != null ? affiliation.hashCode() : 0);
|
|
|
|
result = 31 * result + (realJid != null ? realJid.hashCode() : 0);
|
|
|
|
result = 31 * result + (fullJid != null ? fullJid.hashCode() : 0);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-03-30 06:47:37 +00:00
|
|
|
return "[fulljid:" + String.valueOf(fullJid) + ",realjid:" + String.valueOf(realJid) + ",affiliation" + affiliation.toString() + "]";
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
2016-05-17 12:25:58 +00:00
|
|
|
|
|
|
|
public boolean realJidMatchesAccount() {
|
2018-03-05 17:30:40 +00:00
|
|
|
return realJid != null && realJid.equals(options.account.getJid().asBareJid());
|
2016-05-17 12:25:58 +00:00
|
|
|
}
|
2016-05-17 13:01:56 +00:00
|
|
|
|
|
|
|
@Override
|
2018-06-18 20:17:10 +00:00
|
|
|
public int compareTo(@NonNull User another) {
|
2016-06-14 12:41:32 +00:00
|
|
|
if (another.getAffiliation().outranks(getAffiliation())) {
|
|
|
|
return 1;
|
|
|
|
} else if (getAffiliation().outranks(another.getAffiliation())) {
|
|
|
|
return -1;
|
2016-05-17 13:01:56 +00:00
|
|
|
} else {
|
2016-07-04 17:30:19 +00:00
|
|
|
return getComparableName().compareToIgnoreCase(another.getComparableName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getComparableName() {
|
|
|
|
Contact contact = getContact();
|
|
|
|
if (contact != null) {
|
|
|
|
return contact.getDisplayName();
|
|
|
|
} else {
|
|
|
|
String name = getName();
|
|
|
|
return name == null ? "" : name;
|
2016-05-17 13:01:56 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-19 08:47:03 +00:00
|
|
|
|
|
|
|
public Jid getRealJid() {
|
|
|
|
return realJid;
|
|
|
|
}
|
2017-03-07 13:36:05 +00:00
|
|
|
|
|
|
|
public boolean setChatState(ChatState chatState) {
|
|
|
|
if (this.chatState == chatState) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.chatState = chatState;
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private Account account;
|
2016-05-19 08:47:03 +00:00
|
|
|
private final Set<User> users = new HashSet<>();
|
2018-06-18 20:17:10 +00:00
|
|
|
private ServiceDiscoveryResult serviceDiscoveryResult;
|
2017-12-17 15:23:19 +00:00
|
|
|
private final Conversation conversation;
|
2014-10-22 16:38:44 +00:00
|
|
|
private boolean isOnline = false;
|
2016-02-22 19:19:58 +00:00
|
|
|
private Error error = Error.NONE;
|
2015-12-03 17:18:34 +00:00
|
|
|
public OnRenameListener onRenameListener = null;
|
|
|
|
private User self;
|
2014-10-22 16:38:44 +00:00
|
|
|
private String password = null;
|
|
|
|
|
|
|
|
public MucOptions(Conversation conversation) {
|
|
|
|
this.account = conversation.getAccount();
|
|
|
|
this.conversation = conversation;
|
2018-03-30 06:47:37 +00:00
|
|
|
this.self = new User(this, createJoinJid(getProposedNick()));
|
2018-07-08 18:52:55 +00:00
|
|
|
this.self.affiliation = Affiliation.of(conversation.getAttribute("affiliation"));
|
|
|
|
this.self.role = Role.of(conversation.getAttribute("role"));
|
2018-03-30 06:47:37 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 20:17:10 +00:00
|
|
|
public boolean updateConfiguration(ServiceDiscoveryResult serviceDiscoveryResult) {
|
|
|
|
this.serviceDiscoveryResult = serviceDiscoveryResult;
|
|
|
|
String name;
|
2018-06-19 09:05:21 +00:00
|
|
|
Field roomConfigName = getRoomInfoForm().getFieldByName("muc#roomconfig_roomname");
|
|
|
|
if (roomConfigName != null) {
|
|
|
|
name = roomConfigName.getValue();
|
2018-06-18 20:17:10 +00:00
|
|
|
} else {
|
|
|
|
List<ServiceDiscoveryResult.Identity> identities = serviceDiscoveryResult.getIdentities();
|
|
|
|
String identityName = identities.size() > 0 ? identities.get(0).getName() : null;
|
2018-06-27 15:17:44 +00:00
|
|
|
final Jid jid = conversation.getJid();
|
|
|
|
if (identityName != null && !identityName.equals(jid == null ? null : jid.getEscapedLocal())) {
|
2018-06-18 20:17:10 +00:00
|
|
|
name = identityName;
|
|
|
|
} else {
|
|
|
|
name = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean changed = conversation.setAttribute("muc_name", name);
|
2018-03-30 06:47:37 +00:00
|
|
|
changed |= conversation.setAttribute(Conversation.ATTRIBUTE_MEMBERS_ONLY, this.hasFeature("muc_membersonly"));
|
|
|
|
changed |= conversation.setAttribute(Conversation.ATTRIBUTE_MODERATED, this.hasFeature("muc_moderated"));
|
|
|
|
changed |= conversation.setAttribute(Conversation.ATTRIBUTE_NON_ANONYMOUS, this.hasFeature("muc_nonanonymous"));
|
|
|
|
return changed;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 20:17:10 +00:00
|
|
|
|
|
|
|
private Data getRoomInfoForm() {
|
|
|
|
final List<Data> forms = serviceDiscoveryResult == null ? Collections.emptyList() : serviceDiscoveryResult.forms;
|
|
|
|
return forms.size() == 0 ? new Data() : forms.get(0);
|
2015-01-07 17:34:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-14 15:54:04 +00:00
|
|
|
public String getAvatar() {
|
|
|
|
return account.getRoster().getContact(conversation.getJid()).getAvatar();
|
|
|
|
}
|
|
|
|
|
2015-01-07 17:34:24 +00:00
|
|
|
public boolean hasFeature(String feature) {
|
2018-06-18 20:17:10 +00:00
|
|
|
return this.serviceDiscoveryResult != null && this.serviceDiscoveryResult.features.contains(feature);
|
2015-01-07 17:34:24 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 12:15:19 +00:00
|
|
|
public boolean hasVCards() {
|
|
|
|
return hasFeature("vcard-temp");
|
|
|
|
}
|
|
|
|
|
2015-01-07 17:34:24 +00:00
|
|
|
public boolean canInvite() {
|
2018-06-19 09:05:21 +00:00
|
|
|
Field field = getRoomInfoForm().getFieldByName("muc#roomconfig_allowinvites");
|
2015-11-26 16:44:29 +00:00
|
|
|
return !membersOnly() || self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canChangeSubject() {
|
2018-06-18 20:17:10 +00:00
|
|
|
Field field = getRoomInfoForm().getFieldByName("muc#roominfo_changesubject");
|
2015-11-26 16:44:29 +00:00
|
|
|
return self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
2015-01-07 17:34:24 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 16:35:42 +00:00
|
|
|
public boolean allowPm() {
|
2018-06-19 09:05:21 +00:00
|
|
|
final Field field = getRoomInfoForm().getFieldByName("muc#roomconfig_allowpm");
|
|
|
|
if (field == null) {
|
|
|
|
return true; //fall back if field does not exists
|
|
|
|
}
|
|
|
|
if ("anyone".equals(field.getValue())) {
|
|
|
|
return true;
|
|
|
|
} else if ("participants".equals(field.getValue())) {
|
|
|
|
return self.getRole().ranks(Role.PARTICIPANT);
|
|
|
|
} else if ("moderators".equals(field.getValue())) {
|
|
|
|
return self.getRole().ranks(Role.MODERATOR);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-18 16:35:42 +00:00
|
|
|
}
|
|
|
|
|
2015-09-13 15:13:46 +00:00
|
|
|
public boolean participating() {
|
2018-07-08 18:52:55 +00:00
|
|
|
return self.getRole().ranks(Role.PARTICIPANT) || !moderated();
|
2015-09-13 15:13:46 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 17:34:24 +00:00
|
|
|
public boolean membersOnly() {
|
2018-03-30 06:47:37 +00:00
|
|
|
return conversation.getBooleanAttribute(Conversation.ATTRIBUTE_MEMBERS_ONLY, false);
|
2015-01-07 17:34:24 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 15:42:35 +00:00
|
|
|
|
2018-07-07 09:20:39 +00:00
|
|
|
public List<String> getFeatures() {
|
|
|
|
return this.serviceDiscoveryResult != null ? this.serviceDiscoveryResult.features : Collections.emptyList();
|
2015-10-02 20:00:11 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 20:29:26 +00:00
|
|
|
public boolean nonanonymous() {
|
2018-03-30 06:47:37 +00:00
|
|
|
return conversation.getBooleanAttribute(Conversation.ATTRIBUTE_NON_ANONYMOUS, false);
|
2015-01-08 20:29:26 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 22:21:24 +00:00
|
|
|
public boolean isPrivateAndNonAnonymous() {
|
|
|
|
return membersOnly() && nonanonymous();
|
|
|
|
}
|
|
|
|
|
2015-09-13 15:13:46 +00:00
|
|
|
public boolean moderated() {
|
2018-03-30 06:47:37 +00:00
|
|
|
return conversation.getBooleanAttribute(Conversation.ATTRIBUTE_MODERATED, false);
|
2015-09-13 15:13:46 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 12:10:40 +00:00
|
|
|
public User deleteUser(Jid jid) {
|
|
|
|
User user = findUserByFullJid(jid);
|
|
|
|
if (user != null) {
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
users.remove(user);
|
2016-11-29 12:43:52 +00:00
|
|
|
boolean realJidInMuc = false;
|
|
|
|
for (User u : users) {
|
|
|
|
if (user.realJid != null && user.realJid.equals(u.realJid)) {
|
|
|
|
realJidInMuc = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-03-05 17:30:40 +00:00
|
|
|
boolean self = user.realJid != null && user.realJid.equals(account.getJid().asBareJid());
|
2016-11-29 12:43:52 +00:00
|
|
|
if (membersOnly()
|
|
|
|
&& nonanonymous()
|
|
|
|
&& user.affiliation.ranks(Affiliation.MEMBER)
|
|
|
|
&& user.realJid != null
|
2016-12-01 18:57:40 +00:00
|
|
|
&& !realJidInMuc
|
|
|
|
&& !self) {
|
2016-05-19 08:47:03 +00:00
|
|
|
user.role = Role.NONE;
|
|
|
|
user.avatar = null;
|
|
|
|
user.fullJid = null;
|
|
|
|
users.add(user);
|
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return user;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 07:49:24 +00:00
|
|
|
//returns true if real jid was new;
|
|
|
|
public boolean updateUser(User user) {
|
2016-05-16 12:10:40 +00:00
|
|
|
User old;
|
2017-06-28 07:49:24 +00:00
|
|
|
boolean realJidFound = false;
|
2016-05-16 12:10:40 +00:00
|
|
|
if (user.fullJid == null && user.realJid != null) {
|
|
|
|
old = findUserByRealJid(user.realJid);
|
2017-06-28 07:49:24 +00:00
|
|
|
realJidFound = old != null;
|
2016-05-16 12:10:40 +00:00
|
|
|
if (old != null) {
|
2016-05-19 08:47:03 +00:00
|
|
|
if (old.fullJid != null) {
|
2017-06-28 07:49:24 +00:00
|
|
|
return false; //don't add. user already exists
|
2016-05-19 08:47:03 +00:00
|
|
|
} else {
|
|
|
|
synchronized (users) {
|
|
|
|
users.remove(old);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
} else if (user.realJid != null) {
|
|
|
|
old = findUserByRealJid(user.realJid);
|
2017-06-28 07:49:24 +00:00
|
|
|
realJidFound = old != null;
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
if (old != null && old.fullJid == null) {
|
|
|
|
users.remove(old);
|
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
old = findUserByFullJid(user.getFullJid());
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (this.users) {
|
|
|
|
if (old != null) {
|
|
|
|
users.remove(old);
|
|
|
|
}
|
2017-03-05 16:42:17 +00:00
|
|
|
boolean fullJidIsSelf = isOnline && user.getFullJid() != null && user.getFullJid().equals(self.getFullJid());
|
2016-11-12 19:21:11 +00:00
|
|
|
if ((!membersOnly() || user.getAffiliation().ranks(Affiliation.MEMBER))
|
2017-03-05 16:42:17 +00:00
|
|
|
&& user.getAffiliation().outranks(Affiliation.OUTCAST)
|
2018-03-30 06:47:37 +00:00
|
|
|
&& !fullJidIsSelf) {
|
2016-11-12 19:21:11 +00:00
|
|
|
this.users.add(user);
|
2017-06-28 07:49:24 +00:00
|
|
|
return !realJidFound && user.realJid != null;
|
2016-11-12 19:21:11 +00:00
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
2017-06-28 07:49:24 +00:00
|
|
|
return false;
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public User findUserByFullJid(Jid jid) {
|
|
|
|
if (jid == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
for (User user : users) {
|
|
|
|
if (jid.equals(user.getFullJid())) {
|
|
|
|
return user;
|
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 09:13:34 +00:00
|
|
|
public User findUserByRealJid(Jid jid) {
|
2016-05-16 12:10:40 +00:00
|
|
|
if (jid == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
for (User user : users) {
|
|
|
|
if (jid.equals(user.realJid)) {
|
|
|
|
return user;
|
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2014-11-20 17:20:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 00:53:04 +00:00
|
|
|
public User findUser(ReadByMarker readByMarker) {
|
|
|
|
if (readByMarker.getRealJid() != null) {
|
2018-03-05 17:30:40 +00:00
|
|
|
User user = findUserByRealJid(readByMarker.getRealJid().asBareJid());
|
2017-11-19 00:53:04 +00:00
|
|
|
if (user == null) {
|
2018-03-30 06:47:37 +00:00
|
|
|
user = new User(this, readByMarker.getFullJid());
|
2017-11-19 00:53:04 +00:00
|
|
|
user.setRealJid(readByMarker.getRealJid());
|
|
|
|
}
|
|
|
|
return user;
|
|
|
|
} else if (readByMarker.getFullJid() != null) {
|
|
|
|
return findUserByFullJid(readByMarker.getFullJid());
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 15:11:31 +00:00
|
|
|
public boolean isContactInRoom(Contact contact) {
|
2018-03-05 17:30:40 +00:00
|
|
|
return findUserByRealJid(contact.getJid().asBareJid()) != null;
|
2016-06-14 15:11:31 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 12:10:40 +00:00
|
|
|
public boolean isUserInRoom(Jid jid) {
|
|
|
|
return findUserByFullJid(jid) != null;
|
2015-12-03 17:18:34 +00:00
|
|
|
}
|
|
|
|
|
2016-02-22 19:19:58 +00:00
|
|
|
public void setError(Error error) {
|
|
|
|
this.isOnline = isOnline && error == Error.NONE;
|
2014-11-20 17:20:42 +00:00
|
|
|
this.error = error;
|
|
|
|
}
|
|
|
|
|
2017-12-18 12:19:11 +00:00
|
|
|
public boolean setOnline() {
|
|
|
|
boolean before = this.isOnline;
|
2016-02-01 11:11:40 +00:00
|
|
|
this.isOnline = true;
|
2017-12-18 12:19:11 +00:00
|
|
|
return !before;
|
2016-02-01 11:11:40 +00:00
|
|
|
}
|
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
public ArrayList<User> getUsers() {
|
2016-05-17 08:43:48 +00:00
|
|
|
return getUsers(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<User> getUsers(boolean includeOffline) {
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
2018-06-22 18:25:50 +00:00
|
|
|
ArrayList<User> users = new ArrayList<>();
|
|
|
|
for (User user : this.users) {
|
|
|
|
if (!user.isDomain() && (includeOffline || user.getRole().ranks(Role.PARTICIPANT))) {
|
|
|
|
users.add(user);
|
2016-05-19 08:47:03 +00:00
|
|
|
}
|
2016-05-17 08:43:48 +00:00
|
|
|
}
|
2018-06-22 18:25:50 +00:00
|
|
|
return users;
|
2016-05-17 08:43:48 +00:00
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 09:32:42 +00:00
|
|
|
public ArrayList<User> getUsersWithChatState(ChatState state, int max) {
|
2017-03-07 13:36:05 +00:00
|
|
|
synchronized (users) {
|
|
|
|
ArrayList<User> list = new ArrayList<>();
|
2018-03-30 06:47:37 +00:00
|
|
|
for (User user : users) {
|
2017-03-07 13:36:05 +00:00
|
|
|
if (user.chatState == state) {
|
|
|
|
list.add(user);
|
2017-03-08 09:32:42 +00:00
|
|
|
if (list.size() >= max) {
|
|
|
|
break;
|
|
|
|
}
|
2017-03-07 13:36:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-03 17:18:34 +00:00
|
|
|
public List<User> getUsers(int max) {
|
2016-11-29 12:43:52 +00:00
|
|
|
ArrayList<User> subset = new ArrayList<>();
|
|
|
|
HashSet<Jid> jids = new HashSet<>();
|
2018-03-05 17:30:40 +00:00
|
|
|
jids.add(account.getJid().asBareJid());
|
2016-11-29 12:43:52 +00:00
|
|
|
synchronized (users) {
|
2018-03-30 06:47:37 +00:00
|
|
|
for (User user : users) {
|
2018-06-22 18:25:50 +00:00
|
|
|
if (user.getRealJid() == null || (user.getRealJid().getLocal() != null && jids.add(user.getRealJid()))) {
|
2016-11-29 12:43:52 +00:00
|
|
|
subset.add(user);
|
|
|
|
}
|
|
|
|
if (subset.size() >= max) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return subset;
|
2015-12-03 17:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getUserCount() {
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
return users.size();
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2017-08-23 08:06:32 +00:00
|
|
|
private String getProposedNick() {
|
2014-10-22 16:38:44 +00:00
|
|
|
if (conversation.getBookmark() != null
|
2014-12-02 23:00:25 +00:00
|
|
|
&& conversation.getBookmark().getNick() != null
|
2016-06-03 17:24:11 +00:00
|
|
|
&& !conversation.getBookmark().getNick().trim().isEmpty()) {
|
|
|
|
return conversation.getBookmark().getNick().trim();
|
2014-12-21 20:43:58 +00:00
|
|
|
} else if (!conversation.getJid().isBareJid()) {
|
2018-03-05 17:30:40 +00:00
|
|
|
return conversation.getJid().getResource();
|
2014-10-22 16:38:44 +00:00
|
|
|
} else {
|
2017-10-27 13:46:12 +00:00
|
|
|
return JidHelper.localPartOrFallback(account.getJid());
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getActualNick() {
|
|
|
|
if (this.self.getName() != null) {
|
|
|
|
return this.self.getName();
|
|
|
|
} else {
|
|
|
|
return this.getProposedNick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean online() {
|
|
|
|
return this.isOnline;
|
|
|
|
}
|
|
|
|
|
2016-02-22 19:19:58 +00:00
|
|
|
public Error getError() {
|
2014-10-22 16:38:44 +00:00
|
|
|
return this.error;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOnRenameListener(OnRenameListener listener) {
|
2014-11-20 17:20:42 +00:00
|
|
|
this.onRenameListener = listener;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setOffline() {
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
this.users.clear();
|
|
|
|
}
|
2016-02-22 19:19:58 +00:00
|
|
|
this.error = Error.NO_RESPONSE;
|
2014-10-22 16:38:44 +00:00
|
|
|
this.isOnline = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public User getSelf() {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-12-17 15:23:19 +00:00
|
|
|
public boolean setSubject(String subject) {
|
2018-03-30 06:47:37 +00:00
|
|
|
return this.conversation.setAttribute("subject", subject);
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getSubject() {
|
2017-12-17 15:23:19 +00:00
|
|
|
return this.conversation.getAttribute("subject");
|
|
|
|
}
|
|
|
|
|
2018-06-18 12:15:19 +00:00
|
|
|
public String getName() {
|
2018-06-27 15:17:44 +00:00
|
|
|
return this.conversation.getAttribute("muc_name");
|
2018-06-18 12:15:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 20:17:10 +00:00
|
|
|
private List<User> getFallbackUsersFromCryptoTargets() {
|
2017-12-17 15:23:19 +00:00
|
|
|
List<User> users = new ArrayList<>();
|
2018-03-30 06:47:37 +00:00
|
|
|
for (Jid jid : conversation.getAcceptedCryptoTargets()) {
|
|
|
|
User user = new User(this, null);
|
2017-12-17 15:23:19 +00:00
|
|
|
user.setRealJid(jid);
|
|
|
|
users.add(user);
|
|
|
|
}
|
|
|
|
return users;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<User> getUsersRelevantForNameAndAvatar() {
|
|
|
|
final List<User> users;
|
|
|
|
if (isOnline) {
|
|
|
|
users = getUsers(5);
|
|
|
|
} else {
|
|
|
|
users = getFallbackUsersFromCryptoTargets();
|
|
|
|
}
|
|
|
|
return users;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
2014-11-20 17:20:42 +00:00
|
|
|
public String createNameFromParticipants() {
|
2017-12-17 15:23:19 +00:00
|
|
|
List<User> users = getUsersRelevantForNameAndAvatar();
|
|
|
|
if (users.size() >= 2) {
|
2017-03-06 18:06:16 +00:00
|
|
|
StringBuilder builder = new StringBuilder();
|
2017-12-17 15:23:19 +00:00
|
|
|
for (User user : users) {
|
2017-03-06 18:06:16 +00:00
|
|
|
if (builder.length() != 0) {
|
|
|
|
builder.append(", ");
|
|
|
|
}
|
2017-11-19 00:53:04 +00:00
|
|
|
String name = UIHelper.getDisplayName(user);
|
|
|
|
if (name != null) {
|
|
|
|
builder.append(name.split("\\s+")[0]);
|
2014-11-20 17:20:42 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-01 11:11:40 +00:00
|
|
|
return builder.toString();
|
|
|
|
} else {
|
|
|
|
return null;
|
2014-11-20 17:20:42 +00:00
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public long[] getPgpKeyIds() {
|
2014-11-05 20:55:47 +00:00
|
|
|
List<Long> ids = new ArrayList<>();
|
2016-05-16 12:10:40 +00:00
|
|
|
for (User user : this.users) {
|
2016-02-01 11:11:40 +00:00
|
|
|
if (user.getPgpKeyId() != 0) {
|
|
|
|
ids.add(user.getPgpKeyId());
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-26 16:44:29 +00:00
|
|
|
ids.add(account.getPgpId());
|
|
|
|
long[] primitiveLongArray = new long[ids.size()];
|
2014-10-22 16:38:44 +00:00
|
|
|
for (int i = 0; i < ids.size(); ++i) {
|
2015-11-26 16:44:29 +00:00
|
|
|
primitiveLongArray[i] = ids.get(i);
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
2015-11-26 16:44:29 +00:00
|
|
|
return primitiveLongArray;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean pgpKeysInUse() {
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
for (User user : users) {
|
|
|
|
if (user.getPgpKeyId() != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean everybodyHasKeys() {
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
for (User user : users) {
|
|
|
|
if (user.getPgpKeyId() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-20 17:20:42 +00:00
|
|
|
public Jid createJoinJid(String nick) {
|
2014-12-21 20:43:58 +00:00
|
|
|
try {
|
2018-03-05 17:30:40 +00:00
|
|
|
return Jid.of(this.conversation.getJid().asBareJid().toString() + "/" + nick);
|
|
|
|
} catch (final IllegalArgumentException e) {
|
2014-12-21 20:43:58 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
|
2016-05-16 12:10:40 +00:00
|
|
|
public Jid getTrueCounterpart(Jid jid) {
|
|
|
|
if (jid.equals(getSelf().getFullJid())) {
|
2018-03-05 17:30:40 +00:00
|
|
|
return account.getJid().asBareJid();
|
2016-04-13 09:13:47 +00:00
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
User user = findUserByFullJid(jid);
|
2016-05-19 08:47:03 +00:00
|
|
|
return user == null ? null : user.realJid;
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getPassword() {
|
2014-11-20 17:20:42 +00:00
|
|
|
this.password = conversation.getAttribute(Conversation.ATTRIBUTE_MUC_PASSWORD);
|
2014-10-22 16:38:44 +00:00
|
|
|
if (this.password == null && conversation.getBookmark() != null
|
|
|
|
&& conversation.getBookmark().getPassword() != null) {
|
|
|
|
return conversation.getBookmark().getPassword();
|
|
|
|
} else {
|
|
|
|
return this.password;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPassword(String password) {
|
|
|
|
if (conversation.getBookmark() != null) {
|
|
|
|
conversation.getBookmark().setPassword(password);
|
|
|
|
} else {
|
|
|
|
this.password = password;
|
|
|
|
}
|
2014-11-20 17:20:42 +00:00
|
|
|
conversation.setAttribute(Conversation.ATTRIBUTE_MUC_PASSWORD, password);
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Conversation getConversation() {
|
|
|
|
return this.conversation;
|
|
|
|
}
|
2016-02-29 12:18:07 +00:00
|
|
|
|
2018-06-22 18:25:50 +00:00
|
|
|
public List<Jid> getMembers(final boolean includeDomains) {
|
2016-05-16 12:10:40 +00:00
|
|
|
ArrayList<Jid> members = new ArrayList<>();
|
2016-05-19 08:47:03 +00:00
|
|
|
synchronized (users) {
|
|
|
|
for (User user : users) {
|
2018-06-22 18:25:50 +00:00
|
|
|
if (user.affiliation.ranks(Affiliation.MEMBER) && user.realJid != null && (!user.isDomain() || includeDomains)) {
|
2016-05-19 08:47:03 +00:00
|
|
|
members.add(user.realJid);
|
|
|
|
}
|
2016-05-16 12:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return members;
|
2016-02-29 12:18:07 +00:00
|
|
|
}
|
2014-11-09 18:13:19 +00:00
|
|
|
}
|