Delta Chat Core C-API
 All Classes Functions Typedefs Groups Pages
deltachat.h
1 #ifndef __DELTACHAT_H__
2 #define __DELTACHAT_H__
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 
8 #ifndef PY_CFFI
9 #include <stdint.h>
10 #include <time.h>
11 #endif
12 
13 
14 #define DC_VERSION_STR "0.29.0"
15 
16 
195 typedef struct _dc_context dc_context_t;
196 typedef struct _dc_array dc_array_t;
197 typedef struct _dc_chatlist dc_chatlist_t;
198 typedef struct _dc_chat dc_chat_t;
199 typedef struct _dc_msg dc_msg_t;
200 typedef struct _dc_contact dc_contact_t;
201 typedef struct _dc_lot dc_lot_t;
202 
203 
214 typedef uintptr_t (*dc_callback_t) (dc_context_t*, int event, uintptr_t data1, uintptr_t data2);
215 
216 
217 // create/open/config/information
218 dc_context_t* dc_context_new (dc_callback_t, void* userdata, const char* os_name);
219 void dc_context_unref (dc_context_t*);
220 void* dc_get_userdata (dc_context_t*);
221 
222 int dc_open (dc_context_t*, const char* dbfile, const char* blobdir);
223 void dc_close (dc_context_t*);
224 int dc_is_open (const dc_context_t*);
225 char* dc_get_blobdir (const dc_context_t*);
226 
227 int dc_set_config (dc_context_t*, const char* key, const char* value);
228 char* dc_get_config (dc_context_t*, const char* key);
229 char* dc_get_info (dc_context_t*);
230 char* dc_get_version_str (void);
231 void dc_openssl_init_not_required (void);
232 void dc_no_compound_msgs (void); // deprecated
233 
234 
235 // connect
236 void dc_configure (dc_context_t*);
237 int dc_is_configured (const dc_context_t*);
238 
239 void dc_perform_imap_jobs (dc_context_t*);
240 void dc_perform_imap_fetch (dc_context_t*);
241 void dc_perform_imap_idle (dc_context_t*);
242 void dc_interrupt_imap_idle (dc_context_t*);
243 
244 void dc_perform_smtp_jobs (dc_context_t*);
245 void dc_perform_smtp_idle (dc_context_t*);
246 void dc_interrupt_smtp_idle (dc_context_t*);
247 
248 void dc_maybe_network (dc_context_t*);
249 
250 
251 // handle chatlists
252 #define DC_GCL_ARCHIVED_ONLY 0x01
253 #define DC_GCL_NO_SPECIALS 0x02
254 #define DC_GCL_ADD_ALLDONE_HINT 0x04
255 dc_chatlist_t* dc_get_chatlist (dc_context_t*, int flags, const char* query_str, uint32_t query_id);
256 
257 
258 // handle chats
259 uint32_t dc_create_chat_by_msg_id (dc_context_t*, uint32_t msg_id);
260 uint32_t dc_create_chat_by_contact_id (dc_context_t*, uint32_t contact_id);
261 uint32_t dc_get_chat_id_by_contact_id (dc_context_t*, uint32_t contact_id);
262 
263 uint32_t dc_send_msg (dc_context_t*, uint32_t chat_id, dc_msg_t*);
264 uint32_t dc_send_text_msg (dc_context_t*, uint32_t chat_id, const char* text_to_send);
265 void dc_set_draft (dc_context_t*, uint32_t chat_id, dc_msg_t*);
266 dc_msg_t* dc_get_draft (dc_context_t*, uint32_t chat_id);
267 
268 #define DC_GCM_ADDDAYMARKER 0x01
269 dc_array_t* dc_get_chat_msgs (dc_context_t*, uint32_t chat_id, uint32_t flags, uint32_t marker1before);
270 int dc_get_msg_cnt (dc_context_t*, uint32_t chat_id);
271 int dc_get_fresh_msg_cnt (dc_context_t*, uint32_t chat_id);
272 dc_array_t* dc_get_fresh_msgs (dc_context_t*);
273 void dc_marknoticed_chat (dc_context_t*, uint32_t chat_id);
274 void dc_marknoticed_all_chats (dc_context_t*);
275 dc_array_t* dc_get_chat_media (dc_context_t*, uint32_t chat_id, int msg_type, int or_msg_type);
276 uint32_t dc_get_next_media (dc_context_t*, uint32_t curr_msg_id, int dir);
277 
278 void dc_archive_chat (dc_context_t*, uint32_t chat_id, int archive);
279 void dc_delete_chat (dc_context_t*, uint32_t chat_id);
280 
281 dc_array_t* dc_get_chat_contacts (dc_context_t*, uint32_t chat_id);
282 dc_array_t* dc_search_msgs (dc_context_t*, uint32_t chat_id, const char* query);
283 
284 dc_chat_t* dc_get_chat (dc_context_t*, uint32_t chat_id);
285 
286 
287 // handle group chats
288 uint32_t dc_create_group_chat (dc_context_t*, int verified, const char* name);
289 int dc_is_contact_in_chat (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
290 int dc_add_contact_to_chat (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
291 int dc_remove_contact_from_chat (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
292 int dc_set_chat_name (dc_context_t*, uint32_t chat_id, const char* name);
293 int dc_set_chat_profile_image (dc_context_t*, uint32_t chat_id, const char* image);
294 
295 
296 // handle messages
297 char* dc_get_msg_info (dc_context_t*, uint32_t msg_id);
298 char* dc_get_mime_headers (dc_context_t*, uint32_t msg_id);
299 void dc_delete_msgs (dc_context_t*, const uint32_t* msg_ids, int msg_cnt);
300 void dc_forward_msgs (dc_context_t*, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id);
301 void dc_marknoticed_contact (dc_context_t*, uint32_t contact_id);
302 void dc_markseen_msgs (dc_context_t*, const uint32_t* msg_ids, int msg_cnt);
303 void dc_star_msgs (dc_context_t*, const uint32_t* msg_ids, int msg_cnt, int star);
304 dc_msg_t* dc_get_msg (dc_context_t*, uint32_t msg_id);
305 
306 
307 // handle contacts
308 int dc_may_be_valid_addr (const char* addr);
309 uint32_t dc_lookup_contact_id_by_addr (dc_context_t*, const char* addr);
310 uint32_t dc_create_contact (dc_context_t*, const char* name, const char* addr);
311 int dc_add_address_book (dc_context_t*, const char*);
312 
313 #define DC_GCL_VERIFIED_ONLY 0x01
314 #define DC_GCL_ADD_SELF 0x02
315 dc_array_t* dc_get_contacts (dc_context_t*, uint32_t flags, const char* query);
316 
317 int dc_get_blocked_cnt (dc_context_t*);
318 dc_array_t* dc_get_blocked_contacts (dc_context_t*);
319 void dc_block_contact (dc_context_t*, uint32_t contact_id, int block);
320 char* dc_get_contact_encrinfo (dc_context_t*, uint32_t contact_id);
321 int dc_delete_contact (dc_context_t*, uint32_t contact_id);
322 dc_contact_t* dc_get_contact (dc_context_t*, uint32_t contact_id);
323 
324 
325 // import/export and tools
326 #define DC_IMEX_EXPORT_SELF_KEYS 1 // param1 is a directory where the keys are written to
327 #define DC_IMEX_IMPORT_SELF_KEYS 2 // param1 is a directory where the keys are searched in and read from
328 #define DC_IMEX_EXPORT_BACKUP 11 // param1 is a directory where the backup is written to
329 #define DC_IMEX_IMPORT_BACKUP 12 // param1 is the file with the backup to import
330 void dc_imex (dc_context_t*, int what, const char* param1, const char* param2);
331 char* dc_imex_has_backup (dc_context_t*, const char* dir);
332 int dc_check_password (dc_context_t*, const char* pw);
333 char* dc_initiate_key_transfer (dc_context_t*);
334 int dc_continue_key_transfer (dc_context_t*, uint32_t msg_id, const char* setup_code);
335 void dc_stop_ongoing_process (dc_context_t*);
336 
337 
338 // out-of-band verification
339 #define DC_QR_ASK_VERIFYCONTACT 200 // id=contact
340 #define DC_QR_ASK_VERIFYGROUP 202 // text1=groupname
341 #define DC_QR_FPR_OK 210 // id=contact
342 #define DC_QR_FPR_MISMATCH 220 // id=contact
343 #define DC_QR_FPR_WITHOUT_ADDR 230 // test1=formatted fingerprint
344 #define DC_QR_ADDR 320 // id=contact
345 #define DC_QR_TEXT 330 // text1=text
346 #define DC_QR_URL 332 // text1=URL
347 #define DC_QR_ERROR 400 // text1=error string
348 dc_lot_t* dc_check_qr (dc_context_t*, const char* qr);
349 char* dc_get_securejoin_qr (dc_context_t*, uint32_t chat_id);
350 uint32_t dc_join_securejoin (dc_context_t*, const char* qr);
351 
352 
361 typedef struct _dc_array dc_array_t;
362 
363 
364 dc_array_t* dc_array_new (dc_context_t*, size_t initsize);
365 void dc_array_empty (dc_array_t*);
366 void dc_array_unref (dc_array_t*);
367 
368 void dc_array_add_uint (dc_array_t*, uintptr_t);
369 void dc_array_add_id (dc_array_t*, uint32_t);
370 void dc_array_add_ptr (dc_array_t*, void*);
371 
372 size_t dc_array_get_cnt (const dc_array_t*);
373 uintptr_t dc_array_get_uint (const dc_array_t*, size_t index);
374 uint32_t dc_array_get_id (const dc_array_t*, size_t index);
375 void* dc_array_get_ptr (const dc_array_t*, size_t index);
376 
377 int dc_array_search_id (const dc_array_t*, uint32_t needle, size_t* indx);
378 const uintptr_t* dc_array_get_raw (const dc_array_t*);
379 
380 
419 typedef struct _dc_chatlist dc_chatlist_t;
420 
421 
422 dc_chatlist_t* dc_chatlist_new (dc_context_t*);
423 void dc_chatlist_empty (dc_chatlist_t*);
425 size_t dc_chatlist_get_cnt (const dc_chatlist_t*);
426 uint32_t dc_chatlist_get_chat_id (const dc_chatlist_t*, size_t index);
427 uint32_t dc_chatlist_get_msg_id (const dc_chatlist_t*, size_t index);
428 dc_lot_t* dc_chatlist_get_summary (const dc_chatlist_t*, size_t index, dc_chat_t*);
429 dc_context_t* dc_chatlist_get_context (dc_chatlist_t*);
430 
431 
440 typedef struct _dc_chat dc_chat_t;
441 
442 
443 #define DC_CHAT_ID_DEADDROP 1 // virtual chat showing all messages belonging to chats flagged with chats.blocked=2
444 #define DC_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)
445 #define DC_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 sent and shown)
446 #define DC_CHAT_ID_STARRED 5 // virtual chat showing all messages flagged with msgs.starred=2
447 #define DC_CHAT_ID_ARCHIVED_LINK 6 // only an indicator in a chatlist
448 #define DC_CHAT_ID_ALLDONE_HINT 7 // only an indicator in a chatlist
449 #define DC_CHAT_ID_LAST_SPECIAL 9 // larger chat IDs are "real" chats, their messages are "real" messages.
450 
451 
452 #define DC_CHAT_TYPE_UNDEFINED 0
453 #define DC_CHAT_TYPE_SINGLE 100
454 #define DC_CHAT_TYPE_GROUP 120
455 #define DC_CHAT_TYPE_VERIFIED_GROUP 130
456 
457 
458 dc_chat_t* dc_chat_new (dc_context_t*);
459 void dc_chat_empty (dc_chat_t*);
460 void dc_chat_unref (dc_chat_t*);
461 
462 uint32_t dc_chat_get_id (const dc_chat_t*);
463 int dc_chat_get_type (const dc_chat_t*);
464 char* dc_chat_get_name (const dc_chat_t*);
465 char* dc_chat_get_subtitle (const dc_chat_t*);
466 char* dc_chat_get_profile_image (const dc_chat_t*);
467 uint32_t dc_chat_get_color (const dc_chat_t*);
468 int dc_chat_get_archived (const dc_chat_t*);
469 int dc_chat_is_unpromoted (const dc_chat_t*);
470 int dc_chat_is_self_talk (const dc_chat_t*);
471 int dc_chat_is_verified (const dc_chat_t*);
472 
473 
481 typedef struct _dc_msg dc_msg_t;
482 
483 
484 #define DC_MSG_ID_MARKER1 1
485 #define DC_MSG_ID_DAYMARKER 9
486 #define DC_MSG_ID_LAST_SPECIAL 9
487 
488 
489 #define DC_STATE_UNDEFINED 0
490 #define DC_STATE_IN_FRESH 10
491 #define DC_STATE_IN_NOTICED 13
492 #define DC_STATE_IN_SEEN 16
493 #define DC_STATE_OUT_DRAFT 19
494 #define DC_STATE_OUT_PENDING 20
495 #define DC_STATE_OUT_FAILED 24
496 #define DC_STATE_OUT_DELIVERED 26 // to check if a mail was sent, use dc_msg_is_sent()
497 #define DC_STATE_OUT_MDN_RCVD 28
498 
499 
500 #define DC_MAX_GET_TEXT_LEN 30000 // approx. max. lenght returned by dc_msg_get_text()
501 #define DC_MAX_GET_INFO_LEN 100000 // approx. max. lenght returned by dc_get_msg_info()
502 
503 
504 dc_msg_t* dc_msg_new (dc_context_t*, int viewtype);
505 void dc_msg_unref (dc_msg_t*);
506 void dc_msg_empty (dc_msg_t*);
507 uint32_t dc_msg_get_id (const dc_msg_t*);
508 uint32_t dc_msg_get_from_id (const dc_msg_t*);
509 uint32_t dc_msg_get_chat_id (const dc_msg_t*);
510 int dc_msg_get_viewtype (const dc_msg_t*);
511 int dc_msg_get_state (const dc_msg_t*);
512 time_t dc_msg_get_timestamp (const dc_msg_t*);
514 char* dc_msg_get_text (const dc_msg_t*);
515 char* dc_msg_get_file (const dc_msg_t*);
516 char* dc_msg_get_filename (const dc_msg_t*);
517 char* dc_msg_get_filemime (const dc_msg_t*);
518 uint64_t dc_msg_get_filebytes (const dc_msg_t*);
519 int dc_msg_get_width (const dc_msg_t*);
520 int dc_msg_get_height (const dc_msg_t*);
521 int dc_msg_get_duration (const dc_msg_t*);
522 int dc_msg_get_showpadlock (const dc_msg_t*);
524 char* dc_msg_get_summarytext (const dc_msg_t*, int approx_characters);
525 int dc_msg_is_sent (const dc_msg_t*);
526 int dc_msg_is_starred (const dc_msg_t*);
527 int dc_msg_is_forwarded (const dc_msg_t*);
528 int dc_msg_is_info (const dc_msg_t*);
529 int dc_msg_is_increation (const dc_msg_t*);
530 int dc_msg_is_setupmessage (const dc_msg_t*);
531 char* dc_msg_get_setupcodebegin (const dc_msg_t*);
532 void dc_msg_set_text (dc_msg_t*, const char* text);
533 void dc_msg_set_file (dc_msg_t*, const char* file, const char* filemime);
534 void dc_msg_set_dimension (dc_msg_t*, int width, int height);
535 void dc_msg_set_duration (dc_msg_t*, int duration);
536 void dc_msg_latefiling_mediasize (dc_msg_t*, int width, int height, int duration);
537 
538 
558 typedef struct _dc_contact dc_contact_t;
559 
560 #define DC_CONTACT_ID_SELF 1
561 #define DC_CONTACT_ID_DEVICE 2
562 #define DC_CONTACT_ID_LAST_SPECIAL 9
563 
564 
565 dc_contact_t* dc_contact_new (dc_context_t*);
566 void dc_contact_empty (dc_contact_t*);
568 uint32_t dc_contact_get_id (const dc_contact_t*);
569 char* dc_contact_get_addr (const dc_contact_t*);
570 char* dc_contact_get_name (const dc_contact_t*);
575 uint32_t dc_contact_get_color (const dc_contact_t*);
578 
579 
590 typedef struct _dc_lot dc_lot_t;
591 
592 
593 #define DC_TEXT1_DRAFT 1
594 #define DC_TEXT1_USERNAME 2
595 #define DC_TEXT1_SELF 3
596 
597 
598 dc_lot_t* dc_lot_new ();
599 void dc_lot_empty (dc_lot_t*);
600 void dc_lot_unref (dc_lot_t*);
601 char* dc_lot_get_text1 (const dc_lot_t*);
602 char* dc_lot_get_text2 (const dc_lot_t*);
604 int dc_lot_get_state (const dc_lot_t*);
605 uint32_t dc_lot_get_id (const dc_lot_t*);
606 time_t dc_lot_get_timestamp (const dc_lot_t*);
607 
608 
635 #define DC_MSG_TEXT 10
636 
637 
644 #define DC_MSG_IMAGE 20
645 
646 
652 #define DC_MSG_GIF 21
653 
654 
660 #define DC_MSG_AUDIO 40
661 
662 
669 #define DC_MSG_VOICE 41
670 
671 
680 #define DC_MSG_VIDEO 50
681 
682 
688 #define DC_MSG_FILE 60
689 
711 #define DC_LP_AUTH_NORMAL 0x4
712 
713 
718 #define DC_LP_IMAP_SOCKET_STARTTLS 0x100
719 
720 
725 #define DC_LP_IMAP_SOCKET_SSL 0x200
726 
727 
732 #define DC_LP_IMAP_SOCKET_PLAIN 0x400
733 
734 
739 #define DC_LP_SMTP_SOCKET_STARTTLS 0x10000
740 
741 
746 #define DC_LP_SMTP_SOCKET_SSL 0x20000
747 
748 
753 #define DC_LP_SMTP_SOCKET_PLAIN 0x40000
754 
755 
759 #define DC_LP_AUTH_XOAUTH2 0x2
760 #define DC_LP_AUTH_FLAGS (DC_LP_AUTH_XOAUTH2|DC_LP_AUTH_NORMAL) // if none of these flags are set, the default is choosen
761 #define DC_LP_IMAP_SOCKET_FLAGS (DC_LP_IMAP_SOCKET_STARTTLS|DC_LP_IMAP_SOCKET_SSL|DC_LP_IMAP_SOCKET_PLAIN) // if none of these flags are set, the default is choosen
762 #define DC_LP_SMTP_SOCKET_FLAGS (DC_LP_SMTP_SOCKET_STARTTLS|DC_LP_SMTP_SOCKET_SSL|DC_LP_SMTP_SOCKET_PLAIN) // if none of these flags are set, the default is choosen
763 
764 
765 
790 #define DC_EVENT_INFO 100
791 
792 
801 #define DC_EVENT_SMTP_CONNECTED 101
802 
803 
812 #define DC_EVENT_IMAP_CONNECTED 102
813 
822 #define DC_EVENT_SMTP_MESSAGE_SENT 103
823 
824 
836 #define DC_EVENT_WARNING 300
837 
838 
858 #define DC_EVENT_ERROR 400
859 
860 
882 #define DC_EVENT_ERROR_NETWORK 401
883 
884 
898 #define DC_EVENT_ERROR_SELF_NOT_IN_GROUP 410
899 
900 
912 #define DC_EVENT_MSGS_CHANGED 2000
913 
914 
925 #define DC_EVENT_INCOMING_MSG 2005
926 
927 
936 #define DC_EVENT_MSG_DELIVERED 2010
937 
938 
947 #define DC_EVENT_MSG_FAILED 2012
948 
949 
958 #define DC_EVENT_MSG_READ 2015
959 
960 
971 #define DC_EVENT_CHAT_MODIFIED 2020
972 
973 
981 #define DC_EVENT_CONTACTS_CHANGED 2030
982 
983 
991 #define DC_EVENT_CONFIGURE_PROGRESS 2041
992 
993 
1001 #define DC_EVENT_IMEX_PROGRESS 2051
1002 
1003 
1016 #define DC_EVENT_IMEX_FILE_WRITTEN 2052
1017 
1018 
1034 #define DC_EVENT_SECUREJOIN_INVITER_PROGRESS 2060
1035 
1036 
1050 #define DC_EVENT_SECUREJOIN_JOINER_PROGRESS 2061
1051 
1052 
1053 // the following events are functions that should be provided by the frontends
1054 
1055 
1068 #define DC_EVENT_GET_STRING 2091
1069 
1070 
1084 #define DC_EVENT_HTTP_GET 2100
1085 
1090 #define DC_EVENT_FILE_COPIED 2055 // deprecated
1091 #define DC_EVENT_IS_OFFLINE 2081 // deprecated
1092 #define DC_ERROR_SEE_STRING 0 // deprecated
1093 #define DC_ERROR_SELF_NOT_IN_GROUP 1 // deprecated
1094 #define DC_STR_SELFNOTINGRP 21 // deprecated
1095 #define DC_EVENT_DATA1_IS_STRING(e) ((e)==DC_EVENT_HTTP_GET || (e)==DC_EVENT_IMEX_FILE_WRITTEN || (e)==DC_EVENT_FILE_COPIED)
1096 #define DC_EVENT_DATA2_IS_STRING(e) ((e)>=100 && (e)<=499)
1097 #define DC_EVENT_RETURNS_INT(e) ((e)==DC_EVENT_IS_OFFLINE)
1098 #define DC_EVENT_RETURNS_STRING(e) ((e)==DC_EVENT_GET_STRING || (e)==DC_EVENT_HTTP_GET)
1099 
1100 
1101 /*
1102  * TODO: Strings need some doumentation about used placeholders.
1103  *
1104  * @defgroup DC_STR DC_STR
1105  *
1106  * These constants are used to request strings using #DC_EVENT_GET_STRING.
1107  *
1108  * @addtogroup DC_STR
1109  * @{
1110  */
1111 #define DC_STR_NOMESSAGES 1
1112 #define DC_STR_SELF 2
1113 #define DC_STR_DRAFT 3
1114 #define DC_STR_MEMBER 4
1115 #define DC_STR_CONTACT 6
1116 #define DC_STR_VOICEMESSAGE 7
1117 #define DC_STR_DEADDROP 8
1118 #define DC_STR_IMAGE 9
1119 #define DC_STR_VIDEO 10
1120 #define DC_STR_AUDIO 11
1121 #define DC_STR_FILE 12
1122 #define DC_STR_STATUSLINE 13
1123 #define DC_STR_NEWGROUPDRAFT 14
1124 #define DC_STR_MSGGRPNAME 15
1125 #define DC_STR_MSGGRPIMGCHANGED 16
1126 #define DC_STR_MSGADDMEMBER 17
1127 #define DC_STR_MSGDELMEMBER 18
1128 #define DC_STR_MSGGROUPLEFT 19
1129 #define DC_STR_GIF 23
1130 #define DC_STR_ENCRYPTEDMSG 24
1131 #define DC_STR_E2E_AVAILABLE 25
1132 #define DC_STR_ENCR_TRANSP 27
1133 #define DC_STR_ENCR_NONE 28
1134 #define DC_STR_CANTDECRYPT_MSG_BODY 29
1135 #define DC_STR_FINGERPRINTS 30
1136 #define DC_STR_READRCPT 31
1137 #define DC_STR_READRCPT_MAILBODY 32
1138 #define DC_STR_MSGGRPIMGDELETED 33
1139 #define DC_STR_E2E_PREFERRED 34
1140 #define DC_STR_ARCHIVEDCHATS 40
1141 #define DC_STR_STARREDMSGS 41
1142 #define DC_STR_AC_SETUP_MSG_SUBJECT 42
1143 #define DC_STR_AC_SETUP_MSG_BODY 43
1144 #define DC_STR_SELFTALK_SUBTITLE 50
1145 #define DC_STR_CANNOT_LOGIN 60
1146 #define DC_STR_SERVER_RESPONSE 61
1147 #define DC_STR_COUNT 62
1148 
1149 /*
1150  * @}
1151  */
1152 
1153 
1154 #ifdef __cplusplus
1155 }
1156 #endif
1157 #endif // __DELTACHAT_H__
1158 
dc_context_t * dc_chatlist_get_context(dc_chatlist_t *chatlist)
Helper function to get the associated context object.
Definition: dc_chatlist.c:228
dc_array_t * dc_get_fresh_msgs(dc_context_t *context)
Returns the message IDs of all fresh messages of any chat.
Definition: dc_context.c:712
char * dc_get_contact_encrinfo(dc_context_t *context, uint32_t contact_id)
Get encryption info for a contact.
Definition: dc_contact.c:1307
int dc_chat_is_verified(const dc_chat_t *chat)
Check if a chat is verified.
Definition: dc_chat.c:364
int dc_msg_is_setupmessage(const dc_msg_t *msg)
Check if the message is an Autocrypt Setup Message.
Definition: dc_msg.c:693
dc_array_t * dc_search_msgs(dc_context_t *context, uint32_t chat_id, const char *query)
Search messages containing the given query string.
Definition: dc_context.c:763
dc_array_t * dc_get_blocked_contacts(dc_context_t *context)
Get blocked contacts.
Definition: dc_contact.c:1106
time_t dc_lot_get_timestamp(const dc_lot_t *lot)
Get the associated timestamp.
Definition: dc_lot.c:169
void dc_context_unref(dc_context_t *context)
Free a context object.
Definition: dc_context.c:178
int dc_open(dc_context_t *context, const char *dbfile, const char *blobdir)
Open context database.
Definition: dc_context.c:239
size_t dc_chatlist_get_cnt(const dc_chatlist_t *chatlist)
Find out the number of chats in a chatlist.
Definition: dc_chatlist.c:78
int dc_lot_get_state(const dc_lot_t *lot)
Get the associated state.
Definition: dc_lot.c:133
int dc_msg_is_info(const dc_msg_t *msg)
Check if the message is an informational message, created by the device or by another users...
Definition: dc_msg.c:661
void dc_marknoticed_chat(dc_context_t *context, uint32_t chat_id)
Mark all messages in a chat as noticed.
Definition: dc_chat.c:578
uint32_t dc_join_securejoin(dc_context_t *context, const char *qr)
Join an out-of-band-verification initiated on another device with dc_get_securejoin_qr().
Definition: dc_securejoin.c:403
uint32_t dc_msg_get_from_id(const dc_msg_t *msg)
Get the ID of contact who wrote the message.
Definition: dc_msg.c:127
int dc_msg_get_height(const dc_msg_t *msg)
Get height of image or video.
Definition: dc_msg.c:458
uint32_t dc_create_chat_by_contact_id(dc_context_t *context, uint32_t contact_id)
Create a normal chat with a single user.
Definition: dc_chat.c:718
void dc_msg_set_dimension(dc_msg_t *msg, int width, int height)
Set the dimensions associated with message object.
Definition: dc_msg.c:1052
int dc_add_contact_to_chat(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)
Add a member to a group.
Definition: dc_chat.c:2003
void dc_array_unref(dc_array_t *array)
Free an array object.
Definition: dc_array.c:46
uint32_t dc_msg_get_chat_id(const dc_msg_t *msg)
Get the ID of chat the message belongs to.
Definition: dc_msg.c:146
dc_array_t * dc_get_chat_media(dc_context_t *context, uint32_t chat_id, int msg_type, int or_msg_type)
Returns all message IDs of the given types in a chat.
Definition: dc_chat.c:836
int dc_is_configured(const dc_context_t *context)
Check if the context is already configured.
Definition: dc_configure.c:805
int dc_msg_is_forwarded(const dc_msg_t *msg)
Check if the message is a forwarded message.
Definition: dc_msg.c:636
uint32_t dc_create_group_chat(dc_context_t *context, int verified, const char *chat_name)
Create a new group chat.
Definition: dc_chat.c:1667
void dc_interrupt_smtp_idle(dc_context_t *context)
Interrupt waiting for smtp-jobs.
Definition: dc_job.c:908
An object representing a single chatlist in memory.
char * dc_chat_get_profile_image(const dc_chat_t *chat)
Get the chat's profile image.
Definition: dc_chat.c:231
dc_array_t * dc_get_chat_msgs(dc_context_t *context, uint32_t chat_id, uint32_t flags, uint32_t marker1before)
Get all message IDs belonging to a chat.
Definition: dc_chat.c:987
An object representing a single account.
An object representing a single contact in memory.
void dc_imex(dc_context_t *context, int what, const char *param1, const char *param2)
Import/export things.
Definition: dc_imex.c:1115
void dc_star_msgs(dc_context_t *context, 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: dc_msg.c:1573
char * dc_imex_has_backup(dc_context_t *context, const char *dir_name)
Check if there is a backup file.
Definition: dc_imex.c:1266
char * dc_msg_get_file(const dc_msg_t *msg)
Find out full path, file name and extension of the file associated with a message.
Definition: dc_msg.c:301
char * dc_contact_get_profile_image(const dc_contact_t *contact)
Get the contact's profile image.
Definition: dc_contact.c:225
int dc_set_chat_profile_image(dc_context_t *context, uint32_t chat_id, const char *new_image)
Set group profile image.
Definition: dc_chat.c:1802
int dc_contact_is_blocked(const dc_contact_t *contact)
Check if a contact is blocked.
Definition: dc_contact.c:278
dc_chatlist_t * dc_get_chatlist(dc_context_t *context, int listflags, const char *query_str, uint32_t query_id)
Get a list of chats.
Definition: dc_chatlist.c:448
dc_msg_t * dc_get_msg(dc_context_t *context, uint32_t msg_id)
Get a single message object of the type dc_msg_t.
Definition: dc_msg.c:1323
char * dc_lot_get_text1(const dc_lot_t *lot)
Get first string.
Definition: dc_lot.c:79
uint32_t dc_lookup_contact_id_by_addr(dc_context_t *context, const char *addr)
Check if an e-mail address belongs to a known and unblocked contact.
Definition: dc_contact.c:970
char * dc_lot_get_text2(const dc_lot_t *lot)
Get second string.
Definition: dc_lot.c:97
int dc_remove_contact_from_chat(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)
Remove a member from a group.
Definition: dc_chat.c:2023
char * dc_get_blobdir(const dc_context_t *context)
Get the blob directory.
Definition: dc_context.c:338
uint32_t dc_msg_get_id(const dc_msg_t *msg)
Get the ID of the message.
Definition: dc_msg.c:104
char * dc_msg_get_text(const dc_msg_t *msg)
Get the text of the message.
Definition: dc_msg.c:274
uint64_t dc_msg_get_filebytes(const dc_msg_t *msg)
Get the size of the file.
Definition: dc_msg.c:399
int dc_msg_is_sent(const dc_msg_t *msg)
Check if a message was sent successfully.
Definition: dc_msg.c:590
void dc_set_draft(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)
Save a draft for a chat in the database.
Definition: dc_chat.c:1199
int dc_add_address_book(dc_context_t *context, const char *adr_book)
Add a number of contacts.
Definition: dc_contact.c:883
An object containing a simple array.
int dc_chat_get_type(const dc_chat_t *chat)
Get chat type.
Definition: dc_chat.c:129
void dc_block_contact(dc_context_t *context, uint32_t contact_id, int new_blocking)
Block or unblock a contact.
Definition: dc_contact.c:1225
void dc_perform_smtp_jobs(dc_context_t *context)
Execute pending smtp-jobs.
Definition: dc_job.c:803
uint32_t dc_contact_get_id(const dc_contact_t *contact)
Get the ID of the contact.
Definition: dc_contact.c:92
void dc_chat_unref(dc_chat_t *chat)
Free a chat object.
Definition: dc_chat.c:45
int dc_lot_get_text1_meaning(const dc_lot_t *lot)
Get the meaning of the first string.
Definition: dc_lot.c:115
An object representing a single chat in memory.
char * dc_contact_get_first_name(const dc_contact_t *contact)
Get the part of the name before the first space.
Definition: dc_contact.c:200
char * dc_get_info(dc_context_t *context)
Get information about the context.
Definition: dc_context.c:564
An object representing a single message in memory.
void * dc_array_get_ptr(const dc_array_t *array, size_t index)
Get the item at the given index as an ID.
Definition: dc_array.c:288
dc_context_t * dc_context_new(dc_callback_t cb, void *userdata, const char *os_name)
Create a new context object.
Definition: dc_context.c:123
int dc_msg_is_increation(const dc_msg_t *msg)
Check if a message is still in creation.
Definition: dc_msg.c:959
dc_msg_t * dc_get_draft(dc_context_t *context, uint32_t chat_id)
Get draft for a chat, if any.
Definition: dc_chat.c:1223
int dc_is_open(const dc_context_t *context)
Check if the context database is open.
Definition: dc_context.c:320
char * dc_get_msg_info(dc_context_t *context, uint32_t msg_id)
Get an informational text for a single message.
Definition: dc_msg.c:1361
int dc_may_be_valid_addr(const char *addr)
Rough check if a string may be a valid e-mail address.
Definition: dc_contact.c:938
void dc_chatlist_unref(dc_chatlist_t *chatlist)
Free a chatlist object.
Definition: dc_chatlist.c:40
void dc_forward_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt, uint32_t chat_id)
Forward messages to another chat.
Definition: dc_chat.c:2539
uint32_t dc_chat_get_id(const dc_chat_t *chat)
Get chat ID.
Definition: dc_chat.c:100
int dc_msg_get_duration(const dc_msg_t *msg)
Get the duration of audio or video.
Definition: dc_msg.c:478
uint32_t dc_get_next_media(dc_context_t *context, uint32_t curr_msg_id, int dir)
Get next/previous message of the same type.
Definition: dc_chat.c:872
char * dc_msg_get_filename(const dc_msg_t *msg)
Get base file name without path.
Definition: dc_msg.c:330
int dc_msg_get_viewtype(const dc_msg_t *msg)
Get the type of the message.
Definition: dc_msg.c:163
uintptr_t dc_array_get_uint(const dc_array_t *array, size_t index)
Get the item at the given index as an unsigned integer.
Definition: dc_array.c:252
uint32_t dc_array_get_id(const dc_array_t *array, size_t index)
Get the item at the given index as an ID.
Definition: dc_array.c:270
void * dc_get_userdata(dc_context_t *context)
Get user data associated with a context object.
Definition: dc_context.c:215
uintptr_t(* dc_callback_t)(dc_context_t *, int event, uintptr_t data1, uintptr_t data2)
Callback function that should be given to dc_context_new().
Definition: deltachat.h:214
void dc_openssl_init_not_required(void)
Skip OpenSSL initialisation.
Definition: dc_openssl.c:30
void dc_perform_imap_idle(dc_context_t *context)
Wait for messages or jobs.
Definition: dc_job.c:705
char * dc_chat_get_name(const dc_chat_t *chat)
Get name of a chat.
Definition: dc_chat.c:151
int dc_contact_is_verified(dc_contact_t *contact)
Check if a contact was verified.
Definition: dc_contact.c:335
void dc_delete_chat(dc_context_t *context, uint32_t chat_id)
Delete a chat.
Definition: dc_chat.c:1525
void dc_perform_imap_fetch(dc_context_t *context)
Fetch new messages, if any.
Definition: dc_job.c:670
void dc_markseen_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt)
Mark a message as seen, updates the IMAP state and sends MDNs.
Definition: dc_msg.c:1724
dc_chat_t * dc_get_chat(dc_context_t *context, uint32_t chat_id)
Get chat object by a chat ID.
Definition: dc_chat.c:538
char * dc_msg_get_filemime(const dc_msg_t *msg)
Get mime type of the file.
Definition: dc_msg.c:361
int dc_msg_get_state(const dc_msg_t *msg)
Get the state of a message.
Definition: dc_msg.c:199
char * dc_chat_get_subtitle(const dc_chat_t *chat)
Get a subtitle for a chat.
Definition: dc_chat.c:171
dc_array_t * dc_get_contacts(dc_context_t *context, uint32_t listflags, const char *query)
Returns known and unblocked contacts.
Definition: dc_contact.c:1024
void dc_msg_set_duration(dc_msg_t *msg, int duration)
Set the duration associated with message object.
Definition: dc_msg.c:1072
dc_lot_t * dc_msg_get_summary(const dc_msg_t *msg, const dc_chat_t *chat)
Get a summary for a message.
Definition: dc_msg.c:530
uint32_t dc_create_contact(dc_context_t *context, const char *name, const char *addr)
Add a single contact as a result of an explicit user action.
Definition: dc_contact.c:835
int dc_is_contact_in_chat(dc_context_t *context, uint32_t chat_id, uint32_t contact_id)
Check if a given contact ID is a member of a group chat.
Definition: dc_chat.c:1882
char * dc_initiate_key_transfer(dc_context_t *context)
Initiate Autocrypt Setup Transfer.
Definition: dc_imex.c:444
uint32_t dc_send_text_msg(dc_context_t *context, uint32_t chat_id, const char *text_to_send)
Send a simple text message a given chat.
Definition: dc_chat.c:2473
dc_msg_t * dc_msg_new(dc_context_t *context, int viewtype)
Create new message object.
Definition: dc_msg.c:23
void dc_marknoticed_contact(dc_context_t *context, uint32_t contact_id)
Mark all messages sent by the given contact as noticed.
Definition: dc_contact.c:1168
size_t dc_array_get_cnt(const dc_array_t *array)
Find out the number of items in an array.
Definition: dc_array.c:233
time_t dc_msg_get_received_timestamp(const dc_msg_t *msg)
Get message receive time.
Definition: dc_msg.c:245
char * dc_contact_get_addr(const dc_contact_t *contact)
Get email address.
Definition: dc_contact.c:108
void dc_close(dc_context_t *context)
Close context database opened by dc_open().
Definition: dc_context.c:292
char * dc_get_config(dc_context_t *context, const char *key)
Get a configuration option.
Definition: dc_context.c:498
void dc_interrupt_imap_idle(dc_context_t *context)
Interrupt waiting for imap-jobs.
Definition: dc_job.c:767
uint32_t dc_send_msg(dc_context_t *context, uint32_t chat_id, dc_msg_t *msg)
Send a message defined by a dc_msg_t object to a chat.
Definition: dc_chat.c:2375
dc_lot_t * dc_chatlist_get_summary(const dc_chatlist_t *chatlist, size_t index, dc_chat_t *chat)
Get a summary for a chatlist index.
Definition: dc_chatlist.c:156
int dc_msg_get_showpadlock(const dc_msg_t *msg)
Check if a padlock should be shown beside the message.
Definition: dc_msg.c:494
char * dc_msg_get_setupcodebegin(const dc_msg_t *msg)
Get the first characters of the setup code.
Definition: dc_msg.c:717
char * dc_get_mime_headers(dc_context_t *context, uint32_t msg_id)
Get the raw mime-headers of the given message.
Definition: dc_msg.c:1539
uint32_t dc_chatlist_get_msg_id(const dc_chatlist_t *chatlist, size_t index)
Get a single message ID of a chatlist.
Definition: dc_chatlist.c:120
uint32_t dc_create_chat_by_msg_id(dc_context_t *context, uint32_t msg_id)
Create a normal chat or a group chat by a messages ID that comes typically from the deaddrop...
Definition: dc_chat.c:783
void dc_delete_msgs(dc_context_t *context, const uint32_t *msg_ids, int msg_cnt)
Delete messages.
Definition: dc_msg.c:1685
int dc_chat_is_unpromoted(const dc_chat_t *chat)
Check if a group chat is still unpromoted.
Definition: dc_chat.c:346
int dc_get_msg_cnt(dc_context_t *context, uint32_t chat_id)
Get the total number of messages in a chat.
Definition: dc_chat.c:1360
uint32_t dc_get_chat_id_by_contact_id(dc_context_t *context, uint32_t contact_id)
Check, if there is a normal chat with a given contact.
Definition: dc_chat.c:662
int dc_get_blocked_cnt(dc_context_t *context)
Get the number of blocked contacts.
Definition: dc_contact.c:1191
char * dc_get_securejoin_qr(dc_context_t *context, uint32_t group_chat_id)
Get QR code text that will offer an secure-join verification.
Definition: dc_securejoin.c:300
char * dc_contact_get_name(const dc_contact_t *contact)
Get the contact name.
Definition: dc_contact.c:129
int dc_msg_is_starred(const dc_msg_t *msg)
Check if a message is starred.
Definition: dc_msg.c:611
uint32_t dc_chatlist_get_chat_id(const dc_chatlist_t *chatlist, size_t index)
Get a single chat ID of a chatlist.
Definition: dc_chatlist.c:99
dc_lot_t * dc_check_qr(dc_context_t *context, const char *qr)
Check a scanned QR code.
Definition: dc_qr.c:37
int dc_chat_get_archived(const dc_chat_t *chat)
Get archived state.
Definition: dc_chat.c:317
int dc_msg_get_width(const dc_msg_t *msg)
Get width of image or video.
Definition: dc_msg.c:435
uint32_t dc_lot_get_id(const dc_lot_t *lot)
Get the associated ID.
Definition: dc_lot.c:149
void dc_marknoticed_all_chats(dc_context_t *context)
Same as dc_marknoticed_chat() but for all chats.
Definition: dc_chat.c:622
An object containing a set of values.
void dc_msg_set_text(dc_msg_t *msg, const char *text)
Set the text of a message object.
Definition: dc_msg.c:1008
void dc_perform_imap_jobs(dc_context_t *context)
Execute pending imap-jobs.
Definition: dc_job.c:642
dc_array_t * dc_get_chat_contacts(dc_context_t *context, uint32_t chat_id)
Get contact IDs belonging to a chat.
Definition: dc_chat.c:937
time_t dc_msg_get_timestamp(const dc_msg_t *msg)
Get message sending time.
Definition: dc_msg.c:224
int dc_get_fresh_msg_cnt(dc_context_t *context, uint32_t chat_id)
Get the number of fresh messages in a chat.
Definition: dc_chat.c:1403
void dc_archive_chat(dc_context_t *context, uint32_t chat_id, int archive)
Archive or unarchive a chat.
Definition: dc_chat.c:1450
uint32_t dc_chat_get_color(const dc_chat_t *chat)
Get a color for the chat.
Definition: dc_chat.c:274
dc_contact_t * dc_get_contact(dc_context_t *context, uint32_t contact_id)
Get a single contact object.
Definition: dc_contact.c:1143
char * dc_contact_get_name_n_addr(const dc_contact_t *contact)
Get a summary of name and address.
Definition: dc_contact.c:177
int dc_continue_key_transfer(dc_context_t *context, uint32_t msg_id, const char *setup_code)
Continue the Autocrypt Key Transfer on another device.
Definition: dc_imex.c:613
void dc_maybe_network(dc_context_t *context)
This function can be called whenever there is a hint that the network is available again...
Definition: dc_job.c:941
void dc_contact_unref(dc_contact_t *contact)
Free a contact object.
Definition: dc_contact.c:42
void dc_msg_unref(dc_msg_t *msg)
Free a message object.
Definition: dc_msg.c:55
int dc_set_config(dc_context_t *context, const char *key, const char *value)
Configure the context.
Definition: dc_context.c:449
void dc_perform_smtp_idle(dc_context_t *context)
Wait for smtp-jobs.
Definition: dc_job.c:839
const uintptr_t * dc_array_get_raw(const dc_array_t *array)
Get raw pointer to the data.
Definition: dc_array.c:337
int dc_delete_contact(dc_context_t *context, uint32_t contact_id)
Delete a contact.
Definition: dc_contact.c:1398
uint32_t dc_contact_get_color(const dc_contact_t *contact)
Get a color for the contact.
Definition: dc_contact.c:259
void dc_msg_set_file(dc_msg_t *msg, const char *file, const char *filemime)
Set the file associated with a message object.
Definition: dc_msg.c:1031
int dc_check_password(dc_context_t *context, const char *test_pw)
Check if the user is authorized by the given password in some way.
Definition: dc_imex.c:1330
int dc_chat_is_self_talk(const dc_chat_t *chat)
Check if a chat is a self talk.
Definition: dc_chat.c:381
int dc_set_chat_name(dc_context_t *context, uint32_t chat_id, const char *new_name)
Set group name.
Definition: dc_chat.c:1731
char * dc_msg_get_summarytext(const dc_msg_t *msg, int approx_characters)
Get a message summary as a single line of text.
Definition: dc_msg.c:570
void dc_lot_unref(dc_lot_t *set)
Frees an object containing a set of parameters.
Definition: dc_lot.c:32
char * dc_contact_get_display_name(const dc_contact_t *contact)
Get display name.
Definition: dc_contact.c:150
void dc_configure(dc_context_t *context)
Configure a context.
Definition: dc_configure.c:782
void dc_stop_ongoing_process(dc_context_t *context)
Signal an ongoing process to stop.
Definition: dc_configure.c:886
void dc_msg_latefiling_mediasize(dc_msg_t *msg, int width, int height, int duration)
Late filing information to a message.
Definition: dc_msg.c:1103