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