From 5fe3e01f306ae440ce66376e4cf6d485c6003c6b Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Fri, 5 Mar 2010 14:25:33 +0100 Subject: [PATCH] Add channel name to CHANNEL_NEW and CHANNEL_REMOVE broadcasts --- src/org/yaaic/irc/IRCConnection.java | 15 ++++++++++++--- src/org/yaaic/listener/ChannelListener.java | 4 ++-- src/org/yaaic/receiver/ChannelReceiver.java | 5 +++++ src/org/yaaic/view/ServerActivity.java | 8 ++++---- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/org/yaaic/irc/IRCConnection.java b/src/org/yaaic/irc/IRCConnection.java index d2e73c5..503a991 100644 --- a/src/org/yaaic/irc/IRCConnection.java +++ b/src/org/yaaic/irc/IRCConnection.java @@ -151,7 +151,10 @@ public class IRCConnection extends PircBot if (sender.equals(getNick())) { // We joined a new channel server.addChannel(new Channel(target)); - service.sendBroadcast(new Intent(Broadcast.CHANNEL_NEW)); + + Intent intent = new Intent(Broadcast.CHANNEL_NEW); + intent.putExtra(Broadcast.EXTRA_CHANNEL, target); + service.sendBroadcast(intent); } else { server.getChannel(target).addMessage(sender + " joined"); @@ -172,7 +175,10 @@ public class IRCConnection extends PircBot if (recipientNick.equals(getNick())) { // We are kicked server.removeChannel(target); - service.sendBroadcast(new Intent(Broadcast.CHANNEL_REMOVE)); + + Intent intent = new Intent(Broadcast.CHANNEL_REMOVE); + intent.putExtra(Broadcast.EXTRA_CHANNEL, target); + service.sendBroadcast(intent); } else { server.getChannel(target).addMessage(kickerNick + " kicked " + recipientNick); @@ -256,7 +262,10 @@ public class IRCConnection extends PircBot if (sender.equals(getNick())) { // We pareted a channel server.removeChannel(target); - service.sendBroadcast(new Intent(Broadcast.CHANNEL_REMOVE)); + + Intent intent = new Intent(Broadcast.CHANNEL_REMOVE); + intent.putExtra(Broadcast.EXTRA_CHANNEL, target); + service.sendBroadcast(intent); } else { server.getChannel(target).addMessage(sender + " parted"); diff --git a/src/org/yaaic/listener/ChannelListener.java b/src/org/yaaic/listener/ChannelListener.java index 28db601..387bfb3 100644 --- a/src/org/yaaic/listener/ChannelListener.java +++ b/src/org/yaaic/listener/ChannelListener.java @@ -23,6 +23,6 @@ package org.yaaic.listener; public interface ChannelListener { public void onChannelMessage(String target); - public void onNewChannel(); - public void onRemoveChannel(); + public void onNewChannel(String target); + public void onRemoveChannel(String target); } diff --git a/src/org/yaaic/receiver/ChannelReceiver.java b/src/org/yaaic/receiver/ChannelReceiver.java index ae42021..ce3c943 100644 --- a/src/org/yaaic/receiver/ChannelReceiver.java +++ b/src/org/yaaic/receiver/ChannelReceiver.java @@ -43,6 +43,11 @@ public class ChannelReceiver extends BroadcastReceiver if (action.equals(Broadcast.CHANNEL_MESSAGE)) { listener.onChannelMessage(intent.getExtras().getString(Broadcast.EXTRA_CHANNEL)); + } else if (action.equals(Broadcast.CHANNEL_NEW)) { + listener.onNewChannel(intent.getExtras().getString(Broadcast.EXTRA_CHANNEL)); + } else if (action.equals(Broadcast.CHANNEL_REMOVE)) { + intent.getExtras().getString(Broadcast.EXTRA_CHANNEL); } + } } diff --git a/src/org/yaaic/view/ServerActivity.java b/src/org/yaaic/view/ServerActivity.java index 5679c37..cfd15e9 100644 --- a/src/org/yaaic/view/ServerActivity.java +++ b/src/org/yaaic/view/ServerActivity.java @@ -27,10 +27,8 @@ import org.yaaic.irc.IRCService; import org.yaaic.listener.ChannelListener; import org.yaaic.listener.FlingListener; import org.yaaic.model.Broadcast; -import org.yaaic.model.Channel; import org.yaaic.model.Server; import org.yaaic.receiver.ChannelReceiver; -import org.yaaic.receiver.ServerReceiver; import android.app.Activity; import android.app.Dialog; @@ -196,14 +194,16 @@ public class ServerActivity extends Activity implements ServiceConnection, Chann /** * On new channel */ - public void onNewChannel() + public void onNewChannel(String target) { + } /** * On channel remove */ - public void onRemoveChannel() + public void onRemoveChannel(String target) { + } }