mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
@@ -131,7 +131,7 @@ impl ContextWrapper {
|
|||||||
| Event::Error(msg)
|
| Event::Error(msg)
|
||||||
| Event::ErrorNetwork(msg)
|
| Event::ErrorNetwork(msg)
|
||||||
| Event::ErrorSelfNotInGroup(msg) => {
|
| Event::ErrorSelfNotInGroup(msg) => {
|
||||||
let data2 = CString::new(msg).unwrap();
|
let data2 = CString::new(msg).unwrap_or_default();
|
||||||
ffi_cb(self, event_id, 0, data2.as_ptr() as uintptr_t)
|
ffi_cb(self, event_id, 0, data2.as_ptr() as uintptr_t)
|
||||||
}
|
}
|
||||||
Event::MsgsChanged { chat_id, msg_id }
|
Event::MsgsChanged { chat_id, msg_id }
|
||||||
@@ -150,7 +150,7 @@ impl ContextWrapper {
|
|||||||
ffi_cb(self, event_id, progress as uintptr_t, 0)
|
ffi_cb(self, event_id, progress as uintptr_t, 0)
|
||||||
}
|
}
|
||||||
Event::ImexFileWritten(file) => {
|
Event::ImexFileWritten(file) => {
|
||||||
let data1 = file.to_c_string().unwrap();
|
let data1 = file.to_c_string().unwrap_or_default();
|
||||||
ffi_cb(self, event_id, data1.as_ptr() as uintptr_t, 0)
|
ffi_cb(self, event_id, data1.as_ptr() as uintptr_t, 0)
|
||||||
}
|
}
|
||||||
Event::SecurejoinInviterProgress {
|
Event::SecurejoinInviterProgress {
|
||||||
@@ -2136,7 +2136,7 @@ pub unsafe extern "C" fn dc_chat_get_profile_image(chat: *mut dc_chat_t) -> *mut
|
|||||||
let ffi_context = &*ffi_chat.context;
|
let ffi_context = &*ffi_chat.context;
|
||||||
ffi_context
|
ffi_context
|
||||||
.with_inner(|ctx| match ffi_chat.chat.get_profile_image(ctx) {
|
.with_inner(|ctx| match ffi_chat.chat.get_profile_image(ctx) {
|
||||||
Some(p) => p.to_str().unwrap().to_string().strdup(),
|
Some(p) => p.to_str().unwrap_or_default().to_string().strdup(),
|
||||||
None => ptr::null_mut(),
|
None => ptr::null_mut(),
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|_| ptr::null_mut())
|
.unwrap_or_else(|_| ptr::null_mut())
|
||||||
@@ -2481,7 +2481,7 @@ pub unsafe extern "C" fn dc_msg_get_summarytext(
|
|||||||
.with_inner(|ctx| {
|
.with_inner(|ctx| {
|
||||||
ffi_msg
|
ffi_msg
|
||||||
.message
|
.message
|
||||||
.get_summarytext(ctx, approx_characters.try_into().unwrap())
|
.get_summarytext(ctx, approx_characters.try_into().unwrap_or_default())
|
||||||
})
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.strdup()
|
.strdup()
|
||||||
@@ -2773,7 +2773,7 @@ pub unsafe extern "C" fn dc_contact_get_profile_image(
|
|||||||
ffi_contact
|
ffi_contact
|
||||||
.contact
|
.contact
|
||||||
.get_profile_image(ctx)
|
.get_profile_image(ctx)
|
||||||
.map(|p| p.to_str().unwrap().to_string().strdup())
|
.map(|p| p.to_str().unwrap_or_default().to_string().strdup())
|
||||||
.unwrap_or_else(|| std::ptr::null_mut())
|
.unwrap_or_else(|| std::ptr::null_mut())
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|_| ptr::null_mut())
|
.unwrap_or_else(|_| ptr::null_mut())
|
||||||
|
|||||||
@@ -16,13 +16,16 @@ pub unsafe fn charconv(
|
|||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
assert!(!fromcode.is_null(), "invalid fromcode");
|
assert!(!fromcode.is_null(), "invalid fromcode");
|
||||||
assert!(!s.is_null(), "invalid input string");
|
assert!(!s.is_null(), "invalid input string");
|
||||||
if let Some(encoding) =
|
if let Some(encoding) = charset::Charset::for_label(
|
||||||
charset::Charset::for_label(CStr::from_ptr(fromcode).to_str().unwrap().as_bytes())
|
CStr::from_ptr(fromcode)
|
||||||
{
|
.to_str()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_bytes(),
|
||||||
|
) {
|
||||||
let data = std::slice::from_raw_parts(s as *const u8, strlen(s));
|
let data = std::slice::from_raw_parts(s as *const u8, strlen(s));
|
||||||
|
|
||||||
let (res, _, _) = encoding.decode(data);
|
let (res, _, _) = encoding.decode(data);
|
||||||
let res_c = CString::new(res.as_bytes()).unwrap();
|
let res_c = CString::new(res.as_bytes()).unwrap_or_default();
|
||||||
*result = strdup(res_c.as_ptr()) as *mut _;
|
*result = strdup(res_c.as_ptr()) as *mut _;
|
||||||
|
|
||||||
MAIL_CHARCONV_NO_ERROR as libc::c_int
|
MAIL_CHARCONV_NO_ERROR as libc::c_int
|
||||||
|
|||||||
@@ -1598,7 +1598,7 @@ unsafe fn mailimf_date_time_write_driver(
|
|||||||
(*date_time).dt_sec,
|
(*date_time).dt_sec,
|
||||||
(*date_time).dt_zone,
|
(*date_time).dt_zone,
|
||||||
);
|
);
|
||||||
let date_str_c = std::ffi::CString::new(date_str).unwrap();
|
let date_str_c = std::ffi::CString::new(date_str).unwrap_or_default();
|
||||||
let r = mailimf_string_write_driver(
|
let r = mailimf_string_write_driver(
|
||||||
do_write,
|
do_write,
|
||||||
data,
|
data,
|
||||||
|
|||||||
@@ -848,7 +848,7 @@ pub unsafe fn mailmime_generate_boundary() -> *mut libc::c_char {
|
|||||||
hex::encode(&std::process::id().to_le_bytes()[..2])
|
hex::encode(&std::process::id().to_le_bytes()[..2])
|
||||||
);
|
);
|
||||||
|
|
||||||
let c = std::ffi::CString::new(raw).unwrap();
|
let c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
strdup(c.as_ptr())
|
strdup(c.as_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ unsafe fn mailmime_disposition_param_write_driver(
|
|||||||
4 => {
|
4 => {
|
||||||
let value = (*param).pa_data.pa_size as u32;
|
let value = (*param).pa_data.pa_size as u32;
|
||||||
let raw = format!("{}", value);
|
let raw = format!("{}", value);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
sizestr = strdup(raw_c.as_ptr());
|
sizestr = strdup(raw_c.as_ptr());
|
||||||
len = strlen(b"size=\x00" as *const u8 as *const libc::c_char)
|
len = strlen(b"size=\x00" as *const u8 as *const libc::c_char)
|
||||||
.wrapping_add(strlen(sizestr))
|
.wrapping_add(strlen(sizestr))
|
||||||
@@ -542,7 +542,7 @@ unsafe fn mailmime_version_write_driver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let raw = format!("{}.{}", (version >> 16) as i32, (version & 0xffff) as i32);
|
let raw = format!("{}.{}", (version >> 16) as i32, (version & 0xffff) as i32);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut versionstr = strdup(raw_c.as_ptr());
|
let mut versionstr = strdup(raw_c.as_ptr());
|
||||||
r = mailimf_string_write_driver(do_write, data, col, versionstr, strlen(versionstr));
|
r = mailimf_string_write_driver(do_write, data, col, versionstr, strlen(versionstr));
|
||||||
if r != MAILIMF_NO_ERROR as libc::c_int {
|
if r != MAILIMF_NO_ERROR as libc::c_int {
|
||||||
@@ -1516,7 +1516,7 @@ pub unsafe fn mailmime_data_write_driver(
|
|||||||
1 => {
|
1 => {
|
||||||
let filename = CStr::from_ptr((*mime_data).dt_data.dt_filename)
|
let filename = CStr::from_ptr((*mime_data).dt_data.dt_filename)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap();
|
.unwrap_or_default();
|
||||||
if let Ok(file) = std::fs::File::open(filename) {
|
if let Ok(file) = std::fs::File::open(filename) {
|
||||||
if let Ok(mut text) = memmap::MmapOptions::new().map_copy(&file) {
|
if let Ok(mut text) = memmap::MmapOptions::new().map_copy(&file) {
|
||||||
if 0 != (*mime_data).dt_encoded {
|
if 0 != (*mime_data).dt_encoded {
|
||||||
@@ -1797,7 +1797,7 @@ pub unsafe fn mailmime_quoted_printable_write_driver(
|
|||||||
start = text.offset(i as isize).offset(1isize);
|
start = text.offset(i as isize).offset(1isize);
|
||||||
|
|
||||||
let raw = format!("={:02X}", (ch as libc::c_int));
|
let raw = format!("={:02X}", (ch as libc::c_int));
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut hexstr = strdup(raw_c.as_ptr());
|
let mut hexstr = strdup(raw_c.as_ptr());
|
||||||
r = mailimf_string_write_driver(
|
r = mailimf_string_write_driver(
|
||||||
do_write,
|
do_write,
|
||||||
@@ -1822,7 +1822,7 @@ pub unsafe fn mailmime_quoted_printable_write_driver(
|
|||||||
}
|
}
|
||||||
start = text.offset(i as isize).offset(1isize);
|
start = text.offset(i as isize).offset(1isize);
|
||||||
let raw = format!("={:02X}", ch as libc::c_int);
|
let raw = format!("={:02X}", ch as libc::c_int);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut hexstr = strdup(raw_c.as_ptr());
|
let mut hexstr = strdup(raw_c.as_ptr());
|
||||||
r = mailimf_string_write_driver(
|
r = mailimf_string_write_driver(
|
||||||
do_write,
|
do_write,
|
||||||
@@ -1866,7 +1866,7 @@ pub unsafe fn mailmime_quoted_printable_write_driver(
|
|||||||
}
|
}
|
||||||
start = text.offset(i as isize);
|
start = text.offset(i as isize);
|
||||||
let raw = format!("={:02X}", b'\r' as i32);
|
let raw = format!("={:02X}", b'\r' as i32);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut hexstr = strdup(raw_c.as_ptr());
|
let mut hexstr = strdup(raw_c.as_ptr());
|
||||||
r = mailimf_string_write_driver(do_write, data, col, hexstr, 3i32 as size_t);
|
r = mailimf_string_write_driver(do_write, data, col, hexstr, 3i32 as size_t);
|
||||||
if r != MAILIMF_NO_ERROR as libc::c_int {
|
if r != MAILIMF_NO_ERROR as libc::c_int {
|
||||||
@@ -1890,7 +1890,7 @@ pub unsafe fn mailmime_quoted_printable_write_driver(
|
|||||||
"={:02X}\r\n",
|
"={:02X}\r\n",
|
||||||
*text.offset(i.wrapping_sub(1i32 as libc::size_t) as isize) as libc::c_int
|
*text.offset(i.wrapping_sub(1i32 as libc::size_t) as isize) as libc::c_int
|
||||||
);
|
);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut hexstr = strdup(raw_c.as_ptr());
|
let mut hexstr = strdup(raw_c.as_ptr());
|
||||||
|
|
||||||
r = mailimf_string_write_driver(do_write, data, col, hexstr, strlen(hexstr));
|
r = mailimf_string_write_driver(do_write, data, col, hexstr, strlen(hexstr));
|
||||||
@@ -1917,7 +1917,7 @@ pub unsafe fn mailmime_quoted_printable_write_driver(
|
|||||||
"={:02X}\r\n",
|
"={:02X}\r\n",
|
||||||
*text.offset(i.wrapping_sub(2i32 as libc::size_t) as isize) as libc::c_int
|
*text.offset(i.wrapping_sub(2i32 as libc::size_t) as isize) as libc::c_int
|
||||||
);
|
);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut hexstr = strdup(raw_c.as_ptr());
|
let mut hexstr = strdup(raw_c.as_ptr());
|
||||||
|
|
||||||
r = mailimf_string_write_driver(do_write, data, col, hexstr, strlen(hexstr));
|
r = mailimf_string_write_driver(do_write, data, col, hexstr, strlen(hexstr));
|
||||||
@@ -1938,7 +1938,7 @@ pub unsafe fn mailmime_quoted_printable_write_driver(
|
|||||||
(*text.offset(i.wrapping_sub(2i32 as libc::size_t) as isize) as u8 as char),
|
(*text.offset(i.wrapping_sub(2i32 as libc::size_t) as isize) as u8 as char),
|
||||||
b'\r' as i32
|
b'\r' as i32
|
||||||
);
|
);
|
||||||
let raw_c = std::ffi::CString::new(raw).unwrap();
|
let raw_c = std::ffi::CString::new(raw).unwrap_or_default();
|
||||||
let mut hexstr = strdup(raw_c.as_ptr());
|
let mut hexstr = strdup(raw_c.as_ptr());
|
||||||
|
|
||||||
r = mailimf_string_write_driver(do_write, data, col, hexstr, strlen(hexstr));
|
r = mailimf_string_write_driver(do_write, data, col, hexstr, strlen(hexstr));
|
||||||
|
|||||||
@@ -79,13 +79,16 @@ impl Aheader {
|
|||||||
let optional_field = unsafe { (*field).fld_data.fld_optional_field };
|
let optional_field = unsafe { (*field).fld_data.fld_optional_field };
|
||||||
if !optional_field.is_null()
|
if !optional_field.is_null()
|
||||||
&& unsafe { !(*optional_field).fld_name.is_null() }
|
&& unsafe { !(*optional_field).fld_name.is_null() }
|
||||||
&& unsafe { CStr::from_ptr((*optional_field).fld_name).to_str().unwrap() }
|
&& unsafe {
|
||||||
== "Autocrypt"
|
CStr::from_ptr((*optional_field).fld_name)
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or_default()
|
||||||
|
} == "Autocrypt"
|
||||||
{
|
{
|
||||||
let value = unsafe {
|
let value = unsafe {
|
||||||
CStr::from_ptr((*optional_field).fld_value)
|
CStr::from_ptr((*optional_field).fld_value)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(test) = Self::from_str(value) {
|
if let Ok(test) = Self::from_str(value) {
|
||||||
|
|||||||
15
src/chat.rs
15
src/chat.rs
@@ -287,7 +287,7 @@ impl Chat {
|
|||||||
if self.typ == Chattype::Group || self.typ == Chattype::VerifiedGroup {
|
if self.typ == Chattype::Group || self.typ == Chattype::VerifiedGroup {
|
||||||
if self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 {
|
if self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 {
|
||||||
self.param.remove(Param::Unpromoted);
|
self.param.remove(Param::Unpromoted);
|
||||||
self.update_param(context).unwrap();
|
self.update_param(context)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1368,7 +1368,7 @@ pub(crate) fn add_contact_to_chat_ex(
|
|||||||
}
|
}
|
||||||
if from_handshake && chat.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 {
|
if from_handshake && chat.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 {
|
||||||
chat.param.remove(Param::Unpromoted);
|
chat.param.remove(Param::Unpromoted);
|
||||||
chat.update_param(context).unwrap();
|
chat.update_param(context)?;
|
||||||
}
|
}
|
||||||
let self_addr = context
|
let self_addr = context
|
||||||
.get_config(Config::ConfiguredAddr)
|
.get_config(Config::ConfiguredAddr)
|
||||||
@@ -1503,7 +1503,7 @@ pub fn remove_contact_from_chat(
|
|||||||
if chat.is_promoted() {
|
if chat.is_promoted() {
|
||||||
msg.type_0 = Viewtype::Text;
|
msg.type_0 = Viewtype::Text;
|
||||||
if contact.id == DC_CONTACT_ID_SELF {
|
if contact.id == DC_CONTACT_ID_SELF {
|
||||||
set_group_explicitly_left(context, chat.grpid).unwrap();
|
set_group_explicitly_left(context, chat.grpid)?;
|
||||||
msg.text = Some(context.stock_system_msg(
|
msg.text = Some(context.stock_system_msg(
|
||||||
StockMessage::MsgGroupLeft,
|
StockMessage::MsgGroupLeft,
|
||||||
"",
|
"",
|
||||||
@@ -1712,7 +1712,7 @@ pub fn forward_msgs(context: &Context, msg_ids: &[u32], chat_id: u32) -> Result<
|
|||||||
let mut created_db_entries = Vec::new();
|
let mut created_db_entries = Vec::new();
|
||||||
let mut curr_timestamp: i64;
|
let mut curr_timestamp: i64;
|
||||||
|
|
||||||
unarchive(context, chat_id).unwrap();
|
unarchive(context, chat_id)?;
|
||||||
if let Ok(mut chat) = Chat::load_from_db(context, chat_id) {
|
if let Ok(mut chat) = Chat::load_from_db(context, chat_id) {
|
||||||
curr_timestamp = dc_create_smeared_timestamps(context, msg_ids.len());
|
curr_timestamp = dc_create_smeared_timestamps(context, msg_ids.len());
|
||||||
let idsstr = msg_ids
|
let idsstr = msg_ids
|
||||||
@@ -1722,9 +1722,7 @@ pub fn forward_msgs(context: &Context, msg_ids: &[u32], chat_id: u32) -> Result<
|
|||||||
(if i == 0 { acc } else { acc + "," }) + &n.to_string()
|
(if i == 0 { acc } else { acc + "," }) + &n.to_string()
|
||||||
});
|
});
|
||||||
|
|
||||||
let ids = context
|
let ids = context.sql.query_map(
|
||||||
.sql
|
|
||||||
.query_map(
|
|
||||||
format!(
|
format!(
|
||||||
"SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id",
|
"SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id",
|
||||||
idsstr
|
idsstr
|
||||||
@@ -1732,8 +1730,7 @@ pub fn forward_msgs(context: &Context, msg_ids: &[u32], chat_id: u32) -> Result<
|
|||||||
params![],
|
params![],
|
||||||
|row| row.get::<_, i32>(0),
|
|row| row.get::<_, i32>(0),
|
||||||
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
|
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
|
||||||
)
|
)?;
|
||||||
.unwrap(); // TODO: better error handling
|
|
||||||
|
|
||||||
for id in ids {
|
for id in ids {
|
||||||
let src_msg_id = id;
|
let src_msg_id = id;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ impl Context {
|
|||||||
let value = match key {
|
let value = match key {
|
||||||
Config::Selfavatar => {
|
Config::Selfavatar => {
|
||||||
let rel_path = self.sql.get_raw_config(self, key);
|
let rel_path = self.sql.get_raw_config(self, key);
|
||||||
rel_path.map(|p| dc_get_abs_path(self, &p).to_str().unwrap().to_string())
|
rel_path.map(|p| dc_get_abs_path(self, &p).to_string_lossy().into_owned())
|
||||||
}
|
}
|
||||||
Config::SysVersion => Some((&*DC_VERSION_STR).clone()),
|
Config::SysVersion => Some((&*DC_VERSION_STR).clone()),
|
||||||
Config::SysMsgsizeMaxRecommended => Some(format!("{}", 24 * 1024 * 1024 / 4 * 3)),
|
Config::SysMsgsizeMaxRecommended => Some(format!("{}", 24 * 1024 * 1024 / 4 * 3)),
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ impl Context {
|
|||||||
Ok(ret)
|
Ok(ret)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ impl<'a> MimeParser<'a> {
|
|||||||
if self.get_last_nonmeta().is_some() {
|
if self.get_last_nonmeta().is_some() {
|
||||||
let mut mb_list: *mut mailimf_mailbox_list = ptr::null_mut();
|
let mut mb_list: *mut mailimf_mailbox_list = ptr::null_mut();
|
||||||
let mut index_0 = 0;
|
let mut index_0 = 0;
|
||||||
let dn_field_c = CString::new(dn_field).unwrap();
|
let dn_field_c = CString::new(dn_field).unwrap_or_default();
|
||||||
|
|
||||||
if mailimf_mailbox_list_parse(
|
if mailimf_mailbox_list_parse(
|
||||||
dn_field_c.as_ptr(),
|
dn_field_c.as_ptr(),
|
||||||
@@ -620,9 +620,12 @@ impl<'a> MimeParser<'a> {
|
|||||||
&& strcmp(charset, b"utf-8\x00" as *const u8 as *const libc::c_char) != 0i32
|
&& strcmp(charset, b"utf-8\x00" as *const u8 as *const libc::c_char) != 0i32
|
||||||
&& strcmp(charset, b"UTF-8\x00" as *const u8 as *const libc::c_char) != 0i32
|
&& strcmp(charset, b"UTF-8\x00" as *const u8 as *const libc::c_char) != 0i32
|
||||||
{
|
{
|
||||||
if let Some(encoding) =
|
if let Some(encoding) = Charset::for_label(
|
||||||
Charset::for_label(CStr::from_ptr(charset).to_str().unwrap().as_bytes())
|
CStr::from_ptr(charset)
|
||||||
{
|
.to_str()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_bytes(),
|
||||||
|
) {
|
||||||
let (res, _, _) = encoding.decode(&decoded_data);
|
let (res, _, _) = encoding.decode(&decoded_data);
|
||||||
if res.is_empty() {
|
if res.is_empty() {
|
||||||
/* no error - but nothing to add */
|
/* no error - but nothing to add */
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ unsafe fn add_parts(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// unarchive chat
|
// unarchive chat
|
||||||
chat::unarchive(context, *chat_id).unwrap();
|
chat::unarchive(context, *chat_id)?;
|
||||||
|
|
||||||
// if the mime-headers should be saved, find out its size
|
// if the mime-headers should be saved, find out its size
|
||||||
// (the mime-header ends with an empty line)
|
// (the mime-header ends with an empty line)
|
||||||
@@ -1264,7 +1264,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
} else {
|
} else {
|
||||||
chat.param.set(Param::ProfileImage, grpimage);
|
chat.param.set(Param::ProfileImage, grpimage);
|
||||||
}
|
}
|
||||||
chat.update_param(context).unwrap();
|
chat.update_param(context).unwrap_or_default();
|
||||||
send_EVENT_CHAT_MODIFIED = 1;
|
send_EVENT_CHAT_MODIFIED = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1575,7 +1575,7 @@ fn search_chat_ids_by_contact_ids(context: &Context, unsorted_contact_ids: &Vec<
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
).unwrap(); // TODO: better error handling
|
).unwrap_or_default(); // TODO: better error handling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1683,7 +1683,7 @@ unsafe fn dc_is_reply_to_known_message(context: &Context, mime_parser: &MimePars
|
|||||||
/* check if the message is a reply to a known message; the replies are identified by the Message-ID from
|
/* check if the message is a reply to a known message; the replies are identified by the Message-ID from
|
||||||
`In-Reply-To`/`References:` (to support non-Delta-Clients) or from `Chat-Predecessor:` (Delta clients, see comment in dc_chat.c) */
|
`In-Reply-To`/`References:` (to support non-Delta-Clients) or from `Chat-Predecessor:` (Delta clients, see comment in dc_chat.c) */
|
||||||
if let Some(optional_field) = mime_parser.lookup_optional_field("Chat-Predecessor") {
|
if let Some(optional_field) = mime_parser.lookup_optional_field("Chat-Predecessor") {
|
||||||
let optional_field_c = CString::new(optional_field).unwrap();
|
let optional_field_c = CString::new(optional_field).unwrap_or_default();
|
||||||
if 0 != is_known_rfc724_mid(context, optional_field_c.as_ptr()) {
|
if 0 != is_known_rfc724_mid(context, optional_field_c.as_ptr()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -637,7 +637,10 @@ fn dc_make_rel_path(context: &Context, path: &mut String) {
|
|||||||
.map(|s| path.starts_with(s))
|
.map(|s| path.starts_with(s))
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
{
|
{
|
||||||
*path = path.replace(context.get_blobdir().to_str().unwrap(), "$BLOBDIR");
|
*path = path.replace(
|
||||||
|
context.get_blobdir().to_str().unwrap_or_default(),
|
||||||
|
"$BLOBDIR",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ pub struct EncryptHelper {
|
|||||||
impl EncryptHelper {
|
impl EncryptHelper {
|
||||||
pub fn new(context: &Context) -> Result<EncryptHelper> {
|
pub fn new(context: &Context) -> Result<EncryptHelper> {
|
||||||
let prefer_encrypt =
|
let prefer_encrypt =
|
||||||
EncryptPreference::from_i32(context.get_config_int(Config::E2eeEnabled)).unwrap();
|
EncryptPreference::from_i32(context.get_config_int(Config::E2eeEnabled))
|
||||||
|
.unwrap_or_default();
|
||||||
let addr = match context.get_config(Config::ConfiguredAddr) {
|
let addr = match context.get_config(Config::ConfiguredAddr) {
|
||||||
None => {
|
None => {
|
||||||
bail!("addr not configured!");
|
bail!("addr not configured!");
|
||||||
|
|||||||
30
src/imap.rs
30
src/imap.rs
@@ -697,8 +697,16 @@ impl Imap {
|
|||||||
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
||||||
let mut parts = entry.split(':');
|
let mut parts = entry.split(':');
|
||||||
(
|
(
|
||||||
parts.next().unwrap().parse().unwrap_or_else(|_| 0),
|
parts
|
||||||
parts.next().unwrap().parse().unwrap_or_else(|_| 0),
|
.next()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.parse()
|
||||||
|
.unwrap_or_else(|_| 0),
|
||||||
|
parts
|
||||||
|
.next()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.parse()
|
||||||
|
.unwrap_or_else(|_| 0),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(0, 0)
|
(0, 0)
|
||||||
@@ -742,7 +750,7 @@ impl Imap {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if mailbox.uid_validity.unwrap() != uid_validity {
|
if mailbox.uid_validity.unwrap_or_default() != uid_validity {
|
||||||
// first time this folder is selected or UIDVALIDITY has changed, init lastseenuid and save it to config
|
// first time this folder is selected or UIDVALIDITY has changed, init lastseenuid and save it to config
|
||||||
|
|
||||||
if mailbox.exists == 0 {
|
if mailbox.exists == 0 {
|
||||||
@@ -752,7 +760,12 @@ impl Imap {
|
|||||||
// id we do not do this here, we'll miss the first message
|
// id we do not do this here, we'll miss the first message
|
||||||
// as we will get in here again and fetch from lastseenuid+1 then
|
// as we will get in here again and fetch from lastseenuid+1 then
|
||||||
|
|
||||||
self.set_config_last_seen_uid(context, &folder, mailbox.uid_validity.unwrap(), 0);
|
self.set_config_last_seen_uid(
|
||||||
|
context,
|
||||||
|
&folder,
|
||||||
|
mailbox.uid_validity.unwrap_or_default(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -783,7 +796,7 @@ impl Imap {
|
|||||||
last_seen_uid -= 1;
|
last_seen_uid -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uid_validity = mailbox.uid_validity.unwrap();
|
uid_validity = mailbox.uid_validity.unwrap_or_default();
|
||||||
self.set_config_last_seen_uid(context, &folder, uid_validity, last_seen_uid);
|
self.set_config_last_seen_uid(context, &folder, uid_validity, last_seen_uid);
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
@@ -945,7 +958,7 @@ impl Imap {
|
|||||||
let flags = if is_seen { DC_IMAP_SEEN } else { 0 };
|
let flags = if is_seen { DC_IMAP_SEEN } else { 0 };
|
||||||
|
|
||||||
if !is_deleted && msg.body().is_some() {
|
if !is_deleted && msg.body().is_some() {
|
||||||
let body = msg.body().unwrap();
|
let body = msg.body().unwrap_or_default();
|
||||||
unsafe {
|
unsafe {
|
||||||
dc_receive_imf(context, &body, folder.as_ref(), server_uid, flags as u32);
|
dc_receive_imf(context, &body, folder.as_ref(), server_uid, flags as u32);
|
||||||
}
|
}
|
||||||
@@ -1056,8 +1069,9 @@ impl Imap {
|
|||||||
let mut do_fake_idle = true;
|
let mut do_fake_idle = true;
|
||||||
while do_fake_idle {
|
while do_fake_idle {
|
||||||
// wait a moment: every 5 seconds in the first 3 minutes after a new message, after that every 60 seconds.
|
// wait a moment: every 5 seconds in the first 3 minutes after a new message, after that every 60 seconds.
|
||||||
let seconds_to_wait =
|
let seconds_to_wait = if fake_idle_start_time.elapsed().unwrap_or_default()
|
||||||
if fake_idle_start_time.elapsed().unwrap() < Duration::new(3 * 60, 0) && !wait_long
|
< Duration::new(3 * 60, 0)
|
||||||
|
&& !wait_long
|
||||||
{
|
{
|
||||||
Duration::new(5, 0)
|
Duration::new(5, 0)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ pub fn continue_key_transfer(context: &Context, msg_id: u32, setup_code: &str) -
|
|||||||
if msg.is_err() {
|
if msg.is_err() {
|
||||||
bail!("Message is no Autocrypt Setup Message.");
|
bail!("Message is no Autocrypt Setup Message.");
|
||||||
}
|
}
|
||||||
let msg = msg.unwrap();
|
let msg = msg.unwrap_or_default();
|
||||||
ensure!(
|
ensure!(
|
||||||
msg.is_setupmessage(),
|
msg.is_setupmessage(),
|
||||||
"Message is no Autocrypt Setup Message."
|
"Message is no Autocrypt Setup Message."
|
||||||
@@ -346,7 +346,7 @@ fn set_self_key(
|
|||||||
context,
|
context,
|
||||||
&public_key,
|
&public_key,
|
||||||
&private_key,
|
&private_key,
|
||||||
self_addr.unwrap(),
|
self_addr.unwrap_or_default(),
|
||||||
set_default,
|
set_default,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
) {
|
) {
|
||||||
@@ -682,7 +682,7 @@ fn export_backup(context: &Context, dir: impl AsRef<Path>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
context,
|
context,
|
||||||
@@ -763,7 +763,7 @@ fn import_self_keys(context: &Context, dir: impl AsRef<Path>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
let ccontent = if let Ok(content) = dc_read_file(context, &path_plus_name) {
|
let ccontent = if let Ok(content) = dc_read_file(context, &path_plus_name) {
|
||||||
key = String::from_utf8_lossy(&content).to_string();
|
key = String::from_utf8_lossy(&content).to_string();
|
||||||
CString::new(content).unwrap()
|
CString::new(content).unwrap_or_default()
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ impl Key {
|
|||||||
|
|
||||||
pub fn to_bytes(&self) -> Vec<u8> {
|
pub fn to_bytes(&self) -> Vec<u8> {
|
||||||
match self {
|
match self {
|
||||||
Key::Public(k) => k.to_bytes().unwrap(),
|
Key::Public(k) => k.to_bytes().unwrap_or_default(),
|
||||||
Key::Secret(k) => k.to_bytes().unwrap(),
|
Key::Secret(k) => k.to_bytes().unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ pub fn send_locations_to_chat(context: &Context, chat_id: u32, seconds: i64) {
|
|||||||
msg.text =
|
msg.text =
|
||||||
Some(context.stock_system_msg(StockMessage::MsgLocationEnabled, "", "", 0));
|
Some(context.stock_system_msg(StockMessage::MsgLocationEnabled, "", "", 0));
|
||||||
msg.param.set_int(Param::Cmd, 8);
|
msg.param.set_int(Param::Cmd, 8);
|
||||||
chat::send_msg(context, chat_id, &mut msg).unwrap();
|
chat::send_msg(context, chat_id, &mut msg).unwrap_or_default();
|
||||||
} else if 0 == seconds && is_sending_locations_before {
|
} else if 0 == seconds && is_sending_locations_before {
|
||||||
let stock_str =
|
let stock_str =
|
||||||
context.stock_system_msg(StockMessage::MsgLocationDisabled, "", "", 0);
|
context.stock_system_msg(StockMessage::MsgLocationDisabled, "", "", 0);
|
||||||
@@ -615,7 +615,7 @@ pub fn job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: &Job) {
|
|||||||
|
|
||||||
for (chat_id, mut msg) in msgs.into_iter() {
|
for (chat_id, mut msg) in msgs.into_iter() {
|
||||||
// TODO: better error handling
|
// TODO: better error handling
|
||||||
chat::send_msg(context, chat_id as u32, &mut msg).unwrap();
|
chat::send_msg(context, chat_id as u32, &mut msg).unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if 0 != continue_streaming {
|
if 0 != continue_streaming {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ impl LoginParam {
|
|||||||
let key = format!("{}imap_certificate_checks", prefix);
|
let key = format!("{}imap_certificate_checks", prefix);
|
||||||
let imap_certificate_checks =
|
let imap_certificate_checks =
|
||||||
if let Some(certificate_checks) = sql.get_raw_config_int(context, key) {
|
if let Some(certificate_checks) = sql.get_raw_config_int(context, key) {
|
||||||
num_traits::FromPrimitive::from_i32(certificate_checks).unwrap_or_default()
|
num_traits::FromPrimitive::from_i32(certificate_checks).unwrap()
|
||||||
} else {
|
} else {
|
||||||
Default::default()
|
Default::default()
|
||||||
};
|
};
|
||||||
@@ -91,7 +91,7 @@ impl LoginParam {
|
|||||||
let key = format!("{}smtp_certificate_checks", prefix);
|
let key = format!("{}smtp_certificate_checks", prefix);
|
||||||
let smtp_certificate_checks =
|
let smtp_certificate_checks =
|
||||||
if let Some(certificate_checks) = sql.get_raw_config_int(context, key) {
|
if let Some(certificate_checks) = sql.get_raw_config_int(context, key) {
|
||||||
num_traits::FromPrimitive::from_i32(certificate_checks).unwrap_or_default()
|
num_traits::FromPrimitive::from_i32(certificate_checks).unwrap()
|
||||||
} else {
|
} else {
|
||||||
Default::default()
|
Default::default()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ pub fn get_msg_info(context: &Context, msg_id: u32) -> String {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = msg.unwrap();
|
let msg = msg.unwrap_or_default();
|
||||||
|
|
||||||
let rawtxt: Option<String> = context.sql.query_get_value(
|
let rawtxt: Option<String> = context.sql.query_get_value(
|
||||||
context,
|
context,
|
||||||
@@ -536,7 +536,7 @@ pub fn get_msg_info(context: &Context, msg_id: u32) -> String {
|
|||||||
ret += &format!("Cannot load message #{}.", msg_id as usize);
|
ret += &format!("Cannot load message #{}.", msg_id as usize);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
let rawtxt = rawtxt.unwrap();
|
let rawtxt = rawtxt.unwrap_or_default();
|
||||||
let rawtxt = dc_truncate(rawtxt.trim(), 100000, false);
|
let rawtxt = dc_truncate(rawtxt.trim(), 100000, false);
|
||||||
|
|
||||||
let fts = dc_timestamp_to_str(msg.get_timestamp());
|
let fts = dc_timestamp_to_str(msg.get_timestamp());
|
||||||
@@ -745,7 +745,7 @@ pub fn markseen_msgs(context: &Context, msg_ids: &[u32]) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let mut send_event = false;
|
let mut send_event = false;
|
||||||
let msgs = msgs.unwrap();
|
let msgs = msgs.unwrap_or_default();
|
||||||
|
|
||||||
for (id, curr_state, curr_blocked) in msgs.into_iter() {
|
for (id, curr_state, curr_blocked) in msgs.into_iter() {
|
||||||
if curr_blocked == Blocked::Not {
|
if curr_blocked == Blocked::Not {
|
||||||
@@ -982,7 +982,7 @@ pub fn mdn_from_ext(
|
|||||||
context.sql.execute(
|
context.sql.execute(
|
||||||
"INSERT INTO msgs_mdns (msg_id, contact_id, timestamp_sent) VALUES (?, ?, ?);",
|
"INSERT INTO msgs_mdns (msg_id, contact_id, timestamp_sent) VALUES (?, ?, ?);",
|
||||||
params![*ret_msg_id as i32, from_id as i32, timestamp_sent],
|
params![*ret_msg_id as i32, from_id as i32, timestamp_sent],
|
||||||
).unwrap(); // TODO: better error handling
|
).unwrap_or_default(); // TODO: better error handling
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal chat? that's quite easy.
|
// Normal chat? that's quite easy.
|
||||||
|
|||||||
@@ -695,7 +695,7 @@ impl<'a> MimeFactory<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let command = factory.msg.param.get_cmd();
|
let command = factory.msg.param.get_cmd();
|
||||||
let msg = &factory.msg;
|
let msg = &factory.msg;
|
||||||
@@ -900,7 +900,7 @@ fn build_body_file(
|
|||||||
let mime_sub = mailmime_new_empty(content, mime_fields);
|
let mime_sub = mailmime_new_empty(content, mime_fields);
|
||||||
let abs_path = dc_get_abs_path(context, path_filename)
|
let abs_path = dc_get_abs_path(context, path_filename)
|
||||||
.to_c_string()
|
.to_c_string()
|
||||||
.unwrap();
|
.unwrap_or_default();
|
||||||
mailmime_set_body_file(mime_sub, dc_strdup(abs_path.as_ptr()));
|
mailmime_set_body_file(mime_sub, dc_strdup(abs_path.as_ptr()));
|
||||||
Ok((mime_sub, filename_to_send))
|
Ok((mime_sub, filename_to_send))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ impl str::FromStr for Params {
|
|||||||
ensure!(key.is_some(), "Missing key");
|
ensure!(key.is_some(), "Missing key");
|
||||||
ensure!(value.is_some(), "Missing value");
|
ensure!(value.is_some(), "Missing value");
|
||||||
|
|
||||||
let key = key.unwrap().trim();
|
let key = key.unwrap_or_default().trim();
|
||||||
let value = value.unwrap().trim();
|
let value = value.unwrap_or_default().trim();
|
||||||
|
|
||||||
if let Some(key) = Param::from_u8(key.as_bytes()[0]) {
|
if let Some(key) = Param::from_u8(key.as_bytes()[0]) {
|
||||||
inner.insert(key, value.to_string());
|
inner.insert(key, value.to_string());
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ pub fn dc_join_securejoin(context: &Context, qr: &str) -> u32 {
|
|||||||
info!(context, "Taking protocol shortcut.");
|
info!(context, "Taking protocol shortcut.");
|
||||||
context.bob.write().unwrap().expects = DC_VC_CONTACT_CONFIRM;
|
context.bob.write().unwrap().expects = DC_VC_CONTACT_CONFIRM;
|
||||||
joiner_progress!(context, chat_id_2_contact_id(context, contact_chat_id), 400);
|
joiner_progress!(context, chat_id_2_contact_id(context, contact_chat_id), 400);
|
||||||
let own_fingerprint = get_self_fingerprint(context).unwrap();
|
let own_fingerprint = get_self_fingerprint(context).unwrap_or_default();
|
||||||
send_handshake_msg(
|
send_handshake_msg(
|
||||||
context,
|
context,
|
||||||
contact_chat_id,
|
contact_chat_id,
|
||||||
@@ -291,7 +291,7 @@ fn send_handshake_msg(
|
|||||||
msg.param.set_int(Param::GuranteeE2ee, 1);
|
msg.param.set_int(Param::GuranteeE2ee, 1);
|
||||||
}
|
}
|
||||||
// TODO. handle cleanup on error
|
// TODO. handle cleanup on error
|
||||||
chat::send_msg(context, contact_chat_id, &mut msg).unwrap();
|
chat::send_msg(context, contact_chat_id, &mut msg).unwrap_or_default();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn chat_id_2_contact_id(context: &Context, contact_chat_id: u32) -> u32 {
|
fn chat_id_2_contact_id(context: &Context, contact_chat_id: u32) -> u32 {
|
||||||
@@ -675,7 +675,9 @@ fn mark_peer_as_verified(context: &Context, fingerprint: impl AsRef<str>) -> Res
|
|||||||
if peerstate.set_verified(1, fingerprint.as_ref(), 2) {
|
if peerstate.set_verified(1, fingerprint.as_ref(), 2) {
|
||||||
peerstate.prefer_encrypt = EncryptPreference::Mutual;
|
peerstate.prefer_encrypt = EncryptPreference::Mutual;
|
||||||
peerstate.to_save = Some(ToSave::All);
|
peerstate.to_save = Some(ToSave::All);
|
||||||
peerstate.save_to_db(&context.sql, false).unwrap();
|
peerstate
|
||||||
|
.save_to_db(&context.sql, false)
|
||||||
|
.unwrap_or_default();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,10 @@ impl Smtp {
|
|||||||
}
|
}
|
||||||
let user = &lp.send_user;
|
let user = &lp.send_user;
|
||||||
|
|
||||||
lettre::smtp::authentication::Credentials::new(user.to_string(), access_token.unwrap())
|
lettre::smtp::authentication::Credentials::new(
|
||||||
|
user.to_string(),
|
||||||
|
access_token.unwrap_or_default(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// plain
|
// plain
|
||||||
let user = lp.send_user.clone();
|
let user = lp.send_user.clone();
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ impl StockMessage {
|
|||||||
///
|
///
|
||||||
/// These could be used in logging calls, so no logging here.
|
/// These could be used in logging calls, so no logging here.
|
||||||
fn fallback(&self) -> &'static str {
|
fn fallback(&self) -> &'static str {
|
||||||
self.get_str("fallback").unwrap()
|
self.get_str("fallback").unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub fn get_ct_subtype(mime: *mut Mailmime) -> Option<String> {
|
|||||||
|
|
||||||
pub fn parse_message_id(message_id: &str) -> Result<String, Error> {
|
pub fn parse_message_id(message_id: &str) -> Result<String, Error> {
|
||||||
let mut dummy = 0;
|
let mut dummy = 0;
|
||||||
let c_message_id = CString::new(message_id).unwrap();
|
let c_message_id = CString::new(message_id).unwrap_or_default();
|
||||||
let c_ptr = c_message_id.as_ptr();
|
let c_ptr = c_message_id.as_ptr();
|
||||||
let mut rfc724_mid_c = std::ptr::null_mut();
|
let mut rfc724_mid_c = std::ptr::null_mut();
|
||||||
if unsafe { mailimf_msg_id_parse(c_ptr, libc::strlen(c_ptr), &mut dummy, &mut rfc724_mid_c) }
|
if unsafe { mailimf_msg_id_parse(c_ptr, libc::strlen(c_ptr), &mut dummy, &mut rfc724_mid_c) }
|
||||||
@@ -448,8 +448,8 @@ pub fn append_ct_param(
|
|||||||
value: &str,
|
value: &str,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let name_c = CString::new(name).unwrap();
|
let name_c = CString::new(name).unwrap_or_default();
|
||||||
let value_c = CString::new(value).unwrap();
|
let value_c = CString::new(value).unwrap_or_default();
|
||||||
|
|
||||||
clist_append!(
|
clist_append!(
|
||||||
(*content).ct_parameters,
|
(*content).ct_parameters,
|
||||||
@@ -463,7 +463,7 @@ pub fn append_ct_param(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_content_type(content_type: &str) -> Result<*mut mailmime_content, Error> {
|
pub fn new_content_type(content_type: &str) -> Result<*mut mailmime_content, Error> {
|
||||||
let ct = CString::new(content_type).unwrap();
|
let ct = CString::new(content_type).unwrap_or_default();
|
||||||
let content: *mut mailmime_content;
|
let content: *mut mailmime_content;
|
||||||
// mailmime_content_new_with_str only parses but does not retain/own ct
|
// mailmime_content_new_with_str only parses but does not retain/own ct
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
Reference in New Issue
Block a user