Delta Chat Core C-API
dc_msg.h
1 #ifndef __DC_MSG_H__
2 #define __DC_MSG_H__
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 
8 #include "dc_param.h"
9 
10 
11 typedef enum {
12  DC_MOVE_STATE_UNDEFINED = 0
13  ,DC_MOVE_STATE_PENDING = 1
14  ,DC_MOVE_STATE_STAY = 2
15  ,DC_MOVE_STATE_MOVING = 3
16 } dc_move_state_t;
17 
18 
20 struct _dc_msg
21 {
24  uint32_t magic;
25 
29  uint32_t id;
30 
31 
36  uint32_t from_id;
37 
38 
43  uint32_t to_id;
44 
45 
50  uint32_t chat_id;
51 
52  dc_move_state_t move_state;
53 
54  int type;
56  int state;
58  int hidden;
60  time_t timestamp_sort;
61  time_t timestamp_sent;
62  time_t timestamp_rcvd;
64  char* text;
66  dc_context_t* context;
67  char* rfc724_mid;
68  char* in_reply_to;
69  char* server_folder;
70  uint32_t server_uid;
71  int is_dc_message;
72  int starred;
73  int chat_blocked;
74  dc_param_t* param;
75 };
76 
77 
78 dc_msg_t* dc_msg_new_untyped (dc_context_t*);
79 dc_msg_t* dc_msg_new_load (dc_context_t*, uint32_t id);
80 int dc_msg_load_from_db (dc_msg_t*, dc_context_t*, uint32_t id);
81 int dc_msg_is_increation (const dc_msg_t*);
82 char* dc_msg_get_summarytext_by_raw (int type, const char* text, dc_param_t*, int approx_bytes, dc_context_t*); /* the returned value must be free()'d */
83 void dc_msg_save_param_to_disk (dc_msg_t*);
84 void dc_msg_guess_msgtype_from_suffix (const char* pathNfilename, int* ret_msgtype, char** ret_mime);
85 
86 void dc_delete_msg_from_db (dc_context_t*, uint32_t);
87 
88 #define DC_MSG_NEEDS_ATTACHMENT(a) ((a)==DC_MSG_IMAGE || (a)==DC_MSG_GIF || (a)==DC_MSG_AUDIO || (a)==DC_MSG_VOICE || (a)==DC_MSG_VIDEO || (a)==DC_MSG_FILE)
89 
90 
91 /* as we do not cut inside words, this results in about 32-42 characters.
92 Do not use too long subjects - we add a tag after the subject which gets truncated by the clients otherwise.
93 It should also be very clear, the subject is _not_ the whole message.
94 The value is also used for CC:-summaries */
95 #define DC_APPROX_SUBJECT_CHARS 32
96 
97 
98 // Context functions to work with messages
99 void dc_update_msg_chat_id (dc_context_t*, uint32_t msg_id, uint32_t chat_id);
100 void dc_update_msg_state (dc_context_t*, uint32_t msg_id, int state);
101 void dc_update_msg_move_state (dc_context_t*, const char* rfc724_mid, dc_move_state_t);
102 void dc_set_msg_failed (dc_context_t*, uint32_t msg_id, const char* error);
103 int dc_mdn_from_ext (dc_context_t*, uint32_t from_id, const char* rfc724_mid, time_t, uint32_t* ret_chat_id, uint32_t* ret_msg_id); /* returns 1 if an event should be send */
104 size_t dc_get_real_msg_cnt (dc_context_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
105 size_t dc_get_deaddrop_msg_cnt (dc_context_t*);
106 int dc_rfc724_mid_cnt (dc_context_t*, const char* rfc724_mid);
107 uint32_t dc_rfc724_mid_exists (dc_context_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
108 void dc_update_server_uid (dc_context_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
109 
110 
111 #ifdef __cplusplus
112 } /* /extern "C" */
113 #endif
114 #endif /* __DC_MSG_H__ */
An object representing a single account.
An object representing a single message in memory.