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

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

#include <mrcontact.h>

Public Member Functions

void mrcontact_unref (mrcontact_t *contact)
 Free a contact object. More...
 
char * mrcontact_get_addr (mrcontact_t *contact)
 Get email address. More...
 
char * mrcontact_get_name (mrcontact_t *contact)
 Get name. More...
 
char * mrcontact_get_display_name (mrcontact_t *contact)
 Get display name. More...
 
char * mrcontact_get_name_n_addr (mrcontact_t *contact)
 Get a summary of name and address. More...
 
char * mrcontact_get_first_name (const char *full_name)
 Get the first name. More...
 
void mrcontact_normalize_name (char *full_name)
 Normalize a name in-place. More...
 

Public Attributes

uint32_t m_id
 The contact ID. More...
 
char * m_name
 Contact name. More...
 
char * m_authname
 Name authorized by the contact himself. More...
 
char * m_addr
 E-Mail-Address of the contact. More...
 
int m_blocked
 Blocked state. More...
 

Detailed Description

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.

Member Function Documentation

void mrcontact_unref ( mrcontact_t contact)

Free a contact object.

Parameters
contactThe contact object as created eg. by mrmailbox_get_contact().
Returns
None.
char * mrcontact_get_addr ( mrcontact_t contact)

Get email address.

The email address is always set for a contact.

Parameters
contactThe contact object
Returns
String with the email address, must be free()'d. Never returns NULL.
char * mrcontact_get_name ( mrcontact_t contact)

Get name.

This is the name as defined the 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. This name must not be spreaded via mail (To:, CC: ...) as it as it may be sth. like "Daddy". To get a fine name to display in lists etc., use mrcontact_get_display_name() or mrcontact_get_name_n_addr().

Parameters
contactThe contact object
Returns
String with the name to display, must be free()'d. Empty string if unset, never returns NULL.
char * mrcontact_get_display_name ( mrcontact_t contact)

Get display name.

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

This name is typically used in lists and must not be speaded via mail (To:, CC: ...). To get the name editable in a formular, use mrcontact_get_edit_name().

Parameters
contactThe contact object
Returns
String with the name to display, must be free()'d. Never returns NULL.
char * mrcontact_get_name_n_addr ( mrcontact_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)?"

The summary must not be spreaded via mail (To:, CC: ...) as it as it may contain sth. like "Daddy".

Parameters
contactThe contact object
Returns
Summary string, must be free()'d. Never returns NULL.
char * mrcontact_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.

Parameters
full_nameFull name of the contct.
Returns
String with the first name, must be free()'d after usage.
void mrcontact_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 mrmailbox_add_address_book()

Parameters
full_nameBuffer with the name, is modified during processing; the resulting string may be shorter but never longer.
Returns
None. But the given buffer may be modified.

Member Data Documentation

uint32_t mrcontact_t::m_id

The contact ID.

Special message IDs:

  • MR_CONTACT_ID_SELF (1) - this is the owner of the mailbox with the email-address set by mrmailbox_set_config() using "addr".

Normal contact IDs are larger than these special ones (larger than MR_CONTACT_ID_LAST_SPECIAL).

char* mrcontact_t::m_name

Contact name.

It is recommended to use mrcontact_get_name(), mrcontact_get_display_name() or mrcontact_get_name_n_addr() to access this field. May be NULL or empty, initially set to m_authname.

char* mrcontact_t::m_authname

Name authorized by the contact himself.

It is recommended to use mrcontact_get_name(), mrcontact_get_display_name() or mrcontact_get_name_n_addr() to access this field. This is the name authorized by the sender, only this name may be speaded to others, eg. in To:-lists. May be NULL or empty.

char* mrcontact_t::m_addr

E-Mail-Address of the contact.

It is recommended to use mrcontact_get_addr() to access this field. May be NULL.

int mrcontact_t::m_blocked

Blocked state.

1=contact is blocked, 0=contact is not blocked. To block or unblock a contact, use mrmailbox_block_contact().


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