Delta Chat Core C Interface
Public Member Functions | List of all members
dc_chat_t Class Reference

#include <deltachat.h>

Public Member Functions

int dc_chat_can_send (const dc_chat_t *chat)
 Check if messages can be sent to a give chat. More...
 
uint32_t dc_chat_get_color (const dc_chat_t *chat)
 Get a color for the chat. More...
 
uint32_t dc_chat_get_id (const dc_chat_t *chat)
 Get chat ID. More...
 
char * dc_chat_get_name (const dc_chat_t *chat)
 Get name of a chat. More...
 
char * dc_chat_get_profile_image (const dc_chat_t *chat)
 Get the chat's profile image. More...
 
int64_t dc_chat_get_remaining_mute_duration (const dc_chat_t *chat)
 Get the exact state of the mute of a chat. More...
 
int dc_chat_get_type (const dc_chat_t *chat)
 Get chat type. More...
 
int dc_chat_get_visibility (const dc_chat_t *chat)
 Get visibility of chat. More...
 
int dc_chat_is_device_talk (const dc_chat_t *chat)
 Check if a chat is a device-talk. More...
 
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()). More...
 
int dc_chat_is_self_talk (const dc_chat_t *chat)
 Check if a chat is a self talk. More...
 
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(). More...
 
int dc_chat_is_unpromoted (const dc_chat_t *chat)
 Check if a group chat is still unpromoted. More...
 
int dc_chat_is_verified (const dc_chat_t *chat)
 Check if a chat is verified. More...
 
void dc_chat_unref (dc_chat_t *chat)
 Free a chat object. More...
 

Detailed Description

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.

Member Function Documentation

◆ dc_chat_can_send()

int dc_chat_can_send ( const dc_chat_t chat)

Check if messages can be sent to a give chat.

This is not true eg. for the deaddrop 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.

Parameters
chatThe chat object.
Returns
1=chat is writable, 0=chat is not writable

◆ dc_chat_get_color()

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.

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

◆ dc_chat_get_id()

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).

Parameters
chatThe chat object.
Returns
Chat ID. 0 on errors.

◆ dc_chat_get_name()

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()

Parameters
chatThe chat object.
Returns
Chat name as a string. Must be released using dc_str_unref() after usage. Never NULL.

◆ dc_chat_get_profile_image()

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).

Parameters
chatThe chat object.
Returns
Path and file if the profile image, if any. NULL otherwise. Must be released using dc_str_unref() after usage.

◆ dc_chat_get_remaining_mute_duration()

int64_t dc_chat_get_remaining_mute_duration ( const dc_chat_t chat)

Get the exact state of the mute of a chat.

Parameters
chatThe chat object.
Returns
0=not muted, -1=forever muted, (x>0)=remaining seconds until the mute is lifted

◆ dc_chat_get_type()

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.
Parameters
chatThe chat object.
Returns
Chat type.

◆ dc_chat_get_visibility()

int dc_chat_get_visibility ( const dc_chat_t chat)

Get visibility of chat.

See DC_CHAT_VISIBILITY for detailed information about the visibilities.

Parameters
chatThe chat object.
Returns
One of DC_CHAT_VISIBILITY

◆ dc_chat_is_device_talk()

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()

Parameters
chatThe chat object.
Returns
1=chat is device-talk, 0=chat is no device-talk

◆ dc_chat_is_muted()

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()).

Parameters
chatThe chat object.
Returns
1=muted, 0=not muted

◆ dc_chat_is_self_talk()

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.

Parameters
chatThe chat object.
Returns
1=chat is self talk, 0=chat is no self talk

◆ dc_chat_is_sending_locations()

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().

Parameters
chatThe chat object.
Returns
1=locations are sent to chat, 0=no locations are sent to chat

◆ dc_chat_is_unpromoted()

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.

Parameters
chatThe chat object.
Returns
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.

◆ dc_chat_is_verified()

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.

Parameters
chatThe chat object.
Returns
1=chat verified, 0=chat is not verified

◆ dc_chat_unref()

void dc_chat_unref ( dc_chat_t chat)

Free a chat object.

Parameters
chatChat object are returned eg. by dc_get_chat(). If NULL is given, nothing is done.
Returns
None.

The documentation for this class was generated from the following file: