Delta Chat Core C-API
dc_job.h
1 #ifndef __DC_JOB_H__
2 #define __DC_JOB_H__
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 
8 // thread IDs
9 #define DC_IMAP_THREAD 100
10 #define DC_SMTP_THREAD 5000
11 
12 
13 // jobs in the INBOX-thread, range from DC_IMAP_THREAD..DC_IMAP_THREAD+999
14 #define DC_JOB_HOUSEKEEPING 105 // low priority ...
15 #define DC_JOB_EMPTY_SERVER 107
16 #define DC_JOB_DELETE_MSG_ON_IMAP 110
17 #define DC_JOB_MARKSEEN_MDN_ON_IMAP 120
18 #define DC_JOB_MARKSEEN_MSG_ON_IMAP 130
19 #define DC_JOB_MOVE_MSG 200
20 #define DC_JOB_CONFIGURE_IMAP 900
21 #define DC_JOB_IMEX_IMAP 910 // ... high priority
22 
23 
24 // jobs in the SMTP-thread, range from DC_SMTP_THREAD..DC_SMTP_THREAD+999
25 #define DC_JOB_MAYBE_SEND_LOCATIONS 5005 // low priority ...
26 #define DC_JOB_MAYBE_SEND_LOC_ENDED 5007
27 #define DC_JOB_SEND_MDN_OLD 5010
28 #define DC_JOB_SEND_MDN 5011
29 #define DC_JOB_SEND_MSG_TO_SMTP_OLD 5900
30 #define DC_JOB_SEND_MSG_TO_SMTP 5901 // ... high priority
31 
32 
33 // timeouts until actions are aborted.
34 // this may also affects IDLE to return, so a re-connect may take this time.
35 // mailcore2 uses 30 seconds, k-9 uses 10 seconds
36 #define DC_IMAP_TIMEOUT_SEC 10
37 #define DC_SMTP_TIMEOUT_SEC 10
38 
39 
40 typedef struct _dc_job dc_job_t;
41 
45 struct _dc_job
46 {
49  uint32_t job_id;
50  int action;
51  uint32_t foreign_id;
52  time_t desired_timestamp;
53  time_t added_timestamp;
54  int tries;
55  dc_param_t* param;
56 
57  int try_again;
58  char* pending_error; // discarded if the retry succeeds
59 };
60 
61 
62 void dc_job_add (dc_context_t*, int action, int foreign_id, const char* param, int delay);
63 int dc_job_action_exists (dc_context_t*, int action);
64 void dc_job_kill_action (dc_context_t*, int action); /* delete all pending jobs with the given action */
65 
66 int dc_job_send_msg (dc_context_t*, uint32_t msg_id); /* special case for DC_JOB_SEND_MSG_TO_SMTP */
67 
68 #define DC_DONT_TRY_AGAIN 0
69 #define DC_AT_ONCE -1
70 #define DC_INCREATION_POLL 2 // this value does not increase the number of tries
71 #define DC_STANDARD_DELAY 3
72 void dc_job_try_again_later (dc_job_t*, int try_again, const char* error);
73 
74 
75 // the other dc_job_do_DC_JOB_*() functions are declared static in the c-file
76 void dc_job_do_DC_JOB_CONFIGURE_IMAP (dc_context_t*, dc_job_t*);
77 void dc_job_do_DC_JOB_IMEX_IMAP (dc_context_t*, dc_job_t*);
78 
79 
80 #ifdef __cplusplus
81 } /* /extern "C" */
82 #endif
83 #endif /* __DC_JOB_H__ */
84 
dc_context_t