Delta Chat Core C-API
mrcontact.h
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Copyright (C) 2017 Björn Petersen
5  * Contact: r10s@b44t.com, http://b44t.com
6  *
7  * This program is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program. If not, see http://www.gnu.org/licenses/ .
19  *
20  ******************************************************************************/
21 
22 
23 #ifndef __MRCONTACT_H__
24 #define __MRCONTACT_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrsqlite3_t mrsqlite3_t;
31 
32 
38 typedef struct mrcontact_t
39 {
40  #define MR_CONTACT_ID_SELF 1
41  #define MR_CONTACT_ID_SYSTEM 2
42  #define MR_CONTACT_ID_LAST_SPECIAL 9
43  uint32_t m_id;
45  char* m_name;
46  char* m_authname;
47  char* m_addr;
48  int m_blocked;
51  int m_origin;
52 } mrcontact_t;
53 
54 
55 mrcontact_t* mrcontact_new (); /* the returned pointer is ref'd and must be unref'd after usage */
58 
59 
60 /* contact origins */
61 #define MR_ORIGIN_UNSET 0
62 #define MR_ORIGIN_INCOMING_UNKNOWN_FROM 0x10 /* From: of incoming messages of unknown sender */
63 #define MR_ORIGIN_INCOMING_UNKNOWN_CC 0x20 /* Cc: of incoming messages of unknown sender */
64 #define MR_ORIGIN_INCOMING_UNKNOWN_TO 0x40 /* To: of incoming messages of unknown sender */
65 #define MR_ORIGIN_INCOMING_REPLY_TO 0x100 /* Reply-To: of incoming message of known sender */
66 #define MR_ORIGIN_INCOMING_CC 0x200 /* Cc: of incoming message of known sender */
67 #define MR_ORIGIN_INCOMING_TO 0x400 /* additional To:'s of incoming message of known sender */
68 #define MR_ORIGIN_CREATE_CHAT 0x800 /* a chat was manually created for this user, but no message yet sent */
69 #define MR_ORIGIN_OUTGOING_BCC 0x1000 /* message send by us */
70 #define MR_ORIGIN_OUTGOING_CC 0x2000 /* message send by us */
71 #define MR_ORIGIN_OUTGOING_TO 0x4000 /* message send by us */
72 #define MR_ORIGIN_INTERNAL 0x40000 /* internal use */
73 #define MR_ORIGIN_ADRESS_BOOK 0x80000 /* address is in our address book */
74 #define MR_ORIGIN_MANUALLY_CREATED 0x100000 /* contact added by mrmailbox_create_contact() */
75 
76 #define MR_ORIGIN_MIN_CONTACT_LIST (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are shown in the contact list */
77 #define MR_ORIGIN_MIN_VERIFIED (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are verified and known not to be spam */
78 #define MR_ORIGIN_MIN_START_NEW_NCHAT (0x7FFFFFFF) /* contacts with at least this origin value start a new "normal" chat, defaults to off */
79 
80 
81 /* library-internal */
82 char* mrcontact_get_first_name (const char* full_name);
83 void mrcontact_normalize_name (char* full_name);
84 int mrcontact_load_from_db__ (mrcontact_t*, mrsqlite3_t*, uint32_t contact_id);
85 
86 
87 #ifdef __cplusplus
88 } /* /extern "C" */
89 #endif
90 #endif /* __MRCONTACT_H__ */
char * mrcontact_get_first_name(const char *full_name)
Get the first name.
Definition: mrcontact.c:99
An object representing a single contact in memory.
Definition: mrcontact.h:38
void mrcontact_empty(mrcontact_t *ths)
Empty a contact object.
Definition: mrcontact.c:65
mrcontact_t * mrcontact_new()
Create a new contact object in memory.
Definition: mrcontact.c:32
void mrcontact_unref(mrcontact_t *ths)
Free a contact object.
Definition: mrcontact.c:49
void mrcontact_normalize_name(char *full_name)
Normalize a name in-place.
Definition: mrcontact.c:130
char * m_authname
may be NULL or empty, this is the name authorized by the sender, only this name may be speaded to oth...
Definition: mrcontact.h:46
int m_blocked
Blocked state.
Definition: mrcontact.h:48
char * m_addr
may be NULL or empty
Definition: mrcontact.h:47
char * m_name
may be NULL or empty, this name should not be spreaded as it may be "Daddy" and so on; initially set ...
Definition: mrcontact.h:45
uint32_t m_id
The contact ID.
Definition: mrcontact.h:43