mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 05:46:29 +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:
|
Typical conversions:
|
||||||
- from FILE to AUDIO/VIDEO/IMAGE
|
- from FILE to AUDIO/VIDEO/IMAGE
|
||||||
- from FILE/IMAGE to GIF */
|
- 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 let Some((type_, mime)) =
|
||||||
if Viewtype::Unknown != better_type && !better_mime.is_null() {
|
dc_msg_guess_msgtype_from_suffix(as_path(pathNfilename))
|
||||||
(*msg).type_0 = better_type;
|
{
|
||||||
(*msg).param.set(Param::MimeType, as_str(better_mime));
|
(*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) {
|
} else if !(*msg).param.exists(Param::MimeType) {
|
||||||
let mut better_mime = std::ptr::null_mut();
|
if let Some((_, mime)) = dc_msg_guess_msgtype_from_suffix(as_path(pathNfilename)) {
|
||||||
|
(*msg).param.set(Param::MimeType, mime);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
free(better_mime as *mut _);
|
|
||||||
}
|
}
|
||||||
info!(
|
info!(
|
||||||
context,
|
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 {
|
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() {
|
if let Some(m) = (*msg).param.get(Param::MimeType) {
|
||||||
match (*msg).param.get(Param::MimeType) {
|
return m.strdup();
|
||||||
Some(m) => {
|
} else if let Some(file) = (*msg).param.get(Param::File) {
|
||||||
ret = m.strdup();
|
if let Some((_, mime)) = dc_msg_guess_msgtype_from_suffix(Path::new(file)) {
|
||||||
}
|
return mime.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 !ret.is_null() {
|
"application/octet-stream".strdup()
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_strdup(0 as *const libc::c_char)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[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,
|
pathNfilename: *const libc::c_char,
|
||||||
mut ret_msgtype: *mut Viewtype,
|
mut ret_msgtype: *mut Viewtype,
|
||||||
mut ret_mime: *mut *mut libc::c_char,
|
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);
|
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! {
|
let known = hashmap! {
|
||||||
"mp3" => (Viewtype::Audio, "audio/mpeg"),
|
"mp3" => (Viewtype::Audio, "audio/mpeg"),
|
||||||
"aac" => (Viewtype::Audio, "audio/aac"),
|
"aac" => (Viewtype::Audio, "audio/aac"),
|
||||||
|
|||||||
Reference in New Issue
Block a user