@ -659,6 +659,45 @@ public void rejectInvitation(
multiUserChatAdHocOpSet . rejectInvitation ( invitation , reason ) ;
}
/ * *
* 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
* @param subject the subject which will be set to the room after the user
* join successful .
* /
public void joinChatRoom ( ChatRoomWrapper chatRoomWrapper ,
String nickName ,
byte [ ] password ,
boolean rememberPassword ,
boolean isFirstAttempt ,
String subject )
{
ChatRoom chatRoom = chatRoomWrapper . getChatRoom ( ) ;
if ( chatRoom = = null )
{
new ErrorDialog (
GuiActivator . getUIService ( ) . getMainFrame ( ) ,
GuiActivator . getResources ( ) . getI18NString ( "service.gui.WARNING" ) ,
GuiActivator . getResources ( ) . getI18NString (
"service.gui.CHAT_ROOM_NOT_CONNECTED" ,
new String [ ] { chatRoomWrapper . getChatRoomName ( ) } ) )
. showDialog ( ) ;
return ;
}
new JoinChatRoomTask ( chatRoomWrapper , nickName , password ,
rememberPassword , isFirstAttempt , subject ) . execute ( ) ;
}
/ * *
* Joins the given chat room with the given password and manages all the
* exceptions that could occur during the join process .
@ -693,6 +732,23 @@ public void joinChatRoom( ChatRoomWrapper chatRoomWrapper,
byte [ ] password ,
boolean rememberPassword ,
boolean isFirstAttempt )
{
this . joinChatRoom (
chatRoomWrapper , nickName , password , rememberPassword ,
isFirstAttempt , null ) ;
}
/ * *
* 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 .
* /
public void joinChatRoom ( ChatRoomWrapper chatRoomWrapper ,
String nickName ,
byte [ ] password )
{
ChatRoom chatRoom = chatRoomWrapper . getChatRoom ( ) ;
@ -709,8 +765,7 @@ public void joinChatRoom( ChatRoomWrapper chatRoomWrapper,
return ;
}
new JoinChatRoomTask ( chatRoomWrapper , nickName , password ,
rememberPassword , isFirstAttempt ) . execute ( ) ;
new JoinChatRoomTask ( chatRoomWrapper , nickName , password ) . execute ( ) ;
}
/ * *
@ -720,10 +775,13 @@ public void joinChatRoom( ChatRoomWrapper chatRoomWrapper,
* @param chatRoomWrapper the chat room to join .
* @param nickName the nickname we choose for the given chat room .
* @param password the password .
* @param subject the subject which will be set to the room after the user
* join successful .
* /
public void joinChatRoom ( ChatRoomWrapper chatRoomWrapper ,
String nickName ,
byte [ ] password )
byte [ ] password ,
String subject )
{
ChatRoom chatRoom = chatRoomWrapper . getChatRoom ( ) ;
@ -740,7 +798,8 @@ public void joinChatRoom( ChatRoomWrapper chatRoomWrapper,
return ;
}
new JoinChatRoomTask ( chatRoomWrapper , nickName , password ) . execute ( ) ;
new JoinChatRoomTask ( chatRoomWrapper , nickName , password , subject )
. execute ( ) ;
}
/ * *
@ -1607,16 +1666,20 @@ private static class JoinChatRoomTask
private final boolean rememberPassword ;
private final boolean isFirstAttempt ;
private final String subject ;
JoinChatRoomTask ( ChatRoomWrapper chatRoomWrapper ,
String nickName ,
byte [ ] password ,
boolean rememberPassword ,
boolean isFirstAttempt )
boolean isFirstAttempt ,
String subject )
{
this . chatRoomWrapper = chatRoomWrapper ;
this . nickName = nickName ;
this . isFirstAttempt = isFirstAttempt ;
this . subject = subject ;
if ( password = = null )
{
@ -1641,7 +1704,15 @@ private static class JoinChatRoomTask
String nickName ,
byte [ ] password )
{
this ( chatRoomWrapper , nickName , password , false , true ) ;
this ( chatRoomWrapper , nickName , password , false , true , null ) ;
}
JoinChatRoomTask ( ChatRoomWrapper chatRoomWrapper ,
String nickName ,
byte [ ] password ,
String subject )
{
this ( chatRoomWrapper , nickName , password , false , true , subject ) ;
}
/ * *
@ -1752,7 +1823,8 @@ protected void done()
nickName ,
new String ( authWindow . getPassword ( ) ) . getBytes ( ) ,
authWindow . isRememberPassword ( ) ,
false ) ;
false ,
subject ) ;
}
}
else if ( REGISTRATION_REQUIRED . equals ( returnCode ) )
@ -1794,9 +1866,24 @@ else if(SUBSCRIPTION_ALREADY_EXISTS.equals(returnCode))
"service.gui.ERROR" ) , errorMessage ) . showDialog ( ) ;
}
if ( SUCCESS . equals ( returnCode ) & & rememberPassword )
if ( SUCCESS . equals ( returnCode ) )
{
chatRoomWrapper . savePassword ( new String ( password ) ) ;
if ( rememberPassword )
{
chatRoomWrapper . savePassword ( new String ( password ) ) ;
}
if ( subject ! = null )
{
try
{
chatRoomWrapper . getChatRoom ( ) . setSubject ( subject ) ;
}
catch ( OperationFailedException ex )
{
logger . warn ( "Failed to set subject." ) ;
}
}
}
}
}