mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +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:
@@ -1184,8 +1184,8 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
if strlen(pathNfilename) > 0 {
|
||||
if ((*mimefactory.msg).type_0 == DC_MSG_IMAGE
|
||||
|| (*mimefactory.msg).type_0 == DC_MSG_GIF)
|
||||
if ((*mimefactory.msg).type_0 == Viewtype::Image
|
||||
|| (*mimefactory.msg).type_0 == Viewtype::Gif)
|
||||
&& !(*mimefactory.msg).param.exists(Param::Width)
|
||||
{
|
||||
let mut buf = 0 as *mut libc::c_uchar;
|
||||
|
||||
Reference in New Issue
Block a user