cargo fmt

This commit is contained in:
Simon Laux
2019-08-12 03:19:31 +02:00
committed by holger krekel
parent b440c3636b
commit d0b77b61eb

View File

@@ -244,8 +244,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
param_domain,
param_addr_urlencoded
);
param_autoconfig =
moz_autoconfigure(context, &url, &param);
param_autoconfig = moz_autoconfigure(context, &url, &param);
if s.shall_stop_ongoing {
ok_to_continue1 = false;
} else {
@@ -317,9 +316,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
param_domain
);
param_autoconfig =
outlk_autodiscover(
context, &url, &param,
);
outlk_autodiscover(context, &url, &param);
if s.shall_stop_ongoing {
ok_to_continue3 = false;
@@ -349,9 +346,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
param_addr_urlencoded
);
param_autoconfig =
moz_autoconfigure(
context, &url, &param,
);
moz_autoconfigure(context, &url, &param);
if s.shall_stop_ongoing {
ok_to_continue4 = false;
@@ -375,21 +370,16 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
}
if ok_to_continue4 {
let ok_to_continue5;
if param_autoconfig
.is_none()
{
if param_autoconfig.is_none() {
// do not transfer the email-address unencrypted
let url = format!(
"http://{}/.well-known/autoconfig/mail/config-v1.1.xml",
param_domain
);
param_autoconfig =
moz_autoconfigure(
context, &url,
&param,
param_autoconfig = moz_autoconfigure(
context, &url, &param,
);
if s.shall_stop_ongoing
{
if s.shall_stop_ongoing {
ok_to_continue5 = false;
} else {
context.call_cb(
@@ -401,7 +391,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
} else {
350
},
0
0,
);
ok_to_continue5 = true;
}
@@ -411,23 +401,16 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
if ok_to_continue5 {
let ok_to_continue6;
/* B. If we have no configuration yet, search configuration in Thunderbird's centeral database */
if param_autoconfig
.is_none()
{
if param_autoconfig.is_none() {
/* always SSL for Thunderbird's database */
let url =
format!("https://autoconfig.thunderbird.net/v1.1/{}",
param_domain
);
param_autoconfig
=
moz_autoconfigure(
context,
&url,
&param
param_autoconfig = moz_autoconfigure(
context, &url, &param,
);
if s.shall_stop_ongoing
{
if s.shall_stop_ongoing {
ok_to_continue6 = false;
} else {
context.call_cb(
@@ -439,7 +422,8 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
} else {
500
},
0);
0,
);
ok_to_continue6 = true;
}
} else {
@@ -448,37 +432,28 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
if ok_to_continue6 {
if let Some(ref cfg) = param_autoconfig
{
let r = dc_loginparam_get_readable(cfg);
let r =
dc_loginparam_get_readable(cfg);
info!(
context,
0,
"Got autoconfig: {}",
r
0, "Got autoconfig: {}", r
);
if !cfg.mail_user.is_empty()
{
param.mail_user = cfg.mail_user.clone();
if !cfg.mail_user.is_empty() {
param.mail_user =
cfg.mail_user.clone();
}
param.mail_server = cfg.mail_server.clone();
param.mail_port
=
cfg.mail_port;
param.send_server
=
param.mail_server =
cfg.mail_server.clone();
param.mail_port = cfg.mail_port;
param.send_server =
cfg.send_server.clone();
param.send_port
=
cfg.send_port;
param.send_user
=
param.send_port = cfg.send_port;
param.send_user =
cfg.send_user.clone();
param.server_flags
=
param.server_flags =
cfg.server_flags;
}
param.server_flags
|=
keep_flags;
param.server_flags |= keep_flags;
ok_to_continue7 = true;
}
}
@@ -492,12 +467,10 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
}
if ok_to_continue7 {
if param.mail_server.is_empty() {
param.mail_server =
format!("imap.{}", param_domain,)
param.mail_server = format!("imap.{}", param_domain,)
}
if param.mail_port == 0 {
param.mail_port =
if 0 != param.server_flags & (0x100 | 0x400) {
param.mail_port = if 0 != param.server_flags & (0x100 | 0x400) {
143
} else {
993
@@ -506,19 +479,15 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
if param.mail_user.is_empty() {
param.mail_user = param.addr.clone();
}
if param.send_server.is_empty()
&& !param.mail_server.is_empty()
{
if param.send_server.is_empty() && !param.mail_server.is_empty() {
param.send_server = param.mail_server.clone();
if param.send_server.starts_with("imap.") {
param.send_server = param
.send_server
.replacen("imap", "smtp", 1);
param.send_server =
param.send_server.replacen("imap", "smtp", 1);
}
}
if param.send_port == 0 {
param.send_port =
if 0 != param.server_flags & 0x10000 {
param.send_port = if 0 != param.server_flags & 0x10000 {
587
} else if 0 != param.server_flags & 0x40000 {
25
@@ -526,18 +495,13 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
465
}
}
if param.send_user.is_empty()
&& !param.mail_user.is_empty()
{
if param.send_user.is_empty() && !param.mail_user.is_empty() {
param.send_user = param.mail_user.clone();
}
if param.send_pw.is_empty() && !param.mail_pw.is_empty()
{
if param.send_pw.is_empty() && !param.mail_pw.is_empty() {
param.send_pw = param.mail_pw.clone()
}
if !dc_exactly_one_bit_set(
param.server_flags & (0x2 | 0x4),
) {
if !dc_exactly_one_bit_set(param.server_flags & (0x2 | 0x4)) {
param.server_flags &= !(0x2 | 0x4);
param.server_flags |= 0x4
}
@@ -545,17 +509,13 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
param.server_flags & (0x100 | 0x200 | 0x400),
) {
param.server_flags &= !(0x100 | 0x200 | 0x400);
param.server_flags |= if param.send_port == 143 {
0x100
} else {
0x200
}
param.server_flags |=
if param.send_port == 143 { 0x100 } else { 0x200 }
}
if !dc_exactly_one_bit_set(
param.server_flags & (0x10000 | 0x20000 | 0x40000),
) {
param.server_flags &=
!(0x10000 | 0x20000 | 0x40000);
param.server_flags &= !(0x10000 | 0x20000 | 0x40000);
param.server_flags |= if param.send_port == 587 {
0x10000
} else if param.send_port == 25 {
@@ -585,8 +545,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
999
} else {
600
})
as uintptr_t,
}) as uintptr_t,
0,
);
/* try to connect to IMAP - if we did not got an autoconfig,
@@ -601,12 +560,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
let r_0 = dc_loginparam_get_readable(&param);
info!(context, 0, "Trying: {}", r_0,);
if context
.inbox
.read()
.unwrap()
.connect(context, &param)
{
if context.inbox.read().unwrap().connect(context, &param) {
ok_to_continue8 = true;
break;
}
@@ -623,9 +577,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
Event::CONFIGURE_PROGRESS,
(if 650 + username_variation * 30 < 1 {
1
} else if 650 + username_variation * 30
> 999
{
} else if 650 + username_variation * 30 > 999 {
999
} else {
650 + username_variation * 30
@@ -638,12 +590,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
let r_1 = dc_loginparam_get_readable(&param);
info!(context, 0, "Trying: {}", r_1,);
if context
.inbox
.read()
.unwrap()
.connect(context, &param)
{
if context.inbox.read().unwrap().connect(context, &param) {
ok_to_continue8 = true;
break;
}
@@ -656,9 +603,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
Event::CONFIGURE_PROGRESS,
(if 660 + username_variation * 30 < 1 {
1
} else if 660 + username_variation * 30
> 999
{
} else if 660 + username_variation * 30 > 999 {
999
} else {
660 + username_variation * 30
@@ -670,12 +615,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
let r_2 = dc_loginparam_get_readable(&param);
info!(context, 0, "Trying: {}", r_2,);
if context
.inbox
.read()
.unwrap()
.connect(context, &param)
{
if context.inbox.read().unwrap().connect(context, &param) {
ok_to_continue8 = true;
break;
}
@@ -692,9 +632,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
Event::CONFIGURE_PROGRESS,
(if 670 + username_variation * 30 < 1 {
1
} else if 670 + username_variation * 30
> 999
{
} else if 670 + username_variation * 30 > 999 {
999
} else {
670 + username_variation * 30
@@ -707,18 +645,12 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
param.mail_port = 993;
if let Some(at) = param.mail_user.find('@') {
param.mail_user = param
.mail_user
.split_at(at)
.0
.to_string();
param.mail_user =
param.mail_user.split_at(at).0.to_string();
}
if let Some(at) = param.send_user.find('@') {
param.send_user = param
.send_user
.split_at(at)
.0
.to_string();
param.send_user =
param.send_user.split_at(at).0.to_string();
}
username_variation += 1
@@ -764,19 +696,12 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
as uintptr_t,
0 as uintptr_t,
);
param.server_flags &= !(0x10000
| 0x20000
| 0x40000);
param.server_flags &=
!(0x10000 | 0x20000 | 0x40000);
param.server_flags |= 0x10000;
param.send_port = 587;
let r_3 =
dc_loginparam_get_readable(
&param,
);
info!(
context,
0, "Trying: {}", r_3,
);
let r_3 = dc_loginparam_get_readable(&param);
info!(context, 0, "Trying: {}", r_3,);
if !context
.smtp
@@ -790,47 +715,30 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
} else {
context.call_cb(
Event::CONFIGURE_PROGRESS,
(if 860
<
(if 860 < 1 {
1
{
1
} else if 860
>
999
{
} else if 860 > 999 {
999
} else {
860
})
as
uintptr_t,
0
as
uintptr_t);
param.server_flags &=
!(0x10000
| 0x20000
| 0x40000);
param.server_flags |=
0x10000;
param.send_port = 25;
let r_4 = dc_loginparam_get_readable(&param);
info!(
context,
0,
"Trying: {}",
r_4
as uintptr_t,
0 as uintptr_t,
);
param.server_flags &=
!(0x10000 | 0x20000 | 0x40000);
param.server_flags |= 0x10000;
param.send_port = 25;
let r_4 =
dc_loginparam_get_readable(&param);
info!(context, 0, "Trying: {}", r_4);
if !context
.smtp
.clone()
.lock()
.unwrap()
.connect(
context, &param,
)
.connect(context, &param)
{
ok_to_continue9 = false;
} else {
@@ -862,22 +770,13 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
flags = if 0
!= context
.sql
.get_config_int(
context,
"mvbox_watch",
)
.unwrap_or_else(
|| 1,
)
.get_config_int(context, "mvbox_watch")
.unwrap_or_else(|| 1)
|| 0 != context
.sql
.get_config_int(
context,
"mvbox_move",
)
.unwrap_or_else(
|| 1,
) {
.get_config_int(context, "mvbox_move")
.unwrap_or_else(|| 1)
{
0x1
} else {
0
@@ -887,30 +786,19 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
.inbox
.read()
.unwrap()
.configure_folders(
context, flags,
);
.configure_folders(context, flags);
if !s.shall_stop_ongoing {
context.call_cb(
Event::CONFIGURE_PROGRESS,
(if 910
<
(if 910 < 1 {
1
{
1
} else if 910
>
999
{
} else if 910 > 999 {
999
} else {
910
})
as
uintptr_t,
0
as
uintptr_t
as uintptr_t,
0 as uintptr_t,
);
dc_loginparam_write(
context,
@@ -926,58 +814,38 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
1,
)
.ok();
if !s.shall_stop_ongoing
{
if !s.shall_stop_ongoing {
context.call_cb(
Event::CONFIGURE_PROGRESS,
(if 920
<
(if 920 < 1 {
1
{
1
} else if 920
>
999
{
} else if 920 > 999 {
999
} else {
920
})
as
uintptr_t,
0
as
uintptr_t
as uintptr_t,
0 as uintptr_t,
);
dc_ensure_secret_key_exists(context);
success = true;
info!(
context,
0,
"Configure completed."
0, "Configure completed."
);
if !s.shall_stop_ongoing
{
if !s.shall_stop_ongoing {
context.call_cb(
Event::CONFIGURE_PROGRESS,
(if 940
<
(if 940 < 1 {
1
{
1
} else if 940
>
999
{
} else if 940 > 999 {
999
} else {
940
})
as
uintptr_t,
0
as
uintptr_t);
as uintptr_t,
0 as uintptr_t,
);
}
}
}