Delta Chat Core C-API
Macros
mrevent.h File Reference

The following constants are used as events reported to the callback given to mrmailbox_new(). More...

Go to the source code of this file.

Macros

#define MR_EVENT_INFO   100
 The user may write an informational string to the log. More...
 
#define MR_EVENT_WARNING   300
 The user should write a warning string to the log. More...
 
#define MR_EVENT_ERROR   400
 The user should show an error. More...
 
#define MR_EVENT_MSGS_CHANGED   2000
 Messages or chats changed. More...
 
#define MR_EVENT_INCOMING_MSG   2005
 There is a fresh message. More...
 
#define MR_EVENT_MSG_DELIVERED   2010
 A single message is sent successfully (state changed from MR_STATE_OUT_PENDING to MR_STATE_OUT_DELIVERED, see mrmsg_t::m_state). More...
 
#define MR_EVENT_MSG_READ   2015
 A single message is read by the receiver (state changed from MR_STATE_OUT_DELIVERED to MR_STATE_OUT_MDN_RCVD, see mrmsg_t::m_state). More...
 
#define MR_EVENT_CHAT_MODIFIED   2020
 Group changed. More...
 
#define MR_EVENT_CONTACTS_CHANGED   2030
 Contact(s) created, renamed, blocked or deleted. More...
 
#define MR_EVENT_CONFIGURE_PROGRESS   2041
 Inform about the configuration progress started by mrmailbox_configure_and_connect(). More...
 
#define MR_EVENT_IMEX_PROGRESS   2051
 Inform about the import/export progress started by mrmailbox_imex(). More...
 
#define MR_EVENT_IMEX_FILE_WRITTEN   2052
 A file has been exported. More...
 
#define MR_EVENT_IS_OFFLINE   2081
 Ask the frontend about the offline state. More...
 
#define MR_EVENT_GET_STRING   2091
 Requeste a localized string from the frontend. More...
 
#define MR_EVENT_GET_QUANTITY_STRING   2092
 Requeste a localized quantitiy string from the frontend. More...
 
#define MR_EVENT_HTTP_GET   2100
 Request a HTTP-file from the frontend. More...
 
#define MR_EVENT_WAKE_LOCK   2110
 Acquire or release a wakelock. More...
 

Detailed Description

The following constants are used as events reported to the callback given to mrmailbox_new().

If you do not want to handle an event, it is always safe to return 0, so there is no need to add a "case" for every event.

Macro Definition Documentation

#define MR_EVENT_INFO   100

The user may write an informational string to the log.

Passed to the callback given to mrmailbox_new(). This event should not be reported using a popup or something like that.

Parameters
data10
data2Info string
Returns
0
#define MR_EVENT_WARNING   300

The user should write a warning string to the log.

Passed to the callback given to mrmailbox_new(). This event should not be reported using a popup or something like that.

Parameters
data10
data2Warning string
Returns
0
#define MR_EVENT_ERROR   400

The user should show an error.

The error must be reported to the user by a non-disturbing bubble or so.

Parameters
data10
data2Error string
Returns
0
#define MR_EVENT_MSGS_CHANGED   2000

Messages or chats changed.

One or more messages or chats changed for various reasons in the database:

  • Messages sent, received or removed
  • A message could not be sent (see mrmsg_get_state()/MR_STATE_OUT_ERROR)
  • Chats created, deleted or archived
  • A draft has been set
Parameters
data1chat_id for single added messages
data2msg_id for single added messages
Returns
0
#define MR_EVENT_INCOMING_MSG   2005

There is a fresh message.

Typically, the user will show an notification when receiving this message.

There is no extra MR_EVENT_MSGS_CHANGED event send together with this event.

Parameters
data1chat_id
data2msg_id
Returns
0
#define MR_EVENT_MSG_DELIVERED   2010

A single message is sent successfully (state changed from MR_STATE_OUT_PENDING to MR_STATE_OUT_DELIVERED, see mrmsg_t::m_state).

Parameters
data1chat_id
data2msg_id
Returns
0
#define MR_EVENT_MSG_READ   2015

A single message is read by the receiver (state changed from MR_STATE_OUT_DELIVERED to MR_STATE_OUT_MDN_RCVD, see mrmsg_t::m_state).

Parameters
data1chat_id
data2msg_id
Returns
0
#define MR_EVENT_CHAT_MODIFIED   2020

Group changed.

The name or the image of a chat group was changed or members were added or removed. See mrmailbox_set_chat_name(), mrmailbox_set_chat_profile_image(), mrmailbox_add_contact_to_chat() and mrmailbox_remove_contact_from_chat().

Parameters
data1chat_id
data20
Returns
0
#define MR_EVENT_CONTACTS_CHANGED   2030

Contact(s) created, renamed, blocked or deleted.

Parameters
data10
data20
Returns
0
#define MR_EVENT_CONFIGURE_PROGRESS   2041

Inform about the configuration progress started by mrmailbox_configure_and_connect().

Parameters
data1Permille
data20
Returns
0
#define MR_EVENT_IMEX_PROGRESS   2051

Inform about the import/export progress started by mrmailbox_imex().

Parameters
data1Permille
data20
Returns
0
#define MR_EVENT_IMEX_FILE_WRITTEN   2052

A file has been exported.

A file has been written by mrmailbox_imex(). This event may be sent multiple times by a single call to mrmailbox_imex().

A typical purpose for a handler of this event may be to make the file public to some system services.

Parameters
data1File name
data20
Returns
0
#define MR_EVENT_IS_OFFLINE   2081

Ask the frontend about the offline state.

This function may be provided by the frontend. If we already know, that we're offline, eg. there is no need to try to connect and things will speed up.

Parameters
data10
data20
Returns
0=online, 1=offline
#define MR_EVENT_GET_STRING   2091

Requeste a localized string from the frontend.

Parameters
data1ID of the string to request, one of the MR_STR_* constants as defined in mrstock.h
data20
Returns
Null-terminated UTF-8 string. CAVE: The string will be free()'d by the core, so make sure it is allocated using malloc() or a compatible function. If you cannot provide the requested string, just return 0; the core will use a default string then.
#define MR_EVENT_GET_QUANTITY_STRING   2092

Requeste a localized quantitiy string from the frontend.

Quantitiy strings may have eg. different plural forms and usually also include the count itself to the string. Typical strings in this form are "1 Message" vs. "2 Messages".

Parameters
data1ID of the string to request, one of the MR_STR_* constants as defined in mrstock.h
data2The count. The frontend may return different strings on this value and normally also includes the value itself to the string.
Returns
Null-terminated UTF-8 string. CAVE: The string will be free()'d by the core, so make sure it is allocated using malloc() or a compatible function. If you cannot provide the requested string, just return 0; the core will use a default string then.
#define MR_EVENT_HTTP_GET   2100

Request a HTTP-file from the frontend.

Parameters
data1URL
data20
Returns
The content of the requested file as a null-terminated UTF-8 string. CAVE: The string will be free()'d by the core, so make sure it is allocated using malloc() or a compatible function. If you cannot provide the content, just return 0.
#define MR_EVENT_WAKE_LOCK   2110

Acquire or release a wakelock.

The core surrounds critical functions that should not be killed by the operating system with wakelocks. Before a critical function MR_EVENT_WAKE_LOCK with data1=1 is called, it it finishes, MR_EVENT_WAKE_LOCK with data1=0 is called. If you do not need this functionality, just ignore this event.

Parameters
data11=acquire wakelock, 0=release wakelock, the core does not make nested or unsynchronized calls
data20
Returns
0