mirror of
https://github.com/Ximi1970/systray-x.git
synced 2025-11-14 17:26:13 +01:00
Cleanup
This commit is contained in:
@@ -151,6 +151,10 @@ void WindowCtrl::slotWindowState( int state )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
Q_UNUSED( state )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ SysTrayX.Messaging = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
browser.folderChange.onUnreadMailChange.addListener(function (unread) {
|
browser.folderChange.onUnreadMailChange.addListener(function (unread) {
|
||||||
console.debug("folderChangeListener: " + unread);
|
|
||||||
|
|
||||||
SysTrayX.Messaging.unreadCb(unread);
|
SysTrayX.Messaging.unreadCb(unread);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,22 @@ async function getMinimizeOnClose() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get filters
|
||||||
|
//
|
||||||
|
async function getFilters() {
|
||||||
|
function getFiltersCb(result) {
|
||||||
|
return result.filters || undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFiltersError() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const getFilters = browser.storage.sync.get("filters");
|
||||||
|
return await getFilters.then(getFiltersCb, onFiltersError);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get extended filters
|
// Get extended filters
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ var { folderChange } = ChromeUtils.import(
|
|||||||
// The variable must have the same name you've been using so far, "myapi" in this case.
|
// The variable must have the same name you've been using so far, "myapi" in this case.
|
||||||
var folderChange = class extends ExtensionCommon.ExtensionAPI {
|
var folderChange = class extends ExtensionCommon.ExtensionAPI {
|
||||||
getAPI(context) {
|
getAPI(context) {
|
||||||
console.log("folderChange module started");
|
console.log("folderChange API started");
|
||||||
|
|
||||||
// To be notified of the extension going away, call callOnClose with any object that has a
|
// To be notified of the extension going away, call callOnClose with any object that has a
|
||||||
// close function, such as this one.
|
// close function, such as this one.
|
||||||
@@ -93,7 +93,7 @@ var folderChange = class extends ExtensionCommon.ExtensionAPI {
|
|||||||
|
|
||||||
// This function is called if the extension is disabled or removed, or Thunderbird closes.
|
// This function is called if the extension is disabled or removed, or Thunderbird closes.
|
||||||
// We registered it with callOnClose, above.
|
// We registered it with callOnClose, above.
|
||||||
console.log("folderChange module closed");
|
console.log("folderChange API closed");
|
||||||
|
|
||||||
// Unload the JSM we imported above. This will cause Thunderbird to forget about the JSM, and
|
// Unload the JSM we imported above. This will cause Thunderbird to forget about the JSM, and
|
||||||
// load it afresh next time `import` is called. (If you don't call `unload`, Thunderbird will
|
// load it afresh next time `import` is called. (If you don't call `unload`, Thunderbird will
|
||||||
@@ -131,8 +131,6 @@ var SysTrayX = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Initializing folder listener");
|
|
||||||
|
|
||||||
// Get the mail accounts using MailServices
|
// Get the mail accounts using MailServices
|
||||||
this.getAccounts();
|
this.getAccounts();
|
||||||
|
|
||||||
@@ -150,8 +148,6 @@ var SysTrayX = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.log("Shutting down folder listener");
|
|
||||||
|
|
||||||
// Stop listener
|
// Stop listener
|
||||||
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
||||||
|
|
||||||
@@ -159,8 +155,6 @@ var SysTrayX = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setCountType: function (type) {
|
setCountType: function (type) {
|
||||||
console.debug("setCountType: " + type);
|
|
||||||
|
|
||||||
if (type === 0) {
|
if (type === 0) {
|
||||||
this.countType = this.MESSAGE_COUNT_TYPE_UNREAD;
|
this.countType = this.MESSAGE_COUNT_TYPE_UNREAD;
|
||||||
} else if (type === 1) {
|
} else if (type === 1) {
|
||||||
@@ -186,55 +180,15 @@ var SysTrayX = {
|
|||||||
|
|
||||||
OnItemIntPropertyChanged(item, property, oldValue, newValue) {
|
OnItemIntPropertyChanged(item, property, oldValue, newValue) {
|
||||||
// TotalUnreadMessages, BiffState (per server)
|
// TotalUnreadMessages, BiffState (per server)
|
||||||
/*
|
|
||||||
console.debug(
|
|
||||||
"OnItemIntPropertyChanged " +
|
|
||||||
property +
|
|
||||||
" for folder " +
|
|
||||||
item.prettyName +
|
|
||||||
" was " +
|
|
||||||
oldValue +
|
|
||||||
" became " +
|
|
||||||
newValue +
|
|
||||||
" NEW MESSAGES=" +
|
|
||||||
item.getNumNewMessages(true)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
this.onMsgCountChange(item, property, oldValue, newValue);
|
this.onMsgCountChange(item, property, oldValue, newValue);
|
||||||
},
|
},
|
||||||
|
|
||||||
OnItemBoolPropertyChanged: function (item, property, oldValue, newValue) {
|
OnItemBoolPropertyChanged: function (item, property, oldValue, newValue) {
|
||||||
// NewMessages (per folder)
|
// NewMessages (per folder)
|
||||||
/*
|
|
||||||
console.debug(
|
|
||||||
"OnItemBoolPropertyChanged " +
|
|
||||||
property +
|
|
||||||
" for folder " +
|
|
||||||
item.prettyName +
|
|
||||||
" was " +
|
|
||||||
oldValue +
|
|
||||||
" became " +
|
|
||||||
newValue +
|
|
||||||
" NEW MESSAGES=" +
|
|
||||||
item.getNumNewMessages(true)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
this.onMsgCountChange(item, property, oldValue, newValue);
|
this.onMsgCountChange(item, property, oldValue, newValue);
|
||||||
},
|
},
|
||||||
|
|
||||||
OnItemPropertyFlagChanged: function (item, property, oldFlag, newFlag) {
|
OnItemPropertyFlagChanged: function (item, property, oldFlag, newFlag) {
|
||||||
/*
|
|
||||||
console.debug(
|
|
||||||
"OnItemPropertyFlagChanged" +
|
|
||||||
property +
|
|
||||||
" for " +
|
|
||||||
item +
|
|
||||||
" was " +
|
|
||||||
oldFlag +
|
|
||||||
" became " +
|
|
||||||
newFlag
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
this.onMsgCountChange(item, property, oldFlag, newFlag);
|
this.onMsgCountChange(item, property, oldFlag, newFlag);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -265,10 +219,6 @@ var SysTrayX = {
|
|||||||
updateMsgCountWithCb(callback) {
|
updateMsgCountWithCb(callback) {
|
||||||
if (callback === undefined || !callback) {
|
if (callback === undefined || !callback) {
|
||||||
callback = function (currentMsgCount, newMsgCount) {
|
callback = function (currentMsgCount, newMsgCount) {
|
||||||
// default
|
|
||||||
// .updateIcon(newMsgCount);
|
|
||||||
console.debug("Update icon: " + newMsgCount);
|
|
||||||
|
|
||||||
if (SysTrayX.callback) {
|
if (SysTrayX.callback) {
|
||||||
SysTrayX.callback("unread-changed", newMsgCount);
|
SysTrayX.callback("unread-changed", newMsgCount);
|
||||||
}
|
}
|
||||||
@@ -289,8 +239,6 @@ var SysTrayX = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
countMessages(countType) {
|
countMessages(countType) {
|
||||||
console.debug("countMessages: " + countType);
|
|
||||||
|
|
||||||
this.newMsgCount = 0;
|
this.newMsgCount = 0;
|
||||||
for (let accountServer of this.accounts) {
|
for (let accountServer of this.accounts) {
|
||||||
// if (accountServer.type === ACCOUNT_SERVER_TYPE_IM) {
|
// if (accountServer.type === ACCOUNT_SERVER_TYPE_IM) {
|
||||||
@@ -311,8 +259,6 @@ var SysTrayX = {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug("Total " + countType + " = " + this.newMsgCount);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
applyToSubfolders(account, folder, recursive, fun) {
|
applyToSubfolders(account, folder, recursive, fun) {
|
||||||
@@ -342,9 +288,9 @@ var SysTrayX = {
|
|||||||
filter.folder.name === folder.prettyName
|
filter.folder.name === folder.prettyName
|
||||||
);
|
);
|
||||||
|
|
||||||
count = match.length > 0
|
count = match.length > 0;
|
||||||
} else {
|
} else {
|
||||||
count = folder.getFlag(Ci.nsMsgFolderFlags.Inbox);
|
count = folder.getFlag(Ci.nsMsgFolderFlags.Inbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
@@ -355,13 +301,6 @@ var SysTrayX = {
|
|||||||
addUnreadMessages(folder) {
|
addUnreadMessages(folder) {
|
||||||
let folderUnreadMsgCount = folder["getNumUnread"](false);
|
let folderUnreadMsgCount = folder["getNumUnread"](false);
|
||||||
|
|
||||||
console.debug(
|
|
||||||
"folder: " +
|
|
||||||
folder.prettyName +
|
|
||||||
" folderUnreadMsgCount= " +
|
|
||||||
folderUnreadMsgCount
|
|
||||||
);
|
|
||||||
|
|
||||||
/* nsMsgDBFolder::GetNumUnread basically returns mNumUnreadMessages +
|
/* nsMsgDBFolder::GetNumUnread basically returns mNumUnreadMessages +
|
||||||
mNumPendingUnreadMessages, while mNumPendingUnreadMessages may get -1
|
mNumPendingUnreadMessages, while mNumPendingUnreadMessages may get -1
|
||||||
when updated from the cache. Which means getNumUnread might return -1. */
|
when updated from the cache. Which means getNumUnread might return -1. */
|
||||||
@@ -373,16 +312,10 @@ var SysTrayX = {
|
|||||||
addHasNewMessages(folder) {
|
addHasNewMessages(folder) {
|
||||||
let folderNewMsgCount = folder.hasNewMessages;
|
let folderNewMsgCount = folder.hasNewMessages;
|
||||||
|
|
||||||
console.debug(
|
|
||||||
"folder: " + folder.prettyName + " hasNewMessages= " + folderNewMsgCount
|
|
||||||
);
|
|
||||||
|
|
||||||
this.newMsgCount = this.newMsgCount || folderNewMsgCount;
|
this.newMsgCount = this.newMsgCount || folderNewMsgCount;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAccounts() {
|
getAccounts() {
|
||||||
console.debug("getAccounts");
|
|
||||||
|
|
||||||
let accountServers = [];
|
let accountServers = [];
|
||||||
for (let accountServer of fixIterator(
|
for (let accountServer of fixIterator(
|
||||||
MailServices.accounts.accounts,
|
MailServices.accounts.accounts,
|
||||||
@@ -391,6 +324,7 @@ var SysTrayX = {
|
|||||||
accountServers.push(accountServer.incomingServer);
|
accountServers.push(accountServer.incomingServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (let i = 0, len = accountServers.length; i < len; ++i) {
|
for (let i = 0, len = accountServers.length; i < len; ++i) {
|
||||||
console.debug(
|
console.debug(
|
||||||
"ACCOUNT: " +
|
"ACCOUNT: " +
|
||||||
@@ -401,6 +335,7 @@ var SysTrayX = {
|
|||||||
accountServers[i].key.toString()
|
accountServers[i].key.toString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Store the accounts
|
// Store the accounts
|
||||||
this.accounts = accountServers;
|
this.accounts = accountServers;
|
||||||
|
|||||||
Reference in New Issue
Block a user