All handlers now use conversations instead of channels
This commit is contained in:
parent
47ee4d1d6e
commit
9259ae2afd
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,10 +37,10 @@ public class DeopHandler extends BaseHandler
|
||||||
* Execute /voice
|
* Execute /voice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).deOp(channel.getName(), params[1]);
|
service.getConnection(server.getId()).deOp(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Invalid number of params");
|
throw new CommandException("Invalid number of params");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,10 +37,10 @@ public class DevoiceHandler extends BaseHandler
|
||||||
* Execute /devoice
|
* Execute /devoice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).deVoice(channel.getName(), params[1]);
|
service.getConnection(server.getId()).deVoice(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Invalid number of params");
|
throw new CommandException("Invalid number of params");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Message;
|
import org.yaaic.model.Message;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
|
@ -41,15 +41,15 @@ public class EchoHandler extends BaseHandler
|
||||||
* Execute /echo
|
* Execute /echo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
Message message = new Message(BaseHandler.mergeParams(params));
|
Message message = new Message(BaseHandler.mergeParams(params));
|
||||||
channel.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
intent.putExtra(Broadcast.EXTRA_CHANNEL, conversation.getName());
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Text is missing");
|
throw new CommandException("Text is missing");
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public class JoinHandler extends BaseHandler
|
||||||
* Execute /join
|
* Execute /join
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).joinChannel(params[1]);
|
service.getConnection(server.getId()).joinChannel(params[1]);
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,10 +39,10 @@ public class KickHandler extends BaseHandler
|
||||||
* Execute /kick
|
* Execute /kick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).kick(channel.getName(), params[1]);
|
service.getConnection(server.getId()).kick(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Invalid number of params");
|
throw new CommandException("Invalid number of params");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Message;
|
import org.yaaic.model.Message;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class MeHandler extends BaseHandler
|
||||||
* Execute /me
|
* Execute /me
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
String action = BaseHandler.mergeParams(params);
|
String action = BaseHandler.mergeParams(params);
|
||||||
|
@ -50,14 +50,14 @@ public class MeHandler extends BaseHandler
|
||||||
|
|
||||||
Message message = new Message(nickname + " " + action);
|
Message message = new Message(nickname + " " + action);
|
||||||
message.setIcon(R.drawable.action);
|
message.setIcon(R.drawable.action);
|
||||||
server.getChannel(channel.getName()).addMessage(message);
|
server.getConversation(conversation.getName()).addMessage(message);
|
||||||
|
|
||||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
intent.putExtra(Broadcast.EXTRA_CHANNEL, conversation.getName());
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
|
|
||||||
service.getConnection(server.getId()).sendAction(channel.getName(), action);
|
service.getConnection(server.getId()).sendAction(conversation.getName(), action);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Text is missing");
|
throw new CommandException("Text is missing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Message;
|
import org.yaaic.model.Message;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ public class NamesHandler extends BaseHandler
|
||||||
* Execute /names
|
* Execute /names
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
StringBuffer userList = new StringBuffer("Users " + channel.getName() + ":");
|
StringBuffer userList = new StringBuffer("Users " + conversation.getName() + ":");
|
||||||
for (User user : service.getConnection(server.getId()).getUsers(channel.getName())) {
|
for (User user : service.getConnection(server.getId()).getUsers(conversation.getName())) {
|
||||||
userList.append(" ");
|
userList.append(" ");
|
||||||
userList.append(user.getPrefix());
|
userList.append(user.getPrefix());
|
||||||
userList.append(user.getNick());
|
userList.append(user.getNick());
|
||||||
|
@ -54,11 +54,11 @@ public class NamesHandler extends BaseHandler
|
||||||
|
|
||||||
Message message = new Message(userList.toString());
|
Message message = new Message(userList.toString());
|
||||||
message.setColor(Message.COLOR_YELLOW);
|
message.setColor(Message.COLOR_YELLOW);
|
||||||
channel.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
intent.putExtra(Broadcast.EXTRA_CHANNEL, conversation.getName());
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public class NickHandler extends BaseHandler
|
||||||
* Execute /nick
|
* Execute /nick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).changeNick(params[1]);
|
service.getConnection(server.getId()).changeNick(params[1]);
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,10 +37,10 @@ public class OpHandler extends BaseHandler
|
||||||
* Execute /deop
|
* Execute /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).op(channel.getName(), params[1]);
|
service.getConnection(server.getId()).op(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Invalid number of params");
|
throw new CommandException("Invalid number of params");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public class QuitHandler extends BaseHandler
|
||||||
* Execute /quit
|
* Execute /quit
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 1) {
|
if (params.length == 1) {
|
||||||
service.getConnection(server.getId()).quitServer();
|
service.getConnection(server.getId()).quitServer();
|
||||||
|
|
|
@ -21,8 +21,10 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
package org.yaaic.command.handler;
|
package org.yaaic.command.handler;
|
||||||
|
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Channel;
|
||||||
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +40,14 @@ public class TopicHandler extends BaseHandler
|
||||||
* Execute /topic
|
* Execute /topic
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service)
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
|
throw new CommandException("Only usable from within a channel");
|
||||||
|
}
|
||||||
|
|
||||||
|
Channel channel = (Channel) conversation;
|
||||||
|
|
||||||
if (params.length == 1) {
|
if (params.length == 1) {
|
||||||
// Show topic
|
// Show topic
|
||||||
service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false);
|
service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false);
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||||
import org.yaaic.command.BaseHandler;
|
import org.yaaic.command.BaseHandler;
|
||||||
import org.yaaic.command.CommandException;
|
import org.yaaic.command.CommandException;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,10 +37,10 @@ public class VoiceHandler extends BaseHandler
|
||||||
* Execute /voice
|
* Execute /voice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).voice(channel.getName(), params[1]);
|
service.getConnection(server.getId()).voice(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Invalid number of params");
|
throw new CommandException("Invalid number of params");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue