Delta Chat Core C-API
Getting started

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 a function that is called by the library on specific events (eg. when the configuration is done or when fresh messages arrive). Your function should look like the following:

#include <mrmailbox.h>
uintptr_t my_delta_handler(mrmailbox_t* nb, int event, uintptr_t data1, uintptr_t data2)
{
return 0; // for unhandled events, it is always safe to return 0
}

After that, you can create and configure a mrmailbox_t object easily as follows:

mrmailbox_t* mb = mrmailbox_new(my_delta_handler, NULL, NULL);
mrmailbox_set_config(mb, "addr", "alice@delta.chat"); // use some real test credentials here
mrmailbox_set_config(mb, "mail_pw", "***");

After that, you can send your first message:

uint32_t contact_id = mrmailbox_create_contact(mb, "bob@delta.chat"); // use a real testing address here
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mb, contact_id);
mrmailbox_send_text_msg(mb, chat_id, "Hi, here is my first message!");

Now, go to the testing address (bob) and you should have received a normal email. Answer this email in any email program with "Got it!" and you will get the message from delta as follows:

carray* msglist = mrmailbox_get_chat_msgs(mb, chat_id, 0, 0);
for( size_t i = 0; i < carray_count(msglist); i++ )
{
uint32_t msg_id = carray_get_uint32(msglist, i);
mrmsg_t* msg = mrmailbox_get_msg(mb, msg_id);
printf("message %i: %s\n", i+1, msg->m_text);
}

This will output the following two lines:

Message 1: Hi, here is my first message!
Message 2: Got it!

I think, you got the idea. For further reading, please dive into the mrmailbox_t class.

Further hints

Here are some additional, unsorted hints that may be useful. If you need any further assistance, please do not hesitate to contact us at r10s@.nosp@m.b44t.nosp@m..com.

The following points are important mainly for the authors of the library itself:

Please keep in mind, that your derived work must be released under a GPL-compatible licence. For details, please have a look at the LICENSE file accompanying the source code.

See you.