Hey Danny,
what is the problem that you solved with this one? Asking cause it
seems on macosx escapes some special chars and the escaped string is
seen in the growl notification (like é -> é) and I don't want
to break your stuff and just to check for appropriate fix.
Regards
damencho
···
On Mon, Jan 26, 2015 at 12:13 AM, <danny@dannyvanheumen.nl> wrote:
Repository : ssh://lists.jitsi.org/jitsi
On branch : master
Link : https://github.com/jitsi/jitsi/compare/e547c42c44f8a3efae495c4be27d5e1505f59b21...baeca0ef7bdd708c92ca67724ba5cb9985bdb332---------------------------------------------------------------
commit baeca0ef7bdd708c92ca67724ba5cb9985bdb332
Author: Danny van Heumen <danny@dannyvanheumen.nl>
Date: Sun Jan 25 17:11:38 2015 +0100Escape html entities for plain text messages in notifications.
---------------------------------------------------------------
baeca0ef7bdd708c92ca67724ba5cb9985bdb332
build.xml | 2 +-
.../notificationwiring/NotificationManager.java | 51 ++++++++++++++++++----
.../notificationwiring.manifest.mf | 4 +-
3 files changed, 46 insertions(+), 11 deletions(-)diff --git a/build.xml b/build.xml
index af8c0e6..f84917a 100644
--- a/build.xml
+++ b/build.xml
@@ -2178,7 +2178,7 @@ javax.swing.event, javax.swing.border"/>
</target><!-- BUNDLE-NOTIFICATION-WIRING -->
- <target name="bundle-notification-wiring">
+ <target name="bundle-notification-wiring" depends="bundle-commons-lang">
<!-- Creates a bundle for the notifications.-->
<jar compress="false" destfile="${bundles.dest}/notification-wiring.jar"
manifest="${src}/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf">
diff --git a/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java b/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java
index 1830282..6390529 100644
--- a/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java
+++ b/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java
@@ -18,6 +18,7 @@ import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;+import org.apache.commons.lang3.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.recording.*;
import org.jitsi.service.protocol.event.*;
@@ -99,6 +100,11 @@ public class NotificationManager
public static final String INCOMING_MESSAGE = "IncomingMessage";/**
+ * HTML content type.
+ */
+ private static final String HTML_CONTENT_TYPE = "text/html";
+
+ /**
* The <tt>Logger</tt> used by the <tt>NotificationManager</tt> class and
* its instances for logging output.
*/
@@ -130,6 +136,7 @@ public class NotificationManager
* @param eventType the event type for which we fire a notification
* @param messageTitle the title of the message
* @param message the content of the message
+ * @param messageUID the message UID
*/
public static void fireChatNotification(Object chatContact,
String eventType,
@@ -1145,12 +1152,20 @@ public class NotificationManager
= NotificationWiringActivator.getResources().getI18NString(
"service.gui.MSG_RECEIVED",
new String[] { sourceParticipant.getDisplayName() });
-
+ final String htmlContent;
+ if (HTML_CONTENT_TYPE.equals(evt.getMessage().getContentType()))
+ {
+ htmlContent = messageContent;
+ }
+ else
+ {
+ htmlContent = StringEscapeUtils.escapeHtml4(messageContent);
+ }
fireChatNotification(
sourceChatRoom,
INCOMING_MESSAGE,
title,
- messageContent,
+ htmlContent,
evt.getMessage().getMessageUID());
}
}
@@ -1178,7 +1193,8 @@ public class NotificationManager
// Fire notification
boolean fireChatNotification;- String messageContent = evt.getMessage().getContent();
+ final Message sourceMsg = evt.getMessage();
+ String messageContent = sourceMsg.getContent();/*
* It is uncommon for IRC clients to display popup notifications for
@@ -1212,13 +1228,21 @@ public class NotificationManager
= NotificationWiringActivator.getResources().getI18NString(
"service.gui.MSG_RECEIVED",
new String[] { sourceMember.getName() });
-
+ final String htmlContent;
+ if (HTML_CONTENT_TYPE.equals(sourceMsg.getContentType()))
+ {
+ htmlContent = messageContent;
+ }
+ else
+ {
+ htmlContent = StringEscapeUtils.escapeHtml4(messageContent);
+ }
fireChatNotification(
sourceChatRoom,
INCOMING_MESSAGE,
title,
- messageContent,
- evt.getMessage().getMessageUID());
+ htmlContent,
+ sourceMsg.getMessageUID());
}
}
catch(Throwable t)
@@ -1241,12 +1265,23 @@ public class NotificationManager
"service.gui.MSG_RECEIVED",
new String[]{evt.getSourceContact().getDisplayName()});+ final Message sourceMsg = evt.getSourceMessage();
+ final String htmlContent;
+ if (HTML_CONTENT_TYPE.equals(sourceMsg.getContentType()))
+ {
+ htmlContent = sourceMsg.getContent();
+ }
+ else
+ {
+ htmlContent =
+ StringEscapeUtils.escapeHtml4(sourceMsg.getContent());
+ }
fireChatNotification(
evt.getSourceContact(),
INCOMING_MESSAGE,
title,
- evt.getSourceMessage().getContent(),
- evt.getSourceMessage().getMessageUID());
+ htmlContent,
+ sourceMsg.getMessageUID());
}
catch(Throwable t)
{
diff --git a/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf b/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf
index 46214fb..5f3a542 100644
--- a/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf
@@ -17,5 +17,5 @@ Import-Package: javax.imageio,
org.jitsi.service.neomedia.recording,
org.jitsi.service.protocol.event,
org.jitsi.service.resources,
- org.osgi.framework
-
+ org.osgi.framework,
+ org.apache.commons.lang3_______________________________________________
commits mailing list
commits@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/commits