diff --git a/src/org/yaaic/irc/IRCConnection.java b/src/org/yaaic/irc/IRCConnection.java
index f9491cb..cb7267f 100644
--- a/src/org/yaaic/irc/IRCConnection.java
+++ b/src/org/yaaic/irc/IRCConnection.java
@@ -28,6 +28,7 @@ import org.jibble.pircbot.User;
import org.yaaic.Yaaic;
import org.yaaic.model.Broadcast;
+import org.yaaic.model.Channel;
import org.yaaic.model.Server;
import org.yaaic.model.Status;
@@ -63,6 +64,8 @@ public class IRCConnection extends PircBot
@Override
public void onConnect()
{
+ debug("Connect", "");
+
server.setStatus(Status.CONNECTED);
service.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
@@ -75,6 +78,9 @@ public class IRCConnection extends PircBot
protected void onAction(String sender, String login, String hostname, String target, String action)
{
debug("Action", target + " " + sender + " " + action);
+
+ server.getChannel(target).addMessage("* " + sender + " " + action);
+ service.sendBroadcast(new Intent(Broadcast.CHANNEL_MESSAGE));
}
/**
@@ -120,6 +126,11 @@ public class IRCConnection extends PircBot
protected void onJoin(String channel, String sender, String login, String hostname)
{
debug("Join", channel + " " + sender);
+
+ if (sender.equals(getNick())) {
+ // We joined a new channel
+ server.addChannel(new Channel(channel));
+ }
}
/**
@@ -137,7 +148,7 @@ public class IRCConnection extends PircBot
@Override
protected void onMessage(String channel, String sender, String login, String hostname, String message)
{
- debug("Deop", channel + " " + sender + " " + message);
+ debug("Message", channel + " " + sender + " " + message);
}
/**
@@ -173,7 +184,7 @@ public class IRCConnection extends PircBot
@Override
protected void onOp(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
{
- debug("Deop", channel + " " + recipient + "(" + sourceNick + ")");
+ debug("Op", channel + " " + recipient + "(" + sourceNick + ")");
}
/**
@@ -246,7 +257,7 @@ public class IRCConnection extends PircBot
private void debug(String event, String params)
{
if (DEBUG_EVENTS) {
- Log.d(TAG, "[" + event + "]: " + params);
+ Log.d(TAG, "(" + server.getTitle() + ") [" + event + "]: " + params);
}
}
diff --git a/src/org/yaaic/model/Broadcast.java b/src/org/yaaic/model/Broadcast.java
index 8fbadae..6c284c5 100644
--- a/src/org/yaaic/model/Broadcast.java
+++ b/src/org/yaaic/model/Broadcast.java
@@ -24,6 +24,8 @@ public class Broadcast
{
public static final String SERVER_UPDATE = "org.yaaic.server.status";
+ public static final String CHANNEL_MESSAGE = "org.yaaic.channel.message";
+ /*
public static final String CHANNEL_ACTION = "org.yaaic.channel.action";
public static final String CHANNEL_INFO = "org.yaaic.channel.info";
public static final String CHANNEL_DEOP = "org.yaaic.channel.deop";
@@ -43,4 +45,12 @@ public class Broadcast
public static final String USER_NOTICE = "org.yaaic.user.notice";
public static final String USER_MESSAGE = "org.yaaic.user.message";
public static final String USER_QUIT = "org.yaaic.user.quit";
+
+ public static final String EXTRA_SENDER = "sender";
+ public static final String EXTRA_CHANNEL = "channel";
+ public static final String EXTRA_MESSAGE = "message";
+ public static final String EXTRA_TOPIC = "topic";
+ public static final String EXTRA_USERCOUNT = "usercount";
+ public static final String EXTRA_RECEIVER = "receiver";
+ */
}
diff --git a/src/org/yaaic/model/Server.java b/src/org/yaaic/model/Server.java
index 1e1febc..416b29b 100644
--- a/src/org/yaaic/model/Server.java
+++ b/src/org/yaaic/model/Server.java
@@ -21,6 +21,8 @@ along with Yaaic. If not, see .
package org.yaaic.model;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import org.yaaic.R;
@@ -36,7 +38,7 @@ public class Server
private String host;
private int port;
- private ArrayList channels = new ArrayList();
+ private HashMap channels = new HashMap();
private int status = Status.DISCONNECTED;
@@ -165,9 +167,17 @@ public class Server
*
* @return
*/
- public ArrayList getChannels()
+ public Collection getChannels()
{
- return channels;
+ return channels.values();
+ }
+
+ /**
+ * Get channel by name
+ */
+ public Channel getChannel(String name)
+ {
+ return channels.get(name);
}
/**
@@ -177,7 +187,7 @@ public class Server
*/
public void addChannel(Channel channel)
{
- channels.add(channel);
+ channels.put(channel.getName(), channel);
}
/**