Author: ngn Date: Wed Jul 22 11:35:51 2009 New Revision: 796677 URL: http://svn.apache.org/viewvc?rev=796677&view=rev Log: Adding module for XEP-0045 MUC
Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/pom.xml mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Affiliation.java mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Privilege.java mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Role.java mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/RoomType.java mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/ Modified: mina/sandbox/vysper/trunk/server/extensions/pom.xml Modified: mina/sandbox/vysper/trunk/server/extensions/pom.xml URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/pom.xml?rev=796677&r1=796676&r2=796677&view=diff ============================================================================== --- mina/sandbox/vysper/trunk/server/extensions/pom.xml (original) +++ mina/sandbox/vysper/trunk/server/extensions/pom.xml Wed Jul 22 11:35:51 2009 @@ -32,5 +32,6 @@ <modules> <module>xep0060-pubsub</module> + <module>xep0045-muc</module> </modules> -</project> +</project> \ No newline at end of file Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/pom.xml URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/pom.xml?rev=796677&view=auto ============================================================================== --- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/pom.xml (added) +++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/pom.xml Wed Jul 22 11:35:51 2009 @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to you 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0"> + <parent> + <artifactId>vysper-extensions</artifactId> + <groupId>org.apache.vysper</groupId> + <version>1.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.vysper.extensions</groupId> + <artifactId>xep0045-muc</artifactId> + <name>Apache Vysper XEP-0045 Multi-user chat</name> + <version>1.0.0-SNAPSHOT</version> + + + <dependencies> + <dependency> + <groupId>org.apache.vysper</groupId> + <artifactId>spec-compliance</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.apache.vysper</groupId> + <artifactId>vysper-core</artifactId> + </dependency> + + <!-- Test dependencies --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.vysper</groupId> + <artifactId>vysper-core</artifactId> + <version>${pom.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>jivesoftware</groupId> + <artifactId>smack</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>jivesoftware</groupId> + <artifactId>smackx</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +</project> Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Affiliation.java URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Affiliation.java?rev=796677&view=auto ============================================================================== --- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Affiliation.java (added) +++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Affiliation.java Wed Jul 22 11:35:51 2009 @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.vysper.xmpp.modules.extension.xep0045_muc; + +import org.apache.vysper.compliance.SpecCompliant; + +/** + * These affiliations are long-lived in that they persist across a user's visits to the room and are not affected by happenings in the room. In addition, there is no one-to-one mapping between these affiliations and an occupant's role within the room. Affiliations are granted, revoked, and maintained based on the user's bare JID. + * + * If a user without a defined affiliation enters a room, the user's affiliation is defined as "none"; however, this affiliation does not persist across visits (i.e., a service does not maintain a "none list" across visits). + * + * The member affiliation provides a way for a room owner or admin to specify a "whitelist" of users who are allowed to enter a members-only room. When a member enters a members-only room, his or her affiliation does not change, no matter what his or her role is. The member affiliation also provides a way for users to effectively register with an open room and thus be lastingly associated with that room in some way (one result may be that the user's nickname is reserved in the room). + * + * An outcast is a user who has been banned from a room and who is not allowed to enter the room. + * + * Information about affiliations MUST be sent in all presence stanzas generated or reflected by the room and sent to occupants * + * + * @author The Apache MINA Project (d...@mina.apache.org) + */ +...@speccompliant(spec="xep-0045", section="5.2", status= SpecCompliant.ComplianceStatus.FINISHED, coverage = SpecCompliant.ComplianceCoverage.COMPLETE) +public enum Affiliation { + + Owner, + Admin, + Member, + Outcast, + None +} Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Privilege.java URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Privilege.java?rev=796677&view=auto ============================================================================== --- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Privilege.java (added) +++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Privilege.java Wed Jul 22 11:35:51 2009 @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.vysper.xmpp.modules.extension.xep0045_muc; + +import java.util.EnumSet; + +import org.apache.vysper.compliance.SpecCompliant; + +/** + * For the most part, roles exist in a hierarchy. + * For instance, a participant can do anything a visitor can do, and a moderator + * can do anything a participant can do. Each role has privileges not possessed + * by the next-lowest role; these privileges are specified in the following table + * as defaults (an implementation MAY provide configuration options that override + * these defaults). + * + * @author The Apache MINA Project (d...@mina.apache.org) + */ +...@speccompliant(spec = "xep-0045", section = "5.1.1", status = SpecCompliant.ComplianceStatus.FINISHED, coverage = SpecCompliant.ComplianceCoverage.COMPLETE) +public enum Privilege { + + PresentInRoom, + ReceiveMessages, + ReceiveOccupantPresence, + PresenceBroadcastedToRoom, + ChangeAvailabilityStatus, + ChangeRoomNickname, + SendPrivateMessages, + InviteOtherUsers, + SendMessagesToAll, + ModifySubject, + KickParticipantsAndVisitors, + GrantVoice, + RevokeVoice, + + EnterOpenRoom, + RegisterWithOpenRoom, + RetrieveMemberList, + EnterMembersOnlyRoom, + BanMembersAndUnaffiliatedUsers, + EditMemberList, + EditModeratorList, + EditAdminList, + EditOwnerList, + ChangeRoomDefinition, + DestroyRoom; + + /** + * Privileges for a moderator + */ + private static EnumSet<Privilege> MODERATOR_PRIVILEGES = EnumSet.of( + PresentInRoom, + ReceiveMessages, + ReceiveOccupantPresence, + PresenceBroadcastedToRoom, + ChangeAvailabilityStatus, + ChangeRoomNickname, + SendPrivateMessages, + InviteOtherUsers, + SendMessagesToAll, + ModifySubject, + KickParticipantsAndVisitors, + GrantVoice, + RevokeVoice + ); + + /** + * Privileges for a participant + */ + private static EnumSet<Privilege> PARTICIPANT_PRIVILEGES = EnumSet.of( + PresentInRoom, + ReceiveMessages, + ReceiveOccupantPresence, + PresenceBroadcastedToRoom, + ChangeAvailabilityStatus, + ChangeRoomNickname, + SendPrivateMessages, + InviteOtherUsers, + SendMessagesToAll, + ModifySubject + ); + + /** + * Privileges for a visitor + */ + private static EnumSet<Privilege> VISITOR_PRIVILEGES = EnumSet.of( + PresentInRoom, + ReceiveMessages, + ReceiveOccupantPresence, + PresenceBroadcastedToRoom, + ChangeAvailabilityStatus, + ChangeRoomNickname, + SendPrivateMessages, + InviteOtherUsers + ); + + /** + * Privileges for a none + */ + private static EnumSet<Privilege> NONE_ROLE_PRIVILEGES = EnumSet.noneOf(Privilege.class); + + /** + * Privileges for an {...@link Affiliation} owner + */ + private static EnumSet<Privilege> OWNER_PRIVILEGES = EnumSet.of( + EnterOpenRoom, + RegisterWithOpenRoom, + RetrieveMemberList, + EnterMembersOnlyRoom, + BanMembersAndUnaffiliatedUsers, + EditMemberList, + EditModeratorList, + EditAdminList, + EditOwnerList, + ChangeRoomDefinition, + DestroyRoom + ); + + /** + * Privileges for an {...@link Affiliation} admin + */ + private static EnumSet<Privilege> ADMIN_PRIVILEGES = EnumSet.of( + EnterOpenRoom, + RegisterWithOpenRoom, + RetrieveMemberList, + EnterMembersOnlyRoom, + BanMembersAndUnaffiliatedUsers, + EditMemberList, + EditModeratorList + ); + + /** + * Privileges for an {...@link Affiliation} member + */ + private static EnumSet<Privilege> MEMBER_PRIVILEGES = EnumSet.of( + EnterOpenRoom, + RegisterWithOpenRoom, + RetrieveMemberList, + EnterMembersOnlyRoom + ); + + /** + * Privileges for an {...@link Affiliation} none + */ + private static EnumSet<Privilege> NONE_AFFILIATION_PRIVILEGES = EnumSet.of( + EnterOpenRoom, + RegisterWithOpenRoom + ); + + /** + * Privileges for an {...@link Affiliation} outcast + */ + private static EnumSet<Privilege> OUTCATS_PRIVILEGES = EnumSet.noneOf(Privilege.class); + + /** + * Get the privileges for the specified {...@link Role} + * @param role The {...@link Role} to look up privileges for + * @return The privileges for the specified role + */ + public static EnumSet<Privilege> getPrivileges(Role role) { + switch (role) { + case Moderator: + return MODERATOR_PRIVILEGES; + case Participant: + return PARTICIPANT_PRIVILEGES; + case Visitor: + return VISITOR_PRIVILEGES; + default: + return NONE_ROLE_PRIVILEGES; + } + } + + /** + * Get the privileges for the specified {...@link Affiliation} + * @param role The {...@link Affiliation} to look up privileges for + * @return The privileges for the specified affiliation + */ + public static EnumSet<Privilege> getPrivileges(Affiliation affiliation) { + switch (affiliation) { + case Owner: + return OWNER_PRIVILEGES; + case Admin: + return ADMIN_PRIVILEGES; + case Member: + return MEMBER_PRIVILEGES; + case None: + return NONE_AFFILIATION_PRIVILEGES; + default: + return OUTCATS_PRIVILEGES; + } + } +} Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Role.java URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Role.java?rev=796677&view=auto ============================================================================== --- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Role.java (added) +++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/Role.java Wed Jul 22 11:35:51 2009 @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.vysper.xmpp.modules.extension.xep0045_muc; + +import org.apache.vysper.compliance.SpecCompliant; + +/** + * Roles are temporary in that they do not necessarily persist across a user's visits to the room and MAY change during the course of an occupant's visit to the room. An implementation MAY persist roles across visits and SHOULD do so for moderated rooms (since the distinction between visitor and participant is critical to the functioning of a moderated room). + * + * There is no one-to-one mapping between roles and affiliations (e.g., a member could be a participant or a visitor). + * + * A moderator is the most powerful occupant within the context of the room, and can to some extent manage other occupants' roles in the room. A participant has fewer privileges than a moderator, although he or she always has the right to speak. A visitor is a more restricted role within the context of a moderated room, since visitors are not allowed to send messages to all occupants. + * + * Roles are granted, revoked, and maintained based on the occupant's room nickname or full JID rather than bare JID. The privileges associated with these roles, as well as the actions that trigger changes in roles, are defined below. + * + * Information about roles MUST be sent in all presence stanzas generated or reflected by the room and thus sent to occupants. + * + * @author The Apache MINA Project (d...@mina.apache.org) + */ +...@speccompliant(spec="xep-0045", section="5.1", status= SpecCompliant.ComplianceStatus.FINISHED, coverage = SpecCompliant.ComplianceCoverage.COMPLETE) +public enum Role { + + Moderator, + None, + Participant, + Visitor +} Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/RoomType.java URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/RoomType.java?rev=796677&view=auto ============================================================================== --- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/RoomType.java (added) +++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/RoomType.java Wed Jul 22 11:35:51 2009 @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.vysper.xmpp.modules.extension.xep0045_muc; + +import org.apache.vysper.compliance.SpecCompliant; + +/** + * Describes the different room types for chats + * @author The Apache MINA Project (d...@mina.apache.org) + * + */ +...@speccompliant(spec="xep-0045", section="4.2", status= SpecCompliant.ComplianceStatus.FINISHED, coverage = SpecCompliant.ComplianceCoverage.COMPLETE) +public enum RoomType { + + /** + * A room in which the full JIDs or bare JIDs of occupants cannot be discovered by anyone, including room admins and room owners; such rooms are NOT RECOMMENDED or explicitly supported by MUC, but are possible using this protocol if a service implementation offers the appropriate configuration options; contrast with Non-Anonymous Room and Semi-Anonymous Room. + */ + FullyAnonymous, + + /** + * A room that cannot be found by any user through normal means such as searching and service discovery; antonym: Public Room. + */ + Hidden, + + /** + * A room that a user cannot enter without being on the member list; antonym: Open Room. + */ + MembersOnly, + + /** + * A room in which only those with "voice" may send messages to all occupants; antonym: Unmoderated Room. + */ + Moderated, + + /** + * A room in which an occupant's full JID is exposed to all other occupants, although the occupant may choose any desired room nickname; contrast with Semi-Anonymous Room and Fully-Anonymous Room. + */ + NonAnonymous, + + /** + * A room that anyone may enter without being on the member list; antonym: Members-Only Room. + */ + Open, + + /** + * A room that a user cannot enter without first providing the correct password; antonym: Unsecured Room. + */ + PasswordProtected, + + /** + * A room that is not destroyed if the last occupant exits; antonym: Temporary Room. + */ + Persistent, + + /** + * A room that can be found by any user through normal means such as searching and service discovery; antonym: Hidden Room. + */ + Public, + + /** + * A room in which an occupant's full JID can be discovered by room admins only; contrast with Fully-Anonymous Room and Non-Anonymous Room. + */ + SemiAnonymous, + + /** + * A room that is destroyed if the last occupant exits; antonym: Persistent Room. + */ + Temporary, + + /** + * A room in which any occupant is allowed to send messages to all occupants; antonym: Moderated Room. + */ + Unmoderated, + + /** + * A room that anyone is allowed to enter without first providing the correct password; antonym: Password-Protected Room. + */ + Unsecured +}