Implementation for channel mode 'l'.

Implementation for channel mode change 'l' (channel user limit).
Additionally, there exists a bug in the irc-api library that cuts off
the first character of the source IRC user. This has also been fixed,
and a patch has been included in the NOTICES file.
fix-message-formatting
Danny van Heumen 12 years ago
parent 975cb84123
commit 459996819e

@ -1,7 +1,10 @@
The IRC-API library is currently a snapshot version from VCS on https://code.google.com/p/irc-api.
Additionally, one modification has been made to prevent joining large IRC channels to result in an occasional threading issue when adding users. The diff for the modification:
Additionally:
1. one modification has been made to prevent joining large IRC channels to result in an occasional threading issue when adding users. The diff for the modification:
2. a modification has been made to fix an incorrect cut off of the first character of user names in channel mode change instances.
1.
diff --git a/src/main/java/com/ircclouds/irc/api/domain/IRCChannel.java b/src/main/java/com/ircclouds/irc/api/domain/IRCChannel.java
index a97f2ce..8744eb8 100644
--- a/src/main/java/com/ircclouds/irc/api/domain/IRCChannel.java
@ -15,3 +18,24 @@ index a97f2ce..8744eb8 100644
private List<ChannelMode> chanModes = new ArrayList<ChannelMode>();
public IRCChannel()
2.
commit 4f025450b77ba0bd058b5c852652e76f529e9ff0
Author: Danny van Heumen <danny@dannyvanheumen.nl>
Date: Sat Jan 4 19:33:14 2014 +0100
Fix invalid cut off of first char of user nick.
diff --git a/src/main/java/com/ircclouds/irc/api/om/AbstractChanModeBuilder.java b/src/main/java/com/ircclouds/irc/api/om/AbstractChanModeBuilder.java
index b634e73..c19980f 100644
--- a/src/main/java/com/ircclouds/irc/api/om/AbstractChanModeBuilder.java
+++ b/src/main/java/com/ircclouds/irc/api/om/AbstractChanModeBuilder.java
@@ -63,7 +63,7 @@ public abstract class AbstractChanModeBuilder implements IBuilder<ChannelModeMes
}
}
- return new ChannelModeMessage(ParseUtils.getSource(_cmpnts[0].substring(1)), _cmpnts[2], getModeStr(_cmpnts), _addedModes, _removedModes);
+ return new ChannelModeMessage(ParseUtils.getSource(_cmpnts[0]), _cmpnts[2], getModeStr(_cmpnts), _addedModes, _removedModes);
}
protected abstract IRCServerOptions getIRCServerOptions();

@ -805,6 +805,10 @@ public void onChannelMessage(ChannelPrivMsg msg)
private void processModeMessage(ChannelModeMessage msg)
{
String sourceNick = ((IRCUser) msg.getSource()).getNick();
ChatRoomMemberIrcImpl sourceMember =
(ChatRoomMemberIrcImpl) this.chatroom
.getChatRoomMember(sourceNick);
ModeParser parser = new ModeParser(msg);
for (ModeEntry mode : parser.getModes())
{
@ -885,6 +889,33 @@ private void processModeMessage(ChannelModeMessage msg)
}
}
break;
case LIMIT:
MessageIrcImpl message;
if (mode.isAdded())
{
try
{
message =
new MessageIrcImpl("channel limit set to "
+ Integer.parseInt(mode.getParams()[0]),
"text/plain", "UTF-8", null);
}
catch (NumberFormatException e)
{
e.printStackTrace();
break;
}
}
else
{
message =
new MessageIrcImpl("channel limit removed",
"text/plain", "UTF-8", null);
}
this.chatroom.fireMessageReceivedEvent(message,
sourceMember, new Date(),
ChatRoomMessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
break;
default:
System.out.println("Unsupported mode '"
+ (mode.isAdded() ? "+" : "-") + mode.getMode()

@ -2,12 +2,24 @@
import net.java.sip.communicator.service.protocol.ChatRoomMemberRole;
/**
* IRC Modes enum
*
* @author danny
*/
public enum Mode
{
OWNER('O', ChatRoomMemberRole.OWNER),
OPERATOR('o', ChatRoomMemberRole.ADMINISTRATOR),
VOICE('v', ChatRoomMemberRole.MEMBER);
VOICE('v', ChatRoomMemberRole.MEMBER),
LIMIT('l', null);
/**
* Find Mode instance by mode char.
*
* @param symbol mode char
* @return returns instance
*/
public static Mode bySymbol(char symbol)
{
for (Mode mode : Mode.values())
@ -17,23 +29,48 @@ public static Mode bySymbol(char symbol)
return mode;
}
}
throw new IllegalArgumentException("Unknown mode symbol provided. ('"+symbol+"')");
throw new IllegalArgumentException("Unknown mode symbol provided. ('"
+ symbol + "')");
}
/**
* mode char
*/
final private char symbol;
/**
* ChatRoomMemberRole or null
*/
final private ChatRoomMemberRole role;
/**
* Create Mode instance.
*
* @param symbol mode char
* @param role ChatRoomMemberRole or null
*/
private Mode(char symbol, ChatRoomMemberRole role)
{
this.symbol = symbol;
this.role = role;
}
/**
* Get character symbol for mode.
*
* @return returns char symbol
*/
public char getSymbol()
{
return this.symbol;
}
/**
* Get corresponding ChatRoomMemberRole instance if available or null
* otherwise.
*
* @return returns ChatRoomMemberRole instance or null
*/
public ChatRoomMemberRole getRole()
{
return this.role;

@ -63,6 +63,9 @@ private ModeEntry process(boolean add, char mode)
return new ModeEntry(add, Mode.bySymbol(mode), this.params[this.index++]);
case 'v':
return new ModeEntry(add, Mode.bySymbol(mode), this.params[this.index++]);
case 'l':
String[] params = (add ? new String[] { this.params[this.index++] } : new String[]{});
return new ModeEntry(add, Mode.bySymbol(mode), params);
default:
throw new IllegalArgumentException(""+mode);
}

Loading…
Cancel
Save