思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c
以下内容为反编译后的 MultiUserChat.java 源代码,内容仅作参考
package org.jivesoftware.smackx.muc;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.AsyncButOrdered;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.PresenceListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.StanzaCollector;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.chat.Chat;
import org.jivesoftware.smack.chat.ChatManager;
import org.jivesoftware.smack.chat.ChatMessageListener;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.MessageWithBodiesFilter;
import org.jivesoftware.smack.filter.MessageWithSubjectFilter;
import org.jivesoftware.smack.filter.MessageWithThreadFilter;
import org.jivesoftware.smack.filter.NotFilter;
import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.PresenceTypeFilter;
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaIdFilter;
import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.filter.ToMatchesFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.iqregister.packet.Registration;
import org.jivesoftware.smackx.muc.MucEnterConfiguration;
import org.jivesoftware.smackx.muc.MultiUserChatException;
import org.jivesoftware.smackx.muc.filter.MUCUserStatusCodeFilter;
import org.jivesoftware.smackx.muc.packet.Destroy;
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
import org.jivesoftware.smackx.muc.packet.MUCItem;
import org.jivesoftware.smackx.muc.packet.MUCOwner;
import org.jivesoftware.smackx.muc.packet.MUCUser;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
public class MultiUserChat {
public final XMPPConnection connection;
public final StanzaFilter fromRoomFilter;
public final StanzaFilter fromRoomGroupchatFilter;
public StanzaCollector messageCollector;
public final MultiUserChatManager multiUserChatManager;
public uw3 myRoomJid;
public final tw3 room;
public String subject;
public static final Logger LOGGER = Logger.getLogger(MultiUserChat.class.getName());
public static final sx3<qw3, Void> KNOWN_MUC_SERVICES = new sx3<>(100, 86400000);
public static final AsyncButOrdered<MultiUserChat> asyncButOrdered = new AsyncButOrdered<>();
public static final StanzaFilter DECLINE_FILTER = new AndFilter(MessageTypeFilter.NORMAL, new StanzaExtensionFilter("x", MUCUser.NAMESPACE));
public final Map<uw3, Presence> occupantsMap = new ConcurrentHashMap();
public final Set<InvitationRejectionListener> invitationRejectionListeners = new CopyOnWriteArraySet();
public final Set<SubjectUpdatedListener> subjectUpdatedListeners = new CopyOnWriteArraySet();
public final Set<UserStatusListener> userStatusListeners = new CopyOnWriteArraySet();
public final Set<ParticipantStatusListener> participantStatusListeners = new CopyOnWriteArraySet();
public final Set<MessageListener> messageListeners = new CopyOnWriteArraySet();
public final Set<PresenceListener> presenceListeners = new CopyOnWriteArraySet();
public final Set<PresenceListener> presenceInterceptors = new CopyOnWriteArraySet();
public boolean joined = false;
public final StanzaListener messageListener = new StanzaListener() {
@Override
public void processStanza(Stanza stanza) throws SmackException.NotConnectedException {
final Message message = (Message) stanza;
MultiUserChat.asyncButOrdered.performAsyncButOrdered(MultiUserChat.this, new Runnable() {
@Override
public void run() {
for (MessageListener messageListener : MultiUserChat.this.messageListeners) {
messageListener.processMessage(message);
}
}
});
}
};
public final StanzaListener subjectListener = new StanzaListener() {
@Override
public void processStanza(Stanza stanza) {
final Message message = (Message) stanza;
final uw3 n0 = message.getFrom().n0();
MultiUserChat.this.subject = message.getSubject();
MultiUserChat.asyncButOrdered.performAsyncButOrdered(MultiUserChat.this, new Runnable() {
@Override
public void run() {
for (SubjectUpdatedListener subjectUpdatedListener : MultiUserChat.this.subjectUpdatedListeners) {
subjectUpdatedListener.subjectUpdated(message.getSubject(), n0);
}
}
});
}
};
public final StanzaListener presenceListener = new StanzaListener() {
@Override
public void processStanza(final Stanza stanza) {
final Presence presence = (Presence) stanza;
final uw3 n0 = presence.getFrom().n0();
if (n0 == null) {
return;
}
final uw3 uw3Var = MultiUserChat.this.myRoomJid;
final boolean a = presence.getFrom().a((CharSequence) uw3Var);
MultiUserChat.asyncButOrdered.performAsyncButOrdered(MultiUserChat.this, new Runnable() {
@Override
public void run() {
int i = AnonymousClass7.$SwitchMap$org$jivesoftware$smack$packet$Presence$Type[presence.getType().ordinal()];
if (i == 1) {
Presence presence2 = (Presence) MultiUserChat.this.occupantsMap.put(n0, presence);
if (presence2 != null) {
MUCUser from = MUCUser.from(presence2);
MUCAffiliation affiliation = from.getItem().getAffiliation();
MUCRole role = from.getItem().getRole();
MUCUser from2 = MUCUser.from(stanza);
MUCAffiliation affiliation2 = from2.getItem().getAffiliation();
MultiUserChat.this.checkRoleModifications(role, from2.getItem().getRole(), a, n0);
MultiUserChat.this.checkAffiliationModifications(affiliation, affiliation2, a, n0);
} else if (!a) {
for (ParticipantStatusListener participantStatusListener : MultiUserChat.this.participantStatusListeners) {
participantStatusListener.joined(n0);
}
}
} else if (i == 2) {
MultiUserChat.this.occupantsMap.remove(n0);
MUCUser from3 = MUCUser.from(stanza);
if (from3 != null && from3.hasStatus()) {
MultiUserChat.this.checkPresenceCode(from3.getStatus(), presence.getFrom().a((CharSequence) uw3Var), from3, n0);
} else if (!a) {
for (ParticipantStatusListener participantStatusListener2 : MultiUserChat.this.participantStatusListeners) {
participantStatusListener2.left(n0);
}
}
}
for (PresenceListener presenceListener : MultiUserChat.this.presenceListeners) {
presenceListener.processPresence(presence);
}
}
});
}
};
public final StanzaListener declinesListener = new StanzaListener() {
@Override
public void processStanza(Stanza stanza) {
Message message = (Message) stanza;
MUCUser.Decline decline = MUCUser.from(stanza).getDecline();
if (decline == null) {
return;
}
MultiUserChat.this.fireInvitationRejectionListeners(message, decline);
}
};
public final StanzaListener presenceInterceptor = new StanzaListener() {
@Override
public void processStanza(Stanza stanza) {
Presence presence = (Presence) stanza;
for (PresenceListener presenceListener : MultiUserChat.this.presenceInterceptors) {
presenceListener.processPresence(presence);
}
}
};
public static class AnonymousClass7 {
public static final int[] $SwitchMap$org$jivesoftware$smack$packet$Presence$Type = new int[Presence.Type.values().length];
static {
try {
$SwitchMap$org$jivesoftware$smack$packet$Presence$Type[Presence.Type.available.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$org$jivesoftware$smack$packet$Presence$Type[Presence.Type.unavailable.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public class MucCreateConfigFormHandle {
public MucCreateConfigFormHandle() {
}
public MucConfigFormManager getConfigFormManager() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return MultiUserChat.this.getConfigFormManager();
}
public void makeInstant() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MultiUserChat.this.sendConfigurationForm(new Form(DataForm.Type.submit));
}
}
public MultiUserChat(XMPPConnection xMPPConnection, tw3 tw3Var, MultiUserChatManager multiUserChatManager) {
this.connection = xMPPConnection;
this.room = tw3Var;
this.multiUserChatManager = multiUserChatManager;
this.fromRoomFilter = FromMatchesFilter.create(tw3Var);
this.fromRoomGroupchatFilter = new AndFilter(this.fromRoomFilter, MessageTypeFilter.GROUPCHAT);
}
private void changeAffiliationByAdmin(xw3 xw3Var, MUCAffiliation mUCAffiliation) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, mUCAffiliation, null);
}
private void changeRole(hx3 hx3Var, MUCRole mUCRole, String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCAdmin mUCAdmin = new MUCAdmin();
mUCAdmin.setTo(this.room);
mUCAdmin.setType(IQ.Type.set);
mUCAdmin.addItem(new MUCItem(mUCRole, hx3Var, str));
this.connection.createStanzaCollectorAndSend(mUCAdmin).nextResultOrThrow();
}
public void checkAffiliationModifications(MUCAffiliation mUCAffiliation, MUCAffiliation mUCAffiliation2, boolean z, uw3 uw3Var) {
if (!MUCAffiliation.owner.equals(mUCAffiliation) || MUCAffiliation.owner.equals(mUCAffiliation2)) {
if (!MUCAffiliation.admin.equals(mUCAffiliation) || MUCAffiliation.admin.equals(mUCAffiliation2)) {
if (MUCAffiliation.member.equals(mUCAffiliation) && !MUCAffiliation.member.equals(mUCAffiliation2)) {
if (z) {
for (UserStatusListener userStatusListener : this.userStatusListeners) {
userStatusListener.membershipRevoked();
}
} else {
for (ParticipantStatusListener participantStatusListener : this.participantStatusListeners) {
participantStatusListener.membershipRevoked(uw3Var);
}
}
}
} else if (z) {
for (UserStatusListener userStatusListener2 : this.userStatusListeners) {
userStatusListener2.adminRevoked();
}
} else {
for (ParticipantStatusListener participantStatusListener2 : this.participantStatusListeners) {
participantStatusListener2.adminRevoked(uw3Var);
}
}
} else if (z) {
for (UserStatusListener userStatusListener3 : this.userStatusListeners) {
userStatusListener3.ownershipRevoked();
}
} else {
for (ParticipantStatusListener participantStatusListener3 : this.participantStatusListeners) {
participantStatusListener3.ownershipRevoked(uw3Var);
}
}
if (!MUCAffiliation.owner.equals(mUCAffiliation) && MUCAffiliation.owner.equals(mUCAffiliation2)) {
if (z) {
for (UserStatusListener userStatusListener4 : this.userStatusListeners) {
userStatusListener4.ownershipGranted();
}
return;
}
for (ParticipantStatusListener participantStatusListener4 : this.participantStatusListeners) {
participantStatusListener4.ownershipGranted(uw3Var);
}
} else if (!MUCAffiliation.admin.equals(mUCAffiliation) && MUCAffiliation.admin.equals(mUCAffiliation2)) {
if (z) {
for (UserStatusListener userStatusListener5 : this.userStatusListeners) {
userStatusListener5.adminGranted();
}
return;
}
for (ParticipantStatusListener participantStatusListener5 : this.participantStatusListeners) {
participantStatusListener5.adminGranted(uw3Var);
}
} else if (!MUCAffiliation.member.equals(mUCAffiliation) && MUCAffiliation.member.equals(mUCAffiliation2)) {
if (z) {
for (UserStatusListener userStatusListener6 : this.userStatusListeners) {
userStatusListener6.membershipGranted();
}
return;
}
for (ParticipantStatusListener participantStatusListener6 : this.participantStatusListeners) {
participantStatusListener6.membershipGranted(uw3Var);
}
}
}
public void checkPresenceCode(Set<MUCUser.Status> set, boolean z, MUCUser mUCUser, uw3 uw3Var) {
if (set.contains(MUCUser.Status.KICKED_307)) {
if (z) {
userHasLeft();
for (UserStatusListener userStatusListener : this.userStatusListeners) {
userStatusListener.kicked(mUCUser.getItem().getActor(), mUCUser.getItem().getReason());
}
} else {
for (ParticipantStatusListener participantStatusListener : this.participantStatusListeners) {
participantStatusListener.kicked(uw3Var, mUCUser.getItem().getActor(), mUCUser.getItem().getReason());
}
}
}
if (set.contains(MUCUser.Status.BANNED_301)) {
if (z) {
this.joined = false;
for (UserStatusListener userStatusListener2 : this.userStatusListeners) {
userStatusListener2.banned(mUCUser.getItem().getActor(), mUCUser.getItem().getReason());
}
this.occupantsMap.clear();
this.myRoomJid = null;
userHasLeft();
} else {
for (ParticipantStatusListener participantStatusListener2 : this.participantStatusListeners) {
participantStatusListener2.banned(uw3Var, mUCUser.getItem().getActor(), mUCUser.getItem().getReason());
}
}
}
if (set.contains(MUCUser.Status.REMOVED_AFFIL_CHANGE_321) && z) {
this.joined = false;
for (UserStatusListener userStatusListener3 : this.userStatusListeners) {
userStatusListener3.membershipRevoked();
}
this.occupantsMap.clear();
this.myRoomJid = null;
userHasLeft();
}
if (set.contains(MUCUser.Status.NEW_NICKNAME_303)) {
for (ParticipantStatusListener participantStatusListener3 : this.participantStatusListeners) {
participantStatusListener3.nicknameChanged(uw3Var, mUCUser.getItem().getNick());
}
}
if (mUCUser.getDestroy() != null) {
MultiUserChat multiUserChat = this.multiUserChatManager.getMultiUserChat(mUCUser.getDestroy().getJid());
for (UserStatusListener userStatusListener4 : this.userStatusListeners) {
userStatusListener4.roomDestroyed(multiUserChat, mUCUser.getDestroy().getReason());
}
this.occupantsMap.clear();
this.myRoomJid = null;
userHasLeft();
}
}
public void checkRoleModifications(MUCRole mUCRole, MUCRole mUCRole2, boolean z, uw3 uw3Var) {
if ((MUCRole.visitor.equals(mUCRole) || MUCRole.none.equals(mUCRole)) && MUCRole.participant.equals(mUCRole2)) {
if (z) {
for (UserStatusListener userStatusListener : this.userStatusListeners) {
userStatusListener.voiceGranted();
}
} else {
for (ParticipantStatusListener participantStatusListener : this.participantStatusListeners) {
participantStatusListener.voiceGranted(uw3Var);
}
}
} else if (MUCRole.participant.equals(mUCRole) && (MUCRole.visitor.equals(mUCRole2) || MUCRole.none.equals(mUCRole2))) {
if (z) {
for (UserStatusListener userStatusListener2 : this.userStatusListeners) {
userStatusListener2.voiceRevoked();
}
} else {
for (ParticipantStatusListener participantStatusListener2 : this.participantStatusListeners) {
participantStatusListener2.voiceRevoked(uw3Var);
}
}
}
if (!MUCRole.moderator.equals(mUCRole) && MUCRole.moderator.equals(mUCRole2)) {
if (MUCRole.visitor.equals(mUCRole) || MUCRole.none.equals(mUCRole)) {
if (z) {
for (UserStatusListener userStatusListener3 : this.userStatusListeners) {
userStatusListener3.voiceGranted();
}
} else {
for (ParticipantStatusListener participantStatusListener3 : this.participantStatusListeners) {
participantStatusListener3.voiceGranted(uw3Var);
}
}
}
if (z) {
for (UserStatusListener userStatusListener4 : this.userStatusListeners) {
userStatusListener4.moderatorGranted();
}
return;
}
for (ParticipantStatusListener participantStatusListener4 : this.participantStatusListeners) {
participantStatusListener4.moderatorGranted(uw3Var);
}
} else if (MUCRole.moderator.equals(mUCRole) && !MUCRole.moderator.equals(mUCRole2)) {
if (MUCRole.visitor.equals(mUCRole2) || MUCRole.none.equals(mUCRole2)) {
if (z) {
for (UserStatusListener userStatusListener5 : this.userStatusListeners) {
userStatusListener5.voiceRevoked();
}
} else {
for (ParticipantStatusListener participantStatusListener5 : this.participantStatusListeners) {
participantStatusListener5.voiceRevoked(uw3Var);
}
}
}
if (z) {
for (UserStatusListener userStatusListener6 : this.userStatusListeners) {
userStatusListener6.moderatorRevoked();
}
return;
}
for (ParticipantStatusListener participantStatusListener6 : this.participantStatusListeners) {
participantStatusListener6.moderatorRevoked(uw3Var);
}
}
}
private Presence enter(MucEnterConfiguration mucEnterConfiguration) throws SmackException.NotConnectedException, SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.NotAMucServiceException {
qw3 g0 = this.room.g0();
StanzaCollector stanzaCollector = null;
if (!KNOWN_MUC_SERVICES.containsKey(g0)) {
if (this.multiUserChatManager.providesMucService(g0)) {
KNOWN_MUC_SERVICES.put(g0, null);
} else {
throw new MultiUserChatException.NotAMucServiceException(this);
}
}
Presence joinPresence = mucEnterConfiguration.getJoinPresence(this);
this.connection.addSyncStanzaListener(this.messageListener, this.fromRoomGroupchatFilter);
AndFilter andFilter = new AndFilter(this.fromRoomFilter, StanzaTypeFilter.PRESENCE);
this.connection.addSyncStanzaListener(this.presenceListener, andFilter);
this.connection.addSyncStanzaListener(this.subjectListener, new AndFilter(this.fromRoomFilter, MessageWithSubjectFilter.INSTANCE, new NotFilter(MessageTypeFilter.ERROR), new NotFilter(MessageWithBodiesFilter.INSTANCE), new NotFilter(MessageWithThreadFilter.INSTANCE)));
this.connection.addSyncStanzaListener(this.declinesListener, new AndFilter(this.fromRoomFilter, DECLINE_FILTER));
this.connection.addStanzaInterceptor(this.presenceInterceptor, new AndFilter(ToMatchesFilter.create(this.room), StanzaTypeFilter.PRESENCE));
this.messageCollector = this.connection.createStanzaCollector(this.fromRoomGroupchatFilter);
try {
try {
StanzaCollector createStanzaCollectorAndSend = this.connection.createStanzaCollectorAndSend(new AndFilter(StanzaTypeFilter.PRESENCE, new OrFilter(new AndFilter(FromMatchesFilter.createBare(getRoom()), MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF), new AndFilter(FromMatchesFilter.createFull(joinPresence.getTo()), new StanzaIdFilter(joinPresence), PresenceTypeFilter.ERROR))), joinPresence);
StanzaCollector createStanzaCollector = this.connection.createStanzaCollector(StanzaCollector.newConfiguration().setCollectorToReset(createStanzaCollectorAndSend).setStanzaFilter(andFilter));
Presence presence = (Presence) createStanzaCollectorAndSend.nextResultOrThrow(mucEnterConfiguration.getTimeout());
if (createStanzaCollector != null) {
createStanzaCollector.cancel();
}
setNickname(presence.getFrom().V());
this.joined = true;
this.multiUserChatManager.addJoinedRoom(this.room);
return presence;
} catch (Throwable th) {
if (0 != 0) {
stanzaCollector.cancel();
}
throw th;
}
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
removeConnectionCallbacks();
throw e;
}
}
public void fireInvitationRejectionListeners(Message message, MUCUser.Decline decline) {
InvitationRejectionListener[] invitationRejectionListenerArr;
tw3 from = decline.getFrom();
String reason = decline.getReason();
synchronized (this.invitationRejectionListeners) {
invitationRejectionListenerArr = new InvitationRejectionListener[this.invitationRejectionListeners.size()];
this.invitationRejectionListeners.toArray(invitationRejectionListenerArr);
}
for (InvitationRejectionListener invitationRejectionListener : invitationRejectionListenerArr) {
invitationRejectionListener.invitationDeclined(from, reason, message, decline);
}
}
private List<Affiliate> getAffiliatesByAdmin(MUCAffiliation mUCAffiliation) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCAdmin mUCAdmin = new MUCAdmin();
mUCAdmin.setTo(this.room);
mUCAdmin.setType(IQ.Type.get);
mUCAdmin.addItem(new MUCItem(mUCAffiliation));
ArrayList arrayList = new ArrayList();
for (MUCItem mUCItem : ((MUCAdmin) this.connection.createStanzaCollectorAndSend(mUCAdmin).nextResultOrThrow()).getItems()) {
arrayList.add(new Affiliate(mUCItem));
}
return arrayList;
}
private void removeConnectionCallbacks() {
this.connection.removeSyncStanzaListener(this.messageListener);
this.connection.removeSyncStanzaListener(this.presenceListener);
this.connection.removeSyncStanzaListener(this.subjectListener);
this.connection.removeSyncStanzaListener(this.declinesListener);
this.connection.removeStanzaInterceptor(this.presenceInterceptor);
StanzaCollector stanzaCollector = this.messageCollector;
if (stanzaCollector != null) {
stanzaCollector.cancel();
this.messageCollector = null;
}
}
private void setNickname(hx3 hx3Var) {
this.myRoomJid = bx3.a(this.room, hx3Var);
}
private synchronized void userHasLeft() {
this.occupantsMap.clear();
this.joined = false;
this.multiUserChatManager.removeJoinedRoom(this.room);
removeConnectionCallbacks();
}
public boolean addInvitationRejectionListener(InvitationRejectionListener invitationRejectionListener) {
return this.invitationRejectionListeners.add(invitationRejectionListener);
}
public boolean addMessageListener(MessageListener messageListener) {
return this.messageListeners.add(messageListener);
}
public boolean addParticipantListener(PresenceListener presenceListener) {
return this.presenceListeners.add(presenceListener);
}
public boolean addParticipantStatusListener(ParticipantStatusListener participantStatusListener) {
return this.participantStatusListeners.add(participantStatusListener);
}
public void addPresenceInterceptor(PresenceListener presenceListener) {
this.presenceInterceptors.add(presenceListener);
}
public boolean addSubjectUpdatedListener(SubjectUpdatedListener subjectUpdatedListener) {
return this.subjectUpdatedListeners.add(subjectUpdatedListener);
}
public boolean addUserStatusListener(UserStatusListener userStatusListener) {
return this.userStatusListeners.add(userStatusListener);
}
public void banUser(xw3 xw3Var, String str) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, MUCAffiliation.outcast, str);
}
public void banUsers(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.outcast);
}
public void changeAvailabilityStatus(String str, Presence.Mode mode) throws SmackException.NotConnectedException, InterruptedException, MultiUserChatException.MucNotJoinedException {
uw3 uw3Var = this.myRoomJid;
if (uw3Var != null) {
if (this.joined) {
Presence presence = new Presence(Presence.Type.available);
presence.setStatus(str);
presence.setMode(mode);
presence.setTo(uw3Var);
this.connection.sendStanza(presence);
return;
}
throw new MultiUserChatException.MucNotJoinedException(this);
}
throw new MultiUserChatException.MucNotJoinedException(this);
}
public synchronized void changeNickname(hx3 hx3Var) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.MucNotJoinedException {
Objects.requireNonNull(hx3Var, "Nickname must not be null or blank.");
if (this.joined) {
uw3 fullFrom = bx3.fullFrom(this.room, hx3Var);
Presence presence = new Presence(Presence.Type.available);
presence.setTo(fullFrom);
this.connection.createStanzaCollectorAndSend(new AndFilter(FromMatchesFilter.createFull(fullFrom), new StanzaTypeFilter(Presence.class)), presence).nextResultOrThrow();
setNickname(hx3Var);
} else {
throw new MultiUserChatException.MucNotJoinedException(this);
}
}
public void changeSubject(final String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
Message createMessage = createMessage();
createMessage.setSubject(str);
this.connection.createStanzaCollectorAndSend(new AndFilter(this.fromRoomGroupchatFilter, new StanzaFilter() {
@Override
public boolean accept(Stanza stanza) {
return str.equals(((Message) stanza).getSubject());
}
}), createMessage).nextResultOrThrow();
}
public synchronized MucCreateConfigFormHandle create(hx3 hx3Var) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.MissingMucCreationAcknowledgeException, MultiUserChatException.NotAMucServiceException {
MucCreateConfigFormHandle createOrJoin;
if (!this.joined) {
createOrJoin = createOrJoin(hx3Var);
if (createOrJoin == null) {
leave();
throw new MultiUserChatException.MissingMucCreationAcknowledgeException();
}
} else {
throw new MultiUserChatException.MucAlreadyJoinedException();
}
return createOrJoin;
}
public Message createMessage() {
return new Message(this.room, Message.Type.groupchat);
}
public synchronized MucCreateConfigFormHandle createOrJoin(hx3 hx3Var) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException {
return createOrJoin(getEnterConfigurationBuilder(hx3Var).build());
}
public MucCreateConfigFormHandle createOrJoinIfNecessary(hx3 hx3Var, String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException {
if (isJoined()) {
return null;
}
try {
return createOrJoin(getEnterConfigurationBuilder(hx3Var).withPassword(str).build());
} catch (MultiUserChatException.MucAlreadyJoinedException unused) {
return null;
}
}
public Chat createPrivateChat(uw3 uw3Var, ChatMessageListener chatMessageListener) {
return ChatManager.getInstanceFor(this.connection).createChat(uw3Var, chatMessageListener);
}
public void destroy(String str, tw3 tw3Var) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCOwner mUCOwner = new MUCOwner();
mUCOwner.setTo(this.room);
mUCOwner.setType(IQ.Type.set);
mUCOwner.setDestroy(new Destroy(tw3Var, str));
try {
this.connection.createStanzaCollectorAndSend(mUCOwner).nextResultOrThrow();
userHasLeft();
} catch (InterruptedException e) {
e = e;
userHasLeft();
throw e;
} catch (SmackException.NoResponseException e2) {
e = e2;
userHasLeft();
throw e;
} catch (SmackException.NotConnectedException e3) {
e = e3;
userHasLeft();
throw e;
} catch (XMPPException.XMPPErrorException e4) {
throw e4;
}
}
public List<Affiliate> getAdmins() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return getAffiliatesByAdmin(MUCAffiliation.admin);
}
public MucConfigFormManager getConfigFormManager() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return new MucConfigFormManager(this);
}
public Form getConfigurationForm() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCOwner mUCOwner = new MUCOwner();
mUCOwner.setTo(this.room);
mUCOwner.setType(IQ.Type.get);
return Form.getFormFrom((IQ) this.connection.createStanzaCollectorAndSend(mUCOwner).nextResultOrThrow());
}
public MucEnterConfiguration.Builder getEnterConfigurationBuilder(hx3 hx3Var) {
return new MucEnterConfiguration.Builder(hx3Var, this.connection.getReplyTimeout());
}
public List<Affiliate> getMembers() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return getAffiliatesByAdmin(MUCAffiliation.member);
}
public List<Occupant> getModerators() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return getOccupants(MUCRole.moderator);
}
public hx3 getNickname() {
uw3 uw3Var = this.myRoomJid;
if (uw3Var == null) {
return null;
}
return uw3Var.t0();
}
public Occupant getOccupant(uw3 uw3Var) {
Presence occupantPresence = getOccupantPresence(uw3Var);
if (occupantPresence != null) {
return new Occupant(occupantPresence);
}
return null;
}
public Presence getOccupantPresence(uw3 uw3Var) {
return this.occupantsMap.get(uw3Var);
}
public List<uw3> getOccupants() {
return new ArrayList(this.occupantsMap.keySet());
}
public int getOccupantsCount() {
return this.occupantsMap.size();
}
public List<Affiliate> getOutcasts() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return getAffiliatesByAdmin(MUCAffiliation.outcast);
}
public List<Affiliate> getOwners() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return getAffiliatesByAdmin(MUCAffiliation.owner);
}
public List<Occupant> getParticipants() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return getOccupants(MUCRole.participant);
}
public Form getRegistrationForm() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
Registration registration = new Registration();
registration.setType(IQ.Type.get);
registration.setTo(this.room);
return Form.getFormFrom((IQ) this.connection.createStanzaCollectorAndSend(registration).nextResultOrThrow());
}
public String getReservedNickname() throws SmackException, InterruptedException {
try {
Iterator<DiscoverInfo.Identity> it = ServiceDiscoveryManager.getInstanceFor(this.connection).discoverInfo(this.room, "x-roomuser-item").getIdentities().iterator();
if (it.hasNext()) {
return it.next().getName();
}
return null;
} catch (XMPPException e) {
LOGGER.log(Level.SEVERE, "Error retrieving room nickname", (Throwable) e);
return null;
}
}
public tw3 getRoom() {
return this.room;
}
public String getSubject() {
return this.subject;
}
public XMPPConnection getXmppConnection() {
return this.connection;
}
public void grantAdmin(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.admin);
}
public void grantMembership(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.member);
}
public void grantModerator(Collection<hx3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(collection, MUCRole.moderator);
}
public void grantOwnership(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.owner);
}
public void grantVoice(Collection<hx3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(collection, MUCRole.participant);
}
public void invite(tw3 tw3Var, String str) throws SmackException.NotConnectedException, InterruptedException {
invite(new Message(), tw3Var, str);
}
public boolean isJoined() {
return this.joined;
}
public void join(hx3 hx3Var) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException {
join(getEnterConfigurationBuilder(hx3Var).build());
}
public void kickParticipant(hx3 hx3Var, String str) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(hx3Var, MUCRole.none, str);
}
public synchronized void leave() throws SmackException.NotConnectedException, InterruptedException {
userHasLeft();
uw3 uw3Var = this.myRoomJid;
if (uw3Var == null) {
return;
}
Presence presence = new Presence(Presence.Type.unavailable);
presence.setTo(uw3Var);
this.connection.sendStanza(presence);
}
public synchronized Presence leaveSync() throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, XMPPException.XMPPErrorException, MultiUserChatException.MucNotJoinedException {
uw3 uw3Var;
Presence presence;
userHasLeft();
uw3Var = this.myRoomJid;
if (uw3Var != null) {
presence = new Presence(Presence.Type.unavailable);
presence.setTo(uw3Var);
} else {
throw new MultiUserChatException.MucNotJoinedException(this);
}
return (Presence) this.connection.createStanzaCollectorAndSend(new AndFilter(StanzaTypeFilter.PRESENCE, new StanzaIdFilter(presence), new OrFilter(new AndFilter(FromMatchesFilter.createFull(uw3Var), PresenceTypeFilter.UNAVAILABLE, MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF), new AndFilter(this.fromRoomFilter, PresenceTypeFilter.ERROR))), presence).nextResultOrThrow();
}
public Message nextMessage() throws MultiUserChatException.MucNotJoinedException, InterruptedException {
StanzaCollector stanzaCollector = this.messageCollector;
if (stanzaCollector != null) {
return (Message) stanzaCollector.nextResult();
}
throw new MultiUserChatException.MucNotJoinedException(this);
}
public Message pollMessage() throws MultiUserChatException.MucNotJoinedException {
StanzaCollector stanzaCollector = this.messageCollector;
if (stanzaCollector != null) {
return (Message) stanzaCollector.pollResult();
}
throw new MultiUserChatException.MucNotJoinedException(this);
}
public boolean removeInvitationRejectionListener(InvitationRejectionListener invitationRejectionListener) {
return this.invitationRejectionListeners.remove(invitationRejectionListener);
}
public boolean removeMessageListener(MessageListener messageListener) {
return this.messageListeners.remove(messageListener);
}
public boolean removeParticipantListener(PresenceListener presenceListener) {
return this.presenceListeners.remove(presenceListener);
}
public boolean removeParticipantStatusListener(ParticipantStatusListener participantStatusListener) {
return this.participantStatusListeners.remove(participantStatusListener);
}
public void removePresenceInterceptor(PresenceListener presenceListener) {
this.presenceInterceptors.remove(presenceListener);
}
public boolean removeSubjectUpdatedListener(SubjectUpdatedListener subjectUpdatedListener) {
return this.subjectUpdatedListeners.remove(subjectUpdatedListener);
}
public boolean removeUserStatusListener(UserStatusListener userStatusListener) {
return this.userStatusListeners.remove(userStatusListener);
}
public void requestVoice() throws SmackException.NotConnectedException, InterruptedException {
DataForm dataForm = new DataForm(DataForm.Type.submit);
FormField formField = new FormField(FormField.FORM_TYPE);
formField.addValue("http://jabber.org/protocol/muc#request");
dataForm.addField(formField);
FormField formField2 = new FormField("muc#role");
formField2.setType(FormField.Type.text_single);
formField2.setLabel("Requested role");
formField2.addValue("participant");
dataForm.addField(formField2);
Message message = new Message(this.room);
message.addExtension(dataForm);
this.connection.sendStanza(message);
}
public void revokeAdmin(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.admin);
}
public void revokeMembership(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.none);
}
public void revokeModerator(Collection<hx3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(collection, MUCRole.participant);
}
public void revokeOwnership(Collection<? extends xw3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(collection, MUCAffiliation.admin);
}
public void revokeVoice(Collection<hx3> collection) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(collection, MUCRole.visitor);
}
public void sendConfigurationForm(Form form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCOwner mUCOwner = new MUCOwner();
mUCOwner.setTo(this.room);
mUCOwner.setType(IQ.Type.set);
mUCOwner.addExtension(form.getDataFormToSend());
this.connection.createStanzaCollectorAndSend(mUCOwner).nextResultOrThrow();
}
public void sendMessage(String str) throws SmackException.NotConnectedException, InterruptedException {
Message createMessage = createMessage();
createMessage.setBody(str);
this.connection.sendStanza(createMessage);
}
public void sendRegistrationForm(Form form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
Registration registration = new Registration();
registration.setType(IQ.Type.set);
registration.setTo(this.room);
registration.addExtension(form.getDataFormToSend());
this.connection.createStanzaCollectorAndSend(registration).nextResultOrThrow();
}
public String toString() {
return "MUC: " + ((Object) this.room) + "(" + ((Object) this.connection.getUser()) + ")";
}
private void changeAffiliationByAdmin(xw3 xw3Var, MUCAffiliation mUCAffiliation, String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCAdmin mUCAdmin = new MUCAdmin();
mUCAdmin.setTo(this.room);
mUCAdmin.setType(IQ.Type.set);
mUCAdmin.addItem(new MUCItem(mUCAffiliation, xw3Var, str));
this.connection.createStanzaCollectorAndSend(mUCAdmin).nextResultOrThrow();
}
private List<Occupant> getOccupants(MUCRole mUCRole) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCAdmin mUCAdmin = new MUCAdmin();
mUCAdmin.setTo(this.room);
mUCAdmin.setType(IQ.Type.get);
mUCAdmin.addItem(new MUCItem(mUCRole));
ArrayList arrayList = new ArrayList();
for (MUCItem mUCItem : ((MUCAdmin) this.connection.createStanzaCollectorAndSend(mUCAdmin).nextResultOrThrow()).getItems()) {
arrayList.add(new Occupant(mUCItem));
}
return arrayList;
}
public void grantAdmin(xw3 xw3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, MUCAffiliation.admin);
}
public void grantMembership(xw3 xw3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, MUCAffiliation.member, null);
}
public void grantModerator(hx3 hx3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(hx3Var, MUCRole.moderator, null);
}
public void grantOwnership(xw3 xw3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, MUCAffiliation.owner, null);
}
public void grantVoice(hx3 hx3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(hx3Var, MUCRole.participant, null);
}
public void invite(Message message, tw3 tw3Var, String str) throws SmackException.NotConnectedException, InterruptedException {
message.setTo(this.room);
MUCUser mUCUser = new MUCUser();
mUCUser.setInvite(new MUCUser.Invite(str, tw3Var));
message.addExtension(mUCUser);
this.connection.sendStanza(message);
}
public void revokeAdmin(vw3 vw3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(vw3Var, MUCAffiliation.member);
}
public void revokeMembership(xw3 xw3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, MUCAffiliation.none, null);
}
public void revokeModerator(hx3 hx3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(hx3Var, MUCRole.participant, null);
}
public void revokeOwnership(xw3 xw3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeAffiliationByAdmin(xw3Var, MUCAffiliation.admin, null);
}
public void revokeVoice(hx3 hx3Var) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException {
changeRole(hx3Var, MUCRole.visitor, null);
}
@Deprecated
public MucCreateConfigFormHandle createOrJoin(hx3 hx3Var, String str, DiscussionHistory discussionHistory, long j) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException {
return createOrJoin(getEnterConfigurationBuilder(hx3Var).withPassword(str).timeoutAfter(j).build());
}
public void join(hx3 hx3Var, String str) throws XMPPException.XMPPErrorException, InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException {
join(getEnterConfigurationBuilder(hx3Var).withPassword(str).build());
}
public Message nextMessage(long j) throws MultiUserChatException.MucNotJoinedException, InterruptedException {
StanzaCollector stanzaCollector = this.messageCollector;
if (stanzaCollector != null) {
return (Message) stanzaCollector.nextResult(j);
}
throw new MultiUserChatException.MucNotJoinedException(this);
}
public void sendMessage(Message message) throws SmackException.NotConnectedException, InterruptedException {
message.setTo(this.room);
message.setType(Message.Type.groupchat);
this.connection.sendStanza(message);
}
@Deprecated
public void join(hx3 hx3Var, String str, DiscussionHistory discussionHistory, long j) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException {
join(getEnterConfigurationBuilder(hx3Var).withPassword(str).timeoutAfter(j).build());
}
public synchronized MucCreateConfigFormHandle createOrJoin(MucEnterConfiguration mucEnterConfiguration) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException {
if (!this.joined) {
MUCUser from = MUCUser.from(enter(mucEnterConfiguration));
if (from == null || !from.getStatus().contains(MUCUser.Status.ROOM_CREATED_201)) {
return null;
}
return new MucCreateConfigFormHandle();
}
throw new MultiUserChatException.MucAlreadyJoinedException();
}
private void changeRole(Collection<hx3> collection, MUCRole mUCRole) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCAdmin mUCAdmin = new MUCAdmin();
mUCAdmin.setTo(this.room);
mUCAdmin.setType(IQ.Type.set);
for (hx3 hx3Var : collection) {
mUCAdmin.addItem(new MUCItem(mUCRole, hx3Var));
}
this.connection.createStanzaCollectorAndSend(mUCAdmin).nextResultOrThrow();
}
private void changeAffiliationByAdmin(Collection<? extends xw3> collection, MUCAffiliation mUCAffiliation) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
MUCAdmin mUCAdmin = new MUCAdmin();
mUCAdmin.setTo(this.room);
mUCAdmin.setType(IQ.Type.set);
for (xw3 xw3Var : collection) {
mUCAdmin.addItem(new MUCItem(mUCAffiliation, xw3Var));
}
this.connection.createStanzaCollectorAndSend(mUCAdmin).nextResultOrThrow();
}
public synchronized void join(MucEnterConfiguration mucEnterConfiguration) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException {
if (this.joined) {
try {
leaveSync();
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | MultiUserChatException.MucNotJoinedException e) {
LOGGER.log(Level.WARNING, "Could not leave MUC prior joining, assuming we are not joined", e);
}
}
enter(mucEnterConfiguration);
}
}