mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 22:06:29 +03:00
cargo fmt
This commit is contained in:
@@ -16,9 +16,12 @@ pub unsafe fn charconv(
|
||||
) -> libc::c_int {
|
||||
assert!(!fromcode.is_null(), "invalid fromcode");
|
||||
assert!(!s.is_null(), "invalid input string");
|
||||
if let Some(encoding) =
|
||||
charset::Charset::for_label(CStr::from_ptr(fromcode).to_str().unwrap_or_default().as_bytes())
|
||||
{
|
||||
if let Some(encoding) = charset::Charset::for_label(
|
||||
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 (res, _, _) = encoding.decode(data);
|
||||
|
||||
@@ -79,8 +79,11 @@ impl Aheader {
|
||||
let optional_field = unsafe { (*field).fld_data.fld_optional_field };
|
||||
if !optional_field.is_null()
|
||||
&& unsafe { !(*optional_field).fld_name.is_null() }
|
||||
&& unsafe { CStr::from_ptr((*optional_field).fld_name).to_str().unwrap_or_default() }
|
||||
== "Autocrypt"
|
||||
&& unsafe {
|
||||
CStr::from_ptr((*optional_field).fld_name)
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
} == "Autocrypt"
|
||||
{
|
||||
let value = unsafe {
|
||||
CStr::from_ptr((*optional_field).fld_value)
|
||||
|
||||
@@ -290,7 +290,12 @@ impl Chatlist {
|
||||
{
|
||||
ret.text2 = Some(context.stock_str(StockMessage::NoMessages).to_string());
|
||||
} else {
|
||||
ret.fill(&mut lastmsg.unwrap_or_default(), chat, lastcontact.as_ref(), context);
|
||||
ret.fill(
|
||||
&mut lastmsg.unwrap_or_default(),
|
||||
chat,
|
||||
lastcontact.as_ref(),
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
ret
|
||||
|
||||
@@ -79,7 +79,12 @@ impl Context {
|
||||
let value = match key {
|
||||
Config::Selfavatar => {
|
||||
let rel_path = self.sql.get_raw_config(self, key);
|
||||
rel_path.map(|p| dc_get_abs_path(self, &p).to_str().unwrap_or_default().to_string())
|
||||
rel_path.map(|p| {
|
||||
dc_get_abs_path(self, &p)
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
.to_string()
|
||||
})
|
||||
}
|
||||
Config::SysVersion => Some((&*DC_VERSION_STR).clone()),
|
||||
Config::SysMsgsizeMaxRecommended => Some(format!("{}", 24 * 1024 * 1024 / 4 * 3)),
|
||||
|
||||
@@ -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
|
||||
{
|
||||
if let Some(encoding) =
|
||||
Charset::for_label(CStr::from_ptr(charset).to_str().unwrap_or_default().as_bytes())
|
||||
{
|
||||
if let Some(encoding) = Charset::for_label(
|
||||
CStr::from_ptr(charset)
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
.as_bytes(),
|
||||
) {
|
||||
let (res, _, _) = encoding.decode(&decoded_data);
|
||||
if res.is_empty() {
|
||||
/* no error - but nothing to add */
|
||||
|
||||
@@ -637,7 +637,10 @@ fn dc_make_rel_path(context: &Context, path: &mut String) {
|
||||
.map(|s| path.starts_with(s))
|
||||
.unwrap_or_default()
|
||||
{
|
||||
*path = path.replace(context.get_blobdir().to_str().unwrap_or_default(), "$BLOBDIR");
|
||||
*path = path.replace(
|
||||
context.get_blobdir().to_str().unwrap_or_default(),
|
||||
"$BLOBDIR",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ pub struct EncryptHelper {
|
||||
impl EncryptHelper {
|
||||
pub fn new(context: &Context) -> Result<EncryptHelper> {
|
||||
let prefer_encrypt =
|
||||
EncryptPreference::from_i32(context.get_config_int(Config::E2eeEnabled)).unwrap_or_default();
|
||||
EncryptPreference::from_i32(context.get_config_int(Config::E2eeEnabled))
|
||||
.unwrap_or_default();
|
||||
let addr = match context.get_config(Config::ConfiguredAddr) {
|
||||
None => {
|
||||
bail!("addr not configured!");
|
||||
|
||||
34
src/imap.rs
34
src/imap.rs
@@ -697,8 +697,16 @@ impl Imap {
|
||||
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
||||
let mut parts = entry.split(':');
|
||||
(
|
||||
parts.next().unwrap_or_default().parse().unwrap_or_else(|_| 0),
|
||||
parts.next().unwrap_or_default().parse().unwrap_or_else(|_| 0),
|
||||
parts
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.parse()
|
||||
.unwrap_or_else(|_| 0),
|
||||
parts
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.parse()
|
||||
.unwrap_or_else(|_| 0),
|
||||
)
|
||||
} else {
|
||||
(0, 0)
|
||||
@@ -752,7 +760,12 @@ impl Imap {
|
||||
// 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
|
||||
|
||||
self.set_config_last_seen_uid(context, &folder, mailbox.uid_validity.unwrap_or_default(), 0);
|
||||
self.set_config_last_seen_uid(
|
||||
context,
|
||||
&folder,
|
||||
mailbox.uid_validity.unwrap_or_default(),
|
||||
0,
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1056,13 +1069,14 @@ impl Imap {
|
||||
let mut do_fake_idle = true;
|
||||
while do_fake_idle {
|
||||
// wait a moment: every 5 seconds in the first 3 minutes after a new message, after that every 60 seconds.
|
||||
let seconds_to_wait =
|
||||
if fake_idle_start_time.elapsed().unwrap_or_default() < Duration::new(3 * 60, 0) && !wait_long
|
||||
{
|
||||
Duration::new(5, 0)
|
||||
} else {
|
||||
Duration::new(60, 0)
|
||||
};
|
||||
let seconds_to_wait = if fake_idle_start_time.elapsed().unwrap_or_default()
|
||||
< Duration::new(3 * 60, 0)
|
||||
&& !wait_long
|
||||
{
|
||||
Duration::new(5, 0)
|
||||
} else {
|
||||
Duration::new(60, 0)
|
||||
};
|
||||
|
||||
let &(ref lock, ref cvar) = &*self.watch.clone();
|
||||
let mut watch = lock.lock().unwrap();
|
||||
|
||||
@@ -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) {
|
||||
peerstate.prefer_encrypt = EncryptPreference::Mutual;
|
||||
peerstate.to_save = Some(ToSave::All);
|
||||
peerstate.save_to_db(&context.sql, false).unwrap_or_default();
|
||||
peerstate
|
||||
.save_to_db(&context.sql, false)
|
||||
.unwrap_or_default();
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,10 @@ impl Smtp {
|
||||
}
|
||||
let user = &lp.send_user;
|
||||
|
||||
lettre::smtp::authentication::Credentials::new(user.to_string(), access_token.unwrap_or_default())
|
||||
lettre::smtp::authentication::Credentials::new(
|
||||
user.to_string(),
|
||||
access_token.unwrap_or_default(),
|
||||
)
|
||||
} else {
|
||||
// plain
|
||||
let user = lp.send_user.clone();
|
||||
|
||||
Reference in New Issue
Block a user