![]() |
Delta Chat Core C-API
|
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 define an event-handler-function that is called by the library on specific events (eg. when the configuration is done or when fresh messages arrive). With this function you can create a Delta Chat context then:
After that, you should make sure, sending and receiving jobs are processed as needed. For this purpose, you have to create two threads:
The example above uses "pthreads", however, you can also use anything else for thread handling. NB: The deltachat-core library itself does not create any threads on its own, however, functions, unless stated otherwise, are thread-safe.
After that you can define and open a database. The database is a normal sqlite-file and is created as needed:
Now you can configure the context:
dc_configure() returns immediately, the configuration itself may take a while and is done by a job in the imap-thread you've defined above. Once done, the DC_EVENT_CONFIGURE_PROGRESS reports success to the event_handler_func() that is also 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()).
Now you can send the first message:
dc_send_text_msg() returns immediately; the sending itself is done by a job in the smtp-thread you've defined above. If you check the testing address (bob) and you should have received a normal email. Answer this email in any email program with "Got it!" and the imap-thread you've create above will receive the message.
You can then list all messages of a chat as follow:
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.The following points are important mainly for the authors of the library itself:
LF
, 0x0A
or \n
)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.