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 
55  char* m_name;
56 
62  char* m_authname;
63 
67  char* m_addr;
68 
75  int m_blocked;
76 
78  int m_origin;
79 } mrcontact_t;
80 
81 
82 mrcontact_t* mrcontact_new (); /* the returned pointer is ref'd and must be unref'd after usage */
83 void mrcontact_empty (mrcontact_t*);
85 
90 char* mrcontact_get_first_name (const char* full_name);
91 void mrcontact_normalize_name (char* full_name);
92 
93 
94 /* contact origins */
95 #define MR_ORIGIN_UNSET 0
96 #define MR_ORIGIN_INCOMING_UNKNOWN_FROM 0x10 /* From: of incoming messages of unknown sender */
97 #define MR_ORIGIN_INCOMING_UNKNOWN_CC 0x20 /* Cc: of incoming messages of unknown sender */
98 #define MR_ORIGIN_INCOMING_UNKNOWN_TO 0x40 /* To: of incoming messages of unknown sender */
99 #define MR_ORIGIN_INCOMING_REPLY_TO 0x100 /* Reply-To: of incoming message of known sender */
100 #define MR_ORIGIN_INCOMING_CC 0x200 /* Cc: of incoming message of known sender */
101 #define MR_ORIGIN_INCOMING_TO 0x400 /* additional To:'s of incoming message of known sender */
102 #define MR_ORIGIN_CREATE_CHAT 0x800 /* a chat was manually created for this user, but no message yet sent */
103 #define MR_ORIGIN_OUTGOING_BCC 0x1000 /* message send by us */
104 #define MR_ORIGIN_OUTGOING_CC 0x2000 /* message send by us */
105 #define MR_ORIGIN_OUTGOING_TO 0x4000 /* message send by us */
106 #define MR_ORIGIN_INTERNAL 0x40000 /* internal use */
107 #define MR_ORIGIN_ADRESS_BOOK 0x80000 /* address is in our address book */
108 #define MR_ORIGIN_MANUALLY_CREATED 0x100000 /* contact added by mrmailbox_create_contact() */
109 
110 #define MR_ORIGIN_MIN_CONTACT_LIST (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are shown in the contact list */
111 #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 */
112 #define MR_ORIGIN_MIN_START_NEW_NCHAT (0x7FFFFFFF) /* contacts with at least this origin value start a new "normal" chat, defaults to off */
113 
114 
115 /* library-internal */
116 int mrcontact_load_from_db__ (mrcontact_t*, mrsqlite3_t*, uint32_t contact_id);
117 
118 
119 #ifdef __cplusplus
120 } /* /extern "C" */
121 #endif
122 #endif /* __MRCONTACT_H__ */
char * mrcontact_get_name_n_addr(mrcontact_t *contact)
Get a summary of name and address.
Definition: mrcontact.c:193
char * mrcontact_get_first_name(const char *full_name)
Get the first name.
Definition: mrcontact.c:219
An object representing a single contact in memory.
Definition: mrcontact.h:38
void mrcontact_unref(mrcontact_t *contact)
Free a contact object.
Definition: mrcontact.c:57
char * mrcontact_get_display_name(mrcontact_t *contact)
Get display name.
Definition: mrcontact.c:162
void mrcontact_normalize_name(char *full_name)
Normalize a name in-place.
Definition: mrcontact.c:257
char * mrcontact_get_addr(mrcontact_t *contact)
Get email address.
Definition: mrcontact.c:115
char * m_authname
Name authorized by the contact himself.
Definition: mrcontact.h:62
int m_blocked
Blocked state.
Definition: mrcontact.h:75
char * mrcontact_get_name(mrcontact_t *contact)
Get name.
Definition: mrcontact.c:139
char * m_addr
E-Mail-Address of the contact.
Definition: mrcontact.h:67
char * m_name
Contact name.
Definition: mrcontact.h:55
uint32_t m_id
The contact ID.
Definition: mrcontact.h:48