add pref to exclude mail servers from checking
This commit is contained in:
parent
fcab487297
commit
33fd0b47f7
|
@ -1,9 +1,12 @@
|
|||
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
Components.utils.import("resource://moztray/commons.js");
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource:///modules/mailServices.js");
|
||||
Cu.import("resource://moztray/MoztHandler.jsm");
|
||||
Cu.import("resource://moztray/commons.js");
|
||||
|
||||
/**
|
||||
* mozt namespace.
|
||||
|
@ -13,7 +16,69 @@ if ("undefined" == typeof(mozt)) {
|
|||
};
|
||||
|
||||
mozt.UIOptions = {
|
||||
accountBoxId: "accounts_box",
|
||||
|
||||
onLoad: function() {}
|
||||
onLoad: function() {
|
||||
if(mozt.Handler.inMailApp) {
|
||||
Cu.import("resource://moztray/MoztMessaging.jsm");
|
||||
this.insertMailAccountsExcluded(this.accountBoxId);
|
||||
}
|
||||
},
|
||||
|
||||
insertMailAccountsExcluded: function(parentId) {
|
||||
// the DOM parent where we do appendChild
|
||||
let targetNode = document.getElementById(parentId);
|
||||
|
||||
// accounts_to_exclude preference is a stringified Array containing the
|
||||
// keys of the accounts to exclude
|
||||
let accountsExcluded = mozt.Utils.prefService
|
||||
.getCharPref('accounts_to_exclude').split(',');
|
||||
|
||||
// TODO: sort servers by type, name
|
||||
let accounts = MailServices.accounts.accounts;
|
||||
for (let i = 0; i < accounts.Count(); i++) {
|
||||
let account = accounts.QueryElementAt(i, Ci.nsIMsgAccount);
|
||||
let accountServer = account.incomingServer;
|
||||
if (mozt.Messaging.SERVER_TYPES_EXCLUDED.indexOf(accountServer.type) >= 0)
|
||||
continue;
|
||||
|
||||
let nodeAccount = document.createElement("checkbox");
|
||||
let accountServerKey = accountServer.key.toString();
|
||||
nodeAccount.setAttribute('id', accountServerKey);
|
||||
nodeAccount.setAttribute('label', accountServer.rootFolder.name);
|
||||
nodeAccount.setAttribute('checked',
|
||||
(accountsExcluded.indexOf(accountServerKey) >= 0));
|
||||
nodeAccount.setAttribute(
|
||||
'oncommand',
|
||||
'mozt.UIOptions.updateMailAccountsExcluded(mozt.UIOptions.accountBoxId)');
|
||||
targetNode.appendChild(nodeAccount);
|
||||
}
|
||||
|
||||
// let disable_notify=prefManager.getIntPref("extensions.firetray.show_mail_notification")==0;
|
||||
// this._disableGroup(targetNode,disable_notify);
|
||||
},
|
||||
|
||||
updateMailAccountsExcluded: function(parentId) {
|
||||
let targetNode = document.getElementById(parentId);
|
||||
|
||||
let prefValue = [];
|
||||
for (let i=1; i < targetNode.childNodes.length; i++) {
|
||||
if (targetNode.childNodes[i].checked)
|
||||
prefValue.push(targetNode.childNodes[i].getAttribute('id'));
|
||||
}
|
||||
|
||||
mozt.Utils.prefService.setCharPref('accounts_to_exclude', prefValue.toString());
|
||||
|
||||
mozt.Messaging.updateUnreadMsgCount();
|
||||
},
|
||||
|
||||
_disableGroup: function(group, disableval) {
|
||||
try {
|
||||
for (let i=0; i< group.childNodes.length; i++)
|
||||
group.childNodes[i].disabled = disableval;
|
||||
} catch(e) {
|
||||
ERROR(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<prefwindow id="moztray-preferences"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&prefwindow.title;"
|
||||
onload= "mozt.UIOptions.onLoad()">
|
||||
onload="mozt.UIOptions.onLoad()">
|
||||
|
||||
<script type="application/x-javascript" src="options.js" />
|
||||
|
||||
|
@ -21,6 +21,11 @@
|
|||
accesskey="&bool_close_hides.accesskey;"/>
|
||||
</groupbox>
|
||||
|
||||
<groupbox id="accounts_box"> <!-- mozt.UIOptions.accountBoxId -->
|
||||
<caption label="&mail_accounts_exclude;"/>
|
||||
<!-- accounts are dynamically added here with insert_accounts_name() functions, called at the bottom of this file -->
|
||||
</groupbox>
|
||||
|
||||
</prefpane>
|
||||
|
||||
</prefwindow>
|
||||
|
|
|
@ -30,7 +30,7 @@ mozt.Main = {
|
|||
let init = mozt.Handler.initialized || mozt.Handler.init();
|
||||
|
||||
// update unread messages count
|
||||
if (mozt.Handler._inMailApp)
|
||||
if (mozt.Handler.inMailApp)
|
||||
mozt.Messaging.updateUnreadMsgCount();
|
||||
|
||||
// prevent window closing.
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
<!ENTITY pane1.title "MozTray preferences">
|
||||
<!ENTITY bool_close_hides.label "Closing windows hides to tray">
|
||||
<!ENTITY bool_close_hides.accesskey "C">
|
||||
<!ENTITY mail_accounts_exclude "Mail accounts to exclude" >
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// https://developer.mozilla.org/en/Localizing_extension_descriptions
|
||||
pref("extensions.moztray@foudil.fr.description", "chrome://moztray/locale/overlay.properties");
|
||||
|
||||
// Extension prefs
|
||||
pref("extensions.moztray.close_hides", true);
|
||||
|
||||
// Global prefs
|
||||
pref("browser.tabs.warnOnClose", false);
|
||||
|
||||
// Extension prefs
|
||||
pref("extensions.moztray.close_hides", true);
|
||||
pref("extensions.moztray.accounts_to_exclude", "");
|
||||
|
|
|
@ -28,10 +28,10 @@ if ("undefined" == typeof(mozt)) {
|
|||
// (https://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management)
|
||||
mozt.Handler = {
|
||||
initialized: false,
|
||||
inMailApp: false,
|
||||
|
||||
_windowsHidden: false,
|
||||
_handledDOMWindows: [],
|
||||
_inMailApp: false,
|
||||
|
||||
_getBaseOrXULWindowFromDOMWindow: function(win, winType) {
|
||||
let winInterface, winOut;
|
||||
|
@ -173,7 +173,7 @@ mozt.Handler = {
|
|||
// check if in mail app
|
||||
var mozAppId = Services.appinfo.ID;
|
||||
if (mozAppId === THUNDERBIRD_ID || mozAppId === SEAMONKEY_ID) {
|
||||
this._inMailApp = true;
|
||||
this.inMailApp = true;
|
||||
try {
|
||||
Cu.import("resource://moztray/MoztMessaging.jsm");
|
||||
mozt.Messaging.enable();
|
||||
|
@ -185,14 +185,14 @@ mozt.Handler = {
|
|||
// init unread messages count
|
||||
mozt.Messaging.updateUnreadMsgCount();
|
||||
}
|
||||
LOG('inMailApp: '+this._inMailApp);
|
||||
LOG('inMailApp: '+this.inMailApp);
|
||||
|
||||
this.initialized = true;
|
||||
return true;
|
||||
},
|
||||
|
||||
shutdown: function() { // NOT USED YET
|
||||
if (this._inMailApp)
|
||||
if (this.inMailApp)
|
||||
mozt.Messaging.disable();
|
||||
|
||||
mozt.IconLinux.shutdown();
|
||||
|
|
|
@ -29,6 +29,9 @@ if ("undefined" == typeof(mozt)) {
|
|||
};
|
||||
|
||||
mozt.Messaging = {
|
||||
// TODO: turn into pref
|
||||
SERVER_TYPES_EXCLUDED: ["nntp","rss","movemail"], // keep "pop3","imap","none"
|
||||
|
||||
_unreadMsgCount: 0,
|
||||
|
||||
enable: function() {
|
||||
|
@ -81,14 +84,17 @@ mozt.Messaging = {
|
|||
|
||||
this._unreadMsgCount = 0; // reset
|
||||
try {
|
||||
let accountsExcluded = mozt.Utils.prefService
|
||||
.getCharPref('accounts_to_exclude').split(',');
|
||||
|
||||
let accounts = MailServices.accounts.accounts;
|
||||
for (let i = 0; i < accounts.Count(); i++) {
|
||||
let account = accounts.QueryElementAt(i, Ci.nsIMsgAccount);
|
||||
let accountServerType = account.incomingServer.type;
|
||||
LOG("ACCOUNT: "+account.incomingServer.prettyName+" type: "+accountServerType);
|
||||
if (["pop3","imap","none"].indexOf(accountServerType) == -1)
|
||||
continue; // skip "nntp" "rss" "movemail"
|
||||
// TODO: turn into pref
|
||||
let accountServer = account.incomingServer;
|
||||
LOG("ACCOUNT: "+account.incomingServer.prettyName+" type: "+accountServer.type);
|
||||
if ( (this.SERVER_TYPES_EXCLUDED.indexOf(accountServer.type) >= 0)
|
||||
|| (accountsExcluded.indexOf(accountServer.key) >= 0) )
|
||||
continue;
|
||||
|
||||
let rootFolder = account.incomingServer.rootFolder; // nsIMsgFolder
|
||||
if (rootFolder.hasSubFolders) {
|
||||
|
|
Loading…
Reference in New Issue