diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-10-18 20:17:16 +0200 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-10-28 22:33:33 +0100 |
commit | dd1b9598cd3617c0d2f0ec78bcd28ae2c54d9629 (patch) | |
tree | 96c71bc4e08e50e0164f4f3fb3bee76b59970506 /src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java | |
parent | 340dc5730a12a0fff08ece4afb8d1fbb04440f63 (diff) | |
download | jitsi-dd1b9598cd3617c0d2f0ec78bcd28ae2c54d9629.zip jitsi-dd1b9598cd3617c0d2f0ec78bcd28ae2c54d9629.tar.gz jitsi-dd1b9598cd3617c0d2f0ec78bcd28ae2c54d9629.tar.bz2 |
Added support for ISUPPORT CHANNELLEN server parameter.
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java b/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java index 00c2ec3..b22bc28 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java @@ -28,8 +28,6 @@ import com.ircclouds.irc.api.state.*; * * TODO Do we need to cancel any join channel operations still in progress? * - * TODO Check ISUPPORT 'CHANNELLEN' for maximum channel name length. - * * TODO Check ISUPPORT 'CHANLIMIT' for maximum number of joined channels. * * @author Danny van Heumen @@ -72,6 +70,13 @@ public class ChannelManager .synchronizedMap(new HashMap<String, ChatRoomIrcImpl>()); /** + * Maximum channel name length according to server ISUPPORT instructions. + * + * <p>This value is not guaranteed, so it may be <tt>null</tt>.</p> + */ + private final Integer isupportChannelLen; + + /** * Constructor. * @param irc thread-safe IRCApi instance * @param connectionState the connection state @@ -97,6 +102,30 @@ public class ChannelManager } this.provider = provider; this.irc.addListener(new ManagerListener()); + this.isupportChannelLen = parseISupportChannelLen(this.connectionState); + } + + /** + * Parse the ISUPPORT parameter for server's max channel name length. + * + * @param state the connection state + * @return returns instance with max channel name length or <tt>null</tt> if + * not specified. + */ + private Integer parseISupportChannelLen(final IIRCState state) + { + final String value = + state.getServerOptions().getKey(ISupport.CHANNELLEN.name()); + if (value == null) + { + return null; + } + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Setting ISUPPORT parameter " + + ISupport.CHANNELLEN.name() + " to " + value); + } + return new Integer(value); } /** @@ -168,6 +197,13 @@ public class ChannelManager // is required. return; } + if (this.isupportChannelLen != null + && chatRoomId.length() > this.isupportChannelLen.intValue()) + { + throw new IllegalArgumentException("the channel name must not be " + + "longer than " + this.isupportChannelLen.intValue() + + " characters according to server parameters."); + } LOGGER.trace("Start joining channel " + chatRoomId); final Result<Object, Exception> joinSignal = |