diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index e643710..5c68e89 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -20,6 +20,7 @@
+
@@ -29,6 +30,7 @@
+
diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js
index f9bacde..eebe551 100644
--- a/src/chrome/content/overlay.js
+++ b/src/chrome/content/overlay.js
@@ -10,13 +10,18 @@ var TbChatNotifier = {
prefs : null,
observer : null,
+ observerTopics : {
+ newDirectedIncomingMessage : 'new-directed-incoming-message',
+ newText : 'new-text'
+ },
audio : null,
options : {
showbody : false,
playsound : false,
soundfile : '',
- flashicon : false
+ flashicon : false,
+ mucnotify : false
},
/**
@@ -29,6 +34,7 @@ var TbChatNotifier = {
.getService(Ci.nsIPrefService)
.getBranch('extensions.tbchatnotification.');
prefs.QueryInterface(Ci.nsIPrefBranch);
+
var options = this.options;
options.observe = function(subject, topic, data) {
if (topic != 'nsPref:changed') {
@@ -48,14 +54,18 @@ var TbChatNotifier = {
case 'flashicon' :
this.flashicon = prefs.getBoolPref('flashicon');
break;
+ case 'mucnotify' :
+ this.mucnotify = prefs.getBoolPref('mucnotify');
+ break;
}
}
prefs.addObserver('', options, false);
-
+
options.showbody = prefs.getBoolPref('showbody');
options.playsound = prefs.getBoolPref('playsound');
options.soundfile = prefs.getCharPref('soundfile');
options.flashicon = prefs.getBoolPref('flashicon');
+ options.mucnotify = prefs.getBoolPref('mucnotify');
// Audio
this.audio = new Audio();
@@ -64,29 +74,41 @@ var TbChatNotifier = {
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
- var OBSERVER_TOPIC = 'new-directed-incoming-message';
+ var imServices = {};
+ Cu.import("resource:///modules/imServices.jsm", imServices);
+ imServices = imServices.Services;
+
+ var observerTopics = this.observerTopics;
var notifier = this;
var observer = this.observer = {
observe: function(subject, topic, data) {
- if (topic == OBSERVER_TOPIC) {
+ if (subject.incoming && (((topic == observerTopics.newDirectedIncomingMessage) && !options.mucnotify) || ((topic == observerTopics.newText) && options.mucnotify))) {
notifier.play();
- notifier.notify(subject.alias, subject.originalMessage);
+ notifier.notify(subject.alias, subject.originalMessage, imServices.conversations.getUIConversation(subject.conversation).title);
}
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference])
};
- Services.obs.addObserver(observer, OBSERVER_TOPIC, true);
+ for (var topic in observerTopics) {
+ Services.obs.addObserver(observer, observerTopics[topic], true);
+ }
},
/**
* Unload chat notifier.
*/
unload : function() {
- this.prefs.addObserver('', this.options);
- Services.obs.removeObserver(this.observer, OBSERVER_TOPIC);
+ this.prefs.removeObserver('', this.options);
+
+ var observer = this.observer,
+ observerTopics = this.observerTopics;
+
+ for (var topic in observerTopics) {
+ Services.obs.removeObserver(observer, observerTopics[topic]);
+ }
},
/**
@@ -106,8 +128,9 @@ var TbChatNotifier = {
* Show non-modal alert message.
* @param from string
* @param message string
+ * @param conversation string
*/
- notify : function(from, message) {
+ notify : function(from, message, conversation) {
var options = this.options;
try {
@@ -148,7 +171,7 @@ var TbChatNotifier = {
Cc['@mozilla.org/alerts-service;1']
.getService(Ci.nsIAlertsService)
- .showAlertNotification('chrome://TbChatNotification/skin/icon32.png', title, text, true, from, listener);
+ .showAlertNotification('chrome://TbChatNotification/skin/icon32.png', title, text, true, conversation, listener);
if (options.flashicon) {
window.getAttention();
diff --git a/src/chrome/locale/cs-CZ/options.dtd b/src/chrome/locale/cs-CZ/options.dtd
index c6f656a..5a4ed93 100644
--- a/src/chrome/locale/cs-CZ/options.dtd
+++ b/src/chrome/locale/cs-CZ/options.dtd
@@ -7,3 +7,5 @@
+
+
diff --git a/src/chrome/locale/en-EN/options.dtd b/src/chrome/locale/en-EN/options.dtd
index d1b231d..3a6ff70 100644
--- a/src/chrome/locale/en-EN/options.dtd
+++ b/src/chrome/locale/en-EN/options.dtd
@@ -7,3 +7,5 @@
+
+
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index 712fe73..c4e5f13 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -3,3 +3,4 @@ pref('extensions.tbchatnotification.showbody', false);
pref('extensions.tbchatnotification.playsound', false);
pref('extensions.tbchatnotification.soundfile', '');
pref('extensions.tbchatnotification.flashicon', false);
+pref('extensions.tbchatnotification.mucnotify', false);
diff --git a/src/install.rdf b/src/install.rdf
index 3f9f5ae..34e8f3b 100644
--- a/src/install.rdf
+++ b/src/install.rdf
@@ -6,7 +6,7 @@
tbchatnotification@forrest79.net
2
- 1.0.1
+ 1.1.0
Thunderbird Chat Notification
chrome://TbChatNotification/skin/icon32.png
chrome://TbChatNotification/content/options.xul