Accessible msg error and type changes

This commit is contained in:
René Rössler
2020-10-08 11:51:04 +02:00
parent 893e4b91ba
commit 9739c0305b
5 changed files with 68 additions and 16 deletions

View File

@@ -3524,6 +3524,27 @@ char* dc_msg_get_setupcodebegin (const dc_msg_t* msg);
*/
char* dc_msg_get_videochat_url (const dc_msg_t* msg);
/**
* Gets the error status of the message.
* If there is no error associated with the message, NULL is returned.
*
* A message can have an associated error status if something went wrong when sending or
* receiving message itself. The error status is free-form text and should not be further parsed,
* rather it's presence is meant to indicate *something* went wrong with the message and the
* text of the error is detailed information on what.
*
* Some common reasons error can be associated with messages are:
* * Lack of valid signature on an e2ee message, usually for received messages.
* * Failure to decrypt an e2ee message, usually for received messages.
* * When a message could not be delivered to one or more recipients the non-delivery
* notification text can be stored in the error status.
*
* @memberof dc_msg_t
* @param msg The message object.
* @return Error or NULL. The result must be released using dc_str_unref().
*/
char* dc_msg_get_error (const dc_msg_t* msg);
/**
* Get type of videochat.

View File

@@ -2962,6 +2962,19 @@ pub unsafe extern "C" fn dc_msg_latefiling_mediasize(
});
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_get_error(msg: *mut dc_msg_t) -> *mut libc::c_char {
if msg.is_null() {
eprintln!("ignoring careless call to dc_msg_get_error()");
return ptr::null_mut();
}
let ffi_msg = &*msg;
match ffi_msg.message.error() {
Some(error) => error.strdup(),
None => ptr::null_mut(),
}
}
// dc_contact_t
/// FFI struct for [dc_contact_t]