C deltachat interface

See low level API reference for accessing many of the below functions through the deltachat.capi.lib namespace.

struct CRYPTO_dynlock_value

Public Members

pthread_mutex_t mutex
class dc_array_t
#include <deltachat.h>

An object containing a simple array.

This object is used in several places where functions need to return an array. The items of the array are typically IDs. To free an array object, use dc_array_unref().

Public Functions

double dc_array_get_accuracy(const dc_array_t *array, size_t index)

Return the accuracy of the item at the given index.

See dc_set_location() for more information about the accuracy.

Return

Accuracy of the item at the given index. 0.0 if there is no longitude bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

uint32_t dc_array_get_chat_id(const dc_array_t *array, size_t index)

Return the chat-id of the item at the given index.

Return

Chat-id of the item at the given index. 0 if there is no chat-id bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

size_t dc_array_get_cnt(const dc_array_t *array)

Find out the number of items in an array.

Return

Returns the number of items in a dc_array_t object. 0 on errors or if the array is empty.

Parameters
  • array: The array object.

uint32_t dc_array_get_contact_id(const dc_array_t *array, size_t index)

Return the contact-id of the item at the given index.

Return

Contact-id of the item at the given index. 0 if there is no contact-id bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

uint32_t dc_array_get_id(const dc_array_t *array, size_t index)

Get the item at the given index as an ID.

Return

Returns the item at the given index. Returns 0 on errors or if the array is empty.

Parameters
  • array: The array object.

  • index: Index of the item to get. Must be between 0 and dc_array_get_cnt()-1.

double dc_array_get_latitude(const dc_array_t *array, size_t index)

Return the latitude of the item at the given index.

Return

Latitude of the item at the given index. 0.0 if there is no latitude bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

double dc_array_get_longitude(const dc_array_t *array, size_t index)

Return the longitude of the item at the given index.

Return

Latitude of the item at the given index. 0.0 if there is no longitude bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

char *dc_array_get_marker(const dc_array_t *array, size_t index)

Return the marker-character of the item at the given index.

Marker-character are typically bound to locations returned by dc_get_locations() and are typically created by on-character-messages which can also be an emoticon :)

Return

Marker-character of the item at the given index. NULL if there is no marker-character bound to the given item. The returned value must be free()’d after usage.

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

uint32_t dc_array_get_msg_id(const dc_array_t *array, size_t index)

Return the message-id of the item at the given index.

Return

Message-id of the item at the given index. 0 if there is no message-id bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

void *dc_array_get_ptr(const dc_array_t *array, size_t index)

Get the item at the given index as an ID.

Return

Returns the item at the given index. Returns 0 on errors or if the array is empty.

Parameters
  • array: The array object.

  • index: Index of the item to get. Must be between 0 and dc_array_get_cnt()-1.

const uintptr_t *dc_array_get_raw(const dc_array_t *array)

Get raw pointer to the data.

Return

Raw pointer to the array. You MUST NOT free the data. You MUST NOT access the data beyond the current item count. It is not possible to enlarge the array this way. Calling any other dc_array*()-function may discard the returned pointer.

Parameters
  • array: The array object.

time_t dc_array_get_timestamp(const dc_array_t *array, size_t index)

Return the timestamp of the item at the given index.

Return

Timestamp of the item at the given index. 0 if there is no timestamp bound to the given item,

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

uintptr_t dc_array_get_uint(const dc_array_t *array, size_t index)

Get the item at the given index as an unsigned integer.

The size of the integer is always larget enough to hold a pointer.

Return

Returns the item at the given index. Returns 0 on errors or if the array is empty.

Parameters
  • array: The array object.

  • index: Index of the item to get. Must be between 0 and dc_array_get_cnt()-1.

int dc_array_is_independent(const dc_array_t *array, size_t index)

Return the independent-state of the location at the given index.

Independent locations do not belong to the track of the user.

Return

0=Location belongs to the track of the user, 1=Location was reported independently.

Parameters
  • array: The array object.

  • index: Index of the item. Must be between 0 and dc_array_get_cnt()-1.

void dc_array_unref(dc_array_t *array)

Free an array object.

Does not free any data items.

Return

None.

Parameters

Private Functions

dc_array_t *dc_array_duplicate(const dc_array_t *array)

Duplicates the array, take care if the array contains pointers to objects, take care to free them only once afterwards! If the array only contains integers, you are always save.

Return

The duplicated array.

Parameters
  • array: The array object.

void dc_array_empty(dc_array_t *array)

Empty an array object.

Allocated data is not freed by this function, only the count is set to null.

Return

None.

Parameters
  • array: The array object to empty.

void dc_array_free_ptr(dc_array_t *array)

Calls free() for each item and sets the item to 0 afterwards.

The array object itself is not deleted and the size of the array stays the same.

Return

None.

Parameters
  • array: The array object.

dc_array_t *dc_array_new_typed(dc_context_t *context, int type, size_t initsize)

Create an array object in memory.

Return

New array object of the requested size, the data should be set directly.

Parameters
  • context: The context object that should be stored in the array object. May be NULL.

  • type: 0 for a standard array of int or one of DC_ARRAY_*.

  • initsize: Initial maximal size of the array. If you add more items, the internal data pointer is reallocated.

int dc_array_search_id(const dc_array_t *array, uint32_t needle, size_t *ret_index)

Check if a given ID is present in an array.

Return

1=ID is present in array, 0=ID not found.

Parameters
  • array: The array object to search in.

  • needle: The ID to search for.

  • [out] ret_index: If set, this will receive the index. Set to NULL if you’re not interested in the index.

void dc_array_sort_ids(dc_array_t *array)

Sort the array, assuming it contains unsigned integers.

Return

The duplicated array.

Parameters
  • array: The array object.

void dc_array_sort_strings(dc_array_t *array)

Sort the array, assuming it contains pointers to strings.

Return

The duplicated array.

Parameters
  • array: The array object.

class dc_chat_t
#include <deltachat.h>

An object representing a single chat in memory.

Chat objects are created using eg. dc_get_chat() and are not updated on database changes; if you want an update, you have to recreate the object.

Public Functions

int dc_chat_get_archived(const dc_chat_t *chat)

Get archived state.

  • 0 = normal chat, not archived, not sticky.

  • 1 = chat archived

  • 2 = chat sticky (reserved for future use, if you do not support this value, just treat the chat as a normal one)

To archive or unarchive chats, use dc_archive_chat(). If chats are archived, this should be shown in the UI by a little icon or text, eg. the search will also return archived chats.

Return

Archived state.

Parameters
  • chat: The chat object.

uint32_t dc_chat_get_color(const dc_chat_t *chat)

Get a color for the chat.

For 1:1 chats, the color is calculated from the contact’s email address. Otherwise, the chat name is used. The color can be used for an fallback avatar with white initials as well as for headlines in bubbles of group chats.

Return

Color as 0x00rrggbb with rr=red, gg=green, bb=blue each in the range 0-255.

Parameters
  • chat: The chat object.

uint32_t dc_chat_get_id(const dc_chat_t *chat)

Get chat ID.

The chat ID is the ID under which the chat is filed in the database.

Special IDs:

  • DC_CHAT_ID_DEADDROP (1) - Virtual chat containing messages which senders are not confirmed by the user.

  • DC_CHAT_ID_STARRED (5) - Virtual chat containing all starred messages-

  • DC_CHAT_ID_ARCHIVED_LINK (6) - A link at the end of the chatlist, if present the UI should show the button “Archived chats”-

“Normal” chat IDs are larger than these special IDs (larger than DC_CHAT_ID_LAST_SPECIAL).

Return

Chat ID. 0 on errors.

Parameters
  • chat: The chat object.

char *dc_chat_get_name(const dc_chat_t *chat)

Get name of a chat.

For one-to-one chats, this is the name of the contact. For group chats, this is the name given eg. to dc_create_group_chat() or received by a group-creation message.

To change the name, use dc_set_chat_name()

See also: dc_chat_get_subtitle()

Return

Chat name as a string. Must be free()’d after usage. Never NULL.

Parameters
  • chat: The chat object.

char *dc_chat_get_profile_image(const dc_chat_t *chat)

Get the chat’s profile image.

For groups, this is the image set by any group member using dc_set_chat_profile_image(). For normal chats, this is the image set by each remote user on their own using dc_set_config(context, “selfavatar”, image).

Return

Path and file if the profile image, if any. NULL otherwise. Must be free()’d after usage.

Parameters
  • chat: The chat object.

char *dc_chat_get_subtitle(const dc_chat_t *chat)

Get a subtitle for a chat.

The subtitle is eg. the email-address or the number of group members.

See also: dc_chat_get_name()

Return

Subtitle as a string. Must be free()’d after usage. Never NULL.

Parameters
  • chat: The chat object to calulate the subtitle for.

int dc_chat_get_type(const dc_chat_t *chat)

Get chat type.

Currently, there are two chat types:

  • DC_CHAT_TYPE_SINGLE (100) - a normal chat is a chat with a single contact, chats_contacts contains one record for the user. DC_CONTACT_ID_SELF (see dc_contact_t::id) is added only for a self talk.

  • DC_CHAT_TYPE_GROUP (120) - a group chat, chats_contacts contain all group members, incl. DC_CONTACT_ID_SELF

  • DC_CHAT_TYPE_VERIFIED_GROUP (130) - a verified group chat. In verified groups, all members are verified and encryption is always active and cannot be disabled.

Return

Chat type.

Parameters
  • chat: The chat object.

int dc_chat_is_self_talk(const dc_chat_t *chat)

Check if a chat is a self talk.

Self talks are normal chats with the only contact DC_CONTACT_ID_SELF.

Return

1=chat is self talk, 0=chat is no self talk

Parameters
  • chat: The chat object.

int dc_chat_is_sending_locations(const dc_chat_t *chat)

Check if locations are sent to the chat at the time the object was created using dc_get_chat().

To check if locations are sent to any chat, use dc_is_sending_locations_to_chat().

Return

1=locations are sent to chat, 0=no locations are sent to chat

Parameters
  • chat: The chat object.

int dc_chat_is_unpromoted(const dc_chat_t *chat)

Check if a group chat is still unpromoted.

After the creation with dc_create_group_chat() the chat is usually unpromoted until the first call to dc_send_text_msg() or another sending function.

With unpromoted chats, members can be added and settings can be modified without the need of special status messages being sent.

While the core takes care of the unpromoted state on its own, checking the state from the UI side may be useful to decide whether a hint as “Send the first message to allow others to reply within the group” should be shown to the user or not.

Return

1=chat is still unpromoted, no message was ever send to the chat, 0=chat is not unpromoted, messages were send and/or received or the chat is not group chat.

Parameters
  • chat: The chat object.

int dc_chat_is_verified(const dc_chat_t *chat)

Check if a chat is verified.

Verified chats contain only verified members and encryption is alwasy enabled. Verified chats are created using dc_create_group_chat() by setting the ‘verified’ parameter to true.

Return

1=chat verified, 0=chat is not verified

Parameters
  • chat: The chat object.

void dc_chat_unref(dc_chat_t *chat)

Free a chat object.

Return

None.

Parameters
  • chat: Chat object are returned eg. by dc_get_chat(). If NULL is given, nothing is done.

Private Functions

void dc_chat_empty(dc_chat_t *chat)

Empty a chat object.

Return

None.

Parameters
  • chat: The chat object to empty.

int dc_chat_load_from_db(dc_chat_t *chat, uint32_t chat_id)

Load a chat from the database to the chat object.

Return

1=success, 0=error.

Parameters
  • chat: The chat object that should be filled with the data from the database. Existing data are free()’d before using dc_chat_empty().

  • chat_id: Chat ID that should be loaded from the database.

dc_chat_t *dc_chat_new(dc_context_t *context)

Create a chat object in memory.

Return

New and empty chat object, must be freed using dc_chat_unref().

Parameters
  • context: The context that should be stored in the chat object.

class dc_chatlist_t
#include <deltachat.h>

An object representing a single chatlist in memory.

Chatlist objects contain chat IDs and, if possible, message IDs belonging to them. The chatlist object is not updated; if you want an update, you have to recreate the object.

For a typical chat overview, the idea is to get the list of all chats via dc_get_chatlist() without any listflags (see below) and to implement a “virtual list” or so (the count of chats is known by dc_chatlist_get_cnt()).

Only for the items that are in view (the list may have several hundreds chats), the UI should call dc_chatlist_get_summary() then. dc_chatlist_get_summary() provides all elements needed for painting the item.

On a click of such an item, the UI should change to the chat view and get all messages from this view via dc_get_chat_msgs(). Again, a “virtual list” is created (the count of messages is known) and for each messages that is scrolled into view, dc_get_msg() is called then.

Why no listflags? Without listflags, dc_get_chatlist() adds the deaddrop and the archive “link” automatically as needed. The UI can just render these items differently then. Although the deaddrop link is currently always the first entry and only present on new messages, there is the rough idea that it can be optionally always present and sorted into the list by date. Rendering the deaddrop in the described way would not add extra work in the UI then.

Public Functions

uint32_t dc_chatlist_get_chat_id(const dc_chatlist_t *chatlist, size_t index)

Get a single chat ID of a chatlist.

To get the message object from the message ID, use dc_get_chat().

Return

Returns the chat_id of the item at the given index. Index must be between 0 and dc_chatlist_get_cnt()-1.

Parameters
  • chatlist: The chatlist object as created eg. by dc_get_chatlist().

  • index: The index to get the chat ID for.

size_t dc_chatlist_get_cnt(const dc_chatlist_t *chatlist)

Find out the number of chats in a chatlist.

Return

Returns the number of items in a dc_chatlist_t object. 0 on errors or if the list is empty.

Parameters

dc_context_t *dc_chatlist_get_context(dc_chatlist_t *chatlist)

Helper function to get the associated context object.

Return

Context object associated with the chatlist. NULL if none or on errors.

Parameters
  • chatlist: The chatlist object to empty.

uint32_t dc_chatlist_get_msg_id(const dc_chatlist_t *chatlist, size_t index)

Get a single message ID of a chatlist.

To get the message object from the message ID, use dc_get_msg().

Return

Returns the message_id of the item at the given index. Index must be between 0 and dc_chatlist_get_cnt()-1. If there is no message at the given index (eg. the chat may be empty), 0 is returned.

Parameters
  • chatlist: The chatlist object as created eg. by dc_get_chatlist().

  • index: The index to get the chat ID for.

dc_lot_t *dc_chatlist_get_summary(const dc_chatlist_t *chatlist, size_t index, dc_chat_t *chat)

Get a summary for a chatlist index.

The summary is returned by a dc_lot_t object with the following fields:

  • dc_lot_t::text1: contains the username or the strings “Me”, “Draft” and so on. The string may be colored by having a look at text1_meaning. If there is no such name or it should not be displayed, the element is NULL.

  • dc_lot_t::text1_meaning: one of DC_TEXT1_USERNAME, DC_TEXT1_SELF or DC_TEXT1_DRAFT. Typically used to show dc_lot_t::text1 with different colors. 0 if not applicable.

  • dc_lot_t::text2: contains an excerpt of the message text or strings as “No messages”. May be NULL of there is no such text (eg. for the archive link)

  • dc_lot_t::timestamp: the timestamp of the message. 0 if not applicable.

  • dc_lot_t::state: The state of the message as one of the DC_STATE_* constants (see dc_msg_get_state()). 0 if not applicable.

Return

The summary as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned.

Parameters
  • chatlist: The chatlist to query as returned eg. from dc_get_chatlist().

  • index: The index to query in the chatlist.

  • chat: To speed up things, pass an already available chat object here. If the chat object is not yet available, it is faster to pass NULL.

void dc_chatlist_unref(dc_chatlist_t *chatlist)

Free a chatlist object.

Return

None.

Parameters

Private Functions

void dc_chatlist_empty(dc_chatlist_t *chatlist)

Empty a chatlist object.

Return

None.

Parameters
  • chatlist: The chatlist object to empty.

static int dc_chatlist_load_from_db(dc_chatlist_t *chatlist, int listflags, const char *query__, uint32_t query_contact_id)

Load a chatlist from the database to the chatlist object.

dc_chatlist_t *dc_chatlist_new(dc_context_t *context)

Create a chatlist object in memory.

Return

New and empty chatlist object, must be freed using dc_chatlist_unref().

Parameters
  • context: The context that should be stored in the chatlist object.

class dc_contact_t
#include <deltachat.h>

An object representing a single contact in memory.

The contact object is not updated. If you want an update, you have to recreate the object.

The library makes sure only to use names authorized by the contact in To: or Cc:. _Given-names _as “Daddy” or “Honey” are not used there. For this purpose, internally, two names are tracked - authorized-name and given-name. By default, these names are equal, but functions working with contact names (eg. dc_contact_get_name(), dc_contact_get_display_name(), dc_contact_get_name_n_addr(), dc_contact_get_first_name(), dc_create_contact() or dc_add_address_book()) only affect the given-name.

Public Functions

char *dc_contact_get_addr(const dc_contact_t *contact)

Get email address.

The email address is always set for a contact.

Return

String with the email address, must be free()’d. Never returns NULL.

Parameters
  • contact: The contact object.

uint32_t dc_contact_get_color(const dc_contact_t *contact)

Get a color for the contact.

The color is calculated from the contact’s email address and can be used for an fallback avatar with white initials as well as for headlines in bubbles of group chats.

Return

Color as 0x00rrggbb with rr=red, gg=green, bb=blue each in the range 0-255.

Parameters
  • contact: The contact object.

char *dc_contact_get_display_name(const dc_contact_t *contact)

Get display name.

This is the name as defined by the contact himself, modified by the user or, if both are unset, the email address.

This name is typically used in lists. To get the name editable in a formular, use dc_contact_get_name().

Return

String with the name to display, must be free()’d. Never returns NULL.

Parameters
  • contact: The contact object.

char *dc_contact_get_first_name(const dc_contact_t *contact)

Get the part of the name before the first space.

In most languages, this seems to be the prename. If there is no space, the full display name is returned. If the display name is not set, the e-mail address is returned.

Return

String with the name to display, must be free()’d. Never returns NULL.

Parameters
  • contact: The contact object.

uint32_t dc_contact_get_id(const dc_contact_t *contact)

Get the ID of the contact.

Return

The ID of the contact, 0 on errors.

Parameters
  • contact: The contact object.

char *dc_contact_get_name(const dc_contact_t *contact)

Get the contact name.

This is the name as defined by the contact himself or modified by the user. May be an empty string.

This name is typically used in a form where the user can edit the name of a contact. To get a fine name to display in lists etc., use dc_contact_get_display_name() or dc_contact_get_name_n_addr().

Return

String with the name to display, must be free()’d. Empty string if unset, never returns NULL.

Parameters
  • contact: The contact object.

char *dc_contact_get_name_n_addr(const dc_contact_t *contact)

Get a summary of name and address.

The returned string is either “Name (email@domain.com)” or just “email@domain.com” if the name is unset.

The summary is typically used when asking the user something about the contact. The attached email address makes the question unique, eg. “Chat with Alan Miller (am@uniquedomain.com)?”

Return

Summary string, must be free()’d. Never returns NULL.

Parameters
  • contact: The contact object.

char *dc_contact_get_profile_image(const dc_contact_t *contact)

Get the contact’s profile image.

This is the image set by each remote user on their own using dc_set_config(context, “selfavatar”, image).

Return

Path and file if the profile image, if any. NULL otherwise. Must be free()’d after usage.

Parameters
  • contact: The contact object.

int dc_contact_is_blocked(const dc_contact_t *contact)

Check if a contact is blocked.

To block or unblock a contact, use dc_block_contact().

Return

1=contact is blocked, 0=contact is not blocked.

Parameters
  • contact: The contact object.

int dc_contact_is_verified(dc_contact_t *contact)

Check if a contact was verified.

E.g. by a secure-join QR code scan and if the key has not changed since this verification.

The UI may draw a checkbox or something like that beside verified contacts.

Return

0: contact is not verified. 2: SELF and contact have verified their fingerprints in both directions; in the UI typically checkmarks are shown.

Parameters
  • contact: The contact object.

void dc_contact_unref(dc_contact_t *contact)

Free a contact object.

Return

None.

Parameters
  • contact: The contact object as created eg. by dc_get_contact(). If NULL is given, nothing is done.

Private Functions

int dc_addr_cmp(const char *addr1, const char *addr2)

Compare two e-mail-addresses.

The adresses will be normalized before compare and the comparison is case-insensitive.

Return

0: addresses are equal, >0: addr1 is larger than addr2, <0: addr1 is smaller than addr2

int dc_addr_equals_self(dc_context_t *context, const char *addr)

Check if a given e-mail-address is equal to the configured-self-address.

char *dc_addr_normalize(const char *addr)

Normalize an email address.

Normalization includes:

  • Trimming

  • removing mailto: prefix

Not sure if we should also unifiy international characters before the @, see also https://autocrypt.readthedocs.io/en/latest/address-canonicalization.html

Return

The normalized email address, must be free()’d. NULL is never returned.

Parameters
  • addr: The email address to normalize.

void dc_contact_empty(dc_contact_t *contact)

Empty a contact object.

Typically not needed by the user of the library. To free a contact object, use dc_contact_unref().

Return

None.

Parameters
  • contact: The contact object to free.

int dc_contact_load_from_db(dc_contact_t *contact, dc_sqlite3_t *sql, uint32_t contact_id)

Load a contact from the database to the contact object.

dc_contact_t *dc_contact_new(dc_context_t *context)

Create a new contact object in memory.

Typically the user does not call this function directly but gets contact objects using dc_get_contact().

Return

The contact object. Must be freed using dc_contact_unref() when done.

char *dc_get_first_name(const char *full_name)

Get the first name.

In a string, get the part before the first space. If there is no space in the string, the whole string is returned.

Return

String with the first name, must be free()’d after usage.

Parameters
  • full_name: Full name of the contact.

void dc_normalize_name(char *full_name)

Normalize a name in-place.

  • Remove quotes (come from some bad MUA implementations)

  • Convert names as “Petersen, Björn” to “Björn Petersen”

  • Trims the resulting string

Typically, this function is not needed as it is called implicitly by dc_add_address_book()

Return

None. But the given buffer may be modified.

Parameters
  • full_name: Buffer with the name, is modified during processing; the resulting string may be shorter but never longer.

class dc_context_t
#include <deltachat.h>

An object representing a single account.

Each account is linked to an IMAP/SMTP account and uses a separate SQLite database for offline functionality and for account-related settings.

Import/Export

char *dc_initiate_key_transfer(dc_context_t *context)

Initiate Autocrypt Setup Transfer.

Before starting the setup transfer with this function, the user should be asked:

"An 'Autocrypt Setup Message' securely shares your end-to-end setup with other Autocrypt-compliant apps.
The setup will be encrypted by a setup code which is displayed here and must be typed on the other device.

After that, this function should be called to send the Autocrypt Setup Message. The function creates the setup message and waits until it is really sent. As this may take a while, it is recommended to start the function in a separate thread; to interrupt it, you can use dc_stop_ongoing_process().

After everything succeeded, the required setup code is returned in the following format:

1234-1234-1234-1234-1234-1234-1234-1234-1234

The setup code should be shown to the user then:

"Your key has been sent to yourself. Switch to the other device and
open the setup message. You should be prompted for a setup code. Type
the following digits into the prompt:

1234 - 1234 - 1234 -
1234 - 1234 - 1234 -
1234 - 1234 - 1234

Once you're done, your other device will be ready to use Autocrypt."

On the other device you will call dc_continue_key_transfer() then for setup messages identified by dc_msg_is_setupmessage().

For more details about the Autocrypt setup process, please refer to https://autocrypt.org/en/latest/level1.html#autocrypt-setup-message

Return

The setup code. Must be free()’d after usage. On errors, eg. if the message could not be sent, NULL is returned.

Parameters
  • context: The context object.

int dc_continue_key_transfer(dc_context_t *context, uint32_t msg_id, const char *setup_code)

Continue the Autocrypt Key Transfer on another device.

If you have started the key transfer on another device using dc_initiate_key_transfer() and you’ve detected a setup message with dc_msg_is_setupmessage(), you should prompt the user for the setup code and call this function then.

You can use dc_msg_get_setupcodebegin() to give the user a hint about the code (useful if the user has created several messages and should not enter the wrong code).

Return

1=key successfully decrypted and imported; both devices will use the same key now; 0=key transfer failed eg. due to a bad setup code.

Parameters
  • context: The context object.

  • msg_id: ID of the setup message to decrypt.

  • setup_code: Setup code entered by the user. This is the same setup code as returned from dc_initiate_key_transfer() on the other device. There is no need to format the string correctly, the function will remove all spaces and other characters and insert the - characters at the correct places.

void dc_imex(dc_context_t *context, int what, const char *param1, const char *param2)

Import/export things.

For this purpose, the function creates a job that is executed in the IMAP-thread then; this requires to call dc_perform_imap_jobs() regularly.

What to do is defined by the what parameter which may be one of the following:

  • DC_IMEX_EXPORT_BACKUP (11) - Export a backup to the directory given as param1. The backup contains all contacts, chats, images and other data and device independent settings. The backup does not contain device dependent settings as ringtones or LED notification settings. The name of the backup is typically delta-chat.<day>.bak, if more than one backup is create on a day, the format is delta-chat.<day>-<number>.bak

  • DC_IMEX_IMPORT_BACKUP (12) - param1 is the file (not: directory) to import. The file is normally created by DC_IMEX_EXPORT_BACKUP and detected by dc_imex_has_backup(). Importing a backup is only possible as long as the context is not configured or used in another way.

  • DC_IMEX_EXPORT_SELF_KEYS (1) - Export all private keys and all public keys of the user to the directory given as param1. The default key is written to the files public-key-default.asc and private-key-default.asc, if there are more keys, they are written to files as public-key-<id>.asc and private-key-<id>.asc

  • DC_IMEX_IMPORT_SELF_KEYS (2) - Import private keys found in the directory given as param1. The last imported key is made the default keys unless its name contains the string legacy. Public keys are not imported.

While dc_imex() returns immediately, the started job may take a while, you can stop it using dc_stop_ongoing_process(). During execution of the job, some events are sent out:

  • A number of DC_EVENT_IMEX_PROGRESS events are sent and may be used to create a progress bar or stuff like that. Moreover, you’ll be informed when the imex-job is done.

  • For each file written on export, the function sends DC_EVENT_IMEX_FILE_WRITTEN

Only one import-/export-progress can run at the same time. To cancel an import-/export-progress, use dc_stop_ongoing_process().

Return

None.

Parameters
  • context: The context as created by dc_context_new().

  • what: One of the DC_IMEX_* constants.

  • param1: Meaning depends on the DC_IMEX_* constants. If this parameter is a directory, it should not end with a slash (otherwise you’ll get double slashes when receiving DC_EVENT_IMEX_FILE_WRITTEN). Set to NULL if not used.

  • param2: Meaning depends on the DC_IMEX_* constants. Set to NULL if not used.

char *dc_imex_has_backup(dc_context_t *context, const char *dir_name)

Check if there is a backup file.

May only be used on fresh installations (eg. dc_is_configured() returns 0).

Example:

char dir[] = "/dir/to/search/backups/in";

void ask_user_for_credentials()
{
    // - ask the user for email and password
    // - save them using dc_set_config()
}

int ask_user_whether_to_import()
{
    // - inform the user that we've found a backup
    // - ask if he want to import it
    // - return 1 to import, 0 to skip
    return 1;
}

if (!dc_is_configured(context))
{
    char* file = NULL;
    if ((file=dc_imex_has_backup(context, dir))!=NULL && ask_user_whether_to_import())
    {
        dc_imex(context, DC_IMEX_IMPORT_BACKUP, file, NULL);
        // connect
    }
    else
    {
        do {
            ask_user_for_credentials();
        }
        while (!configure_succeeded())
    }
    free(file);
}

Return

String with the backup file, typically given to dc_imex(), returned strings must be free()’d. The function returns NULL if no backup was found.

Parameters
  • context: The context as created by dc_context_new().

  • dir_name: Directory to search backups in.

int dc_check_password(dc_context_t *context, const char *test_pw)

Check if the user is authorized by the given password in some way.

This is to prompt for the password eg. before exporting keys/backup.

Return

1=user is authorized, 0=user is not authorized.

Parameters
  • context: The context as created by dc_context_new().

  • test_pw: Password to check.

char *dc_render_setup_file(dc_context_t *context, const char *passphrase)

Create an Autocrypt Setup Message.

A complete Autocrypt Setup Message looks like the following:

To: me@mydomain.com
From: me@mydomain.com
Autocrypt-Setup-Message: v1
Content-type: multipart/mixed; boundary="==break1=="

--==break1==
Content-Type: text/plain

This is the Autocrypt setup message.

--==break1==
Content-Type: application/autocrypt-setup
Content-Disposition: attachment; filename="autocrypt-setup-message.html"

<html>
<body>
<p>
    This is the Autocrypt Setup File used to transfer keys between clients.
</p>
<pre>
-----BEGIN PGP MESSAGE-----
Version: BCPG v1.53
Passphrase-Format: numeric9x4
Passphrase-Begin: 12

hQIMAxC7JraDy7DVAQ//SK1NltM+r6uRf2BJEg+rnpmiwfAEIiopU0LeOQ6ysmZ0
CLlfUKAcryaxndj4sBsxLllXWzlNiFDHWw4OOUEZAZd8YRbOPfVq2I8+W4jO3Moe
-----END PGP MESSAGE-----
</pre>
</body>
</html>
--==break1==--

The encrypted message part contains:

-----BEGIN PGP PRIVATE KEY BLOCK-----
Autocrypt-Prefer-Encrypt: mutual

xcLYBFke7/8BCAD0TTmX9WJm9elc7/xrT4/lyzUDMLbuAuUqRINtCoUQPT2P3Snfx/jou1YcmjDgwT
Ny9ddjyLcdSKL/aR6qQ1UBvlC5xtriU/7hZV6OZEmW2ckF7UgGd6ajE+UEjUwJg2+eKxGWFGuZ1P7a
4Av1NXLayZDsYa91RC5hCsj+umLN2s+68ps5pzLP3NoK2zIFGoCRncgGI/pTAVmYDirhVoKh14hCh5
.....
-----END PGP PRIVATE KEY BLOCK-----

dc_render_setup_file() renders the body after the second -==break1== in this example.

Return

String with the HTML-code of the message on success, NULL on errors. The returned value must be free()’d

Parameters
  • context: The context object

  • passphrase: The setup code that shall be used to encrypt the message. Typically created by dc_create_setup_code().

char *dc_decrypt_setup_file(dc_context_t *context, const char *passphrase, const char *filecontent)

Parse the given file content and extract the private key.

Return

The decrypted private key as armored-ascii-data or NULL on errors. Must be dc_key_unref()’d.

Parameters
  • context: The context object

  • passphrase: The setup code that shall be used to decrypt the message. May be created by dc_create_setup_code() on another device or by a completely different app as Thunderbird/Enigmail or K-9.

  • filecontent: The file content of the setup message, may be HTML. May be created by dc_render_setup_code() on another device or by a completely different app as Thunderbird/Enigmail or K-9.

char *dc_create_setup_code(dc_context_t *context)

Create random setup code.

The created “Autocrypt Level 1” setup code has the form 1234-1234-1234-1234-1234-1234-1234-1234-1234. Linebreaks and spaces are not added to the setup code, but the - are. The setup code is typically given to dc_render_setup_file().

A higher-level function to initiate the key transfer is dc_initiate_key_transfer().

Return

Setup code, must be free()’d after usage. NULL on errors.

Parameters

Secure Join

char *dc_get_securejoin_qr(dc_context_t *context, uint32_t group_chat_id)

Get QR code text that will offer an secure-join verification.

The QR code is compatible to the OPENPGP4FPR format so that a basic fingerprint comparison also works eg. with OpenKeychain.

The scanning device will pass the scanned content to dc_check_qr() then; if this function returns DC_QR_ASK_VERIFYCONTACT or DC_QR_ASK_VERIFYGROUP an out-of-band-verification can be joined using dc_join_securejoin()

Return

Text that should go to the QR code, On errors, an empty QR code is returned, NULL is never returned. The returned string must be free()’d after usage.

Parameters
  • context: The context object.

  • group_chat_id: If set to a group-chat-id, the group-join-protocol is offered in the QR code; works for verified groups as well as for normal groups. If set to 0, the setup-Verified-contact-protocol is offered in the QR code.

uint32_t dc_join_securejoin(dc_context_t *context, const char *qr)

Join an out-of-band-verification initiated on another device with dc_get_securejoin_qr().

This function is typically called when dc_check_qr() returns lot.state=DC_QR_ASK_VERIFYCONTACT or lot.state=DC_QR_ASK_VERIFYGROUP.

This function takes some time and sends and receives several messages. You should call it in a separate thread; if you want to abort it, you should call dc_stop_ongoing_process().

Return

Chat-id of the joined chat, the UI may redirect to the this chat. If the out-of-band verification failed or was aborted, 0 is returned.

Parameters
  • context: The context object

  • qr: The text of the scanned QR code. Typically, the same string as given to dc_check_qr().

int dc_handle_securejoin_handshake(dc_context_t *context, dc_mimeparser_t *mimeparser, uint32_t contact_id)

Handle incoming handshake messages.

Called from receive_imf(). Assume, when dc_handle_securejoin_handshake() is called, the message is not yet filed in the database.

Return

bitfield of DC_HANDSHAKE_STOP_NORMAL_PROCESSING, DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING, DC_HANDSHAKE_ADD_DELETE_JOB; 0 if the message is no secure join message

Parameters
  • context: The context object.

  • mimeparser: The mail.

  • contact_id: Contact-id of the sender (typically the From: header)

Public Types

typedef uintptr_t (*dc_callback_t)(dc_context_t *, int event, uintptr_t data1, uintptr_t data2)

Callback function that should be given to dc_context_new().

Return

return 0 unless stated otherwise in the event parameter documentation

Parameters
  • context: The context object as returned by dc_context_new().

  • event: one of the DC_EVENT constants

  • data1: depends on the event parameter

  • data2: depends on the event parameter

Public Functions

int dc_add_address_book(dc_context_t *context, const char *adr_book)

Add a number of contacts.

Typically used to add the whole address book from the OS. As names here are typically not well formatted, we call normalize() for each name given.

No email-address is added twice. Trying to add email-addresses that are already in the contact list, results in updating the name unless the name was changed manually by the user. If any email-address or any name is really updated, the event DC_EVENT_CONTACTS_CHANGED is sent.

To add a single contact entered by the user, you should prefer dc_create_contact(), however, for adding a bunch of addresses, this function is much faster.

Return

The number of modified or added contacts.

Parameters
  • context: the context object as created by dc_context_new().

  • adr_book: A multi-line string in the format Name one\nAddress one\nName two\nAddress two. If an email address already exists, the name is updated unless it was edited manually by dc_create_contact() before.

int dc_add_contact_to_chat(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)

Add a member to a group.

If the group is already promoted (any message was sent to the group), all group members are informed by a special status message that is sent automatically by this function.

If the group is a verified group, only verified contacts can be added to the group.

Sends out DC_EVENT_CHAT_MODIFIED and DC_EVENT_MSGS_CHANGED if a status message was sent.

Return

1=member added to group, 0=error

Parameters
  • context: The context as created by dc_context_new().

  • chat_id: The chat ID to add the contact to. Must be a group chat.

  • contact_id: The contact ID to add to the chat.

void dc_archive_chat(dc_context_t *context, uint32_t chat_id, int archive)

Archive or unarchive a chat.

Archived chats are not included in the default chatlist returned by dc_get_chatlist(). Instead, if there are any archived chats, the pseudo-chat with the chat_id DC_CHAT_ID_ARCHIVED_LINK will be added the the end of the chatlist.

  • To get a list of archived chats, use dc_get_chatlist() with the flag DC_GCL_ARCHIVED_ONLY.

  • To find out the archived state of a given chat, use dc_chat_get_archived()

  • Messages in archived chats are marked as being noticed, so they do not count as “fresh”

  • Calling this function usually results in the event DC_EVENT_MSGS_CHANGED

Return

None.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The ID of the chat to archive or unarchive.

  • archive: 1=archive chat, 0=unarchive chat, all other values are reserved for future use

void dc_block_contact(dc_context_t *context, uint32_t contact_id, int new_blocking)

Block or unblock a contact.

May result in a DC_EVENT_CONTACTS_CHANGED event.

Return

None.

Parameters
  • context: The context object as created by dc_context_new().

  • contact_id: The ID of the contact to block or unblock.

  • new_blocking: 1=block contact, 0=unblock contact

dc_lot_t *dc_check_qr(dc_context_t *context, const char *qr)

Check a scanned QR code.

The function should be called after a QR code is scanned. The function takes the raw text scanned and checks what can be done with it.

The QR code state is returned in dc_lot_t::state as:

  • DC_QR_ASK_VERIFYCONTACT with dc_lot_t::id=Contact ID

  • DC_QR_ASK_VERIFYGROUP withdc_lot_t::text1=Group name

  • DC_QR_FPR_OK with dc_lot_t::id=Contact ID

  • DC_QR_FPR_MISMATCH with dc_lot_t::id=Contact ID

  • DC_QR_FPR_WITHOUT_ADDR with dc_lot_t::test1=Formatted fingerprint

  • DC_QR_ADDR with dc_lot_t::id=Contact ID

  • DC_QR_TEXT with dc_lot_t::text1=Text

  • DC_QR_URL with dc_lot_t::text1=URL

  • DC_QR_ERROR with dc_lot_t::text1=Error string

Return

Parsed QR code as an dc_lot_t object. The returned object must be freed using dc_lot_unref() after usage.

Parameters
  • context: The context object.

  • qr: The text of the scanned QR code.

void dc_close(dc_context_t *context)

Close context database opened by dc_open().

Before this, connections to SMTP and IMAP are closed; these connections are started automatically as needed eg. by sending for fetching messages. This function is also implicitly called by dc_context_unref(). Multiple calls to this functions are okay, the function takes care not to free objects twice.

Return

None.

Parameters

void dc_configure(dc_context_t *context)

Configure a context.

For this purpose, the function creates a job that is executed in the IMAP-thread then; this requires to call dc_perform_imap_jobs() regularly. If the context is already configured, this function will try to change the configuration.

  • Before you call this function, you must set at least addr and mail_pw using dc_set_config().

  • Use mail_user to use a different user name than addr and send_pw to use a different password for the SMTP server.

    • If no more options are specified, the function uses autoconfigure/autodiscover to get the full configuration from well-known URLs.

    • If more options as mail_server, mail_port, send_server, send_port, send_user or server_flags are specified, autoconfigure/autodiscover is skipped.

While dc_configure() returns immediately, the started configuration-job may take a while.

During configuration, DC_EVENT_CONFIGURE_PROGRESS events are emmited; they indicate a successful configuration as well as errors and may be used to create a progress bar.

Additional calls to dc_configure() while a config-job is running are ignored. To interrupt a configuration prematurely, use dc_stop_ongoing_process(); this is not needed if DC_EVENT_CONFIGURE_PROGRESS reports success.

On a successfull configuration, the core makes a copy of the parameters mentioned above: the original parameters as are never modified by the core.

UI-implementors should keep this in mind - eg. if the UI wants to prefill a configure-edit-dialog with these parameters, the UI should reset them if the user cancels the dialog after a configure-attempts has failed. Otherwise the parameters may not reflect the current configuation.

There is no need to call

dc_configure() on every program start, the configuration result is saved in the database and you can use the connection directly:
Return

None.

Parameters

if (!dc_is_configured(context)) {
    dc_configure(context);
    // wait for progress events
}

dc_context_t *dc_context_new(dc_callback_t cb, void *userdata, const char *os_name)

Create a new context object.

After creation it is usually opened, connected and mails are fetched.

Return

A context object with some public members. The object must be passed to the other context functions and must be freed using dc_context_unref() after usage.

Parameters
  • cb: a callback function that is called for events (update, state changes etc.) and to get some information from the client (eg. translation for a given string). See DC_EVENT for a list of possible events that may be passed to the callback.

    • The callback MAY be called from any thread, not only the main/GUI thread!

    • The callback MUST NOT call any dc_* and related functions unless stated otherwise!

    • The callback SHOULD return fast, for GUI updates etc. you should post yourself an asynchronous message to your GUI thread, if needed.

    • If not mentioned otherweise, the callback should return 0.

  • userdata: can be used by the client for any purpuse. He finds it later in dc_get_userdata().

  • os_name: is only for decorative use and is shown eg. in the X-Mailer: header in the form “Delta Chat Core <version>/<os_name>”. You can give the name of the app, the operating system, the used environment and/or the version here. It is okay to give NULL, in this case X-Mailer: header is set to “Delta Chat Core <version>”.

void dc_context_unref(dc_context_t *context)

Free a context object.

If app runs can only be terminated by a forced kill, this may be superfluous. Before the context object is freed, connections to SMTP, IMAP and database are closed. You can also do this explicitly by calling dc_close() on your own before calling dc_context_unref().

Return

None.

Parameters
  • context: The context object as created by dc_context_new(). If NULL is given, nothing is done.

uint32_t dc_create_chat_by_contact_id(dc_context_t *context, uint32_t contact_id)

Create a normal chat with a single user.

To create group chats, see dc_create_group_chat().

If a chat already exists, this ID is returned, otherwise a new chat is created; this new chat may already contain messages, eg. from the deaddrop, to get the chat messages, use dc_get_chat_msgs().

Return

The created or reused chat ID on success. 0 on errors.

Parameters
  • context: The context object as returned from dc_context_new().

  • contact_id: The contact ID to create the chat for. If there is already a chat with this contact, the already existing ID is returned.

uint32_t dc_create_chat_by_msg_id(dc_context_t *context, uint32_t msg_id)

Create a normal chat or a group chat by a messages ID that comes typically from the deaddrop, DC_CHAT_ID_DEADDROP (1).

If the given message ID already belongs to a normal chat or to a group chat, the chat ID of this chat is returned and no new chat is created. If a new chat is created, the given message ID is moved to this chat, however, there may be more messages moved to the chat from the deaddrop. To get the chat messages, use dc_get_chat_msgs().

If the user is asked before creation, he should be asked whether he wants to chat with the contact belonging to the message; the group names may be really weird when taken from the subject of implicit groups and this may look confusing.

Moreover, this function also scales up the origin of the contact belonging to the message and, depending on the contacts origin, messages from the same group may be shown or not - so, all in all, it is fine to show the contact name only.

Return

The created or reused chat ID on success. 0 on errors.

Parameters
  • context: The context object as returned from dc_context_new().

  • msg_id: The message ID to create the chat for.

uint32_t dc_create_contact(dc_context_t *context, const char *name, const char *addr)

Add a single contact as a result of an explicit user action.

We assume, the contact name, if any, is entered by the user and is used “as is” therefore, normalize() is not called for the name. If the contact is blocked, it is unblocked.

To add a number of contacts, see dc_add_address_book() which is much faster for adding a bunch of addresses.

May result in a DC_EVENT_CONTACTS_CHANGED event.

Return

Contact ID of the created or reused contact.

Parameters
  • context: The context object as created by dc_context_new().

  • name: Name of the contact to add. If you do not know the name belonging to the address, you can give NULL here.

  • addr: E-mail-address of the contact to add. If the email address already exists, the name is updated and the origin is increased to “manually created”.

uint32_t dc_create_group_chat(dc_context_t *context, int verified, const char *chat_name)

Create a new group chat.

After creation, the draft of the chat is set to a default text, the group has one member with the ID DC_CONTACT_ID_SELF and is in unpromoted state. This means, you can add or remove members, change the name, the group image and so on without messages being sent to all group members.

This changes as soon as the first message is sent to the group members and the group becomes promoted. After that, all changes are synced with all group members by sending status message.

To check, if a chat is still unpromoted, you dc_chat_is_unpromoted(). This may be useful if you want to show some help for just created groups.

Return

The chat ID of the new group chat, 0 on errors.

Parameters
  • context: The context as created by dc_context_new().

  • verified: If set to 1 the function creates a secure verified group. Only secure-verified members are allowed in these groups and end-to-end-encryption is always enabled.

  • chat_name: The name of the group chat to create. The name may be changed later using dc_set_chat_name(). To find out the name of a group later, see dc_chat_get_name()

void dc_delete_all_locations(dc_context_t *context)

Delete all locations on the current device.

Locations already sent cannot be deleted.

Typically results in the event DC_EVENT_LOCATION_CHANGED with contact_id set to 0.

Return

None.

Parameters
  • context: The context object.

void dc_delete_chat(dc_context_t *context, uint32_t chat_id)

Delete a chat.

Messages are deleted from the device and the chat database entry is deleted. After that, the event DC_EVENT_MSGS_CHANGED is posted.

Things that are not done implicitly:

  • Messages are not deleted from the server.

  • The chat or the contact is not blocked, so new messages from the user/the group may appear and the user may create the chat again.

  • Groups are not left - this would be unexpected as (1) deleting a normal chat also does not prevent new mails from arriving, (2) leaving a group requires sending a message to all group members - especially for groups not used for a longer time, this is really unexpected when deletion results in contacting all members again, (3) only leaving groups is also a valid usecase.

To leave a chat explicitly, use dc_remove_contact_from_chat() with chat_id=DC_CONTACT_ID_SELF)

Return

None.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The ID of the chat to delete.

int dc_delete_contact(dc_context_t *context, uint32_t contact_id)

Delete a contact.

The contact is deleted from the local device. It may happen that this is not possible as the contact is in use. In this case, the contact can be blocked.

May result in a DC_EVENT_CONTACTS_CHANGED event.

Return

1=success, 0=error

Parameters
  • context: The context object as created by dc_context_new().

  • contact_id: ID of the contact to delete.

void dc_delete_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt)

Delete messages.

The messages are deleted on the current device and on the IMAP server.

Return

None.

Parameters
  • context: The context object as created by dc_context_new()

  • msg_ids: an array of uint32_t containing all message IDs that should be deleted

  • msg_cnt: The number of messages IDs in the msg_ids array

void dc_forward_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt, uint32_t chat_id)

Forward messages to another chat.

Return

None.

Parameters
  • context: The context object as created by dc_context_new()

  • msg_ids: An array of uint32_t containing all message IDs that should be forwarded

  • msg_cnt: The number of messages IDs in the msg_ids array

  • chat_id: The destination chat ID.

char *dc_get_blobdir(const dc_context_t *context)

Get the blob directory.

Return

Blob directory associated with the context object, empty string if unset or on errors. NULL is never returned. The returned string must be free()’d.

Parameters

int dc_get_blocked_cnt(dc_context_t *context)

Get the number of blocked contacts.

Return

The number of blocked contacts.

Parameters

dc_array_t *dc_get_blocked_contacts(dc_context_t *context)

Get blocked contacts.

Return

An array containing all blocked contact IDs. Must be dc_array_unref()’d after usage.

Parameters

dc_chat_t *dc_get_chat(dc_context_t *context, uint32_t chat_id)

Get chat object by a chat ID.

Return

A chat object of the type dc_chat_t, must be freed using dc_chat_unref() when done. On errors, NULL is returned.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The ID of the chat to get the chat object for.

dc_array_t *dc_get_chat_contacts(dc_context_t *context, uint32_t chat_id)

Get contact IDs belonging to a chat.

  • for normal chats, the function always returns exactly one contact, DC_CONTACT_ID_SELF is returned only for SELF-chats.

  • for group chats all members are returned, DC_CONTACT_ID_SELF is returned explicitly as it may happen that oneself gets removed from a still existing group

  • for the deaddrop, the list is empty

Return

An array of contact IDs belonging to the chat; must be freed using dc_array_unref() when done.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: Chat ID to get the belonging contact IDs for.

uint32_t dc_get_chat_id_by_contact_id(dc_context_t *context, uint32_t contact_id)

Check, if there is a normal chat with a given contact.

To get the chat messages, use dc_get_chat_msgs().

Return

If there is a normal chat with the given contact_id, this chat_id is returned. If there is no normal chat with the contact_id, the function returns 0.

Parameters
  • context: The context object as returned from dc_context_new().

  • contact_id: The contact ID to check.

dc_array_t *dc_get_chat_media(dc_context_t *context, uint32_t chat_id, int msg_type, int msg_type2, int msg_type3)

Returns all message IDs of the given types in a chat.

Typically used to show a gallery. The result must be dc_array_unref()’d

The list is already sorted and starts with the oldest message. Clients should not try to re-sort the list as this would be an expensive action and would result in inconsistencies between clients.

Return

An array with messages from the given chat ID that have the wanted message types.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The chat ID to get all messages with media from.

  • msg_type: Specify a message type to query here, one of the DC_MSG_* constats.

  • msg_type2: Alternative message type to search for. 0 to skip.

  • msg_type3: Alternative message type to search for. 0 to skip.

dc_array_t *dc_get_chat_msgs(dc_context_t *context, uint32_t chat_id, uint32_t flags, uint32_t marker1before)

Get all message IDs belonging to a chat.

The list is already sorted and starts with the oldest message. Clients should not try to re-sort the list as this would be an expensive action and would result in inconsistencies between clients.

Optionally, some special markers added to the ID-array may help to implement virtual lists.

Return

Array of message IDs, must be dc_array_unref()’d when no longer used.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The chat ID of which the messages IDs should be queried.

  • flags: If set to DC_GCM_ADDDAYMARKER, the marker DC_MSG_ID_DAYMARKER will be added before each day (regarding the local timezone). Set this to 0 if you do not want this behaviour.

  • marker1before: An optional message ID. If set, the id DC_MSG_ID_MARKER1 will be added just before the given ID in the returned array. Set this to 0 if you do not want this behaviour.

dc_chatlist_t *dc_get_chatlist(dc_context_t *context, int listflags, const char *query_str, uint32_t query_id)

Get a list of chats.

The list can be filtered by query parameters.

The list is already sorted and starts with the most recent chat in use. The sorting takes care of invalid sending dates, drafts and chats without messages. Clients should not try to re-sort the list as this would be an expensive action and would result in inconsistencies between clients.

To get information about each entry, use eg. dc_chatlist_get_summary().

By default, the function adds some special entries to the list. These special entries can be identified by the ID returned by dc_chatlist_get_chat_id():

  • DC_CHAT_ID_DEADDROP (1) - this special chat is present if there are messages from addresses that have no relationship to the configured account. The last of these messages is represented by DC_CHAT_ID_DEADDROP and you can retrieve details about it with dc_chatlist_get_msg_id(). Typically, the UI asks the user “Do you want to chat with NAME?” and offers the options “Yes” (call dc_create_chat_by_msg_id()), “Never” (call dc_block_contact()) or “Not now”. The UI can also offer a “Close” button that calls dc_marknoticed_contact() then.

  • DC_CHAT_ID_ARCHIVED_LINK (6) - this special chat is present if the user has archived any chat using dc_archive_chat(). The UI should show a link as “Show archived chats”, if the user clicks this item, the UI should show a list of all archived chats that can be created by this function hen using the DC_GCL_ARCHIVED_ONLY flag.

  • DC_CHAT_ID_ALLDONE_HINT (7) - this special chat is present if DC_GCL_ADD_ALLDONE_HINT is added to listflags and if there are only archived chats.

See also:

dc_get_chat_msgs() to get the messages of a single chat.
Return

A chatlist as an dc_chatlist_t object. On errors, NULL is returned. Must be freed using dc_chatlist_unref() when no longer used.

Parameters
  • context: The context object as returned by dc_context_new()

  • listflags: A combination of flags:

    • if the flag DC_GCL_ARCHIVED_ONLY is set, only archived chats are returned. if DC_GCL_ARCHIVED_ONLY is not set, only unarchived chats are returned and the pseudo-chat DC_CHAT_ID_ARCHIVED_LINK is added if there are any archived chats

    • if the flag DC_GCL_NO_SPECIALS is set, deaddrop and archive link are not added to the list (may be used eg. for selecting chats on forwarding, the flag is not needed when DC_GCL_ARCHIVED_ONLY is already set)

    • if the flag DC_GCL_ADD_ALLDONE_HINT is set, DC_CHAT_ID_ALLDONE_HINT is added as needed.

  • query_str: An optional query for filtering the list. Only chats matching this query are returned. Give NULL for no filtering.

  • query_id: An optional contact ID for filtering the list. Only chats including this contact ID are returned. Give 0 for no filtering.

char *dc_get_config(dc_context_t *context, const char *key)

Get a configuration option.

The configuration option is set by dc_set_config() or by the library itself.

Beside the options shown at dc_set_config(), this function can be used to query some global system values:

  • sys.version = get the version string eg. as 1.2.3 or as 1.2.3special4

  • sys.msgsize_max_recommended = maximal recommended attachment size in bytes. All possible overheads are already subtracted and this value can be used eg. for direct comparison with the size of a file the user wants to attach. If an attachment is larger than this value, an error (no warning as it should be shown to the user) is logged but the attachment is sent anyway.

  • sys.config_keys = get a space-separated list of all config-keys available. The config-keys are the keys that can be passed to the parameter key of this function.

Return

Returns current value of “key”, if “key” is unset, the default value is returned. The returned value must be free()’d, NULL is never returned.

Parameters
  • context: The context object as created by dc_context_new(). For querying system values, this can be NULL.

  • key: The key to query.

dc_contact_t *dc_get_contact(dc_context_t *context, uint32_t contact_id)

Get a single contact object.

For a list, see eg. dc_get_contacts().

For contact DC_CONTACT_ID_SELF (1), the function returns sth. like “Me” in the selected language and the email address defined by dc_set_config().

Return

The contact object, must be freed using dc_contact_unref() when no longer used. NULL on errors.

Parameters
  • context: The context object as created by dc_context_new().

  • contact_id: ID of the contact to get the object for.

char *dc_get_contact_encrinfo(dc_context_t *context, uint32_t contact_id)

Get encryption info for a contact.

Get a multi-line encryption info, containing your fingerprint and the fingerprint of the contact, used eg. to compare the fingerprints for a simple out-of-band verification.

Return

Multi-line text, must be free()’d after usage.

Parameters
  • context: The context object as created by dc_context_new().

  • contact_id: ID of the contact to get the encryption info for.

dc_array_t *dc_get_contacts(dc_context_t *context, uint32_t listflags, const char *query)

Returns known and unblocked contacts.

To get information about a single contact, see dc_get_contact().

Return

An array containing all contact IDs. Must be dc_array_unref()’d after usage.

Parameters
  • context: The context object as created by dc_context_new().

  • listflags: A combination of flags:

    • if the flag DC_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters

    • if the flag DC_GCL_VERIFIED_ONLY is set, only verified contacts are returned. if DC_GCL_VERIFIED_ONLY is not set, verified and unverified contacts are returned.

  • query: A string to filter the list. Typically used to implement an incremental search. NULL for no filtering.

dc_msg_t *dc_get_draft(dc_context_t *context, uint32_t chat_id)

Get draft for a chat, if any.

See dc_set_draft() for more details about drafts.

Return

Message object. Can be passed directly to dc_send_msg(). Must be freed using dc_msg_unref() after usage. If there is no draft, NULL is returned.

Parameters
  • context: The context as created by dc_context_new().

  • chat_id: The chat ID to get the draft for.

int dc_get_fresh_msg_cnt(dc_context_t *context, uint32_t chat_id)

Get the number of fresh messages in a chat.

Typically used to implement a badge with a number in the chatlist.

Return

Number of fresh messages in the given chat. 0 for errors or if there are no fresh messages.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The ID of the chat to count the messages for.

dc_array_t *dc_get_fresh_msgs(dc_context_t *context)

Returns the message IDs of all fresh messages of any chat.

Typically used for implementing notification summaries. The list is already sorted and starts with the most recent fresh message.

Return

Array of message IDs, must be dc_array_unref()’d when no longer used. On errors, the list is empty. NULL is never returned.

Parameters

char *dc_get_info(dc_context_t *context)

Get information about the context.

The information is returned by a multi-line string and contains information about the current configuration.

Return

String which must be free()’d after usage. Never returns NULL.

Parameters

dc_array_t *dc_get_locations(dc_context_t *context, uint32_t chat_id, uint32_t contact_id, time_t timestamp_from, time_t timestamp_to)

Get shared locations from the database.

The locations can be filtered by the chat-id, the contact-id and by a timespan.

The number of returned locations can be retrieved using dc_array_get_cnt(). To get information for each location, use dc_array_get_latitude(), dc_array_get_longitude(), dc_array_get_accuracy(), dc_array_get_timestamp(), dc_array_get_contact_id() and dc_array_get_msg_id(). The latter returns 0 if there is no message bound to the location.

Note that only if dc_array_is_independent() returns 0, the location is the current or a past position of the user. If dc_array_is_independent() returns 1, the location is any location on earth that is marked by the user.

Examples:

// get locations from the last hour for a global map
dc_array_t* loc = dc_get_locations(context, 0, 0, time(NULL)-60*60, 0);
for (int i=0; i<dc_array_get_cnt(); i++) {
    double lat = dc_array_get_latitude(loc, i);
    ...
}
dc_array_unref(loc);

// get locations from a contact for a global map
dc_array_t* loc = dc_get_locations(context, 0, contact_id, 0, 0);
...

// get all locations known for a given chat
dc_array_t* loc = dc_get_locations(context, chat_id, 0, 0, 0);
...

// get locations from a single contact for a given chat
dc_array_t* loc = dc_get_locations(context, chat_id, contact_id, 0, 0);
...
Return

Array of locations, NULL is never returned. The array is sorted decending; the first entry in the array is the location with the newest timestamp. Note that this is only realated to the recent postion of the user if dc_array_is_independent() returns 0. The returned array must be freed using dc_array_unref().

Parameters
  • context: The context object.

  • chat_id: Chat-id to get location information for. 0 to get locations independently of the chat.

  • contact_id: Contact-id to get location information for. If also a chat-id is given, this should be a member of the given chat. 0 to get locations independently of the contact.

  • timestamp_from: Start of timespan to return. Must be given in number of seconds since 00:00 hours, Jan 1, 1970 UTC. 0 for “start from the beginning”.

  • timestamp_to: End of timespan to return. Must be given in number of seconds since 00:00 hours, Jan 1, 1970 UTC. 0 for “all up to now”.

char *dc_get_mime_headers(dc_context_t *context, uint32_t msg_id)

Get the raw mime-headers of the given message.

Raw headers are saved for incoming messages only if dc_set_config(context, "save_mime_headers", "1") was called before.

Return

Raw headers as a multi-line string, must be free()’d after usage. Returns NULL if there are no headers saved for the given message, eg. because of save_mime_headers is not set or the message is not incoming.

Parameters
  • context: The context object as created by dc_context_new().

  • msg_id: The message id, must be the id of an incoming message.

dc_msg_t *dc_get_msg(dc_context_t *context, uint32_t msg_id)

Get a single message object of the type dc_msg_t.

For a list of messages in a chat, see dc_get_chat_msgs() For a list or chats, see dc_get_chatlist()

Return

A dc_msg_t message object. On errors, NULL is returned. When done, the object must be freed using dc_msg_unref().

Parameters
  • context: The context as created by dc_context_new().

  • msg_id: The message ID for which the message object should be created.

int dc_get_msg_cnt(dc_context_t *context, uint32_t chat_id)

Get the total number of messages in a chat.

Return

Number of total messages in the given chat. 0 for errors or empty chats.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The ID of the chat to count the messages for.

char *dc_get_msg_info(dc_context_t *context, uint32_t msg_id)

Get an informational text for a single message.

The text is multiline and may contain eg. the raw text of the message.

The max. text returned is typically longer (about 100000 characters) than the max. text returned by dc_msg_get_text() (about 30000 characters).

Return

Text string, must be free()’d after usage

Parameters
  • context: The context object as created by dc_context_new().

  • msg_id: The message id for which information should be generated

uint32_t dc_get_next_media(dc_context_t *context, uint32_t curr_msg_id, int dir, int msg_type, int msg_type2, int msg_type3)

Search next/previous message based on a given message and a list of types.

The Typically used to implement the “next” and “previous” buttons in a gallery or in a media player.

Return

Returns the message ID that should be played next. The returned message is in the same chat as the given one and has one of the given types. Typically, this result is passed again to dc_get_next_media() later on the next swipe. If there is not next/previous message, the function returns 0.

Parameters
  • context: The context object as returned from dc_context_new().

  • curr_msg_id: This is the current message from which the next or previous message should be searched.

  • dir: 1=get the next message, -1=get the previous one.

  • msg_type: Message type to search for. If 0, the message type from curr_msg_id is used.

  • msg_type2: Alternative message type to search for. 0 to skip.

  • msg_type3: Alternative message type to search for. 0 to skip.

char *dc_get_oauth2_url(dc_context_t *context, const char *addr, const char *redirect_uri)

Get url that can be used to initiate an OAuth2 authorisation.

If an OAuth2 authorization is possible for a given e-mail-address, this function returns the URL that should be opened in a browser.

If the user authorizes access, the given redirect_uri is called by the provider. It’s up to the UI to handle this call.

The provider will attach some parameters to the url, most important the parameter code that should be set as the mail_pw. With server_flags set to DC_LP_AUTH_OAUTH2, dc_configure() can be called as usual afterwards.

Note: OAuth2 depends on DC_EVENT_HTTP_POST; if you have not implemented DC_EVENT_HTTP_POST in the ui, OAuth2 won’t work.

Return

URL that can be opened in the browser to start OAuth2. If OAuth2 is not possible for the given e-mail-address, NULL is returned.

Parameters
  • context: The context object as created by dc_context_new().

  • addr: E-mail address the user has entered. In case the user selects a different e-mail-address during authorization, this is corrected in dc_configure()

  • redirect_uri: URL that will get code that is used as mail_pw then. Not all URLs are allowed here, however, the following should work: chat.delta:/PATH, , , urn:ietf:wg:oauth:2.0:oob (the latter just displays the code the user can copy+paste then)

void *dc_get_userdata(dc_context_t *context)

Get user data associated with a context object.

Return

User data, this is the second parameter given to dc_context_new().

Parameters

void dc_interrupt_imap_idle(dc_context_t *context)

Interrupt waiting for imap-jobs.

If dc_perform_imap_jobs(), dc_perform_imap_fetch() and dc_perform_imap_idle() are called in a loop, calling this function causes imap-jobs to be executed and messages to be fetched.

dc_interrupt_imap_idle() does not interrupt dc_perform_imap_jobs() or dc_perform_imap_fetch(). If the imap-thread is inside one of these functions when dc_interrupt_imap_idle() is called, however, the next call of the imap-thread to dc_perform_imap_idle() is interrupted immediately.

Internally, this function is called whenever a imap-jobs should be processed (delete message, markseen etc.).

When you need to call this function just because to get jobs done after network changes, use dc_maybe_network() instead.

Return

None.

Parameters

void dc_interrupt_mvbox_idle(dc_context_t *context)

Interrupt waiting for MVBOX-fetch.

dc_interrupt_mvbox_idle() does not interrupt dc_perform_mvbox_fetch(). If the MVBOX-thread is inside this function when dc_interrupt_mvbox_idle() is called, however, the next call of the MVBOX-thread to dc_perform_mvbox_idle() is interrupted immediately.

Internally, this function is called whenever a imap-jobs should be processed.

When you need to call this function just because to get jobs done after network changes, use dc_maybe_network() instead.

Return

None.

Parameters

void dc_interrupt_sentbox_idle(dc_context_t *context)

Interrupt waiting for messages or jobs in the SENTBOX-thread.

Return

None.

Parameters

void dc_interrupt_smtp_idle(dc_context_t *context)

Interrupt waiting for smtp-jobs.

If dc_perform_smtp_jobs() and dc_perform_smtp_idle() are called in a loop, calling this function causes jobs to be executed.

dc_interrupt_smtp_idle() does not interrupt dc_perform_smtp_jobs(). If the smtp-thread is inside this function when dc_interrupt_smtp_idle() is called, however, the next call of the smtp-thread to dc_perform_smtp_idle() is interrupted immediately.

Internally, this function is called whenever a message is to be sent.

When you need to call this function just because to get jobs done after network changes, use dc_maybe_network() instead.

Return

None.

Parameters

int dc_is_configured(const dc_context_t *context)

Check if the context is already configured.

Typically, for unconfigured accounts, the user is prompted to enter some settings and dc_configure() is called in a thread then.

Return

1=context is configured and can be used; 0=context is not configured and a configuration by dc_configure() is required.

Parameters

int dc_is_contact_in_chat(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)

Check if a given contact ID is a member of a group chat.

Return

1=contact ID is member of chat ID, 0=contact is not in chat

Parameters
  • context: The context as created by dc_context_new().

  • chat_id: The chat ID to check.

  • contact_id: The contact ID to check. To check if yourself is member of the chat, pass DC_CONTACT_ID_SELF (1) here.

int dc_is_open(const dc_context_t *context)

Check if the context database is open.

Return

0=context is not open, 1=context is open.

Parameters

int dc_is_sending_locations_to_chat(dc_context_t *context, uint32_t chat_id)

Check if location streaming is enabled.

Location stream can be enabled or disabled using dc_send_locations_to_chat(). If you have already a dc_chat_t object, dc_chat_is_sending_locations() may be more handy.

Return

1: location streaming is enabled for the given chat(s); 0: location streaming is disabled for the given chat(s).

Parameters
  • context: The context object.

  • chat_id: >0: Check if location streaming is enabled for the given chat. 0: Check of location streaming is enabled for any chat.

uint32_t dc_lookup_contact_id_by_addr(dc_context_t *context, const char *addr)

Check if an e-mail address belongs to a known and unblocked contact.

Known and unblocked contacts will be returned by dc_get_contacts().

To validate an e-mail address independently of the contact database use dc_may_be_valid_addr().

Return

1=address is a contact in use, 0=address is not a contact in use.

Parameters
  • context: The context object as created by dc_context_new().

  • addr: The e-mail-address to check.

void dc_marknoticed_all_chats(dc_context_t *context)

Same as dc_marknoticed_chat() but for all chats.

Return

None.

Parameters

void dc_marknoticed_chat(dc_context_t *context, uint32_t chat_id)

Mark all messages in a chat as noticed.

Noticed messages are no longer fresh and do not count as being unseen but are still waiting for being marked as “seen” using dc_markseen_msgs() (IMAP/MDNs is not done for noticed messages).

Calling this function usually results in the event DC_EVENT_MSGS_CHANGED. See also dc_marknoticed_all_chats(), dc_marknoticed_contact() and dc_markseen_msgs().

Return

None.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: The chat ID of which all messages should be marked as being noticed.

void dc_marknoticed_contact(dc_context_t *context, uint32_t contact_id)

Mark all messages sent by the given contact as noticed.

See also dc_marknoticed_chat() and dc_markseen_msgs()

Calling this function usually results in the event DC_EVENT_MSGS_CHANGED.

Return

None.

Parameters
  • context: The context object as created by dc_context_new()

  • contact_id: The contact ID of which all messages should be marked as noticed.

void dc_markseen_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt)

Mark a message as seen, updates the IMAP state and sends MDNs.

If the message is not in a real chat (eg. a contact request), the message is only marked as NOTICED and no IMAP/MDNs is done. See also dc_marknoticed_chat() and dc_marknoticed_contact()

Return

None.

Parameters
  • context: The context object.

  • msg_ids: An array of uint32_t containing all the messages IDs that should be marked as seen.

  • msg_cnt: The number of message IDs in msg_ids.

int dc_may_be_valid_addr(const char *addr)

Rough check if a string may be a valid e-mail address.

The function checks if the string contains a minimal amount of characters before and after the @ and . characters.

To check if a given address is a contact in the contact database use dc_lookup_contact_id_by_addr().

Return

1=address may be a valid e-mail address, 0=address won’t be a valid e-mail address

Parameters
  • addr: The e-mail-address to check.

void dc_maybe_network(dc_context_t *context)

This function can be called whenever there is a hint that the network is available again.

The library will try to send pending messages out.

Return

None.

Parameters

int dc_open(dc_context_t *context, const char *dbfile, const char *blobdir)

Open context database.

If the given file does not exist, it is created and can be set up using dc_set_config() afterwards.

Return

1 on success, 0 on failure eg. if the file is not writable or if there is already a database opened for the context.

Parameters
  • context: The context object as created by dc_context_new().

  • dbfile: The file to use to store the database, something like ~/file won’t work on all systems, if in doubt, use absolute paths.

  • blobdir: A directory to store the blobs in; a trailing slash is not needed. If you pass NULL or the empty string, deltachat-core creates a directory beside dbfile with the same name and the suffix -blobs.

void dc_openssl_init_not_required(void)

Skip OpenSSL initialisation.

By default, the OpenSSL library is initialized thread-safe when calling dc_context_new() the first time. When the last context-object is deleted using dc_context_unref(), the OpenSSL library will be released as well.

If your app needs OpenSSL on its own outside these calls, you have to initialize the OpenSSL-library yourself and skip the initialisation in deltachat-core by calling dc_openssl_init_not_required() before calling dc_context_new() the first time.

Multiple calls to dc_openssl_init_not_required() are not needed, however, they do not harm.

Return

None.

void dc_perform_imap_fetch(dc_context_t *context)

Fetch new messages, if any.

This function and dc_perform_imap_jobs() and dc_perform_imap_idle() must be called from the same thread, typically in a loop.

See dc_perform_imap_jobs() for an example.

Return

None.

Parameters

void dc_perform_imap_idle(dc_context_t *context)

Wait for messages or jobs.

This function and dc_perform_imap_jobs() and dc_perform_imap_fetch() must be called from the same thread, typically in a loop.

You should call this function directly after calling dc_perform_imap_fetch().

See dc_perform_imap_jobs() for an example.

Return

None.

Parameters

void dc_perform_imap_jobs(dc_context_t *context)

Execute pending imap-jobs.

This function and dc_perform_imap_fetch() and dc_perform_imap_idle() must be called from the same thread, typically in a loop.

Example:

void* imap_thread_func(void* context)
{
    while (true) {
        dc_perform_imap_jobs(context);
        dc_perform_imap_fetch(context);
        dc_perform_imap_idle(context);
    }
}

// start imap-thread that runs forever
pthread_t imap_thread;
pthread_create(&imap_thread, NULL, imap_thread_func, context);

... program runs ...

// network becomes available again -
// the interrupt causes dc_perform_imap_idle() in the thread above
// to return so that jobs are executed and messages are fetched.
dc_maybe_network(context);

Return

None.

Parameters

void dc_perform_mvbox_fetch(dc_context_t *context)

Fetch new messages from the MVBOX, if any.

The MVBOX is a folder on the account where chat messages are moved to. The moving is done to not disturb shared accounts that are used by both, Delta Chat and a classical MUA.

This function and dc_perform_mvbox_idle() must be called from the same thread, typically in a loop.

Example:

void* mvbox_thread_func(void* context)
{
    while (true) {
        dc_perform_mvbox_fetch(context);
        dc_perform_mvbox_idle(context);
    }
}

// start mvbox-thread that runs forever
pthread_t mvbox_thread;
pthread_create(&mvbox_thread, NULL, mvbox_thread_func, context);

... program runs ...

// network becomes available again -
// the interrupt causes dc_perform_mvbox_idle() in the thread above
// to return so that and messages are fetched.
dc_maybe_network(context);

Return

None.

Parameters

void dc_perform_mvbox_idle(dc_context_t *context)

Wait for messages or jobs in the MVBOX-thread.

This function and dc_perform_mvbox_fetch(). must be called from the same thread, typically in a loop.

You should call this function directly after calling dc_perform_mvbox_fetch().

See dc_perform_mvbox_fetch() for an example.

Return

None.

Parameters

void dc_perform_sentbox_fetch(dc_context_t *context)

Fetch new messages from the Sent folder, if any.

This function and dc_perform_sentbox_idle() must be called from the same thread, typically in a loop.

Return

None.

Parameters

void dc_perform_sentbox_idle(dc_context_t *context)

Wait for messages or jobs in the SENTBOX-thread.

This function and dc_perform_sentbox_fetch() must be called from the same thread, typically in a loop.

Return

None.

Parameters

void dc_perform_smtp_idle(dc_context_t *context)

Wait for smtp-jobs.

This function and dc_perform_smtp_jobs() must be called from the same thread, typically in a loop.

See dc_interrupt_smtp_idle() for an example.

Return

None.

Parameters

void dc_perform_smtp_jobs(dc_context_t *context)

Execute pending smtp-jobs.

This function and dc_perform_smtp_idle() must be called from the same thread, typically in a loop.

Example:

void* smtp_thread_func(void* context)
{
    while (true) {
        dc_perform_smtp_jobs(context);
        dc_perform_smtp_idle(context);
    }
}

// start smtp-thread that runs forever
pthread_t smtp_thread;
pthread_create(&smtp_thread, NULL, smtp_thread_func, context);

... program runs ...

// network becomes available again -
// the interrupt causes dc_perform_smtp_idle() in the thread above
// to return so that jobs are executed
dc_maybe_network(context);

Return

None.

Parameters

uint32_t dc_prepare_msg(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)

Prepare a message for sending.

Call this function if the file to be sent is still in creation. Once you’re done with creating the file, call dc_send_msg() as usual and the message will really be sent.

This is useful as the user can already send the next messages while e.g. the recoding of a video is not yet finished. Or the user can even forward the message with the file being still in creation to other groups.

Files being sent with the increation-method must be placed in the blob directory, see dc_get_blobdir(). If the increation-method is not used - which is probably the normal case - dc_send_msg() copies the file to the blob directory if it is not yet there. To distinguish the two cases, msg->state must be set properly. The easiest way to ensure this is to re-use the same object for both calls.

Example:

dc_msg_t* msg = dc_msg_new(context, DC_MSG_VIDEO);
dc_msg_set_file(msg, "/file/to/send.mp4", NULL);
dc_prepare_msg(context, chat_id, msg);
// ... after /file/to/send.mp4 is ready:
dc_send_msg(context, chat_id, msg);

Return

The ID of the message that is being prepared.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: Chat ID to send the message to.

  • msg: Message object to send to the chat defined by the chat ID. On succcess, msg_id and state of the object are set up, The function does not take ownership of the object, so you have to free it using dc_msg_unref() as usual.

int dc_remove_contact_from_chat(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)

Remove a member from a group.

If the group is already promoted (any message was sent to the group), all group members are informed by a special status message that is sent automatically by this function.

Sends out DC_EVENT_CHAT_MODIFIED and DC_EVENT_MSGS_CHANGED if a status message was sent.

Return

1=member removed from group, 0=error

Parameters
  • context: The context as created by dc_context_new().

  • chat_id: The chat ID to remove the contact from. Must be a group chat.

  • contact_id: The contact ID to remove from the chat.

dc_array_t *dc_search_msgs(dc_context_t *context, uint32_t chat_id, const char *query)

Search messages containing the given query string.

Searching can be done globally (chat_id=0) or in a specified chat only (chat_id set).

Global chat results are typically displayed using dc_msg_get_summary(), chat search results may just hilite the corresponding messages and present a prev/next button.

Return

An array of message IDs. Must be freed using dc_array_unref() when no longer needed. If nothing can be found, the function returns NULL.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: ID of the chat to search messages in. Set this to 0 for a global search.

  • query: The query to search for.

void dc_send_locations_to_chat(dc_context_t *context, uint32_t chat_id, int seconds)

Enable or disable location streaming for a chat.

Locations are sent to all members of the chat for the given number of seconds; after that, location streaming is automatically disabled for the chat. The current location streaming state of a chat can be checked using dc_is_sending_locations_to_chat().

The locations that should be sent to the chat can be set using dc_set_location().

Return

None.

Parameters
  • context: The context object.

  • chat_id: Chat id to enable location streaming for.

  • seconds: >0: enable location streaming for the given number of seconds; 0: disable location streaming.

uint32_t dc_send_msg(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)

Send a message defined by a dc_msg_t object to a chat.

Sends the event DC_EVENT_MSGS_CHANGED on succcess. However, this does not imply, the message really reached the recipient - sending may be delayed eg. due to network problems. However, from your view, you’re done with the message. Sooner or later it will find its way.

Example:

dc_msg_t* msg = dc_msg_new(context, DC_MSG_IMAGE);
dc_msg_set_file(msg, "/file/to/send.jpg", NULL);
dc_send_msg(context, chat_id, msg);

Return

The ID of the message that is about to be sent. 0 in case of errors.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: Chat ID to send the message to. If dc_prepare_msg() was called before, this parameter can be 0.

  • msg: Message object to send to the chat defined by the chat ID. On succcess, msg_id of the object is set up, The function does not take ownership of the object, so you have to free it using dc_msg_unref() as usual.

uint32_t dc_send_text_msg(dc_context_t *context, uint32_t chat_id, const char *text_to_send)

Send a simple text message a given chat.

Sends the event DC_EVENT_MSGS_CHANGED on succcess. However, this does not imply, the message really reached the recipient - sending may be delayed eg. due to network problems. However, from your view, you’re done with the message. Sooner or later it will find its way.

See also dc_send_msg().

Return

The ID of the message that is about being sent.

Parameters
  • context: The context object as returned from dc_context_new().

  • chat_id: Chat ID to send the text message to.

  • text_to_send: Text to send to the chat defined by the chat ID. Passing an empty text here causes an empty text to be sent, it’s up to the caller to handle this if undesired. Passing NULL as the text causes the function to return 0.

int dc_set_chat_name(dc_context_t *context, uint32_t chat_id, const char *new_name)

Set group name.

If the group is already promoted (any message was sent to the group), all group members are informed by a special status message that is sent automatically by this function.

Sends out DC_EVENT_CHAT_MODIFIED and DC_EVENT_MSGS_CHANGED if a status message was sent.

Return

1=success, 0=error

Parameters
  • chat_id: The chat ID to set the name for. Must be a group chat.

  • new_name: New name of the group.

  • context: The context as created by dc_context_new().

int dc_set_chat_profile_image(dc_context_t *context, uint32_t chat_id, const char *new_image)

Set group profile image.

If the group is already promoted (any message was sent to the group), all group members are informed by a special status message that is sent automatically by this function.

Sends out DC_EVENT_CHAT_MODIFIED and DC_EVENT_MSGS_CHANGED if a status message was sent.

To find out the profile image of a chat, use dc_chat_get_profile_image()

Return

1=success, 0=error

Parameters
  • context: The context as created by dc_context_new().

  • chat_id: The chat ID to set the image for.

  • new_image: Full path of the image to use as the group image. If you pass NULL here, the group image is deleted (for promoted groups, all members are informed about this change anyway).

int dc_set_config(dc_context_t *context, const char *key, const char *value)

Configure the context.

The configuration is handled by key=value pairs as:

  • addr = address to display (always needed)

  • mail_server = IMAP-server, guessed if left out

  • mail_user = IMAP-username, guessed if left out

  • mail_pw = IMAP-password (always needed)

  • mail_port = IMAP-port, guessed if left out

  • send_server = SMTP-server, guessed if left out

  • send_user = SMTP-user, guessed if left out

  • send_pw = SMTP-password, guessed if left out

  • send_port = SMTP-port, guessed if left out

  • server_flags = IMAP-/SMTP-flags as a combination of DC_LP flags, guessed if left out

  • displayname = Own name to use when sending messages. MUAs are allowed to spread this way eg. using CC, defaults to empty

  • selfstatus = Own status to display eg. in email footers, defaults to a standard text

  • selfavatar = File containing avatar. Will be copied to blob directory. NULL to remove the avatar. It is planned for future versions to send this image together with the next messages.

  • e2ee_enabled = 0=no end-to-end-encryption, 1=prefer end-to-end-encryption (default)

  • mdns_enabled = 0=do not send or request read receipts, 1=send and request read receipts (default)

  • inbox_watch = 1=watch INBOX-folder for changes (default), 0=do not watch the INBOX-folder

  • sentbox_watch= 1=watch Sent-folder for changes (default), 0=do not watch the Sent-folder

  • mvbox_watch = 1=watch DeltaChat-folder for changes (default), 0=do not watch the DeltaChat-folder

  • mvbox_move = 1=heuristically detect chat-messages and move them to the DeltaChat-folder, 0=do not move chat-messages

  • show_emails = DC_SHOW_EMAILS_OFF (0)= show direct replies to chats only (default), DC_SHOW_EMAILS_ACCEPTED_CONTACTS (1)= also show all mails of confirmed contacts, DC_SHOW_EMAILS_ALL (2)= also show mails of unconfirmed contacts in the deaddrop.

  • save_mime_headers = 1=save mime headers and make dc_get_mime_headers() work for subsequent calls, 0=do not save mime headers (default)

If you want to retrieve a value, use dc_get_config().

Return

0=failure, 1=success

Parameters
  • context: The context object

  • key: The option to change, see above.

  • value: The value to save for “key”

void dc_set_draft(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)

Save a draft for a chat in the database.

The UI should call this function if the user has prepared a message and exits the compose window without clicking the “send” button before. When the user later opens the same chat again, the UI can load the draft using dc_get_draft() allowing the user to continue editing and sending.

Drafts are considered when sorting messages and are also returned eg. by dc_chatlist_get_summary().

Each chat can have its own draft but only one draft per chat is possible.

If the draft is modified, an DC_EVENT_MSGS_CHANGED will be sent.

Return

None.

Parameters
  • context: The context as created by dc_context_new().

  • chat_id: The chat ID to save the draft for.

  • msg: The message to save as a draft. Existing draft will be overwritten. NULL deletes the existing draft, if any, without sending it. Currently, also non-text-messages will delete the existing drafts.

int dc_set_location(dc_context_t *context, double latitude, double longitude, double accuracy)

Set current location.

The location is sent to all chats where location streaming is enabled using dc_send_locations_to_chat().

Typically results in the event DC_EVENT_LOCATION_CHANGED with contact_id set to DC_CONTACT_ID_SELF.

The UI should call this function on all location changes. The locations set by this function are not sent immediately, instead a message with the last locations is sent out every some minutes or when the user sends out a normal message, the last locations are attached.

Return

1: location streaming is still enabled for at least one chat, this dc_set_location() should be called as soon as the location changes; 0: location streaming is no longer needed, dc_is_sending_locations_to_chat() is false for all chats.

Parameters
  • context: The context object.

  • latitude: North-south position of the location. Set to 0.0 if the latitude is not known.

  • longitude: East-west position of the location. Set to 0.0 if the longitude is not known.

  • accuracy: Estimated accuracy of the location, radial, in meters. Set to 0.0 if the accuracy is not known.

void dc_star_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt, int star)

Star/unstar messages by setting the last parameter to 0 (unstar) or 1 (star).

Starred messages are collected in a virtual chat that can be shown using dc_get_chat_msgs() using the chat_id DC_CHAT_ID_STARRED.

Return

None.

Parameters
  • context: The context object as created by dc_context_new()

  • msg_ids: An array of uint32_t message IDs defining the messages to star or unstar

  • msg_cnt: The number of IDs in msg_ids

  • star: 0=unstar the messages in msg_ids, 1=star them

void dc_stop_ongoing_process(dc_context_t *context)

Signal an ongoing process to stop.

After that, dc_stop_ongoing_process() returns without waiting for the ongoing process to return.

The ongoing process will return ASAP then, however, it may still take a moment. If in doubt, the caller may also decide to kill the thread after a few seconds; eg. the process may hang in a function not under the control of the core (eg. DC_EVENT_HTTP_GET). Another reason for dc_stop_ongoing_process() not to wait is that otherwise it would be GUI-blocking and should be started in another thread then; this would make things even more complicated.

Typical ongoing processes are started by dc_configure(), dc_initiate_key_transfer() or dc_imex(). As there is always at most only one onging process at the same time, there is no need to define which process to exit.

Return

None.

Parameters
  • context: The context object.

Private Functions

static uintptr_t cb_dummy(dc_context_t *context, int event, uintptr_t data1, uintptr_t data2)

A callback function that is used if no user-defined callback is given to dc_context_new().

The callback function simply returns 0 which is safe for every event.

static char *cb_get_config(dc_imap_t *imap, const char *key, const char *def)

The following three callback are given to dc_imap_new() to read/write configuration and to handle received messages.

As the imap-functions are typically used in a separate user-thread, also these functions may be called from a different thread.

int dc_contact_is_verified_ex(dc_contact_t *contact, const dc_apeerstate_t *peerstate)

Same as dc_contact_is_verified() but allows speeding up things by adding the peerstate belonging to the contact.

If you do not have the peerstate available, it is loaded automatically.

void dc_delete_msg_from_db(dc_context_t *context, uint32_t msg_id)

Low-level function to delete a message from the database.

This does not delete the messages from the server.

char *dc_get_version_str(void)

Find out the version of the Delta Chat core library.

Deprecated, use dc_get_config() instread

Return

String with version number as major.minor.revision. The return value must be free()’d.

int dc_is_inbox(dc_context_t *context, const char *folder_name)

Tool to check if a folder is equal to the configured INBOX.

int dc_is_mvbox(dc_context_t *context, const char *folder_name)

Tool to check if a folder is equal to the configured sent-folder.

int dc_is_sentbox(dc_context_t *context, const char *folder_name)

Tool to check if a folder is equal to the configured sent-folder.

uint32_t dc_rfc724_mid_exists(dc_context_t *context, const char *rfc724_mid, char **ret_server_folder, uint32_t *ret_server_uid)

Check, if the given Message-ID exists in the database.

If not, the caller loads the message typically completely from the server and parses it. To avoid unnecessary dowonloads and parsing, we should even keep unuseful messages in the database (we can leave the other fields empty to save space).

void dc_set_msg_failed(dc_context_t *context, uint32_t msg_id, const char *error)

Changes the state of PREPARING, PENDING or DELIVERED messages to DC_STATE_OUT_FAILED.

Moreover, the message error text can be updated. Finally, the given error text is also logged using dc_log_error().

struct dc_imapfolder_t

Public Members

int meaning
char *name_to_select
char *name_utf8
class dc_lot_t
#include <deltachat.h>

An object containing a set of values.

The meaning of the values is defined by the function returning the object. Lot objects are created eg. by dc_chatlist_get_summary() or dc_msg_get_summary().

NB: Lot is used in the meaning heap here.

Public Functions

uint32_t dc_lot_get_id(const dc_lot_t *lot)

Get the associated ID.

The meaning of the ID is defined by the creator of the object.

Return

The state as defined by the creator of the object. 0 if there is not state or on errors.

Parameters
  • lot: The lot object.

int dc_lot_get_state(const dc_lot_t *lot)

Get the associated state.

The meaning of the state is defined by the creator of the object.

Return

The state as defined by the creator of the object. 0 if there is not state or on errors.

Parameters
  • lot: The lot object.

char *dc_lot_get_text1(const dc_lot_t *lot)

Get first string.

The meaning of the string is defined by the creator of the object and may be roughly described by dc_lot_get_text1_meaning().

Return

A string, the string may be empty and the returned value must be free()’d. NULL if there is no such string.

Parameters
  • lot: The lot object.

int dc_lot_get_text1_meaning(const dc_lot_t *lot)

Get the meaning of the first string.

Posssible meanings of the string are defined by the creator of the object and may be returned eg. as DC_TEXT1_DRAFT, DC_TEXT1_USERNAME or DC_TEXT1_SELF.

Return

Returns the meaning of the first string, possible meanings are defined by the creator of the object. 0 if there is no concrete meaning or on errors.

Parameters
  • lot: The lot object.

char *dc_lot_get_text2(const dc_lot_t *lot)

Get second string.

The meaning of the string is defined by the creator of the object.

Return

A string, the string may be empty and the returned value must be free()’d . NULL if there is no such string.

Parameters
  • lot: The lot object.

time_t dc_lot_get_timestamp(const dc_lot_t *lot)

Get the associated timestamp.

The timestamp is returned as a unix timestamp in seconds. The meaning of the timestamp is defined by the creator of the object.

Return

The timestamp as defined by the creator of the object. 0 if there is not timestamp or on errors.

Parameters
  • lot: The lot object.

void dc_lot_unref(dc_lot_t *set)

Frees an object containing a set of parameters.

If the set object contains strings, the strings are also freed with this function. Set objects are created eg. by dc_chatlist_get_summary() or dc_msg_get_summary().

Return

None.

Parameters
  • set: The object to free. If NULL is given, nothing is done.

class dc_msg_t
#include <deltachat.h>

An object representing a single message in memory.

The message object is not updated. If you want an update, you have to recreate the object.

Public Functions

uint32_t dc_msg_get_chat_id(const dc_msg_t *msg)

Get the ID of chat the message belongs to.

To get details about the chat, pass the returned ID to dc_get_chat(). If a message is still in the deaddrop, the ID DC_CHAT_ID_DEADDROP is returned although internally another ID is used.

Return

The ID of the chat the message belongs to, 0 on errors.

Parameters
  • msg: The message object.

int dc_msg_get_duration(const dc_msg_t *msg)

Get the duration of audio or video.

The duration is returned in milliseconds (ms). If the duration is unknown or if the associated file is no audio or video file, 0 is returned.

See also dc_msg_get_width() and dc_msg_get_height().

Return

Duration in milliseconds, if applicable. 0 otherwise or if unknown.

Parameters
  • msg: The message object.

char *dc_msg_get_file(const dc_msg_t *msg)

Find out full path, file name and extension of the file associated with a message.

Typically files are associated with images, videos, audios, documents. Plain text messages do not have a file.

Return

Full path, file name and extension of the file associated with the message. If there is no file associated with the message, an emtpy string is returned. NULL is never returned and the returned value must be free()’d.

Parameters
  • msg: The message object.

uint64_t dc_msg_get_filebytes(const dc_msg_t *msg)

Get the size of the file.

Returns the size of the file associated with a message, if applicable.

Typically, this is used to show the size of document messages, eg. a PDF.

Return

File size in bytes, 0 if not applicable or on errors.

Parameters
  • msg: The message object.

char *dc_msg_get_filemime(const dc_msg_t *msg)

Get mime type of the file.

If there is not file, an empty string is returned. If there is no associated mime type with the file, the function guesses on; if in doubt, application/octet-stream is returned. NULL is never returned.

Return

String containing the mime type. Must be free()’d after usage. NULL is never returned.

Parameters
  • msg: The message object.

char *dc_msg_get_filename(const dc_msg_t *msg)

Get base file name without path.

The base file name includes the extension; the path is not returned. To get the full path, use dc_msg_get_file().

Return

Base file name plus extension without part. If there is no file associated with the message, an empty string is returned. The returned value must be free()’d.

Parameters
  • msg: The message object.

uint32_t dc_msg_get_from_id(const dc_msg_t *msg)

Get the ID of contact who wrote the message.

If the ID is equal to DC_CONTACT_ID_SELF (1), the message is an outgoing message that is typically shown on the right side of the chat view.

Otherwise, the message is an incoming message; to get details about the sender, pass the returned ID to dc_get_contact().

Return

The ID of the contact who wrote the message, DC_CONTACT_ID_SELF (1) if this is an outgoing message, 0 on errors.

Parameters
  • msg: The message object.

int dc_msg_get_height(const dc_msg_t *msg)

Get height of image or video.

The height is returned in pixels. If the height is unknown or if the associated file is no image or video file, 0 is returned.

Often the ascpect ratio is the more interesting thing. You can calculate this using dc_msg_get_width() / dc_msg_get_height().

See also dc_msg_get_duration().

Return

Height in pixels, if applicable. 0 otherwise or if unknown.

Parameters
  • msg: The message object.

uint32_t dc_msg_get_id(const dc_msg_t *msg)

Get the ID of the message.

Return

The ID of the message. 0 if the given message object is invalid.

Parameters
  • msg: The message object.

time_t dc_msg_get_received_timestamp(const dc_msg_t *msg)

Get message receive time.

The receive time is returned as a unix timestamp in seconds.

To get the sending time, use dc_msg_get_timestamp().

Return

Receiving time of the message. For outgoing messages, 0 is returned.

Parameters
  • msg: The message object.

char *dc_msg_get_setupcodebegin(const dc_msg_t *msg)

Get the first characters of the setup code.

Typically, this is used to pre-fill the first entry field of the setup code. If the user has several setup messages, he can be sure typing in the correct digits.

To check, if a message is a setup message, use dc_msg_is_setupmessage(). To decrypt a secret key from a setup message, use dc_continue_key_transfer().

Return

Typically, the first two digits of the setup code or an empty string if unknown. NULL is never returned. Must be free()’d when done.

Parameters
  • msg: The message object.

int dc_msg_get_showpadlock(const dc_msg_t *msg)

Check if a padlock should be shown beside the message.

Return

1=padlock should be shown beside message, 0=do not show a padlock beside the message.

Parameters
  • msg: The message object.

time_t dc_msg_get_sort_timestamp(const dc_msg_t *msg)

Get message time used for sorting.

This function returns the timestamp that is used for sorting the message into lists as returned eg. by dc_get_chat_msgs(). This may be the reveived time, the sending time or another time.

To get the receiving time, use dc_msg_get_received_timestamp(). To get the sending time, use dc_msg_get_timestamp().

Return

Time used for ordering.

Parameters
  • msg: The message object.

int dc_msg_get_state(const dc_msg_t *msg)

Get the state of a message.

Incoming message states:

  • DC_STATE_IN_FRESH (10) - Incoming fresh message. Fresh messages are not noticed nor seen and are typically shown in notifications. Use dc_get_fresh_msgs() to get all fresh messages.

  • DC_STATE_IN_NOTICED (13) - Incoming noticed message. Eg. chat opened but message not yet read - noticed messages are not counted as unread but did not marked as read nor resulted in MDNs. Use dc_marknoticed_chat() or dc_marknoticed_contact() to mark messages as being noticed.

  • DC_STATE_IN_SEEN (16) - Incoming message, really seen by the user. Marked as read on IMAP and MDN may be send. Use dc_markseen_msgs() to mark messages as being seen.

Outgoing message states:

  • DC_STATE_OUT_PREPARING (18) - For files which need time to be prepared before they can be sent, the message enters this state before DC_STATE_OUT_PENDING.

  • DC_STATE_OUT_DRAFT (19) - Message saved as draft using dc_set_draft()

  • DC_STATE_OUT_PENDING (20) - The user has send the “send” button but the message is not yet sent and is pending in some way. Maybe we’re offline (no checkmark).

  • DC_STATE_OUT_FAILED (24) - Unrecoverable error (recoverable errors result in pending messages), you’ll receive the event DC_EVENT_MSG_FAILED.

  • DC_STATE_OUT_DELIVERED (26) - Outgoing message successfully delivered to server (one checkmark). Note, that already delivered messages may get into the state DC_STATE_OUT_FAILED if we get such a hint from the server. If a sent message changes to this state, you’ll receive the event DC_EVENT_MSG_DELIVERED.

  • DC_STATE_OUT_MDN_RCVD (28) - Outgoing message read by the recipient (two checkmarks; this requires goodwill on the receiver’s side) If a sent message changes to this state, you’ll receive the event DC_EVENT_MSG_READ.

If you just want to check if a message is sent or not, please use dc_msg_is_sent() which regards all states accordingly.

The state of just created message objects is DC_STATE_UNDEFINED (0). The state is always set by the core-library, users of the library cannot set the state directly, but it is changed implicitly eg. when calling dc_marknoticed_chat() or dc_markseen_msgs().

Return

The state of the message.

Parameters
  • msg: The message object.

dc_lot_t *dc_msg_get_summary(const dc_msg_t *msg, const dc_chat_t *chat)

Get a summary for a message.

The summary is returned by a dc_lot_t object with the following fields:

  • dc_lot_t::text1: contains the username or the string “Me”. The string may be colored by having a look at text1_meaning. If the name should not be displayed, the element is NULL.

  • dc_lot_t::text1_meaning: one of DC_TEXT1_USERNAME or DC_TEXT1_SELF. Typically used to show dc_lot_t::text1 with different colors. 0 if not applicable.

  • dc_lot_t::text2: contains an excerpt of the message text.

  • dc_lot_t::timestamp: the timestamp of the message.

  • dc_lot_t::state: The state of the message as one of the DC_STATE_* constants (see dc_msg_get_state()).

Typically used to display a search result. See also dc_chatlist_get_summary() to display a list of chats.

Return

The summary as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned.

Parameters
  • msg: The message object.

  • chat: To speed up things, pass an already available chat object here. If the chat object is not yet available, it is faster to pass NULL.

char *dc_msg_get_summarytext(const dc_msg_t *msg, int approx_characters)

Get a message summary as a single line of text.

Typically used for notifications.

Return

A summary for the given messages. The returned string must be free()’d. Returns an empty string on errors, never returns NULL.

Parameters
  • msg: The message object.

  • approx_characters: Rough length of the expected string.

char *dc_msg_get_text(const dc_msg_t *msg)

Get the text of the message.

If there is no text associated with the message, an empty string is returned. NULL is never returned.

The returned text is plain text, HTML is stripped. The returned text is truncated to a max. length of currently about 30000 characters, it does not make sense to show more text in the message list and typical controls will have problems with showing much more text. This max. length is to avoid passing lots of data to the frontend which may result eg. from decoding errors (assume some bytes missing in a mime structure, forcing an attachment to be plain text).

To get information about the message and more/raw text, use dc_get_msg_info().

Return

Message text. The result must be free()’d. Never returns NULL.

Parameters
  • msg: The message object.

time_t dc_msg_get_timestamp(const dc_msg_t *msg)

Get message sending time.

The sending time is returned as a unix timestamp in seconds.

Note that the message lists returned eg. by dc_get_chat_msgs() are not sorted by the sending time but by the receiving time. This ensures newly received messages always pop up at the end of the list, however, for delayed messages, the correct sending time will be displayed.

To display detailed information about the times to the user, the UI can use dc_get_msg_info().

Return

The time of the message.

Parameters
  • msg: The message object.

int dc_msg_get_viewtype(const dc_msg_t *msg)

Get the type of the message.

Return

One of the DC_MSG constants. 0 if the given message object is invalid.

Parameters
  • msg: The message object.

int dc_msg_get_width(const dc_msg_t *msg)

Get width of image or video.

The width is returned in pixels. If the width is unknown or if the associated file is no image or video file, 0 is returned.

Often the aspect ratio is the more interesting thing. You can calculate this using dc_msg_get_width() / dc_msg_get_height().

See also dc_msg_get_duration().

Return

Width in pixels, if applicable. 0 otherwise or if unknown.

Parameters
  • msg: The message object.

int dc_msg_has_deviating_timestamp(const dc_msg_t *msg)

Check if a message has a deviating timestamp.

A message has a deviating timestamp when it is sent on another day as received/sorted by.

When the UI displays normally only the time beside the message and the full day as headlines, the UI should display the full date directly beside the message if the timestamp is deviating.

Return

1=Timestamp is deviating, the UI should display the full date beside the message. 0=Timestamp is not deviating and belongs to the same date as the date headers, displaying the time only is sufficient in this case.

Parameters
  • msg: The message object.

int dc_msg_has_location(const dc_msg_t *msg)

Check if a message has a location bound to it.

These messages are also returned by dc_get_locations() and the UI may decide to display a special icon beside such messages,

Return

1=Message has location bound to it, 0=No location bound to message.

Parameters
  • msg: The message object.

int dc_msg_is_forwarded(const dc_msg_t *msg)

Check if the message is a forwarded message.

Forwarded messages may not be created by the contact given as “from”.

Typically, the UI shows a little text for a symbol above forwarded messages.

For privacy reasons, we do not provide the name or the email address of the original author (in a typical GUI, you select the messages text and click on “forwared”; you won’t expect other data to be send to the new recipient, esp. as the new recipient may not be in any relationship to the original author)

Return

1=message is a forwarded message, 0=message not forwarded.

Parameters
  • msg: The message object.

int dc_msg_is_increation(const dc_msg_t *msg)

Check if a message is still in creation.

A message is in creation between the calls to dc_prepare_msg() and dc_send_msg().

Typically, this is used for videos that are recoded by the UI before they can be sent.

Return

1=message is still in creation (dc_send_msg() was not called yet), 0=message no longer in creation

Parameters
  • msg: The message object

int dc_msg_is_info(const dc_msg_t *msg)

Check if the message is an informational message, created by the device or by another users.

Such messages are not “typed” by the user but created due to other actions, eg. dc_set_chat_name(), dc_set_chat_profile_image() or dc_add_contact_to_chat().

These messages are typically shown in the center of the chat view, dc_msg_get_text() returns a descriptive text about what is going on.

There is no need to perform any action when seeing such a message - this is already done by the core. Typically, these messages are displayed in the center of the chat.

Return

1=message is a system command, 0=normal message

Parameters
  • msg: The message object.

int dc_msg_is_sent(const dc_msg_t *msg)

Check if a message was sent successfully.

Currently, “sent” messages are messages that are in the state “delivered” or “mdn received”, see dc_msg_get_state().

Return

1=message sent successfully, 0=message not yet sent or message is an incoming message.

Parameters
  • msg: The message object.

int dc_msg_is_setupmessage(const dc_msg_t *msg)

Check if the message is an Autocrypt Setup Message.

Setup messages should be shown in an unique way eg. using a different text color. On a click or another action, the user should be prompted for the setup code which is forwarded to dc_continue_key_transfer() then.

Setup message are typically generated by dc_initiate_key_transfer() on another device.

Return

1=message is a setup message, 0=no setup message. For setup messages, dc_msg_get_viewtype() returns DC_MSG_FILE.

Parameters
  • msg: The message object.

int dc_msg_is_starred(const dc_msg_t *msg)

Check if a message is starred.

Starred messages are “favorites” marked by the user with a “star” or something like that. Starred messages can typically be shown easily and are not deleted automatically.

To star one or more messages, use dc_star_msgs(), to get a list of starred messages, use dc_get_chat_msgs() using DC_CHAT_ID_STARRED as the chat_id.

Return

1=message is starred, 0=message not starred.

Parameters
  • msg: The message object.

void dc_msg_latefiling_mediasize(dc_msg_t *msg, int width, int height, int duration)

Late filing information to a message.

In contrast to the dc_msg_set_*() functions, this function really stores the information in the database.

Sometimes, the core cannot find out the width, the height or the duration of an image, an audio or a video.

If, in these cases, the frontend can provide the information, it can save them together with the message object for later usage.

This function should only be used if dc_msg_get_width(), dc_msg_get_height() or dc_msg_get_duration() do not provide the expected values.

To get the stored values later, use dc_msg_get_width(), dc_msg_get_height() or dc_msg_get_duration().

Return

None.

Parameters
  • msg: The message object.

  • width: The new width to store in the message object. 0 if you do not want to change width and height.

  • height: The new height to store in the message object. 0 if you do not want to change width and height.

  • duration: The new duration to store in the message object. 0 if you do not want to change it.

dc_msg_t *dc_msg_new(dc_context_t *context, int viewtype)

Create new message object.

Message objects are needed eg. for sending messages using dc_send_msg(). Moreover, they are returned eg. from dc_get_msg(), set up with the current state of a message. The message object is not updated; to achieve this, you have to recreate it.

Return

The created message object.

Parameters
  • context: The context that should be stored in the message object.

  • viewtype: The type to the message object to create, one of the DC_MSG constants.

void dc_msg_set_dimension(dc_msg_t *msg, int width, int height)

Set the dimensions associated with message object.

Typically this is the width and the height of an image or video associated using dc_msg_set_file(). This does not alter any information in the database; this may be done by dc_send_msg() later.

Return

None.

Parameters
  • msg: The message object.

  • width: Width in pixels, if known. 0 if you don’t know or don’t care.

  • height: Height in pixels, if known. 0 if you don’t know or don’t care.

void dc_msg_set_duration(dc_msg_t *msg, int duration)

Set the duration associated with message object.

Typically this is the duration of an audio or video associated using dc_msg_set_file(). This does not alter any information in the database; this may be done by dc_send_msg() later.

Return

None.

Parameters
  • msg: The message object.

  • duration: Length in milliseconds. 0 if you don’t know or don’t care.

void dc_msg_set_file(dc_msg_t *msg, const char *file, const char *filemime)

Set the file associated with a message object.

This does not alter any information in the database nor copy or move the file or checks if the file exist. All this can be done with dc_send_msg() later.

Return

None.

Parameters
  • msg: The message object.

  • file: If the message object is used in dc_send_msg() later, this must be the full path of the image file to send.

  • filemime: Mime type of the file. NULL if you don’t know or don’t care.

void dc_msg_set_location(dc_msg_t *msg, double latitude, double longitude)

Set any location that should be bound to the message object.

The function is useful to add a marker to the map at a position different from the self-location. You should not call this function if you want to bind the current self-location to a message; this is done by dc_set_location() and dc_send_locations_to_chat().

Typically results in the event DC_EVENT_LOCATION_CHANGED with contact_id set to DC_CONTACT_ID_SELF.

Return

None.

Parameters
  • msg: The message object.

  • latitude: North-south position of the location.

  • longitude: East-west position of the location.

void dc_msg_set_text(dc_msg_t *msg, const char *text)

Set the text of a message object.

This does not alter any information in the database; this may be done by dc_send_msg() later.

Return

None.

Parameters
  • msg: The message object.

  • text: Message text.

void dc_msg_unref(dc_msg_t *msg)

Free a message object.

Message objects are created eg. by dc_get_msg().

Return

None.

Parameters
  • msg: The message object to free. If NULL is given, nothing is done.

Private Functions

void dc_msg_empty(dc_msg_t *msg)

Empty a message object.

Return

None.

Parameters
  • msg: The message object to empty.

void dc_msg_guess_msgtype_from_suffix(const char *pathNfilename, int *ret_msgtype, char **ret_mime)

Guess message type from suffix.

Return

None. But there are output parameters.

Parameters
  • pathNfilename: Path and filename of the file to guess the type for.

  • [out] ret_msgtype: Guessed message type is copied here as one of the DC_MSG_* constants. May be NULL if you’re not interested in this value.

  • [out] ret_mime: The pointer to a string buffer is set to the guessed MIME-type. May be NULL. Must be free()’d by the caller.

int dc_msg_load_from_db(dc_msg_t *msg, dc_context_t *context, uint32_t id)

Load a message from the database to the message object.

struct dehtml_t

Public Members

int add_text
char *last_href
dc_strbuilder_t strbuilder
struct moz_autoconfigure_t

Public Members

const dc_loginparam_t *in
char *in_emaildomain
char *in_emaillocalpart
dc_loginparam_t *out
int out_imap_set
int out_smtp_set
int tag_config
int tag_server
struct oauth2_t

Public Members

char *client_id
char *get_code
char *get_userinfo
char *init_token
char *refresh_token
struct outlk_autodiscover_t

Public Members

char *config[_OUTLK_CNT_]
const dc_loginparam_t *in
dc_loginparam_t *out
int out_imap_set
int out_smtp_set
char *redirect
int tag_config
file dc_aheader.c
#include <ctype.h>#include “dc_context.h”#include “dc_aheader.h”#include “dc_apeerstate.h”#include “dc_mimeparser.h”

Defines

AHEADER_WS

Functions

static int add_attribute(dc_aheader_t *aheader, const char *name, const char *value)
file dc_aheader.h
#include “dc_key.h”

Functions

void dc_aheader_empty(dc_aheader_t *)
dc_aheader_t *dc_aheader_new()
dc_aheader_t *dc_aheader_new_from_imffields(const char *wanted_from, const struct mailimf_fields *mime)
char *dc_aheader_render(const dc_aheader_t *)
int dc_aheader_set_from_string(dc_aheader_t *, const char *header_str)
void dc_aheader_unref(dc_aheader_t *)
file dc_apeerstate.c
#include “dc_context.h”#include “dc_apeerstate.h”#include “dc_aheader.h”#include “dc_hash.h”

Defines

GOSSIP_KEY_COL
PEERSTATE_FIELDS
PUBLIC_KEY_COL
VERIFIED_KEY_COL

Functions

void dc_apeerstate_apply_gossip(dc_apeerstate_t *peerstate, const dc_aheader_t *gossip_header, time_t message_time)
void dc_apeerstate_apply_header(dc_apeerstate_t *peerstate, const dc_aheader_t *header, time_t message_time)
int dc_apeerstate_degrade_encryption(dc_apeerstate_t *peerstate, time_t message_time)
static void dc_apeerstate_empty(dc_apeerstate_t *peerstate)
int dc_apeerstate_has_verified_key(const dc_apeerstate_t *peerstate, const dc_hash_t *fingerprints)
int dc_apeerstate_init_from_gossip(dc_apeerstate_t *peerstate, const dc_aheader_t *gossip_header, time_t message_time)
int dc_apeerstate_init_from_header(dc_apeerstate_t *peerstate, const dc_aheader_t *header, time_t message_time)
int dc_apeerstate_load_by_addr(dc_apeerstate_t *peerstate, dc_sqlite3_t *sql, const char *addr)
int dc_apeerstate_load_by_fingerprint(dc_apeerstate_t *peerstate, dc_sqlite3_t *sql, const char *fingerprint)
dc_apeerstate_t *dc_apeerstate_new(dc_context_t *context)
int dc_apeerstate_save_to_db(const dc_apeerstate_t *peerstate, dc_sqlite3_t *sql, int create)
static void dc_apeerstate_set_from_stmt(dc_apeerstate_t *peerstate, sqlite3_stmt *stmt)
void dc_apeerstate_unref(dc_apeerstate_t *peerstate)
file dc_apeerstate.h
#include “dc_key.h”#include “dc_aheader.h”#include “dc_hash.h”

Defines

DC_BIDIRECT_VERIFIED
DC_DE_ENCRYPTION_PAUSED
DC_DE_FINGERPRINT_CHANGED
DC_NOT_VERIFIED
DC_PE_MUTUAL
DC_PE_NOPREFERENCE
DC_PE_RESET
DC_PS_GOSSIP_KEY
DC_PS_PUBLIC_KEY
DC_SAVE_ALL
DC_SAVE_TIMESTAMPS

Functions

void dc_apeerstate_apply_gossip(dc_apeerstate_t *, const dc_aheader_t *, time_t message_time)
void dc_apeerstate_apply_header(dc_apeerstate_t *, const dc_aheader_t *, time_t message_time)
int dc_apeerstate_degrade_encryption(dc_apeerstate_t *, time_t message_time)
int dc_apeerstate_has_verified_key(const dc_apeerstate_t *, const dc_hash_t *fingerprints)
int dc_apeerstate_init_from_gossip(dc_apeerstate_t *, const dc_aheader_t *, time_t message_time)
int dc_apeerstate_init_from_header(dc_apeerstate_t *, const dc_aheader_t *, time_t message_time)
int dc_apeerstate_load_by_addr(dc_apeerstate_t *, dc_sqlite3_t *, const char *addr)
int dc_apeerstate_load_by_fingerprint(dc_apeerstate_t *, dc_sqlite3_t *, const char *fingerprint)
dc_apeerstate_t *dc_apeerstate_new(dc_context_t *)
dc_key_t *dc_apeerstate_peek_key(const dc_apeerstate_t *, int min_verified)
int dc_apeerstate_recalc_fingerprint(dc_apeerstate_t *)
char *dc_apeerstate_render_gossip_header(const dc_apeerstate_t *, int min_verified)
int dc_apeerstate_save_to_db(const dc_apeerstate_t *, dc_sqlite3_t *, int create)
int dc_apeerstate_set_verified(dc_apeerstate_t *, int which_key, const char *fingerprint, int verified)
void dc_apeerstate_unref(dc_apeerstate_t *)
file dc_array.c
#include “dc_context.h”#include “dc_array.h”

Defines

DC_ARRAY_MAGIC
INT_ARR_TO_STR(a, c)

Functions

static int cmp_intptr_t(const void *p1, const void *p2)
static int cmp_strings_t(const void *p1, const void *p2)
char *dc_arr_to_string(const uint32_t *arr, int cnt)
void dc_array_add_id(dc_array_t *array, uint32_t item)

Add an ID to the array.

After calling this function the size of the array grows by one. It is okay to add the ID 0, event in this case, the array grows by one.

Return

None.

Parameters
  • array: The array to add the item to.

  • item: The item to add.

void dc_array_add_ptr(dc_array_t *array, void *item)

Add an pointer to the array.

After calling this function the size of the array grows by one. It is okay to add the ID 0, event in this case, the array grows by one.

Return

None.

Parameters
  • array: The array to add the item to.

  • item: The item to add.

void dc_array_add_uint(dc_array_t *array, uintptr_t item)

Add an unsigned integer to the array.

After calling this function the size of the array grows by one. It is okay to add the ID 0, event in this case, the array grows by one.

Return

None.

Parameters
  • array: The array to add the item to.

  • item: The item to add.

char *dc_array_get_string(const dc_array_t *array, const char *sep)
dc_array_t *dc_array_new(dc_context_t *context, size_t initsize)
file dc_array.h

Functions

char *dc_arr_to_string(const uint32_t *arr, int cnt)
dc_array_t *dc_array_duplicate(const dc_array_t *)
void dc_array_empty(dc_array_t *)
void dc_array_free_ptr(dc_array_t *)
char *dc_array_get_string(const dc_array_t *, const char *sep)
dc_array_t *dc_array_new(dc_context_t *, size_t initsize)
dc_array_t *dc_array_new_typed(dc_context_t *, int type, size_t initsize)
void dc_array_sort_ids(dc_array_t *)
void dc_array_sort_strings(dc_array_t *)
file dc_chat.c
#include <assert.h>#include “dc_context.h”#include “dc_job.h”#include “dc_smtp.h”#include “dc_imap.h”#include “dc_mimefactory.h”#include “dc_apeerstate.h”

Defines

CHAT_FIELDS
DC_CHAT_MAGIC
DO_SEND_STATUS_MAILS
IS_SELF_IN_GROUP

Functions

int dc_add_contact_to_chat_ex(dc_context_t *context, uint32_t chat_id, uint32_t contact_id, int flags)
void dc_add_device_msg(dc_context_t *context, uint32_t chat_id, const char *text)
int dc_add_to_chat_contacts_table(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)
void dc_block_chat(dc_context_t *context, uint32_t chat_id, int new_blocking)
int dc_chat_update_param(dc_chat_t *chat)
void dc_create_or_lookup_nchat_by_contact_id(dc_context_t *context, uint32_t contact_id, int create_blocked, uint32_t *ret_chat_id, int *ret_chat_blocked)
size_t dc_get_chat_cnt(dc_context_t *context)
int dc_get_chat_contact_cnt(dc_context_t *context, uint32_t chat_id)
uint32_t dc_get_chat_id_by_grpid(dc_context_t *context, const char *grpid, int *ret_blocked, int *ret_verified)
int dc_is_group_explicitly_left(dc_context_t *context, const char *grpid)
void dc_lookup_real_nchat_by_contact_id(dc_context_t *context, uint32_t contact_id, uint32_t *ret_chat_id, int *ret_chat_blocked)
void dc_reset_gossiped_timestamp(dc_context_t *context, uint32_t chat_id)
void dc_set_gossiped_timestamp(dc_context_t *context, uint32_t chat_id, time_t timestamp)
void dc_set_group_explicitly_left(dc_context_t *context, const char *grpid)
void dc_unarchive_chat(dc_context_t *context, uint32_t chat_id)
void dc_unblock_chat(dc_context_t *context, uint32_t chat_id)
static uint32_t get_draft_msg_id(dc_context_t *context, uint32_t chat_id)
static int get_parent_mime_headers(const dc_chat_t *chat, char **parent_rfc724_mid, char **parent_in_reply_to, char **parent_references)
static int last_msg_in_chat_encrypted(dc_sqlite3_t *sql, uint32_t chat_id)
static uint32_t prepare_msg_common(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)
static uint32_t prepare_msg_raw(dc_context_t *context, dc_chat_t *chat, const dc_msg_t *msg, time_t timestamp)
static int real_group_exists(dc_context_t *context, uint32_t chat_id)
static int set_draft_raw(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)
static int set_from_stmt(dc_chat_t *chat, sqlite3_stmt *row)
file dc_chat.h

Defines

DC_CHAT_DEADDROP_BLOCKED
DC_CHAT_MANUALLY_BLOCKED
DC_CHAT_NOT_BLOCKED
DC_CHAT_PREFIX
DC_CHAT_TYPE_CAN_SEND(a)
DC_CHAT_TYPE_IS_MULTI(a)
DC_FROM_HANDSHAKE

Functions

int dc_add_contact_to_chat_ex(dc_context_t *, uint32_t chat_id, uint32_t contact_id, int flags)
void dc_add_device_msg(dc_context_t *, uint32_t chat_id, const char *text)
int dc_add_to_chat_contacts_table(dc_context_t *, uint32_t chat_id, uint32_t contact_id)
void dc_block_chat(dc_context_t *, uint32_t chat_id, int new_blocking)
int dc_chat_load_from_db(dc_chat_t *, uint32_t id)
int dc_chat_update_param(dc_chat_t *)
void dc_create_or_lookup_nchat_by_contact_id(dc_context_t *, uint32_t contact_id, int create_blocked, uint32_t *ret_chat_id, int *ret_chat_blocked)
size_t dc_get_chat_cnt(dc_context_t *)
int dc_get_chat_contact_cnt(dc_context_t *, uint32_t chat_id)
uint32_t dc_get_chat_id_by_grpid(dc_context_t *, const char *grpid, int *ret_blocked, int *ret_verified)
int dc_is_contact_in_chat(dc_context_t *, uint32_t chat_id, uint32_t contact_id)
int dc_is_group_explicitly_left(dc_context_t *, const char *grpid)
void dc_lookup_real_nchat_by_contact_id(dc_context_t *, uint32_t contact_id, uint32_t *ret_chat_id, int *ret_chat_blocked)
void dc_reset_gossiped_timestamp(dc_context_t *, uint32_t chat_id)
void dc_set_gossiped_timestamp(dc_context_t *, uint32_t chat_id, time_t)
void dc_set_group_explicitly_left(dc_context_t *, const char *grpid)
void dc_unarchive_chat(dc_context_t *, uint32_t chat_id)
void dc_unblock_chat(dc_context_t *, uint32_t chat_id)
file dc_chatlist.c
#include “dc_context.h”

Defines

DC_CHATLIST_MAGIC
QUR1
QUR2

Functions

int dc_get_archived_cnt(dc_context_t *context)
static uint32_t get_last_deaddrop_fresh_msg(dc_context_t *context)
file dc_chatlist.h

Defines

DC_CHATLIST_IDS_PER_RESULT

Functions

int dc_get_archived_cnt(dc_context_t *)
file dc_configure.c
#include <dirent.h>#include <unistd.h>#include “dc_context.h”#include “dc_loginparam.h”#include “dc_imap.h”#include “dc_smtp.h”#include “dc_saxparser.h”#include “dc_job.h”#include “dc_oauth2.h”

Defines

_OUTLK_CNT_
DC_DEF_MVBOX
MEANING_OTHER_KNOWN
MEANING_SENT_OBJECTS
MEANING_UNKNOWN
MOZ_HOSTNAME
MOZ_PORT
MOZ_SERVER_IMAP
MOZ_SERVER_SMTP
MOZ_SOCKETTYPE
MOZ_USERNAME
OUTLK_PORT
OUTLK_REDIRECTURL
OUTLK_SERVER
OUTLK_SSL
OUTLK_TYPE
PROGRESS(p)
TYPICAL_IMAP_SSL_PORT
TYPICAL_IMAP_STARTTLS_PORT
TYPICAL_SMTP_PLAIN_PORT
TYPICAL_SMTP_SSL_PORT
TYPICAL_SMTP_STARTTLS_PORT

Typedefs

typedef struct dc_imapfolder_t dc_imapfolder_t
typedef struct moz_autoconfigure_t moz_autoconfigure_t
typedef struct outlk_autodiscover_t outlk_autodiscover_t

Functions

int dc_alloc_ongoing(dc_context_t *context)
void dc_configure_folders(dc_context_t *context, dc_imap_t *imap, int flags)
int dc_connect_to_configured_imap(dc_context_t *context, dc_imap_t *imap)
void dc_free_ongoing(dc_context_t *context)
int dc_has_ongoing(dc_context_t *context)
void dc_job_do_DC_JOB_CONFIGURE_IMAP(dc_context_t *context, dc_job_t *job)
static void free_folders(clist *folders)
static int get_folder_meaning(struct mailimap_mbx_list_flags *flags)
static int get_folder_meaning_by_name(const char *folder_name)
static clist *list_folders(dc_imap_t *imap)
static dc_loginparam_t *moz_autoconfigure(dc_context_t *context, const char *url, const dc_loginparam_t *param_in)
static void moz_autoconfigure_endtag_cb(void *userdata, const char *tag)
static void moz_autoconfigure_starttag_cb(void *userdata, const char *tag, char **attr)
static void moz_autoconfigure_text_cb(void *userdata, const char *text, int len)
static dc_loginparam_t *outlk_autodiscover(dc_context_t *context, const char *url__, const dc_loginparam_t *param_in)
static void outlk_autodiscover_endtag_cb(void *userdata, const char *tag)
static void outlk_autodiscover_starttag_cb(void *userdata, const char *tag, char **attr)
static void outlk_autodiscover_text_cb(void *userdata, const char *text, int len)
static void outlk_clean_config(outlk_autodiscover_t *outlk_ad)
static char *read_autoconf_file(dc_context_t *context, const char *url)
file dc_contact.c
#include “dc_context.h”#include “dc_contact.h”#include “dc_apeerstate.h”#include “dc_loginparam.h”#include “dc_pgp.h”

Defines

CONTACT_CREATED
CONTACT_MODIFIED
DC_CONTACT_MAGIC

Functions

static void cat_fingerprint(dc_strbuilder_t *ret, const char *addr, const char *fingerprint_verified, const char *fingerprint_unverified)
uint32_t dc_add_or_lookup_contact(dc_context_t *context, const char *name, const char *addr__, int origin, int *sth_modified)
int dc_addr_equals_contact(dc_context_t *context, const char *addr, uint32_t contact_id)
int dc_get_contact_origin(dc_context_t *context, uint32_t contact_id, int *ret_blocked)
size_t dc_get_real_contact_cnt(dc_context_t *context)
int dc_is_contact_blocked(dc_context_t *context, uint32_t contact_id)
int dc_real_contact_exists(dc_context_t *context, uint32_t contact_id)
void dc_scaleup_contact_origin(dc_context_t *context, uint32_t contact_id, int origin)
file dc_contact.h
#include “dc_contact.h”#include “dc_apeerstate.h”

Defines

DC_ORIGIN_ADRESS_BOOK
DC_ORIGIN_CREATE_CHAT
DC_ORIGIN_INCOMING_CC
DC_ORIGIN_INCOMING_REPLY_TO
DC_ORIGIN_INCOMING_TO
DC_ORIGIN_INCOMING_UNKNOWN_CC
DC_ORIGIN_INCOMING_UNKNOWN_FROM
DC_ORIGIN_INCOMING_UNKNOWN_TO
DC_ORIGIN_INTERNAL
DC_ORIGIN_MANUALLY_CREATED
DC_ORIGIN_MIN_CONTACT_LIST
DC_ORIGIN_MIN_START_NEW_NCHAT
DC_ORIGIN_MIN_VERIFIED
DC_ORIGIN_OUTGOING_BCC
DC_ORIGIN_OUTGOING_CC
DC_ORIGIN_OUTGOING_TO
DC_ORIGIN_SECUREJOIN_INVITED
DC_ORIGIN_SECUREJOIN_JOINED
DC_ORIGIN_UNHANDLED_QR_SCAN

Functions

uint32_t dc_add_or_lookup_contact(dc_context_t *, const char *display_name, const char *addr_spec, int origin, int *sth_modified)
int dc_addr_cmp(const char *addr1, const char *addr2)
int dc_addr_equals_contact(dc_context_t *, const char *addr, uint32_t contact_id)
int dc_addr_equals_self(dc_context_t *, const char *addr)
char *dc_addr_normalize(const char *addr)
int dc_contact_is_verified_ex(dc_contact_t *, const dc_apeerstate_t *)
int dc_contact_load_from_db(dc_contact_t *, dc_sqlite3_t *, uint32_t contact_id)
int dc_get_contact_origin(dc_context_t *, uint32_t contact_id, int *ret_blocked)
char *dc_get_first_name(const char *full_name)
size_t dc_get_real_contact_cnt(dc_context_t *)
int dc_is_contact_blocked(dc_context_t *, uint32_t contact_id)
void dc_normalize_name(char *full_name)
int dc_real_contact_exists(dc_context_t *, uint32_t contact_id)
void dc_scaleup_contact_origin(dc_context_t *, uint32_t contact_id, int origin)
file dc_context.c
#include <sys/stat.h>#include <sys/types.h>#include <locale.h>#include <unistd.h>#include <openssl/opensslv.h>#include <assert.h>#include “dc_context.h”#include “dc_imap.h”#include “dc_smtp.h”#include “dc_openssl.h”#include “dc_mimefactory.h”#include “dc_tools.h”#include “dc_job.h”#include “dc_key.h”#include “dc_pgp.h”#include “dc_apeerstate.h”

Defines

str_array_len(a)

Functions

static int cb_precheck_imf(dc_imap_t *imap, const char *rfc724_mid, const char *server_folder, uint32_t server_uid)
static void cb_receive_imf(dc_imap_t *imap, const char *imf_raw_not_terminated, size_t imf_raw_bytes, const char *server_folder, uint32_t server_uid, uint32_t flags)
static void cb_set_config(dc_imap_t *imap, const char *key, const char *value)
static char *get_config_keys_str()
static char *get_sys_config_str(const char *key)
static int is_gettable_config_key(const char *key)
static int is_settable_config_key(const char *key)

Variables

const char *config_keys[]
const char *sys_config_keys[] = {"sys.version", , }
file dc_context.h
#include <stdlib.h>#include <string.h>#include <pthread.h>#include <libetpan/libetpan.h>#include “deltachat.h”#include “dc_sqlite3.h”#include “dc_tools.h”#include “dc_strbuilder.h”#include “dc_strencode.h”#include “dc_param.h”#include “dc_stock.h”#include “dc_array.h”#include “dc_chat.h”#include “dc_chatlist.h”#include “dc_lot.h”#include “dc_msg.h”#include “dc_contact.h”#include “dc_jobthread.h”#include “dc_imap.h”#include “dc_smtp.h”#include “dc_job.h”#include “dc_mimeparser.h”#include “dc_hash.h”

Defines

DC_ALREADY_CONNECTED
DC_ARRAY_LOCATIONS
DC_BAK_PREFIX
DC_BAK_SUFFIX
DC_BOB_ERROR
DC_BOB_SUCCESS
DC_CONTEXT_MAGIC
DC_CREATE_MVBOX
DC_E2EE_DEFAULT_ENABLED
DC_FOLDERS_CONFIGURED_VERSION
DC_HANDSHAKE_ADD_DELETE_JOB
DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING
DC_HANDSHAKE_STOP_NORMAL_PROCESSING
DC_INBOX_WATCH_DEFAULT
DC_JOBS_NEEDED_AT_ONCE
DC_JOBS_NEEDED_AVOID_DOS
DC_JUST_CONNECTED
DC_MDNS_DEFAULT_ENABLED
DC_MSGSIZE_UPPER_LIMIT
DC_MVBOX_MOVE_DEFAULT
DC_MVBOX_WATCH_DEFAULT
DC_NOT_CONNECTED
DC_OPENPGP4FPR_SCHEME
DC_SENTBOX_WATCH_DEFAULT
DC_SHOW_EMAILS_DEFAULT
DC_VC_AUTH_REQUIRED
DC_VC_CONTACT_CONFIRM

Typedefs

typedef struct _dc_kml dc_kml_t
typedef struct _dc_location dc_location_t

Functions

void dc_add_to_keyhistory(dc_context_t *, const char *rfc724_mid, time_t, const char *addr, const char *fingerprint)
int dc_alloc_ongoing(dc_context_t *)
void dc_configure_folders(dc_context_t *, dc_imap_t *, int flags)
int dc_connect_to_configured_imap(dc_context_t *, dc_imap_t *)
char *dc_create_setup_code(dc_context_t *)
char *dc_decrypt_setup_file(dc_context_t *, const char *passphrase, const char *filecontent)
void dc_do_heuristics_moves(dc_context_t *, const char *folder, uint32_t msg_id)
void dc_e2ee_decrypt(dc_context_t *, struct mailmime *in_out_message, dc_e2ee_helper_t *)
void dc_e2ee_encrypt(dc_context_t *, const clist *recipients_addr, int force_plaintext, int e2ee_guaranteed, int min_verified, int do_gossip, struct mailmime *in_out_message, dc_e2ee_helper_t *)
void dc_e2ee_thanks(dc_e2ee_helper_t *)
int dc_ensure_secret_key_exists(dc_context_t *)
void dc_free_ongoing(dc_context_t *)
char *dc_get_location_kml(dc_context_t *, uint32_t chat_id, uint32_t *last_added_location_id)
char *dc_get_message_kml(dc_context_t *, time_t timestamp, double latitude, double longitude)
void dc_handle_degrade_event(dc_context_t *, dc_apeerstate_t *)
int dc_handle_securejoin_handshake(dc_context_t *, dc_mimeparser_t *, uint32_t contact_id)
int dc_has_ongoing(dc_context_t *)
int dc_is_inbox(dc_context_t *, const char *folder)
int dc_is_mvbox(dc_context_t *, const char *folder)
int dc_is_sentbox(dc_context_t *, const char *folder)
void dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(dc_context_t *, dc_job_t *)
void dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(dc_context_t *, dc_job_t *)
dc_kml_t *dc_kml_parse(dc_context_t *, const char *content, size_t content_bytes)
void dc_kml_unref(dc_kml_t *)
void dc_log_error(dc_context_t *, int data1, const char *msg, ...)
void dc_log_event(dc_context_t *, int event_code, int data1, const char *msg, ...)
void dc_log_event_seq(dc_context_t *, int event_code, int *sequence_start, const char *msg, ...)
void dc_log_info(dc_context_t *, int data1, const char *msg, ...)
void dc_log_warning(dc_context_t *, int data1, const char *msg, ...)
char *dc_normalize_setup_code(dc_context_t *, const char *passphrase)
void dc_receive_imf(dc_context_t *, const char *imf_raw_not_terminated, size_t imf_raw_bytes, const char *server_folder, uint32_t server_uid, uint32_t flags)
char *dc_render_setup_file(dc_context_t *, const char *passphrase)
uint32_t dc_save_locations(dc_context_t *, uint32_t chat_id, uint32_t contact_id, const dc_array_t *, int independent)
void dc_set_kml_sent_timestamp(dc_context_t *, uint32_t chat_id, time_t)
void dc_set_msg_location_id(dc_context_t *, uint32_t msg_id, uint32_t location_id)

Variables

int dc_shall_stop_ongoing
file dc_dehtml.c
#include <stdlib.h>#include <string.h>#include “dc_context.h”#include “dc_dehtml.h”#include “dc_saxparser.h”#include “dc_tools.h”#include “dc_strbuilder.h”

Defines

DO_ADD_PRESERVE_LINEENDS
DO_ADD_REMOVE_LINEENDS
DO_NOT_ADD

Typedefs

typedef struct dehtml_t dehtml_t

Functions

char *dc_dehtml(char *buf_terminated)
static void dehtml_endtag_cb(void *userdata, const char *tag)
static void dehtml_starttag_cb(void *userdata, const char *tag, char **attr)
static void dehtml_text_cb(void *userdata, const char *text, int len)
file dc_dehtml.h

Functions

char *dc_dehtml(char *buf_terminated)
file dc_e2ee.c
#include “dc_context.h”#include “dc_pgp.h”#include “dc_aheader.h”#include “dc_keyring.h”#include “dc_mimeparser.h”#include “dc_apeerstate.h”

Functions

static int contains_report(struct mailmime *mime)

Check if a MIME structure contains a multipart/report part.

As reports are often unencrypted, we do not reset the Autocrypt header in this case.

However, Delta Chat itself has no problem with encrypted multipart/report parts and MUAs should be encouraged to encrpyt multipart/reports as well so that we could use the normal Autocrypt processing.

Return

1=multipart/report found in MIME, 0=no multipart/report found

Parameters
  • mime: The mime struture to check

void dc_e2ee_decrypt(dc_context_t *context, struct mailmime *in_out_message, dc_e2ee_helper_t *helper)
void dc_e2ee_encrypt(dc_context_t *context, const clist *recipients_addr, int force_unencrypted, int e2ee_guaranteed, int min_verified, int do_gossip, struct mailmime *in_out_message, dc_e2ee_helper_t *helper)
void dc_e2ee_thanks(dc_e2ee_helper_t *helper)
int dc_ensure_secret_key_exists(dc_context_t *context)
static int decrypt_part(dc_context_t *context, struct mailmime *mime, const dc_keyring_t *private_keyring, const dc_keyring_t *public_keyring_for_validate, dc_hash_t *ret_valid_signatures, struct mailmime **ret_decrypted_mime)
static int decrypt_recursive(dc_context_t *context, struct mailmime *mime, const dc_keyring_t *private_keyring, const dc_keyring_t *public_keyring_for_validate, dc_hash_t *ret_valid_signatures, struct mailimf_fields **ret_gossip_headers, int *ret_has_unencrypted_parts)
static int has_decrypted_pgp_armor(const char *str__, int str_bytes)
static int load_or_generate_self_public_key(dc_context_t *context, dc_key_t *public_key, const char *self_addr, struct mailmime *random_data_mime)
static struct mailmime *new_data_part(void *data, size_t data_bytes, char *default_content_type, int default_encoding)
static dc_hash_t *update_gossip_peerstates(dc_context_t *context, time_t message_time, struct mailimf_fields *imffields, const struct mailimf_fields *gossip_headers)
file dc_hash.c
#include <assert.h>#include <stdlib.h>#include <memory.h>#include <string.h>#include <stdint.h>#include “dc_context.h”#include “dc_hash.h”

Defines

Addr(X)
sjhashFree(a)
sjhashMallocRaw(a)

Functions

static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2)
static int binHash(const void *pKey, int nKey)
void dc_hash_clear(dc_hash_t *pH)
void *dc_hash_find(const dc_hash_t *pH, const void *pKey, int nKey)
void dc_hash_init(dc_hash_t *pNew, int keyClass, int copyKey)
void *dc_hash_insert(dc_hash_t *pH, const void *pKey, int nKey, void *data)
static dc_hashelem_t *findElementGivenHash(const dc_hash_t *pH, const void *pKey, int nKey, int h)
static void insertElement(dc_hash_t *pH, struct _ht *pEntry, dc_hashelem_t *pNew)
static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2)
static int intHash(const void *pKey, int nKey)
static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2)
static int ptrHash(const void *pKey, int nKey)
static void rehash(dc_hash_t *pH, int new_size)
static void removeElementGivenHash(dc_hash_t *pH, dc_hashelem_t *elem, int h)
static void *sjhashMalloc(long bytes)
static int sjhashNoCase(const char *z, int n)
static int sjhashStrNICmp(const char *zLeft, const char *zRight, int N)
static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2)
static int strHash(const void *pKey, int nKey)

Variables

int(*)(const void*, int, const void*, int) compareFunction(int keyClass)
int(*)(const void*, int) hashFunction(int keyClass)
const unsigned char sjhashUpperToLower[] = {0, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , }
file dc_hash.h

Defines

DC_HASH_BINARY
dc_hash_cnt(H)
DC_HASH_COPY_KEY
dc_hash_data(E)
dc_hash_find_str(H, s)
dc_hash_first(H)
dc_hash_insert_str(H, s, d)
DC_HASH_INT
dc_hash_key(E)
dc_hash_keysize(E)
dc_hash_next(E)
DC_HASH_POINTER
DC_HASH_STRING

Functions

void dc_hash_clear(dc_hash_t *)
void *dc_hash_find(const dc_hash_t *, const void *pKey, int nKey)
void dc_hash_init(dc_hash_t *, int keytype, int copyKey)
void *dc_hash_insert(dc_hash_t *, const void *pKey, int nKey, void *pData)
file dc_imap.c
#include <stdlib.h>#include <libetpan/libetpan.h>#include <sys/stat.h>#include <string.h>#include <unistd.h>#include “dc_context.h”#include “dc_imap.h”#include “dc_job.h”#include “dc_loginparam.h”#include “dc_oauth2.h”

Defines

FREE_FETCH_LIST(a)
FREE_SET(a)
IDLE_DELAY_SECONDS

Functions

static int add_flag(dc_imap_t *imap, uint32_t server_uid, struct mailimap_flag *flag)
int dc_imap_connect(dc_imap_t *imap, const dc_loginparam_t *lp)
int dc_imap_delete_msg(dc_imap_t *imap, const char *rfc724_mid, const char *folder, uint32_t server_uid)
void dc_imap_disconnect(dc_imap_t *imap)
int dc_imap_fetch(dc_imap_t *imap)
void dc_imap_idle(dc_imap_t *imap)
void dc_imap_interrupt_idle(dc_imap_t *imap)
int dc_imap_is_connected(const dc_imap_t *imap)
int dc_imap_is_error(dc_imap_t *imap, int code)
dc_imap_res dc_imap_move(dc_imap_t *imap, const char *folder, uint32_t uid, const char *dest_folder, uint32_t *dest_uid)
dc_imap_t *dc_imap_new(dc_get_config_t get_config, dc_set_config_t set_config, dc_precheck_imf_t precheck_imf, dc_receive_imf_t receive_imf, void *userData, dc_context_t *context)
dc_imap_res dc_imap_set_mdnsent(dc_imap_t *imap, const char *folder, uint32_t uid)
dc_imap_res dc_imap_set_seen(dc_imap_t *imap, const char *folder, uint32_t uid)
void dc_imap_set_watch_folder(dc_imap_t *imap, const char *watch_folder)
void dc_imap_unref(dc_imap_t *imap)
static void fake_idle(dc_imap_t *imap)
static int fetch_from_single_folder(dc_imap_t *imap, const char *folder)
static int fetch_single_msg(dc_imap_t *imap, const char *folder, uint32_t server_uid)
static void free_connect_param(dc_imap_t *imap)
static void get_config_lastseenuid(dc_imap_t *imap, const char *folder, uint32_t *uidvalidity, uint32_t *lastseenuid)
static char *get_error_msg(dc_imap_t *imap, const char *what_failed, int code)
static void peek_body(struct mailimap_msg_att *msg_att, char **p_msg, size_t *p_msg_bytes, uint32_t *flags, int *deleted)
static int peek_flag_keyword(struct mailimap_msg_att *msg_att, const char *flag_keyword)
static const char *peek_rfc724_mid(struct mailimap_msg_att *msg_att)
static uint32_t peek_uid(struct mailimap_msg_att *msg_att)
static int select_folder(dc_imap_t *imap, const char *folder)
static void set_config_lastseenuid(dc_imap_t *imap, const char *folder, uint32_t uidvalidity, uint32_t lastseenuid)
static int setup_handle_if_needed(dc_imap_t *imap)
static char *unquote_rfc724_mid(const char *in)
static void unsetup_handle(dc_imap_t *imap)
file dc_imap.h
#include “dc_loginparam.h”

Defines

DC_IMAP_SEEN

Typedefs

typedef char *(*dc_get_config_t)(dc_imap_t *, const char *, const char *)
typedef int (*dc_precheck_imf_t)(dc_imap_t *, const char *rfc724_mid, const char *server_folder, uint32_t server_uid)
typedef void (*dc_receive_imf_t)(dc_imap_t *, const char *imf_raw_not_terminated, size_t imf_raw_bytes, const char *server_folder, uint32_t server_uid, uint32_t flags)
typedef void (*dc_set_config_t)(dc_imap_t *, const char *, const char *)

Enums

enum dc_imap_res

Values:

DC_FAILED = 0
DC_RETRY_LATER = 1
DC_ALREADY_DONE = 2
DC_SUCCESS = 3

Functions

int dc_imap_connect(dc_imap_t *, const dc_loginparam_t *)
int dc_imap_delete_msg(dc_imap_t *, const char *rfc724_mid, const char *folder, uint32_t server_uid)
void dc_imap_disconnect(dc_imap_t *)
int dc_imap_fetch(dc_imap_t *)
void dc_imap_idle(dc_imap_t *)
void dc_imap_interrupt_idle(dc_imap_t *)
int dc_imap_is_connected(const dc_imap_t *)
int dc_imap_is_error(dc_imap_t *imap, int code)
dc_imap_res dc_imap_move(dc_imap_t *, const char *folder, uint32_t uid, const char *dest_folder, uint32_t *dest_uid)
dc_imap_t *dc_imap_new(dc_get_config_t, dc_set_config_t, dc_precheck_imf_t, dc_receive_imf_t, void *userData, dc_context_t *)
dc_imap_res dc_imap_set_mdnsent(dc_imap_t *, const char *folder, uint32_t uid)
dc_imap_res dc_imap_set_seen(dc_imap_t *, const char *folder, uint32_t uid)
void dc_imap_set_watch_folder(dc_imap_t *, const char *watch_folder)
void dc_imap_unref(dc_imap_t *)
file dc_imex.c
#include <assert.h>#include <dirent.h>#include <unistd.h>#include <openssl/rand.h>#include <libetpan/mmapstring.h>#include “dc_context.h”#include “dc_mimeparser.h”#include “dc_loginparam.h”#include “dc_aheader.h”#include “dc_apeerstate.h”#include “dc_pgp.h”#include “dc_mimefactory.h”#include “dc_job.h”

Import/Export

FILE_PROGRESS
char *dc_normalize_setup_code(dc_context_t *context, const char *in)
static int set_self_key(dc_context_t *context, const char *armored, int set_default)
static int export_key_to_asc_file(dc_context_t *context, const char *dir, int id, const dc_key_t *key, int is_default)
static int export_self_keys(dc_context_t *context, const char *dir)
static int import_self_keys(dc_context_t *context, const char *dir_name)
static int export_backup(dc_context_t *context, const char *dir)
static int import_backup(dc_context_t *context, const char *backup_to_import)
void dc_job_do_DC_JOB_IMEX_IMAP(dc_context_t *context, dc_job_t *job)

Defines

CHECK_EXIT
CODE_ELEMS
LINEEND
file dc_job.c
#include <stdarg.h>#include <unistd.h>#include <math.h>#include “dc_context.h”#include “dc_loginparam.h”#include “dc_job.h”#include “dc_imap.h”#include “dc_smtp.h”#include “dc_mimefactory.h”

Defines

FIELDS
IS_EXCLUSIVE_JOB
JOB_RETRIES
MULTIPLY
THREAD_STR

Functions

static int connect_to_inbox(dc_context_t *context)
static int dc_add_smtp_job(dc_context_t *context, int action, dc_mimefactory_t *mimefactory)

Store the MIME message in a file and send it later with a new SMTP job.

Return

1=success, 0=error

Parameters
  • context: The context object as created by dc_context_new()

  • action: One of the DC_JOB_SEND_ constants

  • mimefactory: An instance of dc_mimefactory_t with a loaded and rendered message or MDN

int dc_job_action_exists(dc_context_t *context, int action)
void dc_job_add(dc_context_t *context, int action, int foreign_id, const char *param, int delay_seconds)
static void dc_job_delete(dc_context_t *context, const dc_job_t *job)
static void dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(dc_context_t *context, dc_job_t *job)
static void dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(dc_context_t *context, dc_job_t *job)
static void dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(dc_context_t *context, dc_job_t *job)
static void dc_job_do_DC_JOB_MOVE_MSG(dc_context_t *context, dc_job_t *job)
static void dc_job_do_DC_JOB_SEND(dc_context_t *context, dc_job_t *job)
void dc_job_kill_action(dc_context_t *context, int action)
static void dc_job_perform(dc_context_t *context, int thread, int probe_network)
int dc_job_send_msg(dc_context_t *context, uint32_t msg_id)

Create an SMTP job to send a message from the DB.

Return

1=success, 0=error

Parameters
  • context: The context object as created by dc_context_new()

  • msg_id: The ID of the message to send

void dc_job_try_again_later(dc_job_t *job, int try_again, const char *pending_error)
static void dc_job_update(dc_context_t *context, const dc_job_t *job)
static void dc_send_mdn(dc_context_t *context, uint32_t msg_id)
static void dc_suspend_smtp_thread(dc_context_t *context, int suspend)
static time_t get_backoff_time_offset(int c_tries)
static time_t get_next_wakeup_time(dc_context_t *context, int thread)
file dc_job.h

Defines

DC_AT_ONCE
DC_DONT_TRY_AGAIN
DC_IMAP_THREAD
DC_IMAP_TIMEOUT_SEC
DC_INCREATION_POLL
DC_JOB_CONFIGURE_IMAP
DC_JOB_DELETE_MSG_ON_IMAP
DC_JOB_HOUSEKEEPING
DC_JOB_IMEX_IMAP
DC_JOB_MARKSEEN_MDN_ON_IMAP
DC_JOB_MARKSEEN_MSG_ON_IMAP
DC_JOB_MAYBE_SEND_LOC_ENDED
DC_JOB_MAYBE_SEND_LOCATIONS
DC_JOB_MOVE_MSG
DC_JOB_SEND_MDN
DC_JOB_SEND_MDN_OLD
DC_JOB_SEND_MSG_TO_SMTP
DC_JOB_SEND_MSG_TO_SMTP_OLD
DC_SMTP_THREAD
DC_SMTP_TIMEOUT_SEC
DC_STANDARD_DELAY

Functions

int dc_job_action_exists(dc_context_t *, int action)
void dc_job_add(dc_context_t *, int action, int foreign_id, const char *param, int delay)
void dc_job_do_DC_JOB_CONFIGURE_IMAP(dc_context_t *, dc_job_t *)
void dc_job_do_DC_JOB_IMEX_IMAP(dc_context_t *, dc_job_t *)
void dc_job_kill_action(dc_context_t *, int action)
int dc_job_send_msg(dc_context_t *context, uint32_t msg_id)

Create an SMTP job to send a message from the DB.

Return

1=success, 0=error

Parameters
  • context: The context object as created by dc_context_new()

  • msg_id: The ID of the message to send

void dc_job_try_again_later(dc_job_t *, int try_again, const char *error)
file dc_jobthread.c
#include <stdarg.h>#include <unistd.h>#include “dc_context.h”#include “dc_imap.h”

Functions

static int connect_to_imap(dc_jobthread_t *jobthread)
void dc_jobthread_exit(dc_jobthread_t *jobthread)
void dc_jobthread_fetch(dc_jobthread_t *jobthread, int use_network)
void dc_jobthread_idle(dc_jobthread_t *jobthread, int use_network)
void dc_jobthread_init(dc_jobthread_t *jobthread, dc_context_t *context, const char *name, const char *folder_config_name)
void dc_jobthread_interrupt_idle(dc_jobthread_t *jobthread)
void dc_jobthread_suspend(dc_jobthread_t *jobthread, int suspend)
file dc_jobthread.h

Functions

void dc_jobthread_exit(dc_jobthread_t *)
void dc_jobthread_fetch(dc_jobthread_t *, int use_network)
void dc_jobthread_idle(dc_jobthread_t *, int use_network)
void dc_jobthread_init(dc_jobthread_t *, dc_context_t *context, const char *name, const char *folder_config_name)
void dc_jobthread_interrupt_idle(dc_jobthread_t *)
void dc_jobthread_suspend(dc_jobthread_t *, int suspend)
file dc_jsmn.c
#include “dc_jsmn.h”
file dc_jsmn.h
#include <stddef.h>
file dc_key.c
#include <ctype.h>#include <memory.h>#include “dc_context.h”#include “dc_key.h”#include “dc_pgp.h”#include “dc_tools.h”

Defines

CRC24_INIT
CRC24_POLY

Functions

static long crc_octets(const unsigned char *octets, size_t len)
char *dc_format_fingerprint(const char *fingerprint)
static void dc_key_empty(dc_key_t *key)
int dc_key_equals(const dc_key_t *key, const dc_key_t *o)
char *dc_key_get_fingerprint(const dc_key_t *key)
char *dc_key_get_formatted_fingerprint(const dc_key_t *key)
int dc_key_load_self_private(dc_key_t *key, const char *self_addr, dc_sqlite3_t *sql)
int dc_key_load_self_public(dc_key_t *key, const char *self_addr, dc_sqlite3_t *sql)
dc_key_t *dc_key_new()
dc_key_t *dc_key_ref(dc_key_t *key)
char *dc_key_render_asc(const dc_key_t *key, const char *add_header_lines)
int dc_key_render_asc_to_file(const dc_key_t *key, const char *file, dc_context_t *context)
char *dc_key_render_base64(const dc_key_t *key, int break_every, const char *break_chars, int add_checksum)
int dc_key_save_self_keypair(const dc_key_t *public_key, const dc_key_t *private_key, const char *addr, int is_default, dc_sqlite3_t *sql)
int dc_key_set_from_base64(dc_key_t *key, const char *base64, int type)
int dc_key_set_from_binary(dc_key_t *key, const void *data, int bytes, int type)
int dc_key_set_from_file(dc_key_t *key, const char *pathNfilename, dc_context_t *context)
int dc_key_set_from_key(dc_key_t *key, const dc_key_t *o)
int dc_key_set_from_stmt(dc_key_t *key, sqlite3_stmt *stmt, int index, int type)
void dc_key_unref(dc_key_t *key)
char *dc_normalize_fingerprint(const char *in)
char *dc_render_base64(const void *buf, size_t buf_bytes, int break_every, const char *break_chars, int add_checksum)
void dc_wipe_secret_mem(void *buf, size_t buf_bytes)
file dc_key.h
#include <sqlite3.h>

Defines

DC_KEY_PRIVATE
DC_KEY_PUBLIC

Functions

char *dc_format_fingerprint(const char *)
int dc_key_equals(const dc_key_t *, const dc_key_t *)
char *dc_key_get_fingerprint(const dc_key_t *)
char *dc_key_get_formatted_fingerprint(const dc_key_t *)
int dc_key_load_self_private(dc_key_t *, const char *self_addr, dc_sqlite3_t *sql)
int dc_key_load_self_public(dc_key_t *, const char *self_addr, dc_sqlite3_t *sql)
dc_key_t *dc_key_new()
dc_key_t *dc_key_ref(dc_key_t *)
char *dc_key_render_asc(const dc_key_t *, const char *add_header_lines)
int dc_key_render_asc_to_file(const dc_key_t *, const char *file, dc_context_t *)
char *dc_key_render_base64(const dc_key_t *, int break_every, const char *break_chars, int add_checksum)
int dc_key_save_self_keypair(const dc_key_t *public_key, const dc_key_t *private_key, const char *addr, int is_default, dc_sqlite3_t *sql)
int dc_key_set_from_base64(dc_key_t *, const char *base64, int type)
int dc_key_set_from_binary(dc_key_t *, const void *data, int bytes, int type)
int dc_key_set_from_file(dc_key_t *, const char *file, dc_context_t *)
int dc_key_set_from_key(dc_key_t *, const dc_key_t *)
int dc_key_set_from_stmt(dc_key_t *, sqlite3_stmt *, int index, int type)
void dc_key_unref(dc_key_t *)
char *dc_normalize_fingerprint(const char *)
char *dc_render_base64(const void *buf, size_t buf_bytes, int break_every, const char *break_chars, int add_checksum)
void dc_wipe_secret_mem(void *buf, size_t buf_bytes)
file dc_keyhistory.c
#include “dc_context.h”

Functions

void dc_add_to_keyhistory(dc_context_t *context, const char *rfc724_mid, time_t sending_time, const char *addr, const char *fingerprint)
file dc_keyring.c
#include <memory.h>#include “dc_context.h”#include “dc_key.h”#include “dc_keyring.h”#include “dc_tools.h”

Functions

void dc_keyring_add(dc_keyring_t *keyring, dc_key_t *to_add)
int dc_keyring_load_self_private_for_decrypting(dc_keyring_t *keyring, const char *self_addr, dc_sqlite3_t *sql)
dc_keyring_t *dc_keyring_new()
void dc_keyring_unref(dc_keyring_t *keyring)
file dc_keyring.h
#include “dc_key.h”

Functions

void dc_keyring_add(dc_keyring_t *, dc_key_t *)
int dc_keyring_load_self_private_for_decrypting(dc_keyring_t *, const char *self_addr, dc_sqlite3_t *sql)
dc_keyring_t *dc_keyring_new()
void dc_keyring_unref()
file dc_location.c
#include “dc_context.h”#include “dc_saxparser.h”#include “dc_mimefactory.h”

Defines

FORCE_SCHEDULE
MAYBE_SEND_LOCATIONS_WAIT_SECONDS
TAG_COORDINATES
TAG_PLACEMARK
TAG_POINT
TAG_TIMESTAMP
TAG_WHEN

Functions

char *dc_get_location_kml(dc_context_t *context, uint32_t chat_id, uint32_t *last_added_location_id)
char *dc_get_message_kml(dc_context_t *context, time_t timestamp, double latitude, double longitude)
void dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(dc_context_t *context, dc_job_t *job)
void dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(dc_context_t *context, dc_job_t *job)
dc_kml_t *dc_kml_parse(dc_context_t *context, const char *content, size_t content_bytes)
void dc_kml_unref(dc_kml_t *kml)
uint32_t dc_save_locations(dc_context_t *context, uint32_t chat_id, uint32_t contact_id, const dc_array_t *locations, int independent)
void dc_set_kml_sent_timestamp(dc_context_t *context, uint32_t chat_id, time_t timestamp)
void dc_set_msg_location_id(dc_context_t *context, uint32_t msg_id, uint32_t location_id)
static char *get_kml_timestamp(time_t utc)
static int is_marker(const char *txt)
static void kml_endtag_cb(void *userdata, const char *tag)
static void kml_starttag_cb(void *userdata, const char *tag, char **attr)
static void kml_text_cb(void *userdata, const char *text, int len)
static void schedule_MAYBE_SEND_LOCATIONS(dc_context_t *context, int flags)
file dc_log.c
#include <stdarg.h>#include <memory.h>#include “dc_context.h”

Defines

BUFSIZE

Functions

void dc_log_error(dc_context_t *context, int data1, const char *msg, ...)
void dc_log_event(dc_context_t *context, int event_code, int data1, const char *msg, ...)
void dc_log_event_seq(dc_context_t *context, int event_code, int *sequence_start, const char *msg, ...)
void dc_log_info(dc_context_t *context, int data1, const char *msg, ...)
void dc_log_warning(dc_context_t *context, int data1, const char *msg, ...)
static void log_vprintf(dc_context_t *context, int event, int data1, const char *msg_format, va_list va)
file dc_loginparam.c
#include “dc_context.h”#include “dc_loginparam.h”

Defines

CAT_FLAG(f, s)
LP_PREFIX(a)

Functions

void dc_loginparam_empty(dc_loginparam_t *loginparam)
char *dc_loginparam_get_readable(const dc_loginparam_t *loginparam)
dc_loginparam_t *dc_loginparam_new()
void dc_loginparam_read(dc_loginparam_t *loginparam, dc_sqlite3_t *sql, const char *prefix)
void dc_loginparam_unref(dc_loginparam_t *loginparam)
void dc_loginparam_write(const dc_loginparam_t *loginparam, dc_sqlite3_t *sql, const char *prefix)
static char *get_readable_flags(int flags)
file dc_loginparam.h

Functions

void dc_loginparam_empty(dc_loginparam_t *)
char *dc_loginparam_get_readable(const dc_loginparam_t *)
dc_loginparam_t *dc_loginparam_new()
void dc_loginparam_read(dc_loginparam_t *, dc_sqlite3_t *, const char *prefix)
void dc_loginparam_unref(dc_loginparam_t *)
void dc_loginparam_write(const dc_loginparam_t *, dc_sqlite3_t *, const char *prefix)
file dc_lot.c
#include “dc_context.h”

Defines

DC_LOT_MAGIC

Functions

void dc_lot_empty(dc_lot_t *lot)
void dc_lot_fill(dc_lot_t *lot, const dc_msg_t *msg, const dc_chat_t *chat, const dc_contact_t *contact, dc_context_t *context)
dc_lot_t *dc_lot_new()
file dc_lot.h

Defines

DC_SUMMARY_CHARACTERS

Functions

void dc_lot_fill(dc_lot_t *, const dc_msg_t *, const dc_chat_t *, const dc_contact_t *, dc_context_t *)
file dc_mimefactory.c
#include “dc_context.h”#include “dc_mimefactory.h”#include “dc_apeerstate.h”

Defines

AUTO_REGOSSIP
LINEEND

Functions

static struct mailmime *build_body_file(const dc_msg_t *msg, const char *base_name, char **ret_file_name_as_sent)
static struct mailmime *build_body_text(char *text)
void dc_mimefactory_empty(dc_mimefactory_t *factory)
void dc_mimefactory_init(dc_mimefactory_t *factory, dc_context_t *context)
int dc_mimefactory_load_mdn(dc_mimefactory_t *factory, uint32_t msg_id)
int dc_mimefactory_load_msg(dc_mimefactory_t *factory, uint32_t msg_id)
int dc_mimefactory_render(dc_mimefactory_t *factory)
static char *get_subject(const dc_chat_t *chat, const dc_msg_t *msg, int afwd_email)
static int is_file_size_okay(const dc_msg_t *msg)
static void load_from(dc_mimefactory_t *factory)
static void set_error(dc_mimefactory_t *factory, const char *text)
file dc_mimefactory.h

Defines

DC_CMD_AUTOCRYPT_SETUP_MESSAGE
DC_CMD_GROUPIMAGE_CHANGED
DC_CMD_GROUPNAME_CHANGED
DC_CMD_LOCATION_ONLY
DC_CMD_LOCATION_STREAMING_ENABLED
DC_CMD_MEMBER_ADDED_TO_GROUP
DC_CMD_MEMBER_REMOVED_FROM_GROUP
DC_CMD_SECUREJOIN_MESSAGE

Functions

void dc_mimefactory_empty(dc_mimefactory_t *)
void dc_mimefactory_init(dc_mimefactory_t *, dc_context_t *)
int dc_mimefactory_load_mdn(dc_mimefactory_t *, uint32_t msg_id)
int dc_mimefactory_load_msg(dc_mimefactory_t *, uint32_t msg_id)
int dc_mimefactory_render(dc_mimefactory_t *)
file dc_mimeparser.c
#include “dc_context.h”#include “dc_mimeparser.h”#include “dc_mimefactory.h”#include “dc_pgp.h”#include “dc_simplify.h”

Defines

DC_MIMETYPE_AC_SETUP_FILE
DC_MIMETYPE_AUDIO
DC_MIMETYPE_FILE
DC_MIMETYPE_IMAGE
DC_MIMETYPE_MP_ALTERNATIVE
DC_MIMETYPE_MP_MIXED
DC_MIMETYPE_MP_NOT_DECRYPTABLE
DC_MIMETYPE_MP_OTHER
DC_MIMETYPE_MP_REPORT
DC_MIMETYPE_MP_SIGNED
DC_MIMETYPE_TEXT_HTML
DC_MIMETYPE_TEXT_PLAIN
DC_MIMETYPE_VIDEO

Functions

static int dc_mimeparser_add_single_part_if_known(dc_mimeparser_t *mimeparser, struct mailmime *mime)
static int dc_mimeparser_parse_mime_recursive(dc_mimeparser_t *mimeparser, struct mailmime *mime)
void dc_mimeparser_repl_msg_by_error(dc_mimeparser_t *mimeparser, const char *error_msg)
static dc_mimepart_t *dc_mimepart_new(void)
static void dc_mimepart_unref(dc_mimepart_t *mimepart)
void dc_no_compound_msgs(void)
static void do_add_single_file_part(dc_mimeparser_t *parser, int msg_type, int mime_type, const char *raw_mime, const char *decoded_data, size_t decoded_data_bytes, const char *desired_filename)
static void do_add_single_part(dc_mimeparser_t *parser, dc_mimepart_t *part)
static void hash_header(dc_hash_t *out, const struct mailimf_fields *in, dc_context_t *context)
struct mailimf_field *mailimf_find_field(struct mailimf_fields *header, int wanted_fld_type)
char *mailimf_find_first_addr(const struct mailimf_mailbox_list *mb_list)
struct mailimf_optional_field *mailimf_find_optional_field(struct mailimf_fields *header, const char *wanted_fld_name)
dc_hash_t *mailimf_get_recipients(struct mailimf_fields *imffields)
static void mailimf_get_recipients__add_addr(dc_hash_t *recipients, struct mailimf_mailbox *mb)
struct mailmime_parameter *mailmime_find_ct_parameter(struct mailmime *mime, const char *name)
struct mailimf_fields *mailmime_find_mailimf_fields(struct mailmime *mime)
static int mailmime_get_mime_type(struct mailmime *mime, int *msg_type, char **raw_mime)
static int mailmime_is_attachment_disposition(struct mailmime *mime)
int mailmime_transfer_decode(struct mailmime *mime, const char **ret_decoded_data, size_t *ret_decoded_data_bytes, char **ret_to_mmap_string_unref)
static void reconcat_mime(char **raw_mime, const char *type, const char *subtype)

Variables

int s_generate_compound_msgs = 1
file dc_mimeparser.h
#include “dc_hash.h”#include “dc_param.h”

Defines

dc_mimeparser_has_nonmeta(a)

Functions

void dc_mimeparser_empty(dc_mimeparser_t *)
dc_mimepart_t *dc_mimeparser_get_last_nonmeta(dc_mimeparser_t *)
int dc_mimeparser_is_mailinglist_message(dc_mimeparser_t *)
struct mailimf_field *dc_mimeparser_lookup_field(dc_mimeparser_t *, const char *field_name)
struct mailimf_optional_field *dc_mimeparser_lookup_optional_field(dc_mimeparser_t *, const char *field_name)
dc_mimeparser_t *dc_mimeparser_new(const char *blobdir, dc_context_t *)
void dc_mimeparser_parse(dc_mimeparser_t *, const char *body_not_terminated, size_t body_bytes)
void dc_mimeparser_repl_msg_by_error(dc_mimeparser_t *, const char *error_msg)
int dc_mimeparser_sender_equals_recipient(dc_mimeparser_t *)
void dc_mimeparser_unref(dc_mimeparser_t *)
struct mailimf_field *mailimf_find_field(struct mailimf_fields *, int wanted_fld_type)
char *mailimf_find_first_addr(const struct mailimf_mailbox_list *)
struct mailimf_optional_field *mailimf_find_optional_field(struct mailimf_fields *, const char *wanted_fld_name)
dc_hash_t *mailimf_get_recipients(struct mailimf_fields *)
struct mailmime_parameter *mailmime_find_ct_parameter(struct mailmime *, const char *name)
struct mailimf_fields *mailmime_find_mailimf_fields(struct mailmime *)
int mailmime_transfer_decode(struct mailmime *, const char **ret_decoded_data, size_t *ret_decoded_data_bytes, char **ret_to_mmap_string_unref)
file dc_move.c
#include “dc_context.h”#include “dc_mimeparser.h”#include “dc_job.h”

Functions

void dc_do_heuristics_moves(dc_context_t *context, const char *folder, uint32_t msg_id)
file dc_msg.c
#include “dc_context.h”#include “dc_imap.h”#include “dc_smtp.h”#include “dc_job.h”#include “dc_pgp.h”#include “dc_mimefactory.h”

Defines

DC_MSG_FIELDS
DC_MSG_MAGIC

Functions

size_t dc_get_deaddrop_msg_cnt(dc_context_t *context)
size_t dc_get_real_msg_cnt(dc_context_t *context)
int dc_mdn_from_ext(dc_context_t *context, uint32_t from_id, const char *rfc724_mid, time_t timestamp_sent, uint32_t *ret_chat_id, uint32_t *ret_msg_id)
int dc_msg_exists(dc_context_t *context, uint32_t msg_id)
char *dc_msg_get_summarytext_by_raw(int type, const char *text, dc_param_t *param, int approx_characters, dc_context_t *context)
dc_msg_t *dc_msg_new_load(dc_context_t *context, uint32_t msg_id)
dc_msg_t *dc_msg_new_untyped(dc_context_t *context)
void dc_msg_save_param_to_disk(dc_msg_t *msg)
static int dc_msg_set_from_stmt(dc_msg_t *msg, sqlite3_stmt *row, int row_offset)
int dc_rfc724_mid_cnt(dc_context_t *context, const char *rfc724_mid)
void dc_update_msg_chat_id(dc_context_t *context, uint32_t msg_id, uint32_t chat_id)
void dc_update_msg_move_state(dc_context_t *context, const char *rfc724_mid, dc_move_state_t state)
void dc_update_msg_state(dc_context_t *context, uint32_t msg_id, int state)
void dc_update_server_uid(dc_context_t *context, const char *rfc724_mid, const char *server_folder, uint32_t server_uid)
file dc_msg.h
#include “dc_param.h”

Defines

DC_APPROX_SUBJECT_CHARS
DC_MSG_NEEDS_ATTACHMENT(a)

Enums

enum dc_move_state_t

Values:

DC_MOVE_STATE_UNDEFINED = 0
DC_MOVE_STATE_PENDING = 1
DC_MOVE_STATE_STAY = 2
DC_MOVE_STATE_MOVING = 3

Functions

void dc_delete_msg_from_db(dc_context_t *, uint32_t)
size_t dc_get_deaddrop_msg_cnt(dc_context_t *)
size_t dc_get_real_msg_cnt(dc_context_t *)
int dc_mdn_from_ext(dc_context_t *, uint32_t from_id, const char *rfc724_mid, time_t, uint32_t *ret_chat_id, uint32_t *ret_msg_id)
int dc_msg_exists(dc_context_t *, uint32_t msg_id)
char *dc_msg_get_summarytext_by_raw(int type, const char *text, dc_param_t *, int approx_bytes, dc_context_t *)
void dc_msg_guess_msgtype_from_suffix(const char *pathNfilename, int *ret_msgtype, char **ret_mime)
int dc_msg_is_increation(const dc_msg_t *)
int dc_msg_load_from_db(dc_msg_t *, dc_context_t *, uint32_t id)
dc_msg_t *dc_msg_new_load(dc_context_t *, uint32_t id)
dc_msg_t *dc_msg_new_untyped(dc_context_t *)
void dc_msg_save_param_to_disk(dc_msg_t *)
int dc_rfc724_mid_cnt(dc_context_t *, const char *rfc724_mid)
uint32_t dc_rfc724_mid_exists(dc_context_t *, const char *rfc724_mid, char **ret_server_folder, uint32_t *ret_server_uid)
void dc_set_msg_failed(dc_context_t *, uint32_t msg_id, const char *error)
void dc_update_msg_chat_id(dc_context_t *, uint32_t msg_id, uint32_t chat_id)
void dc_update_msg_move_state(dc_context_t *, const char *rfc724_mid, dc_move_state_t)
void dc_update_msg_state(dc_context_t *, uint32_t msg_id, int state)
void dc_update_server_uid(dc_context_t *, const char *rfc724_mid, const char *server_folder, uint32_t server_uid)
file dc_oauth2.c
#include “dc_context.h”#include “dc_oauth2.h”#include “dc_jsmn.h”

Defines

CLIENT_ID

Typedefs

typedef struct oauth2_t oauth2_t

Functions

char *dc_get_oauth2_access_token(dc_context_t *context, const char *addr, const char *code, int flags)
char *dc_get_oauth2_addr(dc_context_t *context, const char *addr, const char *code)
static oauth2_t *get_info(const char *addr)
static char *get_oauth2_addr(dc_context_t *context, const oauth2_t *oauth2, const char *access_token)
static int is_expired(dc_context_t *context)
static char *jsondup(const char *json, jsmntok_t *tok)
static int jsoneq(const char *json, jsmntok_t *tok, const char *s)
static void replace_in_uri(char **uri, const char *key, const char *value)
file dc_oauth2.h

Defines

DC_REGENERATE

Functions

char *dc_get_oauth2_access_token(dc_context_t *, const char *addr, const char *code, int flags)
char *dc_get_oauth2_addr(dc_context_t *, const char *addr, const char *code)
file dc_openssl.c
#include <openssl/ssl.h>#include <openssl/rand.h>#include <openssl/rsa.h>#include <openssl/evp.h>#include “dc_context.h”

Functions

void dc_openssl_exit(void)
void dc_openssl_init(void)
static struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line)
static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line)
static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)
static unsigned long id_function(void)
static void locking_function(int mode, int n, const char *file, int line)

Variables

int s_init_counter = 0
pthread_mutex_t s_init_lock = PTHREAD_MUTEX_INITIALIZER
int s_init_not_required = 0
pthread_mutex_t *s_mutex_buf = NULL
file dc_openssl.h

Functions

void dc_openssl_exit(void)
void dc_openssl_init(void)
file dc_param.c
#include <stdlib.h>#include <string.h>#include “dc_context.h”#include “dc_tools.h”

Functions

void dc_param_set_urlencoded(dc_param_t *param, const char *urlencoded)

Same as dc_param_set_packed() but uses ‘&’ as a separator (instead ‘

’).

Urldecoding itself is not done by this function, this is up to the caller.

static char *find_param(char *haystack, int key, char **ret_p2)
file dc_param.h

Defines

DC_FP_ADD_AUTOCRYPT_HEADER
DC_FP_NO_AUTOCRYPT_HEADER
DC_PARAM_ALSO_MOVE
DC_PARAM_CMD
DC_PARAM_CMD_ARG
DC_PARAM_CMD_ARG2
DC_PARAM_CMD_ARG3
DC_PARAM_CMD_ARG4
DC_PARAM_DURATION
DC_PARAM_ERRONEOUS_E2EE
DC_PARAM_ERROR
DC_PARAM_FILE
DC_PARAM_FORCE_PLAINTEXT
DC_PARAM_FORWARDED
DC_PARAM_GUARANTEE_E2EE
DC_PARAM_HEIGHT
DC_PARAM_MIMETYPE
DC_PARAM_PREP_FORWARDS
DC_PARAM_PROFILE_IMAGE
DC_PARAM_RECIPIENTS
DC_PARAM_SELFTALK
DC_PARAM_SERVER_FOLDER
DC_PARAM_SERVER_UID
DC_PARAM_SET_LATITUDE
DC_PARAM_SET_LONGITUDE
DC_PARAM_UNPROMOTED
DC_PARAM_WANTS_MDN
DC_PARAM_WIDTH

Functions

void dc_param_empty(dc_param_t *)
int dc_param_exists(dc_param_t *, int key)
char *dc_param_get(const dc_param_t *, int key, const char *def)
double dc_param_get_float(const dc_param_t *, int key, double def)
int32_t dc_param_get_int(const dc_param_t *, int key, int32_t def)
dc_param_t *dc_param_new()
void dc_param_set(dc_param_t *, int key, const char *value)
void dc_param_set_float(dc_param_t *, int key, double value)
void dc_param_set_int(dc_param_t *, int key, int32_t value)
void dc_param_set_packed(dc_param_t *, const char *)
void dc_param_set_urlencoded(dc_param_t *param, const char *urlencoded)

Same as dc_param_set_packed() but uses ‘&’ as a separator (instead ‘

’).

Urldecoding itself is not done by this function, this is up to the caller.

void dc_param_unref(dc_param_t *)
file dc_pgp.c
#include “dc_context.h”#include <netpgp-extra.h>#include <openssl/rand.h>#include “dc_key.h”#include “dc_keyring.h”#include “dc_pgp.h”#include “dc_hash.h”

Defines

HASH_ALG
PGP_WS
SYMM_ALGO

Functions

static unsigned add_key_prefs(pgp_create_sig_t *sig)
static void add_selfsigned_userid(pgp_key_t *skey, pgp_key_t *pkey, const uint8_t *userid, time_t key_expiry)
static void add_subkey_binding_signature(pgp_subkeysig_t *p, pgp_key_t *primarykey, pgp_key_t *subkey, pgp_key_t *seckey)
int dc_pgp_calc_fingerprint(const dc_key_t *raw_key, uint8_t **ret_fingerprint, size_t *ret_fingerprint_bytes)
int dc_pgp_create_keypair(dc_context_t *context, const char *addr, dc_key_t *ret_public_key, dc_key_t *ret_private_key)
void dc_pgp_exit(void)
void dc_pgp_init(void)
int dc_pgp_is_valid_key(dc_context_t *context, const dc_key_t *raw_key)
int dc_pgp_pk_decrypt(dc_context_t *context, const void *ctext, size_t ctext_bytes, const dc_keyring_t *raw_private_keys_for_decryption, const dc_keyring_t *raw_public_keys_for_validation, int use_armor, void **ret_plain, size_t *ret_plain_bytes, dc_hash_t *ret_signature_fingerprints)
int dc_pgp_pk_encrypt(dc_context_t *context, const void *plain_text, size_t plain_bytes, const dc_keyring_t *raw_public_keys_for_encryption, const dc_key_t *raw_private_key_for_signing, int use_armor, void **ret_ctext, size_t *ret_ctext_bytes)
void dc_pgp_rand_seed(dc_context_t *context, const void *buf, size_t bytes)
int dc_pgp_split_key(dc_context_t *context, const dc_key_t *private_in, dc_key_t *ret_public_key)
int dc_pgp_symm_decrypt(dc_context_t *context, const char *passphrase, const void *ctext, size_t ctext_bytes, void **ret_plain_text, size_t *ret_plain_bytes)
int dc_pgp_symm_encrypt(dc_context_t *context, const char *passphrase, const void *plain, size_t plain_bytes, char **ret_ctext_armored)
int dc_split_armored_data(char *buf, const char **ret_headerline, const char **ret_setupcodebegin, const char **ret_preferencrypt, const char **ret_base64)

Variables

pgp_io_t s_io
int s_io_initialized = 0
file dc_pgp.h
#include “dc_key.h”#include “dc_keyring.h”

Defines

DC_E2EE_NO_VALID_SIGNATURE
DC_KEYGEN_BITS
DC_KEYGEN_E

Functions

int dc_pgp_calc_fingerprint(const dc_key_t *, uint8_t **fingerprint, size_t *fingerprint_bytes)
int dc_pgp_create_keypair(dc_context_t *, const char *addr, dc_key_t *public_key, dc_key_t *private_key)
void dc_pgp_exit(void)
void dc_pgp_init(void)
int dc_pgp_is_valid_key(dc_context_t *, const dc_key_t *)
int dc_pgp_pk_decrypt(dc_context_t *, const void *ctext, size_t ctext_bytes, const dc_keyring_t *, const dc_keyring_t *validate_keys, int use_armor, void **plain, size_t *plain_bytes, dc_hash_t *ret_signature_fingerprints)
int dc_pgp_pk_encrypt(dc_context_t *, const void *plain, size_t plain_bytes, const dc_keyring_t *, const dc_key_t *sign_key, int use_armor, void **ret_ctext, size_t *ret_ctext_bytes)
void dc_pgp_rand_seed(dc_context_t *, const void *buf, size_t bytes)
int dc_pgp_split_key(dc_context_t *, const dc_key_t *private_in, dc_key_t *public_out)
int dc_pgp_symm_decrypt(dc_context_t *context, const char *passphrase, const void *ctext, size_t ctext_bytes, void **ret_plain_text, size_t *ret_plain_bytes)
int dc_pgp_symm_encrypt(dc_context_t *context, const char *passphrase, const void *plain, size_t plain_bytes, char **ret_ctext_armored)
int dc_split_armored_data(char *buf, const char **ret_headerline, const char **ret_setupcodebegin, const char **ret_preferencrypt, const char **ret_base64)
file dc_qr.c
#include <stdarg.h>#include <unistd.h>#include “dc_context.h”#include “dc_apeerstate.h”

Defines

MAILTO_SCHEME
MATMSG_SCHEME
SMTP_SCHEME
VCARD_BEGIN
file dc_receive_imf.c
#include <assert.h>#include “dc_context.h”#include <netpgp-extra.h>#include “dc_mimeparser.h”#include “dc_mimefactory.h”#include “dc_imap.h”#include “dc_job.h”#include “dc_array.h”#include “dc_apeerstate.h”

Defines

outgoing
VERIFY_FAIL(a)

Functions

static void add_or_lookup_contact_by_addr(dc_context_t *context, const char *display_name_enc, const char *addr_spec, int origin, dc_array_t *ids, int *check_self)
static void calc_timestamps(dc_context_t *context, uint32_t chat_id, uint32_t from_id, time_t message_timestamp, int is_fresh_msg, time_t *sort_timestamp, time_t *sent_timestamp, time_t *rcvd_timestamp)
static int check_verified_properties(dc_context_t *context, dc_mimeparser_t *mimeparser, uint32_t from_id, const dc_array_t *to_ids, char **failure_reason)
static char *create_adhoc_grp_id(dc_context_t *context, dc_array_t *member_ids)
static uint32_t create_group_record(dc_context_t *context, const char *grpid, const char *grpname, int create_blocked, int create_verified)
static void create_or_lookup_adhoc_group(dc_context_t *context, dc_mimeparser_t *mime_parser, int allow_creation, int create_blocked, int32_t from_id, const dc_array_t *to_ids, uint32_t *ret_chat_id, int *ret_chat_id_blocked)
static void create_or_lookup_group(dc_context_t *context, dc_mimeparser_t *mime_parser, int allow_creation, int create_blocked, int32_t from_id, const dc_array_t *to_ids, uint32_t *ret_chat_id, int *ret_chat_id_blocked)
static void dc_add_or_lookup_contacts_by_address_list(dc_context_t *context, const struct mailimf_address_list *adr_list, int origin, dc_array_t *ids, int *check_self)
static void dc_add_or_lookup_contacts_by_mailbox_list(dc_context_t *context, const struct mailimf_mailbox_list *mb_list, int origin, dc_array_t *ids, int *check_self)
static int dc_is_reply_to_known_message(dc_context_t *context, dc_mimeparser_t *mime_parser)
static int dc_is_reply_to_messenger_message(dc_context_t *context, dc_mimeparser_t *mime_parser)
void dc_receive_imf(dc_context_t *context, const char *imf_raw_not_terminated, size_t imf_raw_bytes, const char *server_folder, uint32_t server_uid, uint32_t flags)
static int is_known_rfc724_mid(dc_context_t *context, const char *rfc724_mid)
static int is_known_rfc724_mid_in_list(dc_context_t *context, const clist *mid_list)
static int is_msgrmsg_rfc724_mid(dc_context_t *context, const char *rfc724_mid)
static int is_msgrmsg_rfc724_mid_in_list(dc_context_t *context, const clist *mid_list)
static dc_array_t *search_chat_ids_by_contact_ids(dc_context_t *context, const dc_array_t *unsorted_contact_ids)
static void set_better_msg(dc_mimeparser_t *mime_parser, char **better_msg)
file dc_saxparser.c
#include <stdlib.h>#include <string.h>#include <ctype.h>#include “dc_context.h”#include “dc_tools.h”#include “dc_saxparser.h”

Defines

FREE_KEY
FREE_VALUE
MAX_ATTR
XML_WS

Functions

static void call_text_cb(dc_saxparser_t *saxparser, char *text, size_t len, char type)
const char *dc_attr_find(char **attr, const char *key)
void dc_saxparser_init(dc_saxparser_t *saxparser, void *userdata)
void dc_saxparser_parse(dc_saxparser_t *saxparser, const char *buf_start__)
void dc_saxparser_set_tag_handler(dc_saxparser_t *saxparser, dc_saxparser_starttag_cb_t starttag_cb, dc_saxparser_endtag_cb_t endtag_cb)
void dc_saxparser_set_text_handler(dc_saxparser_t *saxparser, dc_saxparser_text_cb_t text_cb)
static void def_endtag_cb(void *userdata, const char *tag)
static void def_starttag_cb(void *userdata, const char *tag, char **attr)
static void def_text_cb(void *userdata, const char *text, int len)
static void do_free_attr(char **attr, int *free_attr)
static char *xml_decode(char *s, char type)

Variables

const char *s_ent[]
file dc_saxparser.h

Typedefs

typedef void (*dc_saxparser_endtag_cb_t)(void *userdata, const char *tag)
typedef void (*dc_saxparser_starttag_cb_t)(void *userdata, const char *tag, char **attr)
typedef void (*dc_saxparser_text_cb_t)(void *userdata, const char *text, int len)

Functions

const char *dc_attr_find(char **attr, const char *key)
void dc_saxparser_init(dc_saxparser_t *, void *userData)
void dc_saxparser_parse(dc_saxparser_t *, const char *text)
void dc_saxparser_set_tag_handler(dc_saxparser_t *, dc_saxparser_starttag_cb_t, dc_saxparser_endtag_cb_t)
void dc_saxparser_set_text_handler(dc_saxparser_t *, dc_saxparser_text_cb_t)
file dc_securejoin.c
#include <stdarg.h>#include <unistd.h>#include “dc_context.h”#include “dc_key.h”#include “dc_apeerstate.h”#include “dc_mimeparser.h”#include “dc_mimefactory.h”#include “dc_job.h”#include “dc_token.h”

Secure Join

void dc_handle_degrade_event(dc_context_t *context, dc_apeerstate_t *peerstate)
static int encrypted_and_signed(dc_mimeparser_t *mimeparser, const char *expected_fingerprint)
static char *get_self_fingerprint(dc_context_t *context)
static uint32_t chat_id_2_contact_id(dc_context_t *context, uint32_t contact_chat_id)
static int fingerprint_equals_sender(dc_context_t *context, const char *fingerprint, uint32_t contact_chat_id)
static int mark_peer_as_verified(dc_context_t *context, const char *fingerprint)
static const char *lookup_field(dc_mimeparser_t *mimeparser, const char *key)
static void send_handshake_msg(dc_context_t *context, uint32_t contact_chat_id, const char *step, const char *param2, const char *fingerprint, const char *grpid)
static void could_not_establish_secure_connection(dc_context_t *context, uint32_t contact_chat_id, const char *details)
static void secure_connection_established(dc_context_t *context, uint32_t contact_chat_id)
static void end_bobs_joining(dc_context_t *context, int status)

Defines

CHECK_EXIT
LOCK_QR
UNLOCK_QR
file dc_simplify.c
#include <stdlib.h>#include <string.h>#include “dc_context.h”#include “dc_simplify.h”#include “dc_tools.h”#include “dc_dehtml.h”#include “dc_mimeparser.h”#include “dc_strbuilder.h”

Functions

dc_simplify_t *dc_simplify_new()
char *dc_simplify_simplify(dc_simplify_t *simplify, const char *in_unterminated, int in_bytes, int is_html, int is_msgrmsg)
static char *dc_simplify_simplify_plain_text(dc_simplify_t *simplify, const char *buf_terminated, int is_msgrmsg)
void dc_simplify_unref(dc_simplify_t *simplify)
static int is_empty_line(const char *buf)
static int is_plain_quote(const char *buf)
static int is_quoted_headline(const char *buf)
file dc_simplify.h

Functions

dc_simplify_t *dc_simplify_new()
char *dc_simplify_simplify(dc_simplify_t *, const char *txt_unterminated, int txt_bytes, int is_html, int is_msgrmsg)
void dc_simplify_unref(dc_simplify_t *)
file dc_smtp.c
#include <unistd.h>#include <libetpan/libetpan.h>#include “dc_context.h”#include “dc_smtp.h”#include “dc_job.h”#include “dc_oauth2.h”

Defines

DEBUG_SMTP

Functions

static void body_progress(size_t current, size_t maximum, void *user_data)
int dc_smtp_connect(dc_smtp_t *smtp, const dc_loginparam_t *lp)
void dc_smtp_disconnect(dc_smtp_t *smtp)
int dc_smtp_is_connected(const dc_smtp_t *smtp)
dc_smtp_t *dc_smtp_new(dc_context_t *context)
int dc_smtp_send_msg(dc_smtp_t *smtp, const clist *recipients, const char *data_not_terminated, size_t data_bytes)
void dc_smtp_unref(dc_smtp_t *smtp)
static void log_error(dc_smtp_t *smtp, const char *what_failed, int r)
file dc_smtp.h
#include “dc_loginparam.h”

Functions

int dc_smtp_connect(dc_smtp_t *, const dc_loginparam_t *)
void dc_smtp_disconnect(dc_smtp_t *)
int dc_smtp_is_connected(const dc_smtp_t *)
dc_smtp_t *dc_smtp_new(dc_context_t *)
int dc_smtp_send_msg(dc_smtp_t *, const clist *recipients, const char *data, size_t data_bytes)
void dc_smtp_unref(dc_smtp_t *)
file dc_sqlite3.c
#include <assert.h>#include <dirent.h>#include <sys/stat.h>#include “dc_context.h”#include “dc_apeerstate.h”

Defines

NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
NEW_DB_VERSION
PREFIX
PREFIX_LEN
SELECT_v_FROM_config_k_STATEMENT

Functions

void dc_housekeeping(dc_context_t *context)
void dc_sqlite3_begin_transaction(dc_sqlite3_t *sql)
void dc_sqlite3_close(dc_sqlite3_t *sql)
void dc_sqlite3_commit(dc_sqlite3_t *sql)
int dc_sqlite3_execute(dc_sqlite3_t *sql, const char *querystr)
char *dc_sqlite3_get_config(dc_sqlite3_t *sql, const char *key, const char *def)
int32_t dc_sqlite3_get_config_int(dc_sqlite3_t *sql, const char *key, int32_t def)
int64_t dc_sqlite3_get_config_int64(dc_sqlite3_t *sql, const char *key, int64_t def)
uint32_t dc_sqlite3_get_rowid(dc_sqlite3_t *sql, const char *table, const char *field, const char *value)
uint32_t dc_sqlite3_get_rowid2(dc_sqlite3_t *sql, const char *table, const char *field, uint64_t value, const char *field2, uint32_t value2)
int dc_sqlite3_is_open(const dc_sqlite3_t *sql)
void dc_sqlite3_log_error(dc_sqlite3_t *sql, const char *msg_format, ...)
dc_sqlite3_t *dc_sqlite3_new(dc_context_t *context)
int dc_sqlite3_open(dc_sqlite3_t *sql, const char *dbfile, int flags)
sqlite3_stmt *dc_sqlite3_prepare(dc_sqlite3_t *sql, const char *querystr)
void dc_sqlite3_rollback(dc_sqlite3_t *sql)
int dc_sqlite3_set_config(dc_sqlite3_t *sql, const char *key, const char *value)
int dc_sqlite3_set_config_int(dc_sqlite3_t *sql, const char *key, int32_t value)
int dc_sqlite3_set_config_int64(dc_sqlite3_t *sql, const char *key, int64_t value)
int dc_sqlite3_table_exists(dc_sqlite3_t *sql, const char *name)
int dc_sqlite3_try_execute(dc_sqlite3_t *sql, const char *querystr)
void dc_sqlite3_unref(dc_sqlite3_t *sql)
static int is_file_in_use(dc_hash_t *files_in_use, const char *namespc, const char *name)
static void maybe_add_file(dc_hash_t *files_in_use, const char *file)
static void maybe_add_from_param(dc_context_t *context, dc_hash_t *files_in_use, const char *query, int param_id)
file dc_sqlite3.h
#include <sqlite3.h>#include <libetpan/libetpan.h>#include <pthread.h>

Defines

DC_HOUSEKEEPING_DELAY_SEC
DC_OPEN_READONLY

Functions

void dc_housekeeping(dc_context_t *)
void dc_sqlite3_begin_transaction(dc_sqlite3_t *)
void dc_sqlite3_close(dc_sqlite3_t *)
void dc_sqlite3_commit(dc_sqlite3_t *)
int dc_sqlite3_execute(dc_sqlite3_t *, const char *sql)
char *dc_sqlite3_get_config(dc_sqlite3_t *, const char *key, const char *def)
int32_t dc_sqlite3_get_config_int(dc_sqlite3_t *, const char *key, int32_t def)
int64_t dc_sqlite3_get_config_int64(dc_sqlite3_t *, const char *key, int64_t def)
uint32_t dc_sqlite3_get_rowid(dc_sqlite3_t *, const char *table, const char *field, const char *value)
uint32_t dc_sqlite3_get_rowid2(dc_sqlite3_t *, const char *table, const char *field, uint64_t value, const char *field2, uint32_t value2)
int dc_sqlite3_is_open(const dc_sqlite3_t *)
void dc_sqlite3_log_error(dc_sqlite3_t *, const char *msg, ...)
dc_sqlite3_t *dc_sqlite3_new(dc_context_t *)
int dc_sqlite3_open(dc_sqlite3_t *, const char *dbfile, int flags)
sqlite3_stmt *dc_sqlite3_prepare(dc_sqlite3_t *, const char *sql)
void dc_sqlite3_rollback(dc_sqlite3_t *)
int dc_sqlite3_set_config(dc_sqlite3_t *, const char *key, const char *value)
int dc_sqlite3_set_config_int(dc_sqlite3_t *, const char *key, int32_t value)
int dc_sqlite3_set_config_int64(dc_sqlite3_t *, const char *key, int64_t value)
int dc_sqlite3_table_exists(dc_sqlite3_t *, const char *name)
int dc_sqlite3_try_execute(dc_sqlite3_t *, const ch