mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Adjust call sites to use new version of dc_msg_guess_msgtype_from_suffix
This commit is contained in:
committed by
holger krekel
parent
8f0e554bc4
commit
ceb4464a9b
@@ -426,24 +426,17 @@ unsafe fn prepare_msg_common<'a>(
|
||||
Typical conversions:
|
||||
- from FILE to AUDIO/VIDEO/IMAGE
|
||||
- from FILE/IMAGE to GIF */
|
||||
let mut better_type = Viewtype::Unknown;
|
||||
let mut better_mime = std::ptr::null_mut();
|
||||
|
||||
dc_msg_guess_msgtype_from_suffix(pathNfilename, &mut better_type, &mut better_mime);
|
||||
if Viewtype::Unknown != better_type && !better_mime.is_null() {
|
||||
(*msg).type_0 = better_type;
|
||||
(*msg).param.set(Param::MimeType, as_str(better_mime));
|
||||
if let Some((type_, mime)) =
|
||||
dc_msg_guess_msgtype_from_suffix(as_path(pathNfilename))
|
||||
{
|
||||
(*msg).type_0 = type_;
|
||||
(*msg).param.set(Param::MimeType, mime);
|
||||
}
|
||||
free(better_mime as *mut libc::c_void);
|
||||
} else if !(*msg).param.exists(Param::MimeType) {
|
||||
let mut better_mime = std::ptr::null_mut();
|
||||
|
||||
dc_msg_guess_msgtype_from_suffix(pathNfilename, ptr::null_mut(), &mut better_mime);
|
||||
|
||||
if !better_mime.is_null() {
|
||||
(*msg).param.set(Param::MimeType, as_str(better_mime));
|
||||
if let Some((_, mime)) = dc_msg_guess_msgtype_from_suffix(as_path(pathNfilename)) {
|
||||
(*msg).param.set(Param::MimeType, mime);
|
||||
}
|
||||
free(better_mime as *mut _);
|
||||
}
|
||||
info!(
|
||||
context,
|
||||
|
||||
@@ -270,36 +270,23 @@ pub unsafe fn dc_msg_empty(mut msg: *mut dc_msg_t) {
|
||||
}
|
||||
|
||||
pub unsafe fn dc_msg_get_filemime(msg: *const dc_msg_t) -> *mut libc::c_char {
|
||||
let mut ret = 0 as *mut libc::c_char;
|
||||
if msg.is_null() {
|
||||
return dc_strdup(0 as *const libc::c_char);
|
||||
}
|
||||
|
||||
if !msg.is_null() {
|
||||
match (*msg).param.get(Param::MimeType) {
|
||||
Some(m) => {
|
||||
ret = m.strdup();
|
||||
}
|
||||
None => {
|
||||
if let Some(file) = (*msg).param.get(Param::File) {
|
||||
let file_c = CString::yolo(file);
|
||||
dc_msg_guess_msgtype_from_suffix(file_c.as_ptr(), 0 as *mut Viewtype, &mut ret);
|
||||
if ret.is_null() {
|
||||
ret = dc_strdup(
|
||||
b"application/octet-stream\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(m) = (*msg).param.get(Param::MimeType) {
|
||||
return m.strdup();
|
||||
} else if let Some(file) = (*msg).param.get(Param::File) {
|
||||
if let Some((_, mime)) = dc_msg_guess_msgtype_from_suffix(Path::new(file)) {
|
||||
return mime.strdup();
|
||||
}
|
||||
}
|
||||
|
||||
if !ret.is_null() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
dc_strdup(0 as *const libc::c_char)
|
||||
"application/octet-stream".strdup()
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn dc_msg_guess_msgtype_from_suffix(
|
||||
pub unsafe fn dc_msg_guess_msgtype_from_suffix0(
|
||||
pathNfilename: *const libc::c_char,
|
||||
mut ret_msgtype: *mut Viewtype,
|
||||
mut ret_mime: *mut *mut libc::c_char,
|
||||
@@ -353,7 +340,7 @@ pub unsafe fn dc_msg_guess_msgtype_from_suffix(
|
||||
free(dummy_buf as *mut libc::c_void);
|
||||
}
|
||||
|
||||
pub fn dc_msg_guess_msgtype_from_suffix2(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
pub fn dc_msg_guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
let known = hashmap! {
|
||||
"mp3" => (Viewtype::Audio, "audio/mpeg"),
|
||||
"aac" => (Viewtype::Audio, "audio/aac"),
|
||||
|
||||
Reference in New Issue
Block a user