save subject for messages (#2274)

save subject for messages:

- new api `dc_msg_get_subject()`,

- when quoting, use the subject of the quoted message as the new subject, instead of the
last subject in the chat
This commit is contained in:
Hocuri
2021-03-07 16:57:12 +01:00
committed by GitHub
parent 8703da83f5
commit 04891238d4
11 changed files with 357 additions and 72 deletions

View File

@@ -1498,6 +1498,8 @@ char* dc_get_msg_info (dc_context_t* context, uint32_t ms
* this removes the need for the UI
* to deal with different formatting options of PLAIN-parts.
*
* As the title of the full-message-view, you can use the subject (see dc_msg_get_subject()).
*
* **Note:** The returned HTML-code may contain scripts,
* external images that may be misused as hidden read-receipts and so on.
* Taking care of these parts
@@ -3344,6 +3346,25 @@ int64_t dc_msg_get_sort_timestamp (const dc_msg_t* msg);
char* dc_msg_get_text (const dc_msg_t* msg);
/**
* Get the subject of the email.
* If there is no subject associated with the message, an empty string is returned.
* NULL is never returned.
*
* You usually don't need this; if the core thinks that the subject might contain important
* information, it automatically prepends it to the message text.
*
* This function was introduced so that you can use the subject as the title for the
* full-message-view (see dc_get_msg_html()).
*
* For outgoing messages, the subject is not stored and an empty string is returned.
*
* @memberof dc_msg_t
* @param msg The message object.
* @return The subject. The result must be released using dc_str_unref(). Never returns NULL.
*/
char* dc_msg_get_subject (const dc_msg_t* msg);
/**
* Find out full path, file name and extension of the file associated with a
* message.

View File

@@ -2698,6 +2698,16 @@ pub unsafe extern "C" fn dc_msg_get_text(msg: *mut dc_msg_t) -> *mut libc::c_cha
ffi_msg.message.get_text().unwrap_or_default().strdup()
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_subject(msg: *mut dc_msg_t) -> *mut libc::c_char {
if msg.is_null() {
eprintln!("ignoring careless call to dc_msg_get_subject()");
return "".strdup();
}
let ffi_msg = &*msg;
ffi_msg.message.get_subject().strdup()
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_file(msg: *mut dc_msg_t) -> *mut libc::c_char {
if msg.is_null() {