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  uint32_t location_id;
75  dc_param_t* param;
76 };
77 
78 
79 dc_msg_t* dc_msg_new_untyped (dc_context_t*);
80 dc_msg_t* dc_msg_new_load (dc_context_t*, uint32_t id);
81 int dc_msg_load_from_db (dc_msg_t*, dc_context_t*, uint32_t id);
82 int dc_msg_is_increation (const dc_msg_t*);
83 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 */
84 void dc_msg_save_param_to_disk (dc_msg_t*);
85 void dc_msg_guess_msgtype_from_suffix (const char* pathNfilename, int* ret_msgtype, char** ret_mime);
86 
87 void dc_delete_msg_from_db (dc_context_t*, uint32_t);
88 
89 #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)
90 
91 
92 /* as we do not cut inside words, this results in about 32-42 characters.
93 Do not use too long subjects - we add a tag after the subject which gets truncated by the clients otherwise.
94 It should also be very clear, the subject is _not_ the whole message.
95 The value is also used for CC:-summaries */
96 #define DC_APPROX_SUBJECT_CHARS 32
97 
98 
99 // Context functions to work with messages
100 int dc_msg_exists (dc_context_t*, uint32_t msg_id);
101 void dc_update_msg_chat_id (dc_context_t*, uint32_t msg_id, uint32_t chat_id);
102 void dc_update_msg_state (dc_context_t*, uint32_t msg_id, int state);
103 void dc_update_msg_move_state (dc_context_t*, const char* rfc724_mid, dc_move_state_t);
104 void dc_set_msg_failed (dc_context_t*, uint32_t msg_id, const char* error);
105 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 */
106 size_t dc_get_real_msg_cnt (dc_context_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
107 size_t dc_get_deaddrop_msg_cnt (dc_context_t*);
108 int dc_rfc724_mid_cnt (dc_context_t*, const char* rfc724_mid);
109 uint32_t dc_rfc724_mid_exists (dc_context_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
110 void dc_update_server_uid (dc_context_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
111 
112 
113 #ifdef __cplusplus
114 } /* /extern "C" */
115 #endif
116 #endif /* __DC_MSG_H__ */
dc_context_t
dc_msg_t::dc_msg_is_increation
int dc_msg_is_increation(const dc_msg_t *msg)
Check if a message is still in creation.
Definition: dc_msg.c:1070
dc_msg_t