Use Jitsi /me display support instead of IRC formatting it itself.

cefexperiments
Danny van Heumen 12 years ago
parent 3aad682f9b
commit 143d2a01f4

@ -1142,7 +1142,7 @@ public void onChannelAction(final ChannelActionMsg msg)
this.chatroom, userNick, msg.getSource().getIdent(), msg
.getSource().getHostname(), ChatRoomMemberRole.MEMBER);
MessageIrcImpl message =
MessageIrcImpl.newActionFromIRC(member, msg.getText());
MessageIrcImpl.newActionFromIRC(msg.getText());
this.chatroom.fireMessageReceivedEvent(message, member, new Date(),
ChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED);
}

@ -98,50 +98,17 @@ private static MessageIrcImpl newNoticeFromIRC(final String user,
null);
}
/**
* Create a new instance from an IRC text and parse the IRC message. (See
* {@link #newMessageFromIRC(String)}.)
*
* @param user the originating user
* @param message the IRC action message
* @return returns a new message instance
*/
public static MessageIrcImpl newActionFromIRC(
final ChatRoomMemberIrcImpl user, final String message)
{
return newActionFromIRC(user.getContactAddress(), message);
}
/**
* Create a new instance from an IRC text and parse the IRC message. (See
* {@link #newMessageFromIRC(String)}.)
*
* @param user the originating user
* @param message the IRC action message
* @return returns a new message instance
*/
public static MessageIrcImpl newActionFromIRC(final Contact user,
final String message)
{
return newActionFromIRC(user.getAddress(), message);
}
/**
* Construct the new action message.
*
* @param user the originating user
* @param message the IRC action message
* @return returns a new message instance
*/
private static MessageIrcImpl newActionFromIRC(final String user,
final String message)
public static MessageIrcImpl newActionFromIRC(final String message)
{
String text = Utils.parseIrcMessage(message);
// TODO consider returning message starting with "/me " and let Jitsi do
// the /me formatting.
text = Utils.styleAsAction(text, user);
return new MessageIrcImpl(text, HTML_MIME_TYPE, DEFAULT_MIME_ENCODING,
null);
return new MessageIrcImpl("/me " + text, HTML_MIME_TYPE,
DEFAULT_MIME_ENCODING, null);
}
/**

@ -424,7 +424,7 @@ public void onUserAction(final UserActionMsg msg)
MessageManager.this.provider.getPersistentPresence()
.findContactByID(user);
final MessageIrcImpl message =
MessageIrcImpl.newActionFromIRC(from, msg.getText());
MessageIrcImpl.newActionFromIRC(msg.getText());
MessageManager.this.provider.getBasicInstantMessaging()
.fireMessageReceived(message, from);
}

@ -211,18 +211,6 @@ public static String styleAsNotice(final String message, final String user)
return "<i>" + user + "</i>: " + message;
}
/**
* Format message as HTML-formatted action.
*
* @param message original IRC message
* @param user user nick name
* @return returns HTML-formatted action
*/
public static String styleAsAction(final String message, final String user)
{
return "<b>*" + user + "</b> " + message;
}
/**
* Format message as HTML-formatted away message.
*

@ -68,13 +68,9 @@ public void testNewActionFromIRC()
// Test with chat room member.
ChatRoomMemberIrcImpl chatRoomMember =
EasyMock.createMock(ChatRoomMemberIrcImpl.class);
EasyMock.expect(chatRoomMember.getContactAddress())
.andReturn("IamUser");
EasyMock.replay(chatRoomMember);
MessageIrcImpl message =
MessageIrcImpl.newActionFromIRC(chatRoomMember, text);
Assert.assertEquals(Utils.styleAsAction(text, "IamUser"),
message.getContent());
MessageIrcImpl message = MessageIrcImpl.newActionFromIRC(text);
Assert.assertEquals("/me Hello world.", message.getContent());
Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
message.getContentType());
Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,
@ -83,11 +79,9 @@ public void testNewActionFromIRC()
// Test with contact.
ContactIrcImpl contact = EasyMock.createMock(ContactIrcImpl.class);
EasyMock.expect(contact.getAddress()).andReturn("IamUser");
EasyMock.replay(contact);
message = MessageIrcImpl.newActionFromIRC(contact, text);
Assert.assertEquals(Utils.styleAsAction(text, "IamUser"),
message.getContent());
message = MessageIrcImpl.newActionFromIRC(text);
Assert.assertEquals("/me Hello world.", message.getContent());
Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
message.getContentType());
Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,

@ -194,12 +194,4 @@ public void testStyleAsNotice()
Assert.assertEquals("<i>MrNiceGuy</i>: hello world",
Utils.styleAsNotice(message, nick));
}
public void testStyleAsAction()
{
String message = "is absolutely crazy!";
String nick = "AbsoluteLunatic";
Assert.assertEquals("<b>*AbsoluteLunatic</b> is absolutely crazy!",
Utils.styleAsAction(message, nick));
}
}

Loading…
Cancel
Save