KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > master > command > plugins > Invite


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd.master.command.plugins;
19
20 import net.sf.drftpd.event.InviteEvent;
21 import net.sf.drftpd.master.BaseFtpConnection;
22 import net.sf.drftpd.master.FtpReply;
23 import net.sf.drftpd.master.command.CommandManager;
24 import net.sf.drftpd.master.command.CommandManagerFactory;
25
26 import org.drftpd.commands.CommandHandler;
27 import org.drftpd.commands.CommandHandlerFactory;
28 import org.drftpd.commands.UnhandledCommandException;
29
30 /**
31  * @author mog
32  *
33  * @version $Id: Invite.java,v 1.9.2.1 2004/06/19 23:37:26 mog Exp $
34  */

35 public class Invite implements CommandHandlerFactory, CommandHandler {
36     public Invite() {
37     }
38
39     public FtpReply execute(BaseFtpConnection conn)
40         throws UnhandledCommandException {
41         String JavaDoc cmd = conn.getRequest().getCommand();
42         if (!"SITE INVITE".equals(cmd)) {
43             throw UnhandledCommandException.create(
44                 Invite.class,
45                 conn.getRequest());
46         }
47         if (!conn.getRequest().hasArgument())
48             return new FtpReply(
49                 501,
50                 conn.jprintf(Invite.class, "invite.usage"));
51         String JavaDoc user = conn.getRequest().getArgument();
52         InviteEvent invite = new InviteEvent(cmd, user);
53         conn.getConnectionManager().dispatchFtpEvent(invite);
54         return new FtpReply(200, "Inviting " + user);
55     }
56
57     public String JavaDoc[] getFeatReplies() {
58         return null;
59     }
60     public CommandHandler initialize(
61         BaseFtpConnection conn,
62         CommandManager initializer) {
63         return this;
64     }
65     public void load(CommandManagerFactory initializer) {
66     }
67     public void unload() {
68     }
69 }
70
Popular Tags