From db5ac3a467efaff18e2a44a3db48bc50adf66cf8 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Tue, 2 Mar 2010 19:47:43 +0100 Subject: [PATCH] Implemented IRCConnection.onKick() --- src/org/yaaic/irc/IRCConnection.java | 17 +++++++++++++---- src/org/yaaic/model/Broadcast.java | 1 + src/org/yaaic/model/Server.java | 10 ++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/org/yaaic/irc/IRCConnection.java b/src/org/yaaic/irc/IRCConnection.java index 3cff545..602d1e7 100644 --- a/src/org/yaaic/irc/IRCConnection.java +++ b/src/org/yaaic/irc/IRCConnection.java @@ -141,18 +141,27 @@ public class IRCConnection extends PircBot * On Kick */ @Override - protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) + protected void onKick(String target, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) { - debug("Kick", channel + " " + recipientNick + "(" + kickerNick + ")"); + debug("Kick", target + " " + recipientNick + "(" + kickerNick + ")"); + + if (recipientNick.equals(getNick())) { + // We are kicked + server.removeChannel(target); + service.sendBroadcast(new Intent(Broadcast.CHANNEL_REMOVE)); + } else { + server.getChannel(target).addMessage(kickerNick + " kicked " + recipientNick); + service.sendBroadcast(new Intent(Broadcast.CHANNEL_MESSAGE)); + } } /** * On Message */ @Override - protected void onMessage(String channel, String sender, String login, String hostname, String message) + protected void onMessage(String target, String sender, String login, String hostname, String message) { - debug("Message", channel + " " + sender + " " + message); + debug("Message", target + " " + sender + " " + message); } /** diff --git a/src/org/yaaic/model/Broadcast.java b/src/org/yaaic/model/Broadcast.java index afd0308..a5989aa 100644 --- a/src/org/yaaic/model/Broadcast.java +++ b/src/org/yaaic/model/Broadcast.java @@ -26,4 +26,5 @@ public class Broadcast public static final String CHANNEL_MESSAGE = "org.yaaic.channel.message"; public static final String CHANNEL_NEW = "org.yaaic.channel.new"; + public static final String CHANNEL_REMOVE = "org.yaaic.channel.remove"; } diff --git a/src/org/yaaic/model/Server.java b/src/org/yaaic/model/Server.java index 416b29b..1d979e3 100644 --- a/src/org/yaaic/model/Server.java +++ b/src/org/yaaic/model/Server.java @@ -190,6 +190,16 @@ public class Server channels.put(channel.getName(), channel); } + /** + * Renive a (joined) channel + * + * @param name + */ + public void removeChannel(String name) + { + channels.remove(name); + } + /** * Get icon for current server status *