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 
60  char* m_name;
61 
69  char* m_authname;
70 
76  char* m_addr;
77 
84  int m_blocked;
85 
87  int m_origin;
88 } mrcontact_t;
89 
90 
91 mrcontact_t* mrcontact_new (); /* the returned pointer is ref'd and must be unref'd after usage */
94 
95 
96 /* contact origins */
97 #define MR_ORIGIN_UNSET 0
98 #define MR_ORIGIN_INCOMING_UNKNOWN_FROM 0x10 /* From: of incoming messages of unknown sender */
99 #define MR_ORIGIN_INCOMING_UNKNOWN_CC 0x20 /* Cc: of incoming messages of unknown sender */
100 #define MR_ORIGIN_INCOMING_UNKNOWN_TO 0x40 /* To: of incoming messages of unknown sender */
101 #define MR_ORIGIN_INCOMING_REPLY_TO 0x100 /* Reply-To: of incoming message of known sender */
102 #define MR_ORIGIN_INCOMING_CC 0x200 /* Cc: of incoming message of known sender */
103 #define MR_ORIGIN_INCOMING_TO 0x400 /* additional To:'s of incoming message of known sender */
104 #define MR_ORIGIN_CREATE_CHAT 0x800 /* a chat was manually created for this user, but no message yet sent */
105 #define MR_ORIGIN_OUTGOING_BCC 0x1000 /* message send by us */
106 #define MR_ORIGIN_OUTGOING_CC 0x2000 /* message send by us */
107 #define MR_ORIGIN_OUTGOING_TO 0x4000 /* message send by us */
108 #define MR_ORIGIN_INTERNAL 0x40000 /* internal use */
109 #define MR_ORIGIN_ADRESS_BOOK 0x80000 /* address is in our address book */
110 #define MR_ORIGIN_MANUALLY_CREATED 0x100000 /* contact added by mrmailbox_create_contact() */
111 
112 #define MR_ORIGIN_MIN_CONTACT_LIST (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are shown in the contact list */
113 #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 */
114 #define MR_ORIGIN_MIN_START_NEW_NCHAT (0x7FFFFFFF) /* contacts with at least this origin value start a new "normal" chat, defaults to off */
115 
116 
117 /* library-internal */
118 char* mrcontact_get_first_name (const char* full_name);
119 void mrcontact_normalize_name (char* full_name);
120 int mrcontact_load_from_db__ (mrcontact_t*, mrsqlite3_t*, uint32_t contact_id);
121 
122 
123 #ifdef __cplusplus
124 } /* /extern "C" */
125 #endif
126 #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
Name authorized by the contact himself.
Definition: mrcontact.h:69
int m_blocked
Blocked state.
Definition: mrcontact.h:84
char * m_addr
The E-Mail-Address of the contact.
Definition: mrcontact.h:76
char * m_name
Name given by the user to the contact.
Definition: mrcontact.h:60
uint32_t m_id
The contact ID.
Definition: mrcontact.h:48