2014-07-14 19:22:02 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2003-2007 Jive Software, 2014 Florian Schmaus
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
package org.jivesoftware.smackx.muc.packet;
|
|
|
|
|
2015-03-11 21:31:37 +01:00
|
|
|
import java.io.Serializable;
|
|
|
|
|
2014-09-11 09:49:16 +02:00
|
|
|
import org.jivesoftware.smack.packet.NamedElement;
|
2014-07-14 19:22:02 +02:00
|
|
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2015-05-27 19:29:51 +02:00
|
|
|
import org.jxmpp.jid.EntityBareJid;
|
2014-07-14 19:22:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a request to the server to destroy a room. The sender of the request should be the
|
|
|
|
* room's owner. If the sender of the destroy request is not the room's owner then the server will
|
|
|
|
* answer a "Forbidden" error.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-07-14 19:22:02 +02:00
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2015-03-12 13:12:39 +01:00
|
|
|
public class Destroy implements NamedElement, Serializable {
|
2015-03-11 21:31:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
public static final String ELEMENT = "destroy";
|
|
|
|
|
2015-03-11 21:31:37 +01:00
|
|
|
private final String reason;
|
2015-05-27 19:29:51 +02:00
|
|
|
private final EntityBareJid jid;
|
2015-03-11 21:31:37 +01:00
|
|
|
|
|
|
|
public Destroy(Destroy other) {
|
|
|
|
this(other.jid, other.reason);
|
|
|
|
}
|
|
|
|
|
2015-05-27 19:29:51 +02:00
|
|
|
public Destroy(EntityBareJid alternativeJid, String reason) {
|
2015-03-11 21:31:37 +01:00
|
|
|
this.jid = alternativeJid;
|
|
|
|
this.reason = reason;
|
|
|
|
}
|
2014-07-14 19:22:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the JID of an alternate location since the current room is being destroyed.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-07-14 19:22:02 +02:00
|
|
|
* @return the JID of an alternate location.
|
|
|
|
*/
|
2015-05-27 19:29:51 +02:00
|
|
|
public EntityBareJid getJid() {
|
2014-07-14 19:22:02 +02:00
|
|
|
return jid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the reason for the room destruction.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-07-14 19:22:02 +02:00
|
|
|
* @return the reason for the room destruction.
|
|
|
|
*/
|
|
|
|
public String getReason() {
|
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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("jid", getJid());
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-11 21:31:37 +01:00
|
|
|
@Override
|
|
|
|
public Destroy clone() {
|
|
|
|
return new Destroy(this);
|
|
|
|
}
|
2014-07-14 19:22:02 +02:00
|
|
|
}
|