mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-13 22:41:08 +01:00
New API design (SMACK-545)
This commit is contained in:
parent
201152ef42
commit
8d3814a8a7
152 changed files with 394 additions and 493 deletions
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smackx.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.packet.MUCOwner;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
||||
|
||||
/**
|
||||
* Represents an affiliation of a user to a given room. The affiliate's information will always have
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muc;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smackx.packet.MUCInitialPresence;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||
|
||||
/**
|
||||
* The DiscussionHistory class controls the number of characters or messages to receive
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smackx.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
||||
/**
|
||||
* Hosted rooms by a chat service may be discovered if they are configured to appear in the room
|
||||
|
|
|
|||
|
|
@ -55,15 +55,15 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Registration;
|
||||
import org.jivesoftware.smackx.Form;
|
||||
import org.jivesoftware.smackx.NodeInformationProvider;
|
||||
import org.jivesoftware.smackx.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.packet.MUCInitialPresence;
|
||||
import org.jivesoftware.smackx.packet.MUCOwner;
|
||||
import org.jivesoftware.smackx.packet.MUCUser;
|
||||
import org.jivesoftware.smackx.disco.NodeInformationProvider;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jivesoftware.smackx.xdata.Form;
|
||||
|
||||
/**
|
||||
* A MultiUserChat is a conversation that takes place among many users in a virtual
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smackx.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.packet.MUCUser;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smackx.Form;
|
||||
import org.jivesoftware.smackx.FormField;
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.xdata.Form;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* A group chat invitation packet extension, which is used to invite other
|
||||
* users to a group chat room. To invite a user to a group chat room, address
|
||||
* a new message to the user and set the room name appropriately, as in the
|
||||
* following code example:
|
||||
*
|
||||
* <pre>
|
||||
* Message message = new Message("user@chat.example.com");
|
||||
* message.setBody("Join me for a group chat!");
|
||||
* message.addExtension(new GroupChatInvitation("room@chat.example.com"););
|
||||
* con.sendPacket(message);
|
||||
* </pre>
|
||||
*
|
||||
* To listen for group chat invitations, use a PacketExtensionFilter for the
|
||||
* <tt>x</tt> element name and <tt>jabber:x:conference</tt> namespace, as in the
|
||||
* following code example:
|
||||
*
|
||||
* <pre>
|
||||
* PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference");
|
||||
* // Create a packet collector or packet listeners using the filter...
|
||||
* </pre>
|
||||
*
|
||||
* <b>Note</b>: this protocol is outdated now that the Multi-User Chat (MUC) JEP is available
|
||||
* (<a href="http://www.jabber.org/jeps/jep-0045.html">JEP-45</a>). However, most
|
||||
* existing clients still use this older protocol. Once MUC support becomes more
|
||||
* widespread, this API may be deprecated.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class GroupChatInvitation implements PacketExtension {
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "x";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "jabber:x:conference";
|
||||
|
||||
private String roomAddress;
|
||||
|
||||
/**
|
||||
* Creates a new group chat invitation to the specified room address.
|
||||
* GroupChat room addresses are in the form <tt>room@service</tt>,
|
||||
* where <tt>service</tt> is the name of groupchat server, such as
|
||||
* <tt>chat.example.com</tt>.
|
||||
*
|
||||
* @param roomAddress the address of the group chat room.
|
||||
*/
|
||||
public GroupChatInvitation(String roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the group chat room. GroupChat room addresses
|
||||
* are in the form <tt>room@service</tt>, where <tt>service</tt> is
|
||||
* the name of groupchat server, such as <tt>chat.example.com</tt>.
|
||||
*
|
||||
* @return the address of the group chat room.
|
||||
*/
|
||||
public String getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public String getElementName() {
|
||||
return ELEMENT_NAME;
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<x xmlns=\"jabber:x:conference\" jid=\"").append(roomAddress).append("\"/>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension (XmlPullParser parser) throws Exception {
|
||||
String roomAddress = parser.getAttributeValue("", "jid");
|
||||
// Advance to end of extension.
|
||||
parser.next();
|
||||
return new GroupChatInvitation(roomAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
/**
|
||||
* IQ packet that serves for kicking users, granting and revoking voice, banning users,
|
||||
* modifying the ban list, granting and revoking membership and granting and revoking
|
||||
* moderator privileges. All these operations are scoped by the
|
||||
* 'http://jabber.org/protocol/muc#admin' namespace.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCAdmin extends IQ {
|
||||
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
|
||||
/**
|
||||
* Returns an Iterator for item childs that holds information about roles, affiliation,
|
||||
* jids and nicks.
|
||||
*
|
||||
* @return an Iterator for item childs that holds information about roles, affiliation,
|
||||
* jids and nicks.
|
||||
*/
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item child that holds information about roles, affiliation, jids and nicks.
|
||||
*
|
||||
* @param item the item child that holds information about roles, affiliation, jids and nicks.
|
||||
*/
|
||||
public void addItem(Item item) {
|
||||
synchronized (items) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<query xmlns=\"http://jabber.org/protocol/muc#admin\">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = items.get(i);
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
// Add packet extensions, if any are defined.
|
||||
buf.append(getExtensionsXML());
|
||||
buf.append("</query>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Item child that holds information about roles, affiliation, jids and nicks.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Item {
|
||||
private String actor;
|
||||
private String reason;
|
||||
private String affiliation;
|
||||
private String jid;
|
||||
private String nick;
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* Creates a new item child.
|
||||
*
|
||||
* @param affiliation the actor's affiliation to the room
|
||||
* @param role the privilege level of an occupant within a room.
|
||||
*/
|
||||
public Item(String affiliation, String role) {
|
||||
this.affiliation = affiliation;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*
|
||||
* @return the JID of an occupant in the room that was kicked or banned.
|
||||
*/
|
||||
public String getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason for the item child. The reason is optional and could be used to
|
||||
* explain the reason why a user (occupant) was kicked or banned.
|
||||
*
|
||||
* @return the reason for the item child.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the occupant's affiliation to the room. The affiliation is a semi-permanent
|
||||
* association or connection with a room. The possible affiliations are "owner", "admin",
|
||||
* "member", and "outcast" (naturally it is also possible to have no affiliation). An
|
||||
* affiliation lasts across a user's visits to a room.
|
||||
*
|
||||
* @return the actor's affiliation to the room
|
||||
*/
|
||||
public String getAffiliation() {
|
||||
return affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <room@service/nick> by which an occupant is identified within the context
|
||||
* of a room. If the room is non-anonymous, the JID will be included in the item.
|
||||
*
|
||||
* @return the room JID by which an occupant is identified within the room.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new nickname of an occupant that is changing his/her nickname. The new
|
||||
* nickname is sent as part of the unavailable presence.
|
||||
*
|
||||
* @return the new nickname of an occupant that is changing his/her nickname.
|
||||
*/
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the temporary position or privilege level of an occupant within a room. The
|
||||
* possible roles are "moderator", "participant", and "visitor" (it is also possible to
|
||||
* have no defined role). A role lasts only for the duration of an occupant's visit to
|
||||
* a room.
|
||||
*
|
||||
* @return the privilege level of an occupant within a room.
|
||||
*/
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*
|
||||
* @param actor the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*/
|
||||
public void setActor(String actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reason for the item child. The reason is optional and could be used to
|
||||
* explain the reason why a user (occupant) was kicked or banned.
|
||||
*
|
||||
* @param reason the reason why a user (occupant) was kicked or banned.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <room@service/nick> by which an occupant is identified within the context
|
||||
* of a room. If the room is non-anonymous, the JID will be included in the item.
|
||||
*
|
||||
* @param jid the JID by which an occupant is identified within a room.
|
||||
*/
|
||||
public void setJid(String jid) {
|
||||
this.jid = jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new nickname of an occupant that is changing his/her nickname. The new
|
||||
* nickname is sent as part of the unavailable presence.
|
||||
*
|
||||
* @param nick the new nickname of an occupant that is changing his/her nickname.
|
||||
*/
|
||||
public void setNick(String nick) {
|
||||
this.nick = nick;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item");
|
||||
if (getAffiliation() != null) {
|
||||
buf.append(" affiliation=\"").append(getAffiliation()).append("\"");
|
||||
}
|
||||
if (getJid() != null) {
|
||||
buf.append(" jid=\"").append(getJid()).append("\"");
|
||||
}
|
||||
if (getNick() != null) {
|
||||
buf.append(" nick=\"").append(getNick()).append("\"");
|
||||
}
|
||||
if (getRole() != null) {
|
||||
buf.append(" role=\"").append(getRole()).append("\"");
|
||||
}
|
||||
if (getReason() == null && getActor() == null) {
|
||||
buf.append("/>");
|
||||
}
|
||||
else {
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
if (getActor() != null) {
|
||||
buf.append("<actor jid=\"").append(getActor()).append("\"/>");
|
||||
}
|
||||
buf.append("</item>");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* Represents extended presence information whose sole purpose is to signal the ability of
|
||||
* the occupant to speak the MUC protocol when joining a room. If the room requires a password
|
||||
* then the MUCInitialPresence should include one.<p>
|
||||
*
|
||||
* The amount of discussion history provided on entering a room (perhaps because the
|
||||
* user is on a low-bandwidth connection or is using a small-footprint client) could be managed by
|
||||
* setting a configured History instance to the MUCInitialPresence instance.
|
||||
* @see MUCInitialPresence#setHistory(MUCInitialPresence.History).
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCInitialPresence implements PacketExtension {
|
||||
|
||||
private String password;
|
||||
private History history;
|
||||
|
||||
public String getElementName() {
|
||||
return "x";
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return "http://jabber.org/protocol/muc";
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\">");
|
||||
if (getPassword() != null) {
|
||||
buf.append("<password>").append(getPassword()).append("</password>");
|
||||
}
|
||||
if (getHistory() != null) {
|
||||
buf.append(getHistory().toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the history that manages the amount of discussion history provided on
|
||||
* entering a room.
|
||||
*
|
||||
* @return the history that manages the amount of discussion history provided on
|
||||
* entering a room.
|
||||
*/
|
||||
public History getHistory() {
|
||||
return history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password to use when the room requires a password.
|
||||
*
|
||||
* @return the password to use when the room requires a password.
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the History that manages the amount of discussion history provided on
|
||||
* entering a room.
|
||||
*
|
||||
* @param history that manages the amount of discussion history provided on
|
||||
* entering a room.
|
||||
*/
|
||||
public void setHistory(History history) {
|
||||
this.history = history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password to use when the room requires a password.
|
||||
*
|
||||
* @param password the password to use when the room requires a password.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* The History class controls the number of characters or messages to receive
|
||||
* when entering a room.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class History {
|
||||
|
||||
private int maxChars = -1;
|
||||
private int maxStanzas = -1;
|
||||
private int seconds = -1;
|
||||
private Date since;
|
||||
|
||||
/**
|
||||
* Returns the total number of characters to receive in the history.
|
||||
*
|
||||
* @return total number of characters to receive in the history.
|
||||
*/
|
||||
public int getMaxChars() {
|
||||
return maxChars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of messages to receive in the history.
|
||||
*
|
||||
* @return the total number of messages to receive in the history.
|
||||
*/
|
||||
public int getMaxStanzas() {
|
||||
return maxStanzas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of seconds to use to filter the messages received during that time.
|
||||
* In other words, only the messages received in the last "X" seconds will be included in
|
||||
* the history.
|
||||
*
|
||||
* @return the number of seconds to use to filter the messages received during that time.
|
||||
*/
|
||||
public int getSeconds() {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the since date to use to filter the messages received during that time.
|
||||
* In other words, only the messages received since the datetime specified will be
|
||||
* included in the history.
|
||||
*
|
||||
* @return the since date to use to filter the messages received during that time.
|
||||
*/
|
||||
public Date getSince() {
|
||||
return since;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total number of characters to receive in the history.
|
||||
*
|
||||
* @param maxChars the total number of characters to receive in the history.
|
||||
*/
|
||||
public void setMaxChars(int maxChars) {
|
||||
this.maxChars = maxChars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total number of messages to receive in the history.
|
||||
*
|
||||
* @param maxStanzas the total number of messages to receive in the history.
|
||||
*/
|
||||
public void setMaxStanzas(int maxStanzas) {
|
||||
this.maxStanzas = maxStanzas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of seconds to use to filter the messages received during that time.
|
||||
* In other words, only the messages received in the last "X" seconds will be included in
|
||||
* the history.
|
||||
*
|
||||
* @param seconds the number of seconds to use to filter the messages received during
|
||||
* that time.
|
||||
*/
|
||||
public void setSeconds(int seconds) {
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the since date to use to filter the messages received during that time.
|
||||
* In other words, only the messages received since the datetime specified will be
|
||||
* included in the history.
|
||||
*
|
||||
* @param since the since date to use to filter the messages received during that time.
|
||||
*/
|
||||
public void setSince(Date since) {
|
||||
this.since = since;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<history");
|
||||
if (getMaxChars() != -1) {
|
||||
buf.append(" maxchars=\"").append(getMaxChars()).append("\"");
|
||||
}
|
||||
if (getMaxStanzas() != -1) {
|
||||
buf.append(" maxstanzas=\"").append(getMaxStanzas()).append("\"");
|
||||
}
|
||||
if (getSeconds() != -1) {
|
||||
buf.append(" seconds=\"").append(getSeconds()).append("\"");
|
||||
}
|
||||
if (getSince() != null) {
|
||||
SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
buf.append(" since=\"").append(utcFormat.format(getSince())).append("\"");
|
||||
}
|
||||
buf.append("/>");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,339 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IQ packet that serves for granting and revoking ownership privileges, granting
|
||||
* and revoking administrative privileges and destroying a room. All these operations
|
||||
* are scoped by the 'http://jabber.org/protocol/muc#owner' namespace.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCOwner extends IQ {
|
||||
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private Destroy destroy;
|
||||
|
||||
/**
|
||||
* Returns an Iterator for item childs that holds information about affiliation,
|
||||
* jids and nicks.
|
||||
*
|
||||
* @return an Iterator for item childs that holds information about affiliation,
|
||||
* jids and nicks.
|
||||
*/
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return a request to the server to destroy a room.
|
||||
*/
|
||||
public Destroy getDestroy() {
|
||||
return destroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param destroy the request to the server to destroy a room.
|
||||
*/
|
||||
public void setDestroy(Destroy destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item child that holds information about affiliation, jids and nicks.
|
||||
*
|
||||
* @param item the item child that holds information about affiliation, jids and nicks.
|
||||
*/
|
||||
public void addItem(Item item) {
|
||||
synchronized (items) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<query xmlns=\"http://jabber.org/protocol/muc#owner\">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = (Item) items.get(i);
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
if (getDestroy() != null) {
|
||||
buf.append(getDestroy().toXML());
|
||||
}
|
||||
// Add packet extensions, if any are defined.
|
||||
buf.append(getExtensionsXML());
|
||||
buf.append("</query>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Item child that holds information about affiliation, jids and nicks.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Item {
|
||||
|
||||
private String actor;
|
||||
private String reason;
|
||||
private String affiliation;
|
||||
private String jid;
|
||||
private String nick;
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* Creates a new item child.
|
||||
*
|
||||
* @param affiliation the actor's affiliation to the room
|
||||
*/
|
||||
public Item(String affiliation) {
|
||||
this.affiliation = affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*
|
||||
* @return the JID of an occupant in the room that was kicked or banned.
|
||||
*/
|
||||
public String getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason for the item child. The reason is optional and could be used to
|
||||
* explain the reason why a user (occupant) was kicked or banned.
|
||||
*
|
||||
* @return the reason for the item child.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the occupant's affiliation to the room. The affiliation is a semi-permanent
|
||||
* association or connection with a room. The possible affiliations are "owner", "admin",
|
||||
* "member", and "outcast" (naturally it is also possible to have no affiliation). An
|
||||
* affiliation lasts across a user's visits to a room.
|
||||
*
|
||||
* @return the actor's affiliation to the room
|
||||
*/
|
||||
public String getAffiliation() {
|
||||
return affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <room@service/nick> by which an occupant is identified within the context
|
||||
* of a room. If the room is non-anonymous, the JID will be included in the item.
|
||||
*
|
||||
* @return the room JID by which an occupant is identified within the room.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new nickname of an occupant that is changing his/her nickname. The new
|
||||
* nickname is sent as part of the unavailable presence.
|
||||
*
|
||||
* @return the new nickname of an occupant that is changing his/her nickname.
|
||||
*/
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the temporary position or privilege level of an occupant within a room. The
|
||||
* possible roles are "moderator", "participant", and "visitor" (it is also possible to
|
||||
* have no defined role). A role lasts only for the duration of an occupant's visit to
|
||||
* a room.
|
||||
*
|
||||
* @return the privilege level of an occupant within a room.
|
||||
*/
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*
|
||||
* @param actor the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*/
|
||||
public void setActor(String actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reason for the item child. The reason is optional and could be used to
|
||||
* explain the reason why a user (occupant) was kicked or banned.
|
||||
*
|
||||
* @param reason the reason why a user (occupant) was kicked or banned.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <room@service/nick> by which an occupant is identified within the context
|
||||
* of a room. If the room is non-anonymous, the JID will be included in the item.
|
||||
*
|
||||
* @param jid the JID by which an occupant is identified within a room.
|
||||
*/
|
||||
public void setJid(String jid) {
|
||||
this.jid = jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new nickname of an occupant that is changing his/her nickname. The new
|
||||
* nickname is sent as part of the unavailable presence.
|
||||
*
|
||||
* @param nick the new nickname of an occupant that is changing his/her nickname.
|
||||
*/
|
||||
public void setNick(String nick) {
|
||||
this.nick = nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temporary position or privilege level of an occupant within a room. The
|
||||
* possible roles are "moderator", "participant", and "visitor" (it is also possible to
|
||||
* have no defined role). A role lasts only for the duration of an occupant's visit to
|
||||
* a room.
|
||||
*
|
||||
* @param role the new privilege level of an occupant within a room.
|
||||
*/
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item");
|
||||
if (getAffiliation() != null) {
|
||||
buf.append(" affiliation=\"").append(getAffiliation()).append("\"");
|
||||
}
|
||||
if (getJid() != null) {
|
||||
buf.append(" jid=\"").append(getJid()).append("\"");
|
||||
}
|
||||
if (getNick() != null) {
|
||||
buf.append(" nick=\"").append(getNick()).append("\"");
|
||||
}
|
||||
if (getRole() != null) {
|
||||
buf.append(" role=\"").append(getRole()).append("\"");
|
||||
}
|
||||
if (getReason() == null && getActor() == null) {
|
||||
buf.append("/>");
|
||||
}
|
||||
else {
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
if (getActor() != null) {
|
||||
buf.append("<actor jid=\"").append(getActor()).append("\"/>");
|
||||
}
|
||||
buf.append("</item>");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Destroy {
|
||||
private String reason;
|
||||
private String jid;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the JID of an alternate location since the current room is being destroyed.
|
||||
*
|
||||
* @return the JID of an alternate location.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason for the room destruction.
|
||||
*
|
||||
* @return the reason for the room destruction.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JID of an alternate location since the current room is being destroyed.
|
||||
*
|
||||
* @param jid the JID of an alternate location.
|
||||
*/
|
||||
public void setJid(String jid) {
|
||||
this.jid = jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reason for the room destruction.
|
||||
*
|
||||
* @param reason the reason for the room destruction.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<destroy");
|
||||
if (getJid() != null) {
|
||||
buf.append(" jid=\"").append(getJid()).append("\"");
|
||||
}
|
||||
if (getReason() == null) {
|
||||
buf.append("/>");
|
||||
}
|
||||
else {
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
buf.append("</destroy>");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,624 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
|
||||
/**
|
||||
* Represents extended presence information about roles, affiliations, full JIDs,
|
||||
* or status codes scoped by the 'http://jabber.org/protocol/muc#user' namespace.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCUser implements PacketExtension {
|
||||
|
||||
private Invite invite;
|
||||
private Decline decline;
|
||||
private Item item;
|
||||
private String password;
|
||||
private Status status;
|
||||
private Destroy destroy;
|
||||
|
||||
public String getElementName() {
|
||||
return "x";
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return "http://jabber.org/protocol/muc#user";
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\">");
|
||||
if (getInvite() != null) {
|
||||
buf.append(getInvite().toXML());
|
||||
}
|
||||
if (getDecline() != null) {
|
||||
buf.append(getDecline().toXML());
|
||||
}
|
||||
if (getItem() != null) {
|
||||
buf.append(getItem().toXML());
|
||||
}
|
||||
if (getPassword() != null) {
|
||||
buf.append("<password>").append(getPassword()).append("</password>");
|
||||
}
|
||||
if (getStatus() != null) {
|
||||
buf.append(getStatus().toXML());
|
||||
}
|
||||
if (getDestroy() != null) {
|
||||
buf.append(getDestroy().toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return an invitation for another user to a room.
|
||||
*/
|
||||
public Invite getInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rejection to an invitation from another user to a room. The rejection will be
|
||||
* sent to the room which in turn will forward the refusal to the inviter.
|
||||
*
|
||||
* @return a rejection to an invitation from another user to a room.
|
||||
*/
|
||||
public Decline getDecline() {
|
||||
return decline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item child that holds information about roles, affiliation, jids and nicks.
|
||||
*
|
||||
* @return an item child that holds information about roles, affiliation, jids and nicks.
|
||||
*/
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password to use to enter Password-Protected Room. A Password-Protected Room is
|
||||
* a room that a user cannot enter without first providing the correct password.
|
||||
*
|
||||
* @return the password to use to enter Password-Protected Room.
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status which holds a code that assists in presenting notification messages.
|
||||
*
|
||||
* @return the status which holds a code that assists in presenting notification messages.
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the notification that the room has been destroyed. After a room has been destroyed,
|
||||
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for
|
||||
* the room destruction if provided by the room owner.
|
||||
*
|
||||
* @return a notification that the room has been destroyed.
|
||||
*/
|
||||
public Destroy getDestroy() {
|
||||
return destroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param invite the invitation for another user to a room.
|
||||
*/
|
||||
public void setInvite(Invite invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rejection to an invitation from another user to a room. The rejection will be
|
||||
* sent to the room which in turn will forward the refusal to the inviter.
|
||||
*
|
||||
* @param decline the rejection to an invitation from another user to a room.
|
||||
*/
|
||||
public void setDecline(Decline decline) {
|
||||
this.decline = decline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item child that holds information about roles, affiliation, jids and nicks.
|
||||
*
|
||||
* @param item the item child that holds information about roles, affiliation, jids and nicks.
|
||||
*/
|
||||
public void setItem(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password to use to enter Password-Protected Room. A Password-Protected Room is
|
||||
* a room that a user cannot enter without first providing the correct password.
|
||||
*
|
||||
* @param string the password to use to enter Password-Protected Room.
|
||||
*/
|
||||
public void setPassword(String string) {
|
||||
password = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status which holds a code that assists in presenting notification messages.
|
||||
*
|
||||
* @param status the status which holds a code that assists in presenting notification
|
||||
* messages.
|
||||
*/
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the notification that the room has been destroyed. After a room has been destroyed,
|
||||
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for
|
||||
* the room destruction if provided by the room owner.
|
||||
*
|
||||
* @param destroy the notification that the room has been destroyed.
|
||||
*/
|
||||
public void setDestroy(Destroy destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* will forward the invitation to the invitee.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Invite {
|
||||
private String reason;
|
||||
private String from;
|
||||
private String to;
|
||||
|
||||
/**
|
||||
* Returns the bare JID of the inviter or, optionally, the room JID. (e.g.
|
||||
* 'crone1@shakespeare.lit/desktop').
|
||||
*
|
||||
* @return the room's occupant that sent the invitation.
|
||||
*/
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message explaining the invitation.
|
||||
*
|
||||
* @return the message explaining the invitation.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit')
|
||||
*
|
||||
* @return the bare JID of the invitee.
|
||||
*/
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bare JID of the inviter or, optionally, the room JID. (e.g.
|
||||
* 'crone1@shakespeare.lit/desktop')
|
||||
*
|
||||
* @param from the bare JID of the inviter or, optionally, the room JID.
|
||||
*/
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message explaining the invitation.
|
||||
*
|
||||
* @param reason the message explaining the invitation.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit')
|
||||
*
|
||||
* @param to the bare JID of the invitee.
|
||||
*/
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<invite ");
|
||||
if (getTo() != null) {
|
||||
buf.append(" to=\"").append(getTo()).append("\"");
|
||||
}
|
||||
if (getFrom() != null) {
|
||||
buf.append(" from=\"").append(getFrom()).append("\"");
|
||||
}
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
buf.append("</invite>");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a rejection to an invitation from another user to a room. The rejection will be
|
||||
* sent to the room which in turn will forward the refusal to the inviter.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Decline {
|
||||
private String reason;
|
||||
private String from;
|
||||
private String to;
|
||||
|
||||
/**
|
||||
* Returns the bare JID of the invitee that rejected the invitation. (e.g.
|
||||
* 'crone1@shakespeare.lit/desktop').
|
||||
*
|
||||
* @return the bare JID of the invitee that rejected the invitation.
|
||||
*/
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message explaining why the invitation was rejected.
|
||||
*
|
||||
* @return the message explaining the reason for the rejection.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit')
|
||||
*
|
||||
* @return the bare JID of the inviter.
|
||||
*/
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bare JID of the invitee that rejected the invitation. (e.g.
|
||||
* 'crone1@shakespeare.lit/desktop').
|
||||
*
|
||||
* @param from the bare JID of the invitee that rejected the invitation.
|
||||
*/
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message explaining why the invitation was rejected.
|
||||
*
|
||||
* @param reason the message explaining the reason for the rejection.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit')
|
||||
*
|
||||
* @param to the bare JID of the inviter.
|
||||
*/
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<decline ");
|
||||
if (getTo() != null) {
|
||||
buf.append(" to=\"").append(getTo()).append("\"");
|
||||
}
|
||||
if (getFrom() != null) {
|
||||
buf.append(" from=\"").append(getFrom()).append("\"");
|
||||
}
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
buf.append("</decline>");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Item child that holds information about roles, affiliation, jids and nicks.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Item {
|
||||
private String actor;
|
||||
private String reason;
|
||||
private String affiliation;
|
||||
private String jid;
|
||||
private String nick;
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* Creates a new item child.
|
||||
*
|
||||
* @param affiliation the actor's affiliation to the room
|
||||
* @param role the privilege level of an occupant within a room.
|
||||
*/
|
||||
public Item(String affiliation, String role) {
|
||||
this.affiliation = affiliation;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*
|
||||
* @return the JID of an occupant in the room that was kicked or banned.
|
||||
*/
|
||||
public String getActor() {
|
||||
return actor == null ? "" : actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason for the item child. The reason is optional and could be used to
|
||||
* explain the reason why a user (occupant) was kicked or banned.
|
||||
*
|
||||
* @return the reason for the item child.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason == null ? "" : reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the occupant's affiliation to the room. The affiliation is a semi-permanent
|
||||
* association or connection with a room. The possible affiliations are "owner", "admin",
|
||||
* "member", and "outcast" (naturally it is also possible to have no affiliation). An
|
||||
* affiliation lasts across a user's visits to a room.
|
||||
*
|
||||
* @return the actor's affiliation to the room
|
||||
*/
|
||||
public String getAffiliation() {
|
||||
return affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <room@service/nick> by which an occupant is identified within the context
|
||||
* of a room. If the room is non-anonymous, the JID will be included in the item.
|
||||
*
|
||||
* @return the room JID by which an occupant is identified within the room.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new nickname of an occupant that is changing his/her nickname. The new
|
||||
* nickname is sent as part of the unavailable presence.
|
||||
*
|
||||
* @return the new nickname of an occupant that is changing his/her nickname.
|
||||
*/
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the temporary position or privilege level of an occupant within a room. The
|
||||
* possible roles are "moderator", "participant", and "visitor" (it is also possible to
|
||||
* have no defined role). A role lasts only for the duration of an occupant's visit to
|
||||
* a room.
|
||||
*
|
||||
* @return the privilege level of an occupant within a room.
|
||||
*/
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*
|
||||
* @param actor the actor (JID of an occupant in the room) that was kicked or banned.
|
||||
*/
|
||||
public void setActor(String actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reason for the item child. The reason is optional and could be used to
|
||||
* explain the reason why a user (occupant) was kicked or banned.
|
||||
*
|
||||
* @param reason the reason why a user (occupant) was kicked or banned.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <room@service/nick> by which an occupant is identified within the context
|
||||
* of a room. If the room is non-anonymous, the JID will be included in the item.
|
||||
*
|
||||
* @param jid the JID by which an occupant is identified within a room.
|
||||
*/
|
||||
public void setJid(String jid) {
|
||||
this.jid = jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new nickname of an occupant that is changing his/her nickname. The new
|
||||
* nickname is sent as part of the unavailable presence.
|
||||
*
|
||||
* @param nick the new nickname of an occupant that is changing his/her nickname.
|
||||
*/
|
||||
public void setNick(String nick) {
|
||||
this.nick = nick;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item");
|
||||
if (getAffiliation() != null) {
|
||||
buf.append(" affiliation=\"").append(getAffiliation()).append("\"");
|
||||
}
|
||||
if (getJid() != null) {
|
||||
buf.append(" jid=\"").append(getJid()).append("\"");
|
||||
}
|
||||
if (getNick() != null) {
|
||||
buf.append(" nick=\"").append(getNick()).append("\"");
|
||||
}
|
||||
if (getRole() != null) {
|
||||
buf.append(" role=\"").append(getRole()).append("\"");
|
||||
}
|
||||
if (getReason() == null && getActor() == null) {
|
||||
buf.append("/>");
|
||||
}
|
||||
else {
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
if (getActor() != null) {
|
||||
buf.append("<actor jid=\"").append(getActor()).append("\"/>");
|
||||
}
|
||||
buf.append("</item>");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Status code assists in presenting notification messages. The following link provides the
|
||||
* list of existing error codes (@link http://www.jabber.org/jeps/jep-0045.html#errorstatus).
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Status {
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Creates a new instance of Status with the specified code.
|
||||
*
|
||||
* @param code the code that uniquely identifies the reason of the error.
|
||||
*/
|
||||
public Status(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code that uniquely identifies the reason of the error. The code
|
||||
* assists in presenting notification messages.
|
||||
*
|
||||
* @return the code that uniquely identifies the reason of the error.
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<status code=\"").append(getCode()).append("\"/>");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a notification that the room has been destroyed. After a room has been destroyed,
|
||||
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for
|
||||
* the room destruction if provided by the room owner.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Destroy {
|
||||
private String reason;
|
||||
private String jid;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the JID of an alternate location since the current room is being destroyed.
|
||||
*
|
||||
* @return the JID of an alternate location.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason for the room destruction.
|
||||
*
|
||||
* @return the reason for the room destruction.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JID of an alternate location since the current room is being destroyed.
|
||||
*
|
||||
* @param jid the JID of an alternate location.
|
||||
*/
|
||||
public void setJid(String jid) {
|
||||
this.jid = jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reason for the room destruction.
|
||||
*
|
||||
* @param reason the reason for the room destruction.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<destroy");
|
||||
if (getJid() != null) {
|
||||
buf.append(" jid=\"").append(getJid()).append("\"");
|
||||
}
|
||||
if (getReason() == null) {
|
||||
buf.append("/>");
|
||||
}
|
||||
else {
|
||||
buf.append(">");
|
||||
if (getReason() != null) {
|
||||
buf.append("<reason>").append(getReason()).append("</reason>");
|
||||
}
|
||||
buf.append("</destroy>");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* The MUCAdminProvider parses MUCAdmin packets. (@see MUCAdmin)
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCAdminProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
MUCAdmin mucAdmin = new MUCAdmin();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
mucAdmin.addItem(parseItem(parser));
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("query")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mucAdmin;
|
||||
}
|
||||
|
||||
private MUCAdmin.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCAdmin.Item item =
|
||||
new MUCAdmin.Item(
|
||||
parser.getAttributeValue("", "affiliation"),
|
||||
parser.getAttributeValue("", "role"));
|
||||
item.setNick(parser.getAttributeValue("", "nick"));
|
||||
item.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("actor")) {
|
||||
item.setActor(parser.getAttributeValue("", "jid"));
|
||||
}
|
||||
if (parser.getName().equals("reason")) {
|
||||
item.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.provider.*;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner)
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCOwnerProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
MUCOwner mucOwner = new MUCOwner();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
mucOwner.addItem(parseItem(parser));
|
||||
}
|
||||
else if (parser.getName().equals("destroy")) {
|
||||
mucOwner.setDestroy(parseDestroy(parser));
|
||||
}
|
||||
// Otherwise, it must be a packet extension.
|
||||
else {
|
||||
mucOwner.addExtension(PacketParserUtils.parsePacketExtension(parser.getName(),
|
||||
parser.getNamespace(), parser));
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("query")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mucOwner;
|
||||
}
|
||||
|
||||
private MUCOwner.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCOwner.Item item = new MUCOwner.Item(parser.getAttributeValue("", "affiliation"));
|
||||
item.setNick(parser.getAttributeValue("", "nick"));
|
||||
item.setRole(parser.getAttributeValue("", "role"));
|
||||
item.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("actor")) {
|
||||
item.setActor(parser.getAttributeValue("", "jid"));
|
||||
}
|
||||
if (parser.getName().equals("reason")) {
|
||||
item.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private MUCOwner.Destroy parseDestroy(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCOwner.Destroy destroy = new MUCOwner.Destroy();
|
||||
destroy.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("reason")) {
|
||||
destroy.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("destroy")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return destroy;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. 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.provider;
|
||||
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* The MUCUserProvider parses packets with extended presence information about
|
||||
* roles and affiliations.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCUserProvider implements PacketExtensionProvider {
|
||||
|
||||
/**
|
||||
* Creates a new MUCUserProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument
|
||||
* constructor
|
||||
*/
|
||||
public MUCUserProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a MUCUser packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
MUCUser mucUser = new MUCUser();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("invite")) {
|
||||
mucUser.setInvite(parseInvite(parser));
|
||||
}
|
||||
if (parser.getName().equals("item")) {
|
||||
mucUser.setItem(parseItem(parser));
|
||||
}
|
||||
if (parser.getName().equals("password")) {
|
||||
mucUser.setPassword(parser.nextText());
|
||||
}
|
||||
if (parser.getName().equals("status")) {
|
||||
mucUser.setStatus(new MUCUser.Status(parser.getAttributeValue("", "code")));
|
||||
}
|
||||
if (parser.getName().equals("decline")) {
|
||||
mucUser.setDecline(parseDecline(parser));
|
||||
}
|
||||
if (parser.getName().equals("destroy")) {
|
||||
mucUser.setDestroy(parseDestroy(parser));
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("x")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mucUser;
|
||||
}
|
||||
|
||||
private MUCUser.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCUser.Item item =
|
||||
new MUCUser.Item(
|
||||
parser.getAttributeValue("", "affiliation"),
|
||||
parser.getAttributeValue("", "role"));
|
||||
item.setNick(parser.getAttributeValue("", "nick"));
|
||||
item.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("actor")) {
|
||||
item.setActor(parser.getAttributeValue("", "jid"));
|
||||
}
|
||||
if (parser.getName().equals("reason")) {
|
||||
item.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private MUCUser.Invite parseInvite(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCUser.Invite invite = new MUCUser.Invite();
|
||||
invite.setFrom(parser.getAttributeValue("", "from"));
|
||||
invite.setTo(parser.getAttributeValue("", "to"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("reason")) {
|
||||
invite.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("invite")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return invite;
|
||||
}
|
||||
|
||||
private MUCUser.Decline parseDecline(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCUser.Decline decline = new MUCUser.Decline();
|
||||
decline.setFrom(parser.getAttributeValue("", "from"));
|
||||
decline.setTo(parser.getAttributeValue("", "to"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("reason")) {
|
||||
decline.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("decline")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return decline;
|
||||
}
|
||||
|
||||
private MUCUser.Destroy parseDestroy(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCUser.Destroy destroy = new MUCUser.Destroy();
|
||||
destroy.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("reason")) {
|
||||
destroy.setReason(parser.nextText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("destroy")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return destroy;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue