Delta Chat Core C-Library
mrmailbox.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 __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 7
33 
34 
100 #include <libetpan/libetpan.h> /* defines uint16_t etc. */
101 #include "mrchatlist.h"
102 #include "mrchat.h"
103 #include "mrmsg.h"
104 #include "mrcontact.h"
105 #include "mrpoortext.h"
106 #include "mrparam.h"
107 
108 typedef struct mrmailbox_t mrmailbox_t;
109 typedef struct mrimap_t mrimap_t;
110 typedef struct mrsmtp_t mrsmtp_t;
111 typedef struct mrsqlite3_t mrsqlite3_t;
112 typedef struct mrjob_t mrjob_t;
113 typedef struct mrmimeparser_t mrmimeparser_t;
114 
115 
131 typedef uintptr_t (*mrmailboxcb_t) (mrmailbox_t*, int event, uintptr_t data1, uintptr_t data2);
132 
133 
141 typedef struct mrmailbox_t
142 {
143  void* m_userdata;
144  char* m_dbfile;
145  char* m_blobdir;
148  mrsqlite3_t* m_sql;
149  mrimap_t* m_imap;
150  mrsmtp_t* m_smtp;
152  pthread_t m_job_thread;
153  pthread_cond_t m_job_cond;
154  pthread_mutex_t m_job_condmutex;
155  int m_job_condflag;
156  int m_job_do_exit;
158  mrmailboxcb_t m_cb;
160  char* m_os_name;
162  uint32_t m_cmdline_sel_chat_id;
164  int m_wake_lock;
165  pthread_mutex_t m_wake_lock_critical;
167  int m_e2ee_enabled;
169  #define MR_LOG_RINGBUF_SIZE 200
170  pthread_mutex_t m_log_ringbuf_critical;
171  char* m_log_ringbuf[MR_LOG_RINGBUF_SIZE];
172  time_t m_log_ringbuf_times[MR_LOG_RINGBUF_SIZE];
173  int m_log_ringbuf_pos;
175 } mrmailbox_t;
176 
177 
178 /* create/open/connect */
179 mrmailbox_t* mrmailbox_new (mrmailboxcb_t, void* userdata, const char* os_name);
180 void mrmailbox_unref (mrmailbox_t*);
181 
182 int mrmailbox_open (mrmailbox_t*, const char* dbfile, const char* blobdir);
183 void mrmailbox_close (mrmailbox_t*);
184 int mrmailbox_is_open (const mrmailbox_t*);
185 
186 int mrmailbox_set_config (mrmailbox_t*, const char* key, const char* value);
187 char* mrmailbox_get_config (mrmailbox_t*, const char* key, const char* def);
188 int mrmailbox_set_config_int (mrmailbox_t*, const char* key, int32_t value);
189 int32_t mrmailbox_get_config_int (mrmailbox_t*, const char* key, int32_t def);
190 char* mrmailbox_get_blobdir (mrmailbox_t*);
191 char* mrmailbox_get_version_str (void);
192 
193 void mrmailbox_configure_and_connect(mrmailbox_t*);
194 void mrmailbox_configure_cancel (mrmailbox_t*);
195 int mrmailbox_is_configured (mrmailbox_t*);
196 
197 void mrmailbox_connect (mrmailbox_t*);
198 void mrmailbox_disconnect (mrmailbox_t*);
199 
200 int mrmailbox_restore (mrmailbox_t*, time_t seconds_to_restore); /* not really implemented */
201 char* mrmailbox_get_info (mrmailbox_t*);
202 
203 
204 /* Handle chatlists */
205 #define MR_GCL_ARCHIVED_ONLY 0x01
206 #define MR_GCL_NO_SPECIALS 0x02
207 mrchatlist_t* mrmailbox_get_chatlist (mrmailbox_t*, int flags, const char* query);
208 
209 
210 /* Handle chats */
211 uint32_t mrmailbox_create_chat_by_contact_id (mrmailbox_t*, uint32_t contact_id);
212 uint32_t mrmailbox_get_chat_id_by_contact_id (mrmailbox_t*, uint32_t contact_id);
213 
214 uint32_t mrmailbox_send_text_msg (mrmailbox_t*, uint32_t chat_id, const char* text_to_send);
215 uint32_t mrmailbox_send_msg (mrmailbox_t*, uint32_t chat_id, mrmsg_t*);
216 void mrmailbox_set_draft (mrmailbox_t*, uint32_t chat_id, const char*);
217 
218 #define MR_GCM_ADDDAYMARKER 0x01
219 carray* mrmailbox_get_chat_msgs (mrmailbox_t*, uint32_t chat_id, uint32_t flags, uint32_t marker1before);
220 int mrmailbox_get_total_msg_count (mrmailbox_t*, uint32_t chat_id);
221 int mrmailbox_get_fresh_msg_count (mrmailbox_t*, uint32_t chat_id);
222 carray* mrmailbox_get_fresh_msgs (mrmailbox_t*);
223 void mrmailbox_marknoticed_chat (mrmailbox_t*, uint32_t chat_id);
224 carray* mrmailbox_get_chat_media (mrmailbox_t*, uint32_t chat_id, int msg_type, int or_msg_type);
225 uint32_t mrmailbox_get_next_media (mrmailbox_t*, uint32_t curr_msg_id, int dir);
226 
227 void mrmailbox_archive_chat (mrmailbox_t*, uint32_t chat_id, int archive);
228 void mrmailbox_delete_chat (mrmailbox_t*, uint32_t chat_id);
229 
230 carray* mrmailbox_get_chat_contacts (mrmailbox_t*, uint32_t chat_id);
231 carray* mrmailbox_search_msgs (mrmailbox_t*, uint32_t chat_id, const char* query);
232 
233 mrchat_t* mrmailbox_get_chat (mrmailbox_t*, uint32_t chat_id);
234 
235 
236 /* Handle group chats */
237 uint32_t mrmailbox_create_group_chat (mrmailbox_t*, const char* name);
238 int mrmailbox_is_contact_in_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
239 int mrmailbox_add_contact_to_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
240 int mrmailbox_remove_contact_from_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
241 int mrmailbox_set_chat_name (mrmailbox_t*, uint32_t chat_id, const char* name);
242 int mrmailbox_set_chat_image (mrmailbox_t*, uint32_t chat_id, const char* image);
243 
244 
245 /* Handle messages */
246 char* mrmailbox_get_msg_info (mrmailbox_t*, uint32_t msg_id);
247 void mrmailbox_delete_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt);
248 void mrmailbox_forward_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id);
249 void mrmailbox_marknoticed_contact (mrmailbox_t*, uint32_t contact_id);
250 void mrmailbox_markseen_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt);
251 void mrmailbox_star_msgs (mrmailbox_t*, const uint32_t* msg_ids, int msg_cnt, int star);
252 mrmsg_t* mrmailbox_get_msg (mrmailbox_t*, uint32_t msg_id);
253 
254 
255 
256 /* Handle contacts */
257 uint32_t mrmailbox_create_contact (mrmailbox_t*, const char* name, const char* addr);
258 int mrmailbox_add_address_book (mrmailbox_t*, const char*);
259 carray* mrmailbox_get_known_contacts (mrmailbox_t*, const char* query);
260 int mrmailbox_get_blocked_count (mrmailbox_t*);
261 carray* mrmailbox_get_blocked_contacts (mrmailbox_t*);
262 void mrmailbox_block_contact (mrmailbox_t*, uint32_t contact_id, int block);
263 char* mrmailbox_get_contact_encrinfo (mrmailbox_t*, uint32_t contact_id);
264 int mrmailbox_delete_contact (mrmailbox_t*, uint32_t contact_id);
265 mrcontact_t* mrmailbox_get_contact (mrmailbox_t*, uint32_t contact_id);
266 
267 
268 /* logging */
269 void mrmailbox_log_error (mrmailbox_t*, int code, const char* msg, ...);
270 void mrmailbox_log_error_if (int* condition, mrmailbox_t*, int code, const char* msg, ...);
271 void mrmailbox_log_warning (mrmailbox_t*, int code, const char* msg, ...);
272 void mrmailbox_log_info (mrmailbox_t*, int code, const char* msg, ...);
273 void mrmailbox_log_vprintf (mrmailbox_t*, int event, int code, const char* msg, va_list);
274 int mrmailbox_get_thread_index (void);
275 
276 
277 /* library private */
278 uint32_t mrmailbox_send_msg_i__ (mrmailbox_t*, mrchat_t*, const mrmsg_t*, time_t);
279 void mrmailbox_connect_to_imap (mrmailbox_t*, mrjob_t*);
280 void mrmailbox_wake_lock (mrmailbox_t*);
281 void mrmailbox_wake_unlock (mrmailbox_t*);
282 int mrmailbox_poke_eml_file (mrmailbox_t*, const char* file);
283 int mrmailbox_is_reply_to_known_message__ (mrmailbox_t*, mrmimeparser_t*);
284 int mrmailbox_is_reply_to_messenger_message__ (mrmailbox_t*, mrmimeparser_t*);
285 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);
286 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);
287 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);
288 int mrmailbox_get_archived_count__ (mrmailbox_t*);
289 int mrmailbox_reset_tables (mrmailbox_t*, int bits); /* reset tables but leaves server configuration, 1=jobs, 2=e2ee, 8=rest but server config */
290 size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*);
291 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);
292 int mrmailbox_get_contact_origin__ (mrmailbox_t*, uint32_t id, int* ret_blocked);
293 int mrmailbox_is_contact_blocked__ (mrmailbox_t*, uint32_t id);
294 int mrmailbox_real_contact_exists__ (mrmailbox_t*, uint32_t id);
295 int mrmailbox_contact_addr_equals__ (mrmailbox_t*, uint32_t contact_id, const char* other_addr);
296 void mrmailbox_scaleup_contact_origin__ (mrmailbox_t*, uint32_t contact_id, int origin);
297 
298 
299 /* library private: end-to-end-encryption */
300 #define MR_E2EE_DEFAULT_ENABLED 1
301 #define MR_MDNS_DEFAULT_ENABLED 1
302 
303 typedef struct mrmailbox_e2ee_helper_t {
304  int m_encryption_successfull;
305  void* m_cdata_to_free;
306 } mrmailbox_e2ee_helper_t;
307 
308 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*);
309 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 */
310 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! */
311 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 */
312 
313 
314 /*******************************************************************************
315  * Events
316  ******************************************************************************/
317 
318 
319 /* The following events may be passed to the callback given to mrmailbox_new() */
320 
321 
322 /* Information, should not be reported, can be logged,
323 data1=0, data2=info string */
324 #define MR_EVENT_INFO 100
325 
326 
327 /* Warning, should not be reported, should be logged
328 data1=0, data2=warning string */
329 #define MR_EVENT_WARNING 300
330 
331 
332 /* Error, must be reported to the user by a non-disturbing bubble or so.
333 data1=error code MR_ERR_*, see below, data2=error string */
334 #define MR_EVENT_ERROR 400
335 
336 
337 /* one or more messages changed for some reasons in the database - added or
338 removed. For added messages: data1=chat_id, data2=msg_id */
339 #define MR_EVENT_MSGS_CHANGED 2000
340 
341 
342 /* For fresh messages from the INBOX, MR_EVENT_INCOMING_MSG is send;
343 data1=chat_id, data2=msg_id */
344 #define MR_EVENT_INCOMING_MSG 2005
345 
346 
347 /* a single message is send successfully (state changed from PENDING/SENDING to
348 DELIVERED); data1=chat_id, data2=msg_id */
349 #define MR_EVENT_MSG_DELIVERED 2010
350 
351 
352 /* a single message is read by the receiver (state changed from DELIVERED to
353 READ); data1=chat_id, data2=msg_id */
354 #define MR_EVENT_MSG_READ 2015
355 
356 
357 /* group name/image changed or members added/removed */
358 #define MR_EVENT_CHAT_MODIFIED 2020
359 
360 
361 /* contact(s) created, renamed, blocked or deleted */
362 #define MR_EVENT_CONTACTS_CHANGED 2030
363 
364 
365 /* connection state changed,
366 data1=0:failed-not-connected, 1:configured-and-connected */
367 #define MR_EVENT_CONFIGURE_ENDED 2040
368 
369 
370 /* data1=percent */
371 #define MR_EVENT_CONFIGURE_PROGRESS 2041
372 
373 
374 /* mrmailbox_imex() done:
375 data1=0:failed, 1=success */
376 #define MR_EVENT_IMEX_ENDED 2050
377 
378 
379 /* data1=permille */
380 #define MR_EVENT_IMEX_PROGRESS 2051
381 
382 
383 /* file written, event may be needed to make the file public to some system
384 services. data1=file name, data2=mime type */
385 #define MR_EVENT_IMEX_FILE_WRITTEN 2052
386 
387 
388 /* The following events are functions that should be provided by the frontends */
389 
390 
391 /* check, if the system is online currently
392 ret=0: not online, ret=1: online */
393 #define MR_EVENT_IS_ONLINE 2080
394 
395 
396 /* get a string from the frontend, data1=MR_STR_*, ret=string which will be
397 free()'d by the backend */
398 #define MR_EVENT_GET_STRING 2091
399 
400 
401 /* synchronous http/https(!) call, data1=url, ret=content which will be
402 free()'d by the backend, 0 on errors */
403 #define MR_EVENT_GET_QUANTITY_STRING 2092
404 
405 
406 /* synchronous http/https(!) call, data1=url, ret=content which will be free()'d
407 by the backend, 0 on errors */
408 #define MR_EVENT_HTTP_GET 2100
409 
410 /* acquire wakeLock (data1=1) or release it (data1=0), the backend does not make
411 nested or unsynchronized calls */
412 #define MR_EVENT_WAKE_LOCK 2110
413 
414 
415 /* Error codes */
416 #define MR_ERR_SELF_NOT_IN_GROUP 1
417 #define MR_ERR_NONETWORK 2
418 
419 
420 /*******************************************************************************
421  * Import/export and Tools
422  ******************************************************************************/
423 
424 
425 #define MR_IMEX_CANCEL 0
426 #define MR_IMEX_EXPORT_SELF_KEYS 1
427 #define MR_IMEX_IMPORT_SELF_KEYS 2
428 #define MR_IMEX_EXPORT_BACKUP 11
429 #define MR_IMEX_IMPORT_BACKUP 12
430 #define MR_IMEX_EXPORT_SETUP_MESSAGE 20
431 #define MR_BAK_PREFIX "delta-chat"
432 #define MR_BAK_SUFFIX "bak"
433 void mrmailbox_imex (mrmailbox_t*, int what, const char* param1, const char* setup_code);
434 char* mrmailbox_imex_has_backup (mrmailbox_t*, const char* dir);
435 
436 
437 
438 int mrmailbox_check_password (mrmailbox_t*, const char* pw);
439 
440 
441 
442 char* mrmailbox_create_setup_code (mrmailbox_t*);
443 
444 
445 
446 int mrmailbox_poke_spec (mrmailbox_t*, const char* spec);
447 
448 
449 /* The library tries itself to stay alive. For this purpose there is an additional
450 "heartbeat" thread that checks if the IDLE-thread is up and working. This check is done about every minute.
451 However, depending on the operating system, this thread may be delayed or stopped, if this is the case you can
452 force additional checks manually by just calling mrmailbox_heartbeat() about every minute.
453 If in doubt, call this function too often, not too less :-) */
454 void mrmailbox_heartbeat (mrmailbox_t*);
455 
456 
457 /* carray tools, already defined are things as
458 unsigned unt carray_count() */
459 uint32_t carray_get_uint32 (carray*, unsigned int index);
460 
461 
462 /* deprecated functions */
463 mrchat_t* mrchatlist_get_chat_by_index (mrchatlist_t*, size_t index); /* deprecated - use mrchatlist_get_chat_id_by_index() */
464 mrmsg_t* mrchatlist_get_msg_by_index (mrchatlist_t*, size_t index); /* deprecated - use mrchatlist_get_msg_id_by_index() */
465 int mrchat_set_draft (mrchat_t*, const char* msg); /* deprecated - use mrmailbox_set_draft() instead */
466 
467 
468 /* library-internal */
469 void mrmailbox_unarchive_chat__ (mrmailbox_t*, uint32_t chat_id);
470 size_t mrmailbox_get_chat_cnt__ (mrmailbox_t*);
471 uint32_t mrmailbox_create_or_lookup_nchat_by_contact_id__(mrmailbox_t*, uint32_t contact_id);
472 uint32_t mrmailbox_lookup_real_nchat_by_contact_id__(mrmailbox_t*, uint32_t contact_id);
473 int mrmailbox_get_total_msg_count__ (mrmailbox_t*, uint32_t chat_id);
474 int mrmailbox_get_fresh_msg_count__ (mrmailbox_t*, uint32_t chat_id);
475 uint32_t mrmailbox_get_last_deaddrop_fresh_msg__(mrmailbox_t*);
476 void mrmailbox_send_msg_to_smtp (mrmailbox_t*, mrjob_t*);
477 void mrmailbox_send_msg_to_imap (mrmailbox_t*, mrjob_t*);
478 int mrmailbox_add_contact_to_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
479 int mrmailbox_is_contact_in_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
480 int mrmailbox_get_chat_contact_count__ (mrmailbox_t*, uint32_t chat_id);
481 int mrmailbox_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
482 void mrmailbox_set_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
483 
484 size_t mrmailbox_get_real_msg_cnt__ (mrmailbox_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
485 size_t mrmailbox_get_deaddrop_msg_cnt__ (mrmailbox_t*);
486 int mrmailbox_rfc724_mid_cnt__ (mrmailbox_t*, const char* rfc724_mid);
487 int mrmailbox_rfc724_mid_exists__ (mrmailbox_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
488 void mrmailbox_update_server_uid__ (mrmailbox_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
489 void mrmailbox_update_msg_chat_id__ (mrmailbox_t*, uint32_t msg_id, uint32_t chat_id);
490 void mrmailbox_update_msg_state__ (mrmailbox_t*, uint32_t msg_id, int state);
491 void mrmailbox_delete_msg_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
492 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 */
493 void mrmailbox_send_mdn (mrmailbox_t*, mrjob_t* job);
494 void mrmailbox_markseen_msg_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
495 void mrmailbox_markseen_mdn_on_imap (mrmailbox_t* mailbox, mrjob_t* job);
496 
497 
498 #ifdef __cplusplus
499 } /* /extern "C" */
500 #endif
501 #endif /* __MRMAILBOX_H__ */
int mrmailbox_add_address_book(mrmailbox_t *mailbox, const char *adr_book)
Add a number of contacts.
Definition: mrmailbox.c:4021
uint32_t mrmailbox_create_group_chat(mrmailbox_t *mailbox, const char *chat_name)
Create a new group chat.
Definition: mrmailbox.c:3333
uint32_t mrmailbox_create_contact(mrmailbox_t *mailbox, const char *name, const char *addr)
Add a single contact.
Definition: mrmailbox.c:3985
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:3101
void mrmailbox_close(mrmailbox_t *mailbox)
Close mailbox database.
Definition: mrmailbox.c:1075
mrmailbox_t * mrmailbox_new(mrmailboxcb_t cb, void *userdata, const char *os_name)
Create a new mailbox object.
Definition: mrmailbox.c:897
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:3565
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:1709
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:3678
int mrmailbox_open(mrmailbox_t *mailbox, const char *dbfile, const char *blobdir)
Open mailbox database.
Definition: mrmailbox.c:1010
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:4509
An object representing a single chatlist in memory.
Definition: mrchatlist.h:42
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:2120
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:4954
carray * mrmailbox_search_msgs(mrmailbox_t *mailbox, uint32_t chat_id, const char *query)
Search messages containing the given query string.
Definition: mrmailbox.c:2224
int mrmailbox_set_config(mrmailbox_t *ths, const char *key, const char *value)
Configure the mailbox.
Definition: mrmailbox.c:1176
char * m_dbfile
the database file in file.
Definition: mrmailbox.h:144
An object representing a single mailbox.
Definition: mrmailbox.h:141
void mrmailbox_delete_msgs(mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt)
Delete a list of messages.
Definition: mrmailbox.c:5096
int mrmailbox_is_open(const mrmailbox_t *mailbox)
Check if a given mailbox database is open.
Definition: mrmailbox.c:1109
void mrmailbox_archive_chat(mrmailbox_t *mailbox, uint32_t chat_id, int archive)
Archive or unarchive a chat.
Definition: mrmailbox.c:2652
char * mrmailbox_get_info(mrmailbox_t *mailbox)
Get information about the mailbox.
Definition: mrmailbox.c:1292
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:3595
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:1927
char * mrmailbox_get_version_str(void)
Find out the version of the Delta Chat core library.
Definition: mrmailbox.c:1490
void mrmailbox_disconnect(mrmailbox_t *mailbox)
Disonnect the mailbox from the server.
Definition: mrmailbox.c:1605
char * m_blobdir
full path of the blob directory in use.
Definition: mrmailbox.h:145
carray * mrmailbox_get_fresh_msgs(mrmailbox_t *mailbox)
Returns the message IDs of all fresh messages of any chat.
Definition: mrmailbox.c:2052
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:3142
void mrmailbox_connect(mrmailbox_t *mailbox)
Connect to the mailbox using the configured settings.
Definition: mrmailbox.c:1578
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:2588
carray * mrmailbox_get_chat_contacts(mrmailbox_t *mailbox, uint32_t chat_id)
Get contact IDs belonging to a chat.
Definition: mrmailbox.c:2003
void mrmailbox_unref(mrmailbox_t *mailbox)
Free a mailbox object.
Definition: mrmailbox.c:954
void mrmailbox_block_contact(mrmailbox_t *mailbox, uint32_t contact_id, int new_blocking)
Block or unblock a contact.
Definition: mrmailbox.c:4290
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:131
mrchatlist_t * mrmailbox_get_chatlist(mrmailbox_t *mailbox, int listflags, const char *query)
Get a list of chats.
Definition: mrmailbox.c:1663
An object representing a single message in memory.
Definition: mrmsg.h:40
void mrmailbox_configure_and_connect(mrmailbox_t *mailbox)
Configure and connect a mailbox.
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:1789
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:2616
void mrmailbox_delete_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Delete a chat:
Definition: mrmailbox.c:2773
void mrmailbox_set_draft(mrmailbox_t *mailbox, uint32_t chat_id, const char *msg)
Save a draft for a chat.
Definition: mrmailbox.c:2371
int mrmailbox_get_blocked_count(mrmailbox_t *mailbox)
Get the number of blocked contacts.
Definition: mrmailbox.c:4174
int mrmailbox_set_chat_image(mrmailbox_t *mailbox, uint32_t chat_id, const char *new_image)
Set group image.
Definition: mrmailbox.c:3476
carray * mrmailbox_get_known_contacts(mrmailbox_t *mailbox, const char *query)
Returns known and unblocked contacts.
Definition: mrmailbox.c:4076
char * mrmailbox_get_blobdir(mrmailbox_t *mailbox)
Get the blob directory.
Definition: mrmailbox.c:1276
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:4701
void * m_userdata
the same pointer as given to mrmailbox_new(), may be used by the caller for any purpose ...
Definition: mrmailbox.h:143
int mrmailbox_is_configured(mrmailbox_t *mailbox)
Check if the mailbox is already configured.
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:1896
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:1816
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:4868
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:5237
void mrmailbox_marknoticed_chat(mrmailbox_t *mailbox, uint32_t chat_id)
Mark all message in a chat as noticed.
Definition: mrmailbox.c:1755
char * mrmailbox_imex_has_backup(mrmailbox_t *mailbox, const char *dir_name)
Check if there is a backup file.
void mrmailbox_configure_cancel(mrmailbox_t *mailbox)
Cancel an configuration started by mrmailbox_configure_and_connect().
carray * mrmailbox_get_blocked_contacts(mrmailbox_t *mailbox)
Get blocked contacts.
Definition: mrmailbox.c:4140
mrcontact_t * mrmailbox_get_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Get a single contact object.
Definition: mrmailbox.c:4216
int mrmailbox_check_password(mrmailbox_t *mailbox, const char *test_pw)
Check if the user is authorized by the given password in some way.
void mrmailbox_marknoticed_contact(mrmailbox_t *mailbox, uint32_t contact_id)
Mark all messages send by the given contact as noticed.
Definition: mrmailbox.c:4264
int mrmailbox_set_config_int(mrmailbox_t *ths, const char *key, int32_t value)
Configure the mailbox.
Definition: mrmailbox.c:1229
int32_t mrmailbox_get_config_int(mrmailbox_t *ths, const char *key, int32_t def)
Get a configuration option.
Definition: mrmailbox.c:1251
int mrmailbox_set_chat_name(mrmailbox_t *mailbox, uint32_t chat_id, const char *new_name)
Set group name.
Definition: mrmailbox.c:3399
char * mrmailbox_create_setup_code(mrmailbox_t *mailbox)
Create random setup code.
char * mrmailbox_get_contact_encrinfo(mrmailbox_t *mailbox, uint32_t contact_id)
Get encryption info.
Definition: mrmailbox.c:4381
void mrmailbox_imex(mrmailbox_t *mailbox, int what, const char *param1, const char *setup_code)
Import/export things.
char * mrmailbox_get_config(mrmailbox_t *ths, const char *key, const char *def)
Get a configuration option.
Definition: mrmailbox.c:1207
char * mrmailbox_get_msg_info(mrmailbox_t *mailbox, uint32_t msg_id)
Get an informational text for a single message.
Definition: mrmailbox.c:4743
An object representing a single chat in memory.
Definition: mrchat.h:39