1 #ifndef __DC_CONTEXT_H__
2 #define __DC_CONTEXT_H__
17 #include <libetpan/libetpan.h>
18 #include "deltachat.h"
19 #include "dc_sqlite3.h"
21 #include "dc_strbuilder.h"
22 #include "dc_strencode.h"
27 #include "dc_chatlist.h"
30 #include "dc_contact.h"
31 #include "dc_jobthread.h"
35 #include "dc_mimeparser.h"
43 #define DC_CONTEXT_MAGIC 0x11a11807
54 pthread_mutex_t inboxidle_condmutex;
55 int perform_inbox_jobs_needed;
56 int probe_imap_network;
58 dc_jobthread_t sentbox_thread;
59 dc_jobthread_t mvbox_thread;
62 pthread_cond_t smtpidle_cond;
63 pthread_mutex_t smtpidle_condmutex;
64 int smtpidle_condflag;
67 #define DC_JOBS_NEEDED_AT_ONCE 1
68 #define DC_JOBS_NEEDED_AVOID_DOS 2
69 int perform_smtp_jobs_needed;
70 int probe_smtp_network;
72 pthread_mutex_t oauth2_critical;
78 uint32_t cmdline_sel_chat_id;
81 #define DC_VC_AUTH_REQUIRED 2
82 #define DC_VC_CONTACT_CONFIRM 6
84 #define DC_BOB_ERROR 0
85 #define DC_BOB_SUCCESS 1
88 pthread_mutex_t bobs_qr_critical;
91 time_t last_smeared_timestamp;
92 pthread_mutex_t smear_critical;
96 int shall_stop_ongoing;
99 void dc_log_event (
dc_context_t*,
int event_code,
int data1,
const char* msg, ...);
100 void dc_log_event_seq (
dc_context_t*,
int event_code,
int* sequence_start,
const char* msg, ...);
101 void dc_log_error (
dc_context_t*,
int data1,
const char* msg, ...);
102 void dc_log_warning (
dc_context_t*,
int data1,
const char* msg, ...);
103 void dc_log_info (
dc_context_t*,
int data1,
const char* msg, ...);
105 void dc_receive_imf (
dc_context_t*,
const char* imf_raw_not_terminated,
size_t imf_raw_bytes,
const char* server_folder, uint32_t server_uid, uint32_t flags);
107 #define DC_NOT_CONNECTED 0
108 #define DC_ALREADY_CONNECTED 1
109 #define DC_JUST_CONNECTED 2
110 int dc_connect_to_configured_imap (
dc_context_t*, dc_imap_t*);
112 #define DC_CREATE_MVBOX 0x01
113 #define DC_FOLDERS_CONFIGURED_VERSION 3
114 void dc_configure_folders (
dc_context_t*, dc_imap_t*,
int flags);
117 void dc_do_heuristics_moves(
dc_context_t*,
const char* folder, uint32_t msg_id);
126 typedef struct _dc_location
128 #define DC_ARRAY_LOCATIONS 1
129 uint32_t location_id;
141 typedef struct _dc_kml
149 char* dc_get_location_kml (
dc_context_t*, uint32_t chat_id, uint32_t* last_added_location_id);
150 char* dc_get_message_kml (
dc_context_t*, time_t timestamp,
double latitude,
double longitude);
151 void dc_set_kml_sent_timestamp (
dc_context_t*, uint32_t chat_id, time_t);
152 void dc_set_msg_location_id (
dc_context_t*, uint32_t msg_id, uint32_t location_id);
153 uint32_t dc_save_locations (
dc_context_t*, uint32_t chat_id, uint32_t contact_id,
const dc_array_t*,
int independent);
154 dc_kml_t* dc_kml_parse (
dc_context_t*,
const char* content,
size_t content_bytes);
155 void dc_kml_unref (dc_kml_t*);
156 void dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS (
dc_context_t*, dc_job_t*);
157 void dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED (
dc_context_t*, dc_job_t*);
161 #define DC_BAK_PREFIX "delta-chat"
162 #define DC_BAK_SUFFIX "bak"
169 #define DC_MSGSIZE_MAX_RECOMMENDED ((24*1024*1024)/4*3)
170 #define DC_MSGSIZE_UPPER_LIMIT ((49*1024*1024)/4*3)
174 #define DC_E2EE_DEFAULT_ENABLED 1
175 #define DC_MDNS_DEFAULT_ENABLED 1
176 #define DC_INBOX_WATCH_DEFAULT 1
177 #define DC_SENTBOX_WATCH_DEFAULT 1
178 #define DC_MVBOX_WATCH_DEFAULT 1
179 #define DC_MVBOX_MOVE_DEFAULT 1
180 #define DC_SHOW_EMAILS_DEFAULT DC_SHOW_EMAILS_OFF
183 typedef struct _dc_e2ee_helper dc_e2ee_helper_t;
187 struct _dc_e2ee_helper {
189 int encryption_successfull;
194 dc_hash_t* signatures;
195 dc_hash_t* gossipped_addr;
199 void dc_e2ee_encrypt (
dc_context_t*,
const clist* recipients_addr,
200 int force_plaintext,
int e2ee_guaranteed,
int min_verified,
201 int do_gossip,
struct mailmime* in_out_message, dc_e2ee_helper_t*);
202 void dc_e2ee_decrypt (
dc_context_t*,
struct mailmime* in_out_message, dc_e2ee_helper_t*);
203 void dc_e2ee_thanks (dc_e2ee_helper_t*);
206 char* dc_normalize_setup_code(
dc_context_t*,
const char* passphrase);
207 char* dc_render_setup_file (
dc_context_t*,
const char* passphrase);
208 char* dc_decrypt_setup_file(
dc_context_t*,
const char* passphrase,
const char* filecontent);
210 extern int dc_shall_stop_ongoing;
216 #define DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING 0x01
217 #define DC_HANDSHAKE_STOP_NORMAL_PROCESSING 0x02
218 #define DC_HANDSHAKE_ADD_DELETE_JOB 0x04
219 int dc_handle_securejoin_handshake(
dc_context_t*, dc_mimeparser_t*, uint32_t contact_id);
220 void dc_handle_degrade_event (
dc_context_t*, dc_apeerstate_t*);
223 #define DC_OPENPGP4FPR_SCHEME "OPENPGP4FPR:"
227 void dc_add_to_keyhistory(
dc_context_t*,
const char* rfc724_mid, time_t,
const char* addr,
const char* fingerprint);