![]() |
Delta Chat Core C Interface
|
This document describes how to handle the Delta Chat core library. For general information about Delta Chat itself, see https://delta.chat and https://github.com/deltachat.
Let's start.
First of all, you have to create a context object bound to a database. The database is a normal SQLite file with a "blob directory" beside it. This will create "example.db" database and "example.db-blobs" directory if they don't exist already:
After that, make sure you can receive events from the context. For that purpose, create an event emitter you can ask for events. If there is no event, the emitter will wait until there is one, so, in many situations, you will do this in a thread:
The example above uses "pthreads", however, you can also use anything else for thread handling. All deltachat-core functions, unless stated otherwise, are thread-safe.
Now you can configure the context:
dc_configure() returns immediately. The configuration itself runs in the background and may take a while. Once done, the DC_EVENT_CONFIGURE_PROGRESS reports success to the event_handler() you've defined above.
The configuration result is saved in the database. On subsequent starts it is not needed to call dc_configure() (you can check this using dc_is_configured()).
On a successfully configured context, you can finally connect to the servers:
Now you can send the first message:
dc_send_text_msg() returns immediately; the sending itself is done in the background. If you check the testing address (bob), you should receive a normal e-mail. Answer this e-mail in any e-mail program with "Got it!", and the IO you started above will receive the message.
You can then list all messages of a chat as follows:
This will output the following two lines:
For a class reference, see the "Classes" link atop.
Here are some additional, unsorted hints that may be useful.
get
-functions, you have to unref the return value in some way.If you need further assistance, please do not hesitate to contact us through the channels shown at https://delta.chat/en/contribute
Please keep in mind, that your derived work must respect the Mozilla Public License 2.0 of libdeltachat and the respective licenses of the libraries libdeltachat links with.
See you.