diff --git a/src/org/yaaic/irc/IRCConnection.java b/src/org/yaaic/irc/IRCConnection.java index 301fb37..f9491cb 100644 --- a/src/org/yaaic/irc/IRCConnection.java +++ b/src/org/yaaic/irc/IRCConnection.java @@ -21,8 +21,10 @@ along with Yaaic. If not, see . package org.yaaic.irc; import android.content.Intent; +import android.util.Log; import org.jibble.pircbot.PircBot; +import org.jibble.pircbot.User; import org.yaaic.Yaaic; import org.yaaic.model.Broadcast; @@ -34,6 +36,16 @@ public class IRCConnection extends PircBot private IRCService service; private Server server; + // XXX: Print all IRC events to the debug console + private static final boolean DEBUG_EVENTS = true; + public static final String TAG = "Yaaic/IRCConnection"; + + /** + * Create a new connection + * + * @param service + * @param serverId + */ public IRCConnection(IRCService service, int serverId) { this.server = Yaaic.getInstance().getServerById(serverId); @@ -56,6 +68,168 @@ public class IRCConnection extends PircBot service.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); } + /** + * On channel action + */ + @Override + protected void onAction(String sender, String login, String hostname, String target, String action) + { + debug("Action", target + " " + sender + " " + action); + } + + /** + * On Channel Info + */ + @Override + protected void onChannelInfo(String channel, int userCount, String topic) + { + debug("ChannelInfo", channel + " " + userCount); + } + + /** + * On Deop + */ + @Override + protected void onDeop(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) + { + debug("Deop", channel + " " + recipient + "(" + sourceNick + ")"); + } + + /** + * On DeVoice + */ + @Override + protected void onDeVoice(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) + { + debug("DeVoice", channel + " " + recipient + "(" + sourceNick + ")"); + } + + /** + * On Invite + */ + @Override + protected void onInvite(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String channel) + { + debug("Invite", channel + " " + targetNick + "(" + sourceNick + ")"); + } + + /** + * On Join + */ + @Override + protected void onJoin(String channel, String sender, String login, String hostname) + { + debug("Join", channel + " " + sender); + } + + /** + * On Kick + */ + @Override + protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) + { + debug("Kick", channel + " " + recipientNick + "(" + kickerNick + ")"); + } + + /** + * On Message + */ + @Override + protected void onMessage(String channel, String sender, String login, String hostname, String message) + { + debug("Deop", channel + " " + sender + " " + message); + } + + /** + * On Mode + */ + @Override + protected void onMode(String channel, String sourceNick, String sourceLogin, String sourceHostname, String mode) + { + debug("Mode", channel + " " + sourceNick + " " + mode); + } + + /** + * On Nick Change + */ + @Override + protected void onNickChange(String oldNick, String login, String hostname, String newNick) + { + debug("Nick", oldNick + " " + newNick); + } + + /** + * On Notice + */ + @Override + protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) + { + debug("Notice", sourceNick + " " + notice); + } + + /** + * On Op + */ + @Override + protected void onOp(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) + { + debug("Deop", channel + " " + recipient + "(" + sourceNick + ")"); + } + + /** + * On Part + */ + @Override + protected void onPart(String channel, String sender, String login, String hostname) + { + debug("Part", channel + " " + sender); + } + + /** + * On Private Message + */ + @Override + protected void onPrivateMessage(String sender, String login, String hostname, String message) + { + debug("PrivateMessage", sender + " " + message); + } + + /** + * On Quit + */ + @Override + protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) + { + debug("Quit", sourceNick); + } + + /** + * On Topic + */ + @Override + protected void onTopic(String channel, String topic, String setBy, long date, boolean changed) + { + debug("Topic", channel + " " + setBy + " " + topic); + } + + /** + * On User List + */ + @Override + protected void onUserList(String channel, User[] users) + { + debug("UserList", channel + " (" + users.length + ")"); + } + + /** + * On Voice + */ + @Override + protected void onVoice(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) + { + debug("Voice", channel + " " + recipient + "(" + sourceNick + ")"); + } + /** * On disconnect */ @@ -63,10 +237,19 @@ public class IRCConnection extends PircBot public void onDisconnect() { server.setStatus(Status.DISCONNECTED); - service.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); } + /** + * Print an event to the debug console + */ + private void debug(String event, String params) + { + if (DEBUG_EVENTS) { + Log.d(TAG, "[" + event + "]: " + params); + } + } + /** * Quits from the IRC server with default reason. */