diff --git a/src/org/yaaic/activity/AddCommandsActivity.java b/src/org/yaaic/activity/AddCommandsActivity.java index 0407c58..c980d30 100644 --- a/src/org/yaaic/activity/AddCommandsActivity.java +++ b/src/org/yaaic/activity/AddCommandsActivity.java @@ -23,7 +23,6 @@ package org.yaaic.activity; import java.util.ArrayList; import org.yaaic.R; -import org.yaaic.command.CommandParser; import org.yaaic.model.Extra; import android.app.Activity; @@ -39,7 +38,6 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; -import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; /** @@ -97,19 +95,12 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On case R.id.add: String command = commandInput.getText().toString().trim(); - if (command.startsWith("/")) { - command = command.substring(1); // cut the slash + if (!command.startsWith("/")) { + command = "/" + command; } - String[] params = command.split(" "); - String type = params[0]; - if (!CommandParser.getInstance().isValidCommand(type)) { - Toast.makeText(this, "Invalid command: " + params[0], Toast.LENGTH_SHORT).show(); - return; - } - - commands.add("/" + command); - adapter.add("/" + command); + commands.add(command); + adapter.add(command); commandInput.setText("/"); okButton.setEnabled(true); break; diff --git a/src/org/yaaic/command/CommandParser.java b/src/org/yaaic/command/CommandParser.java index bb26b40..42babfc 100644 --- a/src/org/yaaic/command/CommandParser.java +++ b/src/org/yaaic/command/CommandParser.java @@ -65,19 +65,6 @@ public class CommandParser private HashMap commands; private HashMap aliases; private static CommandParser instance; - - private final static String[] serverCommands = { - // whitelist of server commands - "admin", "motd", "version", "knock", "rules", - "vhost", "credits", "license", "setname", "watch", "pong", - "cycle", "links", "silence", "who", "dalinfo", "userhost", - "list", "stats", "invite", "lusers", "ping", - "time", "whowas", "ison", "map", "oper", - - // services - "nickserv", "ns", "chanserv", "cs", "authserv", "hostserv", - "memoserv", "operserv" - }; /** * Create a new CommandParser instance @@ -156,16 +143,6 @@ public class CommandParser return aliases; } - /** - * Is the given command a valid (client or server) command? - * - * @return true if the command is valid - */ - public boolean isValidCommand(String command) - { - return isClientCommand(command) || isServerCommand(command); - } - /** * Is the given command a valid client command? * @@ -177,24 +154,6 @@ public class CommandParser return commands.containsKey(command.toLowerCase()) || aliases.containsKey(command.toLowerCase()); } - /** - * Is the given command a valid server command? - * - * @param command The (server) command to check (/command) - * @return true if the command can be handled by a server, false otherwise - */ - public boolean isServerCommand(String command) - { - command = command.toLowerCase(); - for (String validCommand : serverCommands) { - if (validCommand.equals(command)) { - return true; - } - } - - return false; - } - /** * Handle a client command * @@ -257,32 +216,6 @@ public class CommandParser } } - /** - * Handle an unknown command - * - * @param type Type of the command (/type param1 param2 ..) - * @param server The current server - * @param conversation The selected conversation - * @param service The service handling the connections - */ - public void handleUnknownCommand(String type, Server server, Conversation conversation, IRCService service) - { - if (conversation != null) { - // XXX:I18N - How to get a context here? (unknown_command) - Message message = new Message("Unknown command: " + type); - message.setColor(Message.COLOR_RED); - conversation.addMessage(message); - - Intent intent = Broadcast.createConversationIntent( - Broadcast.CONVERSATION_MESSAGE, - server.getId(), - conversation.getName() - ); - - service.sendBroadcast(intent); - } - } - /** * Parse the given line * @@ -296,10 +229,8 @@ public class CommandParser if (isClientCommand(type)) { handleClientCommand(type, params, server, conversation, service); - } else if (isServerCommand(type)) { - handleServerCommand(type, params, server, conversation, service); } else { - handleUnknownCommand(type, server, conversation, service); + handleServerCommand(type, params, server, conversation, service); } } }