01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * 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 java.util.StringTokenizer;
21:
22: import net.sf.drftpd.event.InviteEvent;
23: import net.sf.drftpd.master.BaseFtpConnection;
24: import net.sf.drftpd.master.command.CommandManager;
25: import net.sf.drftpd.master.command.CommandManagerFactory;
26:
27: import org.drftpd.commands.CommandHandler;
28: import org.drftpd.commands.CommandHandlerFactory;
29: import org.drftpd.commands.ImproperUsageException;
30: import org.drftpd.commands.Reply;
31: import org.drftpd.commands.UnhandledCommandException;
32:
33: /**
34: * @author mog
35: *
36: * @version $Id: Invite.java 1402 2006-01-22 05:01:29Z tdsoul $
37: */
38: public class Invite implements CommandHandler, CommandHandlerFactory {
39: public Invite() {
40: }
41:
42: public Reply execute(BaseFtpConnection conn)
43: throws UnhandledCommandException, ImproperUsageException {
44: String cmd = conn.getRequest().getCommand();
45:
46: if (!"SITE INVITE".equals(cmd)) {
47: throw UnhandledCommandException.create(Invite.class, conn
48: .getRequest());
49: }
50:
51: if (!conn.getRequest().hasArgument()) {
52: throw new ImproperUsageException();
53: }
54:
55: StringTokenizer st = new StringTokenizer(conn.getRequest()
56: .getArgument());
57: if (st.countTokens() != 1)
58: return Reply.RESPONSE_501_SYNTAX_ERROR;
59:
60: String user = st.nextToken();
61:
62: InviteEvent invite = new InviteEvent(cmd, user, conn
63: .getUserNull());
64: conn.getGlobalContext().dispatchFtpEvent(invite);
65:
66: return new Reply(200, "Inviting " + user);
67: }
68:
69: // public String getHelp(String cmd) {
70: // ResourceBundle bundle = ResourceBundle.getBundle(Invite.class.getName());
71: // if ("".equals(cmd))
72: // return bundle.getString("help.general")+"\n";
73: // else if ("invite".equals(cmd))
74: // return bundle.getString("help.invite")+"\n";
75: // else
76: // return "";
77: // }
78:
79: public String[] getFeatReplies() {
80: return null;
81: }
82:
83: public CommandHandler initialize(BaseFtpConnection conn,
84: CommandManager initializer) {
85: return this ;
86: }
87:
88: public void load(CommandManagerFactory initializer) {
89: }
90:
91: public void unload() {
92: }
93: }
|