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 {
48  uint32_t m_id;
49  #define MR_CONTACT_ID_SELF 1
50  #define MR_CONTACT_ID_LAST_SPECIAL 9
51 
52  char* m_name;
53  char* m_authname;
54  char* m_addr;
55  int m_blocked;
58  int m_origin;
59 } mrcontact_t;
60 
61 
62 mrcontact_t* mrcontact_new (); /* the returned pointer is ref'd and must be unref'd after usage */
65 
66 
67 /* contact origins */
68 #define MR_ORIGIN_UNSET 0
69 #define MR_ORIGIN_INCOMING_UNKNOWN_FROM 0x10 /* From: of incoming messages of unknown sender */
70 #define MR_ORIGIN_INCOMING_UNKNOWN_CC 0x20 /* Cc: of incoming messages of unknown sender */
71 #define MR_ORIGIN_INCOMING_UNKNOWN_TO 0x40 /* To: of incoming messages of unknown sender */
72 #define MR_ORIGIN_INCOMING_REPLY_TO 0x100 /* Reply-To: of incoming message of known sender */
73 #define MR_ORIGIN_INCOMING_CC 0x200 /* Cc: of incoming message of known sender */
74 #define MR_ORIGIN_INCOMING_TO 0x400 /* additional To:'s of incoming message of known sender */
75 #define MR_ORIGIN_CREATE_CHAT 0x800 /* a chat was manually created for this user, but no message yet sent */
76 #define MR_ORIGIN_OUTGOING_BCC 0x1000 /* message send by us */
77 #define MR_ORIGIN_OUTGOING_CC 0x2000 /* message send by us */
78 #define MR_ORIGIN_OUTGOING_TO 0x4000 /* message send by us */
79 #define MR_ORIGIN_INTERNAL 0x40000 /* internal use */
80 #define MR_ORIGIN_ADRESS_BOOK 0x80000 /* address is in our address book */
81 #define MR_ORIGIN_MANUALLY_CREATED 0x100000 /* contact added by mrmailbox_create_contact() */
82 
83 #define MR_ORIGIN_MIN_CONTACT_LIST (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are shown in the contact list */
84 #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 */
85 #define MR_ORIGIN_MIN_START_NEW_NCHAT (0x7FFFFFFF) /* contacts with at least this origin value start a new "normal" chat, defaults to off */
86 
87 
88 /* library-internal */
89 char* mrcontact_get_first_name (const char* full_name);
90 void mrcontact_normalize_name (char* full_name);
91 int mrcontact_load_from_db__ (mrcontact_t*, mrsqlite3_t*, uint32_t contact_id);
92 
93 
94 #ifdef __cplusplus
95 } /* /extern "C" */
96 #endif
97 #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:53
int m_blocked
Blocked state.
Definition: mrcontact.h:55
char * m_addr
may be NULL or empty
Definition: mrcontact.h:54
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:52
uint32_t m_id
The contact ID.
Definition: mrcontact.h:48