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. 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 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 index a97f2ce..8744eb8 100644
--- a/src/main/java/com/ircclouds/irc/api/domain/IRCChannel.java --- 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>(); private List<ChannelMode> chanModes = new ArrayList<ChannelMode>();
public IRCChannel() 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) private void processModeMessage(ChannelModeMessage msg)
{ {
String sourceNick = ((IRCUser) msg.getSource()).getNick();
ChatRoomMemberIrcImpl sourceMember =
(ChatRoomMemberIrcImpl) this.chatroom
.getChatRoomMember(sourceNick);
ModeParser parser = new ModeParser(msg); ModeParser parser = new ModeParser(msg);
for (ModeEntry mode : parser.getModes()) for (ModeEntry mode : parser.getModes())
{ {
@ -885,6 +889,33 @@ private void processModeMessage(ChannelModeMessage msg)
} }
} }
break; 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: default:
System.out.println("Unsupported mode '" System.out.println("Unsupported mode '"
+ (mode.isAdded() ? "+" : "-") + mode.getMode() + (mode.isAdded() ? "+" : "-") + mode.getMode()

@ -2,38 +2,75 @@
import net.java.sip.communicator.service.protocol.ChatRoomMemberRole; import net.java.sip.communicator.service.protocol.ChatRoomMemberRole;
/**
* IRC Modes enum
*
* @author danny
*/
public enum Mode public enum Mode
{ {
OWNER('O', ChatRoomMemberRole.OWNER), OWNER('O', ChatRoomMemberRole.OWNER),
OPERATOR('o', ChatRoomMemberRole.ADMINISTRATOR), 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) public static Mode bySymbol(char symbol)
{ {
for(Mode mode : Mode.values()) for (Mode mode : Mode.values())
{ {
if (mode.getSymbol() == symbol) if (mode.getSymbol() == symbol)
{ {
return mode; return mode;
} }
} }
throw new IllegalArgumentException("Unknown mode symbol provided. ('"+symbol+"')"); throw new IllegalArgumentException("Unknown mode symbol provided. ('"
+ symbol + "')");
} }
/**
* mode char
*/
final private char symbol; final private char symbol;
/**
* ChatRoomMemberRole or null
*/
final private ChatRoomMemberRole role; final private ChatRoomMemberRole role;
/**
* Create Mode instance.
*
* @param symbol mode char
* @param role ChatRoomMemberRole or null
*/
private Mode(char symbol, ChatRoomMemberRole role) private Mode(char symbol, ChatRoomMemberRole role)
{ {
this.symbol = symbol; this.symbol = symbol;
this.role = role; this.role = role;
} }
/**
* Get character symbol for mode.
*
* @return returns char symbol
*/
public char getSymbol() public char getSymbol()
{ {
return this.symbol; return this.symbol;
} }
/**
* Get corresponding ChatRoomMemberRole instance if available or null
* otherwise.
*
* @return returns ChatRoomMemberRole instance or null
*/
public ChatRoomMemberRole getRole() public ChatRoomMemberRole getRole()
{ {
return this.role; 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++]); return new ModeEntry(add, Mode.bySymbol(mode), this.params[this.index++]);
case 'v': case 'v':
return new ModeEntry(add, Mode.bySymbol(mode), this.params[this.index++]); 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: default:
throw new IllegalArgumentException(""+mode); throw new IllegalArgumentException(""+mode);
} }

Loading…
Cancel
Save