From cd0c18d40b90024e3e450d9d8171bb98b82f5672 Mon Sep 17 00:00:00 2001 From: Danny van Heumen Date: Tue, 29 Jul 2014 22:36:10 +0200 Subject: [PATCH] Basic failed delivery response for ERR_NOSUCHNICK server reply. --- .../impl/protocol/irc/IrcStack.java | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java index d585adbb9..068f69595 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java @@ -1130,6 +1130,12 @@ public void onServerNumericMessage(final ServerNumericMessage msg) switch (code.intValue()) { case IRCServerNumerics.CHANNEL_NICKS_END_OF_LIST: + // CHANNEL_NICKS_END_OF_LIST indicates the end of a nick list as + // you will receive when joining a channel. This is used as the + // indicator that we have joined a channel. Now we have to + // determine whether or not we already know about this + // particular join attempt. If not, we continue to inform Jitsi + // and to create a listener for this new chat room. String text = msg.getText(); String channelName = text.substring(0, text.indexOf(' ')); final ChatRoomIrcImpl chatRoom; @@ -1178,15 +1184,45 @@ public void onServerNumericMessage(final ServerNumericMessage msg) LOGGER.trace("Unannounced join of chat room '" + channelName + "' completed."); break; + case IRCServerNumerics.NO_SUCH_NICK_CHANNEL: // TODO Check if target is Contact, then update contact presence // status to off-line since the nick apparently does not exist // anymore. - // - // ":hobana.freenode.net 401 dvheumen dvheumen_ :No such - // nick/channel" - LOGGER.warn("Message did not get delivered: " + msg.asRaw()); + if (LOGGER.isTraceEnabled()) + { + LOGGER.trace("Message did not get delivered: " + + msg.asRaw()); + } + final String msgText = msg.getText(); + final int endOfTargetIndex = msgText.indexOf(' '); + if (endOfTargetIndex == -1) + { + LOGGER.trace("Expected source nick name in error message, " + + "but it cannot be found. Stop parsing."); + break; + } + final String targetNick = + msgText.substring(0, endOfTargetIndex); + final String msgTextError = + msgText.substring(endOfTargetIndex + 2); + MessageIrcImpl message = + new MessageIrcImpl( + "", + OperationSetBasicInstantMessaging.HTML_MIME_TYPE, + OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING, + null); + final Contact to = + IrcStack.this.provider.getPersistentPresence() + .findOrCreateContactByID(targetNick); + IrcStack.this.provider + .getBasicInstantMessaging() + .fireMessageDeliveryFailed( + message, + to, + MessageDeliveryFailedEvent.OFFLINE_MESSAGES_NOT_SUPPORTED); break; + default: if (LOGGER.isTraceEnabled()) {