mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-08 22:21:08 +01:00
smack_1_5_1
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2639 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
aa32e12164
commit
7ae75258be
276 changed files with 40430 additions and 0 deletions
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
import org.jivesoftware.smackx.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.packet.MUCOwner;
|
||||
|
||||
/**
|
||||
* Represents an affiliation of a user to a given room. The affiliate's information will always have
|
||||
* the bare jid of the real user and its affiliation. If the affiliate is an occupant of the room
|
||||
* then we will also have information about the role and nickname of the user in the room.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class Affiliate {
|
||||
// Fields that must have a value
|
||||
private String jid;
|
||||
private String affiliation;
|
||||
|
||||
// Fields that may have a value
|
||||
private String role;
|
||||
private String nick;
|
||||
|
||||
Affiliate(MUCOwner.Item item) {
|
||||
super();
|
||||
this.jid = item.getJid();
|
||||
this.affiliation = item.getAffiliation();
|
||||
this.role = item.getRole();
|
||||
this.nick = item.getNick();
|
||||
}
|
||||
|
||||
Affiliate(MUCAdmin.Item item) {
|
||||
super();
|
||||
this.jid = item.getJid();
|
||||
this.affiliation = item.getAffiliation();
|
||||
this.role = item.getRole();
|
||||
this.nick = item.getNick();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bare JID of the affiliated user. This information will always be available.
|
||||
*
|
||||
* @return the bare JID of the affiliated user.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affiliation of the afffiliated user. Possible affiliations are: "owner", "admin",
|
||||
* "member", "outcast". This information will always be available.
|
||||
*
|
||||
* @return the affiliation of the afffiliated user.
|
||||
*/
|
||||
public String getAffiliation() {
|
||||
return affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current role of the affiliated user if the user is currently in the room.
|
||||
* If the user is not present in the room then the answer will be null.
|
||||
*
|
||||
* @return the current role of the affiliated user in the room or null if the user is not in
|
||||
* the room.
|
||||
*/
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current nickname of the affiliated user if the user is currently in the room.
|
||||
* If the user is not present in the room then the answer will be null.
|
||||
*
|
||||
* @return the current nickname of the affiliated user in the room or null if the user is not in
|
||||
* the room.
|
||||
*/
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
/**
|
||||
* Default implementation of the ParticipantStatusListener interface.<p>
|
||||
*
|
||||
* This class does not provide any behavior by default. It just avoids having
|
||||
* to implement all the inteface methods if the user is only interested in implementing
|
||||
* some of the methods.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DefaultParticipantStatusListener implements ParticipantStatusListener {
|
||||
|
||||
public void joined(String participant) {
|
||||
}
|
||||
|
||||
public void left(String participant) {
|
||||
}
|
||||
|
||||
public void kicked(String participant) {
|
||||
}
|
||||
|
||||
public void voiceGranted(String participant) {
|
||||
}
|
||||
|
||||
public void voiceRevoked(String participant) {
|
||||
}
|
||||
|
||||
public void banned(String participant) {
|
||||
}
|
||||
|
||||
public void membershipGranted(String participant) {
|
||||
}
|
||||
|
||||
public void membershipRevoked(String participant) {
|
||||
}
|
||||
|
||||
public void moderatorGranted(String participant) {
|
||||
}
|
||||
|
||||
public void moderatorRevoked(String participant) {
|
||||
}
|
||||
|
||||
public void ownershipGranted(String participant) {
|
||||
}
|
||||
|
||||
public void ownershipRevoked(String participant) {
|
||||
}
|
||||
|
||||
public void adminGranted(String participant) {
|
||||
}
|
||||
|
||||
public void adminRevoked(String participant) {
|
||||
}
|
||||
|
||||
public void nicknameChanged(String nickname) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
/**
|
||||
* Default implementation of the UserStatusListener interface.<p>
|
||||
*
|
||||
* This class does not provide any behavior by default. It just avoids having
|
||||
* to implement all the inteface methods if the user is only interested in implementing
|
||||
* some of the methods.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DefaultUserStatusListener implements UserStatusListener {
|
||||
|
||||
public void kicked(String actor, String reason) {
|
||||
}
|
||||
|
||||
public void voiceGranted() {
|
||||
}
|
||||
|
||||
public void voiceRevoked() {
|
||||
}
|
||||
|
||||
public void banned(String actor, String reason) {
|
||||
}
|
||||
|
||||
public void membershipGranted() {
|
||||
}
|
||||
|
||||
public void membershipRevoked() {
|
||||
}
|
||||
|
||||
public void moderatorGranted() {
|
||||
}
|
||||
|
||||
public void moderatorRevoked() {
|
||||
}
|
||||
|
||||
public void ownershipGranted() {
|
||||
}
|
||||
|
||||
public void ownershipRevoked() {
|
||||
}
|
||||
|
||||
public void adminGranted() {
|
||||
}
|
||||
|
||||
public void adminRevoked() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smackx.packet.MUCInitialPresence;
|
||||
|
||||
/**
|
||||
* The DiscussionHistory class controls the number of characters or messages to receive
|
||||
* when entering a room. The room will decide the amount of history to return if you don't
|
||||
* specify a DiscussionHistory while joining a room.<p>
|
||||
*
|
||||
* You can use some or all of these variable to control the amount of history to receive:
|
||||
* <ul>
|
||||
* <li>maxchars -> total number of characters to receive in the history.
|
||||
* <li>maxstanzas -> total number of messages to receive in the history.
|
||||
* <li>seconds -> only the messages received in the last "X" seconds will be included in the
|
||||
* history.
|
||||
* <li>since -> only the messages received since the datetime specified will be included in
|
||||
* the history.
|
||||
* </ul>
|
||||
*
|
||||
* Note: Setting maxchars to 0 indicates that the user requests to receive no history.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DiscussionHistory {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the history has been configured with some values.
|
||||
*
|
||||
* @return true if the history has been configured with some values.
|
||||
*/
|
||||
private boolean isConfigured() {
|
||||
return maxChars > -1 || maxStanzas > -1 || seconds > -1 || since != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
MUCInitialPresence.History getMUCHistory() {
|
||||
// Return null if the history was not properly configured
|
||||
if (!isConfigured()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MUCInitialPresence.History mucHistory = new MUCInitialPresence.History();
|
||||
if (maxChars > -1) {
|
||||
mucHistory.setMaxChars(maxChars);
|
||||
}
|
||||
if (maxStanzas > -1) {
|
||||
mucHistory.setMaxStanzas(maxStanzas);
|
||||
}
|
||||
if (seconds > -1) {
|
||||
mucHistory.setSeconds(seconds);
|
||||
}
|
||||
if (since != null) {
|
||||
mucHistory.setSince(since);
|
||||
}
|
||||
return mucHistory;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
import org.jivesoftware.smackx.packet.DiscoverItems;
|
||||
|
||||
/**
|
||||
* Hosted rooms by a chat service may be discovered if they are configured to appear in the room
|
||||
* directory . The information that may be discovered is the XMPP address of the room and the room
|
||||
* name. The address of the room may be used for obtaining more detailed information
|
||||
* {@link org.jivesoftware.smackx.muc.MultiUserChat#getRoomInfo(org.jivesoftware.smack.XMPPConnection, String)}
|
||||
* or could be used for joining the room
|
||||
* {@link org.jivesoftware.smackx.muc.MultiUserChat#MultiUserChat(org.jivesoftware.smack.XMPPConnection, String)}
|
||||
* and {@link org.jivesoftware.smackx.muc.MultiUserChat#join(String)}.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class HostedRoom {
|
||||
|
||||
private String jid;
|
||||
|
||||
private String name;
|
||||
|
||||
public HostedRoom(DiscoverItems.Item item) {
|
||||
super();
|
||||
jid = item.getEntityID();
|
||||
name = item.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XMPP address of the hosted room by the chat service. This address may be used
|
||||
* when creating a <code>MultiUserChat</code> when joining a room.
|
||||
*
|
||||
* @return the XMPP address of the hosted room by the chat service.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the room.
|
||||
*
|
||||
* @return the name of the room.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
/**
|
||||
* A listener that is fired anytime an invitation to join a MUC room is received.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface InvitationListener {
|
||||
|
||||
/**
|
||||
* Called when the an invitation to join a MUC room is received.<p>
|
||||
*
|
||||
* If the room is password-protected, the invitee will receive a password to use to join
|
||||
* the room. If the room is members-only, the the invitee may be added to the member list.
|
||||
*
|
||||
* @param conn the XMPPConnection that received the invitation.
|
||||
* @param room the room that invitation refers to.
|
||||
* @param inviter the inviter that sent the invitation. (e.g. crone1@shakespeare.lit).
|
||||
* @param reason the reason why the inviter sent the invitation.
|
||||
* @param password the password to use when joining the room.
|
||||
* @param message the message used by the inviter to send the invitation.
|
||||
*/
|
||||
public abstract void invitationReceived(XMPPConnection conn, String room, String inviter, String reason,
|
||||
String password, Message message);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
/**
|
||||
* A listener that is fired anytime an invitee declines or rejects an invitation.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface InvitationRejectionListener {
|
||||
|
||||
/**
|
||||
* Called when the invitee declines the invitation.
|
||||
*
|
||||
* @param invitee the invitee that declined the invitation. (e.g. hecate@shakespeare.lit).
|
||||
* @param reason the reason why the invitee declined the invitation.
|
||||
*/
|
||||
public abstract void invitationDeclined(String invitee, String reason);
|
||||
|
||||
}
|
||||
2572
CopyOftrunk/source/org/jivesoftware/smackx/muc/MultiUserChat.java
Normal file
2572
CopyOftrunk/source/org/jivesoftware/smackx/muc/MultiUserChat.java
Normal file
File diff suppressed because it is too large
Load diff
104
CopyOftrunk/source/org/jivesoftware/smackx/muc/Occupant.java
Normal file
104
CopyOftrunk/source/org/jivesoftware/smackx/muc/Occupant.java
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
import org.jivesoftware.smackx.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.packet.MUCUser;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents the information about an occupant in a given room. The information will always have
|
||||
* the affiliation and role of the occupant in the room. The full JID and nickname are optional.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class Occupant {
|
||||
// Fields that must have a value
|
||||
private String affiliation;
|
||||
private String role;
|
||||
// Fields that may have a value
|
||||
private String jid;
|
||||
private String nick;
|
||||
|
||||
Occupant(MUCAdmin.Item item) {
|
||||
super();
|
||||
this.jid = item.getJid();
|
||||
this.affiliation = item.getAffiliation();
|
||||
this.role = item.getRole();
|
||||
this.nick = item.getNick();
|
||||
}
|
||||
|
||||
Occupant(Presence presence) {
|
||||
super();
|
||||
MUCUser mucUser = (MUCUser) presence.getExtension("x",
|
||||
"http://jabber.org/protocol/muc#user");
|
||||
MUCUser.Item item = mucUser.getItem();
|
||||
this.jid = item.getJid();
|
||||
this.affiliation = item.getAffiliation();
|
||||
this.role = item.getRole();
|
||||
// Get the nickname from the FROM attribute of the presence
|
||||
this.nick = StringUtils.parseResource(presence.getFrom());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full JID of the occupant. If this information was extracted from a presence and
|
||||
* the room is semi or full-anonymous then the answer will be null. On the other hand, if this
|
||||
* information was obtained while maintaining the voice list or the moderator list then we will
|
||||
* always have a full JID.
|
||||
*
|
||||
* @return the full JID of the occupant.
|
||||
*/
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affiliation of the occupant. Possible affiliations are: "owner", "admin",
|
||||
* "member", "outcast". This information will always be available.
|
||||
*
|
||||
* @return the affiliation of the occupant.
|
||||
*/
|
||||
public String getAffiliation() {
|
||||
return affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current role of the occupant in the room. This information will always be
|
||||
* available.
|
||||
*
|
||||
* @return the current role of the occupant in the room.
|
||||
*/
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current nickname of the occupant in the room. If this information was extracted
|
||||
* from a presence then the answer will be null.
|
||||
*
|
||||
* @return the current nickname of the occupant in the room or null if this information was
|
||||
* obtained from a presence.
|
||||
*/
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
/**
|
||||
* A listener that is fired anytime a participant's status in a room is changed, such as the
|
||||
* user being kicked, banned, or granted admin permissions.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface ParticipantStatusListener {
|
||||
|
||||
/**
|
||||
* Called when a new room occupant has joined the room. Note: Take in consideration that when
|
||||
* you join a room you will receive the list of current occupants in the room. This message will
|
||||
* be sent for each occupant.
|
||||
*
|
||||
* @param participant the participant that has just joined the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void joined(String participant);
|
||||
|
||||
/**
|
||||
* Called when a room occupant has left the room on its own. This means that the occupant was
|
||||
* neither kicked nor banned from the room.
|
||||
*
|
||||
* @param participant the participant that has left the room on its own.
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void left(String participant);
|
||||
|
||||
/**
|
||||
* Called when a room participant has been kicked from the room. This means that the kicked
|
||||
* participant is no longer participating in the room.
|
||||
*
|
||||
* @param participant the participant that was kicked from the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void kicked(String participant);
|
||||
|
||||
/**
|
||||
* Called when a moderator grants voice to a visitor. This means that the visitor
|
||||
* can now participate in the moderated room sending messages to all occupants.
|
||||
*
|
||||
* @param participant the participant that was granted voice in the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void voiceGranted(String participant);
|
||||
|
||||
/**
|
||||
* Called when a moderator revokes voice from a participant. This means that the participant
|
||||
* in the room was able to speak and now is a visitor that can't send messages to the room
|
||||
* occupants.
|
||||
*
|
||||
* @param participant the participant that was revoked voice from the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void voiceRevoked(String participant);
|
||||
|
||||
/**
|
||||
* Called when an administrator or owner banned a participant from the room. This means that
|
||||
* banned participant will no longer be able to join the room unless the ban has been removed.
|
||||
*
|
||||
* @param participant the participant that was banned from the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void banned(String participant);
|
||||
|
||||
/**
|
||||
* Called when an administrator grants a user membership to the room. This means that the user
|
||||
* will be able to join the members-only room.
|
||||
*
|
||||
* @param participant the participant that was granted membership in the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void membershipGranted(String participant);
|
||||
|
||||
/**
|
||||
* Called when an administrator revokes a user membership to the room. This means that the
|
||||
* user will not be able to join the members-only room.
|
||||
*
|
||||
* @param participant the participant that was revoked membership from the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void membershipRevoked(String participant);
|
||||
|
||||
/**
|
||||
* Called when an administrator grants moderator privileges to a user. This means that the user
|
||||
* will be able to kick users, grant and revoke voice, invite other users, modify room's
|
||||
* subject plus all the partcipants privileges.
|
||||
*
|
||||
* @param participant the participant that was granted moderator privileges in the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void moderatorGranted(String participant);
|
||||
|
||||
/**
|
||||
* Called when an administrator revokes moderator privileges from a user. This means that the
|
||||
* user will no longer be able to kick users, grant and revoke voice, invite other users,
|
||||
* modify room's subject plus all the partcipants privileges.
|
||||
*
|
||||
* @param participant the participant that was revoked moderator privileges in the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void moderatorRevoked(String participant);
|
||||
|
||||
/**
|
||||
* Called when an owner grants a user ownership on the room. This means that the user
|
||||
* will be able to change defining room features as well as perform all administrative
|
||||
* functions.
|
||||
*
|
||||
* @param participant the participant that was granted ownership on the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void ownershipGranted(String participant);
|
||||
|
||||
/**
|
||||
* Called when an owner revokes a user ownership on the room. This means that the user
|
||||
* will no longer be able to change defining room features as well as perform all
|
||||
* administrative functions.
|
||||
*
|
||||
* @param participant the participant that was revoked ownership on the room
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void ownershipRevoked(String participant);
|
||||
|
||||
/**
|
||||
* Called when an owner grants administrator privileges to a user. This means that the user
|
||||
* will be able to perform administrative functions such as banning users and edit moderator
|
||||
* list.
|
||||
*
|
||||
* @param participant the participant that was granted administrator privileges
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void adminGranted(String participant);
|
||||
|
||||
/**
|
||||
* Called when an owner revokes administrator privileges from a user. This means that the user
|
||||
* will no longer be able to perform administrative functions such as banning users and edit
|
||||
* moderator list.
|
||||
*
|
||||
* @param participant the participant that was revoked administrator privileges
|
||||
* (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void adminRevoked(String participant);
|
||||
|
||||
/**
|
||||
* Called when a participant changed his/her nickname in the room. The new participant's
|
||||
* nickname will be informed with the next available presence.
|
||||
*
|
||||
* @param nickname the old nickname that the participant decided to change.
|
||||
*/
|
||||
public abstract void nicknameChanged(String nickname);
|
||||
|
||||
}
|
||||
184
CopyOftrunk/source/org/jivesoftware/smackx/muc/RoomInfo.java
Normal file
184
CopyOftrunk/source/org/jivesoftware/smackx/muc/RoomInfo.java
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.Form;
|
||||
|
||||
/**
|
||||
* Represents the room information that was discovered using Service Discovery. It's possible to
|
||||
* obtain information about a room before joining the room but only for rooms that are public (i.e.
|
||||
* rooms that may be discovered).
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class RoomInfo {
|
||||
|
||||
/**
|
||||
* JID of the room. The node of the JID is commonly used as the ID of the room or name.
|
||||
*/
|
||||
private String room;
|
||||
/**
|
||||
* Description of the room.
|
||||
*/
|
||||
private String description = "";
|
||||
/**
|
||||
* Last known subject of the room.
|
||||
*/
|
||||
private String subject = "";
|
||||
/**
|
||||
* Current number of occupants in the room.
|
||||
*/
|
||||
private int occupantsCount = -1;
|
||||
/**
|
||||
* A room is considered members-only if an invitation is required in order to enter the room.
|
||||
* Any user that is not a member of the room won't be able to join the room unless the user
|
||||
* decides to register with the room (thus becoming a member).
|
||||
*/
|
||||
private boolean membersOnly;
|
||||
/**
|
||||
* Moderated rooms enable only participants to speak. Users that join the room and aren't
|
||||
* participants can't speak (they are just visitors).
|
||||
*/
|
||||
private boolean moderated;
|
||||
/**
|
||||
* Every presence packet can include the JID of every occupant unless the owner deactives this
|
||||
* configuration.
|
||||
*/
|
||||
private boolean nonanonymous;
|
||||
/**
|
||||
* Indicates if users must supply a password to join the room.
|
||||
*/
|
||||
private boolean passwordProtected;
|
||||
/**
|
||||
* Persistent rooms are saved to the database to make sure that rooms configurations can be
|
||||
* restored in case the server goes down.
|
||||
*/
|
||||
private boolean persistent;
|
||||
|
||||
RoomInfo(DiscoverInfo info) {
|
||||
super();
|
||||
this.room = info.getFrom();
|
||||
// Get the information based on the discovered features
|
||||
this.membersOnly = info.containsFeature("muc_membersonly");
|
||||
this.moderated = info.containsFeature("muc_moderated");
|
||||
this.nonanonymous = info.containsFeature("muc_nonanonymous");
|
||||
this.passwordProtected = info.containsFeature("muc_passwordprotected");
|
||||
this.persistent = info.containsFeature("muc_persistent");
|
||||
// Get the information based on the discovered extended information
|
||||
Form form = Form.getFormFrom(info);
|
||||
if (form != null) {
|
||||
this.description =
|
||||
(String) form.getField("muc#roominfo_description").getValues().next();
|
||||
this.subject = (String) form.getField("muc#roominfo_subject").getValues().next();
|
||||
this.occupantsCount =
|
||||
Integer.parseInt((String) form.getField("muc#roominfo_occupants").getValues()
|
||||
.next());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JID of the room whose information was discovered.
|
||||
*
|
||||
* @return the JID of the room whose information was discovered.
|
||||
*/
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the discovered description of the room.
|
||||
*
|
||||
* @return the discovered description of the room.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the discovered subject of the room. The subject may be empty if the room does not
|
||||
* have a subject.
|
||||
*
|
||||
* @return the discovered subject of the room.
|
||||
*/
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the discovered number of occupants that are currently in the room. If this
|
||||
* information was not discovered (i.e. the server didn't send it) then a value of -1 will be
|
||||
* returned.
|
||||
*
|
||||
* @return the number of occupants that are currently in the room or -1 if that information was
|
||||
* not provided by the server.
|
||||
*/
|
||||
public int getOccupantsCount() {
|
||||
return occupantsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the room has restricted the access so that only members may enter the room.
|
||||
*
|
||||
* @return true if the room has restricted the access so that only members may enter the room.
|
||||
*/
|
||||
public boolean isMembersOnly() {
|
||||
return membersOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the room enabled only participants to speak. Occupants with a role of
|
||||
* visitor won't be able to speak in the room.
|
||||
*
|
||||
* @return true if the room enabled only participants to speak.
|
||||
*/
|
||||
public boolean isModerated() {
|
||||
return moderated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if presence packets will include the JID of every occupant.
|
||||
*
|
||||
* @return true if presence packets will include the JID of every occupant.
|
||||
*/
|
||||
public boolean isNonanonymous() {
|
||||
return nonanonymous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if users musy provide a valid password in order to join the room.
|
||||
*
|
||||
* @return true if users musy provide a valid password in order to join the room.
|
||||
*/
|
||||
public boolean isPasswordProtected() {
|
||||
return passwordProtected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the room will persist after the last occupant have left the room.
|
||||
*
|
||||
* @return true if the room will persist after the last occupant have left the room.
|
||||
*/
|
||||
public boolean isPersistent() {
|
||||
return persistent;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
/**
|
||||
* A listener that is fired anytime a MUC room changes its subject.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface SubjectUpdatedListener {
|
||||
|
||||
/**
|
||||
* Called when a MUC room has changed its subject.
|
||||
*
|
||||
* @param subject the new room's subject.
|
||||
* @param from the user that changed the room's subject (e.g. room@conference.jabber.org/nick).
|
||||
*/
|
||||
public abstract void subjectUpdated(String subject, String from);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2004 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;
|
||||
|
||||
/**
|
||||
* A listener that is fired anytime your participant's status in a room is changed, such as the
|
||||
* user being kicked, banned, or granted admin permissions.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface UserStatusListener {
|
||||
|
||||
/**
|
||||
* Called when a moderator kicked your user from the room. This means that you are no longer
|
||||
* participanting in the room.
|
||||
*
|
||||
* @param actor the moderator that kicked your user from the room (e.g. user@host.org).
|
||||
* @param reason the reason provided by the actor to kick you from the room.
|
||||
*/
|
||||
public abstract void kicked(String actor, String reason);
|
||||
|
||||
/**
|
||||
* Called when a moderator grants voice to your user. This means that you were a visitor in
|
||||
* the moderated room before and now you can participate in the room by sending messages to
|
||||
* all occupants.
|
||||
*
|
||||
*/
|
||||
public abstract void voiceGranted();
|
||||
|
||||
/**
|
||||
* Called when a moderator revokes voice from your user. This means that you were a
|
||||
* participant in the room able to speak and now you are a visitor that can't send
|
||||
* messages to the room occupants.
|
||||
*
|
||||
*/
|
||||
public abstract void voiceRevoked();
|
||||
|
||||
/**
|
||||
* Called when an administrator or owner banned your user from the room. This means that you
|
||||
* will no longer be able to join the room unless the ban has been removed.
|
||||
*
|
||||
* @param actor the administrator that banned your user (e.g. user@host.org).
|
||||
* @param reason the reason provided by the administrator to banned you.
|
||||
*/
|
||||
public abstract void banned(String actor, String reason);
|
||||
|
||||
/**
|
||||
* Called when an administrator grants your user membership to the room. This means that you
|
||||
* will be able to join the members-only room.
|
||||
*
|
||||
*/
|
||||
public abstract void membershipGranted();
|
||||
|
||||
/**
|
||||
* Called when an administrator revokes your user membership to the room. This means that you
|
||||
* will not be able to join the members-only room.
|
||||
*
|
||||
*/
|
||||
public abstract void membershipRevoked();
|
||||
|
||||
/**
|
||||
* Called when an administrator grants moderator privileges to your user. This means that you
|
||||
* will be able to kick users, grant and revoke voice, invite other users, modify room's
|
||||
* subject plus all the partcipants privileges.
|
||||
*
|
||||
*/
|
||||
public abstract void moderatorGranted();
|
||||
|
||||
/**
|
||||
* Called when an administrator revokes moderator privileges from your user. This means that
|
||||
* you will no longer be able to kick users, grant and revoke voice, invite other users,
|
||||
* modify room's subject plus all the partcipants privileges.
|
||||
*
|
||||
*/
|
||||
public abstract void moderatorRevoked();
|
||||
|
||||
/**
|
||||
* Called when an owner grants to your user ownership on the room. This means that you
|
||||
* will be able to change defining room features as well as perform all administrative
|
||||
* functions.
|
||||
*
|
||||
*/
|
||||
public abstract void ownershipGranted();
|
||||
|
||||
/**
|
||||
* Called when an owner revokes from your user ownership on the room. This means that you
|
||||
* will no longer be able to change defining room features as well as perform all
|
||||
* administrative functions.
|
||||
*
|
||||
*/
|
||||
public abstract void ownershipRevoked();
|
||||
|
||||
/**
|
||||
* Called when an owner grants administrator privileges to your user. This means that you
|
||||
* will be able to perform administrative functions such as banning users and edit moderator
|
||||
* list.
|
||||
*
|
||||
*/
|
||||
public abstract void adminGranted();
|
||||
|
||||
/**
|
||||
* Called when an owner revokes administrator privileges from your user. This means that you
|
||||
* will no longer be able to perform administrative functions such as banning users and edit
|
||||
* moderator list.
|
||||
*
|
||||
*/
|
||||
public abstract void adminRevoked();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<body>Classes and Interfaces that implement Multi-User Chat (MUC).</body>
|
||||
Loading…
Add table
Add a link
Reference in a new issue