mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 15:06:30 +03:00
Introduce new enum: Viewtype
With this change, kind of message is represented by value of enum `Viewtype' instead of raw libc::c_int, providing more type safety. This enum replaces DC_MSG_* constants. The only way to create `Viewtype' from libc::c_int is smart constructor. With this change, functions `dc_get_chat_media' and `dc_get_next_media' became less forgiving about invalid message type arguments. Previously, invalid message types were implicitly interpreted as 0 (Viewtype::Unknown). Now, function calls with invalid message type arguments are rejected (error code returned) on FFI boundary. Additionally, when `Viewtype' is read from database, it is checked to have sensible value. No tests assumed forgiving behaviour.
This commit is contained in:
@@ -263,7 +263,7 @@ unsafe fn send_handshake_msg(
|
||||
grpid: *const libc::c_char,
|
||||
) {
|
||||
let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context);
|
||||
(*msg).type_0 = DC_MSG_TEXT;
|
||||
(*msg).type_0 = Viewtype::Text;
|
||||
(*msg).text = dc_mprintf(
|
||||
b"Secure-Join: %s\x00" as *const u8 as *const libc::c_char,
|
||||
step,
|
||||
|
||||
Reference in New Issue
Block a user