Fire LOCAL_USER_JOIN_FAILED when failing or forwarding.

fix-message-formatting
Danny van Heumen 12 years ago
parent 33f7f079ef
commit 0507e20d54

@ -523,6 +523,8 @@ public void onSuccess(IRCChannel channel)
{ {
if (!isRequestedChatRoom) if (!isRequestedChatRoom)
{ {
// We joined another chat room than the one we
// requested initially.
if (LOGGER.isTraceEnabled()) if (LOGGER.isTraceEnabled())
{ {
LOGGER LOGGER
@ -537,9 +539,16 @@ public void onSuccess(IRCChannel channel)
+ "since that channel was not " + "since that channel was not "
+ "announced."); + "announced.");
} }
// We did not actually join this channel.
IrcStack.this.joining.remove(chatroom IrcStack.this.joining.remove(chatroom
.getIdentifier()); .getIdentifier());
IrcStack.this.provider
.getMUC()
.fireLocalUserPresenceEvent(
chatroom,
LocalUserChatRoomPresenceChangeEvent
.LOCAL_USER_JOIN_FAILED,
"We got forwarded to channel '"
+ channel.getName() + "'.");
// Notify waiting threads of finished execution. // Notify waiting threads of finished execution.
joinSignal.setDone(); joinSignal.setDone();
joinSignal.notifyAll(); joinSignal.notifyAll();
@ -572,7 +581,8 @@ public void onSuccess(IRCChannel channel)
.getMUC() .getMUC()
.fireLocalUserPresenceEvent( .fireLocalUserPresenceEvent(
chatroom, chatroom,
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED, LocalUserChatRoomPresenceChangeEvent
.LOCAL_USER_JOINED,
null); null);
LOGGER LOGGER
.trace("Finished successful join callback " .trace("Finished successful join callback "
@ -593,29 +603,19 @@ public void onFailure(Exception e)
LOGGER.trace("Started callback for failed attempt to " LOGGER.trace("Started callback for failed attempt to "
+ "join channel '" + chatroom.getIdentifier() + "join channel '" + chatroom.getIdentifier()
+ "'."); + "'.");
// TODO how should we communicate a failed attempt
// at joining the channel? (System messages don't
// seem to show if there is no actual chat room
// presence.)
synchronized (joinSignal) synchronized (joinSignal)
{ {
try try
{ {
IrcStack.this.joining.remove(chatroom IrcStack.this.joining.remove(chatroom
.getIdentifier()); .getIdentifier());
MessageIrcImpl message = IrcStack.this.provider
new MessageIrcImpl( .getMUC()
"Failed to join channel " .fireLocalUserPresenceEvent(
+ chatroom.getIdentifier() + " (" chatroom,
+ e.getMessage() + ")", LocalUserChatRoomPresenceChangeEvent
"text/plain", "UTF-8", "Failed to join"); .LOCAL_USER_JOIN_FAILED,
chatroom e.getMessage());
.fireMessageReceivedEvent(
message,
null,
new Date(),
MessageReceivedEvent
.SYSTEM_MESSAGE_RECEIVED);
} }
finally finally
{ {
@ -649,14 +649,6 @@ public void onFailure(Exception e)
.trace("Finished waiting for join operation for channel '" .trace("Finished waiting for join operation for channel '"
+ chatroom.getIdentifier() + "' to complete."); + chatroom.getIdentifier() + "' to complete.");
// TODO How to handle 480 (+j): Channel throttle exceeded? // TODO How to handle 480 (+j): Channel throttle exceeded?
Exception e = joinSignal.getException();
if (e != null)
{
// in case an exception occurred during join process
throw new OperationFailedException(e.getMessage(),
OperationFailedException.CHAT_ROOM_NOT_JOINED, e);
}
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
@ -998,10 +990,11 @@ private void deliverReceivedMessageToPrivateChat(
ChatRoomMember member = chatroom.getChatRoomMember(user); ChatRoomMember member = chatroom.getChatRoomMember(user);
if (member == null) if (member == null)
{ {
// TODO check should not be necessary, but sometimes null is still returned. // TODO check should not be necessary, but sometimes null is
// still returned.
LOGGER LOGGER
.warn("Got null member from chatroom, but expected message source member '" .warn("Got null member from chatroom, but expected message"
+ user + "' to be present."); + "source member '" + user + "' to be present.");
return; return;
} }
MessageIrcImpl message = MessageIrcImpl message =
@ -1018,7 +1011,8 @@ private void deliverReceivedMessageToPrivateChat(
*/ */
private ChatRoomIrcImpl initiatePrivateChatRoom(String user) private ChatRoomIrcImpl initiatePrivateChatRoom(String user)
{ {
OperationSetMultiUserChatIrcImpl muc = IrcStack.this.provider.getMUC(); OperationSetMultiUserChatIrcImpl muc =
IrcStack.this.provider.getMUC();
ChatRoomIrcImpl chatroom = muc.findOrCreateRoom(user); ChatRoomIrcImpl chatroom = muc.findOrCreateRoom(user);
IrcStack.this.joined.put(chatroom.getIdentifier(), chatroom); IrcStack.this.joined.put(chatroom.getIdentifier(), chatroom);
ChatRoomMemberIrcImpl member = ChatRoomMemberIrcImpl member =

Loading…
Cancel
Save