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* imap_server;
38  int imap_port;
39  char* imap_user;
40  char* imap_pw;
41  int server_flags;
42 
43  int connected;
44  mailimap* etpan; /* normally, if connected, etpan is also set; however, if a reconnection is required, we may lost this handle */
45 
46  int idle_set_up;
47  char* selected_folder;
48  int selected_folder_needs_expunge;
49  int should_reconnect;
50 
51  int can_idle;
52  int has_xlist;
53  char imap_delimiter;/* IMAP Path separator. Set as a side-effect during configure() */
54 
55  char* watch_folder;
56  pthread_cond_t watch_cond;
57  pthread_mutex_t watch_condmutex;
58  int watch_condflag;
59 
60  struct mailimap_fetch_type* fetch_type_prefetch;
61  struct mailimap_fetch_type* fetch_type_body;
62  struct mailimap_fetch_type* fetch_type_flags;
63 
64  dc_get_config_t get_config;
65  dc_set_config_t set_config;
66  dc_precheck_imf_t precheck_imf;
67  dc_receive_imf_t receive_imf;
68  void* userData;
69  dc_context_t* context;
70 
71  int log_connect_errors;
72  int skip_log_capabilities;
73 
74 };
75 
76 
77 typedef enum {
78  DC_FAILED = 0
79  ,DC_RETRY_LATER = 1
80  ,DC_ALREADY_DONE = 2
81  ,DC_SUCCESS = 3
82 } dc_imap_res;
83 
84 
85 dc_imap_t* dc_imap_new (dc_get_config_t, dc_set_config_t,
86  dc_precheck_imf_t, dc_receive_imf_t,
87  void* userData, dc_context_t*);
88 void dc_imap_unref (dc_imap_t*);
89 
90 int dc_imap_connect (dc_imap_t*, const dc_loginparam_t*);
91 void dc_imap_set_watch_folder (dc_imap_t*, const char* watch_folder);
92 void dc_imap_disconnect (dc_imap_t*);
93 int dc_imap_is_connected (const dc_imap_t*);
94 int dc_imap_fetch (dc_imap_t*);
95 
96 void dc_imap_idle (dc_imap_t*);
97 void dc_imap_interrupt_idle (dc_imap_t*);
98 
99 dc_imap_res dc_imap_move (dc_imap_t*, const char* folder, uint32_t uid,
100  const char* dest_folder, uint32_t* dest_uid);
101 dc_imap_res dc_imap_set_seen (dc_imap_t*, const char* folder, uint32_t uid);
102 dc_imap_res dc_imap_set_mdnsent (dc_imap_t*, const char* folder, uint32_t uid);
103 
104 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 */
105 
106 int dc_imap_is_error (dc_imap_t* imap, int code);
107 
108 
109 #ifdef __cplusplus
110 } /* /extern "C" */
111 #endif
112 #endif // __DC_IMAP_H__
113 
An object representing a single account.