2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2004-11-03 00:37:00 +01:00
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2004-11-03 00:37:00 +01: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
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
package org.jivesoftware.smackx.muc.packet;
|
2006-07-18 07:14:33 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2017-06-14 17:12:43 +02:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* IQ stanza that serves for granting and revoking ownership privileges, granting
|
|
|
|
* and revoking administrative privileges and destroying a room. All these operations
|
2004-04-05 18:21:56 +02:00
|
|
|
* are scoped by the 'http://jabber.org/protocol/muc#owner' namespace.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2004-03-29 23:29:55 +02:00
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
|
|
|
public class MUCOwner extends IQ {
|
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
public static final String ELEMENT = QUERY_ELEMENT;
|
2014-07-14 19:22:02 +02:00
|
|
|
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#owner";
|
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
private final List<MUCItem> items = new ArrayList<>();
|
2004-03-29 23:29:55 +02:00
|
|
|
private Destroy destroy;
|
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
public MUCOwner() {
|
|
|
|
super(ELEMENT, NAMESPACE);
|
|
|
|
}
|
|
|
|
|
2004-04-05 18:21:56 +02:00
|
|
|
/**
|
2017-12-13 23:10:11 +01:00
|
|
|
* Returns a List of item children that holds information about affiliation,
|
2004-04-05 18:21:56 +02:00
|
|
|
* jids and nicks.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2017-12-13 23:10:11 +01:00
|
|
|
* @return a List of item children that holds information about affiliation,
|
2004-04-05 18:21:56 +02:00
|
|
|
* jids and nicks.
|
|
|
|
*/
|
2014-07-14 19:22:02 +02:00
|
|
|
public List<MUCItem> getItems() {
|
2004-03-29 23:29:55 +02:00
|
|
|
synchronized (items) {
|
2017-12-13 23:10:11 +01:00
|
|
|
return Collections.unmodifiableList(new ArrayList<>(items));
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-05 18:21:56 +02:00
|
|
|
/**
|
|
|
|
* Returns 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
|
|
|
*
|
2004-04-05 18:21:56 +02:00
|
|
|
* @return a request to the server to destroy a room.
|
|
|
|
*/
|
2004-03-29 23:29:55 +02:00
|
|
|
public Destroy getDestroy() {
|
|
|
|
return destroy;
|
|
|
|
}
|
|
|
|
|
2004-04-05 18:21:56 +02:00
|
|
|
/**
|
|
|
|
* Sets 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
|
|
|
*
|
2004-04-05 18:21:56 +02:00
|
|
|
* @param destroy the request to the server to destroy a room.
|
|
|
|
*/
|
2004-03-29 23:29:55 +02:00
|
|
|
public void setDestroy(Destroy destroy) {
|
|
|
|
this.destroy = destroy;
|
|
|
|
}
|
|
|
|
|
2004-04-05 18:21:56 +02:00
|
|
|
/**
|
|
|
|
* Adds an item child that holds information about affiliation, jids and nicks.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2004-04-05 18:21:56 +02:00
|
|
|
* @param item the item child that holds information about affiliation, jids and nicks.
|
|
|
|
*/
|
2014-07-14 19:22:02 +02:00
|
|
|
public void addItem(MUCItem item) {
|
2004-03-29 23:29:55 +02:00
|
|
|
synchronized (items) {
|
|
|
|
items.add(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
@Override
|
2014-11-07 21:12:01 +01:00
|
|
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
2014-08-20 21:25:14 +02:00
|
|
|
xml.rightAngleBracket();
|
2014-11-07 21:12:01 +01:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
synchronized (items) {
|
2014-07-14 19:22:02 +02:00
|
|
|
for (MUCItem item : items) {
|
2018-04-25 14:20:18 +02:00
|
|
|
xml.append(item.toXML(null));
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-14 19:22:02 +02:00
|
|
|
xml.optElement(getDestroy());
|
2014-11-07 21:12:01 +01:00
|
|
|
|
2014-07-14 19:22:02 +02:00
|
|
|
return xml;
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|