Delta Chat Core C-API
dc_contact.h
1 #ifndef __DC_CONTACT_H__
2 #define __DC_CONTACT_H__
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 
8 #include "dc_contact.h"
9 #include "dc_apeerstate.h"
10 
11 
13 struct _dc_contact
14 {
17  uint32_t magic;
18  dc_context_t* context;
19 
28  uint32_t id;
29  char* name;
30  char* authname;
31  char* addr;
32  int blocked;
33  int origin;
34 };
35 
36 #define DC_ORIGIN_INCOMING_UNKNOWN_FROM 0x10 /* From: of incoming messages of unknown sender */
37 #define DC_ORIGIN_INCOMING_UNKNOWN_CC 0x20 /* Cc: of incoming messages of unknown sender */
38 #define DC_ORIGIN_INCOMING_UNKNOWN_TO 0x40 /* To: of incoming messages of unknown sender */
39 #define DC_ORIGIN_UNHANDLED_QR_SCAN 0x80 /* address scanned but not verified */
40 #define DC_ORIGIN_INCOMING_REPLY_TO 0x100 /* Reply-To: of incoming message of known sender */
41 #define DC_ORIGIN_INCOMING_CC 0x200 /* Cc: of incoming message of known sender */
42 #define DC_ORIGIN_INCOMING_TO 0x400 /* additional To:'s of incoming message of known sender */
43 #define DC_ORIGIN_CREATE_CHAT 0x800 /* a chat was manually created for this user, but no message yet sent */
44 #define DC_ORIGIN_OUTGOING_BCC 0x1000 /* message sent by us */
45 #define DC_ORIGIN_OUTGOING_CC 0x2000 /* message sent by us */
46 #define DC_ORIGIN_OUTGOING_TO 0x4000 /* message sent by us */
47 #define DC_ORIGIN_INTERNAL 0x40000 /* internal use */
48 #define DC_ORIGIN_ADRESS_BOOK 0x80000 /* address is in our address book */
49 #define DC_ORIGIN_SECUREJOIN_INVITED 0x1000000 /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */
50 #define DC_ORIGIN_SECUREJOIN_JOINED 0x2000000 /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */
51 #define DC_ORIGIN_MANUALLY_CREATED 0x4000000 /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */
52 
53 #define DC_ORIGIN_MIN_CONTACT_LIST (DC_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are shown in the contact list */
54 #define DC_ORIGIN_MIN_VERIFIED (DC_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are verified and known not to be spam */
55 #define DC_ORIGIN_MIN_START_NEW_NCHAT (0x7FFFFFFF) /* contacts with at least this origin value start a new "normal" chat, defaults to off */
56 
57 int dc_contact_load_from_db (dc_contact_t*, dc_sqlite3_t*, uint32_t contact_id);
58 int dc_contact_is_verified_ex (dc_contact_t*, const dc_apeerstate_t*);
59 
60 
61 // Working with names
62 void dc_normalize_name (char* full_name);
63 char* dc_get_first_name (const char* full_name);
64 
65 
66 // Working with e-mail-addresses
67 int dc_addr_cmp (const char* addr1, const char* addr2);
68 char* dc_addr_normalize (const char* addr);
69 int dc_addr_equals_self (dc_context_t*, const char* addr);
70 int dc_addr_equals_contact (dc_context_t*, const char* addr, uint32_t contact_id);
71 
72 
73 // Context functions to work with contacts
74 size_t dc_get_real_contact_cnt (dc_context_t*);
75 uint32_t dc_add_or_lookup_contact (dc_context_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
76 int dc_get_contact_origin (dc_context_t*, uint32_t contact_id, int* ret_blocked);
77 int dc_is_contact_blocked (dc_context_t*, uint32_t contact_id);
78 int dc_real_contact_exists (dc_context_t*, uint32_t contact_id);
79 void dc_scaleup_contact_origin (dc_context_t*, uint32_t contact_id, int origin);
80 
81 
82 #ifdef __cplusplus
83 } /* /extern "C" */
84 #endif
85 #endif /* __DC_CONTACT_H__ */
An object representing a single account.
An object representing a single contact in memory.