as discussed in several chats, this PR starts making it possible to use Webxdc as integrations to the main app. In other word: selected parts of the main app can be integrated as Webxdc, eg. Maps [^1] this PR contains two parts: - draft an Webxdc Integration API - use the Webxdc Integration API to create a Maps Integration to be clear: a Webxdc is not part of this PR. the PR is about marking a Webxdc being used as a Map - and core then feeds the Webxdc with location data. from the view of the Webxdc, the normal `sendUpdate()`/`setUpdateListener()` is used. things are still marked as "experimental", idea is to get that in to allow @adbenitez and @nicodh to move forward on the integrations into android and desktop, as well as improving the maps.xdc itself. good news is that we currently can change the protocol between Webxdc and core at any point :) # Webxdc Integration API see `dc_init_webxdc_integration()` in `deltachat.h` for overview and documentation. rust code is mostly in `webxdc/integration.rs` that is called by other places as needed. current [user of the API is deltachat-ios](https://github.com/deltachat/deltachat-ios/pull/1912), android/desktop will probably follow. the jsonrpc part is missing and can come in another PR when things are settled and desktop is really starting [^2] (so we won't need to do all iterations twice :) makes also sense, when this is done by someone actually trying that out on desktop while the API is prepared to allow other types of integrations (photo editor, compose tools ...) internally, we currently ignore the type. if that gets more crazy, we probably also need a dedicated table for the integrations and not just a single param. # Maps Integration rust code is mostly in `webxdc/maps_integration.rs` that is called by `webxdc/integration.rs` as needed. EDIT: the idea of having a split here, is that `webxdc/maps_integration.rs` really can focus on the json part, on the communication with the .xdc, including tests this PR is basic implementation, enabling to move forward on integrations on iOS, but also on desktop and android. the current implementation allows already the following: - global and per-chat maps - add and display POIs - show positions and tracks of the last 24 hours the current maps.xdc uses leaflet, and is in some regards better than the current android/desktop implementations (much faster, show age of positions, fade out positions, always show names of POIs, clearer UI). however, we are also not bound to leaflet, it can be anything > [**screenshots of the current state**](https://github.com/deltachat/deltachat-ios/pull/1912) > 👆 to move forward faster and to keep this PR small, the following will go to a subsequent PR: - consider allowing webxdc to use a different timewindow for the location - delete POIs - jsonrpc [^1]: maps are a good example as anyways barely native (see android app), did cause a lot of pain on many levels in the past (technically, bureaucratically), and have a comparable simple api [^2]: only going for jsonrpc would only make sense if large parts of android/ios would use jsonrpc, we're not there --------- Co-authored-by: link2xt <link2xt@testrun.org>
The core library for Delta Chat, written in Rust
Installing Rust and Cargo
To download and install the official compiler for the Rust programming language, and the Cargo package manager, run the command in your user environment:
$ curl https://sh.rustup.rs -sSf | sh
On Windows, you may need to also install Perl to be able to compile deltachat-core.
Using the CLI client
Compile and run Delta Chat Core command line utility, using cargo:
$ cargo run -p deltachat-repl -- ~/deltachat-db
where ~/deltachat-db is the database file. Delta Chat will create it if it does not exist.
Optionally, install deltachat-repl binary with
$ cargo install --path deltachat-repl/
and run as
$ deltachat-repl ~/deltachat-db
Configure your account (if not already configured):
Delta Chat Core is awaiting your commands.
> set addr your@email.org
> set mail_pw yourpassword
> configure
Connect to your mail server (if already configured):
> connect
Create a contact:
> addcontact yourfriends@email.org
Command executed successfully.
List contacts:
> listcontacts
Contact#10: <name unset> <yourfriends@email.org>
Contact#1: Me √√ <your@email.org>
Create a chat with your friend and send a message:
> createchat 10
Single#10 created successfully.
> chat 10
Single#10: yourfriends@email.org [yourfriends@email.org]
> send hi
Message sent.
If yourfriend@email.org uses DeltaChat, but does not receive message just
sent, it is advisable to check Spam folder. It is known that at least
gmx.com treat such test messages as spam, unless told otherwise with web
interface.
List messages when inside a chat:
> chat
For more commands type:
> help
Installing libdeltachat system wide
$ git clone https://github.com/deltachat/deltachat-core-rust.git
$ cd deltachat-core-rust
$ cmake -B build . -DCMAKE_INSTALL_PREFIX=/usr
$ cmake --build build
$ sudo cmake --install build
Development
# run tests
$ cargo test --all
# build c-ffi
$ cargo build -p deltachat_ffi --release
Debugging environment variables
-
DCC_MIME_DEBUG: if set outgoing and incoming message will be printed -
RUST_LOG=async_imap=trace,async_smtp=trace: enable IMAP and SMTP tracing in addition to info messages.
Expensive tests
Some tests are expensive and marked with #[ignore], to run these
use the --ignored argument to the test binary (not to cargo itself):
$ cargo test -- --ignored
Fuzzing
Install cargo-bolero with
$ cargo install cargo-bolero
Run fuzzing tests with
$ cd fuzz
$ cargo bolero test fuzz_mailparse --release=false -s NONE
Corpus is created at fuzz/fuzz_targets/corpus,
you can add initial inputs there.
For fuzz_mailparse target corpus can be populated with
../test-data/message/*.eml.
To run with AFL instead of libFuzzer:
$ cargo bolero test fuzz_format_flowed --release=false -e afl -s NONE
Features
vendored: When using Openssl for TLS, this bundles a vendored version.nightly: Enable nightly only performance and security related features.
Update Provider Data
To add the updates from the provider-db to the core, run:
./src/provider/update.py ../provider-db/_providers/ > src/provider/data.rs
Language bindings and frontend projects
Language bindings are available for:
- C [📂 source | 📚 docs]
- Node.js
- Python [📂 source | 📦 pypi | 📚 docs]
- Go
- Free Pascal1 [📂 source]
- Java and Swift (contained in the Android/iOS repos)
The following "frontend" projects make use of the Rust-library or its language bindings:
-
Out of date / unmaintained, if you like those languages feel free to start maintaining them. If you have questions we'll help you, please ask in the issues. ↩︎
