From 72b505bf397cddac5920b6f69ef093f5622e7fe3 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Mon, 26 Aug 2013 12:54:07 +0300 Subject: [PATCH] Shows error message when providing password for chatroom fails. --- .../conference/ConferenceChatManager.java | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) 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 8440a0133..80088b12f 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 @@ -663,6 +663,27 @@ public void joinChatRoom( ChatRoomWrapper chatRoomWrapper, String nickName, byte[] password, boolean rememberPassword) + { + this.joinChatRoom( + chatRoomWrapper, nickName, password, rememberPassword, true); + } + + /** + * Joins the given chat room with the given password and manages all the + * exceptions that could occur during the join process. + * + * @param chatRoomWrapper the chat room to join. + * @param nickName the nickname we choose for the given chat room. + * @param password the password. + * @param rememberPassword if true the password should be saved. + * @param isFirstAttempt is this the first attempt to join room, used + * to check whether to show some error messages + */ + public void joinChatRoom( ChatRoomWrapper chatRoomWrapper, + String nickName, + byte[] password, + boolean rememberPassword, + boolean isFirstAttempt) { ChatRoom chatRoom = chatRoomWrapper.getChatRoom(); @@ -680,7 +701,7 @@ public void joinChatRoom( ChatRoomWrapper chatRoomWrapper, } new JoinChatRoomTask(chatRoomWrapper, nickName, password, - rememberPassword).execute(); + rememberPassword, isFirstAttempt).execute(); } /** @@ -1522,14 +1543,18 @@ private static class JoinChatRoomTask private final boolean rememberPassword; + private final boolean isFirstAttempt; + JoinChatRoomTask( ChatRoomWrapper chatRoomWrapper, String nickName, byte[] password, - boolean rememberPassword) + boolean rememberPassword, + boolean isFirstAttempt) { this.chatRoomWrapper = chatRoomWrapper; this.nickName = nickName; - + this.isFirstAttempt = isFirstAttempt; + if(password == null) { String passString = chatRoomWrapper.loadPassword(); @@ -1553,8 +1578,7 @@ private static class JoinChatRoomTask String nickName, byte[] password) { - this(chatRoomWrapper, nickName, password, false); - + this(chatRoomWrapper, nickName, password, false, true); } /** @@ -1647,7 +1671,13 @@ protected void done() "service.gui.CHAT_ROOM_REQUIRES_PASSWORD", new String[]{ chatRoomWrapper.getChatRoomName()}), - "", null, null, null); + "", null, + isFirstAttempt ? + null : + GuiActivator.getResources().getI18NString( + "service.gui.AUTHENTICATION_FAILED", + new String[]{chatRoomWrapper.getChatRoomName()}), + null); authWindow.setVisible(true); @@ -1658,7 +1688,8 @@ protected void done() chatRoomWrapper, nickName, new String(authWindow.getPassword()).getBytes(), - authWindow.isRememberPassword()); + authWindow.isRememberPassword(), + false); } } else if(REGISTRATION_REQUIRED.equals(returnCode))