Delta Chat Core C Interface
|
An object representing a single chat in memory. More...
#include <deltachat.h>
Public Member Functions | |
int | dc_chat_can_send (const dc_chat_t *chat) |
Check if messages can be sent to a given chat. | |
uint32_t | dc_chat_get_color (const dc_chat_t *chat) |
Get a color for the chat. | |
uint32_t | dc_chat_get_id (const dc_chat_t *chat) |
Get the chat ID. | |
char * | dc_chat_get_mailinglist_addr (const dc_chat_t *chat) |
Returns the address where messages are sent to if the chat is a mailing list. | |
char * | dc_chat_get_name (const dc_chat_t *chat) |
Get name of a chat. | |
char * | dc_chat_get_profile_image (const dc_chat_t *chat) |
Get the chat's profile image. | |
int64_t | dc_chat_get_remaining_mute_duration (const dc_chat_t *chat) |
Get the exact state of the mute of a chat. | |
int | dc_chat_get_type (const dc_chat_t *chat) |
Get chat type as one of the DC_CHAT_TYPE constants: | |
int | dc_chat_get_visibility (const dc_chat_t *chat) |
Get visibility of chat. | |
int | dc_chat_is_contact_request (const dc_chat_t *chat) |
Check if a chat is a contact request chat. | |
int | dc_chat_is_device_talk (const dc_chat_t *chat) |
Check if a chat is a device-talk. | |
int | dc_chat_is_muted (const dc_chat_t *chat) |
Check whether the chat is currently muted (can be changed by dc_set_chat_mute_duration()). | |
int | dc_chat_is_protected (const dc_chat_t *chat) |
Check if a chat is protected. | |
int | dc_chat_is_protection_broken (const dc_chat_t *chat) |
Checks if the chat was protected, and then an incoming message broke this protection. | |
int | dc_chat_is_self_talk (const dc_chat_t *chat) |
Check if a chat is a self talk. | |
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(). | |
int | dc_chat_is_unpromoted (const dc_chat_t *chat) |
Check if a group chat is still unpromoted. | |
void | dc_chat_unref (dc_chat_t *chat) |
Free a chat object. | |
An object representing a single chat in memory.
Chat objects are created using e.g. dc_get_chat() and are not updated on database changes; if you want an update, you have to recreate the object.
int dc_chat_can_send | ( | const dc_chat_t * | chat | ) |
Check if messages can be sent to a given chat.
This is not true e.g. for contact requests or for the device-talk, cmp. dc_chat_is_device_talk().
Calling dc_send_msg() for these chats will fail and the UI may decide to hide input controls therefore.
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 e-mail 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.
chat | The chat object. |
uint32_t dc_chat_get_id | ( | const dc_chat_t * | chat | ) |
Get the chat ID.
The chat ID is the ID under which the chat is filed in the database.
Special IDs:
"Normal" chat IDs are larger than these special IDs (larger than DC_CHAT_ID_LAST_SPECIAL).
chat | The chat object. |
char * dc_chat_get_mailinglist_addr | ( | const dc_chat_t * | chat | ) |
Returns the address where messages are sent to if the chat is a mailing list.
If you just want to know if a mailing list can be written to, use dc_chat_can_send() instead.
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 e.g. to dc_create_group_chat() or received by a group-creation message.
To change the name, use dc_set_chat_name()
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).
chat | The chat object. |
int64_t dc_chat_get_remaining_mute_duration | ( | const dc_chat_t * | chat | ) |
Get the exact state of the mute of a chat.
chat | The chat object. |
int dc_chat_get_type | ( | const dc_chat_t * | chat | ) |
Get chat type as one of the DC_CHAT_TYPE constants:
chat | The chat object. |
int dc_chat_get_visibility | ( | const dc_chat_t * | chat | ) |
Get visibility of chat.
See DC_CHAT_VISIBILITY for detailed information about the visibilities.
chat | The chat object. |
int dc_chat_is_contact_request | ( | const dc_chat_t * | chat | ) |
Check if a chat is a contact request chat.
UI should display such chats with a [New] badge in the chatlist.
When such chat is opened, user should be presented with a set of options instead of the message composition area, for example:
chat | The chat object. |
int dc_chat_is_device_talk | ( | const dc_chat_t * | chat | ) |
Check if a chat is a device-talk.
Device-talks contain update information and some hints that are added during the program runs, multi-device etc.
From the UI view, device-talks are not very special, the user can delete and forward messages, archive the chat, set notifications etc.
Messages can be added to the device-talk using dc_add_device_msg()
chat | The chat object. |
int dc_chat_is_muted | ( | const dc_chat_t * | chat | ) |
Check whether the chat is currently muted (can be changed by dc_set_chat_mute_duration()).
chat | The chat object. |
int dc_chat_is_protected | ( | const dc_chat_t * | chat | ) |
Check if a chat is protected.
End-to-end encryption is guaranteed in protected chats and only verified contacts as determined by dc_contact_is_verified() can be added to protected chats.
Protected chats are created using dc_create_group_chat() by setting the 'protect' parameter to 1. 1:1 chats become protected or unprotected automatically if verified_one_on_one_chats
setting is enabled.
UI should display a green checkmark in the chat title, in the chatlist item and in the chat profile if chat protection is enabled.
chat | The chat object. |
int dc_chat_is_protection_broken | ( | const dc_chat_t * | chat | ) |
Checks if the chat was protected, and then an incoming message broke this protection.
This function is only useful if the UI enabled the verified_one_on_one_chats
feature flag, otherwise it will return false for all chats.
1:1 chats are automatically set as protected when a contact is verified. When a message comes in that is not encrypted / signed correctly, the chat is automatically set as unprotected again. dc_chat_is_protection_broken() will return true until dc_accept_chat() is called.
The UI should let the user confirm that this is OK with a message like Bob sent a message from another device. Tap to learn more
and then call dc_accept_chat().
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.
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().
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.
chat | The chat object. |
void dc_chat_unref | ( | dc_chat_t * | chat | ) |
Free a chat object.
chat | Chat object are returned e.g. by dc_get_chat(). If NULL is given, nothing is done. |