diff options
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/modes')
20 files changed, 667 insertions, 0 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/GenericMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/GenericMode.java new file mode 100644 index 000000000..e1dad6045 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/GenericMode.java @@ -0,0 +1,77 @@ +package f00f.net.irc.martyr.modes; + +import f00f.net.irc.martyr.Mode; + +/** + * GenericNode uses the character to specify the hash code. Thus, two + * mode types are the same, in a hash table, even if they have + * different parameters or positive/negative values. + */ +public abstract class GenericMode implements Mode +{ + private String str; + private Mode.Sign sign = Mode.Sign.NOSIGN; + + public void setParam( String str ) + { + this.str = str; + } + + public String getParam() + { + return str; + } + + public void setSign( Mode.Sign sign ) + { + this.sign = sign; + } + + public Mode.Sign getSign() + { + return sign; + } + + public String toString() + { + String pString = " "; + if( sign != Mode.Sign.NOSIGN ) + pString += ( sign == Mode.Sign.POSITIVE ? "+" : "-" ); + String className = this.getClass().getName(); + className = className.substring( className.indexOf('$')+1 ); + + String result = className + pString + getChar(); + if( requiresParam() ) + { + result += " " + getParam(); + } + + return result; + } + + public boolean equals( Object o ) + { + if( o instanceof Mode ) + { + Mode oMode = (Mode)o; + + if( oMode.getParam() == null || this.getParam() == null ) + return oMode.getChar() == this.getChar(); + + if( oMode.getParam() == null && this.getParam() != null ) + return false; + if( oMode.getParam() == null && this.getParam() == null ) + return oMode.getChar() == this.getChar(); + + return oMode.getChar() == this.getChar() && + oMode.getParam().equals(this.getParam()); + } + return false; + } + + public int hashCode() + { + return (int)getChar(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/README b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/README new file mode 100644 index 000000000..8d2e25c18 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/README @@ -0,0 +1,8 @@ +This directory contains modes. Unlike commands, errors, and replies, +these modes do NOT contain any information about the mode other than +what it is. The Mode objects know if the mode takes a parameter, what +character represents the mode, and contain a method to create a new +instance of itself. + +You can get and set parameters using the Mode related commands. + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/AnonChannelMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/AnonChannelMode.java new file mode 100644 index 000000000..9fd215416 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/AnonChannelMode.java @@ -0,0 +1,44 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>The channel flag 'a' defines an anonymous channel. This means that + * when a message sent to the channel is sent by the server to users, + * and the origin is a user, then it MUST be masked. To mask the + * message, the origin is changed to "anonymous!anonymous@anonymous." + * (e.g., a user with the nickname "anonymous", the username "anonymous" + * and from a host called "anonymous."). Because of this, servers MUST + * forbid users from using the nickname "anonymous". Servers MUST also + * NOT send QUIT messages for users leaving such channels to the other + * channel members but generate a PART message instead.</p> + * + * <p>On channels with the character '&' as prefix, this flag MAY be + * toggled by channel operators, but on channels with the character '!' + * as prefix, this flag can be set (but SHALL NOT be unset) by the + * "channel creator" only. This flag MUST NOT be made available on + * other types of channels.</p> + * + * <p>Replies to the WHOIS, WHO and NAMES commands MUST NOT reveal the + * presence of other users on channels for which the anonymous flag is + * set.</p> + * (From RFC2811) + */ +public class AnonChannelMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 'a'; + } + + public Mode newInstance() + { + return new AnonChannelMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/BanMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/BanMode.java new file mode 100644 index 000000000..d169370cb --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/BanMode.java @@ -0,0 +1,38 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Channel Ban and Exception - When a user requests to join a + * channel, his local server checks if the user's address matches + * any of the ban masks set for the channel. If a match is found, + * the user request is denied unless the address also matches an + * exception mask set for the channel.</p> + * + * <p>Servers MUST NOT allow a channel member who is banned from the + * channel to speak on the channel, unless this member is a channel + * operator or has voice privilege. (See Section 4.1.3 (Voice + * Privilege)).</p> + * + * <p>A user who is banned from a channel and who carries an invitation + * sent by a channel operator is allowed to join the channel.</p> + * (From RFC2811) + */ +public class BanMode extends GenericChannelMask +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'b'; + } + + public Mode newInstance() + { + return new BanMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/ExceptionMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/ExceptionMode.java new file mode 100644 index 000000000..63f3d03f8 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/ExceptionMode.java @@ -0,0 +1,38 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Channel Ban and Exception - When a user requests to join a + * channel, his local server checks if the user's address matches + * any of the ban masks set for the channel. If a match is found, + * the user request is denied unless the address also matches an + * exception mask set for the channel.</p> + * + * <p>Servers MUST NOT allow a channel member who is banned from the + * channel to speak on the channel, unless this member is a channel + * operator or has voice privilege. (See Section 4.1.3 (Voice + * Privilege)).</p> + * + * <p>A user who is banned from a channel and who carries an invitation + * sent by a channel operator is allowed to join the channel.</p> + * (From RFC2811) +*/ +public class ExceptionMode extends GenericChannelMask +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'e'; + } + + public Mode newInstance() + { + return new ExceptionMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/GenericChannelMask.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/GenericChannelMask.java new file mode 100644 index 000000000..13e1fc3de --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/GenericChannelMask.java @@ -0,0 +1,16 @@ +package f00f.net.irc.martyr.modes.channel; + + +/** + * 'Masks' and other modes that can have multiple copies in a channel + * at once should subclass this. + */ +public abstract class GenericChannelMask extends GenericChannelMode +{ + public boolean onePerChannel() + { + return false; + } +} + + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/GenericChannelMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/GenericChannelMode.java new file mode 100644 index 000000000..d65f850b8 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/GenericChannelMode.java @@ -0,0 +1,23 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.modes.GenericMode; + +/** + * A generic channel mode will be recorded in the channel, and there + * will be one per channel. Modes that can have multiple copies in + * the channel (masks) should subclass GenericChannelMask. + */ +public abstract class GenericChannelMode extends GenericMode +{ + public boolean recordInChannel() + { + return true; + } + + public boolean onePerChannel() + { + return true; + } +} + + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/InviteMaskMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/InviteMaskMode.java new file mode 100644 index 000000000..c9faa27fc --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/InviteMaskMode.java @@ -0,0 +1,30 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Channel Invitation - For channels which have the invite-only + * flag set (See Section 4.2.2 (Invite Only Flag)), users whose + * address matches an invitation mask set for the channel are + * allowed to join the channel without any + * invitation.</p> + * (From RFC2811) + */ +public class InviteMaskMode extends GenericChannelMask +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'I'; + } + + public Mode newInstance() + { + return new InviteMaskMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/InviteOnlyMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/InviteOnlyMode.java new file mode 100644 index 000000000..45da646c9 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/InviteOnlyMode.java @@ -0,0 +1,32 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Invite Only Flag - When the channel flag 'i' is set, new + * members are only accepted if their mask matches Invite-list (See + * section 4.3.2) or they have been invited by a channel operator. + * This flag also restricts the usage of the INVITE command (See + * "IRC Client Protocol" [IRC-CLIENT]) to channel operators.</p> + * (From RFC2811) + * + * @see InviteMaskMode + */ +public class InviteOnlyMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 'i'; + } + + public Mode newInstance() + { + return new InviteOnlyMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/KeyMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/KeyMode.java new file mode 100644 index 000000000..9f29da431 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/KeyMode.java @@ -0,0 +1,31 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Channel Key - When a channel key is set (by using the mode + * 'k'), servers MUST reject their local users request to join the + * channel unless this key is given.</p> + * + * <p>The channel key MUST only be made visible to the channel members in + * the reply sent by the server to a MODE query.</p> + * (From RFC2811) + */ +public class KeyMode extends GenericChannelMask +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'k'; + } + + public Mode newInstance() + { + return new KeyMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/LimitMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/LimitMode.java new file mode 100644 index 000000000..028739705 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/LimitMode.java @@ -0,0 +1,31 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>User Limit - A user limit may be set on channels by using the + * channel flag 'l'. When the limit is reached, servers MUST + * forbid their local users to join the channel.</p> + * + * <p>The value of the limit MUST only be made available to the channel + * members in the reply sent by the server to a MODE query.</p> + * (From RFC2811) +*/ +public class LimitMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'l'; + } + + public Mode newInstance() + { + return new LimitMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/ModeratedMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/ModeratedMode.java new file mode 100644 index 000000000..d0938a565 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/ModeratedMode.java @@ -0,0 +1,31 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Moderated Channel Flag - The channel flag 'm' is used to + * control who may speak on a channel. When it is set, only + * channel operators, and members who have been given the voice + * privilege may send messages to the channel.</p> + * + * <p>This flag only affects users.</p> + * (From RFC2811) + */ +public class ModeratedMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 'm'; + } + + public Mode newInstance() + { + return new ModeratedMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/NoExtMsgMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/NoExtMsgMode.java new file mode 100644 index 000000000..029baf760 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/NoExtMsgMode.java @@ -0,0 +1,30 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>No Messages To Channel From Clients On The Outside - When the + * channel flag 'n' is set, only channel members MAY send messages + * to the channel.</p> + * + * <p>This flag only affects users.</p> + * (From RFC2811) + */ +public class NoExtMsgMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 'n'; + } + + public Mode newInstance() + { + return new NoExtMsgMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/OperMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/OperMode.java new file mode 100644 index 000000000..e8f45f0be --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/OperMode.java @@ -0,0 +1,31 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Channel Operator Status - The mode 'o' is used to toggle the + * operator status of a channel member.</p> (From RFC2811) + * + * <p>Note that OperMode is recorded in the channel, but checking the op + * status of a member will give you a true list of who is and isn't an + * operator. This is because we don't know the entire list of modes + * when entering a channel.</p> + */ +public class OperMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'o'; + } + + public Mode newInstance() + { + return new OperMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/PrivateMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/PrivateMode.java new file mode 100644 index 000000000..580b957e6 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/PrivateMode.java @@ -0,0 +1,50 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Private and Secret Channels - The channel flag 'p' is used to + * mark a channel "private" and the channel flag 's' to mark a + * channel "secret". Both properties are similar and conceal the + * existence of the channel from other users.</p> + * + * <p>This means that there is no way of getting this channel's name from + * the server without being a member. In other words, these channels + * MUST be omitted from replies to queries like the WHOIS + * command.</p> + * + * <p>When a channel is "secret", in addition to the restriction above, the + * server will act as if the channel does not exist for queries like the + * TOPIC, LIST, NAMES commands. Note that there is one exception to + * this rule: servers will correctly reply to the MODE command. + * Finally, secret channels are not accounted for in the reply to the + * LUSERS command (See "Internet Relay Chat: Client Protocol" [IRC- + * CLIENT]) when the <mask> parameter is specified.</p> + * + * <p>The channel flags 'p' and 's' MUST NOT both be set at the same time. + * If a MODE message originating from a server sets the flag 'p' and the + * flag 's' is already set for the channel, the change is silently + * ignored. This should only happen during a split healing phase + * (mentioned in the "IRC Server Protocol" document + * [IRC-SERVER]).</p> + * + * (From RFC2811) + */ +public class PrivateMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 'p'; + } + + public Mode newInstance() + { + return new PrivateMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/SecretMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/SecretMode.java new file mode 100644 index 000000000..33bb13733 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/SecretMode.java @@ -0,0 +1,50 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Private and Secret Channels - The channel flag 'p' is used to + * mark a channel "private" and the channel flag 's' to mark a + * channel "secret". Both properties are similar and conceal the + * existence of the channel from other users.</p> + * + * <p>This means that there is no way of getting this channel's name from + * the server without being a member. In other words, these channels + * MUST be omitted from replies to queries like the WHOIS + * command.</p> + * + * <p>When a channel is "secret", in addition to the restriction above, the + * server will act as if the channel does not exist for queries like the + * TOPIC, LIST, NAMES commands. Note that there is one exception to + * this rule: servers will correctly reply to the MODE command. + * Finally, secret channels are not accounted for in the reply to the + * LUSERS command (See "Internet Relay Chat: Client Protocol" [IRC- + * CLIENT]) when the <mask> parameter is specified.</p> + * + * <p>The channel flags 'p' and 's' MUST NOT both be set at the same time. + * If a MODE message originating from a server sets the flag 'p' and the + * flag 's' is already set for the channel, the change is silently + * ignored. This should only happen during a split healing phase + * (mentioned in the "IRC Server Protocol" document + * [IRC-SERVER]).</p> + * + * (From RFC2811) + */ +public class SecretMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 's'; + } + + public Mode newInstance() + { + return new SecretMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/TopicLockMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/TopicLockMode.java new file mode 100644 index 000000000..c6f9b8a81 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/TopicLockMode.java @@ -0,0 +1,27 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Topic - The channel flag 't' is used to restrict the usage of the TOPIC + * command to channel operators.</p> + * (From RFC2811) + */ +public class TopicLockMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return false; + } + + public char getChar() + { + return 't'; + } + + public Mode newInstance() + { + return new TopicLockMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/VoiceMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/VoiceMode.java new file mode 100644 index 000000000..8d5faeac3 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/channel/VoiceMode.java @@ -0,0 +1,34 @@ +package f00f.net.irc.martyr.modes.channel; + +import f00f.net.irc.martyr.Mode; + +/** + * <p>Voice Privilege - The mode 'v' is used to give and take voice + * privilege to/from a channel member. Users with this privilege + * can talk on moderated channels. (See section 4.2.3 (Moderated + * Channel Flag).</p> + * (From RFC2811) + */ +public class VoiceMode extends GenericChannelMode +{ + public boolean requiresParam() + { + return true; + } + + public char getChar() + { + return 'v'; + } + + public boolean recordInChannel() + { + return false; + } + + public Mode newInstance() + { + return new VoiceMode(); + } +} + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/user/GenericUserMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/user/GenericUserMode.java new file mode 100644 index 000000000..7a3767d2d --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/user/GenericUserMode.java @@ -0,0 +1,24 @@ +package f00f.net.irc.martyr.modes.user; + +import f00f.net.irc.martyr.modes.GenericMode; + +/** + * + */ +public abstract class GenericUserMode extends GenericMode +{ + public boolean recordInChannel() + { + return false; + } + + /** + * Well, this is kind of irrelevent isn't it? + */ + public boolean onePerChannel() + { + return false; + } +} + + diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/modes/user/InvisibleMode.java b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/user/InvisibleMode.java new file mode 100644 index 000000000..f86da15a5 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/modes/user/InvisibleMode.java @@ -0,0 +1,22 @@ +package f00f.net.irc.martyr.modes.user; + +import f00f.net.irc.martyr.Mode; + +public class InvisibleMode extends GenericUserMode +{ + public char getChar() + { + return 'i'; + } + + public boolean requiresParam() + { + return false; + } + + public Mode newInstance() + { + return new InvisibleMode(); + } +} + |