mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-07 03:27:16 +02:00
Merge branch 'develop' into feature-fix-new-mail-icon
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# SysTray-X
|
||||
|
||||
SysTray-X is a system tray extension for Thunderbird 68+. The addon uses the WebExtension API's to control an external system dependent system tray application.
|
||||
SysTray-X is a system tray extension for Thunderbird. The addon uses the WebExtension API's to control an external system dependent system tray application.
|
||||
|
||||
The addon and system tray application can do:
|
||||
|
||||
|
||||
@@ -173,11 +173,6 @@ const QString& Preferences::getBrowserVersion() const
|
||||
void Preferences::setBrowserVersion( const QString version )
|
||||
{
|
||||
m_browser_version = version;
|
||||
|
||||
/*
|
||||
* Tell the world the new preference
|
||||
*/
|
||||
emit signalBrowserVersion();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -620,11 +620,6 @@ class Preferences : public QObject
|
||||
*/
|
||||
void signalConsole( QString message );
|
||||
|
||||
/**
|
||||
* @brief signalBrowserVersion. Signal the browser version.
|
||||
*/
|
||||
void signalBrowserVersion();
|
||||
|
||||
/**
|
||||
* @brief signalMinimizeTypeChange. Signal a minimize type change.
|
||||
*/
|
||||
|
||||
@@ -779,23 +779,6 @@ void PreferencesDialog::slotDebugChange()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle the browser version signal
|
||||
*/
|
||||
void PreferencesDialog::slotBrowserVersion()
|
||||
{
|
||||
QString version = m_pref->getBrowserVersion();
|
||||
|
||||
if( version.section( '.', 0, 0 ).toInt() > 89 && version.section( '.', 0, 0 ).toInt() < 91)
|
||||
{
|
||||
/*
|
||||
* Hide the count type for TB90 and up, not supported
|
||||
*/
|
||||
m_ui->countTypeGroupBox->setVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle the start minimized change signal
|
||||
*/
|
||||
|
||||
@@ -285,11 +285,6 @@ class PreferencesDialog : public QDialog
|
||||
*/
|
||||
void slotDebugChange();
|
||||
|
||||
/**
|
||||
* @brief slotBrowserVersion. Slot for handling the browser version signals.
|
||||
*/
|
||||
void slotBrowserVersion();
|
||||
|
||||
/**
|
||||
* @brief slotMinimizeTypeChange. Slot for handling minimize type change signals.
|
||||
*/
|
||||
|
||||
@@ -115,7 +115,6 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
|
||||
connect( m_preferences, &Preferences::signalCloseTypeChange, m_win_ctrl, &WindowCtrl::slotCloseTypeChange );
|
||||
connect( m_preferences, &Preferences::signalStartMinimizedChange, m_win_ctrl, &WindowCtrl::slotStartMinimizedChange );
|
||||
|
||||
connect( m_preferences, &Preferences::signalBrowserVersion, m_pref_dialog, &PreferencesDialog::slotBrowserVersion );
|
||||
connect( m_preferences, &Preferences::signalDefaultIconTypeChange, m_pref_dialog, &PreferencesDialog::slotDefaultIconTypeChange );
|
||||
connect( m_preferences, &Preferences::signalDefaultIconDataChange, m_pref_dialog, &PreferencesDialog::slotDefaultIconDataChange );
|
||||
connect( m_preferences, &Preferences::signalHideDefaultIconChange, m_pref_dialog, &PreferencesDialog::slotHideDefaultIconChange );
|
||||
|
||||
4
dist/arch/gnome/PKGBUILD
vendored
4
dist/arch/gnome/PKGBUILD
vendored
@@ -4,14 +4,14 @@ pkgname=systray-x-gnome
|
||||
pkgver=0
|
||||
pkgrel=0
|
||||
epoch=1
|
||||
pkgdesc='A system tray extension for Thunderbird 68+ (GNOME)'
|
||||
pkgdesc='A system tray extension for Thunderbird (GNOME)'
|
||||
arch=(x86_64)
|
||||
url=https://github.com/Ximi1970/systray-x
|
||||
license=(MPL-2.0)
|
||||
depends=(
|
||||
'qt5-base'
|
||||
'gnome-shell-extension-appindicator'
|
||||
'thunderbird>=68'
|
||||
'thunderbird>=91'
|
||||
'thunderbird<118'
|
||||
)
|
||||
makedepends=(
|
||||
|
||||
4
dist/arch/kde/PKGBUILD
vendored
4
dist/arch/kde/PKGBUILD
vendored
@@ -4,14 +4,14 @@ pkgname=systray-x
|
||||
pkgver=0
|
||||
pkgrel=0
|
||||
epoch=1
|
||||
pkgdesc='A system tray extension for Thunderbird 68+ (KDE)'
|
||||
pkgdesc='A system tray extension for Thunderbird (KDE)'
|
||||
arch=(x86_64)
|
||||
url=https://github.com/Ximi1970/systray-x
|
||||
license=(MPL-2.0)
|
||||
depends=(
|
||||
'qt5-base'
|
||||
'knotifications'
|
||||
'thunderbird>=68'
|
||||
'thunderbird>=91'
|
||||
'thunderbird<118'
|
||||
)
|
||||
makedepends=(
|
||||
|
||||
4
dist/arch/minimal/PKGBUILD
vendored
4
dist/arch/minimal/PKGBUILD
vendored
@@ -4,13 +4,13 @@ pkgname=systray-x-minimal
|
||||
pkgver=0
|
||||
pkgrel=0
|
||||
epoch=1
|
||||
pkgdesc='A system tray extension for Thunderbird 68+ (Unity/XFCE/other)'
|
||||
pkgdesc='A system tray extension for Thunderbird (Unity/XFCE/other)'
|
||||
arch=(x86_64)
|
||||
url=https://github.com/Ximi1970/systray-x
|
||||
license=(MPL-2.0)
|
||||
depends=(
|
||||
'qt5-base'
|
||||
'thunderbird>=68'
|
||||
'thunderbird>=91'
|
||||
'thunderbird<118'
|
||||
)
|
||||
makedepends=(
|
||||
|
||||
8
dist/deb/gnome/debian.control
vendored
8
dist/deb/gnome/debian.control
vendored
@@ -6,14 +6,16 @@ Build-Depends: debhelper (>= 4.1.16), zip, g++, libx11-dev, qt5-qmake, qtbase5-d
|
||||
|
||||
Package: systray-x-gnome
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, gnome-shell-extension-appindicator, thunderbird (>= 1:68), thunderbird (< 1:118)
|
||||
Description: SysTray-X is a system tray extension for Thunderbird 68+ (GNOME).
|
||||
Depends: ${shlibs:Depends}, gnome-shell-extension-appindicator, thunderbird (>= 1:91), thunderbird (< 1:118)
|
||||
Description: SysTray-X is a system tray extension for Thunderbird (GNOME).
|
||||
This version is optimized for the GNOME desktop.
|
||||
The add-on uses the WebExtension API's to control an external system
|
||||
dependent system tray application.
|
||||
The add-on and system tray application can do:
|
||||
* custom new mail icon
|
||||
* display number of unread mails
|
||||
* display number of unread /new mails
|
||||
* optional new mail indicator (icon or shading)
|
||||
* run app on start or close
|
||||
* show / hide Thunderbird (minimize)
|
||||
* minimizing hides to tray
|
||||
* minimize on startup
|
||||
|
||||
8
dist/deb/kde/debian.control
vendored
8
dist/deb/kde/debian.control
vendored
@@ -6,14 +6,16 @@ Build-Depends: debhelper (>= 4.1.16), zip, g++, libx11-dev, qt5-qmake, qtbase5-d
|
||||
|
||||
Package: systray-x
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, thunderbird (>= 1:68), thunderbird (< 1:118)
|
||||
Description: SysTray-X is a system tray extension for Thunderbird 68+ (KDE).
|
||||
Depends: ${shlibs:Depends}, thunderbird (>= 1:91), thunderbird (< 1:118)
|
||||
Description: SysTray-X is a system tray extension for Thunderbird (KDE).
|
||||
This version is optimized for the KDE desktop.
|
||||
The add-on uses the WebExtension API's to control an external system
|
||||
dependent system tray application.
|
||||
The add-on and system tray application can do:
|
||||
* custom new mail icon
|
||||
* display number of unread mails
|
||||
* display number of unread /new mails
|
||||
* optional new mail indicator (icon or shading)
|
||||
* run app on start or close
|
||||
* show / hide Thunderbird (minimize)
|
||||
* minimizing hides to tray
|
||||
* minimize on startup
|
||||
|
||||
8
dist/deb/minimal/debian.control
vendored
8
dist/deb/minimal/debian.control
vendored
@@ -6,14 +6,16 @@ Build-Depends: debhelper (>= 4.1.16), zip, g++, libx11-dev, qt5-qmake, qtbase5-d
|
||||
|
||||
Package: systray-x-minimal
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, thunderbird (>= 1:68), thunderbird (< 1:118)
|
||||
Description: SysTray-X is a system tray extension for Thunderbird 68+ (non-GNOME,non-KDE).
|
||||
Depends: ${shlibs:Depends}, thunderbird (>= 1:91), thunderbird (< 1:118)
|
||||
Description: SysTray-X is a system tray extension for Thunderbird (non-GNOME,non-KDE).
|
||||
This version is for non-KDE and non-GNOME desktops.
|
||||
The add-on uses the WebExtension API's to control an external system
|
||||
dependent system tray application.
|
||||
The add-on and system tray application can do:
|
||||
* custom new mail icon
|
||||
* display number of unread mails
|
||||
* display number of unread /new mails
|
||||
* optional new mail indicator (icon or shading)
|
||||
* run app on start or close
|
||||
* show / hide Thunderbird (minimize)
|
||||
* minimizing hides to tray
|
||||
* minimize on startup
|
||||
|
||||
12
dist/rpm/gnome/systray-x-gnome.spec
vendored
12
dist/rpm/gnome/systray-x-gnome.spec
vendored
@@ -18,7 +18,7 @@
|
||||
Name: systray-x-gnome
|
||||
Version: 0
|
||||
Release: 0
|
||||
Summary: A system tray extension for Thunderbird 68+ (GNOME)
|
||||
Summary: A system tray extension for Thunderbird (GNOME)
|
||||
License: MPL-2.0
|
||||
Group: Productivity/Networking/Email/Clients
|
||||
URL: https://github.com/Ximi1970/systray-x
|
||||
@@ -32,15 +32,15 @@ BuildRequires: pkgconfig(Qt5DBus)
|
||||
BuildRequires: pkgconfig(x11)
|
||||
Requires: gnome-shell-extension-appindicator
|
||||
%if 0%{?fedora_version} || 0%{?centos_version}
|
||||
Requires: thunderbird >= 68
|
||||
Requires: thunderbird >= 91
|
||||
Requires: thunderbird < 118
|
||||
%else
|
||||
Requires: MozillaThunderbird >= 68
|
||||
Requires: MozillaThunderbird >= 91
|
||||
Requires: MozillaThunderbird < 118
|
||||
%endif
|
||||
|
||||
%description
|
||||
SysTray-X is a system tray extension for Thunderbird 68+.
|
||||
SysTray-X is a system tray extension for Thunderbird.
|
||||
This version is optimized for the GNOME desktop.
|
||||
The add-on uses the WebExtension API's to control an external system
|
||||
dependent system tray application.
|
||||
@@ -48,7 +48,9 @@ dependent system tray application.
|
||||
The add-on and system tray application can do:
|
||||
|
||||
* custom new mail icon
|
||||
* display number of unread mails
|
||||
* display number of unread /new mails
|
||||
* optional new mail indicator (icon or shading)
|
||||
* run app on start or close
|
||||
* show / hide Thunderbird (minimize)
|
||||
* minimizing hides to tray
|
||||
* minimize on startup
|
||||
|
||||
13
dist/rpm/kde/systray-x.spec
vendored
13
dist/rpm/kde/systray-x.spec
vendored
@@ -18,7 +18,7 @@
|
||||
Name: systray-x
|
||||
Version: 0
|
||||
Release: 0
|
||||
Summary: A system tray extension for Thunderbird 68+ (KDE)
|
||||
Summary: A system tray extension for Thunderbird (KDE)
|
||||
License: MPL-2.0
|
||||
Group: Productivity/Networking/Email/Clients
|
||||
URL: https://github.com/Ximi1970/systray-x
|
||||
@@ -33,17 +33,17 @@ BuildRequires: pkgconfig(x11)
|
||||
%if 0%{?fedora_version} || 0%{?centos_version}
|
||||
BuildRequires: kf5-knotifications-devel
|
||||
Requires: kf5-knotifications
|
||||
Requires: thunderbird >= 68
|
||||
Requires: thunderbird >= 91
|
||||
Requires: thunderbird < 118
|
||||
%else
|
||||
BuildRequires: knotifications-devel
|
||||
Requires: libKF5Notifications5
|
||||
Requires: MozillaThunderbird >= 68
|
||||
Requires: MozillaThunderbird >= 91
|
||||
Requires: MozillaThunderbird < 118
|
||||
%endif
|
||||
|
||||
%description
|
||||
SysTray-X is a system tray extension for Thunderbird 68+.
|
||||
SysTray-X is a system tray extension for Thunderbird.
|
||||
This version is optimized for the KDE desktop.
|
||||
The add-on uses the WebExtension API's to control an external system
|
||||
dependent system tray application.
|
||||
@@ -51,8 +51,9 @@ dependent system tray application.
|
||||
The add-on and system tray application can do:
|
||||
|
||||
* custom new mail icon
|
||||
* display number of unread mails
|
||||
* show / hide Thunderbird (minimize)
|
||||
* display number of unread /new mails
|
||||
* optional new mail indicator (icon or shading)
|
||||
* run app on start or close
|
||||
* minimizing hides to tray
|
||||
* minimize on startup
|
||||
* minimize on close
|
||||
|
||||
12
dist/rpm/minimal/systray-x-minimal.spec
vendored
12
dist/rpm/minimal/systray-x-minimal.spec
vendored
@@ -18,7 +18,7 @@
|
||||
Name: systray-x-minimal
|
||||
Version: 0
|
||||
Release: 0
|
||||
Summary: A system tray extension for Thunderbird 68+ (Unity/XFCE/other)
|
||||
Summary: A system tray extension for Thunderbird (Unity/XFCE/other)
|
||||
License: MPL-2.0
|
||||
Group: Productivity/Networking/Email/Clients
|
||||
URL: https://github.com/Ximi1970/systray-x
|
||||
@@ -31,15 +31,15 @@ BuildRequires: pkgconfig(Qt5Widgets)
|
||||
BuildRequires: pkgconfig(Qt5DBus)
|
||||
BuildRequires: pkgconfig(x11)
|
||||
%if 0%{?fedora_version} || 0%{?centos_version}
|
||||
Requires: thunderbird >= 68
|
||||
Requires: thunderbird >= 91
|
||||
Requires: thunderbird < 118
|
||||
%else
|
||||
Requires: MozillaThunderbird >= 68
|
||||
Requires: MozillaThunderbird >= 91
|
||||
Requires: MozillaThunderbird < 118
|
||||
%endif
|
||||
|
||||
%description
|
||||
SysTray-X is a system tray extension for Thunderbird 68+.
|
||||
SysTray-X is a system tray extension for Thunderbird.
|
||||
This version is for non-KDE and non-GNOME desktops.
|
||||
The add-on uses the WebExtension API's to control an external system
|
||||
dependent system tray application.
|
||||
@@ -47,7 +47,9 @@ dependent system tray application.
|
||||
The add-on and system tray application can do:
|
||||
|
||||
* custom new mail icon
|
||||
* display number of unread mails
|
||||
* display number of unread /new mails
|
||||
* optional new mail indicator (icon or shading)
|
||||
* run app on start or close
|
||||
* show / hide Thunderbird (minimize)
|
||||
* minimizing hides to tray
|
||||
* minimize on startup
|
||||
|
||||
@@ -84,29 +84,19 @@ SysTrayX.Messaging = {
|
||||
await delay(startupDelay * 1000);
|
||||
*/
|
||||
// Get all accounts
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
SysTrayX.Messaging.accounts = await browser.accounts.list();
|
||||
SysTrayX.Messaging.accounts = await browser.accounts.list(false);
|
||||
|
||||
// Get folder tree
|
||||
SysTrayX.Messaging.folderTree = getFolderTree(
|
||||
SysTrayX.Messaging.accounts,
|
||||
SysTrayX.Info.browserInfo
|
||||
// Fill the sub folders using the folders API, they are not same...
|
||||
for (let i = 0; i < SysTrayX.Messaging.accounts.length; ++i) {
|
||||
const subFolders = await browser.folders.getSubFolders(
|
||||
SysTrayX.Messaging.accounts[i],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
SysTrayX.Messaging.accounts = await browser.accounts.list(false);
|
||||
|
||||
// Fill the sub folders using the folders API, they are not same...
|
||||
for (let i = 0; i < SysTrayX.Messaging.accounts.length; ++i) {
|
||||
const subFolders = await browser.folders.getSubFolders(
|
||||
SysTrayX.Messaging.accounts[i],
|
||||
true
|
||||
);
|
||||
SysTrayX.Messaging.accounts[i].folders = subFolders;
|
||||
}
|
||||
|
||||
console.debug("Accounts: " + JSON.stringify(SysTrayX.Messaging.accounts));
|
||||
SysTrayX.Messaging.accounts[i].folders = subFolders;
|
||||
}
|
||||
|
||||
console.debug("Accounts: " + JSON.stringify(SysTrayX.Messaging.accounts));
|
||||
|
||||
// Get the filters (needs the accounts)
|
||||
const getFiltersPromise = () => new Promise((res) => res(getFilters()));
|
||||
SysTrayX.Messaging.filters = await getFiltersPromise();
|
||||
@@ -115,66 +105,29 @@ SysTrayX.Messaging = {
|
||||
const getCountTypePromise = () => new Promise((res) => res(getCountType()));
|
||||
SysTrayX.Messaging.countType = await getCountTypePromise();
|
||||
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
// Set TB versionn
|
||||
browser.folderChange.setVersion(
|
||||
Number(SysTrayX.Info.browserInfo.majorVersion)
|
||||
);
|
||||
browser.messages.onNewMailReceived.addListener(
|
||||
SysTrayX.Messaging.listenerNewMail
|
||||
);
|
||||
|
||||
// Catch the unread / new mails
|
||||
browser.folderChange.onUnreadMailChange.addListener(function (unread) {
|
||||
SysTrayX.Messaging.unreadCb(unread);
|
||||
});
|
||||
browser.folders.onCreated.addListener(
|
||||
SysTrayX.Messaging.listenerFolderCreated
|
||||
);
|
||||
browser.folders.onRenamed.addListener(
|
||||
SysTrayX.Messaging.listenerFolderRenamed
|
||||
);
|
||||
browser.folders.onDeleted.addListener(
|
||||
SysTrayX.Messaging.listenerFolderDeleted
|
||||
);
|
||||
|
||||
browser.folderChange.onFolderChange.addListener(function (
|
||||
rootFolder,
|
||||
parentFolder,
|
||||
folder,
|
||||
added
|
||||
) {
|
||||
SysTrayX.Messaging.updateFilters(
|
||||
rootFolder,
|
||||
parentFolder,
|
||||
folder,
|
||||
added
|
||||
);
|
||||
});
|
||||
// Get the mail count
|
||||
const getCountPromise = () =>
|
||||
new Promise((res) => res(SysTrayX.Messaging.countMail()));
|
||||
await getCountPromise();
|
||||
|
||||
// Set the count type in the folderChange listener
|
||||
browser.folderChange.setCountType(Number(SysTrayX.Messaging.countType));
|
||||
|
||||
// Set the filters in the folderChange listener
|
||||
browser.folderChange.setFilters(SysTrayX.Messaging.filters);
|
||||
} else {
|
||||
browser.messages.onNewMailReceived.addListener(
|
||||
SysTrayX.Messaging.listenerNewMail
|
||||
);
|
||||
|
||||
browser.folders.onCreated.addListener(
|
||||
SysTrayX.Messaging.listenerFolderCreated
|
||||
);
|
||||
browser.folders.onRenamed.addListener(
|
||||
SysTrayX.Messaging.listenerFolderRenamed
|
||||
);
|
||||
browser.folders.onDeleted.addListener(
|
||||
SysTrayX.Messaging.listenerFolderDeleted
|
||||
);
|
||||
|
||||
// Get the mail count
|
||||
const getCountPromise = () =>
|
||||
new Promise((res) => res(SysTrayX.Messaging.countMail()));
|
||||
await getCountPromise();
|
||||
|
||||
// Get the mail count
|
||||
const getCount2Promise = () =>
|
||||
new Promise((res) => res(getMailCount2()));
|
||||
await getCount2Promise();
|
||||
|
||||
// Set count listener
|
||||
browser.folders.onFolderInfoChanged.addListener(
|
||||
SysTrayX.Messaging.listenerFolderInfoChanged
|
||||
);
|
||||
}
|
||||
// Get the mail count
|
||||
const getCount2Promise = () =>
|
||||
new Promise((res) => res(getMailCount2()));
|
||||
await getCount2Promise();
|
||||
|
||||
// Catch a folder change to reset the new counter
|
||||
browser.mailTabs.onDisplayedFolderChanged.addListener(
|
||||
@@ -374,12 +327,8 @@ SysTrayX.Messaging = {
|
||||
if ("filters" in changes && changes["filters"].newValue) {
|
||||
SysTrayX.Messaging.filters = changes["filters"].newValue;
|
||||
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
browser.folderChange.setFilters(SysTrayX.Messaging.filters);
|
||||
} else {
|
||||
getMailCount();
|
||||
getMailCount2();
|
||||
}
|
||||
getMailCount();
|
||||
getMailCount2();
|
||||
}
|
||||
|
||||
if ("closeType" in changes && changes["closeType"].newValue) {
|
||||
@@ -401,12 +350,8 @@ SysTrayX.Messaging = {
|
||||
if ("countType" in changes && changes["countType"].newValue) {
|
||||
SysTrayX.Messaging.countType = changes["countType"].newValue;
|
||||
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
browser.folderChange.setCountType(Number(SysTrayX.Messaging.countType));
|
||||
} else {
|
||||
getMailCount();
|
||||
getMailCount2();
|
||||
}
|
||||
getMailCount();
|
||||
getMailCount2();
|
||||
}
|
||||
|
||||
if ("addonprefchanged" in changes && changes["addonprefchanged"].newValue) {
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
//
|
||||
// Get the prefered storage
|
||||
//
|
||||
function storage(store) {
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91 || store === "sync") {
|
||||
console.log("Using sync storage");
|
||||
return browser.storage.sync;
|
||||
} else {
|
||||
function storage() {
|
||||
console.log("Using local storage");
|
||||
return browser.storage.local;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -229,30 +224,14 @@ async function getFilters() {
|
||||
|
||||
if (inbox.length > 0) {
|
||||
let folder = {};
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
// console.debug("Folder pre 91: " + JSON.stringify(inbox[0]));
|
||||
|
||||
folder = {
|
||||
...inbox[0],
|
||||
accountName: account.name,
|
||||
path: "/" + inbox[0].name,
|
||||
version: SysTrayX.Info.version,
|
||||
};
|
||||
delete folder.subFolders;
|
||||
// console.debug("Folder 91+: " + JSON.stringify(inbox[0]));
|
||||
|
||||
filters.push({
|
||||
unread: true,
|
||||
folder: folder,
|
||||
});
|
||||
} else {
|
||||
// console.debug("Folder 91+: " + JSON.stringify(inbox[0]));
|
||||
|
||||
filters.push({
|
||||
accountId: inbox[0].accountId,
|
||||
version: SysTrayX.Info.version,
|
||||
folders: [inbox[0].path],
|
||||
});
|
||||
}
|
||||
filters.push({
|
||||
accountId: inbox[0].accountId,
|
||||
version: SysTrayX.Info.version,
|
||||
folders: [inbox[0].path],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,457 +0,0 @@
|
||||
/* eslint-disable object-shorthand */
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
// Get various parts of the WebExtension framework that we need.
|
||||
var { ExtensionCommon } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionCommon.jsm"
|
||||
);
|
||||
|
||||
// You probably already know what this does.
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
var { fixIterator } = ChromeUtils.import(
|
||||
"resource:///modules/iteratorUtils.jsm"
|
||||
);
|
||||
|
||||
// ChromeUtils.import() works in experiments for core resource urls as it did
|
||||
// in legacy add-ons. However, chrome:// urls that point to add-on resources no
|
||||
// longer work, as the "chrome.manifest" file is no longer supported, which
|
||||
// defined the root path for each add-on. Instead, ChromeUtils.import() needs
|
||||
// a url generated by
|
||||
//
|
||||
// let url = context.extension.rootURI.resolve("path/to/file.jsm")
|
||||
//
|
||||
// Instead of taking the extension object from the context, you may generate
|
||||
// the extension object from a given add-on ID as shown in the example below.
|
||||
// This allows to import a JSM without context, for example inside another JSM.
|
||||
//
|
||||
var { ExtensionParent } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionParent.jsm"
|
||||
);
|
||||
var extension = ExtensionParent.GlobalManager.getExtension(
|
||||
"systray-x@Ximi1970"
|
||||
);
|
||||
var { folderChange } = ChromeUtils.import(
|
||||
extension.rootURI.resolve("modules/folderChange.jsm")
|
||||
);
|
||||
|
||||
// This is the important part. It implements the functions and events defined in schema.json.
|
||||
// The variable must have the same name you've been using so far, "myapi" in this case.
|
||||
var folderChange = class extends ExtensionCommon.ExtensionAPI {
|
||||
getAPI(context) {
|
||||
console.log("folderChange API started");
|
||||
|
||||
// To be notified of the extension going away, call callOnClose with any object that has a
|
||||
// close function, such as this one.
|
||||
context.callOnClose(this);
|
||||
|
||||
//
|
||||
// Setup folder listener
|
||||
//
|
||||
SysTrayX.init();
|
||||
|
||||
return {
|
||||
// Again, this key must have the same name.
|
||||
folderChange: {
|
||||
setVersion: async function (version) {
|
||||
SysTrayX.setVersion(version);
|
||||
},
|
||||
|
||||
setCountType: async function (type) {
|
||||
SysTrayX.setCountType(type);
|
||||
},
|
||||
|
||||
setFilters: async function (filters) {
|
||||
SysTrayX.setFilters(filters);
|
||||
},
|
||||
|
||||
onUnreadMailChange: new ExtensionCommon.EventManager({
|
||||
context,
|
||||
name: "folderChange.onUnreadMailChange",
|
||||
// In this function we add listeners for any events we want to listen to, and return a
|
||||
// function that removes those listeners. To have the event fire in your extension,
|
||||
// call fire.async.
|
||||
register(fire) {
|
||||
function callback(event, unread) {
|
||||
return fire.async(unread);
|
||||
}
|
||||
|
||||
SysTrayX.add(callback);
|
||||
return function () {
|
||||
SysTrayX.remove(callback);
|
||||
};
|
||||
},
|
||||
}).api(),
|
||||
|
||||
onFolderChange: new ExtensionCommon.EventManager({
|
||||
context,
|
||||
name: "folderChange.onFolderChange",
|
||||
// In this function we add listeners for any events we want to listen to, and return a
|
||||
// function that removes those listeners. To have the event fire in your extension,
|
||||
// call fire.async.
|
||||
register(fire) {
|
||||
function callback(event, rootFolder, parentFolder, folder, added) {
|
||||
return fire.async(rootFolder, parentFolder, folder, added);
|
||||
}
|
||||
|
||||
SysTrayX.addOnFolderChange(callback);
|
||||
return function () {
|
||||
SysTrayX.removeOnFolderChange(callback);
|
||||
};
|
||||
},
|
||||
}).api(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
close() {
|
||||
/*
|
||||
* Remove the folder listener
|
||||
*/
|
||||
SysTrayX.shutdown();
|
||||
|
||||
// This function is called if the extension is disabled or removed, or Thunderbird closes.
|
||||
// We registered it with callOnClose, above.
|
||||
console.log("folderChange API closed");
|
||||
|
||||
// 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
|
||||
// remember this version of the module and continue to use it, even if your extension receives
|
||||
// an update.) You should *always* unload JSMs provided by your extension.
|
||||
Cu.unload(extension.getURL("modules/folderChange.jsm"));
|
||||
}
|
||||
};
|
||||
|
||||
// A helpful class for listening to windows opening and closing.
|
||||
// (This file had a lowercase E in Thunderbird 65 and earlier.)
|
||||
var { ExtensionSupport } = ChromeUtils.import(
|
||||
"resource:///modules/ExtensionSupport.jsm"
|
||||
);
|
||||
|
||||
var SysTrayX = {
|
||||
MESSAGE_COUNT_TYPE_UNREAD: 0,
|
||||
MESSAGE_COUNT_TYPE_NEW: 1,
|
||||
|
||||
version: 0,
|
||||
|
||||
countType: this.MESSAGE_COUNT_TYPE_UNREAD,
|
||||
|
||||
initialized: false,
|
||||
|
||||
accounts: undefined,
|
||||
filters: undefined,
|
||||
|
||||
currentMsgCount: null,
|
||||
newMsgCount: null,
|
||||
|
||||
callbackOnUnreadMailChange: undefined,
|
||||
callbackOnFolderChange: undefined,
|
||||
|
||||
init: function () {
|
||||
if (this.initialized) {
|
||||
console.warn("Folder listener already initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the mail accounts using MailServices
|
||||
this.getAccounts();
|
||||
|
||||
// Start listener
|
||||
MailServices.mailSession.AddFolderListener(
|
||||
this.mailSessionListener,
|
||||
this.mailSessionListener.notificationFlags
|
||||
);
|
||||
|
||||
this.initialized = true;
|
||||
},
|
||||
|
||||
shutdown: function () {
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop listener
|
||||
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
||||
|
||||
this.initialized = false;
|
||||
},
|
||||
|
||||
setVersion: function (version) {
|
||||
this.version = version;
|
||||
},
|
||||
|
||||
setCountType: function (type) {
|
||||
if (type === 0) {
|
||||
this.countType = this.MESSAGE_COUNT_TYPE_UNREAD;
|
||||
} else if (type === 1) {
|
||||
this.countType = this.MESSAGE_COUNT_TYPE_NEW;
|
||||
} else console.log("Unknown count type: " + type);
|
||||
|
||||
// Update count
|
||||
this.updateMsgCountWithCb();
|
||||
},
|
||||
|
||||
setFilters: function (filters) {
|
||||
this.filters = filters;
|
||||
|
||||
// Update count
|
||||
this.updateMsgCountWithCb();
|
||||
},
|
||||
|
||||
mailSessionListener: {
|
||||
notificationFlags:
|
||||
Ci.nsIFolderListener.added |
|
||||
Ci.nsIFolderListener.removed |
|
||||
Ci.nsIFolderListener.propertyFlagChanged |
|
||||
Ci.nsIFolderListener.boolPropertyChanged |
|
||||
Ci.nsIFolderListener.intPropertyChanged,
|
||||
|
||||
OnItemAdded(parentItem, item) {
|
||||
if (SysTrayX.callbackOnFolderChange) {
|
||||
SysTrayX.callbackOnFolderChange(
|
||||
"folder-changed",
|
||||
parentItem.rootFolder.prettyName,
|
||||
parentItem.prettyName,
|
||||
item.prettyName,
|
||||
true
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
OnItemRemoved(parentItem, item) {
|
||||
if (SysTrayX.callbackOnFolderChange) {
|
||||
SysTrayX.callbackOnFolderChange(
|
||||
"folder-changed",
|
||||
parentItem.rootFolder.prettyName,
|
||||
parentItem.prettyName,
|
||||
item.prettyName,
|
||||
false
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
OnItemIntPropertyChanged(item, property, oldValue, newValue) {
|
||||
// TotalUnreadMessages, BiffState (per server)
|
||||
this.onMsgCountChange(item, property, oldValue, newValue);
|
||||
},
|
||||
|
||||
OnItemBoolPropertyChanged: function (item, property, oldValue, newValue) {
|
||||
// NewMessages (per folder)
|
||||
this.onMsgCountChange(item, property, oldValue, newValue);
|
||||
},
|
||||
|
||||
OnItemPropertyFlagChanged: function (item, property, oldFlag, newFlag) {
|
||||
this.onMsgCountChange(item, property, oldFlag, newFlag);
|
||||
},
|
||||
|
||||
onMsgCountChange: function (item, property, oldValue, newValue) {
|
||||
let msgCountType = SysTrayX.countType;
|
||||
|
||||
let prop = property.toString();
|
||||
if (
|
||||
prop === "TotalUnreadMessages" &&
|
||||
msgCountType === SysTrayX.MESSAGE_COUNT_TYPE_UNREAD
|
||||
) {
|
||||
SysTrayX.updateMsgCountWithCb();
|
||||
} else {
|
||||
if (
|
||||
prop === "NewMessages" &&
|
||||
msgCountType === SysTrayX.MESSAGE_COUNT_TYPE_NEW
|
||||
) {
|
||||
if (oldValue === true && newValue === false) {
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=727460
|
||||
item.setNumNewMessages(0);
|
||||
}
|
||||
SysTrayX.updateMsgCountWithCb();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
updateMsgCountWithCb(callback) {
|
||||
if (callback === undefined || !callback) {
|
||||
callback = function (currentMsgCount, newMsgCount) {
|
||||
if (SysTrayX.callbackOnUnreadMailChange) {
|
||||
SysTrayX.callbackOnUnreadMailChange("unread-changed", newMsgCount);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let msgCountType = SysTrayX.countType;
|
||||
if (msgCountType === SysTrayX.MESSAGE_COUNT_TYPE_UNREAD) {
|
||||
this.countMessages("UnreadMessages");
|
||||
} else if (msgCountType === SysTrayX.MESSAGE_COUNT_TYPE_NEW) {
|
||||
this.countMessages("HasNewMessages");
|
||||
} else console.error("Unknown message count type: " + msgCountType);
|
||||
|
||||
// currentMsgCount and newMsgCount may be integers or bool, which do
|
||||
// also support comparison operations
|
||||
callback.call(this, this.currentMsgCount, this.newMsgCount);
|
||||
this.currentMsgCount = this.newMsgCount;
|
||||
},
|
||||
|
||||
countMessages(countType) {
|
||||
this.newMsgCount = 0;
|
||||
for (let accountServer of this.accounts) {
|
||||
// if (accountServer.type === ACCOUNT_SERVER_TYPE_IM) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (excludedAccounts.indexOf(accountServer.key) >= 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
this.applyToSubfolders(
|
||||
accountServer.prettyName,
|
||||
"",
|
||||
accountServer.rootFolder,
|
||||
true,
|
||||
function (path, folder) {
|
||||
this.msgCountIterate(
|
||||
countType,
|
||||
accountServer.prettyName,
|
||||
path,
|
||||
folder
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
applyToSubfolders(account, path, folder, recursive, fun) {
|
||||
if (folder.hasSubFolders) {
|
||||
let subFolders = folder.subFolders;
|
||||
if (this.version < 87) {
|
||||
while (subFolders.hasMoreElements()) {
|
||||
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
|
||||
if (recursive && subFolder.hasSubFolders)
|
||||
this.applyToSubfoldersRecursive(
|
||||
account,
|
||||
path,
|
||||
subFolder,
|
||||
recursive,
|
||||
fun
|
||||
);
|
||||
else fun.call(this, path, subFolder);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < subFolders.length; ++i) {
|
||||
let subFolder = subFolders[i].QueryInterface(Ci.nsIMsgFolder);
|
||||
if (recursive && subFolder.hasSubFolders)
|
||||
this.applyToSubfoldersRecursive(
|
||||
account,
|
||||
path,
|
||||
subFolder,
|
||||
recursive,
|
||||
fun
|
||||
);
|
||||
else fun.call(this, path, subFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
applyToSubfoldersRecursive(account, path, folder, recursive, fun) {
|
||||
fun.call(this, path, folder);
|
||||
this.applyToSubfolders(
|
||||
account,
|
||||
path + "/" + folder.prettyName,
|
||||
folder,
|
||||
recursive,
|
||||
fun
|
||||
);
|
||||
},
|
||||
|
||||
msgCountIterate(type, account, path, folder) {
|
||||
let count = false;
|
||||
|
||||
const folderPath = path + "/" + folder.prettyName;
|
||||
|
||||
if (SysTrayX.filters) {
|
||||
const match = SysTrayX.filters.filter((filter) => {
|
||||
function ciEquals(a, b) {
|
||||
return typeof a === "string" && typeof b === "string"
|
||||
? a.localeCompare(b, undefined, { sensitivity: "accent" }) === 0
|
||||
: a === b;
|
||||
}
|
||||
return (
|
||||
filter.folder.accountName === account &&
|
||||
ciEquals(filter.folder.path, folderPath)
|
||||
);
|
||||
});
|
||||
|
||||
count = match.length > 0;
|
||||
} else {
|
||||
count = folder.getFlag(Ci.nsMsgFolderFlags.Inbox);
|
||||
}
|
||||
|
||||
if (count) {
|
||||
SysTrayX["add" + type](folder);
|
||||
}
|
||||
},
|
||||
|
||||
addUnreadMessages(folder) {
|
||||
let folderUnreadMsgCount = folder["getNumUnread"](false);
|
||||
|
||||
/* nsMsgDBFolder::GetNumUnread basically returns mNumUnreadMessages +
|
||||
mNumPendingUnreadMessages, while mNumPendingUnreadMessages may get -1
|
||||
when updated from the cache. Which means getNumUnread might return -1. */
|
||||
if (folderUnreadMsgCount > 0) {
|
||||
this.newMsgCount += folderUnreadMsgCount;
|
||||
}
|
||||
},
|
||||
|
||||
addHasNewMessages(folder) {
|
||||
let folderNewMsgCount = folder.hasNewMessages;
|
||||
|
||||
if (folderNewMsgCount > 0) {
|
||||
this.newMsgCount += folderNewMsgCount;
|
||||
}
|
||||
},
|
||||
|
||||
getAccounts() {
|
||||
let accountServers = [];
|
||||
for (let accountServer of fixIterator(
|
||||
MailServices.accounts.accounts,
|
||||
Ci.nsIMsgAccount
|
||||
)) {
|
||||
accountServers.push(accountServer.incomingServer);
|
||||
}
|
||||
|
||||
/*
|
||||
for (let i = 0, len = accountServers.length; i < len; ++i) {
|
||||
console.debug(
|
||||
"ACCOUNT: " +
|
||||
accountServers[i].prettyName +
|
||||
" type: " +
|
||||
accountServers[i].type +
|
||||
" key: " +
|
||||
accountServers[i].key.toString()
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
// Store the accounts
|
||||
this.accounts = accountServers;
|
||||
},
|
||||
|
||||
add(callback) {
|
||||
this.callbackOnUnreadMailChange = callback;
|
||||
},
|
||||
|
||||
remove(callback) {
|
||||
this.callbackOnUnreadMailChange = undefined;
|
||||
},
|
||||
|
||||
addOnFolderChange(callback) {
|
||||
this.callbackOnFolderChange = callback;
|
||||
},
|
||||
|
||||
removeOnFolderChange(callback) {
|
||||
this.callbackOnFolderChange = undefined;
|
||||
},
|
||||
};
|
||||
@@ -10,19 +10,15 @@ SysTrayX.Accounts = {
|
||||
getAccounts: async function () {
|
||||
let accounts;
|
||||
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
accounts = await browser.accounts.list();
|
||||
} else {
|
||||
accounts = await browser.accounts.list(false);
|
||||
accounts = await browser.accounts.list(false);
|
||||
|
||||
// Fill the sub folders using the folders API, they are not same...
|
||||
for (let i = 0; i < accounts.length; ++i) {
|
||||
const subFolders = await browser.folders.getSubFolders(
|
||||
accounts[i],
|
||||
true
|
||||
);
|
||||
accounts[i].folders = subFolders;
|
||||
}
|
||||
// Fill the sub folders using the folders API, they are not same...
|
||||
for (let i = 0; i < accounts.length; ++i) {
|
||||
const subFolders = await browser.folders.getSubFolders(
|
||||
accounts[i],
|
||||
true
|
||||
);
|
||||
accounts[i].folders = subFolders;
|
||||
}
|
||||
|
||||
return accounts;
|
||||
@@ -173,25 +169,11 @@ SysTrayX.Accounts = {
|
||||
|
||||
// Create a usable folder tree
|
||||
let folders = [];
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 74) {
|
||||
// Pre TB74 accounts API
|
||||
folders = createFolderTreePre74(
|
||||
accounts[prop][i].name,
|
||||
accounts[prop][i].folders
|
||||
);
|
||||
} else if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
// TB74 - TB90? accounts API, (this shit never ends...)
|
||||
folders = createFolderTreePre91(
|
||||
accounts[prop][i].name,
|
||||
accounts[prop][i].folders
|
||||
);
|
||||
} else {
|
||||
// TB91+ accounts API, (this shit never ends...)
|
||||
folders = createFolderTree(
|
||||
accounts[prop][i].name,
|
||||
accounts[prop][i].folders
|
||||
);
|
||||
}
|
||||
|
||||
folders = createFolderTree(
|
||||
accounts[prop][i].name,
|
||||
accounts[prop][i].folders
|
||||
);
|
||||
|
||||
// Recursive list creator
|
||||
function createListLevel(level, parent) {
|
||||
@@ -226,10 +208,7 @@ SysTrayX.Accounts = {
|
||||
accountId: element.accountId,
|
||||
type: element.type != undefined ? element.type : "",
|
||||
path: element.path,
|
||||
name:
|
||||
SysTrayX.Info.browserInfo.majorVersion < 91
|
||||
? element.path.split("/").pop()
|
||||
: element.originalName
|
||||
name: element.originalName
|
||||
? element.originalName
|
||||
: element.name,
|
||||
version: SysTrayX.Info.version,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "systray-x@Ximi1970",
|
||||
"strict_min_version": "68.0",
|
||||
"strict_min_version": "91.0",
|
||||
"strict_max_version": "117.*"
|
||||
}
|
||||
},
|
||||
@@ -32,14 +32,6 @@
|
||||
},
|
||||
|
||||
"experiment_apis": {
|
||||
"folderChange": {
|
||||
"schema": "schema_folderchange.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"paths": [["folderChange"]],
|
||||
"script": "js/folderChange.js"
|
||||
}
|
||||
},
|
||||
"windowEvent": {
|
||||
"schema": "schema_windowEvent.json",
|
||||
"parent": {
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
var EXPORTED_SYMBOLS = ["folderChange"];
|
||||
|
||||
var folderChange = {
|
||||
};
|
||||
|
||||
console.log("Loading folderChange.jsm");
|
||||
@@ -1,14 +1,9 @@
|
||||
//
|
||||
// Get the prefered storage
|
||||
//
|
||||
function storage(store) {
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91 || store === "sync") {
|
||||
console.log("Using sync storage");
|
||||
return browser.storage.sync;
|
||||
} else {
|
||||
console.log("Using local storage");
|
||||
return browser.storage.local;
|
||||
}
|
||||
function storage() {
|
||||
console.log("Using local storage");
|
||||
return browser.storage.local;
|
||||
}
|
||||
|
||||
SysTrayX.SaveOptions = {
|
||||
@@ -24,55 +19,30 @@ SysTrayX.SaveOptions = {
|
||||
);
|
||||
|
||||
let filters = [];
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
let checkedFolders = [];
|
||||
accounts.forEach((account) => {
|
||||
if (account.checked || account.indeterminate) {
|
||||
// Find all selected folders
|
||||
const folders = Array.from(
|
||||
account.parentNode.querySelectorAll(
|
||||
'input[type="checkbox"]:not([name^="account"]):not([name^="parent-"])'
|
||||
)
|
||||
).filter((folder) => folder.checked);
|
||||
accounts.forEach((account) => {
|
||||
if (account.checked || account.indeterminate) {
|
||||
// Find all selected folders
|
||||
const folders = Array.from(
|
||||
account.parentNode.querySelectorAll(
|
||||
'input[type="checkbox"]:not([name^="account"]):not([name^="parent-"])'
|
||||
)
|
||||
).filter((folder) => folder.checked);
|
||||
|
||||
checkedFolders = checkedFolders.concat(folders);
|
||||
if (folders.length > 0) {
|
||||
const mailFolderExt = JSON.parse(folders[0].value);
|
||||
filters.push({
|
||||
accountId: mailFolderExt.accountId,
|
||||
version: mailFolderExt.version,
|
||||
folders: [],
|
||||
});
|
||||
|
||||
folders.forEach((folder) => {
|
||||
const mailFolderExt = JSON.parse(folder.value);
|
||||
filters[filters.length - 1].folders.push(mailFolderExt.path);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
checkedFolders.forEach((folder) => {
|
||||
const mailFolderExt = JSON.parse(folder.value);
|
||||
|
||||
filters.push({
|
||||
unread: true,
|
||||
folder: mailFolderExt,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
accounts.forEach((account) => {
|
||||
if (account.checked || account.indeterminate) {
|
||||
// Find all selected folders
|
||||
const folders = Array.from(
|
||||
account.parentNode.querySelectorAll(
|
||||
'input[type="checkbox"]:not([name^="account"]):not([name^="parent-"])'
|
||||
)
|
||||
).filter((folder) => folder.checked);
|
||||
|
||||
if (folders.length > 0) {
|
||||
const mailFolderExt = JSON.parse(folders[0].value);
|
||||
filters.push({
|
||||
accountId: mailFolderExt.accountId,
|
||||
version: mailFolderExt.version,
|
||||
folders: [],
|
||||
});
|
||||
|
||||
folders.forEach((folder) => {
|
||||
const mailFolderExt = JSON.parse(folder.value);
|
||||
filters[filters.length - 1].folders.push(mailFolderExt.path);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Store extended query filters
|
||||
|
||||
@@ -1157,25 +1127,10 @@ SysTrayX.RestoreOptions = {
|
||||
|
||||
if (inbox.length > 0) {
|
||||
let folder = {};
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
folder = {
|
||||
...inbox[0],
|
||||
accountName: account.name,
|
||||
path: "/" + inbox[0].name,
|
||||
};
|
||||
delete folder.type;
|
||||
delete folder.subFolders;
|
||||
|
||||
filters.push({
|
||||
unread: true,
|
||||
folder: folder,
|
||||
});
|
||||
} else {
|
||||
filters.push({
|
||||
accountId: inbox[0].accountId,
|
||||
folders: [inbox[0].path],
|
||||
});
|
||||
}
|
||||
filters.push({
|
||||
accountId: inbox[0].accountId,
|
||||
folders: [inbox[0].path],
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1183,22 +1138,20 @@ SysTrayX.RestoreOptions = {
|
||||
if (filters) {
|
||||
const treeBase = document.getElementById("accountsTree");
|
||||
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
filters.forEach((filter) => {
|
||||
const folder = filter.folder;
|
||||
|
||||
const account = treeBase.querySelector(
|
||||
`input[name=${folder.accountId}]`
|
||||
);
|
||||
const checkboxes = Array.from(
|
||||
account.parentNode.querySelectorAll(
|
||||
'input[type="checkbox"]:not([name^="account"]):not([name^="parent-"])'
|
||||
)
|
||||
);
|
||||
filters.forEach((filter) => {
|
||||
const account = treeBase.querySelector(
|
||||
`input[name=${filter.accountId}]`
|
||||
);
|
||||
const checkboxes = Array.from(
|
||||
account.parentNode.querySelectorAll(
|
||||
'input[type="checkbox"]:not([name^="account"]):not([name^="parent-"])'
|
||||
)
|
||||
);
|
||||
|
||||
filter.folders.forEach((path) => {
|
||||
checkboxes.forEach((checkbox) => {
|
||||
const value = JSON.parse(checkbox.value);
|
||||
if (value.path === folder.path) {
|
||||
if (value.path === path) {
|
||||
checkbox.checked = true;
|
||||
|
||||
const event = document.createEvent("HTMLEvents");
|
||||
@@ -1207,31 +1160,7 @@ SysTrayX.RestoreOptions = {
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
filters.forEach((filter) => {
|
||||
const account = treeBase.querySelector(
|
||||
`input[name=${filter.accountId}]`
|
||||
);
|
||||
const checkboxes = Array.from(
|
||||
account.parentNode.querySelectorAll(
|
||||
'input[type="checkbox"]:not([name^="account"]):not([name^="parent-"])'
|
||||
)
|
||||
);
|
||||
|
||||
filter.folders.forEach((path) => {
|
||||
checkboxes.forEach((checkbox) => {
|
||||
const value = JSON.parse(checkbox.value);
|
||||
if (value.path === path) {
|
||||
checkbox.checked = true;
|
||||
|
||||
const event = document.createEvent("HTMLEvents");
|
||||
event.initEvent("change", false, true);
|
||||
checkbox.dispatchEvent(event);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1472,11 +1401,6 @@ async function start() {
|
||||
"https://github.com/Ximi1970/systray-x/releases/tag/" +
|
||||
SysTrayX.Info.version;
|
||||
|
||||
// Disable incompatible items
|
||||
if (SysTrayX.Info.browserInfo.majorVersion > 89 && SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||
document.getElementById("counttype").style.display = "none";
|
||||
}
|
||||
|
||||
// Set the right default icon
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 115) {
|
||||
document.getElementById("defaultCustomIconImage").setAttribute("src","icons/Thunderbird.png");
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
[
|
||||
{
|
||||
"namespace": "folderChange",
|
||||
"functions": [
|
||||
{
|
||||
"name": "setVersion",
|
||||
"type": "function",
|
||||
"description": "Set the TB version.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "version",
|
||||
"minimum": 0,
|
||||
"maximum": 999
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "setCountType",
|
||||
"type": "function",
|
||||
"description": "Set the count type.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "type",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "setFilters",
|
||||
"type": "function",
|
||||
"description": "Set the account filters.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"name": "filters",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"unread": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accountName": {
|
||||
"type": "string"
|
||||
},
|
||||
"accountId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "onUnreadMailChange",
|
||||
"type": "function",
|
||||
"description": "Fires when there is a change in the number of unread mails.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "unread",
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "onFolderChange",
|
||||
"type": "function",
|
||||
"description": "Fires when there is a folder added or removed.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "rootFolder",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "parentFolder",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "folder",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "added",
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user