Delta Chat Core C-API
dc_imap.h
1 /* Purpose: Reading from IMAP servers with no dependencies to the database.
2 dc_context_t is only used for logging and to get information about
3 the online state. */
4 
5 
6 #ifndef __DC_IMAP_H__
7 #define __DC_IMAP_H__
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 
13 #include "dc_loginparam.h"
14 
15 
16 typedef struct _dc_imap dc_imap_t;
17 
18 
19 typedef char* (*dc_get_config_t) (dc_imap_t*, const char*, const char*);
20 typedef void (*dc_set_config_t) (dc_imap_t*, const char*, const char*);
21 
22 typedef int (*dc_precheck_imf_t) (dc_imap_t*, const char* rfc724_mid,
23  const char* server_folder,
24  uint32_t server_uid);
25 
26 #define DC_IMAP_SEEN 0x0001L
27 typedef void (*dc_receive_imf_t) (dc_imap_t*, const char* imf_raw_not_terminated, size_t imf_raw_bytes, const char* server_folder, uint32_t server_uid, uint32_t flags);
28 
29 
33 struct _dc_imap
34 {
37  char* addr;
38  char* imap_server;
39  int imap_port;
40  char* imap_user;
41  char* imap_pw;
42  int server_flags;
43 
44  int connected;
45  mailimap* etpan; /* normally, if connected, etpan is also set; however, if a reconnection is required, we may lost this handle */
46 
47  int idle_set_up;
48  char* selected_folder;
49  int selected_folder_needs_expunge;
50  int should_reconnect;
51 
52  int can_idle;
53  int has_xlist;
54  char imap_delimiter;/* IMAP Path separator. Set as a side-effect during configure() */
55 
56  char* watch_folder;
57  pthread_cond_t watch_cond;
58  pthread_mutex_t watch_condmutex;
59  int watch_condflag;
60 
61  struct mailimap_fetch_type* fetch_type_prefetch;
62  struct mailimap_fetch_type* fetch_type_body;
63  struct mailimap_fetch_type* fetch_type_flags;
64 
65  dc_get_config_t get_config;
66  dc_set_config_t set_config;
67  dc_precheck_imf_t precheck_imf;
68  dc_receive_imf_t receive_imf;
69  void* userData;
70  dc_context_t* context;
71 
72  int log_connect_errors;
73  int skip_log_capabilities;
74 
75 };
76 
77 
78 typedef enum {
79  DC_FAILED = 0
80  ,DC_RETRY_LATER = 1
81  ,DC_ALREADY_DONE = 2
82  ,DC_SUCCESS = 3
83 } dc_imap_res;
84 
85 
86 dc_imap_t* dc_imap_new (dc_get_config_t, dc_set_config_t,
87  dc_precheck_imf_t, dc_receive_imf_t,
88  void* userData, dc_context_t*);
89 void dc_imap_unref (dc_imap_t*);
90 
91 int dc_imap_connect (dc_imap_t*, const dc_loginparam_t*);
92 void dc_imap_set_watch_folder (dc_imap_t*, const char* watch_folder);
93 void dc_imap_disconnect (dc_imap_t*);
94 int dc_imap_is_connected (const dc_imap_t*);
95 int dc_imap_fetch (dc_imap_t*);
96 
97 void dc_imap_idle (dc_imap_t*);
98 void dc_imap_interrupt_idle (dc_imap_t*);
99 
100 dc_imap_res dc_imap_move (dc_imap_t*, const char* folder, uint32_t uid,
101  const char* dest_folder, uint32_t* dest_uid);
102 dc_imap_res dc_imap_set_seen (dc_imap_t*, const char* folder, uint32_t uid);
103 dc_imap_res dc_imap_set_mdnsent (dc_imap_t*, const char* folder, uint32_t uid);
104 
105 int dc_imap_delete_msg (dc_imap_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 */
106 void dc_imap_empty_folder (dc_imap_t*, const char* folder);
107 
108 int dc_imap_is_error (dc_imap_t* imap, int code);
109 
110 
111 #ifdef __cplusplus
112 } /* /extern "C" */
113 #endif
114 #endif // __DC_IMAP_H__
115 
dc_context_t