diff options
author | Izhar Firdaus <izhar@inigo-tech.com> | 2011-04-13 03:20:00 +0800 |
---|---|---|
committer | Izhar Firdaus <izhar@inigo-tech.com> | 2011-04-13 03:20:00 +0800 |
commit | 41c9dff5f13a48405a82e8506747e1429a21dfca (patch) | |
tree | 9645f2d8bcfb28433e1f8ba2d88c61b1ed2f1de0 | |
parent | 21690298e8b97223ba4b9239460b77078a9b669c (diff) | |
download | hack-patches-41c9dff5f13a48405a82e8506747e1429a21dfca.tar.gz hack-patches-41c9dff5f13a48405a82e8506747e1429a21dfca.tar.xz hack-patches-41c9dff5f13a48405a82e8506747e1429a21dfca.zip |
text already escaped, dont escape them when appending
-rw-r--r-- | gnomeshell@pidgin.im/extension.js | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/gnomeshell@pidgin.im/extension.js b/gnomeshell@pidgin.im/extension.js index 7a9f0c7..ea9c0bc 100644 --- a/gnomeshell@pidgin.im/extension.js +++ b/gnomeshell@pidgin.im/extension.js @@ -36,6 +36,37 @@ function wrappedText(text, sender, timestamp, direction) { }; } + +function PidginNotification(source) { + this._init(source); +} + +function _fixText(text) { + // remove A HREF + let _text = text.replace(/<A HREF=".*?">(.*?)<\/A>/g, '$1'); + return _text; +} + +PidginNotification.prototype = { + __proto__: TelepathyClient.Notification.prototype, + + appendMessage: function(message, noTimestamp, styles) { + let messageBody = _fixText(message.text); + styles = styles || []; + styles.push(message.direction); + + if (message.messageType == Tp.ChannelTextMessageType.ACTION) { + let senderAlias = GLib.markup_escape_text(message.sender, -1); + messageBody = '<i>%s</i> %s'.format(senderAlias, messageBody); + styles.push('chat-action'); + } + + this.update(this.source.title, messageBody, { customContent: true, bannerMarkup: true }); + this._append(messageBody, styles, message.timestamp, noTimestamp); + } + +} + function Source(client, conversation, initialMessage) { this._init(client, conversation, initialMessage); } @@ -61,7 +92,8 @@ Source.prototype = { this._initialMessage = initialMessage; this._iconUri = 'file:///usr/share/icons/hicolor/48x48/apps/pidgin.png'; // use this icon as default this._presence = 'online'; - this._notification = new TelepathyClient.Notification(this); +// this._notification = new TelepathyClient.Notification(this); + this._notification = new PidginNotification(this); this._notification.setUrgency(MessageTray.Urgency.HIGH); @@ -82,7 +114,7 @@ Source.prototype = { // Start! // - this.title = proxy.PurpleBuddyGetAliasSync(this._author_buddy); + this.title = GLib.markup_escape_text(proxy.PurpleBuddyGetAliasSync(this._author_buddy)); this._setSummaryIcon(this.createNotificationIcon()); @@ -179,7 +211,7 @@ Source.prototype = { if (buddy != this._author_buddy) return; this._presence = 'offline'; - this._notification.appendPresence(': <i>offline</i>', false); + this._notification.appendPresence(': <i>' + this.title + ' have signed off</i>', false); }, _onDeleteConversation: function(emitter, conversation) { |