From 7834f1013a5eb1c30082dea80b60693dc65a4277 Mon Sep 17 00:00:00 2001 From: David Wille Date: Sun, 13 May 2012 19:51:46 +0200 Subject: [PATCH 1/4] added new textboxes for new / no new mail scripts and functions stubs for update methods --- src/chrome/content/options.js | 8 ++++++++ src/chrome/content/options.xul | 29 +++++++++++++++++++++++++++++ src/chrome/locale/en-US/options.dtd | 4 ++++ 3 files changed, 41 insertions(+) diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index c9c73f0..eb86dde 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -206,6 +206,14 @@ var firetrayUIOptions = { if (+radio.getItemAtIndex(i).value == value) return i; return -1; }, + + updateNewMailScript : function() { + + }, + + updateNoNewMailScript : function() { + + }, updateNotificationSettings: function() { F.LOG("updateNotificationSettings"); diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul index 8a2bde2..3060307 100644 --- a/src/chrome/content/options.xul +++ b/src/chrome/content/options.xul @@ -36,6 +36,8 @@ + + @@ -218,6 +220,33 @@ accesskey="&folder_count_recursive.accesskey;" preference="pref_folder_count_recursive" observes="broadcaster-notification-disabled"/> + + + + + diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd index 121a731..3432619 100644 --- a/src/chrome/locale/en-US/options.dtd +++ b/src/chrome/locale/en-US/options.dtd @@ -41,6 +41,10 @@ + + + + From 496dce296cc7400a4bd4e10bee4b5a1e99f98f1e Mon Sep 17 00:00:00 2001 From: David Wille Date: Sun, 13 May 2012 20:15:08 +0200 Subject: [PATCH 2/4] added default values and prefs are stored and restored --- src/chrome/content/options.js | 18 ++++++++++++++++-- src/defaults/preferences/prefs.js | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index eb86dde..8b715b6 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -31,6 +31,8 @@ var firetrayUIOptions = { this.updateScrollOptions(); this.initAppIconType(); this.initAppIconNames(); + this.initNewMailScript(); + this.initNoNewMailScript(); if (firetray.Handler.inMailApp) this.initNewMailIconNames(); }, @@ -207,12 +209,24 @@ var firetrayUIOptions = { return -1; }, + initNewMailScript : function() { + document.getElementById("ui_new_mail_script").value = + firetray.Utils.prefService.getCharPref("new_mail_script"); + }, + + initNoNewMailScript : function() { + document.getElementById("ui_no_new_mail_script").value = + firetray.Utils.prefService.getCharPref("no_new_mail_script"); + }, + updateNewMailScript : function() { - + let newMailScript = document.getElementById("ui_new_mail_script").value; + firetray.Utils.prefService.setCharPref("new_mail_script", newMailScript); }, updateNoNewMailScript : function() { - + let noNewMailScript = document.getElementById("ui_no_new_mail_script").value; + firetray.Utils.prefService.setCharPref("no_new_mail_script", noNewMailScript); }, updateNotificationSettings: function() { diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js index dcafd7d..3e28d02 100644 --- a/src/defaults/preferences/prefs.js +++ b/src/defaults/preferences/prefs.js @@ -27,6 +27,8 @@ pref("extensions.firetray.mail_notification_enabled", true); pref("extensions.firetray.mail_notification_type", 0); pref("extensions.firetray.icon_text_color", "#000000"); pref("extensions.firetray.custom_mail_icon", ""); +pref("extensions.firetray.new_mail_script", ""); +pref("extensions.firetray.no_new_mail_script", ""); // Ci.nsMsgFolderFlags.Archive|Drafts|Junk|Queue|SentMail|Trash|Virtual pref("extensions.firetray.excluded_folders_flags", 1077956384); // exposed in 1 tree, hence 2 branches: serverTypes, excludedAccounts From 51edcf43771af3c9aed8960688f470414a730714 Mon Sep 17 00:00:00 2001 From: David Wille Date: Sun, 13 May 2012 21:35:42 +0200 Subject: [PATCH 3/4] added functions to run scripts on new / no new mail... should be working --- src/modules/FiretrayMessaging.jsm | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index f7dddb8..2253ec6 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -138,6 +138,36 @@ firetray.Messaging = { } } }, + + runNewMailScript: function() { + // create a file for the process + var file = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + file.initWithPath(firetray.Utils.prefService.getCharPref("new_mail_script")); + + // create the process + var process = Components.classes["@mozilla.org/process/util;1"] + .createInstance(Components.interfaces.nsIProcess); + process.init(file); + + var args = [ ]; + process.run(false, args, args.length); + }, + + runNoNewMailScript: function() { + // create a file for the process + var file = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + file.initWithPath(firetray.Utils.prefService.getCharPref("no_new_mail_script")); + + // create the process + var process = Components.classes["@mozilla.org/process/util;1"] + .createInstance(Components.interfaces.nsIProcess); + process.init(file); + + var args = [ ]; + process.run(false, args, args.length); + }, /** * computes and display new msg count @@ -168,8 +198,10 @@ firetray.Messaging = { if (newMsgCount == 0) { firetray.Handler.setIconImageDefault(); firetray.Handler.setIconTooltipDefault(); + this.runNoNewMailScript(); } else if (newMsgCount > 0) { + this.runNewMailScript(); let prefMailNotification = firetray.Utils.prefService.getIntPref('mail_notification_type'); switch (prefMailNotification) { case FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT: From 8cdb6093694e023dd9d892da2b839f3e9c0894d5 Mon Sep 17 00:00:00 2001 From: David Wille Date: Mon, 14 May 2012 07:35:31 +0200 Subject: [PATCH 4/4] run "no new script only" if old msg count > 0 --- src/modules/FiretrayMessaging.jsm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index 2253ec6..ec34131 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -25,6 +25,7 @@ const FLDRS_UNINTERESTING = { firetray.Messaging = { initialized: false, cleaningTimer: null, + oldMsgCount: 0, init: function() { if (this.initialized) { @@ -198,7 +199,9 @@ firetray.Messaging = { if (newMsgCount == 0) { firetray.Handler.setIconImageDefault(); firetray.Handler.setIconTooltipDefault(); - this.runNoNewMailScript(); + if (this.oldMsgCount > 0) { + this.runNoNewMailScript(); + } } else if (newMsgCount > 0) { this.runNewMailScript(); @@ -224,6 +227,7 @@ firetray.Messaging = { } else { throw "negative message count"; // should never happen } + this.oldMsgCount = newMsgCount; },