summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/f00f/net/irc/martyr/replies
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/replies')
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/AbstractWhoisReply.java58
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/AwayReply.java49
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/ChannelCreationReply.java78
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericReply.java16
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericStringReply.java23
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserClientReply.java28
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserMeReply.java28
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserOpReply.java36
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListEndReply.java31
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListReply.java63
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListStartReply.java31
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/ModeReply.java54
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesEndReply.java47
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesReply.java89
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/NowAwayReply.java43
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/TopicInfoReply.java80
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnAwayReply.java43
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnknownReply.java66
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisChannelsReply.java70
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisEndReply.java37
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisIdleReply.java68
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisServerReply.java61
-rw-r--r--EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisUserReply.java54
23 files changed, 1153 insertions, 0 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/AbstractWhoisReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/AbstractWhoisReply.java
new file mode 100644
index 000000000..d52e59dcf
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/AbstractWhoisReply.java
@@ -0,0 +1,58 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.util.ParameterIterator;
+
+public abstract class AbstractWhoisReply extends GenericReply
+{
+ //static Logger log = Logger.getLogger(AbstractWhoisReply.class);
+
+ private String target = null;
+
+ /**
+ * Factory constructor.
+ * */
+ public AbstractWhoisReply()
+ {
+ }
+
+ public AbstractWhoisReply( String params )
+ {
+ ParameterIterator pi = getParams( params );
+ parseParams( pi );
+ }
+
+ public abstract String getIrcIdentifier();
+
+ /**
+ * Parse the parameters, but the target param has already been
+ * stripped off.
+ *
+ * @param pi Parameter iterator that will parse the parameters
+ * */
+ protected abstract void parseParams( ParameterIterator pi );
+
+ /**
+ * @return the target of the whois
+ * */
+ public String getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * @param params the params string passed to "parse".
+ * @return a parameter iterator, with the whois target already
+ * stripped off.
+ * */
+ protected ParameterIterator getParams( String params )
+ {
+ ParameterIterator pi = new ParameterIterator(params);
+ pi.next(); // throw away our own nick
+ this.target = (String)pi.next();
+ //log.debug("AbstractWhoisReply: Whois target: " + target);
+
+ return pi;
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/AwayReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/AwayReply.java
new file mode 100644
index 000000000..a7105546e
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/AwayReply.java
@@ -0,0 +1,49 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+/**
+ * Signals an automated AWAY message received as a response to a PRIVMSG that was sent out.
+ *
+ * @author Daniel Henninger
+ */
+public class AwayReply extends GenericReply
+{
+
+ private String nick;
+ private String message;
+
+ /**
+ * Factory constructor.
+ */
+ public AwayReply()
+ {
+ }
+
+ public AwayReply(String nick, String message)
+ {
+ this.nick = nick;
+ this.message = message;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "301";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new AwayReply(getParameter(params, 1), getParameter(params, 2));
+ }
+
+ public String getNick()
+ {
+ return nick;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+}
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ChannelCreationReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ChannelCreationReply.java
new file mode 100644
index 000000000..2dd89e1cd
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ChannelCreationReply.java
@@ -0,0 +1,78 @@
+package f00f.net.irc.martyr.replies;
+
+import java.util.Date;
+import java.util.StringTokenizer;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.clientstate.Channel;
+import f00f.net.irc.martyr.clientstate.ClientState;
+
+/**
+ * ChannelCreationReply sets the creation time of the channel. It is sent
+ * automatically on a MODE discovery request.
+ */
+public class ChannelCreationReply extends GenericReply
+{
+ private String channelName;
+ private Date date;
+
+ /** For use as a factory. */
+ public ChannelCreationReply()
+ {
+ }
+
+ public ChannelCreationReply( String channelName, Date date )
+ {
+ this.channelName = channelName;
+ this.date = date;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "329";
+ }
+
+ /**
+ * This is a factory that passes the command off to a
+ * ChannelModeCommand.
+ */
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ StringTokenizer tokens = new StringTokenizer( params );
+
+ // Our nick. We don't need that, I think.
+ tokens.nextToken();
+
+ // The channel.
+ String chan = tokens.nextToken();
+
+ // The date.
+ Date date;
+ try
+ {
+ date = new Date( Long.parseLong( tokens.nextToken() ) * 1000 );
+ }
+ catch( NumberFormatException nfe )
+ {
+ // riiiight...
+ date = new Date(0);
+ }
+
+ return new ChannelCreationReply( chan, date );
+ }
+
+ /**
+ * This should, theoretically, never be called, because this command is
+ * only ever used as a factory.
+ */
+ public boolean updateClientState( ClientState state )
+ {
+ Channel channel = state.getChannel( channelName );
+ channel.setCreationDate( date );
+ return true;
+ }
+}
+
+
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericReply.java
new file mode 100644
index 000000000..eabdf2658
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericReply.java
@@ -0,0 +1,16 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.commands.AbstractInCommand;
+
+/**
+ * Defines what a reply is. A reply is really the same as an error,
+ * it just doesn't signify an error.
+ */
+public abstract class GenericReply extends AbstractInCommand
+{
+
+
+}
+
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericStringReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericStringReply.java
new file mode 100644
index 000000000..38d609ac6
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/GenericStringReply.java
@@ -0,0 +1,23 @@
+package f00f.net.irc.martyr.replies;
+
+public abstract class GenericStringReply extends GenericReply
+{
+
+ private String string;
+
+ public GenericStringReply()
+ {
+ }
+
+ public GenericStringReply( String string )
+ {
+ this.string = string;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserClientReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserClientReply.java
new file mode 100644
index 000000000..c108fe919
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserClientReply.java
@@ -0,0 +1,28 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+public class LUserClientReply extends GenericStringReply
+{
+
+ public LUserClientReply()
+ {
+ }
+
+ public LUserClientReply( String string )
+ {
+ super( string );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "251";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new LUserClientReply( getParameter( params, 1 ) );
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserMeReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserMeReply.java
new file mode 100644
index 000000000..9083f0a73
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserMeReply.java
@@ -0,0 +1,28 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+public class LUserMeReply extends GenericStringReply
+{
+
+ public LUserMeReply()
+ {
+ }
+
+ public LUserMeReply( String string )
+ {
+ super( string );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "255";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new LUserMeReply( getParameter( params, 1 ) );
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserOpReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserOpReply.java
new file mode 100644
index 000000000..b05efedc1
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/LUserOpReply.java
@@ -0,0 +1,36 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+public class LUserOpReply extends GenericStringReply
+{
+
+ private int numOps;
+
+ public LUserOpReply()
+ {
+ }
+
+ public LUserOpReply( int ops, String string )
+ {
+ super( string );
+ this.numOps = ops;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "252";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new LUserOpReply( getIntParameter( params, 1, -1 ), getParameter( params, 2 ) );
+ }
+
+ public int getNumOps()
+ {
+ return numOps;
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListEndReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListEndReply.java
new file mode 100644
index 000000000..6a0b1ca7f
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListEndReply.java
@@ -0,0 +1,31 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+/**
+ * Signals the end of a LIST response.
+ *
+ * @author Daniel Henninger
+ */
+public class ListEndReply extends GenericReply
+{
+
+ /**
+ * Factory constructor.
+ */
+ public ListEndReply()
+ {
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "323";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new ListEndReply();
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListReply.java
new file mode 100644
index 000000000..a814c5a43
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListReply.java
@@ -0,0 +1,63 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+/**
+ * Signals an entry of a LIST response.
+ *
+ * @author Daniel Henninger
+ */
+public class ListReply extends GenericReply
+{
+
+ private String requestor;
+ private String channel;
+ private Integer memberCount;
+ private String topic;
+
+ /**
+ * Factory constructor.
+ */
+ public ListReply()
+ {
+ }
+
+ public ListReply(String requestor, String channel, Integer memberCount, String topic)
+ {
+ this.requestor = requestor;
+ this.channel = channel;
+ this.memberCount = memberCount;
+ this.topic = topic;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "322";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new ListReply(getParameter(params, 0), getParameter(params, 1), Integer.parseInt(getParameter(params, 2)), getParameter(params, 3));
+ }
+
+ public String getChannel()
+ {
+ return channel;
+ }
+
+ public Integer getMemberCount()
+ {
+ return memberCount;
+ }
+
+ public String getTopic()
+ {
+ return topic;
+ }
+
+ public String getRequestor()
+ {
+ return requestor;
+ }
+
+}
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListStartReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListStartReply.java
new file mode 100644
index 000000000..0f00d6c3f
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ListStartReply.java
@@ -0,0 +1,31 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+/**
+ * Signals the beginning of a LIST response.
+ *
+ * @author Daniel Henninger
+ */
+public class ListStartReply extends GenericReply
+{
+
+ /**
+ * Factory constructor.
+ */
+ public ListStartReply()
+ {
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "321";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new ListStartReply();
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ModeReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ModeReply.java
new file mode 100644
index 000000000..d355e45e3
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/ModeReply.java
@@ -0,0 +1,54 @@
+package f00f.net.irc.martyr.replies;
+
+import java.util.StringTokenizer;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.clientstate.ClientState;
+import f00f.net.irc.martyr.commands.ChannelModeCommand;
+
+/**
+ * ModeReply is really a factory that passes the ModeReply off to a
+ * ChannelModeCommand.
+ */
+public class ModeReply extends GenericReply
+{
+
+ /** For use as a factory. */
+ public ModeReply()
+ {
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "324";
+ }
+
+ /**
+ * This is a factory that passes the command off to a
+ * ChannelModeCommand.
+ */
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ StringTokenizer tokens = new StringTokenizer( params );
+
+ // Our nick. We don't need that, I think.
+ tokens.nextToken();
+
+ String chan = tokens.nextToken();
+
+ return new ChannelModeCommand( prefix, chan, tokens );
+ }
+
+ /**
+ * This should, theoretically, never be called, because this command is
+ * only ever used as a factory.
+ */
+ public boolean updateClientState( ClientState state )
+ {
+ throw new IllegalStateException("This shouldn't be called!" );
+ }
+}
+
+
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesEndReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesEndReply.java
new file mode 100644
index 000000000..a0605b5bd
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesEndReply.java
@@ -0,0 +1,47 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+public class NamesEndReply extends GenericReply
+{
+
+ private String channel;
+ private String comment;
+
+ /** For use as a factory. */
+ public NamesEndReply()
+ {
+ this( null, null );
+ }
+
+ public NamesEndReply( String channel, String comment )
+ {
+ this.channel = channel;
+ this.comment = comment;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "366";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new NamesEndReply( getParameter( params, 1 ), getParameter( params, 2 ) );
+ }
+
+ public String getChannel()
+ {
+ return channel;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+
+}
+
+
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesReply.java
new file mode 100644
index 000000000..acd5045f6
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NamesReply.java
@@ -0,0 +1,89 @@
+package f00f.net.irc.martyr.replies;
+
+import java.util.List;
+import java.util.Arrays;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.clientstate.Channel;
+import f00f.net.irc.martyr.clientstate.ClientState;
+import java.util.logging.Logger;
+
+public class NamesReply extends GenericReply
+{
+ static Logger log = Logger.getLogger(NamesReply.class.getName());
+
+ private List<String> names;
+ private String channel;
+
+ /** For use as a factory. */
+ public NamesReply()
+ {
+ }
+
+ public NamesReply( String channel, List<String> names )
+ {
+ this.names = names;
+ this.channel = channel;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "353";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new NamesReply( getParameter( params, 2 ), Arrays.asList(getParameter( params, 3 ).split(" ")) );
+ }
+
+ /**
+ * Adds the list of names to the client state.
+ */
+ public boolean updateClientState( ClientState state )
+ {
+ boolean stateChanged = false;
+
+ // 1) Get the Channel
+ Channel channelObj = state.getChannel( channel );
+
+ if( channel == null )
+ {
+ log.severe("NamesReply: Channel is null");
+ return false;
+ }
+
+ if( channelObj == null )
+ {
+ log.severe("NamesReply: No channel object for channel: " + channel);
+ return false;
+ }
+
+
+ // 2) Parse out names
+ for (String nick : names) {
+ // 3) Check that the user is not already in the list
+ if( !channelObj.isMemberInChannel( nick ) )
+ {
+ channelObj.addMember( nick, this );
+ stateChanged = true;
+ }
+ }
+
+ return stateChanged;
+ }
+
+ public List<String> getNames()
+ {
+ return names;
+ }
+
+ public String getChannel()
+ {
+ return channel;
+ }
+
+}
+
+
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NowAwayReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NowAwayReply.java
new file mode 100644
index 000000000..012431112
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/NowAwayReply.java
@@ -0,0 +1,43 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+/**
+ * Signals that you were successfully marked un-away.
+ *
+ * @author Daniel Henninger
+ */
+public class NowAwayReply extends GenericReply
+{
+
+ /* Should always be You have been marked as being away */
+ private String message;
+
+ /**
+ * Factory constructor.
+ */
+ public NowAwayReply()
+ {
+ }
+
+ public NowAwayReply(String message)
+ {
+ this.message = message;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "306";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new NowAwayReply(getParameter(params, 0));
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+}
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/TopicInfoReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/TopicInfoReply.java
new file mode 100644
index 000000000..311e17dc8
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/TopicInfoReply.java
@@ -0,0 +1,80 @@
+package f00f.net.irc.martyr.replies;
+
+import java.util.Date;
+import java.util.StringTokenizer;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.clientstate.Channel;
+import f00f.net.irc.martyr.clientstate.ClientState;
+
+/**
+ * Contains info about the topic, who set it and when.
+ */
+public class TopicInfoReply extends GenericReply
+{
+ private String channelName;
+ private Date date;
+ private String author;
+
+ /** For use as a factory. */
+ public TopicInfoReply()
+ {
+ }
+
+ public TopicInfoReply( String channelName, Date date, String author )
+ {
+ this.channelName = channelName;
+ this.date = date;
+ this.author = author;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "333";
+ }
+
+ public String getChannel()
+ {
+ return this.channelName;
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ StringTokenizer tokens = new StringTokenizer( params );
+
+ // Our nick. We don't need that, I think.
+ tokens.nextToken();
+
+ // The channel.
+ String chan = tokens.nextToken();
+
+ // The author
+ String author = tokens.nextToken();
+
+ // The date.
+ Date date;
+ try
+ {
+ date = new Date( Long.parseLong( tokens.nextToken() ) * 1000 );
+ }
+ catch( NumberFormatException nfe )
+ {
+ // riiiight...
+ date = new Date(0);
+ }
+
+ return new TopicInfoReply( chan, date, author );
+ }
+
+ public boolean updateClientState( ClientState state )
+ {
+ Channel channel = state.getChannel( channelName );
+ channel.setTopicDate( date );
+ channel.setTopicAuthor( author );
+ return true;
+ }
+}
+
+
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnAwayReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnAwayReply.java
new file mode 100644
index 000000000..f4652f0ce
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnAwayReply.java
@@ -0,0 +1,43 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+
+/**
+ * Signals that you were successfully marked un-away.
+ *
+ * @author Daniel Henninger
+ */
+public class UnAwayReply extends GenericReply
+{
+
+ /* Should always be You are no longer marked as being away */
+ private String message;
+
+ /**
+ * Factory constructor.
+ */
+ public UnAwayReply()
+ {
+ }
+
+ public UnAwayReply(String message)
+ {
+ this.message = message;
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "305";
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new UnAwayReply(getParameter(params, 0));
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+}
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnknownReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnknownReply.java
new file mode 100644
index 000000000..f4ebc14d6
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/UnknownReply.java
@@ -0,0 +1,66 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.State;
+import f00f.net.irc.martyr.commands.UnknownCommand;
+
+
+/**
+ * A container for unknown replies.
+ */
+public class UnknownReply extends UnknownCommand
+{
+ private String replyStr;
+ private int replyCode;
+
+ public UnknownReply( String ident )
+ {
+ replyStr = ident;
+ replyCode = Integer.parseInt( ident );
+ }
+
+ public int getReplyCode()
+ {
+ return replyCode;
+ }
+
+ public String getReply()
+ {
+ return replyStr;
+ }
+
+ public static boolean isReply( String ident )
+ {
+ char c = ident.charAt(0);
+ return ( c == '0' || c == '2' || c == '3' );
+ }
+
+ public State getState()
+ {
+ return State.UNKNOWN;
+ }
+
+ /**
+ * Never parsed.
+ */
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ throw new UnsupportedOperationException("UnknownReply does no parsing.");
+ }
+
+ /**
+ * Unknown, so we don't know what the identifier is ahead of time.
+ */
+ public String getIrcIdentifier()
+ {
+ return replyStr;
+ }
+
+ public String toString()
+ {
+ return "UnknownReply[" + replyStr + "]";
+ }
+
+}
+
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisChannelsReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisChannelsReply.java
new file mode 100644
index 000000000..0eee5eb2f
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisChannelsReply.java
@@ -0,0 +1,70 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.util.ParameterIterator;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+//import org.apache.log4j.Logger;
+
+public class WhoisChannelsReply extends AbstractWhoisReply
+{
+ //static Logger log = Logger.getLogger(WhoisChannelsReply.class);
+
+ private String channels;
+
+ /**
+ * Factory constructor.
+ * */
+ public WhoisChannelsReply()
+ {
+ }
+
+ public WhoisChannelsReply( String params )
+ {
+ super( params );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "319";
+ }
+
+ /**
+ * @return a space-delimited list of channels
+ * */
+ public String getChannels()
+ {
+ return channels;
+ }
+
+ /**
+ * @return a set of Strings of channels
+ * */
+ public Set<String> getChannelSet()
+ {
+ StringTokenizer tokens = new StringTokenizer( channels );
+ Set<String> set = new HashSet<String>();
+ while( tokens.hasMoreTokens() )
+ {
+ set.add( tokens.nextToken() );
+ }
+
+ return set;
+ }
+
+ protected void parseParams( ParameterIterator pi )
+ {
+ channels = pi.last(); // Channels
+
+ //log.debug("WhoisChannelsReply: channels: " + channels);
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new WhoisChannelsReply( params );
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisEndReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisEndReply.java
new file mode 100644
index 000000000..ce9def847
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisEndReply.java
@@ -0,0 +1,37 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.util.ParameterIterator;
+
+public class WhoisEndReply extends AbstractWhoisReply
+{
+ /**
+ * Factory constructor.
+ * */
+ public WhoisEndReply()
+ {
+ }
+
+ public WhoisEndReply( String params )
+ {
+ super( params );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "318";
+ }
+
+
+ protected void parseParams( ParameterIterator pi )
+ {
+ // nothing to do here
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new WhoisEndReply( params );
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisIdleReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisIdleReply.java
new file mode 100644
index 000000000..aba98205d
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisIdleReply.java
@@ -0,0 +1,68 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.util.ParameterIterator;
+import java.util.Date;
+
+//import org.apache.log4j.Logger;
+
+public class WhoisIdleReply extends AbstractWhoisReply
+{
+ //static Logger log = Logger.getLogger(WhoisIdleReply.class);
+
+ private int idleTime;
+ private Date loginTime;
+
+ /**
+ * Factory constructor.
+ * */
+ public WhoisIdleReply()
+ {
+ }
+
+ public WhoisIdleReply( String params )
+ {
+ super( params );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "317";
+ }
+
+ /**
+ * @return seconds idle
+ * */
+ public int getIdleTime()
+ {
+ return idleTime;
+ }
+
+ /**
+ * @return login time, if provided, null otherwise
+ * */
+ public Date getLoginTime()
+ {
+ return loginTime;
+ }
+
+ protected void parseParams( ParameterIterator pi )
+ {
+ String idleTimeStr = (String)pi.next(); // Idle name
+ idleTime = Integer.parseInt( idleTimeStr );
+ if( pi.hasNext() && ! pi.nextIsLast() )
+ {
+ String loginTimeStr = (String)pi.next(); // Idle description
+ loginTime = new Date( Long.parseLong( loginTimeStr ) * 1000 );
+ }
+ //log.debug("WhoisIdleReply: idle: " + idleTime);
+ //log.debug("WhoisIdleReply: login: " + loginTime);
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new WhoisIdleReply( params );
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisServerReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisServerReply.java
new file mode 100644
index 000000000..d1f4d6344
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisServerReply.java
@@ -0,0 +1,61 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.util.ParameterIterator;
+//import org.apache.log4j.Logger;
+
+public class WhoisServerReply extends AbstractWhoisReply
+{
+ //static Logger log = Logger.getLogger(WhoisServerReply.class);
+
+ private String serverName;
+ private String serverDesc;
+
+ /**
+ * Factory constructor.
+ * */
+ public WhoisServerReply()
+ {
+ }
+
+ public WhoisServerReply( String params )
+ {
+ super( params );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "312";
+ }
+
+ /**
+ * @return the DNS name of the server
+ * */
+ public String getServerName()
+ {
+ return serverName;
+ }
+
+ /**
+ * @return the free-form description of the server
+ * */
+ public String getServerDescription()
+ {
+ return serverDesc;
+ }
+
+ protected void parseParams( ParameterIterator pi )
+ {
+ serverName = (String)pi.next(); // Server name
+ serverDesc = (String)pi.next(); // Server description
+ //log.debug("WhoisServerReply: server name: " + serverName);
+ //log.debug("WhoisServerReply: server desc: " + serverDesc);
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new WhoisServerReply( params );
+ }
+
+}
+
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisUserReply.java b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisUserReply.java
new file mode 100644
index 000000000..a896c65e6
--- /dev/null
+++ b/EssentialsUpdate/src/f00f/net/irc/martyr/replies/WhoisUserReply.java
@@ -0,0 +1,54 @@
+package f00f.net.irc.martyr.replies;
+
+import f00f.net.irc.martyr.InCommand;
+import f00f.net.irc.martyr.util.ParameterIterator;
+
+public class WhoisUserReply extends AbstractWhoisReply
+{
+
+ private String host;
+ private String name;
+
+ /**
+ * Factory constructor.
+ * */
+ public WhoisUserReply()
+ {
+ }
+
+ public WhoisUserReply( String params )
+ {
+ super( params );
+ }
+
+ public String getIrcIdentifier()
+ {
+ return "311";
+ }
+
+ protected void parseParams( ParameterIterator pi )
+ {
+ pi.next(); // throw away the nick
+ host = (String)pi.next(); // hostmask
+ //log.debug("WhoisUserReply: host: " + host);
+ name = pi.last(); // the "Name"
+ //log.debug("WhoisUserReply: name: " + name);
+ }
+
+ public InCommand parse( String prefix, String identifier, String params )
+ {
+ return new WhoisUserReply( params );
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
+