This is the story of building an open source email service that runs natively on a Linux desktop with the help of the Electron framework.

Tutanota is a secure, open source email service that is available through a browser as well as iOS and Android apps. The client code is released under GPLv3, and Android applications are available on the F-Droid so that everyone can use a completely Google-independent version.

Because Of Tutanota’s focus on open source and Linux client development, we wanted to release a desktop application for Linux and other platforms. As a small team, we quickly ruled out building native applications for Linux, Windows, and MacOS and decided to use Electron to build our application.

Electron is the perfect choice for anyone who wants to quickly deliver visually consistent cross-platform applications, especially if you already have a Web application and want to break free from the confines of a browser API. Tutanota is one such case.

Based on SystemJS and Mithril, Tutanota aims to provide simple, secure email communication for everyone. Therefore, it must provide many of the standard features that users expect from E-mail clients.

Some of these features, such as basic push notifications, search text and contacts, and support for two-factor authentication, are easily available in the browser thanks to modern apis and standards. Other features (such as automatic backups or IMAP support that doesn’t need to be relayed by our server) require restricted access to system resources, which is what the Electron framework provides.

While the Electron has been criticized for being “just a basic package,” it has obvious benefits:

  • Electron enables you to quickly build Web applications for Linux, Windows, and MacOS desktops. In fact, most Linux desktop applications are built using Electron.
  • Electron can easily bring desktop clients and Web applications to the same level of functionality.
  • Once you publish your desktop application, you are free to use the development features to add desktop-specific features to enhance usability and security.
  • Last but not least, it’s a great way to make your application feel native and integrated into the user’s system while maintaining its identity.

Meet user requirements

Tutanota does not rely on large investments, but on community-driven projects. We grew our team organically as more and more users upgraded to paid plans for our free service. Listening to our users is not only important to us, it’s critical to our success.

Providing a desktop client is the feature that Tutanota users want most, and we are proud that we can now offer a free desktop client beta to all users. (We also implemented another highly demanding feature — searching encrypted data — but that’s a topic for another day.)

We like to give users a signed version of Tutanota and support features that are not available in browsers, such as push notifications via background processes. Now, we plan to add more desktop-specific features such as IMAP support (without relying on our server to act as a proxy), automatic backup, and offline availability.

We chose Electron because its combination of Chromium and Node.js is best suited for our small development team as it requires minimal changes to our Web application. It was particularly useful to be able to use the browser API for all functionality when we started, slowly replacing these components with more native versions as we progressed. This approach is especially convenient for attachment downloads and notifications.

Adjusting safety

We know some people have concerns about Electron’s security, but we find Electron’s options for fine-tuning access in Web applications very satisfying. You can use resources like Electron’s security documentation and Luca Carettoni’s Electron Security Checklist to help prevent catastrophic accidents from happening to untrusted content in your Web applications.

Implement specific functionality

The Tutanota Web client has built a reliable protocol for interprocess communication from the beginning. We leverage Web threads to keep the user interface (UI) responsive while encrypting and requesting data. This came in handy when we started implementing our mobile applications, which used the same protocol to communicate between the native part and the Web view.

That’s why when we started building the desktop client, a lot of the parts for native push notifications, opening mailboxes, and using file systems already existed, so we just needed to implement the native side (Node.js).

Another convenience was that our build process used the Babel translator, which allowed us to write the entire code base in modern ES6 JavaScript and mix and match functional modules between different environments. This allowed us to quickly tweak the code for our Electron based desktop application. However, we also encountered some challenges.

To overcome the challenges

While Electron allows us to easily integrate with desktop environments on different platforms, you can’t underestimate the time commitment! In the end, it was these little things that took more time than we expected, but were also critical to completing the desktop client project.

Platform-specific code causes most of the obstruction:

  • For example, window management and pallets are still handled slightly differently on the three platforms.
  • Registering Tutanota as the default mail program and setting up automatic startup requires digging deep into the Windows registry and ensuring that users are prompted for administrator access in a [UAC] 12-compatible manner.
  • We need to use Electron’s API as a shortcut and menu to provide standard features like copy, paste, undo, and redo.

This process is complicated by user expectations of certain (and sometimes incompatible) behavior from applications on different platforms. Making the three versions feel native will require some iteration, and even some modest additions to the Web application to provide functionality similar to text search in the browser.

conclusion

Our experience with Electron has been largely positive and we completed the project in less than four months. Despite some fairly time-consuming features, we were surprised that we could easily provide a beta version of the Tutanota desktop client for Linux. If you’re interested, you can dig into the source code on GitHub.


Via: opensource.com/article/19/…

By Nils Ganther, lujun9972

This article is originally compiled by LCTT and released in Linux China