From 6a263286e0516dbbf7eade6c2f835d3bd018e6f5 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 25 Mar 2014 17:25:17 +0200 Subject: [PATCH] Prints friendly message when user has its voice revoked and tries to send a message. --- resources/languages/resources.properties | 1 + .../gui/main/chat/conference/ConferenceChatManager.java | 6 ++++++ .../OperationSetBasicInstantMessagingJabberImpl.java | 7 +++++++ .../protocol/event/ChatRoomMessageDeliveryFailedEvent.java | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index 0357f9c57..c255cfbe5 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -119,6 +119,7 @@ service.gui.CHAT_ROOM_USER_JOINED=has joined {0} service.gui.CHAT_ROOM_USER_LEFT=has left {0} service.gui.CHAT_ROOM_USER_KICKED=has been kicked from {0} service.gui.CHAT_ROOM_USER_QUIT=has quit {0} +service.gui.CHAT_ROOM_SEND_MSG_FORBIDDEN=Message sending is forbidden (voice revoked) service.gui.CHAT_ROOM_SAVE_BUTTON_TOOLTIP=Saves the chat room for future use service.gui.CHAT_ROOM_REMOVE_BUTTON_TOOLTIP=Removes the selected room from the list of saved rooms service.gui.CHAT_ROOM_NAME=Chat room name diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java index b4d9a45c5..a7643eb22 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java @@ -362,6 +362,12 @@ else if (evt.getErrorCode() errorMsg = GuiActivator.getResources().getI18NString( "service.gui.MSG_DELIVERY_INTERNAL_ERROR"); } + else if (evt.getErrorCode() + == ChatRoomMessageDeliveryFailedEvent.FORBIDDEN) + { + errorMsg = GuiActivator.getResources().getI18NString( + "service.gui.CHAT_ROOM_SEND_MSG_FORBIDDEN"); + } else { errorMsg = GuiActivator.getResources().getI18NString( diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java index 02ac494f2..a72713321 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java @@ -936,6 +936,13 @@ public void processPacket(Packet packet) XMPPError error = packet.getError(); int errorResultCode = ChatRoomMessageDeliveryFailedEvent.UNKNOWN_ERROR; + + if(error != null && error.getCode() == 403) + { + errorResultCode + = ChatRoomMessageDeliveryFailedEvent.FORBIDDEN; + } + String errorReason = error.getMessage(); ChatRoomMessageDeliveryFailedEvent evt = diff --git a/src/net/java/sip/communicator/service/protocol/event/ChatRoomMessageDeliveryFailedEvent.java b/src/net/java/sip/communicator/service/protocol/event/ChatRoomMessageDeliveryFailedEvent.java index 1b6da1a94..2ac7fcf92 100644 --- a/src/net/java/sip/communicator/service/protocol/event/ChatRoomMessageDeliveryFailedEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/ChatRoomMessageDeliveryFailedEvent.java @@ -59,6 +59,12 @@ public class ChatRoomMessageDeliveryFailedEvent */ public static final int OFFLINE_MESSAGES_NOT_SUPPORTED = 5; + /** + * Set when delivery fails because we're trying to send a message to a + * a room where we are not allowed to send messages. + */ + public static final int FORBIDDEN = 6; + /** * An error code indicating the reason for the failure of this delivery. */