mirror of
https://github.com/chatmail/core.git
synced 2026-05-21 07:46:31 +03:00
add dc_msg_is_truncated and dc_msg_get_full_text
This commit is contained in:
@@ -2951,6 +2951,32 @@ int64_t dc_msg_get_sort_timestamp (const dc_msg_t* msg);
|
||||
*/
|
||||
char* dc_msg_get_text (const dc_msg_t* msg);
|
||||
|
||||
/**
|
||||
* Get the text of the message.
|
||||
* If there is no text associated with the message, an empty string is returned.
|
||||
* NULL is never returned.
|
||||
*
|
||||
* Same as dc_msg_get_text, but isn't truncated
|
||||
*
|
||||
* To get information about the message and more/raw text, use dc_get_msg_info().
|
||||
*
|
||||
* @memberof dc_msg_t
|
||||
* @param msg The message object.
|
||||
* @return Message text. The result must be released using dc_str_unref(). Never returns NULL.
|
||||
*/
|
||||
char* dc_msg_get_full_text (const dc_msg_t* msg);
|
||||
|
||||
|
||||
/**
|
||||
* Check if a message is truncated.
|
||||
*
|
||||
* @memberof dc_msg_t
|
||||
* @param msg The message object.
|
||||
* @return 1=message is truncated, 0=message not truncated.
|
||||
*/
|
||||
int dc_msg_is_truncated (const dc_msg_t* msg);
|
||||
|
||||
// define DC_MSG_TRUNCATE_THRESHOLD
|
||||
|
||||
/**
|
||||
* Find out full path, file name and extension of the file associated with a
|
||||
|
||||
@@ -2420,7 +2420,26 @@ pub unsafe extern "C" fn dc_msg_get_text(msg: *mut dc_msg_t) -> *mut libc::c_cha
|
||||
return dc_strdup(ptr::null());
|
||||
}
|
||||
let ffi_msg = &*msg;
|
||||
ffi_msg.message.get_text().unwrap_or_default().strdup()
|
||||
ffi_msg.message.get_text(false).unwrap_or_default().strdup()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_msg_get_full_text(msg: *mut dc_msg_t) -> *mut libc::c_char {
|
||||
if msg.is_null() {
|
||||
eprintln!("ignoring careless call to dc_msg_get_full_text()");
|
||||
return dc_strdup(ptr::null());
|
||||
}
|
||||
let ffi_msg = &*msg;
|
||||
ffi_msg.message.get_text(true).unwrap_or_default().strdup()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn is_truncated(msg: *mut dc_msg_t) -> libc::c_int {
|
||||
if msg.is_null() {
|
||||
return 0
|
||||
}
|
||||
let ffi_msg = &*msg;
|
||||
ffi_msg.message.is_truncated().into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user