Delta Chat Core C-API
mrmsg-private.h
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Copyright (C) 2017 Björn Petersen
5  * Contact: r10s@b44t.com, http://b44t.com
6  *
7  * This program is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program. If not, see http://www.gnu.org/licenses/ .
19  *
20  ******************************************************************************/
21 
22 
23 #ifndef __MRMSG_PRIVATE_H__
24 #define __MRMSG_PRIVATE_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrparam_t mrparam_t;
31 typedef struct sqlite3_stmt sqlite3_stmt;
32 
33 
35 struct _mrmsg
36 {
39  uint32_t m_magic;
40 
44  uint32_t m_id;
45 
46 
51  uint32_t m_from_id;
52 
53 
58  uint32_t m_to_id;
59 
60 
65  uint32_t m_chat_id;
66 
67 
68  /*
69  * The mailbox object the chat belongs to. Never NULL.
70  */
71  //mrmailbox_t* m_mailbox;
72 
73 
74  int m_type;
76  int m_state;
78  time_t m_timestamp;
79  char* m_text;
81  mrmailbox_t* m_mailbox;
82  char* m_rfc724_mid;
83  char* m_server_folder;
84  uint32_t m_server_uid;
85  int m_is_msgrmsg;
86  int m_starred;
87  mrparam_t* m_param;
88 };
89 
90 
91 #define MR_MSG_FIELDS " m.id,rfc724_mid,m.server_folder,m.server_uid,m.chat_id, m.from_id,m.to_id,m.timestamp, m.type,m.state,m.msgrmsg,m.txt, m.param,m.starred "
92 int mrmsg_set_from_stmt__ (mrmsg_t*, sqlite3_stmt* row, int row_offset); /* row order is MR_MSG_FIELDS */
93 int mrmsg_load_from_db__ (mrmsg_t*, mrmailbox_t*, uint32_t id);
94 int mrmsg_is_increation__ (const mrmsg_t*);
95 char* mrmsg_get_summarytext_by_raw (int type, const char* text, mrparam_t*, int approx_bytes); /* the returned value must be free()'d */
96 void mrmsg_save_param_to_disk__ (mrmsg_t*);
97 void mrmsg_guess_msgtype_from_suffix (const char* pathNfilename, int* ret_msgtype, char** ret_mime);
98 void mrmsg_get_authorNtitle_from_filename (const char* pathNfilename, char** ret_author, char** ret_title);
99 
100 #define MR_MSG_NEEDS_ATTACHMENT(a) ((a)==MR_MSG_IMAGE || (a)==MR_MSG_GIF || (a)==MR_MSG_AUDIO || (a)==MR_MSG_VOICE || (a)==MR_MSG_VIDEO || (a)==MR_MSG_FILE)
101 #define MR_MSG_MAKE_FILENAME_SEARCHABLE(a) ((a)==MR_MSG_AUDIO || (a)==MR_MSG_FILE || (a)==MR_MSG_VIDEO ) /* add filename.ext (without path) to m_text? this is needed for the fulltext search. The extension is useful to get all PDF, all MP3 etc. */
102 #define MR_MSG_MAKE_SUFFIX_SEARCHABLE(a) ((a)==MR_MSG_IMAGE || (a)==MR_MSG_GIF || (a)==MR_MSG_VOICE)
103 
104 #define APPROX_SUBJECT_CHARS 32 /* as we do not cut inside words, this results in about 32-42 characters.
105  Do not use too long subjects - we add a tag after the subject which gets truncated by the clients otherwise.
106  It should also be very clear, the subject is _not_ the whole message.
107  The value is also used for CC:-summaries */
108 
109 
110 
111 #ifdef __cplusplus
112 } /* /extern "C" */
113 #endif
114 #endif /* __MRMSG_PRIVATE_H__ */
An object representing a single message in memory.
An object representing a single mailbox.