valinet / ThunderbirdToasts

Thunderbird Toasts is a simple framework that allows Thunderbird to send Windows 10 toasts as notifications instead of its custom popup notifications that are not native.
GNU General Public License v3.0
26 stars 3 forks source link

Thunderbird Toasts

Thunderbird Toasts is a simple framework that allows Thunderbird to send Windows 10 toasts as notifications instead of its custom popup notifications that are not native. It works on Thunderbird 78+ as of January 2021 and can be thought of as a replacement for now defunct GNotifier.

Features

The intent is for this to become flagship, showcase product of pure C programming and interfacing with the Microsoft Windows operating system.

Installation

An installation package is available in the releases section of this repository.

To begin, download the latest available release. It comes in the form of an executable file, usually called setup_thunderbird_toasts.exe.

Before starting the installation, make sure that you saved all your work in Thunderbird, as the program will be reloaded so that the new add-on gets loaded in the program. Then, open the downloaded file and once it is done, a notification should pop-up and Thunderbird will open back up.

Now, you have to open the Add-ons Manager (Tools - Add-ons) and enable the extension in there, by toggling the switch near its name. Then, click "Enable" in the confirmation dialog.

To configure the add-on, click the settings icon and choose Options.

As you can see, the installation process is fully automated and self contained. The files are installed in your profile folder, in the following directory:

C:\Users\Valentin\AppData\Roaming\ThunderbirdToasts

Additionally, the extension is naturally placed in your Thunderbird profile directory (Help - Troubleshooting Information - Open Profile).

The following registry keys are created by the installer:

When you open the program for the first time, a Windows Firewall warning like the following may pop up. Please allow communications on all networks (the components internally communicate over local network sockets).

Configuration

The options page presents a host of options that can help you customize the behavior of the add-on.

Text fields on the toast notifications that you can customize provide a series of variables that will be replaced with the particular value from the mail message for which the toast is displayed. The current list of variables is:

More options may be provided in the future, and they will surely be mentioned here. Please suggest new, useful variables or functions here.

Next. a brief explanation for each of the options the add-on supports is presented below. The default values are displayed besides each of the settings, so that it is easy to revert to factory configs. All the available tweaks are automatically saved.

Inner workings

The product is made out of two main components:

A custom URI scheme (protocol handler), thunderbirdtoasts:// is installed on the system, allowing clicked toasts to open back in the Thunderbird application. The format of a request to this system is the following:

thunderbirdtoasts://111111111111/3682732184834846b73483784==

Where:

Internally, the protocol handler instance and the background process instance communicate via a socket that runs on the fixed TCP port 46578 (chosen randomly, fixed). Supported commands are similar to the URI schema, thus, you can make similar requests to the one above by using HTTP and standard client like:

curl 127.0.0.1:46578/111111111111/3682732184834846b73483784==

This will use the GET request of the HTTP protocol. You can send a random POST request to trigger a random notification to pop up (for testing purposes), while a DELETE request will uninstall the add-on.

More details

I will publish more in-depth details soon, probably as a series of articles on my web site, for when time will allow.

This is a very good teaching example in my opinion, as it helps broaden your knowledge in a few diverse areas:

Sources

ALL sources are available in this repository.

Compiling

To put together the add-on, simply zip the contents of its "src" folder, change the extension to xpi and load in Thunderbird.

For details about the C native client, check the README in its folder: src\native-app.

License

This product uses code from the following third party repositories:

Taking into consideration the licenses of the individual components, the combined work of this project is released under GNU General Public License v3.0 or newer.

Additionally, I license all my original work that's separate from the third party bits used in this project under MIT license.