Delta Chat Core C-API
Public Member Functions | Public Attributes | List of all members
mrchat_t Struct Reference

An object representing a single chat in memory. More...

#include <mrchat.h>

Public Member Functions

void mrchat_unref (mrchat_t *chat)
 Free a chat object. More...
 
int mrchat_is_unpromoted (mrchat_t *chat)
 Check if a chat is still unpromoted. More...
 
char * mrchat_get_profile_image (mrchat_t *chat)
 Get the chat's profile image. More...
 
char * mrchat_get_subtitle (mrchat_t *chat)
 Get a subtitle for a chat. More...
 

Public Attributes

uint32_t m_id
 Chat ID under which the chat is filed in the database. More...
 
int m_type
 Chat type. More...
 
char * m_name
 Name of the chat. More...
 
time_t m_draft_timestamp
 Timestamp of the draft. More...
 
char * m_draft_text
 The draft text. More...
 
mrmailbox_tm_mailbox
 The mailbox object the chat belongs to. More...
 
int m_archived
 Flag for the archived state. More...
 

Detailed Description

An object representing a single chat in memory.

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

Member Function Documentation

void mrchat_unref ( mrchat_t chat)

Free a chat object.

Parameters
chatChat object are returned eg. by mrmailbox_get_chat().
Returns
None.
int mrchat_is_unpromoted ( mrchat_t chat)

Check if a chat is still unpromoted.

Chats are unpromoted until the first message is sent. With unpromoted chats, members can be sent, settings can be modified without the need of special status messages being sent.

After the creation with mrmailbox_create_group_chat() the chat is usuall unpromoted until the first call to mrmailbox_send_msg() or mrmailbox_send_text_msg().

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
char * mrchat_get_profile_image ( mrchat_t chat)

Get the chat's profile image.

The profile image is set using mrmailbox_set_chat_profile_image() for groups. For normal chats, the profile image is set using mrmailbox_set_contact_profile_image() (not yet implemented).

Parameters
chatThe chat object.
Returns
Path and file if the profile image, if any. NULL otherwise. Must be free()'d after usage.
char * mrchat_get_subtitle ( mrchat_t chat)

Get a subtitle for a chat.

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

Parameters
chatThe chat object to calulate the subtitle for.
Returns
Subtitle as a string. Must be free()'d after usage.

Member Data Documentation

uint32_t mrchat_t::m_id

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

Special IDs:

  • MR_CHAT_ID_DEADDROP (1) - Messages send from unknown/unwanted users to us, chats_contacts is not set up. This group may be shown normally.
  • MR_CHAT_ID_STARRED (5) - Virtual chat containing all starred messages-
  • MR_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 MR_CHAT_ID_LAST_SPECIAL).

int mrchat_t::m_type

Chat type.

  • MR_CHAT_TYPE_NORMAL (100) - a normal chat is a chat with a single contact, chats_contacts contains one record for the user, MR_CONTACT_ID_SELF (see mrcontact_t::m_id) is not added.
  • MR_CHAT_TYPE_GROUP (120) - a group chat, chats_contacts conain all group members, incl. MR_CONTACT_ID_SELF

If the chat type is not set, it is MR_CHAT_TYPE_UNDEFINED (0).

char* mrchat_t::m_name

Name of the chat.

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

To change the name, use mrmailbox_set_chat_name()

NULL if unset.

time_t mrchat_t::m_draft_timestamp

Timestamp of the draft.

The draft itself is placed in mrchat_t::m_draft_text. To save a draft for a chat, use mrmailbox_set_draft()

0 if there is no draft.

char* mrchat_t::m_draft_text

The draft text.

The timetamp of the draft is placed in mrchat_t::m_draft_timestamp. To save a draft for a chat, use mrmailbox_set_draft()

NULL if there is no draft.

mrmailbox_t* mrchat_t::m_mailbox

The mailbox object the chat belongs to.

Never NULL.

int mrchat_t::m_archived

Flag for the 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 mrmailbox_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.


The documentation for this struct was generated from the following files: