1 /*****************************************************/
\r
2 /* This java file is a part of the */
\r
4 /* - Plouf's Java IRC Client - */
\r
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
\r
8 /* All contacts : theplouf@yahoo.com */
\r
10 /* PJIRC is free software; you can redistribute */
\r
11 /* it and/or modify it under the terms of the GNU */
\r
12 /* General Public License as published by the */
\r
13 /* Free Software Foundation; version 2 or later of */
\r
16 /* PJIRC is distributed in the hope that it will */
\r
17 /* be useful, but WITHOUT ANY WARRANTY; without */
\r
18 /* even the implied warranty of MERCHANTABILITY or */
\r
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
\r
20 /* General Public License for more details. */
\r
22 /* You should have received a copy of the GNU */
\r
23 /* General Public License along with PJIRC; if */
\r
24 /* not, write to the Free Software Foundation, */
\r
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
\r
26 /* MA 02111-1307 USA */
\r
28 /*****************************************************/
\r
33 * A default interpretor.
\r
35 public class DefaultInterpretor extends BasicInterpretor {
\r
36 private StartupConfiguration _start;
\r
37 private ServerManager _mgr;
\r
38 private PluginManager _plugin;
\r
41 * Create a new DefaultInterpretor.
\r
44 * global irc configuration.
\r
46 * statup configuration.
\r
48 * the server manager to be called upon server creation.
\r
50 * the plugin manager.
\r
52 public DefaultInterpretor(IRCConfiguration config, StartupConfiguration start, ServerManager mgr, PluginManager plugin) {
\r
60 protected void handleCommand(Source source, String cmd, String[] parts, String[] cumul) {
\r
62 if (cmd.equals("newserver")) {
\r
63 if (_ircConfiguration.getB("multiserver")) {
\r
64 test(cmd, parts, 2);
\r
67 String alias = parts[1];
\r
68 if (parts.length > 3)
\r
69 port = new Integer(parts[3]).intValue();
\r
70 if (parts.length > 4)
\r
72 String host = parts[2];
\r
74 IRCServer server = new IRCServer(_ircConfiguration, _mgr, _start.getNick(), _start.getAltNick(),
\r
75 _start.getName(), alias);
\r
76 server.setServers(new String[] { host }, new int[] { port }, new String[] { pass });
\r
77 _mgr.newServer(server, true);
\r
79 source.report(getText(IRCTextProvider.INTERPRETOR_MULTISERVER_DISABLED));
\r
81 } else if (cmd.equals("load")) {
\r
82 test(cmd, parts, 1);
\r
83 _plugin.loadPlugin(parts[1]);
\r
84 } else if (cmd.equals("unload")) {
\r
85 test(cmd, parts, 1);
\r
86 _plugin.unloadPlugin(parts[1]);
\r
88 super.handleCommand(source, cmd, parts, cumul);
\r
90 } catch (NotEnoughParametersException ex) {
\r
91 source.report(getText(IRCTextProvider.INTERPRETOR_INSUFFICIENT_PARAMETERS, ex.getMessage()));
\r