|
|
|
|
@ -527,8 +527,9 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
|
+ "of channel '" + chatroom.getIdentifier()
|
|
|
|
|
+ "'.");
|
|
|
|
|
}
|
|
|
|
|
String chatRoomId = chatroom.getIdentifier();
|
|
|
|
|
boolean isRequestedChatRoom = channel.getName()
|
|
|
|
|
.equalsIgnoreCase(chatroom.getIdentifier());
|
|
|
|
|
.equalsIgnoreCase(chatRoomId);
|
|
|
|
|
synchronized (joinSignal)
|
|
|
|
|
{
|
|
|
|
|
if (!isRequestedChatRoom)
|
|
|
|
|
@ -541,7 +542,7 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
|
.trace("Callback for successful join "
|
|
|
|
|
+ "finished prematurely since we "
|
|
|
|
|
+ "got forwarded from '"
|
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
|
+ chatRoomId
|
|
|
|
|
+ "' to '"
|
|
|
|
|
+ channel.getName()
|
|
|
|
|
+ "'. Joining of forwarded channel "
|
|
|
|
|
@ -549,8 +550,7 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
|
+ "since that channel was not "
|
|
|
|
|
+ "announced.");
|
|
|
|
|
}
|
|
|
|
|
IrcStack.this.joining.remove(chatroom
|
|
|
|
|
.getIdentifier());
|
|
|
|
|
IrcStack.this.joining.remove(chatRoomId);
|
|
|
|
|
IrcStack.this.provider
|
|
|
|
|
.getMUC()
|
|
|
|
|
.fireLocalUserPresenceEvent(
|
|
|
|
|
@ -570,10 +570,8 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IrcStack.this.joined.put(
|
|
|
|
|
chatroom.getIdentifier(), chatroom);
|
|
|
|
|
IrcStack.this.joining.remove(chatroom
|
|
|
|
|
.getIdentifier());
|
|
|
|
|
IrcStack.this.joined.put(chatRoomId, chatroom);
|
|
|
|
|
IrcStack.this.joining.remove(chatRoomId);
|
|
|
|
|
IrcStack.this.irc
|
|
|
|
|
.addListener(new ChatRoomListener(
|
|
|
|
|
chatroom));
|
|
|
|
|
@ -599,7 +597,7 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
|
LOGGER
|
|
|
|
|
.trace("Finished successful join "
|
|
|
|
|
+ "callback for channel '"
|
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
|
+ chatRoomId
|
|
|
|
|
+ "'. Waking up original thread.");
|
|
|
|
|
}
|
|
|
|
|
// Notify waiting threads of finished
|
|
|
|
|
@ -616,12 +614,12 @@ public void onFailure(Exception e)
|
|
|
|
|
LOGGER.trace("Started callback for failed attempt to "
|
|
|
|
|
+ "join channel '" + chatroom.getIdentifier()
|
|
|
|
|
+ "'.");
|
|
|
|
|
String chatRoomId = chatroom.getIdentifier();
|
|
|
|
|
synchronized (joinSignal)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IrcStack.this.joining.remove(chatroom
|
|
|
|
|
.getIdentifier());
|
|
|
|
|
IrcStack.this.joining.remove(chatRoomId);
|
|
|
|
|
IrcStack.this.provider
|
|
|
|
|
.getMUC()
|
|
|
|
|
.fireLocalUserPresenceEvent(
|
|
|
|
|
@ -637,7 +635,7 @@ public void onFailure(Exception e)
|
|
|
|
|
LOGGER
|
|
|
|
|
.trace("Finished callback for failed "
|
|
|
|
|
+ "attempt to join channel '"
|
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
|
+ chatRoomId
|
|
|
|
|
+ "'. Waking up original thread.");
|
|
|
|
|
}
|
|
|
|
|
// Notify waiting threads of finished
|
|
|
|
|
@ -806,15 +804,12 @@ private void prepareChatRoom(final ChatRoomIrcImpl chatRoom,
|
|
|
|
|
{
|
|
|
|
|
chatRoom.prepUserRole(role);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ChatRoomMemberIrcImpl member =
|
|
|
|
|
new ChatRoomMemberIrcImpl(this.provider, chatRoom,
|
|
|
|
|
user.getNick(), role);
|
|
|
|
|
chatRoom.addChatRoomMember(member.getContactAddress(), member);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert a member mode character to a ChatRoomMemberRole instance.
|
|
|
|
|
@ -1018,18 +1013,22 @@ private void deliverReceivedMessageToPrivateChat(
|
|
|
|
|
/**
|
|
|
|
|
* Create a private chat room if one does not exist yet.
|
|
|
|
|
*
|
|
|
|
|
* @param user private chat room for this user
|
|
|
|
|
* @param userName private chat room for this user
|
|
|
|
|
* @return returns the private chat room
|
|
|
|
|
*/
|
|
|
|
|
private ChatRoomIrcImpl initiatePrivateChatRoom(String user)
|
|
|
|
|
private ChatRoomIrcImpl initiatePrivateChatRoom(String userName)
|
|
|
|
|
{
|
|
|
|
|
OperationSetMultiUserChatIrcImpl muc =
|
|
|
|
|
IrcStack.this.provider.getMUC();
|
|
|
|
|
ChatRoomIrcImpl chatroom = muc.findOrCreateRoom(user);
|
|
|
|
|
ChatRoomIrcImpl chatroom = muc.findOrCreateRoom(userName);
|
|
|
|
|
IrcStack.this.joined.put(chatroom.getIdentifier(), chatroom);
|
|
|
|
|
ChatRoomMemberIrcImpl member =
|
|
|
|
|
final ChatRoomMemberIrcImpl user =
|
|
|
|
|
new ChatRoomMemberIrcImpl(IrcStack.this.provider, chatroom,
|
|
|
|
|
user, ChatRoomMemberRole.MEMBER);
|
|
|
|
|
IrcStack.this.getNick(), ChatRoomMemberRole.MEMBER);
|
|
|
|
|
chatroom.addChatRoomMember(user.getContactAddress(), user);
|
|
|
|
|
final ChatRoomMemberIrcImpl member =
|
|
|
|
|
new ChatRoomMemberIrcImpl(IrcStack.this.provider, chatroom,
|
|
|
|
|
userName, ChatRoomMemberRole.MEMBER);
|
|
|
|
|
chatroom.addChatRoomMember(member.getContactAddress(), member);
|
|
|
|
|
IrcStack.this.provider.getMUC().fireLocalUserPresenceEvent(
|
|
|
|
|
chatroom,
|
|
|
|
|
@ -1046,13 +1045,17 @@ private ChatRoomIrcImpl initiatePrivateChatRoom(String user)
|
|
|
|
|
* chat room listener updates chat room data and fires events based on IRC
|
|
|
|
|
* messages that report state changes for the specified channel.
|
|
|
|
|
*
|
|
|
|
|
* @author danny
|
|
|
|
|
* @author Danny van Heumen
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
private class ChatRoomListener
|
|
|
|
|
extends VariousMessageListenerAdapter
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* IRC error code for case where user is not joined to that channel.
|
|
|
|
|
*/
|
|
|
|
|
private static final int IRC_ERR_NOTONCHANNEL = 442;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Chat room for which this listener is working.
|
|
|
|
|
*/
|
|
|
|
|
@ -1104,12 +1107,6 @@ public void onChannelJoin(ChanJoinMessage msg)
|
|
|
|
|
if (!isThisChatRoom(msg.getChannelName()))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (isMe(msg.getSource()))
|
|
|
|
|
{
|
|
|
|
|
// I think that this should not happen.
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
String user = msg.getSource().getNick();
|
|
|
|
|
ChatRoomMemberIrcImpl member =
|
|
|
|
|
new ChatRoomMemberIrcImpl(IrcStack.this.provider,
|
|
|
|
|
@ -1117,7 +1114,6 @@ public void onChannelJoin(ChanJoinMessage msg)
|
|
|
|
|
this.chatroom.fireMemberPresenceEvent(member, null,
|
|
|
|
|
ChatRoomMemberPresenceChangeEvent.MEMBER_JOINED, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Event in case of channel part.
|
|
|
|
|
@ -1128,14 +1124,15 @@ public void onChannelPart(ChanPartMessage msg)
|
|
|
|
|
if (!isThisChatRoom(msg.getChannelName()))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (isMe(msg.getSource()))
|
|
|
|
|
IRCUser user = msg.getSource();
|
|
|
|
|
if (isMe(user))
|
|
|
|
|
{
|
|
|
|
|
leaveChatRoom();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
String user = msg.getSource().getNick();
|
|
|
|
|
ChatRoomMember member = this.chatroom.getChatRoomMember(user);
|
|
|
|
|
|
|
|
|
|
String userNick = msg.getSource().getNick();
|
|
|
|
|
ChatRoomMember member = this.chatroom.getChatRoomMember(userNick);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Possibility that 'member' is null (should be fixed now
|
|
|
|
|
@ -1151,7 +1148,6 @@ public void onChannelPart(ChanPartMessage msg)
|
|
|
|
|
+ "as it is a bug.", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Some of the generic message are relevant to us, so keep an eye on
|
|
|
|
|
@ -1196,28 +1192,25 @@ public void onChannelKick(ChannelKick msg)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
String kickedUser = msg.getKickedNickname();
|
|
|
|
|
if (isMe(kickedUser))
|
|
|
|
|
{
|
|
|
|
|
IrcStack.this.irc.deleteListener(this);
|
|
|
|
|
IrcStack.this.joined.remove(this.chatroom.getIdentifier());
|
|
|
|
|
IrcStack.this.provider.getMUC().fireLocalUserPresenceEvent(
|
|
|
|
|
this.chatroom,
|
|
|
|
|
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED,
|
|
|
|
|
msg.getText());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ChatRoomMember kickedMember =
|
|
|
|
|
this.chatroom.getChatRoomMember(kickedUser);
|
|
|
|
|
String user = msg.getSource().getNick();
|
|
|
|
|
if (kickedMember != null)
|
|
|
|
|
{
|
|
|
|
|
ChatRoomMember kicker =
|
|
|
|
|
this.chatroom.getChatRoomMember(user);
|
|
|
|
|
ChatRoomMember kicker = this.chatroom.getChatRoomMember(user);
|
|
|
|
|
this.chatroom.fireMemberPresenceEvent(kickedMember, kicker,
|
|
|
|
|
ChatRoomMemberPresenceChangeEvent.MEMBER_KICKED,
|
|
|
|
|
msg.getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isMe(kickedUser))
|
|
|
|
|
{
|
|
|
|
|
IrcStack.this.irc.deleteListener(this);
|
|
|
|
|
IrcStack.this.joined.remove(this.chatroom.getIdentifier());
|
|
|
|
|
IrcStack.this.provider.getMUC().fireLocalUserPresenceEvent(
|
|
|
|
|
this.chatroom,
|
|
|
|
|
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED,
|
|
|
|
|
msg.getText());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1333,11 +1326,8 @@ private void processModeMessage(ChannelModeMessage msg)
|
|
|
|
|
}
|
|
|
|
|
this.chatroom.fireLocalUserRoleChangedEvent(event);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ChatRoomMember owner =
|
|
|
|
|
this.chatroom
|
|
|
|
|
.getChatRoomMember(mode.getParams()[0]);
|
|
|
|
|
this.chatroom.getChatRoomMember(mode.getParams()[0]);
|
|
|
|
|
if (owner != null)
|
|
|
|
|
{
|
|
|
|
|
if (mode.isAdded())
|
|
|
|
|
@ -1351,7 +1341,6 @@ private void processModeMessage(ChannelModeMessage msg)
|
|
|
|
|
ChatRoomMemberRole.SILENT_MEMBER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case OPERATOR:
|
|
|
|
|
String opUserName = mode.getParams()[0];
|
|
|
|
|
@ -1376,8 +1365,6 @@ private void processModeMessage(ChannelModeMessage msg)
|
|
|
|
|
}
|
|
|
|
|
this.chatroom.fireLocalUserRoleChangedEvent(event);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ChatRoomMember op =
|
|
|
|
|
this.chatroom.getChatRoomMember(opUserName);
|
|
|
|
|
if (op != null)
|
|
|
|
|
@ -1393,7 +1380,6 @@ private void processModeMessage(ChannelModeMessage msg)
|
|
|
|
|
ChatRoomMemberRole.SILENT_MEMBER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case VOICE:
|
|
|
|
|
String voiceUserName = mode.getParams()[0];
|
|
|
|
|
@ -1417,8 +1403,6 @@ private void processModeMessage(ChannelModeMessage msg)
|
|
|
|
|
}
|
|
|
|
|
this.chatroom.fireLocalUserRoleChangedEvent(event);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ChatRoomMember voice =
|
|
|
|
|
this.chatroom.getChatRoomMember(voiceUserName);
|
|
|
|
|
if (voice != null)
|
|
|
|
|
@ -1434,7 +1418,6 @@ private void processModeMessage(ChannelModeMessage msg)
|
|
|
|
|
ChatRoomMemberRole.SILENT_MEMBER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case LIMIT:
|
|
|
|
|
MessageIrcImpl limitMessage;
|
|
|
|
|
|