diff --git a/docs/html/index.html b/docs/html/index.html index e1fbf1f8..ade1323a 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -82,10 +82,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

This document describes how to handle the Delta Chat core library.For general information about Delta Chat itself, see https://delta.chat and https://github.com/deltachat.

Let's start.

First of all, you have to define a function that is called by the library on specific events (eg. when the configuration is done or when fresh messages arrive). Your function should look like the following:

-
#include <mrmailbox.h>
uintptr_t my_delta_handler(mrmailbox_t* nb, int event, uintptr_t data1, uintptr_t data2)
{
return 0; // for unhandled events, it is always safe to return 0
}

After that, you can create and configure a mrmailbox_t object easily as follows:

-
mrmailbox_t* mb = mrmailbox_new(my_delta_handler, NULL, NULL);
mrmailbox_set_config(mb, "addr", "alice@delta.chat"); // use some real test credentials here
mrmailbox_set_config(mb, "mail_pw", "***");

After that, you can send your first message:

-
uint32_t contact_id = mrmailbox_create_contact(mb, "bob@delta.chat"); // use a real testing address here
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mb, contact_id);
mrmailbox_send_text_msg(mb, chat_id, "Hi, here is my first message!");

Now, go to the testing address (bob) and you should have received a normal email. Answer this email in any email program with "Got it!" and you will get the message from delta as follows:

-
carray* msglist = mrmailbox_get_chat_msgs(mb, chat_id, 0, 0);
for( size_t i = 0; i < carray_count(msglist); i++ )
{
uint32_t msg_id = carray_get_uint32(msglist, i);
mrmsg_t* msg = mrmailbox_get_msg(mb, msg_id);
printf("message %i: %s\n", i+1, msg->m_text);
}

This will output the following two lines:

+
#include <mrmailbox.h>
uintptr_t my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
{
return 0; // for unhandled events, it is always safe to return 0
}

After that, you can create and configure a mrmailbox_t object easily as follows:

+
mrmailbox_t* mailbox = mrmailbox_new(my_delta_handler, NULL, NULL);
mrmailbox_set_config(mailbox, "addr", "alice@delta.chat"); // use some real test credentials here
mrmailbox_set_config(mailbox, "mail_pw", "***");

mrmailbox_configure_and_connect() may take a while and saves the result in the database. On subsequent starts, you can call mrmailbox_connect() instead if mrmailbox_is_configured() returns true.

+

However, now you can send your first message:

+
uint32_t contact_id = mrmailbox_create_contact(mailbox, "bob@delta.chat"); // use a real testing address here
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mailbox, contact_id);
mrmailbox_send_text_msg(mailbox, chat_id, "Hi, here is my first message!");

Now, go to the testing address (bob) and you should have received a normal email. Answer this email in any email program with "Got it!" and you will get the message from delta as follows:

+
carray* msglist = mrmailbox_get_chat_msgs(mailbox, chat_id, 0, 0);
for( size_t i = 0; i < carray_count(msglist); i++ )
{
uint32_t msg_id = carray_get_uint32(msglist, i);
mrmsg_t* msg = mrmailbox_get_msg(mailbox, msg_id);
printf("message %i: %s\n", i+1, msg->m_text);
}

This will output the following two lines:

Message 1: Hi, here is my first message!
Message 2: Got it!

I think, you got the idea. For further reading, please dive into the mrmailbox_t class.

Further hints

Here are some additional, unsorted hints that may be useful. If you need any further assistance, please do not hesitate to contact us at r10s@.nosp@m.b44t.nosp@m..com.

diff --git a/docs/html/mrchat_8h_source.html b/docs/html/mrchat_8h_source.html index 97eec32f..207129e3 100644 --- a/docs/html/mrchat_8h_source.html +++ b/docs/html/mrchat_8h_source.html @@ -90,7 +90,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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 __MRCHAT_H__
24 #define __MRCHAT_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrmailbox_t mrmailbox_t;
31 typedef struct mrparam_t mrparam_t;
32 
33 
39 typedef struct mrchat_t
40 {
51  uint32_t m_id;
52  #define MR_CHAT_ID_DEADDROP 1
53  #define MR_CHAT_ID_TO_DEADDROP 2 /* messages send from us to unknown/unwanted users (this may happen when deleting chats or when using CC: in the email-program) */
54  #define MR_CHAT_ID_TRASH 3 /* messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again) */
55  #define MR_CHAT_ID_MSGS_IN_CREATION 4 /* a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be send and shown) */
56  #define MR_CHAT_ID_STARRED 5
57  #define MR_CHAT_ID_ARCHIVED_LINK 6
58  #define MR_CHAT_ID_LAST_SPECIAL 9 /* larger chat IDs are "real" chats, their messages are "real" messages. */
59 
60 
69  int m_type;
70  #define MR_CHAT_TYPE_UNDEFINED 0
71  #define MR_CHAT_TYPE_NORMAL 100
72  #define MR_CHAT_TYPE_GROUP 120
73 
74 
75  char* m_name;
77  char* m_draft_text;
79  int m_archived;
83  char* m_grpid; /* NULL if unset */
84 } mrchat_t;
85 
86 
87 mrchat_t* mrchat_new (mrmailbox_t*);
88 void mrchat_empty (mrchat_t*);
89 void mrchat_unref (mrchat_t*);
91 
92 /* library-internal */
93 int mrchat_load_from_db__ (mrchat_t*, uint32_t id);
94 int mrchat_update_param__ (mrchat_t*);
95 
96 #define MR_CHAT_PREFIX "Chat:" /* you MUST NOT modify this or the following strings */
97 #define MR_CHATS_FOLDER "Chats" /* if we want to support Gma'l-labels - "Chats" is a reserved word for Gma'l */
98 
99 
100 #ifdef __cplusplus
101 } /* /extern "C" */
102 #endif
103 #endif /* __MRCHAT_H__ */
int m_type
Chat type.
Definition: mrchat.h:69
-
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
An object representing a single mailbox.
Definition: mrmailbox.h:182
void mrchat_unref(mrchat_t *chat)
Free a chat object.
Definition: mrchat.c:65
char * m_draft_text
NULL if unset.
Definition: mrchat.h:77
mrmailbox_t * m_mailbox
!= NULL
Definition: mrchat.h:78
diff --git a/docs/html/mrchatlist_8h_source.html b/docs/html/mrchatlist_8h_source.html index 34ccedc1..afc27a9f 100644 --- a/docs/html/mrchatlist_8h_source.html +++ b/docs/html/mrchatlist_8h_source.html @@ -92,7 +92,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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 __MRCHATLIST_H__
24 #define __MRCHATLIST_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrmailbox_t mrmailbox_t;
31 typedef struct mrpoortext_t mrpoortext_t;
32 typedef struct mrchat_t mrchat_t;
33 
34 
42 typedef struct mrchatlist_t
43 {
47  #define MR_CHATLIST_IDS_PER_RESULT 2
48  size_t m_cnt;
49  carray* m_chatNlastmsg_ids;
50 } mrchatlist_t;
51 
52 
53 mrchatlist_t* mrchatlist_new (mrmailbox_t*);
57 uint32_t mrchatlist_get_chat_id (mrchatlist_t*, size_t index);
58 uint32_t mrchatlist_get_msg_id (mrchatlist_t*, size_t index);
60 
61 /* library-internal */
62 int mrchatlist_load_from_db__ (mrchatlist_t*, int listflags, const char* query);
63 
64 
65 #ifdef __cplusplus
66 } /* /extern "C" */
67 #endif
68 #endif /* __MRCHATLIST_H__ */
mrmailbox_t * m_mailbox
The mailbox, the chatlist belongs to.
Definition: mrchatlist.h:44
An object representing a single chatlist in memory.
Definition: mrchatlist.h:42
mrpoortext_t * mrchatlist_get_summary(mrchatlist_t *chatlist, size_t index, mrchat_t *chat)
Get a summary for a chatlist index.
Definition: mrchatlist.c:205
-
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
An object representing a single mailbox.
Definition: mrmailbox.h:182
void mrchatlist_empty(mrchatlist_t *chatlist)
Empty a chatlist object.
Definition: mrchatlist.c:83
uint32_t mrchatlist_get_msg_id(mrchatlist_t *chatlist, size_t index)
Get a single message ID of a chatlist.
Definition: mrchatlist.c:155
An object representing text with some attributes.
Definition: mrpoortext.h:35
diff --git a/docs/html/mrcontact_8h_source.html b/docs/html/mrcontact_8h_source.html index a65fefe6..e6059c7b 100644 --- a/docs/html/mrcontact_8h_source.html +++ b/docs/html/mrcontact_8h_source.html @@ -89,16 +89,16 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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
+
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
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
+
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
diff --git a/docs/html/mrimap_8h_source.html b/docs/html/mrimap_8h_source.html index ab21bbb3..ba8bb53c 100644 --- a/docs/html/mrimap_8h_source.html +++ b/docs/html/mrimap_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrimap.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 /* Purpose: Reading from IMAP servers with no dependencies to the database.
24 mrmailbox_t is only used for logging and to get information about
25 the online state. */
26 
27 
28 #ifndef __MRIMAP_H__
29 #define __MRIMAP_H__
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 typedef struct mrloginparam_t mrloginparam_t;
36 typedef struct mrimap_t mrimap_t;
37 
38 #define MR_IMAP_SEEN 0x0001L
39 
40 typedef int32_t (*mr_get_config_int_t)(mrimap_t*, const char*, int32_t);
41 typedef void (*mr_set_config_int_t)(mrimap_t*, const char*, int32_t);
42 typedef void (*mr_receive_imf_t) (mrimap_t*, const char* imf_raw_not_terminated, size_t imf_raw_bytes, const char* server_folder, uint32_t server_uid, uint32_t flags);
43 
44 
48 typedef struct mrimap_t
49 {
52  char* m_imap_server;
53  int m_imap_port;
54  char* m_imap_user;
55  char* m_imap_pw;
56  int m_server_flags;
57 
58  int m_connected; /* initally connected and watch thread installed */
59  mailimap* m_hEtpan; /* normally, if connected, m_hEtpan is also set; however, if a reconnection is required, we may lost this handle */
60  pthread_mutex_t m_hEtpanmutex;
61  int m_idle_set_up;
62  char* m_selected_folder;
63  int m_should_reconnect;
64 
65  int m_can_idle;
66  int m_has_xlist;
67  char* m_moveto_folder;/* Folder, where reveived chat messages should go to. Normally "Chats" but may be NULL to leave them in the INBOX */
68  char* m_sent_folder; /* Folder, where send messages should go to. Normally "Chats". */
69  pthread_mutex_t m_idlemutex; /* set, if idle is not possible; morover, the interrupted IDLE thread waits a second before IDLEing again; this allows several jobs to be executed */
70  pthread_mutex_t m_inwait_mutex; /* only used to wait for mailstream_wait_idle()/mailimap_idle_done() to terminate. */
71 
72  pthread_t m_watch_thread;
73  pthread_cond_t m_watch_cond;
74  pthread_mutex_t m_watch_condmutex;
75  int m_watch_condflag;
76  int m_watch_do_exit;
77 
78  time_t m_enter_watch_wait_time;
79 
80  pthread_t m_heartbeat_thread;
81  pthread_cond_t m_heartbeat_cond;
82  pthread_mutex_t m_heartbeat_condmutex;
83 
84  struct mailimap_fetch_type* m_fetch_type_uid;
85  struct mailimap_fetch_type* m_fetch_type_body;
86  struct mailimap_fetch_type* m_fetch_type_flags;
87 
88  mr_get_config_int_t m_get_config_int;
89  mr_set_config_int_t m_set_config_int;
90  mr_receive_imf_t m_receive_imf;
91  void* m_userData;
92  mrmailbox_t* m_mailbox;
93 
94  int m_log_connect_errors;
95 } mrimap_t;
96 
97 
98 mrimap_t* mrimap_new (mr_get_config_int_t, mr_set_config_int_t, mr_receive_imf_t, void* userData, mrmailbox_t*);
99 void mrimap_unref (mrimap_t*);
100 
101 int mrimap_connect (mrimap_t*, const mrloginparam_t*);
102 void mrimap_disconnect (mrimap_t*);
103 int mrimap_is_connected (mrimap_t*);
104 int mrimap_fetch (mrimap_t*);
105 
106 int mrimap_append_msg (mrimap_t*, time_t timestamp, const char* data_not_terminated, size_t data_bytes, char** ret_server_folder, uint32_t* ret_server_uid);
107 
108 #define MR_MS_ALSO_MOVE 0x01
109 #define MR_MS_SET_MDNSent_FLAG 0x02
110 #define MR_MS_MDNSent_JUST_SET 0x10
111 int mrimap_markseen_msg (mrimap_t*, const char* folder, uint32_t server_uid, int ms_flags, char** ret_server_folder, uint32_t* ret_server_uid, int* ret_ms_flags); /* only returns 0 on connection problems; we should try later again in this case */
112 
113 int mrimap_delete_msg (mrimap_t*, const char* rfc724_mid, const char* folder, uint32_t server_uid); /* only returns 0 on connection problems; we should try later again in this case */
114 
115 void mrimap_heartbeat (mrimap_t*);
116 
117 #ifdef __cplusplus
118 } /* /extern "C" */
119 #endif
120 #endif /* __MRIMAP_H__ */
121 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 /* Purpose: Reading from IMAP servers with no dependencies to the database.
24 mrmailbox_t is only used for logging and to get information about
25 the online state. */
26 
27 
28 #ifndef __MRIMAP_H__
29 #define __MRIMAP_H__
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 typedef struct mrloginparam_t mrloginparam_t;
36 typedef struct mrimap_t mrimap_t;
37 
38 #define MR_IMAP_SEEN 0x0001L
39 
40 typedef int32_t (*mr_get_config_int_t)(mrimap_t*, const char*, int32_t);
41 typedef void (*mr_set_config_int_t)(mrimap_t*, const char*, int32_t);
42 typedef void (*mr_receive_imf_t) (mrimap_t*, const char* imf_raw_not_terminated, size_t imf_raw_bytes, const char* server_folder, uint32_t server_uid, uint32_t flags);
43 
44 
48 typedef struct mrimap_t
49 {
52  char* m_imap_server;
53  int m_imap_port;
54  char* m_imap_user;
55  char* m_imap_pw;
56  int m_server_flags;
57 
58  int m_connected; /* initally connected and watch thread installed */
59  mailimap* m_hEtpan; /* normally, if connected, m_hEtpan is also set; however, if a reconnection is required, we may lost this handle */
60  pthread_mutex_t m_hEtpanmutex;
61  int m_idle_set_up;
62  char* m_selected_folder;
63  int m_should_reconnect;
64 
65  int m_can_idle;
66  int m_has_xlist;
67  char* m_moveto_folder;/* Folder, where reveived chat messages should go to. Normally "Chats" but may be NULL to leave them in the INBOX */
68  char* m_sent_folder; /* Folder, where send messages should go to. Normally "Chats". */
69  pthread_mutex_t m_idlemutex; /* set, if idle is not possible; morover, the interrupted IDLE thread waits a second before IDLEing again; this allows several jobs to be executed */
70  pthread_mutex_t m_inwait_mutex; /* only used to wait for mailstream_wait_idle()/mailimap_idle_done() to terminate. */
71 
72  pthread_t m_watch_thread;
73  pthread_cond_t m_watch_cond;
74  pthread_mutex_t m_watch_condmutex;
75  int m_watch_condflag;
76  int m_watch_do_exit;
77 
78  time_t m_enter_watch_wait_time;
79 
80  pthread_t m_heartbeat_thread;
81  pthread_cond_t m_heartbeat_cond;
82  pthread_mutex_t m_heartbeat_condmutex;
83 
84  struct mailimap_fetch_type* m_fetch_type_uid;
85  struct mailimap_fetch_type* m_fetch_type_body;
86  struct mailimap_fetch_type* m_fetch_type_flags;
87 
88  mr_get_config_int_t m_get_config_int;
89  mr_set_config_int_t m_set_config_int;
90  mr_receive_imf_t m_receive_imf;
91  void* m_userData;
92  mrmailbox_t* m_mailbox;
93 
94  int m_log_connect_errors;
95 } mrimap_t;
96 
97 
98 mrimap_t* mrimap_new (mr_get_config_int_t, mr_set_config_int_t, mr_receive_imf_t, void* userData, mrmailbox_t*);
99 void mrimap_unref (mrimap_t*);
100 
101 int mrimap_connect (mrimap_t*, const mrloginparam_t*);
102 void mrimap_disconnect (mrimap_t*);
103 int mrimap_is_connected (mrimap_t*);
104 int mrimap_fetch (mrimap_t*);
105 
106 int mrimap_append_msg (mrimap_t*, time_t timestamp, const char* data_not_terminated, size_t data_bytes, char** ret_server_folder, uint32_t* ret_server_uid);
107 
108 #define MR_MS_ALSO_MOVE 0x01
109 #define MR_MS_SET_MDNSent_FLAG 0x02
110 #define MR_MS_MDNSent_JUST_SET 0x10
111 int mrimap_markseen_msg (mrimap_t*, const char* folder, uint32_t server_uid, int ms_flags, char** ret_server_folder, uint32_t* ret_server_uid, int* ret_ms_flags); /* only returns 0 on connection problems; we should try later again in this case */
112 
113 int mrimap_delete_msg (mrimap_t*, const char* rfc724_mid, const char* folder, uint32_t server_uid); /* only returns 0 on connection problems; we should try later again in this case */
114 
115 void mrimap_heartbeat (mrimap_t*);
116 
117 #ifdef __cplusplus
118 } /* /extern "C" */
119 #endif
120 #endif /* __MRIMAP_H__ */
121 
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Contact: r10s@b44t.com, http://b44t.com
5  *
6  * This program is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License as published by the Free Software
8  * Foundation, either version 3 of the License, or (at your option) any later
9  * version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program. If not, see http://www.gnu.org/licenses/ .
18  *
19  ******************************************************************************/
20 
21 
22 #ifndef __MRJOB_H__
23 #define __MRJOB_H__
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
29 #define MRJ_DELETE_MSG_ON_IMAP 100 /* low priority ... */
30 #define MRJ_MARKSEEN_MDN_ON_IMAP 102
31 #define MRJ_SEND_MDN 105
32 #define MRJ_MARKSEEN_MSG_ON_IMAP 110
33 #define MRJ_SEND_MSG_TO_IMAP 700
34 #define MRJ_SEND_MSG_TO_SMTP 800
35 #define MRJ_CONNECT_TO_IMAP 900 /* ... high priority*/
36 
40 typedef struct mrjob_t
41 {
44  uint32_t m_job_id;
45  int m_action;
46  uint32_t m_foreign_id;
47  mrparam_t* m_param;
48  /* the following fields are set by the execution routines, m_param may also be modified */
49  time_t m_start_again_at; /* 1=on next loop, >1=on timestamp, 0=delete job (default) */
50 } mrjob_t;
51 
52 void mrjob_init_thread (mrmailbox_t*);
53 void mrjob_exit_thread (mrmailbox_t*);
54 uint32_t mrjob_add__ (mrmailbox_t*, int action, int foreign_id, const char* param); /* returns the job_id or 0 on errors. the job may or may not be done if the function returns. */
55 void mrjob_kill_action__ (mrmailbox_t*, int action); /* delete all pending jobs with the given action */
56 
57 #define MR_AT_ONCE 0
58 #define MR_INCREATION_POLL 2 /* this value does not increase the number of tries */
59 #define MR_STANDARD_DELAY 3
60 void mrjob_try_again_later (mrjob_t*, int initial_delay_seconds);
61 
62 
63 #ifdef __cplusplus
64 } /* /extern "C" */
65 #endif
66 #endif /* __MRJOB_H__ */
67 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Contact: r10s@b44t.com, http://b44t.com
5  *
6  * This program is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License as published by the Free Software
8  * Foundation, either version 3 of the License, or (at your option) any later
9  * version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program. If not, see http://www.gnu.org/licenses/ .
18  *
19  ******************************************************************************/
20 
21 
22 #ifndef __MRJOB_H__
23 #define __MRJOB_H__
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
29 #define MRJ_DELETE_MSG_ON_IMAP 100 /* low priority ... */
30 #define MRJ_MARKSEEN_MDN_ON_IMAP 102
31 #define MRJ_SEND_MDN 105
32 #define MRJ_MARKSEEN_MSG_ON_IMAP 110
33 #define MRJ_SEND_MSG_TO_IMAP 700
34 #define MRJ_SEND_MSG_TO_SMTP 800
35 #define MRJ_CONNECT_TO_IMAP 900 /* ... high priority*/
36 
40 typedef struct mrjob_t
41 {
44  uint32_t m_job_id;
45  int m_action;
46  uint32_t m_foreign_id;
47  mrparam_t* m_param;
48  /* the following fields are set by the execution routines, m_param may also be modified */
49  time_t m_start_again_at; /* 1=on next loop, >1=on timestamp, 0=delete job (default) */
50 } mrjob_t;
51 
52 void mrjob_init_thread (mrmailbox_t*);
53 void mrjob_exit_thread (mrmailbox_t*);
54 uint32_t mrjob_add__ (mrmailbox_t*, int action, int foreign_id, const char* param); /* returns the job_id or 0 on errors. the job may or may not be done if the function returns. */
55 void mrjob_kill_action__ (mrmailbox_t*, int action); /* delete all pending jobs with the given action */
56 
57 #define MR_AT_ONCE 0
58 #define MR_INCREATION_POLL 2 /* this value does not increase the number of tries */
59 #define MR_STANDARD_DELAY 3
60 void mrjob_try_again_later (mrjob_t*, int initial_delay_seconds);
61 
62 
63 #ifdef __cplusplus
64 } /* /extern "C" */
65 #endif
66 #endif /* __MRJOB_H__ */
67 
An object representing a single mailbox.
Definition: mrmailbox.h:182
An object for handling key=value parameter lists.
Definition: mrparam.h:36
diff --git a/docs/html/mrkey_8h_source.html b/docs/html/mrkey_8h_source.html index 0fecbc84..f18658b2 100644 --- a/docs/html/mrkey_8h_source.html +++ b/docs/html/mrkey_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrkey.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 __MRKEY_H__
24 #define __MRKEY_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrmailbox_t mrmailbox_t;
31 typedef struct sqlite3_stmt sqlite3_stmt;
32 
33 
34 #define MR_PUBLIC 0
35 #define MR_PRIVATE 1
36 
37 
41 typedef struct mrkey_t
42 {
43  void* m_binary;
44  int m_bytes;
45  int m_type;
46 
48  int _m_heap_refcnt; /* !=0 for objects created with mrkey_new(), 0 for stack objects */
49 } mrkey_t;
50 
51 
52 mrkey_t* mrkey_new ();
53 mrkey_t* mrkey_ref (mrkey_t*);
54 void mrkey_unref (mrkey_t*);
55 
56 int mrkey_set_from_raw (mrkey_t*, const void* data, int bytes, int type);
57 int mrkey_set_from_key (mrkey_t*, const mrkey_t*);
58 int mrkey_set_from_stmt (mrkey_t*, sqlite3_stmt*, int index, int type);
59 int mrkey_set_from_base64(mrkey_t*,const char* base64, int type);
60 int mrkey_set_from_file (mrkey_t*, const char* file, mrmailbox_t* mailbox);
61 
62 int mrkey_equals (const mrkey_t*, const mrkey_t*);
63 
64 int mrkey_save_self_keypair__(const mrkey_t* public_key, const mrkey_t* private_key, const char* addr, int is_default, mrsqlite3_t* sql);
65 int mrkey_load_self_public__ (mrkey_t*, const char* self_addr, mrsqlite3_t* sql);
66 int mrkey_load_self_private__(mrkey_t*, const char* self_addr, mrsqlite3_t* sql);
67 
68 char* mr_render_base64 (const void* buf, size_t buf_bytes, int break_every, const char* break_chars, int add_checksum); /* the result must be freed */
69 char* mrkey_render_base64(const mrkey_t* ths, int break_every, const char* break_chars, int add_checksum); /* the result must be freed */
70 char* mrkey_render_asc (const mrkey_t*, const char* add_header_lines); /* each header line must be terminated by \r\n, the result must be freed */
71 char* mrkey_render_fingerprint(const mrkey_t*, mrmailbox_t* mailbox);
72 char* mr_render_fingerprint(const uint8_t* data, size_t bytes);
73 void mr_wipe_secret_mem(void* buf, size_t buf_bytes);
74 
75 
76 #ifdef __cplusplus
77 } /* /extern "C" */
78 #endif
79 #endif /* __MRKEY_H__ */
80 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MRKEY_H__
24 #define __MRKEY_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrmailbox_t mrmailbox_t;
31 typedef struct sqlite3_stmt sqlite3_stmt;
32 
33 
34 #define MR_PUBLIC 0
35 #define MR_PRIVATE 1
36 
37 
41 typedef struct mrkey_t
42 {
43  void* m_binary;
44  int m_bytes;
45  int m_type;
46 
48  int _m_heap_refcnt; /* !=0 for objects created with mrkey_new(), 0 for stack objects */
49 } mrkey_t;
50 
51 
52 mrkey_t* mrkey_new ();
53 mrkey_t* mrkey_ref (mrkey_t*);
54 void mrkey_unref (mrkey_t*);
55 
56 int mrkey_set_from_raw (mrkey_t*, const void* data, int bytes, int type);
57 int mrkey_set_from_key (mrkey_t*, const mrkey_t*);
58 int mrkey_set_from_stmt (mrkey_t*, sqlite3_stmt*, int index, int type);
59 int mrkey_set_from_base64(mrkey_t*,const char* base64, int type);
60 int mrkey_set_from_file (mrkey_t*, const char* file, mrmailbox_t* mailbox);
61 
62 int mrkey_equals (const mrkey_t*, const mrkey_t*);
63 
64 int mrkey_save_self_keypair__(const mrkey_t* public_key, const mrkey_t* private_key, const char* addr, int is_default, mrsqlite3_t* sql);
65 int mrkey_load_self_public__ (mrkey_t*, const char* self_addr, mrsqlite3_t* sql);
66 int mrkey_load_self_private__(mrkey_t*, const char* self_addr, mrsqlite3_t* sql);
67 
68 char* mr_render_base64 (const void* buf, size_t buf_bytes, int break_every, const char* break_chars, int add_checksum); /* the result must be freed */
69 char* mrkey_render_base64(const mrkey_t* ths, int break_every, const char* break_chars, int add_checksum); /* the result must be freed */
70 char* mrkey_render_asc (const mrkey_t*, const char* add_header_lines); /* each header line must be terminated by \r\n, the result must be freed */
71 char* mrkey_render_fingerprint(const mrkey_t*, mrmailbox_t* mailbox);
72 char* mr_render_fingerprint(const uint8_t* data, size_t bytes);
73 void mr_wipe_secret_mem(void* buf, size_t buf_bytes);
74 
75 
76 #ifdef __cplusplus
77 } /* /extern "C" */
78 #endif
79 #endif /* __MRKEY_H__ */
80 
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
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 __MRMAILBOX_H__
24 #define __MRMAILBOX_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #define MR_VERSION_MAJOR 0
31 #define MR_VERSION_MINOR 9
32 #define MR_VERSION_REVISION 8
33 
34 
136 #include <libetpan/libetpan.h> /* defines uint16_t and carray */
137 #include "mrchatlist.h"
138 #include "mrchat.h"
139 #include "mrmsg.h"
140 #include "mrcontact.h"
141 #include "mrpoortext.h"
142 #include "mrparam.h"
143 #include "mrevent.h"
144 
145 typedef struct mrmailbox_t mrmailbox_t;
146 typedef struct mrimap_t mrimap_t;
147 typedef struct mrsmtp_t mrsmtp_t;
148 typedef struct mrsqlite3_t mrsqlite3_t;
149 typedef struct mrjob_t mrjob_t;
150 typedef struct mrmimeparser_t mrmimeparser_t;
151 
152 
168 typedef uintptr_t (*mrmailboxcb_t) (mrmailbox_t*, int event, uintptr_t data1, uintptr_t data2);
169 
170 
178 typedef struct mrmailbox_t
179 {
180  void* m_userdata;
181  char* m_dbfile;
182  char* m_blobdir;
185  mrsqlite3_t* m_sql;
186  mrimap_t* m_imap;
187  mrsmtp_t* m_smtp;
189  pthread_t m_job_thread;
190  pthread_cond_t m_job_cond;
191  pthread_mutex_t m_job_condmutex;
192  int m_job_condflag;
193  int m_job_do_exit;
195  mrmailboxcb_t m_cb;
197  char* m_os_name;
199  uint32_t m_cmdline_sel_chat_id;
201  int m_wake_lock;
202  pthread_mutex_t m_wake_lock_critical;
204  int m_e2ee_enabled;
206  #define MR_LOG_RINGBUF_SIZE 200
207  pthread_mutex_t m_log_ringbuf_critical;
208  char* m_log_ringbuf[MR_LOG_RINGBUF_SIZE];
210  time_t m_log_ringbuf_times[MR_LOG_RINGBUF_SIZE];
212  int m_log_ringbuf_pos;
214 } mrmailbox_t;
215 
216 
217 /* create/open/connect */
218 mrmailbox_t* mrmailbox_new (mrmailboxcb_t, void* userdata, const char* os_name);
219 void mrmailbox_unref (mrmailbox_t*);
220 
221 int mrmailbox_open (mrmailbox_t*, const char* dbfile, const char* blobdir);
222 void mrmailbox_close (mrmailbox_t*);
223 int mrmailbox_is_open (const mrmailbox_t*);
224 
225 int mrmailbox_set_config (mrmailbox_t*, const char* key, const char* value);
226 char* mrmailbox_get_config (mrmailbox_t*, const char* key, const char* def);
227 int mrmailbox_set_config_int (mrmailbox_t*, const char* key, int32_t value);
228 int32_t mrmailbox_get_config_int (mrmailbox_t*, const char* key, int32_t def);
229 char* mrmailbox_get_version_str (void);
230 
231 int mrmailbox_configure_and_connect(mrmailbox_t*);
232 void mrmailbox_configure_cancel (mrmailbox_t*);
233 int mrmailbox_is_configured (mrmailbox_t*);
234 
235 void mrmailbox_connect (mrmailbox_t*);
236 void mrmailbox_disconnect (mrmailbox_t*);
237 
238 char* mrmailbox_get_info (mrmailbox_t*);
239 
240 
241 /* Handle chatlists */
242 #define MR_GCL_ARCHIVED_ONLY 0x01
243 #define MR_GCL_NO_SPECIALS 0x02
244 mrchatlist_t* mrmailbox_get_chatlist (mrmailbox_t*, int flags, const char* query);
245 
246 
247 /* Handle chats */
248 uint32_t mrmailbox_create_chat_by_contact_id (mrmailbox_t*, uint32_t contact_id);
249 uint32_t mrmailbox_get_chat_id_by_contact_id (mrmailbox_t*, uint32_t contact_id);
250 
251 uint32_t mrmailbox_send_text_msg (mrmailbox_t*, uint32_t chat_id, const char* text_to_send);
252 uint32_t mrmailbox_send_msg (mrmailbox_t*, uint32_t chat_id, mrmsg_t*);
253 void mrmailbox_set_draft (mrmailbox_t*, uint32_t chat_id, const char*);
254 
255 #define MR_GCM_ADDDAYMARKER 0x01
256 carray* mrmailbox_get_chat_msgs (mrmailbox_t*, uint32_t chat_id, uint32_t flags, uint32_t marker1before);
257 int mrmailbox_get_total_msg_count (mrmailbox_t*, uint32_t chat_id);
258 int mrmailbox_get_fresh_msg_count (mrmailbox_t*, uint32_t chat_id);
259 carray* mrmailbox_get_fresh_msgs (mrmailbox_t*);
260 void mrmailbox_marknoticed_chat (mrmailbox_t*, uint32_t chat_id);
261 carray* mrmailbox_get_chat_media (mrmailbox_t*, uint32_t chat_id, int msg_type, int or_msg_type);
262 uint32_t mrmailbox_get_next_media (mrmailbox_t*, uint32_t curr_msg_id, int dir);
263 
264 void mrmailbox_archive_chat (mrmailbox_t*, uint32_t chat_id, int archive);
265 void mrmailbox_delete_chat (mrmailbox_t*, uint32_t chat_id);
266 
267 carray* mrmailbox_get_chat_contacts (mrmailbox_t*, uint32_t chat_id);
268 carray* mrmailbox_search_msgs (mrmailbox_t*, uint32_t chat_id, const char* query);
269 
270 mrchat_t* mrmailbox_get_chat (mrmailbox_t*, uint32_t chat_id);
271 
272 
273 /* Handle group chats */
274 uint32_t mrmailbox_create_group_chat (mrmailbox_t*, const char* name);
275 int mrmailbox_is_contact_in_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
276 int mrmailbox_add_contact_to_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
277 int mrmailbox_remove_contact_from_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
278 int mrmailbox_set_chat_name (mrmailbox_t*, uint32_t chat_id, const char* name);
279 int mrmailbox_set_chat_image (mrmailbox_t*, uint32_t chat_id, const char* image);
280 
281 
282 /* Handle messages */
283 char* mrmailbox_get_msg_info (mrmailbox_t*, uint32_t msg_id);
284 void mrmailbox_delete_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt);
285 void mrmailbox_forward_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id);
286 void mrmailbox_marknoticed_contact (mrmailbox_t*, uint32_t contact_id);
287 void mrmailbox_markseen_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt);
288 void mrmailbox_star_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt, int star);
289 mrmsg_t* mrmailbox_get_msg (mrmailbox_t*, uint32_t msg_id);
290 
291 
292 /* Handle contacts */
293 uint32_t mrmailbox_create_contact (mrmailbox_t*, const char* name, const char* addr);
294 int mrmailbox_add_address_book (mrmailbox_t*, const char*);
295 carray* mrmailbox_get_known_contacts (mrmailbox_t*, const char* query);
296 int mrmailbox_get_blocked_count (mrmailbox_t*);
297 carray* mrmailbox_get_blocked_contacts (mrmailbox_t*);
298 void mrmailbox_block_contact (mrmailbox_t*, uint32_t contact_id, int block);
299 char* mrmailbox_get_contact_encrinfo (mrmailbox_t*, uint32_t contact_id);
300 int mrmailbox_delete_contact (mrmailbox_t*, uint32_t contact_id);
301 mrcontact_t* mrmailbox_get_contact (mrmailbox_t*, uint32_t contact_id);
302 
303 
304 /* Import/export and Tools */
305 #define MR_IMEX_CANCEL 0
306 #define MR_IMEX_EXPORT_SELF_KEYS 1 /* param1 is a directory where the keys are written to */
307 #define MR_IMEX_IMPORT_SELF_KEYS 2 /* param1 is a directory where the keys are searched in and read from */
308 #define MR_IMEX_EXPORT_BACKUP 11 /* param1 is a directory where the backup is written to */
309 #define MR_IMEX_IMPORT_BACKUP 12 /* param1 is the file with the backup to import */
310 #define MR_IMEX_EXPORT_SETUP_MESSAGE 20 /* param1 is a directory where the setup file is written to */
311 #define MR_BAK_PREFIX "delta-chat"
312 #define MR_BAK_SUFFIX "bak"
313 void mrmailbox_imex (mrmailbox_t*, int what, const char* param1, const char* setup_code);
314 char* mrmailbox_imex_has_backup (mrmailbox_t*, const char* dir);
315 int mrmailbox_check_password (mrmailbox_t*, const char* pw);
316 char* mrmailbox_create_setup_code (mrmailbox_t*);
317 void mrmailbox_heartbeat (mrmailbox_t*);
318 
319 
320 /* logging */
321 void mrmailbox_log_error (mrmailbox_t*, int code, const char* msg, ...);
322 void mrmailbox_log_error_if (int* condition, mrmailbox_t*, int code, const char* msg, ...);
323 void mrmailbox_log_warning (mrmailbox_t*, int code, const char* msg, ...);
324 void mrmailbox_log_info (mrmailbox_t*, int code, const char* msg, ...);
325 void mrmailbox_log_vprintf (mrmailbox_t*, int event, int code, const char* msg, va_list);
326 int mrmailbox_get_thread_index (void);
327 
328 
329 /* error codes */
330 #define MR_ERR_SELF_NOT_IN_GROUP 1
331 #define MR_ERR_NONETWORK 2
332 
333 
334 /* carray tools, already defined are things as
335 unsigned unt carray_count() */
336 uint32_t carray_get_uint32 (carray*, unsigned int index);
337 
338 
339 /* deprecated functions */
340 mrchat_t* mrchatlist_get_chat_by_index (mrchatlist_t*, size_t index); /* deprecated - use mrchatlist_get_chat_id_by_index() */
341 mrmsg_t* mrchatlist_get_msg_by_index (mrchatlist_t*, size_t index); /* deprecated - use mrchatlist_get_msg_id_by_index() */
342 int mrchat_set_draft (mrchat_t*, const char* msg); /* deprecated - use mrmailbox_set_draft() instead */
343 
344 
345 /* library-internal */
346 uint32_t mrmailbox_send_msg_i__ (mrmailbox_t*, mrchat_t*, const mrmsg_t*, time_t);
347 void mrmailbox_connect_to_imap (mrmailbox_t*, mrjob_t*);
348 void mrmailbox_wake_lock (mrmailbox_t*);
349 void mrmailbox_wake_unlock (mrmailbox_t*);
350 int mrmailbox_poke_eml_file (mrmailbox_t*, const char* file);
351 int mrmailbox_is_reply_to_known_message__ (mrmailbox_t*, mrmimeparser_t*);
352 int mrmailbox_is_reply_to_messenger_message__ (mrmailbox_t*, mrmimeparser_t*);
353 time_t mrmailbox_correct_bad_timestamp__ (mrmailbox_t* ths, uint32_t chat_id, uint32_t from_id, time_t desired_timestamp, int is_fresh_msg);
354 void mrmailbox_add_or_lookup_contacts_by_mailbox_list__(mrmailbox_t* ths, struct mailimf_mailbox_list* mb_list, int origin, carray* ids, int* check_self);
355 void mrmailbox_add_or_lookup_contacts_by_address_list__(mrmailbox_t* ths, struct mailimf_address_list* adr_list, int origin, carray* ids, int* check_self);
356 int mrmailbox_get_archived_count__ (mrmailbox_t*);
357 int mrmailbox_reset_tables (mrmailbox_t*, int bits); /* reset tables but leaves server configuration, 1=jobs, 2=e2ee, 8=rest but server config */
358 size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*);
359 uint32_t mrmailbox_add_or_lookup_contact__ (mrmailbox_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
360 int mrmailbox_get_contact_origin__ (mrmailbox_t*, uint32_t id, int* ret_blocked);
361 int mrmailbox_is_contact_blocked__ (mrmailbox_t*, uint32_t id);
362 int mrmailbox_real_contact_exists__ (mrmailbox_t*, uint32_t id);
363 int mrmailbox_contact_addr_equals__ (mrmailbox_t*, uint32_t contact_id, const char* other_addr);
364 void mrmailbox_scaleup_contact_origin__ (mrmailbox_t*, uint32_t contact_id, int origin);
365 void mrmailbox_unarchive_chat__ (mrmailbox_t*, uint32_t chat_id);
366 size_t mrmailbox_get_chat_cnt__ (mrmailbox_t*);
367 uint32_t mrmailbox_create_or_lookup_nchat_by_contact_id__ (mrmailbox_t*, uint32_t contact_id);
368 uint32_t mrmailbox_lookup_real_nchat_by_contact_id__ (mrmailbox_t*, uint32_t contact_id);
369 int mrmailbox_get_total_msg_count__ (mrmailbox_t*, uint32_t chat_id);
370 int mrmailbox_get_fresh_msg_count__ (mrmailbox_t*, uint32_t chat_id);
371 uint32_t mrmailbox_get_last_deaddrop_fresh_msg__ (mrmailbox_t*);
372 void mrmailbox_send_msg_to_smtp (mrmailbox_t*, mrjob_t*);
373 void mrmailbox_send_msg_to_imap (mrmailbox_t*, mrjob_t*);
374 int mrmailbox_add_contact_to_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
375 int mrmailbox_is_contact_in_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
376 int mrmailbox_get_chat_contact_count__ (mrmailbox_t*, uint32_t chat_id);
377 int mrmailbox_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
378 void mrmailbox_set_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
379 size_t mrmailbox_get_real_msg_cnt__ (mrmailbox_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
380 size_t mrmailbox_get_deaddrop_msg_cnt__ (mrmailbox_t*);
381 int mrmailbox_rfc724_mid_cnt__ (mrmailbox_t*, const char* rfc724_mid);
382 int mrmailbox_rfc724_mid_exists__ (mrmailbox_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
383 void mrmailbox_update_server_uid__ (mrmailbox_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
384 void mrmailbox_update_msg_chat_id__ (mrmailbox_t*, uint32_t msg_id, uint32_t chat_id);
385 void mrmailbox_update_msg_state__ (mrmailbox_t*, uint32_t msg_id, int state);
386 void mrmailbox_delete_msg_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
387 int mrmailbox_mdn_from_ext__ (mrmailbox_t*, uint32_t from_id, const char* rfc724_mid, uint32_t* ret_chat_id, uint32_t* ret_msg_id); /* returns 1 if an event should be send */
388 void mrmailbox_send_mdn (mrmailbox_t*, mrjob_t* job);
389 void mrmailbox_markseen_msg_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
390 void mrmailbox_markseen_mdn_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
391 
392 
393 /* library private: end-to-end-encryption */
394 #define MR_E2EE_DEFAULT_ENABLED 1
395 #define MR_MDNS_DEFAULT_ENABLED 1
396 
397 typedef struct mrmailbox_e2ee_helper_t {
398  int m_encryption_successfull;
399  void* m_cdata_to_free;
400 } mrmailbox_e2ee_helper_t;
401 
402 void mrmailbox_e2ee_encrypt (mrmailbox_t*, const clist* recipients_addr, int e2ee_guaranteed, int encrypt_to_self, struct mailmime* in_out_message, mrmailbox_e2ee_helper_t*);
403 int mrmailbox_e2ee_decrypt (mrmailbox_t*, struct mailmime* in_out_message, int* ret_validation_errors); /* returns 1 if sth. was decrypted, 0 in other cases */
404 void mrmailbox_e2ee_thanks (mrmailbox_e2ee_helper_t*); /* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling mre2ee_unhelp(), in_out_message cannot be used any longer! */
405 int mrmailbox_ensure_secret_key_exists (mrmailbox_t*); /* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */
406 
407 
408 #ifdef __cplusplus
409 } /* /extern "C" */
410 #endif
411 #endif /* __MRMAILBOX_H__ */
int mrmailbox_add_address_book(mrmailbox_t *mailbox, const char *adr_book)
Add a number of contacts.
Definition: mrmailbox.c:4006
-
uint32_t mrmailbox_create_group_chat(mrmailbox_t *mailbox, const char *chat_name)
Create a new group chat.
Definition: mrmailbox.c:3318
-
uint32_t mrmailbox_create_contact(mrmailbox_t *mailbox, const char *name, const char *addr)
Add a single contact.
Definition: mrmailbox.c:3970
-
uint32_t mrmailbox_send_text_msg(mrmailbox_t *mailbox, uint32_t chat_id, const char *text_to_send)
Send a simple text message to the given chat.
Definition: mrmailbox.c:3086
+
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 __MRMAILBOX_H__
24 #define __MRMAILBOX_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #define MR_VERSION_MAJOR 0
31 #define MR_VERSION_MINOR 9
32 #define MR_VERSION_REVISION 8
33 
34 
140 #include <libetpan/libetpan.h> /* defines uint16_t and carray */
141 #include "mrchatlist.h"
142 #include "mrchat.h"
143 #include "mrmsg.h"
144 #include "mrcontact.h"
145 #include "mrpoortext.h"
146 #include "mrparam.h"
147 #include "mrevent.h"
148 
149 typedef struct mrmailbox_t mrmailbox_t;
150 typedef struct mrimap_t mrimap_t;
151 typedef struct mrsmtp_t mrsmtp_t;
152 typedef struct mrsqlite3_t mrsqlite3_t;
153 typedef struct mrjob_t mrjob_t;
154 typedef struct mrmimeparser_t mrmimeparser_t;
155 
156 
172 typedef uintptr_t (*mrmailboxcb_t) (mrmailbox_t*, int event, uintptr_t data1, uintptr_t data2);
173 
174 
182 typedef struct mrmailbox_t
183 {
184  void* m_userdata;
185  char* m_dbfile;
186  char* m_blobdir;
189  mrsqlite3_t* m_sql;
190  mrimap_t* m_imap;
191  mrsmtp_t* m_smtp;
193  pthread_t m_job_thread;
194  pthread_cond_t m_job_cond;
195  pthread_mutex_t m_job_condmutex;
196  int m_job_condflag;
197  int m_job_do_exit;
199  mrmailboxcb_t m_cb;
201  char* m_os_name;
203  uint32_t m_cmdline_sel_chat_id;
205  int m_wake_lock;
206  pthread_mutex_t m_wake_lock_critical;
208  int m_e2ee_enabled;
210  #define MR_LOG_RINGBUF_SIZE 200
211  pthread_mutex_t m_log_ringbuf_critical;
212  char* m_log_ringbuf[MR_LOG_RINGBUF_SIZE];
214  time_t m_log_ringbuf_times[MR_LOG_RINGBUF_SIZE];
216  int m_log_ringbuf_pos;
218 } mrmailbox_t;
219 
220 
221 /* create/open/connect */
222 mrmailbox_t* mrmailbox_new (mrmailboxcb_t, void* userdata, const char* os_name);
223 void mrmailbox_unref (mrmailbox_t*);
224 
225 int mrmailbox_open (mrmailbox_t*, const char* dbfile, const char* blobdir);
226 void mrmailbox_close (mrmailbox_t*);
227 int mrmailbox_is_open (const mrmailbox_t*);
228 
229 int mrmailbox_set_config (mrmailbox_t*, const char* key, const char* value);
230 char* mrmailbox_get_config (mrmailbox_t*, const char* key, const char* def);
231 int mrmailbox_set_config_int (mrmailbox_t*, const char* key, int32_t value);
232 int32_t mrmailbox_get_config_int (mrmailbox_t*, const char* key, int32_t def);
233 char* mrmailbox_get_version_str (void);
234 
235 int mrmailbox_configure_and_connect(mrmailbox_t*);
236 void mrmailbox_configure_cancel (mrmailbox_t*);
237 int mrmailbox_is_configured (mrmailbox_t*);
238 
239 void mrmailbox_connect (mrmailbox_t*);
240 void mrmailbox_disconnect (mrmailbox_t*);
241 
242 char* mrmailbox_get_info (mrmailbox_t*);
243 
244 
245 /* Handle chatlists */
246 #define MR_GCL_ARCHIVED_ONLY 0x01
247 #define MR_GCL_NO_SPECIALS 0x02
248 mrchatlist_t* mrmailbox_get_chatlist (mrmailbox_t*, int flags, const char* query);
249 
250 
251 /* Handle chats */
252 uint32_t mrmailbox_create_chat_by_contact_id (mrmailbox_t*, uint32_t contact_id);
253 uint32_t mrmailbox_get_chat_id_by_contact_id (mrmailbox_t*, uint32_t contact_id);
254 
255 uint32_t mrmailbox_send_text_msg (mrmailbox_t*, uint32_t chat_id, const char* text_to_send);
256 uint32_t mrmailbox_send_msg (mrmailbox_t*, uint32_t chat_id, mrmsg_t*);
257 void mrmailbox_set_draft (mrmailbox_t*, uint32_t chat_id, const char*);
258 
259 #define MR_GCM_ADDDAYMARKER 0x01
260 carray* mrmailbox_get_chat_msgs (mrmailbox_t*, uint32_t chat_id, uint32_t flags, uint32_t marker1before);
261 int mrmailbox_get_total_msg_count (mrmailbox_t*, uint32_t chat_id);
262 int mrmailbox_get_fresh_msg_count (mrmailbox_t*, uint32_t chat_id);
263 carray* mrmailbox_get_fresh_msgs (mrmailbox_t*);
264 void mrmailbox_marknoticed_chat (mrmailbox_t*, uint32_t chat_id);
265 carray* mrmailbox_get_chat_media (mrmailbox_t*, uint32_t chat_id, int msg_type, int or_msg_type);
266 uint32_t mrmailbox_get_next_media (mrmailbox_t*, uint32_t curr_msg_id, int dir);
267 
268 void mrmailbox_archive_chat (mrmailbox_t*, uint32_t chat_id, int archive);
269 void mrmailbox_delete_chat (mrmailbox_t*, uint32_t chat_id);
270 
271 carray* mrmailbox_get_chat_contacts (mrmailbox_t*, uint32_t chat_id);
272 carray* mrmailbox_search_msgs (mrmailbox_t*, uint32_t chat_id, const char* query);
273 
274 mrchat_t* mrmailbox_get_chat (mrmailbox_t*, uint32_t chat_id);
275 
276 
277 /* Handle group chats */
278 uint32_t mrmailbox_create_group_chat (mrmailbox_t*, const char* name);
279 int mrmailbox_is_contact_in_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
280 int mrmailbox_add_contact_to_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
281 int mrmailbox_remove_contact_from_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
282 int mrmailbox_set_chat_name (mrmailbox_t*, uint32_t chat_id, const char* name);
283 int mrmailbox_set_chat_image (mrmailbox_t*, uint32_t chat_id, const char* image);
284 
285 
286 /* Handle messages */
287 char* mrmailbox_get_msg_info (mrmailbox_t*, uint32_t msg_id);
288 void mrmailbox_delete_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt);
289 void mrmailbox_forward_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id);
290 void mrmailbox_marknoticed_contact (mrmailbox_t*, uint32_t contact_id);
291 void mrmailbox_markseen_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt);
292 void mrmailbox_star_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt, int star);
293 mrmsg_t* mrmailbox_get_msg (mrmailbox_t*, uint32_t msg_id);
294 
295 
296 /* Handle contacts */
297 uint32_t mrmailbox_create_contact (mrmailbox_t*, const char* name, const char* addr);
298 int mrmailbox_add_address_book (mrmailbox_t*, const char*);
299 carray* mrmailbox_get_known_contacts (mrmailbox_t*, const char* query);
300 int mrmailbox_get_blocked_count (mrmailbox_t*);
301 carray* mrmailbox_get_blocked_contacts (mrmailbox_t*);
302 void mrmailbox_block_contact (mrmailbox_t*, uint32_t contact_id, int block);
303 char* mrmailbox_get_contact_encrinfo (mrmailbox_t*, uint32_t contact_id);
304 int mrmailbox_delete_contact (mrmailbox_t*, uint32_t contact_id);
305 mrcontact_t* mrmailbox_get_contact (mrmailbox_t*, uint32_t contact_id);
306 
307 
308 /* Import/export and Tools */
309 #define MR_IMEX_CANCEL 0
310 #define MR_IMEX_EXPORT_SELF_KEYS 1 /* param1 is a directory where the keys are written to */
311 #define MR_IMEX_IMPORT_SELF_KEYS 2 /* param1 is a directory where the keys are searched in and read from */
312 #define MR_IMEX_EXPORT_BACKUP 11 /* param1 is a directory where the backup is written to */
313 #define MR_IMEX_IMPORT_BACKUP 12 /* param1 is the file with the backup to import */
314 #define MR_IMEX_EXPORT_SETUP_MESSAGE 20 /* param1 is a directory where the setup file is written to */
315 #define MR_BAK_PREFIX "delta-chat"
316 #define MR_BAK_SUFFIX "bak"
317 void mrmailbox_imex (mrmailbox_t*, int what, const char* param1, const char* setup_code);
318 char* mrmailbox_imex_has_backup (mrmailbox_t*, const char* dir);
319 int mrmailbox_check_password (mrmailbox_t*, const char* pw);
320 char* mrmailbox_create_setup_code (mrmailbox_t*);
321 void mrmailbox_heartbeat (mrmailbox_t*);
322 
323 
324 /* logging */
325 void mrmailbox_log_error (mrmailbox_t*, int code, const char* msg, ...);
326 void mrmailbox_log_error_if (int* condition, mrmailbox_t*, int code, const char* msg, ...);
327 void mrmailbox_log_warning (mrmailbox_t*, int code, const char* msg, ...);
328 void mrmailbox_log_info (mrmailbox_t*, int code, const char* msg, ...);
329 void mrmailbox_log_vprintf (mrmailbox_t*, int event, int code, const char* msg, va_list);
330 int mrmailbox_get_thread_index (void);
331 
332 
333 /* error codes */
334 #define MR_ERR_SELF_NOT_IN_GROUP 1
335 #define MR_ERR_NONETWORK 2
336 
337 
338 /* carray tools, already defined are things as
339 unsigned unt carray_count() */
340 uint32_t carray_get_uint32 (carray*, unsigned int index);
341 
342 
343 /* deprecated functions */
344 mrchat_t* mrchatlist_get_chat_by_index (mrchatlist_t*, size_t index); /* deprecated - use mrchatlist_get_chat_id_by_index() */
345 mrmsg_t* mrchatlist_get_msg_by_index (mrchatlist_t*, size_t index); /* deprecated - use mrchatlist_get_msg_id_by_index() */
346 int mrchat_set_draft (mrchat_t*, const char* msg); /* deprecated - use mrmailbox_set_draft() instead */
347 
348 
349 /* library-internal */
350 uint32_t mrmailbox_send_msg_i__ (mrmailbox_t*, mrchat_t*, const mrmsg_t*, time_t);
351 void mrmailbox_connect_to_imap (mrmailbox_t*, mrjob_t*);
352 void mrmailbox_wake_lock (mrmailbox_t*);
353 void mrmailbox_wake_unlock (mrmailbox_t*);
354 int mrmailbox_poke_eml_file (mrmailbox_t*, const char* file);
355 int mrmailbox_is_reply_to_known_message__ (mrmailbox_t*, mrmimeparser_t*);
356 int mrmailbox_is_reply_to_messenger_message__ (mrmailbox_t*, mrmimeparser_t*);
357 time_t mrmailbox_correct_bad_timestamp__ (mrmailbox_t* ths, uint32_t chat_id, uint32_t from_id, time_t desired_timestamp, int is_fresh_msg);
358 void mrmailbox_add_or_lookup_contacts_by_mailbox_list__(mrmailbox_t* ths, struct mailimf_mailbox_list* mb_list, int origin, carray* ids, int* check_self);
359 void mrmailbox_add_or_lookup_contacts_by_address_list__(mrmailbox_t* ths, struct mailimf_address_list* adr_list, int origin, carray* ids, int* check_self);
360 int mrmailbox_get_archived_count__ (mrmailbox_t*);
361 int mrmailbox_reset_tables (mrmailbox_t*, int bits); /* reset tables but leaves server configuration, 1=jobs, 2=e2ee, 8=rest but server config */
362 size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*);
363 uint32_t mrmailbox_add_or_lookup_contact__ (mrmailbox_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
364 int mrmailbox_get_contact_origin__ (mrmailbox_t*, uint32_t id, int* ret_blocked);
365 int mrmailbox_is_contact_blocked__ (mrmailbox_t*, uint32_t id);
366 int mrmailbox_real_contact_exists__ (mrmailbox_t*, uint32_t id);
367 int mrmailbox_contact_addr_equals__ (mrmailbox_t*, uint32_t contact_id, const char* other_addr);
368 void mrmailbox_scaleup_contact_origin__ (mrmailbox_t*, uint32_t contact_id, int origin);
369 void mrmailbox_unarchive_chat__ (mrmailbox_t*, uint32_t chat_id);
370 size_t mrmailbox_get_chat_cnt__ (mrmailbox_t*);
371 uint32_t mrmailbox_create_or_lookup_nchat_by_contact_id__ (mrmailbox_t*, uint32_t contact_id);
372 uint32_t mrmailbox_lookup_real_nchat_by_contact_id__ (mrmailbox_t*, uint32_t contact_id);
373 int mrmailbox_get_total_msg_count__ (mrmailbox_t*, uint32_t chat_id);
374 int mrmailbox_get_fresh_msg_count__ (mrmailbox_t*, uint32_t chat_id);
375 uint32_t mrmailbox_get_last_deaddrop_fresh_msg__ (mrmailbox_t*);
376 void mrmailbox_send_msg_to_smtp (mrmailbox_t*, mrjob_t*);
377 void mrmailbox_send_msg_to_imap (mrmailbox_t*, mrjob_t*);
378 int mrmailbox_add_contact_to_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
379 int mrmailbox_is_contact_in_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
380 int mrmailbox_get_chat_contact_count__ (mrmailbox_t*, uint32_t chat_id);
381 int mrmailbox_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
382 void mrmailbox_set_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
383 size_t mrmailbox_get_real_msg_cnt__ (mrmailbox_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
384 size_t mrmailbox_get_deaddrop_msg_cnt__ (mrmailbox_t*);
385 int mrmailbox_rfc724_mid_cnt__ (mrmailbox_t*, const char* rfc724_mid);
386 int mrmailbox_rfc724_mid_exists__ (mrmailbox_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
387 void mrmailbox_update_server_uid__ (mrmailbox_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
388 void mrmailbox_update_msg_chat_id__ (mrmailbox_t*, uint32_t msg_id, uint32_t chat_id);
389 void mrmailbox_update_msg_state__ (mrmailbox_t*, uint32_t msg_id, int state);
390 void mrmailbox_delete_msg_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
391 int mrmailbox_mdn_from_ext__ (mrmailbox_t*, uint32_t from_id, const char* rfc724_mid, uint32_t* ret_chat_id, uint32_t* ret_msg_id); /* returns 1 if an event should be send */
392 void mrmailbox_send_mdn (mrmailbox_t*, mrjob_t* job);
393 void mrmailbox_markseen_msg_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
394 void mrmailbox_markseen_mdn_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
395 
396 
397 /* library private: end-to-end-encryption */
398 #define MR_E2EE_DEFAULT_ENABLED 1
399 #define MR_MDNS_DEFAULT_ENABLED 1
400 
401 typedef struct mrmailbox_e2ee_helper_t {
402  int m_encryption_successfull;
403  void* m_cdata_to_free;
404 } mrmailbox_e2ee_helper_t;
405 
406 void mrmailbox_e2ee_encrypt (mrmailbox_t*, const clist* recipients_addr, int e2ee_guaranteed, int encrypt_to_self, struct mailmime* in_out_message, mrmailbox_e2ee_helper_t*);
407 int mrmailbox_e2ee_decrypt (mrmailbox_t*, struct mailmime* in_out_message, int* ret_validation_errors); /* returns 1 if sth. was decrypted, 0 in other cases */
408 void mrmailbox_e2ee_thanks (mrmailbox_e2ee_helper_t*); /* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling mre2ee_unhelp(), in_out_message cannot be used any longer! */
409 int mrmailbox_ensure_secret_key_exists (mrmailbox_t*); /* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */
410 
411 
412 #ifdef __cplusplus
413 } /* /extern "C" */
414 #endif
415 #endif /* __MRMAILBOX_H__ */
int mrmailbox_add_address_book(mrmailbox_t *mailbox, const char *adr_book)
Add a number of contacts.
Definition: mrmailbox.c:4004
+
uint32_t mrmailbox_create_group_chat(mrmailbox_t *mailbox, const char *chat_name)
Create a new group chat.
Definition: mrmailbox.c:3316
+
uint32_t mrmailbox_create_contact(mrmailbox_t *mailbox, const char *name, const char *addr)
Add a single contact.
Definition: mrmailbox.c:3968
+
uint32_t mrmailbox_send_text_msg(mrmailbox_t *mailbox, uint32_t chat_id, const char *text_to_send)
Send a simple text message to the given chat.
Definition: mrmailbox.c:3084
void mrmailbox_close(mrmailbox_t *mailbox)
Close mailbox database.
Definition: mrmailbox.c:1076
mrmailbox_t * mrmailbox_new(mrmailboxcb_t cb, void *userdata, const char *os_name)
Create a new mailbox object.
Definition: mrmailbox.c:898
-
int mrmailbox_is_contact_in_chat(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t contact_id)
Check if a given contact ID is a member of a group chat.
Definition: mrmailbox.c:3550
+
int mrmailbox_is_contact_in_chat(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t contact_id)
Check if a given contact ID is a member of a group chat.
Definition: mrmailbox.c:3548
The following constants are used as events reported to the callback given to mrmailbox_new().
-
mrchat_t * mrmailbox_get_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Get a chat object of type mrchat_t by a chat_id.
Definition: mrmailbox.c:1694
-
int mrmailbox_remove_contact_from_chat(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t contact_id)
Remove a member from a group.
Definition: mrmailbox.c:3663
+
mrchat_t * mrmailbox_get_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Get chat object by a chat ID.
Definition: mrmailbox.c:1692
+
int mrmailbox_remove_contact_from_chat(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t contact_id)
Remove a member from a group.
Definition: mrmailbox.c:3661
int mrmailbox_open(mrmailbox_t *mailbox, const char *dbfile, const char *blobdir)
Open mailbox database.
Definition: mrmailbox.c:1011
An object representing a single contact in memory.
Definition: mrcontact.h:38
-
int mrmailbox_delete_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Delete a contact.
Definition: mrmailbox.c:4494
+
int mrmailbox_delete_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Delete a contact.
Definition: mrmailbox.c:4492
An object representing a single chatlist in memory.
Definition: mrchatlist.h:42
void mrmailbox_heartbeat(mrmailbox_t *ths)
Stay alive.
Definition: mrmailbox.c:1616
-
carray * mrmailbox_get_chat_msgs(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t flags, uint32_t marker1before)
Get all message IDs belonging to a chat.
Definition: mrmailbox.c:2105
-
void mrmailbox_star_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt, int star)
Star/unstar messages by setting the last parameter to 0 (unstar) or 1(star).
Definition: mrmailbox.c:4939
-
carray * mrmailbox_search_msgs(mrmailbox_t *mailbox, uint32_t chat_id, const char *query)
Search messages containing the given query string.
Definition: mrmailbox.c:2209
+
carray * mrmailbox_get_chat_msgs(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t flags, uint32_t marker1before)
Get all message IDs belonging to a chat.
Definition: mrmailbox.c:2103
+
void mrmailbox_star_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt, int star)
Star/unstar messages by setting the last parameter to 0 (unstar) or 1(star).
Definition: mrmailbox.c:4937
+
carray * mrmailbox_search_msgs(mrmailbox_t *mailbox, uint32_t chat_id, const char *query)
Search messages containing the given query string.
Definition: mrmailbox.c:2207
int mrmailbox_set_config(mrmailbox_t *ths, const char *key, const char *value)
Configure the mailbox.
Definition: mrmailbox.c:1177
-
char * m_dbfile
the database file in file.
Definition: mrmailbox.h:181
-
An object representing a single mailbox.
Definition: mrmailbox.h:178
-
void mrmailbox_delete_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt)
Delete a list of messages.
Definition: mrmailbox.c:5081
+
char * m_dbfile
the database file in file.
Definition: mrmailbox.h:185
+
An object representing a single mailbox.
Definition: mrmailbox.h:182
+
void mrmailbox_delete_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt)
Delete a list of messages.
Definition: mrmailbox.c:5079
int mrmailbox_is_open(const mrmailbox_t *mailbox)
Check if a given mailbox database is open.
Definition: mrmailbox.c:1110
-
void mrmailbox_archive_chat(mrmailbox_t *mailbox, uint32_t chat_id, int archive)
Archive or unarchive a chat.
Definition: mrmailbox.c:2637
+
void mrmailbox_archive_chat(mrmailbox_t *mailbox, uint32_t chat_id, int archive)
Archive or unarchive a chat.
Definition: mrmailbox.c:2635
char * mrmailbox_get_info(mrmailbox_t *mailbox)
Get information about the mailbox.
Definition: mrmailbox.c:1278
-
int mrmailbox_add_contact_to_chat(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t contact_id)
Add a member to a group.
Definition: mrmailbox.c:3580
-
uint32_t mrmailbox_get_next_media(mrmailbox_t *mailbox, uint32_t curr_msg_id, int dir)
Returns all message IDs of the given types in a chat.
Definition: mrmailbox.c:1912
+
int mrmailbox_add_contact_to_chat(mrmailbox_t *mailbox, uint32_t chat_id, uint32_t contact_id)
Add a member to a group.
Definition: mrmailbox.c:3578
+
uint32_t mrmailbox_get_next_media(mrmailbox_t *mailbox, uint32_t curr_msg_id, int dir)
Returns all message IDs of the given types in a chat.
Definition: mrmailbox.c:1910
char * mrmailbox_get_version_str(void)
Find out the version of the Delta Chat core library.
Definition: mrmailbox.c:1476
void mrmailbox_disconnect(mrmailbox_t *mailbox)
Disonnect the mailbox from the server.
Definition: mrmailbox.c:1591
-
char * m_blobdir
full path of the blob directory in use.
Definition: mrmailbox.h:182
-
carray * mrmailbox_get_fresh_msgs(mrmailbox_t *mailbox)
Returns the message IDs of all fresh messages of any chat.
Definition: mrmailbox.c:2037
-
uint32_t mrmailbox_send_msg(mrmailbox_t *mailbox, uint32_t chat_id, mrmsg_t *msg)
save message in database and send it, the given message object is not unref&#39;d by the function but som...
Definition: mrmailbox.c:3127
+
char * m_blobdir
full path of the blob directory in use.
Definition: mrmailbox.h:186
+
carray * mrmailbox_get_fresh_msgs(mrmailbox_t *mailbox)
Returns the message IDs of all fresh messages of any chat.
Definition: mrmailbox.c:2035
+
uint32_t mrmailbox_send_msg(mrmailbox_t *mailbox, uint32_t chat_id, mrmsg_t *msg)
save message in database and send it, the given message object is not unref&#39;d by the function but som...
Definition: mrmailbox.c:3125
void mrmailbox_connect(mrmailbox_t *mailbox)
Connect to the mailbox using the configured settings.
Definition: mrmailbox.c:1564
-
int mrmailbox_get_total_msg_count(mrmailbox_t *mailbox, uint32_t chat_id)
Get the total number of messages in a chat.
Definition: mrmailbox.c:2573
-
carray * mrmailbox_get_chat_contacts(mrmailbox_t *mailbox, uint32_t chat_id)
Get contact IDs belonging to a chat.
Definition: mrmailbox.c:1988
+
int mrmailbox_get_total_msg_count(mrmailbox_t *mailbox, uint32_t chat_id)
Get the total number of messages in a chat.
Definition: mrmailbox.c:2571
+
carray * mrmailbox_get_chat_contacts(mrmailbox_t *mailbox, uint32_t chat_id)
Get contact IDs belonging to a chat.
Definition: mrmailbox.c:1986
void mrmailbox_unref(mrmailbox_t *mailbox)
Free a mailbox object.
Definition: mrmailbox.c:955
-
void mrmailbox_block_contact(mrmailbox_t *mailbox, uint32_t contact_id, int new_blocking)
Block or unblock a contact.
Definition: mrmailbox.c:4275
-
uintptr_t(* mrmailboxcb_t)(mrmailbox_t *, int event, uintptr_t data1, uintptr_t data2)
Callback function that should be given to mrmailbox_new().
Definition: mrmailbox.h:168
-
int mrmailbox_configure_and_connect(mrmailbox_t *mailbox)
Configure and connect a mailbox.
Definition: mrmailbox_configure.c:387
+
void mrmailbox_block_contact(mrmailbox_t *mailbox, uint32_t contact_id, int new_blocking)
Block or unblock a contact.
Definition: mrmailbox.c:4273
+
uintptr_t(* mrmailboxcb_t)(mrmailbox_t *, int event, uintptr_t data1, uintptr_t data2)
Callback function that should be given to mrmailbox_new().
Definition: mrmailbox.h:172
+
int mrmailbox_configure_and_connect(mrmailbox_t *mailbox)
Configure and connect a mailbox.
Definition: mrmailbox_configure.c:397
mrchatlist_t * mrmailbox_get_chatlist(mrmailbox_t *mailbox, int listflags, const char *query)
Get a list of chats.
Definition: mrmailbox.c:1648
An object representing a single message in memory.
Definition: mrmsg.h:40
-
uint32_t mrmailbox_get_chat_id_by_contact_id(mrmailbox_t *mailbox, uint32_t contact_id)
Check, if there is a normal chat with a given contact.
Definition: mrmailbox.c:1774
-
int mrmailbox_get_fresh_msg_count(mrmailbox_t *mailbox, uint32_t chat_id)
Get the number of fresh messages in a chat.
Definition: mrmailbox.c:2601
-
void mrmailbox_delete_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Delete a chat:
Definition: mrmailbox.c:2758
-
void mrmailbox_set_draft(mrmailbox_t *mailbox, uint32_t chat_id, const char *msg)
Save a draft for a chat.
Definition: mrmailbox.c:2356
-
int mrmailbox_get_blocked_count(mrmailbox_t *mailbox)
Get the number of blocked contacts.
Definition: mrmailbox.c:4159
-
int mrmailbox_set_chat_image(mrmailbox_t *mailbox, uint32_t chat_id, const char *new_image)
Set group image.
Definition: mrmailbox.c:3461
-
carray * mrmailbox_get_known_contacts(mrmailbox_t *mailbox, const char *query)
Returns known and unblocked contacts.
Definition: mrmailbox.c:4061
-
mrmsg_t * mrmailbox_get_msg(mrmailbox_t *mailbox, uint32_t msg_id)
Get a single message object of the type mrmsg_t.
Definition: mrmailbox.c:4686
-
void * m_userdata
the same pointer as given to mrmailbox_new(), may be used by the caller for any purpose ...
Definition: mrmailbox.h:180
-
int mrmailbox_is_configured(mrmailbox_t *mailbox)
Check if the mailbox is already configured.
Definition: mrmailbox_configure.c:738
-
carray * mrmailbox_get_chat_media(mrmailbox_t *mailbox, uint32_t chat_id, int msg_type, int or_msg_type)
Returns all message IDs of the given types in a chat.
Definition: mrmailbox.c:1881
-
uint32_t mrmailbox_create_chat_by_contact_id(mrmailbox_t *mailbox, uint32_t contact_id)
Create a normal chat with a single user.
Definition: mrmailbox.c:1801
-
void mrmailbox_forward_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt, uint32_t chat_id)
Forward a list of messages to another chat.
Definition: mrmailbox.c:4853
-
void mrmailbox_markseen_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt)
Mark a message as seen, updates the IMAP state and sends MDNs.
Definition: mrmailbox.c:5222
-
void mrmailbox_marknoticed_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Mark all message in a chat as noticed.
Definition: mrmailbox.c:1740
+
uint32_t mrmailbox_get_chat_id_by_contact_id(mrmailbox_t *mailbox, uint32_t contact_id)
Check, if there is a normal chat with a given contact.
Definition: mrmailbox.c:1772
+
int mrmailbox_get_fresh_msg_count(mrmailbox_t *mailbox, uint32_t chat_id)
Get the number of fresh messages in a chat.
Definition: mrmailbox.c:2599
+
void mrmailbox_delete_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Delete a chat:
Definition: mrmailbox.c:2756
+
void mrmailbox_set_draft(mrmailbox_t *mailbox, uint32_t chat_id, const char *msg)
Save a draft for a chat.
Definition: mrmailbox.c:2354
+
int mrmailbox_get_blocked_count(mrmailbox_t *mailbox)
Get the number of blocked contacts.
Definition: mrmailbox.c:4157
+
int mrmailbox_set_chat_image(mrmailbox_t *mailbox, uint32_t chat_id, const char *new_image)
Set group image.
Definition: mrmailbox.c:3459
+
carray * mrmailbox_get_known_contacts(mrmailbox_t *mailbox, const char *query)
Returns known and unblocked contacts.
Definition: mrmailbox.c:4059
+
mrmsg_t * mrmailbox_get_msg(mrmailbox_t *mailbox, uint32_t msg_id)
Get a single message object of the type mrmsg_t.
Definition: mrmailbox.c:4684
+
void * m_userdata
the same pointer as given to mrmailbox_new(), may be used by the caller for any purpose ...
Definition: mrmailbox.h:184
+
int mrmailbox_is_configured(mrmailbox_t *mailbox)
Check if the mailbox is already configured.
Definition: mrmailbox_configure.c:751
+
carray * mrmailbox_get_chat_media(mrmailbox_t *mailbox, uint32_t chat_id, int msg_type, int or_msg_type)
Returns all message IDs of the given types in a chat.
Definition: mrmailbox.c:1879
+
uint32_t mrmailbox_create_chat_by_contact_id(mrmailbox_t *mailbox, uint32_t contact_id)
Create a normal chat with a single user.
Definition: mrmailbox.c:1799
+
void mrmailbox_forward_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt, uint32_t chat_id)
Forward a list of messages to another chat.
Definition: mrmailbox.c:4851
+
void mrmailbox_markseen_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt)
Mark a message as seen, updates the IMAP state and sends MDNs.
Definition: mrmailbox.c:5220
+
void mrmailbox_marknoticed_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Mark all message in a chat as noticed.
Definition: mrmailbox.c:1738
char * mrmailbox_imex_has_backup(mrmailbox_t *mailbox, const char *dir_name)
Check if there is a backup file.
Definition: mrmailbox_imex.c:697
-
void mrmailbox_configure_cancel(mrmailbox_t *mailbox)
Signal the configure-process to stop.
Definition: mrmailbox_configure.c:710
-
carray * mrmailbox_get_blocked_contacts(mrmailbox_t *mailbox)
Get blocked contacts.
Definition: mrmailbox.c:4125
-
mrcontact_t * mrmailbox_get_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Get a single contact object.
Definition: mrmailbox.c:4201
+
void mrmailbox_configure_cancel(mrmailbox_t *mailbox)
Signal the configure-process to stop.
Definition: mrmailbox_configure.c:720
+
carray * mrmailbox_get_blocked_contacts(mrmailbox_t *mailbox)
Get blocked contacts.
Definition: mrmailbox.c:4123
+
mrcontact_t * mrmailbox_get_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Get a single contact object.
Definition: mrmailbox.c:4199
int mrmailbox_check_password(mrmailbox_t *mailbox, const char *test_pw)
Check if the user is authorized by the given password in some way.
Definition: mrmailbox_imex.c:1051
-
void mrmailbox_marknoticed_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Mark all messages send by the given contact as noticed.
Definition: mrmailbox.c:4249
+
void mrmailbox_marknoticed_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Mark all messages send by the given contact as noticed.
Definition: mrmailbox.c:4247
int mrmailbox_set_config_int(mrmailbox_t *ths, const char *key, int32_t value)
Configure the mailbox.
Definition: mrmailbox.c:1230
int32_t mrmailbox_get_config_int(mrmailbox_t *ths, const char *key, int32_t def)
Get a configuration option.
Definition: mrmailbox.c:1252
-
int mrmailbox_set_chat_name(mrmailbox_t *mailbox, uint32_t chat_id, const char *new_name)
Set group name.
Definition: mrmailbox.c:3384
+
int mrmailbox_set_chat_name(mrmailbox_t *mailbox, uint32_t chat_id, const char *new_name)
Set group name.
Definition: mrmailbox.c:3382
char * mrmailbox_create_setup_code(mrmailbox_t *mailbox)
Create random setup code.
Definition: mrmailbox_imex.c:1108
-
char * mrmailbox_get_contact_encrinfo(mrmailbox_t *mailbox, uint32_t contact_id)
Get encryption info.
Definition: mrmailbox.c:4366
+
char * mrmailbox_get_contact_encrinfo(mrmailbox_t *mailbox, uint32_t contact_id)
Get encryption info.
Definition: mrmailbox.c:4364
void mrmailbox_imex(mrmailbox_t *mailbox, int what, const char *param1, const char *setup_code)
Import/export things.
Definition: mrmailbox_imex.c:998
char * mrmailbox_get_config(mrmailbox_t *ths, const char *key, const char *def)
Get a configuration option.
Definition: mrmailbox.c:1208
-
char * mrmailbox_get_msg_info(mrmailbox_t *mailbox, uint32_t msg_id)
Get an informational text for a single message.
Definition: mrmailbox.c:4728
+
char * mrmailbox_get_msg_info(mrmailbox_t *mailbox, uint32_t msg_id)
Get an informational text for a single message.
Definition: mrmailbox.c:4726
An object representing a single chat in memory.
Definition: mrchat.h:39
diff --git a/docs/html/mrmimefactory_8h_source.html b/docs/html/mrmimefactory_8h_source.html index 847b2c96..632728a3 100644 --- a/docs/html/mrmimefactory_8h_source.html +++ b/docs/html/mrmimefactory_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrmimefactory.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 __MRMIMEFACTORY_H__
24 #define __MRMIMEFACTORY_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 
31 
32 typedef struct mrmsg_t mrmsg_t;
33 typedef struct mrchat_t mrchat_t;
34 typedef struct mrmailbox_t mrmailbox_t;
35 
36 
37 #define MR_SYSTEM_GROUPNAME_CHANGED 2
38 #define MR_SYSTEM_GROUPIMAGE_CHANGED 3
39 #define MR_SYSTEM_MEMBER_ADDED_TO_GROUP 4
40 #define MR_SYSTEM_MEMBER_REMOVED_FROM_GROUP 5
41 
42 
43 typedef enum {
44  MR_MF_NOTHING_LOADED = 0,
45  MR_MF_MSG_LOADED,
46  MR_MF_MDN_LOADED
47 } mrmimefactory_loaded_t;
48 
49 
53 typedef struct mrmimefactory_t {
54 
57  /* in: parameters, set eg. by mrmimefactory_load_msg() */
58  char* m_from_addr;
59  char* m_from_displayname;
60  char* m_selfstatus;
61  clist* m_recipients_names;
62  clist* m_recipients_addr;
63  time_t m_timestamp;
64  char* m_rfc724_mid;
65 
66  /* what is loaded? */
67  mrmimefactory_loaded_t m_loaded;
68 
69  mrmsg_t* m_msg;
70  mrchat_t* m_chat;
71  int m_increation;
72  char* m_predecessor;
73  char* m_references;
74  int m_req_mdn;
75 
76  /* out: after a successfull mrmimefactory_create_mime(), here's the data */
77  MMAPString* m_out;
78  int m_out_encrypted;
79 
80  /* private */
81  mrmailbox_t* m_mailbox;
82 
83 } mrmimefactory_t;
84 
85 
86 void mrmimefactory_init (mrmimefactory_t*, mrmailbox_t*);
87 void mrmimefactory_empty (mrmimefactory_t*);
88 int mrmimefactory_load_msg (mrmimefactory_t*, uint32_t msg_id);
89 int mrmimefactory_load_mdn (mrmimefactory_t*, uint32_t msg_id);
90 int mrmimefactory_render (mrmimefactory_t*, int encrypt_to_self);
91 
92 
93 #ifdef __cplusplus
94 } /* /extern "C" */
95 #endif
96 #endif /* __MRMIMEFACTORY_H__ */
97 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MRMIMEFACTORY_H__
24 #define __MRMIMEFACTORY_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 
31 
32 typedef struct mrmsg_t mrmsg_t;
33 typedef struct mrchat_t mrchat_t;
34 typedef struct mrmailbox_t mrmailbox_t;
35 
36 
37 #define MR_SYSTEM_GROUPNAME_CHANGED 2
38 #define MR_SYSTEM_GROUPIMAGE_CHANGED 3
39 #define MR_SYSTEM_MEMBER_ADDED_TO_GROUP 4
40 #define MR_SYSTEM_MEMBER_REMOVED_FROM_GROUP 5
41 
42 
43 typedef enum {
44  MR_MF_NOTHING_LOADED = 0,
45  MR_MF_MSG_LOADED,
46  MR_MF_MDN_LOADED
47 } mrmimefactory_loaded_t;
48 
49 
53 typedef struct mrmimefactory_t {
54 
57  /* in: parameters, set eg. by mrmimefactory_load_msg() */
58  char* m_from_addr;
59  char* m_from_displayname;
60  char* m_selfstatus;
61  clist* m_recipients_names;
62  clist* m_recipients_addr;
63  time_t m_timestamp;
64  char* m_rfc724_mid;
65 
66  /* what is loaded? */
67  mrmimefactory_loaded_t m_loaded;
68 
69  mrmsg_t* m_msg;
70  mrchat_t* m_chat;
71  int m_increation;
72  char* m_predecessor;
73  char* m_references;
74  int m_req_mdn;
75 
76  /* out: after a successfull mrmimefactory_create_mime(), here's the data */
77  MMAPString* m_out;
78  int m_out_encrypted;
79 
80  /* private */
81  mrmailbox_t* m_mailbox;
82 
83 } mrmimefactory_t;
84 
85 
86 void mrmimefactory_init (mrmimefactory_t*, mrmailbox_t*);
87 void mrmimefactory_empty (mrmimefactory_t*);
88 int mrmimefactory_load_msg (mrmimefactory_t*, uint32_t msg_id);
89 int mrmimefactory_load_mdn (mrmimefactory_t*, uint32_t msg_id);
90 int mrmimefactory_render (mrmimefactory_t*, int encrypt_to_self);
91 
92 
93 #ifdef __cplusplus
94 } /* /extern "C" */
95 #endif
96 #endif /* __MRMIMEFACTORY_H__ */
97 
An object representing a single mailbox.
Definition: mrmailbox.h:182
An object representing a single message in memory.
Definition: mrmsg.h:40
An object representing a single chat in memory.
Definition: mrchat.h:39
diff --git a/docs/html/mrmimeparser_8h_source.html b/docs/html/mrmimeparser_8h_source.html index 09fc0691..77440928 100644 --- a/docs/html/mrmimeparser_8h_source.html +++ b/docs/html/mrmimeparser_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrmimeparser.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 /* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322
24 mrmimeparser_t has no deep dependencies to mrmailbox_t or to the database
25 (mrmailbox_t is used for logging only). */
26 
27 
28 #ifndef __MRMIMEPARSER_H__
29 #define __MRMIMEPARSER_H__
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
38 typedef struct mrmimepart_t
39 {
41  int m_type; /*one of MR_MSG_* */
42  int m_is_meta; /*meta parts contain eg. profile or group images and are only present if there is at least one "normal" part*/
43  char* m_msg;
44  char* m_msg_raw;
45  int m_bytes;
46  mrparam_t* m_param;
47 } mrmimepart_t;
48 
49 
53 typedef struct mrmimeparser_t
54 {
57  /* data, read-only, must not be free()'d (it is free()'d when the MrMimeParser object gets destructed) */
58  carray* m_parts; /*array of mrmimepart_t objects*/
59  struct mailmime* m_mimeroot;
60  struct mailimf_fields* m_header; /* a pointer somewhere to the MIME data, must not be freed */
61  char* m_subject;
62  int m_is_send_by_messenger;
63  int m_decrypted_and_validated;
64  int m_decrypted_with_validation_errors;
65  int m_decrypting_failed; /* set, if there are multipart/encrypted parts left after decryption */
66  const char* m_blobdir;
67 
68  int m_is_forwarded;
69 
70  mrmailbox_t* m_mailbox;
71 
72  carray* m_reports; /* array of mailmime objects */
73 
74  int m_is_system_message;
75 
76 } mrmimeparser_t;
77 
78 
79 mrmimeparser_t* mrmimeparser_new (const char* blobdir, mrmailbox_t*);
80 void mrmimeparser_unref (mrmimeparser_t*);
81 void mrmimeparser_empty (mrmimeparser_t*);
82 
83 /* The data returned from Parse() must not be freed (it is free()'d when the MrMimeParser object gets destructed)
84 Unless memory-allocation-errors occur, Parse() returns at least one empty part.
85 (this is because we want to add even these message to our database to avoid reading them several times.
86 of course, these empty messages are not added to any chat) */
87 void mrmimeparser_parse (mrmimeparser_t*, const char* body_not_terminated, size_t body_bytes);
88 
89 /* mrmimeparser_get_last_nonmeta() gets the _last_ part _not_ flagged with m_is_meta. */
90 mrmimepart_t* mrmimeparser_get_last_nonmeta (mrmimeparser_t*);
91 #define mrmimeparser_has_nonmeta(a) (mrmimeparser_get_last_nonmeta((a))!=NULL)
92 
93 /* mrmimeparser_is_mailinglist_message() just checks if there is a `List-ID`-header. */
94 int mrmimeparser_is_mailinglist_message (mrmimeparser_t*);
95 
96 /* low-level-tools for working with mailmime structures directly */
97 char* mr_find_first_addr (const struct mailimf_mailbox_list*); /*the result must be freed*/
98 char* mr_normalize_addr (const char*); /*the result must be freed*/
99 struct mailimf_fields* mr_find_mailimf_fields(struct mailmime*); /*the result is a pointer to mime, must not be freed*/
100 struct mailimf_field* mr_find_mailimf_field (struct mailimf_fields*, int wanted_fld_type); /*the result is a pointer to mime, must not be freed*/
101 struct mailimf_optional_field* mr_find_mailimf_field2(struct mailimf_fields*, const char* wanted_fld_name);
102 struct mailmime_parameter* mr_find_ct_parameter (struct mailmime*, const char* name);
103 int mr_mime_transfer_decode(struct mailmime*, const char** ret_decoded_data, size_t* ret_decoded_data_bytes, char** ret_to_mmap_string_unref);
104 
105 
106 #ifdef MR_USE_MIME_DEBUG
107 void mr_print_mime(struct mailmime * mime);
108 #endif
109 
110 
111 #ifdef __cplusplus
112 } /* /extern "C" */
113 #endif
114 #endif /* __MRMIMEPARSER_H__ */
115 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 /* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322
24 mrmimeparser_t has no deep dependencies to mrmailbox_t or to the database
25 (mrmailbox_t is used for logging only). */
26 
27 
28 #ifndef __MRMIMEPARSER_H__
29 #define __MRMIMEPARSER_H__
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
38 typedef struct mrmimepart_t
39 {
41  int m_type; /*one of MR_MSG_* */
42  int m_is_meta; /*meta parts contain eg. profile or group images and are only present if there is at least one "normal" part*/
43  char* m_msg;
44  char* m_msg_raw;
45  int m_bytes;
46  mrparam_t* m_param;
47 } mrmimepart_t;
48 
49 
53 typedef struct mrmimeparser_t
54 {
57  /* data, read-only, must not be free()'d (it is free()'d when the MrMimeParser object gets destructed) */
58  carray* m_parts; /*array of mrmimepart_t objects*/
59  struct mailmime* m_mimeroot;
60  struct mailimf_fields* m_header; /* a pointer somewhere to the MIME data, must not be freed */
61  char* m_subject;
62  int m_is_send_by_messenger;
63  int m_decrypted_and_validated;
64  int m_decrypted_with_validation_errors;
65  int m_decrypting_failed; /* set, if there are multipart/encrypted parts left after decryption */
66  const char* m_blobdir;
67 
68  int m_is_forwarded;
69 
70  mrmailbox_t* m_mailbox;
71 
72  carray* m_reports; /* array of mailmime objects */
73 
74  int m_is_system_message;
75 
76 } mrmimeparser_t;
77 
78 
79 mrmimeparser_t* mrmimeparser_new (const char* blobdir, mrmailbox_t*);
80 void mrmimeparser_unref (mrmimeparser_t*);
81 void mrmimeparser_empty (mrmimeparser_t*);
82 
83 /* The data returned from Parse() must not be freed (it is free()'d when the MrMimeParser object gets destructed)
84 Unless memory-allocation-errors occur, Parse() returns at least one empty part.
85 (this is because we want to add even these message to our database to avoid reading them several times.
86 of course, these empty messages are not added to any chat) */
87 void mrmimeparser_parse (mrmimeparser_t*, const char* body_not_terminated, size_t body_bytes);
88 
89 /* mrmimeparser_get_last_nonmeta() gets the _last_ part _not_ flagged with m_is_meta. */
90 mrmimepart_t* mrmimeparser_get_last_nonmeta (mrmimeparser_t*);
91 #define mrmimeparser_has_nonmeta(a) (mrmimeparser_get_last_nonmeta((a))!=NULL)
92 
93 /* mrmimeparser_is_mailinglist_message() just checks if there is a `List-ID`-header. */
94 int mrmimeparser_is_mailinglist_message (mrmimeparser_t*);
95 
96 /* low-level-tools for working with mailmime structures directly */
97 char* mr_find_first_addr (const struct mailimf_mailbox_list*); /*the result must be freed*/
98 char* mr_normalize_addr (const char*); /*the result must be freed*/
99 struct mailimf_fields* mr_find_mailimf_fields(struct mailmime*); /*the result is a pointer to mime, must not be freed*/
100 struct mailimf_field* mr_find_mailimf_field (struct mailimf_fields*, int wanted_fld_type); /*the result is a pointer to mime, must not be freed*/
101 struct mailimf_optional_field* mr_find_mailimf_field2(struct mailimf_fields*, const char* wanted_fld_name);
102 struct mailmime_parameter* mr_find_ct_parameter (struct mailmime*, const char* name);
103 int mr_mime_transfer_decode(struct mailmime*, const char** ret_decoded_data, size_t* ret_decoded_data_bytes, char** ret_to_mmap_string_unref);
104 
105 
106 #ifdef MR_USE_MIME_DEBUG
107 void mr_print_mime(struct mailmime * mime);
108 #endif
109 
110 
111 #ifdef __cplusplus
112 } /* /extern "C" */
113 #endif
114 #endif /* __MRMIMEPARSER_H__ */
115 
An object representing a single mailbox.
Definition: mrmailbox.h:182
An object for handling key=value parameter lists.
Definition: mrparam.h:36
diff --git a/docs/html/mrmsg_8h_source.html b/docs/html/mrmsg_8h_source.html index 2ac2df8f..cb6ccc4b 100644 --- a/docs/html/mrmsg_8h_source.html +++ b/docs/html/mrmsg_8h_source.html @@ -90,7 +90,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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 __MRMSG_H__
24 #define __MRMSG_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrmailbox_t mrmailbox_t;
31 typedef struct mrparam_t mrparam_t;
32 typedef struct sqlite3_stmt sqlite3_stmt;
33 
34 
40 typedef struct mrmsg_t
41 {
52  uint32_t m_id;
53  #define MR_MSG_ID_MARKER1 1
54  #define MR_MSG_ID_DAYMARKER 9
55  #define MR_MSG_ID_LAST_SPECIAL 9
56 
57 
62  uint32_t m_from_id;
63 
64 
69  uint32_t m_to_id;
70 
71 
76  uint32_t m_chat_id;
77 
78 
82  time_t m_timestamp;
83 
84 
98  int m_type;
99  #define MR_MSG_UNDEFINED 0
100  #define MR_MSG_TEXT 10
101  #define MR_MSG_IMAGE 20
102  #define MR_MSG_GIF 21
103  #define MR_MSG_AUDIO 40
104  #define MR_MSG_VOICE 41
105  #define MR_MSG_VIDEO 50
106  #define MR_MSG_FILE 60
107 
108 
128  int m_state;
129  #define MR_STATE_UNDEFINED 0
130  #define MR_STATE_IN_FRESH 10
131  #define MR_STATE_IN_NOTICED 13
132  #define MR_STATE_IN_SEEN 16
133  #define MR_STATE_OUT_PENDING 20
134  #define MR_STATE_OUT_ERROR 24
135  #define MR_STATE_OUT_DELIVERED 26
136  #define MR_STATE_OUT_MDN_RCVD 28
137 
138  char* m_text;
140  int m_starred;
144  mrmailbox_t* m_mailbox;
145  char* m_rfc724_mid;
146  char* m_server_folder;
147  uint32_t m_server_uid;
148 } mrmsg_t;
149 
150 
151 mrmsg_t* mrmsg_new ();
152 void mrmsg_unref (mrmsg_t*);
153 void mrmsg_empty (mrmsg_t*);
155 char* mrmsg_get_summarytext (mrmsg_t*, int approx_characters);
157 char* mrmsg_get_fullpath (mrmsg_t*);
158 char* mrmsg_get_filename (mrmsg_t*);
160 int mrmsg_is_increation (mrmsg_t*);
162 void mrmsg_set_text (mrmsg_t*, const char* text);
163 
164 /* library-private */
165 #define MR_MSG_FIELDS " m.id,rfc724_mid,m.server_folder,m.server_uid,m.chat_id, m.from_id,m.to_id,m.timestamp, m.type,m.state,m.msgrmsg,m.txt, m.param,m.starred "
166 int mrmsg_set_from_stmt__ (mrmsg_t*, sqlite3_stmt* row, int row_offset); /* row order is MR_MSG_FIELDS */
167 int mrmsg_load_from_db__ (mrmsg_t*, mrmailbox_t*, uint32_t id);
168 int mrmsg_is_increation__ (const mrmsg_t*);
169 char* mrmsg_get_summarytext_by_raw (int type, const char* text, mrparam_t*, int approx_bytes); /* the returned value must be free()'d */
170 void mrmsg_save_param_to_disk__ (mrmsg_t*);
171 void mrmsg_guess_msgtype_from_suffix (const char* pathNfilename, int* ret_msgtype, char** ret_mime);
172 void mrmsg_get_authorNtitle_from_filename (const char* pathNfilename, char** ret_author, char** ret_title);
173 
174 #define MR_MSG_NEEDS_ATTACHMENT(a) ((a)==MR_MSG_IMAGE || (a)==MR_MSG_GIF || (a)==MR_MSG_AUDIO || (a)==MR_MSG_VOICE || (a)==MR_MSG_VIDEO || (a)==MR_MSG_FILE)
175 #define MR_MSG_MAKE_FILENAME_SEARCHABLE(a) ((a)==MR_MSG_AUDIO || (a)==MR_MSG_FILE || (a)==MR_MSG_VIDEO ) /* add filename.ext (without path) to m_text? this is needed for the fulltext search. The extension is useful to get all PDF, all MP3 etc. */
176 #define MR_MSG_MAKE_SUFFIX_SEARCHABLE(a) ((a)==MR_MSG_IMAGE || (a)==MR_MSG_GIF || (a)==MR_MSG_VOICE)
177 
178 #define APPROX_SUBJECT_CHARS 32 /* as we do not cut inside words, this results in about 32-42 characters.
179  Do not use too long subjects - we add a tag after the subject which gets truncated by the clients otherwise.
180  It should also be very clear, the subject is _not_ the whole message.
181  The value is also used for CC:-summaries */
182 
183 
184 #ifdef __cplusplus
185 } /* /extern "C" */
186 #endif
187 #endif /* __MRMSG_H__ */
int m_is_msgrmsg
Set to 1 if the message was sent by another messenger.
Definition: mrmsg.h:141
-
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
An object representing a single mailbox.
Definition: mrmailbox.h:182
int m_type
Type of the message.
Definition: mrmsg.h:98
char * mrmsg_get_summarytext(mrmsg_t *msg, int approx_characters)
Get a message summary as a single line of text.
Definition: mrmsg.c:340
uint32_t m_chat_id
Chat ID the message belongs to.
Definition: mrmsg.h:76
diff --git a/docs/html/mrosnative_8h_source.html b/docs/html/mrosnative_8h_source.html index fa109a7a..e248e0af 100644 --- a/docs/html/mrosnative_8h_source.html +++ b/docs/html/mrosnative_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrosnative.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 __MROSNATIVE_H__
24 #define __MROSNATIVE_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 
33 typedef struct mrmailbox_t mrmailbox_t;
34 
35 int mrosnative_setup_thread (mrmailbox_t*); /*returns true/false*/
36 void mrosnative_unsetup_thread (mrmailbox_t*);
37 
38 
39 #ifdef __cplusplus
40 } /* /extern "C" */
41 #endif
42 #endif /* __MROSNATIVE_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MROSNATIVE_H__
24 #define __MROSNATIVE_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 
33 typedef struct mrmailbox_t mrmailbox_t;
34 
35 int mrosnative_setup_thread (mrmailbox_t*); /*returns true/false*/
36 void mrosnative_unsetup_thread (mrmailbox_t*);
37 
38 
39 #ifdef __cplusplus
40 } /* /extern "C" */
41 #endif
42 #endif /* __MROSNATIVE_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
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 __MRPGP_H__
24 #define __MRPGP_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 typedef struct mrkey_t mrkey_t;
33 typedef struct mrkeyring_t mrkeyring_t;
34 
35 
36 /* validation errors */
37 #define MR_VALIDATE_NO_SIGNATURE 0x01
38 #define MR_VALIDATE_UNKNOWN_SIGNATURE 0x02
39 #define MR_VALIDATE_BAD_SIGNATURE 0x04
40 #define MR_VALIDATE_NOT_MUTUAL 0x08
41 
42 /* misc. */
43 void mrpgp_init (mrmailbox_t*);
44 void mrpgp_exit (mrmailbox_t*);
45 void mrpgp_rand_seed (mrmailbox_t*, const void* buf, size_t bytes);
46 
47 
48 /* public key encryption */
49 int mrpgp_create_keypair (mrmailbox_t*, const char* addr, mrkey_t* public_key, mrkey_t* private_key);
50 int mrpgp_is_valid_key (mrmailbox_t*, const mrkey_t*);
51 int mrpgp_calc_fingerprint (mrmailbox_t*, const mrkey_t*, uint8_t** fingerprint, size_t* fingerprint_bytes);
52 int mrpgp_split_key (mrmailbox_t*, const mrkey_t* private_in, mrkey_t* public_out);
53 
54 int mrpgp_pk_encrypt (mrmailbox_t*, const void* plain, size_t plain_bytes, const mrkeyring_t*, const mrkey_t* sign_key, int use_armor, void** ret_ctext, size_t* ret_ctext_bytes);
55 int mrpgp_pk_decrypt (mrmailbox_t*, const void* ctext, size_t ctext_bytes, const mrkeyring_t*, const mrkey_t* validate_key, int use_armor, void** plain, size_t* plain_bytes, int* ret_validation_errors);
56 
57 
58 #ifdef __cplusplus
59 } /* /extern "C" */
60 #endif
61 #endif /* __MRPGP_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MRPGP_H__
24 #define __MRPGP_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 typedef struct mrkey_t mrkey_t;
33 typedef struct mrkeyring_t mrkeyring_t;
34 
35 
36 /* validation errors */
37 #define MR_VALIDATE_NO_SIGNATURE 0x01
38 #define MR_VALIDATE_UNKNOWN_SIGNATURE 0x02
39 #define MR_VALIDATE_BAD_SIGNATURE 0x04
40 #define MR_VALIDATE_NOT_MUTUAL 0x08
41 
42 /* misc. */
43 void mrpgp_init (mrmailbox_t*);
44 void mrpgp_exit (mrmailbox_t*);
45 void mrpgp_rand_seed (mrmailbox_t*, const void* buf, size_t bytes);
46 
47 
48 /* public key encryption */
49 int mrpgp_create_keypair (mrmailbox_t*, const char* addr, mrkey_t* public_key, mrkey_t* private_key);
50 int mrpgp_is_valid_key (mrmailbox_t*, const mrkey_t*);
51 int mrpgp_calc_fingerprint (mrmailbox_t*, const mrkey_t*, uint8_t** fingerprint, size_t* fingerprint_bytes);
52 int mrpgp_split_key (mrmailbox_t*, const mrkey_t* private_in, mrkey_t* public_out);
53 
54 int mrpgp_pk_encrypt (mrmailbox_t*, const void* plain, size_t plain_bytes, const mrkeyring_t*, const mrkey_t* sign_key, int use_armor, void** ret_ctext, size_t* ret_ctext_bytes);
55 int mrpgp_pk_decrypt (mrmailbox_t*, const void* ctext, size_t ctext_bytes, const mrkeyring_t*, const mrkey_t* validate_key, int use_armor, void** plain, size_t* plain_bytes, int* ret_validation_errors);
56 
57 
58 #ifdef __cplusplus
59 } /* /extern "C" */
60 #endif
61 #endif /* __MRPGP_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
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 __MRSMTP_H__
24 #define __MRSMTP_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include "mrloginparam.h"
31 
32 
33 /*** library-private **********************************************************/
34 
35 typedef struct mrsmtp_t
36 {
37  mailsmtp* m_hEtpan;
38  char* m_from;
39  int m_esmtp;
40  pthread_mutex_t m_mutex;
41 
42  int m_log_connect_errors;
43  int m_log_usual_error;
44 
45  mrmailbox_t* m_mailbox; /* only for logging! */
46 } mrsmtp_t;
47 
48 mrsmtp_t* mrsmtp_new (mrmailbox_t*);
49 void mrsmtp_unref (mrsmtp_t*);
50 int mrsmtp_is_connected (const mrsmtp_t*);
51 int mrsmtp_connect (mrsmtp_t*, const mrloginparam_t*);
52 void mrsmtp_disconnect (mrsmtp_t*);
53 int mrsmtp_send_msg (mrsmtp_t*, const clist* recipients, const char* data, size_t data_bytes);
54 
55 
56 #ifdef __cplusplus
57 } /* /extern "C" */
58 #endif
59 #endif /* __MRPARAM_H__ */
60 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MRSMTP_H__
24 #define __MRSMTP_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include "mrloginparam.h"
31 
32 
33 /*** library-private **********************************************************/
34 
35 typedef struct mrsmtp_t
36 {
37  mailsmtp* m_hEtpan;
38  char* m_from;
39  int m_esmtp;
40  pthread_mutex_t m_mutex;
41 
42  int m_log_connect_errors;
43  int m_log_usual_error;
44 
45  mrmailbox_t* m_mailbox; /* only for logging! */
46 } mrsmtp_t;
47 
48 mrsmtp_t* mrsmtp_new (mrmailbox_t*);
49 void mrsmtp_unref (mrsmtp_t*);
50 int mrsmtp_is_connected (const mrsmtp_t*);
51 int mrsmtp_connect (mrsmtp_t*, const mrloginparam_t*);
52 void mrsmtp_disconnect (mrsmtp_t*);
53 int mrsmtp_send_msg (mrsmtp_t*, const clist* recipients, const char* data, size_t data_bytes);
54 
55 
56 #ifdef __cplusplus
57 } /* /extern "C" */
58 #endif
59 #endif /* __MRPARAM_H__ */
60 
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
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 __MRSQLITE3_H__
24 #define __MRSQLITE3_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 #include <sqlite3.h>
33 #include <libetpan/libetpan.h>
34 #include <pthread.h>
35 typedef struct mrmailbox_t mrmailbox_t;
36 
37 
38 /* predefined statements */
39 enum
40 {
41  BEGIN_transaction = 0 /* must be first */
42  ,ROLLBACK_transaction
43  ,COMMIT_transaction
44 
45  ,SELECT_v_FROM_config_k
46  ,INSERT_INTO_config_kv
47  ,UPDATE_config_vk
48  ,DELETE_FROM_config_k
49 
50  ,SELECT_COUNT_FROM_contacts
51  ,SELECT_naob_FROM_contacts_i
52  ,SELECT_inao_FROM_contacts_a
53  ,SELECT_id_FROM_contacts_WHERE_id
54  ,SELECT_na_FROM_chats_contacs_JOIN_contacts_WHERE_cc
55  ,SELECT_p_FROM_chats_contacs_JOIN_contacts_peerstates_WHERE_cc
56  ,SELECT_id_FROM_contacts_WHERE_chat_id
57  ,SELECT_id_FROM_contacts_ORDER_BY
58  ,SELECT_id_FROM_contacts_WHERE_query_ORDER_BY
59  ,SELECT_COUNT_FROM_contacts_WHERE_blocked
60  ,SELECT_id_FROM_contacts_WHERE_blocked
61  ,INSERT_INTO_contacts_neo
62  ,UPDATE_contacts_nao_WHERE_i
63  ,UPDATE_contacts_SET_origin_WHERE_id
64  ,UPDATE_contacts_SET_b_WHERE_i
65  ,DELETE_FROM_contacts_WHERE_id
66 
67  ,SELECT_COUNT_FROM_chats
68  ,SELECT_COUNT_FROM_chats_WHERE_archived
69  ,SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_archived
70  ,SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_unarchived
71  ,SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_query
72  ,SELECT_itndd_FROM_chats_WHERE_i
73  ,SELECT_id_FROM_chats_WHERE_id
74  ,SELECT_id_FROM_chats_WHERE_contact_id
75  ,SELECT_id_FROM_CHATS_WHERE_grpid
76  ,SELECT_timestamp_FROM_msgs_WHERE_timestamp
77  ,SELECT_it_FROM_msgs_JOIN_chats_WHERE_rfc724
78  ,SELECT_MAX_timestamp_FROM_msgs
79  ,SELECT_rfc724_FROM_msgs_ORDER_BY_timestamp_LIMIT_1
80  ,UPDATE_chats_SET_draft_WHERE_id
81  ,UPDATE_chats_SET_n_WHERE_c
82  ,UPDATE_chats_SET_blocked
83  ,UPDATE_chats_SET_unarchived
84 
85  ,SELECT_a_FROM_chats_contacts_WHERE_i
86  ,SELECT_COUNT_FROM_chats_contacts_WHERE_chat_id
87  ,SELECT_COUNT_FROM_chats_contacts_WHERE_contact_id
88  ,SELECT_c_FROM_chats_contacts_WHERE_c
89  ,SELECT_c_FROM_chats_contacts_WHERE_c_ORDER_BY
90  ,SELECT_void_FROM_chats_contacts_WHERE_chat_id_AND_contact_id
91  ,INSERT_INTO_chats_contacts
92 
93  ,SELECT_COUNT_FROM_msgs_WHERE_assigned
94  ,SELECT_COUNT_FROM_msgs_WHERE_unassigned
95  ,SELECT_COUNT_FROM_msgs_WHERE_state_AND_chat_id
96  ,SELECT_COUNT_FROM_msgs_WHERE_chat_id
97  ,SELECT_COUNT_FROM_msgs_WHERE_rfc724_mid
98  ,SELECT_COUNT_FROM_msgs_WHERE_ft
99  ,SELECT_COUNT_DISTINCT_f_FROM_msgs_WHERE_c
100  ,SELECT_i_FROM_msgs_WHERE_ctt
101  ,SELECT_id_FROM_msgs_WHERE_cm
102  ,SELECT_id_FROM_msgs_WHERE_mcm
103  ,SELECT_id_FROM_msgs_WHERE_fresh_AND_deaddrop
104  ,SELECT_txt_raw_FROM_msgs_WHERE_id
105  ,SELECT_ircftttstpb_FROM_msg_WHERE_i
106  ,SELECT_ss_FROM_msgs_WHERE_m
107  ,SELECT_i_FROM_msgs_LEFT_JOIN_contacts_WHERE_c
108  ,SELECT_i_FROM_msgs_LEFT_JOIN_contacts_WHERE_starred
109  ,SELECT_i_FROM_msgs_LEFT_JOIN_contacts_WHERE_fresh
110  ,SELECT_i_FROM_msgs_WHERE_query
111  ,SELECT_i_FROM_msgs_WHERE_chat_id_AND_query
112  ,INSERT_INTO_msgs_msscftttsmttpb
113  ,INSERT_INTO_msgs_mcftttstpb
114  ,UPDATE_msgs_SET_chat_id_WHERE_id
115  ,UPDATE_msgs_SET_state_WHERE_id
116  ,UPDATE_msgs_SET_seen_WHERE_id_AND_chat_id_AND_freshORnoticed
117  ,UPDATE_msgs_SET_noticed_WHERE_id_AND_fresh
118  ,UPDATE_msgs_SET_state_WHERE_chat_id_AND_state
119  ,UPDATE_msgs_SET_state_WHERE_from_id_AND_state
120  ,UPDATE_msgs_SET_ss_WHERE_rfc724_mid
121  ,UPDATE_msgs_SET_param_WHERE_id
122  ,UPDATE_msgs_SET_starred_WHERE_id
123  ,DELETE_FROM_msgs_WHERE_id
124  ,DELETE_FROM_msgs_WHERE_rfc724_mid
125 
126  ,SELECT_c_FROM_msgs_mdns_WHERE_mc
127  ,INSERT_INTO_msgs_mdns
128  ,SELECT_COUNT_FROM_msgs_mdns_WHERE_m
129  ,DELETE_FROM_msgs_mdns_WHERE_m
130 
131  ,INSERT_INTO_jobs_aafp
132  ,SELECT_MIN_d_FROM_jobs
133  ,SELECT_iafp_FROM_jobs
134  ,DELETE_FROM_jobs_WHERE_id
135  ,DELETE_FROM_jobs_WHERE_action
136  ,UPDATE_jobs_SET_dp_WHERE_id
137 
138  ,SELECT_FROM_leftgrps_WHERE_grpid
139 
140  ,INSERT_INTO_acpeerstates_a
141  ,SELECT_aclpp_FROM_acpeerstates_WHERE_a
142  ,UPDATE_acpeerstates_SET_l_WHERE_a
143  ,UPDATE_acpeerstates_SET_lcpp_WHERE_a
144 
145  ,INSERT_INTO_keypairs_aippc
146  ,SELECT_private_key_FROM_keypairs_WHERE_default
147  ,SELECT_private_key_FROM_keypairs_ORDER_BY_default
148  ,SELECT_public_key_FROM_keypairs_WHERE_default
149 
150  ,PREDEFINED_CNT /* must be last */
151 };
152 
153 
162 typedef struct mrsqlite3_t
163 {
165  sqlite3_stmt* m_pd[PREDEFINED_CNT];
166  sqlite3* m_cobj;
167  int m_transactionCount;
168  mrmailbox_t* m_mailbox;
169  pthread_mutex_t m_critical_;
171 } mrsqlite3_t;
172 
173 
174 mrsqlite3_t* mrsqlite3_new (mrmailbox_t*);
175 void mrsqlite3_unref (mrsqlite3_t*);
176 
177 #define MR_OPEN_READONLY 0x01
178 int mrsqlite3_open__ (mrsqlite3_t*, const char* dbfile, int flags);
179 
180 void mrsqlite3_close__ (mrsqlite3_t*);
181 int mrsqlite3_is_open (const mrsqlite3_t*);
182 
183 /* handle configurations, private */
184 int mrsqlite3_set_config__ (mrsqlite3_t*, const char* key, const char* value);
185 int mrsqlite3_set_config_int__ (mrsqlite3_t*, const char* key, int32_t value);
186 char* mrsqlite3_get_config__ (mrsqlite3_t*, const char* key, const char* def); /* the returned string must be free()'d, returns NULL on errors */
187 int32_t mrsqlite3_get_config_int__ (mrsqlite3_t*, const char* key, int32_t def);
188 
189 /* tools, these functions are compatible to the corresponding sqlite3_* functions */
190 sqlite3_stmt* mrsqlite3_predefine__ (mrsqlite3_t*, size_t idx, const char* sql); /*the result is resetted as needed and must not be freed. CAVE: you must not call this function with different strings for the same index!*/
191 sqlite3_stmt* mrsqlite3_prepare_v2_ (mrsqlite3_t*, const char* sql); /* the result mus be freed using sqlite3_finalize() */
192 int mrsqlite3_execute__ (mrsqlite3_t*, const char* sql);
193 int mrsqlite3_table_exists__ (mrsqlite3_t*, const char* name);
194 void mrsqlite3_log_error (mrsqlite3_t*, const char* msg, ...);
195 
196 /* reset all predefined statements, this is needed only in very rare cases, eg. when dropping a table and there are pending statements */
197 void mrsqlite3_reset_all_predefinitions(mrsqlite3_t*);
198 
199 /* tools for locking, may be called nested, see also m_critical_ above.
200 the user of MrSqlite3 must make sure that the MrSqlite3-object is only used by one thread at the same time.
201 In general, we will lock the hightest level as possible - this avoids deadlocks and massive on/off lockings.
202 Low-level-functions, eg. the MrSqlite3-methods, do not lock. */
203 void mrsqlite3_lock (mrsqlite3_t*); /* lock or wait; these calls must not be nested in a single thread */
204 void mrsqlite3_unlock (mrsqlite3_t*);
205 
206 /* nestable transactions, only the outest is really used */
207 void mrsqlite3_begin_transaction__(mrsqlite3_t*);
208 void mrsqlite3_commit__ (mrsqlite3_t*);
209 void mrsqlite3_rollback__ (mrsqlite3_t*);
210 
211 #ifdef __cplusplus
212 } /* /extern "C" */
213 #endif
214 #endif /* __MRSQLITE3_H__ */
215 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MRSQLITE3_H__
24 #define __MRSQLITE3_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 #include <sqlite3.h>
33 #include <libetpan/libetpan.h>
34 #include <pthread.h>
35 typedef struct mrmailbox_t mrmailbox_t;
36 
37 
38 /* predefined statements */
39 enum
40 {
41  BEGIN_transaction = 0 /* must be first */
42  ,ROLLBACK_transaction
43  ,COMMIT_transaction
44 
45  ,SELECT_v_FROM_config_k
46  ,INSERT_INTO_config_kv
47  ,UPDATE_config_vk
48  ,DELETE_FROM_config_k
49 
50  ,SELECT_COUNT_FROM_contacts
51  ,SELECT_naob_FROM_contacts_i
52  ,SELECT_inao_FROM_contacts_a
53  ,SELECT_id_FROM_contacts_WHERE_id
54  ,SELECT_na_FROM_chats_contacs_JOIN_contacts_WHERE_cc
55  ,SELECT_p_FROM_chats_contacs_JOIN_contacts_peerstates_WHERE_cc
56  ,SELECT_id_FROM_contacts_WHERE_chat_id
57  ,SELECT_id_FROM_contacts_ORDER_BY
58  ,SELECT_id_FROM_contacts_WHERE_query_ORDER_BY
59  ,SELECT_COUNT_FROM_contacts_WHERE_blocked
60  ,SELECT_id_FROM_contacts_WHERE_blocked
61  ,INSERT_INTO_contacts_neo
62  ,UPDATE_contacts_nao_WHERE_i
63  ,UPDATE_contacts_SET_origin_WHERE_id
64  ,UPDATE_contacts_SET_b_WHERE_i
65  ,DELETE_FROM_contacts_WHERE_id
66 
67  ,SELECT_COUNT_FROM_chats
68  ,SELECT_COUNT_FROM_chats_WHERE_archived
69  ,SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_archived
70  ,SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_unarchived
71  ,SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_query
72  ,SELECT_itndd_FROM_chats_WHERE_i
73  ,SELECT_id_FROM_chats_WHERE_id
74  ,SELECT_id_FROM_chats_WHERE_contact_id
75  ,SELECT_id_FROM_CHATS_WHERE_grpid
76  ,SELECT_timestamp_FROM_msgs_WHERE_timestamp
77  ,SELECT_it_FROM_msgs_JOIN_chats_WHERE_rfc724
78  ,SELECT_MAX_timestamp_FROM_msgs
79  ,SELECT_rfc724_FROM_msgs_ORDER_BY_timestamp_LIMIT_1
80  ,UPDATE_chats_SET_draft_WHERE_id
81  ,UPDATE_chats_SET_n_WHERE_c
82  ,UPDATE_chats_SET_blocked
83  ,UPDATE_chats_SET_unarchived
84 
85  ,SELECT_a_FROM_chats_contacts_WHERE_i
86  ,SELECT_COUNT_FROM_chats_contacts_WHERE_chat_id
87  ,SELECT_COUNT_FROM_chats_contacts_WHERE_contact_id
88  ,SELECT_c_FROM_chats_contacts_WHERE_c
89  ,SELECT_c_FROM_chats_contacts_WHERE_c_ORDER_BY
90  ,SELECT_void_FROM_chats_contacts_WHERE_chat_id_AND_contact_id
91  ,INSERT_INTO_chats_contacts
92 
93  ,SELECT_COUNT_FROM_msgs_WHERE_assigned
94  ,SELECT_COUNT_FROM_msgs_WHERE_unassigned
95  ,SELECT_COUNT_FROM_msgs_WHERE_state_AND_chat_id
96  ,SELECT_COUNT_FROM_msgs_WHERE_chat_id
97  ,SELECT_COUNT_FROM_msgs_WHERE_rfc724_mid
98  ,SELECT_COUNT_FROM_msgs_WHERE_ft
99  ,SELECT_COUNT_DISTINCT_f_FROM_msgs_WHERE_c
100  ,SELECT_i_FROM_msgs_WHERE_ctt
101  ,SELECT_id_FROM_msgs_WHERE_cm
102  ,SELECT_id_FROM_msgs_WHERE_mcm
103  ,SELECT_id_FROM_msgs_WHERE_fresh_AND_deaddrop
104  ,SELECT_txt_raw_FROM_msgs_WHERE_id
105  ,SELECT_ircftttstpb_FROM_msg_WHERE_i
106  ,SELECT_ss_FROM_msgs_WHERE_m
107  ,SELECT_i_FROM_msgs_LEFT_JOIN_contacts_WHERE_c
108  ,SELECT_i_FROM_msgs_LEFT_JOIN_contacts_WHERE_starred
109  ,SELECT_i_FROM_msgs_LEFT_JOIN_contacts_WHERE_fresh
110  ,SELECT_i_FROM_msgs_WHERE_query
111  ,SELECT_i_FROM_msgs_WHERE_chat_id_AND_query
112  ,INSERT_INTO_msgs_msscftttsmttpb
113  ,INSERT_INTO_msgs_mcftttstpb
114  ,UPDATE_msgs_SET_chat_id_WHERE_id
115  ,UPDATE_msgs_SET_state_WHERE_id
116  ,UPDATE_msgs_SET_seen_WHERE_id_AND_chat_id_AND_freshORnoticed
117  ,UPDATE_msgs_SET_noticed_WHERE_id_AND_fresh
118  ,UPDATE_msgs_SET_state_WHERE_chat_id_AND_state
119  ,UPDATE_msgs_SET_state_WHERE_from_id_AND_state
120  ,UPDATE_msgs_SET_ss_WHERE_rfc724_mid
121  ,UPDATE_msgs_SET_param_WHERE_id
122  ,UPDATE_msgs_SET_starred_WHERE_id
123  ,DELETE_FROM_msgs_WHERE_id
124  ,DELETE_FROM_msgs_WHERE_rfc724_mid
125 
126  ,SELECT_c_FROM_msgs_mdns_WHERE_mc
127  ,INSERT_INTO_msgs_mdns
128  ,SELECT_COUNT_FROM_msgs_mdns_WHERE_m
129  ,DELETE_FROM_msgs_mdns_WHERE_m
130 
131  ,INSERT_INTO_jobs_aafp
132  ,SELECT_MIN_d_FROM_jobs
133  ,SELECT_iafp_FROM_jobs
134  ,DELETE_FROM_jobs_WHERE_id
135  ,DELETE_FROM_jobs_WHERE_action
136  ,UPDATE_jobs_SET_dp_WHERE_id
137 
138  ,SELECT_FROM_leftgrps_WHERE_grpid
139 
140  ,INSERT_INTO_acpeerstates_a
141  ,SELECT_aclpp_FROM_acpeerstates_WHERE_a
142  ,UPDATE_acpeerstates_SET_l_WHERE_a
143  ,UPDATE_acpeerstates_SET_lcpp_WHERE_a
144 
145  ,INSERT_INTO_keypairs_aippc
146  ,SELECT_private_key_FROM_keypairs_WHERE_default
147  ,SELECT_private_key_FROM_keypairs_ORDER_BY_default
148  ,SELECT_public_key_FROM_keypairs_WHERE_default
149 
150  ,PREDEFINED_CNT /* must be last */
151 };
152 
153 
162 typedef struct mrsqlite3_t
163 {
165  sqlite3_stmt* m_pd[PREDEFINED_CNT];
166  sqlite3* m_cobj;
167  int m_transactionCount;
168  mrmailbox_t* m_mailbox;
169  pthread_mutex_t m_critical_;
171 } mrsqlite3_t;
172 
173 
174 mrsqlite3_t* mrsqlite3_new (mrmailbox_t*);
175 void mrsqlite3_unref (mrsqlite3_t*);
176 
177 #define MR_OPEN_READONLY 0x01
178 int mrsqlite3_open__ (mrsqlite3_t*, const char* dbfile, int flags);
179 
180 void mrsqlite3_close__ (mrsqlite3_t*);
181 int mrsqlite3_is_open (const mrsqlite3_t*);
182 
183 /* handle configurations, private */
184 int mrsqlite3_set_config__ (mrsqlite3_t*, const char* key, const char* value);
185 int mrsqlite3_set_config_int__ (mrsqlite3_t*, const char* key, int32_t value);
186 char* mrsqlite3_get_config__ (mrsqlite3_t*, const char* key, const char* def); /* the returned string must be free()'d, returns NULL on errors */
187 int32_t mrsqlite3_get_config_int__ (mrsqlite3_t*, const char* key, int32_t def);
188 
189 /* tools, these functions are compatible to the corresponding sqlite3_* functions */
190 sqlite3_stmt* mrsqlite3_predefine__ (mrsqlite3_t*, size_t idx, const char* sql); /*the result is resetted as needed and must not be freed. CAVE: you must not call this function with different strings for the same index!*/
191 sqlite3_stmt* mrsqlite3_prepare_v2_ (mrsqlite3_t*, const char* sql); /* the result mus be freed using sqlite3_finalize() */
192 int mrsqlite3_execute__ (mrsqlite3_t*, const char* sql);
193 int mrsqlite3_table_exists__ (mrsqlite3_t*, const char* name);
194 void mrsqlite3_log_error (mrsqlite3_t*, const char* msg, ...);
195 
196 /* reset all predefined statements, this is needed only in very rare cases, eg. when dropping a table and there are pending statements */
197 void mrsqlite3_reset_all_predefinitions(mrsqlite3_t*);
198 
199 /* tools for locking, may be called nested, see also m_critical_ above.
200 the user of MrSqlite3 must make sure that the MrSqlite3-object is only used by one thread at the same time.
201 In general, we will lock the hightest level as possible - this avoids deadlocks and massive on/off lockings.
202 Low-level-functions, eg. the MrSqlite3-methods, do not lock. */
203 void mrsqlite3_lock (mrsqlite3_t*); /* lock or wait; these calls must not be nested in a single thread */
204 void mrsqlite3_unlock (mrsqlite3_t*);
205 
206 /* nestable transactions, only the outest is really used */
207 void mrsqlite3_begin_transaction__(mrsqlite3_t*);
208 void mrsqlite3_commit__ (mrsqlite3_t*);
209 void mrsqlite3_rollback__ (mrsqlite3_t*);
210 
211 #ifdef __cplusplus
212 } /* /extern "C" */
213 #endif
214 #endif /* __MRSQLITE3_H__ */
215 
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
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 __MRSTOCK_H__
24 #define __MRSTOCK_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include "mrmailbox.h"
31 #include <stdlib.h>
32 #include <string.h>
33 
34 
35 /* Strings requested by MR_EVENT_GET_STRING and MR_EVENT_GET_QUANTITY_STRING */
36 #define MR_STR_FREE_ 0
37 #define MR_STR_NOMESSAGES 1
38 #define MR_STR_SELF 2
39 #define MR_STR_DRAFT 3
40 #define MR_STR_MEMBER 4
41 #define MR_STR_CONTACT 6
42 #define MR_STR_VOICEMESSAGE 7
43 #define MR_STR_DEADDROP 8
44 #define MR_STR_IMAGE 9
45 #define MR_STR_VIDEO 10
46 #define MR_STR_AUDIO 11
47 #define MR_STR_FILE 12
48 #define MR_STR_STATUSLINE 13
49 #define MR_STR_NEWGROUPDRAFT 14
50 #define MR_STR_MSGGRPNAME 15
51 #define MR_STR_MSGGRPIMGCHANGED 16
52 #define MR_STR_MSGADDMEMBER 17
53 #define MR_STR_MSGDELMEMBER 18
54 #define MR_STR_MSGGROUPLEFT 19
55 #define MR_STR_ERROR 20
56 #define MR_STR_SELFNOTINGRP 21
57 #define MR_STR_NONETWORK 22
58 #define MR_STR_GIF 23
59 #define MR_STR_ENCRYPTEDMSG 24
60 #define MR_STR_ENCR_E2E 25
61 #define MR_STR_ENCR_TRANSP 27
62 #define MR_STR_ENCR_NONE 28
63 #define MR_STR_FINGERPRINTS 30
64 #define MR_STR_READRCPT 31
65 #define MR_STR_READRCPT_MAILBODY 32
66 #define MR_STR_MSGGRPIMGDELETED 33
67 #define MR_STR_E2E_FINE 34
68 #define MR_STR_E2E_NO_AUTOCRYPT 35
69 #define MR_STR_E2E_DIS_BY_YOU 36
70 #define MR_STR_E2E_DIS_BY_RCPT 37
71 #define MR_STR_ARCHIVEDCHATS 40
72 #define MR_STR_STARREDMSGS 41
73 
74 
75 /* should be set up by mrmailbox_new() */
76 extern mrmailbox_t* s_localize_mb_obj;
77 
78 
79 /* Return the string with the given ID by calling MR_EVENT_GET_STRING.
80 The result must be free()'d! */
81 char* mrstock_str (int id);
82 
83 
84 /* Replaces the first `%1$s` in the given String-ID by the given value.
85 The result must be free()'d! */
86 char* mrstock_str_repl_string (int id, const char* value);
87 char* mrstock_str_repl_int (int id, int value);
88 
89 
90 /* Replaces the first `%1$s` and `%2$s` in the given String-ID by the two given strings.
91 The result must be free()'d! */
92 char* mrstock_str_repl_string2 (int id, const char*, const char*);
93 
94 
95 /* Return a string with a correct plural form by callint MR_EVENT_GET_QUANTITY_STRING.
96 The result must be free()'d! */
97 char* mrstock_str_repl_pl (int id, int cnt);
98 
99 
100 #ifdef __cplusplus
101 } /* /extern "C" */
102 #endif
103 #endif /* __MRSTOCK_H__ */
104 
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 __MRSTOCK_H__
24 #define __MRSTOCK_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include "mrmailbox.h"
31 #include <stdlib.h>
32 #include <string.h>
33 
34 
35 /* Strings requested by MR_EVENT_GET_STRING and MR_EVENT_GET_QUANTITY_STRING */
36 #define MR_STR_FREE_ 0
37 #define MR_STR_NOMESSAGES 1
38 #define MR_STR_SELF 2
39 #define MR_STR_DRAFT 3
40 #define MR_STR_MEMBER 4
41 #define MR_STR_CONTACT 6
42 #define MR_STR_VOICEMESSAGE 7
43 #define MR_STR_DEADDROP 8
44 #define MR_STR_IMAGE 9
45 #define MR_STR_VIDEO 10
46 #define MR_STR_AUDIO 11
47 #define MR_STR_FILE 12
48 #define MR_STR_STATUSLINE 13
49 #define MR_STR_NEWGROUPDRAFT 14
50 #define MR_STR_MSGGRPNAME 15
51 #define MR_STR_MSGGRPIMGCHANGED 16
52 #define MR_STR_MSGADDMEMBER 17
53 #define MR_STR_MSGDELMEMBER 18
54 #define MR_STR_MSGGROUPLEFT 19
55 #define MR_STR_ERROR 20
56 #define MR_STR_SELFNOTINGRP 21
57 #define MR_STR_NONETWORK 22
58 #define MR_STR_GIF 23
59 #define MR_STR_ENCRYPTEDMSG 24
60 #define MR_STR_ENCR_E2E 25
61 #define MR_STR_ENCR_TRANSP 27
62 #define MR_STR_ENCR_NONE 28
63 #define MR_STR_FINGERPRINTS 30
64 #define MR_STR_READRCPT 31
65 #define MR_STR_READRCPT_MAILBODY 32
66 #define MR_STR_MSGGRPIMGDELETED 33
67 #define MR_STR_E2E_FINE 34
68 #define MR_STR_E2E_NO_AUTOCRYPT 35
69 #define MR_STR_E2E_DIS_BY_YOU 36
70 #define MR_STR_E2E_DIS_BY_RCPT 37
71 #define MR_STR_ARCHIVEDCHATS 40
72 #define MR_STR_STARREDMSGS 41
73 
74 
75 /* should be set up by mrmailbox_new() */
76 extern mrmailbox_t* s_localize_mb_obj;
77 
78 
79 /* Return the string with the given ID by calling MR_EVENT_GET_STRING.
80 The result must be free()'d! */
81 char* mrstock_str (int id);
82 
83 
84 /* Replaces the first `%1$s` in the given String-ID by the given value.
85 The result must be free()'d! */
86 char* mrstock_str_repl_string (int id, const char* value);
87 char* mrstock_str_repl_int (int id, int value);
88 
89 
90 /* Replaces the first `%1$s` and `%2$s` in the given String-ID by the two given strings.
91 The result must be free()'d! */
92 char* mrstock_str_repl_string2 (int id, const char*, const char*);
93 
94 
95 /* Return a string with a correct plural form by callint MR_EVENT_GET_QUANTITY_STRING.
96 The result must be free()'d! */
97 char* mrstock_str_repl_pl (int id, int cnt);
98 
99 
100 #ifdef __cplusplus
101 } /* /extern "C" */
102 #endif
103 #endif /* __MRSTOCK_H__ */
104 
An object representing a single mailbox.
Definition: mrmailbox.h:182
-
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 /* Some tools and enhancements to the used libraries, there should be
24 no references to mrmailbox_t and other "larger" classes here. */
25 
26 
27 #ifndef __MRTOOLS_H__
28 #define __MRTOOLS_H__
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 
34 /*** library-private **********************************************************/
35 
36 /* match tools */
37 int mr_exactly_one_bit_set (int v);
38 
39 /* string tools */
40 char* safe_strdup (const char*); /* safe_strdup() returns empty string if NULL is given, never returns NULL (exists on errors) */
41 char* strdup_keep_null (const char*); /* strdup(NULL) is undefined, safe_strdup_keep_null(NULL) returns NULL in this case */
42 int atoi_null_is_0 (const char*);
43 void mr_ltrim (char*);
44 void mr_rtrim (char*);
45 void mr_trim (char*);
46 char* mr_strlower (const char*); /* the result must be free()'d */
47 void mr_strlower_in_place (char*);
48 int mr_str_replace (char** haystack, const char* needle, const char* replacement); /* haystack may be realloc()'d, returns the number of replacements */
49 char* mr_null_terminate (const char*, int bytes); /* the result must be free()'d */
50 char* mr_mprintf (const char* format, ...); /* The result must be free()'d. */
51 void mr_remove_cr_chars (char*); /* remove all \r characters from string */
52 void mr_replace_bad_utf8_chars (char*); /* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */
53 void mr_truncate_n_unwrap_str (char*, int approx_characters, int do_unwrap);
54 carray* mr_split_into_lines (const char* buf_terminated); /* split string into lines*/
55 void mr_free_splitted_lines (carray* lines);
56 char* mr_insert_breaks (const char*, int break_every, const char* break_chars); /* insert a break every n characters, the return must be free()'d */
57 char* mr_arr_to_string (const uint32_t*, int cnt);
58 char* mr_decode_header_string (const char*); /* the result must be free()'d */
59 char* mr_encode_header_string (const char*); /* the result must be free()'d */
60 char* imap_modified_utf7_to_utf8 (const char *mbox, int change_spaces);
61 char* imap_utf8_to_modified_utf7 (const char *src, int change_spaces);
62 char* mr_url_encode (const char*); /* the result must be free()'d */
63 char* encode_base64 (const char * in, int len); /* prototype, from libetpan/src/data-types/base64.h which cannot be included without adding libetpan/src/... to the include-search-paths, which would result in double-file-name-errors */
64 
65 /* string builder */
66 typedef struct mrstrbuilder_t
67 {
68  char* m_buf;
69  int m_allocated;
70  int m_free;
71  char* m_eos;
72 } mrstrbuilder_t;
73 void mrstrbuilder_init (mrstrbuilder_t* ths);
74 char* mrstrbuilder_cat (mrstrbuilder_t* ths, const char* text);
75 void mrstrbuilder_empty(mrstrbuilder_t* ths); /* set the string to a lenght of 0, does not free the buffer */
76 
77 
78 /* carray/clist tools */
79 int carray_search (carray*, void* needle, unsigned int* indx); /* returns 1/0 and the index if `indx` is not NULL */
80 void clist_free_content (const clist*); /* calls free() for each item content */
81 int clist_search_string_nocase (const clist*, const char* str);
82 
83 /* date/time tools */
84 #define MR_INVALID_TIMESTAMP (-1)
85 time_t mr_timestamp_from_date (struct mailimf_date_time * date_time); /* the result is UTC or MR_INVALID_TIMESTAMP */
86 char* mr_timestamp_to_str (time_t); /* the return value must be free()'d */
87 struct mailimap_date_time* mr_timestamp_to_mailimap_date_time (time_t);
88 long mr_gm2local_offset (void);
89 
90 /* timesmearing */
91 time_t mr_smeared_time__ (void);
92 time_t mr_create_smeared_timestamp__ (void);
93 time_t mr_create_smeared_timestamps__(int count);
94 
95 /* Message-ID tools */
96 #define MR_VALID_ID_LEN 11
97 char* mr_create_id (void);
98 char* mr_create_dummy_references_mid (void);
99 char* mr_create_incoming_rfc724_mid (time_t message_timestamp, uint32_t contact_id_from, carray* contact_ids_to);
100 char* mr_create_outgoing_rfc724_mid (const char* grpid, const char* addr);
101 char* mr_extract_grpid_from_rfc724_mid (const char* rfc724_mid);
102 char* mr_extract_grpid_from_rfc724_mid_list(const clist* rfc724_mid_list);
103 
104 
105 /* file tools */
106 int mr_file_exist (const char* pathNfilename);
107 size_t mr_get_filebytes (const char* pathNfilename);
108 char* mr_get_filename (const char* pathNfilename); /* the return value must be free()'d */
109 int mr_delete_file (const char* pathNFilename, mrmailbox_t* log);
110 int mr_copy_file (const char* src_pathNFilename, const char* dest_pathNFilename, mrmailbox_t* log);
111 int mr_create_folder (const char* pathNfilename, mrmailbox_t* log);
112 int mr_write_file (const char* pathNfilename, const void* buf, size_t buf_bytes, mrmailbox_t* log);
113 int mr_read_file (const char* pathNfilename, void** buf, size_t* buf_bytes, mrmailbox_t* log);
114 char* mr_get_filesuffix_lc (const char* pathNfilename); /* the returned suffix is lower-case */
115 void mr_split_filename (const char* pathNfilename, char** ret_basename, char** ret_all_suffixes_incl_dot); /* the case of the suffix is preserved! */
116 int mr_get_filemeta (const void* buf, size_t buf_bytes, uint32_t* ret_width, uint32_t *ret_height);
117 char* mr_get_fine_pathNfilename (const char* folder, const char* desired_name);
118 
119 /* macros */
120 #define MR_QUOTEHELPER(name) #name
121 #define MR_STRINGIFY(macro) MR_QUOTEHELPER(macro)
122 #define MR_MIN(X, Y) (((X) < (Y))? (X) : (Y))
123 #define MR_MAX(X, Y) (((X) > (Y))? (X) : (Y))
124 
125 
126 #ifdef __cplusplus
127 } /* /extern "C" */
128 #endif
129 #endif /* __MRTOOLS_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:178
+
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 /* Some tools and enhancements to the used libraries, there should be
24 no references to mrmailbox_t and other "larger" classes here. */
25 
26 
27 #ifndef __MRTOOLS_H__
28 #define __MRTOOLS_H__
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 
34 /*** library-private **********************************************************/
35 
36 /* match tools */
37 int mr_exactly_one_bit_set (int v);
38 
39 /* string tools */
40 char* safe_strdup (const char*); /* safe_strdup() returns empty string if NULL is given, never returns NULL (exists on errors) */
41 char* strdup_keep_null (const char*); /* strdup(NULL) is undefined, safe_strdup_keep_null(NULL) returns NULL in this case */
42 int atoi_null_is_0 (const char*);
43 void mr_ltrim (char*);
44 void mr_rtrim (char*);
45 void mr_trim (char*);
46 char* mr_strlower (const char*); /* the result must be free()'d */
47 void mr_strlower_in_place (char*);
48 int mr_str_replace (char** haystack, const char* needle, const char* replacement); /* haystack may be realloc()'d, returns the number of replacements */
49 char* mr_null_terminate (const char*, int bytes); /* the result must be free()'d */
50 char* mr_mprintf (const char* format, ...); /* The result must be free()'d. */
51 void mr_remove_cr_chars (char*); /* remove all \r characters from string */
52 void mr_replace_bad_utf8_chars (char*); /* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */
53 void mr_truncate_n_unwrap_str (char*, int approx_characters, int do_unwrap);
54 carray* mr_split_into_lines (const char* buf_terminated); /* split string into lines*/
55 void mr_free_splitted_lines (carray* lines);
56 char* mr_insert_breaks (const char*, int break_every, const char* break_chars); /* insert a break every n characters, the return must be free()'d */
57 char* mr_arr_to_string (const uint32_t*, int cnt);
58 char* mr_decode_header_string (const char*); /* the result must be free()'d */
59 char* mr_encode_header_string (const char*); /* the result must be free()'d */
60 char* imap_modified_utf7_to_utf8 (const char *mbox, int change_spaces);
61 char* imap_utf8_to_modified_utf7 (const char *src, int change_spaces);
62 char* mr_url_encode (const char*); /* the result must be free()'d */
63 char* encode_base64 (const char * in, int len); /* prototype, from libetpan/src/data-types/base64.h which cannot be included without adding libetpan/src/... to the include-search-paths, which would result in double-file-name-errors */
64 
65 /* string builder */
66 typedef struct mrstrbuilder_t
67 {
68  char* m_buf;
69  int m_allocated;
70  int m_free;
71  char* m_eos;
72 } mrstrbuilder_t;
73 void mrstrbuilder_init (mrstrbuilder_t* ths);
74 char* mrstrbuilder_cat (mrstrbuilder_t* ths, const char* text);
75 void mrstrbuilder_empty(mrstrbuilder_t* ths); /* set the string to a lenght of 0, does not free the buffer */
76 
77 
78 /* carray/clist tools */
79 int carray_search (carray*, void* needle, unsigned int* indx); /* returns 1/0 and the index if `indx` is not NULL */
80 void clist_free_content (const clist*); /* calls free() for each item content */
81 int clist_search_string_nocase (const clist*, const char* str);
82 
83 /* date/time tools */
84 #define MR_INVALID_TIMESTAMP (-1)
85 time_t mr_timestamp_from_date (struct mailimf_date_time * date_time); /* the result is UTC or MR_INVALID_TIMESTAMP */
86 char* mr_timestamp_to_str (time_t); /* the return value must be free()'d */
87 struct mailimap_date_time* mr_timestamp_to_mailimap_date_time (time_t);
88 long mr_gm2local_offset (void);
89 
90 /* timesmearing */
91 time_t mr_smeared_time__ (void);
92 time_t mr_create_smeared_timestamp__ (void);
93 time_t mr_create_smeared_timestamps__(int count);
94 
95 /* Message-ID tools */
96 #define MR_VALID_ID_LEN 11
97 char* mr_create_id (void);
98 char* mr_create_dummy_references_mid (void);
99 char* mr_create_incoming_rfc724_mid (time_t message_timestamp, uint32_t contact_id_from, carray* contact_ids_to);
100 char* mr_create_outgoing_rfc724_mid (const char* grpid, const char* addr);
101 char* mr_extract_grpid_from_rfc724_mid (const char* rfc724_mid);
102 char* mr_extract_grpid_from_rfc724_mid_list(const clist* rfc724_mid_list);
103 
104 
105 /* file tools */
106 int mr_file_exist (const char* pathNfilename);
107 size_t mr_get_filebytes (const char* pathNfilename);
108 char* mr_get_filename (const char* pathNfilename); /* the return value must be free()'d */
109 int mr_delete_file (const char* pathNFilename, mrmailbox_t* log);
110 int mr_copy_file (const char* src_pathNFilename, const char* dest_pathNFilename, mrmailbox_t* log);
111 int mr_create_folder (const char* pathNfilename, mrmailbox_t* log);
112 int mr_write_file (const char* pathNfilename, const void* buf, size_t buf_bytes, mrmailbox_t* log);
113 int mr_read_file (const char* pathNfilename, void** buf, size_t* buf_bytes, mrmailbox_t* log);
114 char* mr_get_filesuffix_lc (const char* pathNfilename); /* the returned suffix is lower-case */
115 void mr_split_filename (const char* pathNfilename, char** ret_basename, char** ret_all_suffixes_incl_dot); /* the case of the suffix is preserved! */
116 int mr_get_filemeta (const void* buf, size_t buf_bytes, uint32_t* ret_width, uint32_t *ret_height);
117 char* mr_get_fine_pathNfilename (const char* folder, const char* desired_name);
118 
119 /* macros */
120 #define MR_QUOTEHELPER(name) #name
121 #define MR_STRINGIFY(macro) MR_QUOTEHELPER(macro)
122 #define MR_MIN(X, Y) (((X) < (Y))? (X) : (Y))
123 #define MR_MAX(X, Y) (((X) > (Y))? (X) : (Y))
124 
125 
126 #ifdef __cplusplus
127 } /* /extern "C" */
128 #endif
129 #endif /* __MRTOOLS_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:182
@@ -243,6 +256,22 @@ char *  +
+
+ + + + +
char* mrcontact_t::m_name
+
+ +

Name given by the user to the contact.

+

Should be used for displaying everywhere and is editable by the user but must not be spreaded via mail (To:, CC: ...) as it as it may be sth. like "Daddy".

+

May be NULL or empty, initially set to m_authname

+

The documentation for this struct was generated from the following files:
Parameters
@@ -589,8 +588,9 @@ void * 
Returns
1=configured and connected, 0=not configured, not explicitly connected, however, an existing connection may still be present
- +
Returns
1=configured and connected, 0=not configured, not explicitly connected, however, an existing connection may still be present
+

There is no need to call this every program start, the result is saved in the database. Instead, you can use mrmailbox_connect() which reuses the configuration and is much faster:

+
if( mrmailbox_is_configured(mailbox) ) {
mrmailbox_connect(mailbox); // fast, reuse the configuration
}
else {
mrmailbox_configure_and_connect(mailbox); // may take a while, typically started in a thread
}
@@ -1066,8 +1066,7 @@ void * 
-

Get a chat object of type mrchat_t by a chat_id.

-

To access the mrchat_t object, see mrchat.h The result must be unref'd using mrchat_unref().

+

Get chat object by a chat ID.

Parameters
@@ -1075,7 +1074,7 @@ void * 
mailboxThe mailbox object as returned from mrmailbox_new().
Returns
A chat object, must be freed using mrchat_unref() when done.
+
Returns
A chat object of the type mrchat_t, must be freed using mrchat_unref() when done.
@@ -1878,14 +1877,14 @@ void * 

Check if the mailbox is already configured.

-

Typically, for unconfigured mailboxes, the user is prompeted for to enter some settings and mrmailbox_configure_and_connect() is called with them.

+

Typically, for unconfigured mailboxes, the user is prompeted for to enter some settings and mrmailbox_configure_and_connect() is called in a thread then.

Parameters
- +
mailboxThe mailbox object as created by mrmailbox_new()
mailboxThe mailbox object as created by mrmailbox_new().
-
Returns
None
+
Returns
1=mailbox is configured and mrmailbox_connect() can be called directly as needed, 0=mailbox is not configured and a configuration by mrmailbox_configure_and_connect() is required.
diff --git a/docs/html/structmrmsg__t.html b/docs/html/structmrmsg__t.html index bc1a070f..4820d053 100644 --- a/docs/html/structmrmsg__t.html +++ b/docs/html/structmrmsg__t.html @@ -396,7 +396,7 @@ char * 

Chat ID the message belongs to.

-

0 if unset. See mrchat_t::m_id for special IDs. Use mrmailbox_get_chat() to load details about the chat.

+

0 if unset. See mrchat_t::m_id for special IDs. Use mrmailbox_get_chat() to load details about the chat.