2004-03-29 23:29:55 +02:00
|
|
|
/**
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2004-03-29 23:29:55 +02:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2004-11-03 00:37:00 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2004-03-29 23:29:55 +02:00
|
|
|
*
|
2004-11-03 00:37:00 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2004-03-29 23:29:55 +02:00
|
|
|
*
|
2004-11-03 00:37:00 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2004-11-03 00:37:00 +01:00
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
package org.jivesoftware.smackx.muc.packet;
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2014-09-05 00:18:48 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2020-04-05 22:10:05 +02:00
|
|
|
import javax.xml.namespace.QName;
|
|
|
|
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
2017-06-14 17:12:43 +02:00
|
|
|
import org.jivesoftware.smack.packet.NamedElement;
|
|
|
|
import org.jivesoftware.smack.packet.Stanza;
|
2014-07-14 19:22:02 +02:00
|
|
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2016-07-29 16:21:20 +02:00
|
|
|
import org.jxmpp.jid.EntityBareJid;
|
|
|
|
import org.jxmpp.jid.EntityFullJid;
|
2017-01-20 17:06:06 +01:00
|
|
|
import org.jxmpp.jid.EntityJid;
|
2004-03-29 23:29:55 +02:00
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Represents extended presence information about roles, affiliations, full JIDs,
|
2004-03-29 23:29:55 +02:00
|
|
|
* or status codes scoped by the 'http://jabber.org/protocol/muc#user' namespace.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-03-29 23:29:55 +02:00
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2015-02-26 18:41:17 +01:00
|
|
|
public class MUCUser implements ExtensionElement {
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
public static final String ELEMENT = "x";
|
|
|
|
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#user";
|
2020-04-05 22:10:05 +02:00
|
|
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
2014-07-14 19:22:02 +02:00
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
private final Set<Status> statusCodes = new HashSet<>(4);
|
2014-09-05 00:18:48 +02:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
private Invite invite;
|
|
|
|
private Decline decline;
|
2014-07-14 19:22:02 +02:00
|
|
|
private MUCItem item;
|
2004-03-29 23:29:55 +02:00
|
|
|
private String password;
|
2004-04-01 23:46:39 +02:00
|
|
|
private Destroy destroy;
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2004-03-29 23:29:55 +02:00
|
|
|
public String getElementName() {
|
2014-07-14 19:22:02 +02:00
|
|
|
return ELEMENT;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2004-03-29 23:29:55 +02:00
|
|
|
public String getNamespace() {
|
2014-07-14 19:22:02 +02:00
|
|
|
return NAMESPACE;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
2019-02-04 13:27:41 +01:00
|
|
|
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
2014-07-14 19:22:02 +02:00
|
|
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
2014-08-20 21:25:14 +02:00
|
|
|
xml.rightAngleBracket();
|
2014-07-14 19:22:02 +02:00
|
|
|
xml.optElement(getInvite());
|
|
|
|
xml.optElement(getDecline());
|
|
|
|
xml.optElement(getItem());
|
|
|
|
xml.optElement("password", getPassword());
|
2015-01-02 00:14:04 +01:00
|
|
|
xml.append(statusCodes);
|
2014-07-14 19:22:02 +02:00
|
|
|
xml.optElement(getDestroy());
|
|
|
|
xml.closeElement(this);
|
|
|
|
return xml;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Returns the invitation for another user to a room. The sender of the invitation
|
|
|
|
* must be an occupant of the room. The invitation will be sent to the room which in turn
|
|
|
|
* will forward the invitation to the invitee.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return an invitation for another user to a room.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public Invite getInvite() {
|
|
|
|
return invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Returns the rejection to an invitation from another user to a room. The rejection will be
|
2017-12-13 23:10:11 +01:00
|
|
|
* sent to the room which in turn will forward the refusal to the inviting user.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return a rejection to an invitation from another user to a room.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public Decline getDecline() {
|
|
|
|
return decline;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Returns the item child that holds information about roles, affiliation, jids and nicks.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return an item child that holds information about roles, affiliation, jids and nicks.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2014-07-14 19:22:02 +02:00
|
|
|
public MUCItem getItem() {
|
2004-03-29 23:29:55 +02:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Returns the password to use to enter Password-Protected Room. A Password-Protected Room is
|
2004-04-01 23:46:39 +02:00
|
|
|
* a room that a user cannot enter without first providing the correct password.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the password to use to enter Password-Protected Room.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public String getPassword() {
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-05 00:18:48 +02:00
|
|
|
* Returns a set of status which holds the status code that assist in presenting notification messages.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2014-09-05 00:18:48 +02:00
|
|
|
* @return the set of status which holds the status code that assist in presenting notification messages.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2014-09-05 00:18:48 +02:00
|
|
|
public Set<Status> getStatus() {
|
|
|
|
return statusCodes;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
|
2015-03-03 17:05:42 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this MUCUser instance has also {@link Status} information.
|
|
|
|
* <p>
|
|
|
|
* If <code>true</code> is returned, then {@link #getStatus()} will return a non-empty set.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @return true if this MUCUser has status information.
|
|
|
|
* @since 4.1
|
|
|
|
*/
|
|
|
|
public boolean hasStatus() {
|
|
|
|
return !statusCodes.isEmpty();
|
|
|
|
}
|
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Returns the notification that the room has been destroyed. After a room has been destroyed,
|
2018-03-31 14:17:30 +02:00
|
|
|
* the room occupants will receive a Presence stanza of type 'unavailable' with the reason for
|
2004-04-01 23:46:39 +02:00
|
|
|
* the room destruction if provided by the room owner.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return a notification that the room has been destroyed.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2004-04-01 23:46:39 +02:00
|
|
|
public Destroy getDestroy() {
|
|
|
|
return destroy;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
2006-09-14 17:19:39 +02:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Sets the invitation for another user to a room. The sender of the invitation
|
|
|
|
* must be an occupant of the room. The invitation will be sent to the room which in turn
|
|
|
|
* will forward the invitation to the invitee.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @param invite the invitation for another user to a room.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public void setInvite(Invite invite) {
|
|
|
|
this.invite = invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Sets the rejection to an invitation from another user to a room. The rejection will be
|
2017-12-13 23:10:11 +01:00
|
|
|
* sent to the room which in turn will forward the refusal to the inviting user.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @param decline the rejection to an invitation from another user to a room.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public void setDecline(Decline decline) {
|
|
|
|
this.decline = decline;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Sets the item child that holds information about roles, affiliation, jids and nicks.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @param item the item child that holds information about roles, affiliation, jids and nicks.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2014-07-14 19:22:02 +02:00
|
|
|
public void setItem(MUCItem item) {
|
2004-03-29 23:29:55 +02:00
|
|
|
this.item = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Sets the password to use to enter Password-Protected Room. A Password-Protected Room is
|
2004-04-01 23:46:39 +02:00
|
|
|
* a room that a user cannot enter without first providing the correct password.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @param string the password to use to enter Password-Protected Room.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public void setPassword(String string) {
|
|
|
|
password = string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-05 00:18:48 +02:00
|
|
|
* Add the status codes which holds the codes that assists in presenting notification messages.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2014-09-05 00:18:48 +02:00
|
|
|
* @param statusCodes the status codes which hold the codes that assists in presenting notification
|
2004-04-01 23:46:39 +02:00
|
|
|
* messages.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2014-09-05 00:18:48 +02:00
|
|
|
public void addStatusCodes(Set<Status> statusCodes) {
|
|
|
|
this.statusCodes.addAll(statusCodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a status code which hold a code that assists in presenting notification messages.
|
|
|
|
*
|
|
|
|
* @param status the status code which olds a code that assists in presenting notification messages.
|
|
|
|
*/
|
|
|
|
public void addStatusCode(Status status) {
|
|
|
|
this.statusCodes.add(status);
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Sets the notification that the room has been destroyed. After a room has been destroyed,
|
2018-03-31 14:17:30 +02:00
|
|
|
* the room occupants will receive a Presence stanza of type 'unavailable' with the reason for
|
2004-04-01 23:46:39 +02:00
|
|
|
* the room destruction if provided by the room owner.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @param destroy the notification that the room has been destroyed.
|
|
|
|
*/
|
|
|
|
public void setDestroy(Destroy destroy) {
|
|
|
|
this.destroy = destroy;
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
/**
|
|
|
|
* Retrieve the MUCUser PacketExtension from packet, if any.
|
|
|
|
*
|
2019-08-30 12:08:30 +02:00
|
|
|
* @param packet TODO javadoc me please
|
2014-07-14 19:22:02 +02:00
|
|
|
* @return the MUCUser PacketExtension or {@code null}
|
2015-02-05 11:17:27 +01:00
|
|
|
* @deprecated use {@link #from(Stanza)} instead
|
2014-07-14 19:22:02 +02:00
|
|
|
*/
|
2014-09-16 22:14:10 +02:00
|
|
|
@Deprecated
|
2015-02-05 11:17:27 +01:00
|
|
|
public static MUCUser getFrom(Stanza packet) {
|
2014-09-16 22:14:10 +02:00
|
|
|
return from(packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the MUCUser PacketExtension from packet, if any.
|
|
|
|
*
|
2019-08-30 12:08:30 +02:00
|
|
|
* @param packet TODO javadoc me please
|
2014-09-16 22:14:10 +02:00
|
|
|
* @return the MUCUser PacketExtension or {@code null}
|
|
|
|
*/
|
2015-02-05 11:17:27 +01:00
|
|
|
public static MUCUser from(Stanza packet) {
|
2020-04-05 22:10:05 +02:00
|
|
|
return packet.getExtension(MUCUser.class);
|
2014-07-14 19:22:02 +02:00
|
|
|
}
|
|
|
|
|
2004-04-01 23:46:39 +02:00
|
|
|
/**
|
2004-03-29 23:29:55 +02:00
|
|
|
* Represents an invitation for another user to a room. The sender of the invitation
|
|
|
|
* must be an occupant of the room. The invitation will be sent to the room which in turn
|
2006-09-16 00:42:06 +02:00
|
|
|
* will forward the invitation to the invitee.
|
2004-03-29 23:29:55 +02:00
|
|
|
*
|
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2014-09-11 09:49:16 +02:00
|
|
|
public static class Invite implements NamedElement {
|
2017-05-23 16:45:04 +02:00
|
|
|
public static final String ELEMENT = "invite";
|
2014-07-14 19:22:02 +02:00
|
|
|
|
2016-07-29 16:21:20 +02:00
|
|
|
private final String reason;
|
2017-01-20 17:06:06 +01:00
|
|
|
|
|
|
|
/**
|
2017-12-13 23:10:11 +01:00
|
|
|
* From XEP-0045 § 7.8.2: "… whose value is the bare JID, full JID, or occupant JID of the inviting user …"
|
2017-01-20 17:06:06 +01:00
|
|
|
*/
|
|
|
|
private final EntityJid from;
|
|
|
|
|
2016-07-29 16:21:20 +02:00
|
|
|
private final EntityBareJid to;
|
|
|
|
|
|
|
|
public Invite(String reason, EntityFullJid from) {
|
|
|
|
this(reason, from, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Invite(String reason, EntityBareJid to) {
|
|
|
|
this(reason, null, to);
|
|
|
|
}
|
|
|
|
|
2017-01-20 17:06:06 +01:00
|
|
|
public Invite(String reason, EntityJid from, EntityBareJid to) {
|
2016-07-29 16:21:20 +02:00
|
|
|
this.reason = reason;
|
|
|
|
this.from = from;
|
|
|
|
this.to = to;
|
|
|
|
}
|
2006-09-14 17:19:39 +02:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2017-12-13 23:10:11 +01:00
|
|
|
* Returns the bare JID of the inviting user or, optionally, the room JID. (e.g.
|
2006-09-16 00:42:06 +02:00
|
|
|
* 'crone1@shakespeare.lit/desktop').
|
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the room's occupant that sent the invitation.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2017-01-20 17:06:06 +01:00
|
|
|
public EntityJid getFrom() {
|
2004-03-29 23:29:55 +02:00
|
|
|
return from;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Returns the message explaining the invitation.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the message explaining the invitation.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public String getReason() {
|
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Returns the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit')
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the bare JID of the invitee.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2016-07-29 16:21:20 +02:00
|
|
|
public EntityBareJid getTo() {
|
2004-03-29 23:29:55 +02:00
|
|
|
return to;
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
2019-02-04 13:27:41 +01:00
|
|
|
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
2014-07-14 19:22:02 +02:00
|
|
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
|
|
|
xml.optAttribute("to", getTo());
|
|
|
|
xml.optAttribute("from", getFrom());
|
2014-08-20 21:25:14 +02:00
|
|
|
xml.rightAngleBracket();
|
2014-07-14 19:22:02 +02:00
|
|
|
xml.optElement("reason", getReason());
|
|
|
|
xml.closeElement(this);
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getElementName() {
|
|
|
|
return ELEMENT;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
2006-09-16 00:42:06 +02:00
|
|
|
}
|
2004-03-29 23:29:55 +02:00
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Represents a rejection to an invitation from another user to a room. The rejection will be
|
2017-12-13 23:10:11 +01:00
|
|
|
* sent to the room which in turn will forward the refusal to the inviting user.
|
2004-03-29 23:29:55 +02:00
|
|
|
*
|
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2019-09-07 18:17:08 +02:00
|
|
|
public static class Decline implements ExtensionElement {
|
2014-07-14 19:22:02 +02:00
|
|
|
public static final String ELEMENT = "decline";
|
2021-04-18 17:19:32 +02:00
|
|
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
2014-07-14 19:22:02 +02:00
|
|
|
|
2016-07-29 16:21:20 +02:00
|
|
|
private final String reason;
|
|
|
|
private final EntityBareJid from;
|
|
|
|
private final EntityBareJid to;
|
|
|
|
|
|
|
|
public Decline(String reason, EntityBareJid to) {
|
|
|
|
this(reason, null, to);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Decline(String reason, EntityBareJid from, EntityBareJid to) {
|
|
|
|
this.reason = reason;
|
|
|
|
this.from = from;
|
|
|
|
this.to = to;
|
|
|
|
}
|
2006-09-14 17:19:39 +02:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Returns the bare JID of the invitee that rejected the invitation. (e.g.
|
2016-07-29 16:21:20 +02:00
|
|
|
* 'crone1@shakespeare.lit').
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the bare JID of the invitee that rejected the invitation.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2016-07-29 16:21:20 +02:00
|
|
|
public EntityBareJid getFrom() {
|
2004-03-29 23:29:55 +02:00
|
|
|
return from;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-01 23:46:39 +02:00
|
|
|
* Returns the message explaining why the invitation was rejected.
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the message explaining the reason for the rejection.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
|
|
|
public String getReason() {
|
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-13 23:10:11 +01:00
|
|
|
* Returns the bare JID of the inviting user. (e.g. 'hecate@shakespeare.lit')
|
2006-09-16 00:42:06 +02:00
|
|
|
*
|
2017-12-13 23:10:11 +01:00
|
|
|
* @return the bare JID of the inviting user.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2016-07-29 16:21:20 +02:00
|
|
|
public EntityBareJid getTo() {
|
2004-03-29 23:29:55 +02:00
|
|
|
return to;
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
2019-02-04 13:27:41 +01:00
|
|
|
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
2019-09-07 18:17:08 +02:00
|
|
|
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
2014-07-14 19:22:02 +02:00
|
|
|
xml.optAttribute("to", getTo());
|
|
|
|
xml.optAttribute("from", getFrom());
|
2014-08-20 21:25:14 +02:00
|
|
|
xml.rightAngleBracket();
|
2014-07-14 19:22:02 +02:00
|
|
|
xml.optElement("reason", getReason());
|
|
|
|
xml.closeElement(this);
|
|
|
|
return xml;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
2006-09-14 17:19:39 +02:00
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
|
|
|
public String getElementName() {
|
2021-04-18 17:19:32 +02:00
|
|
|
return QNAME.getLocalPart();
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
2019-09-07 18:17:08 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getNamespace() {
|
2021-04-18 17:19:32 +02:00
|
|
|
return QNAME.getNamespaceURI();
|
2019-09-07 18:17:08 +02:00
|
|
|
}
|
2006-09-16 00:42:06 +02:00
|
|
|
}
|
2004-03-29 23:29:55 +02:00
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Status code assists in presenting notification messages. The following link provides the
|
2014-09-05 00:18:48 +02:00
|
|
|
* list of existing error codes <a href="http://xmpp.org/registrar/mucstatus.html">Multi-User Chat Status Codes</a>.
|
2004-03-29 23:29:55 +02:00
|
|
|
*
|
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2015-04-06 10:45:12 +02:00
|
|
|
public static final class Status implements NamedElement {
|
2014-07-14 19:22:02 +02:00
|
|
|
public static final String ELEMENT = "status";
|
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
private static final Map<Integer, Status> statusMap = new HashMap<>(8);
|
2014-09-05 00:18:48 +02:00
|
|
|
|
2015-04-23 23:10:41 +02:00
|
|
|
public static final Status PRESENCE_TO_SELF_110 = Status.create(110);
|
2014-09-05 00:18:48 +02:00
|
|
|
public static final Status ROOM_CREATED_201 = Status.create(201);
|
|
|
|
public static final Status BANNED_301 = Status.create(301);
|
|
|
|
public static final Status NEW_NICKNAME_303 = Status.create(303);
|
|
|
|
public static final Status KICKED_307 = Status.create(307);
|
|
|
|
public static final Status REMOVED_AFFIL_CHANGE_321 = Status.create(321);
|
2020-04-16 21:20:35 +02:00
|
|
|
public static final Status REMOVED_FOR_TECHNICAL_REASONS_333 = Status.create(333);
|
2014-09-05 00:18:48 +02:00
|
|
|
|
|
|
|
private final Integer code;
|
|
|
|
|
|
|
|
public static Status create(String string) {
|
|
|
|
Integer integer = Integer.valueOf(string);
|
|
|
|
return create(integer);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Status create(Integer i) {
|
2020-04-16 21:20:53 +02:00
|
|
|
Status status;
|
|
|
|
// TODO: Use computeIfAbsent once Smack's minimum required Android SDK level is 24 or higher.
|
|
|
|
synchronized (statusMap) {
|
|
|
|
status = statusMap.get(i);
|
|
|
|
if (status == null) {
|
|
|
|
status = new Status(i);
|
|
|
|
statusMap.put(i, status);
|
|
|
|
}
|
2014-09-05 00:18:48 +02:00
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
2004-03-29 23:29:55 +02:00
|
|
|
|
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Creates a new instance of Status with the specified code.
|
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @param code the code that uniquely identifies the reason of the error.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2014-09-05 00:18:48 +02:00
|
|
|
private Status(int code) {
|
2004-03-29 23:29:55 +02:00
|
|
|
this.code = code;
|
|
|
|
}
|
2006-09-14 17:19:39 +02:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2006-09-16 00:42:06 +02:00
|
|
|
* Returns the code that uniquely identifies the reason of the error. The code
|
|
|
|
* assists in presenting notification messages.
|
|
|
|
*
|
2004-04-01 23:46:39 +02:00
|
|
|
* @return the code that uniquely identifies the reason of the error.
|
2004-03-29 23:29:55 +02:00
|
|
|
*/
|
2014-09-05 00:18:48 +02:00
|
|
|
public int getCode() {
|
2004-03-29 23:29:55 +02:00
|
|
|
return code;
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
2019-02-04 13:27:41 +01:00
|
|
|
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
2014-07-14 19:22:02 +02:00
|
|
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
|
|
|
xml.attribute("code", getCode());
|
|
|
|
xml.closeEmptyElement();
|
|
|
|
return xml;
|
2004-04-01 23:46:39 +02:00
|
|
|
}
|
|
|
|
|
2015-04-23 23:10:41 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return code.toString();
|
|
|
|
}
|
|
|
|
|
2014-09-05 00:18:48 +02:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
|
|
|
if (other == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (other instanceof Status) {
|
|
|
|
Status otherStatus = (Status) other;
|
|
|
|
return code.equals(otherStatus.getCode());
|
2015-03-18 21:01:49 +01:00
|
|
|
}
|
2014-09-05 00:18:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return code;
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
|
|
|
public String getElementName() {
|
|
|
|
return ELEMENT;
|
2004-04-01 23:46:39 +02:00
|
|
|
}
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|