mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
cargo fmt
This commit is contained in:
41
src/dc_qr.rs
41
src/dc_qr.rs
@@ -201,9 +201,8 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
|
|||||||
addr = temp;
|
addr = temp;
|
||||||
if !may_be_valid_addr(as_str(addr)) {
|
if !may_be_valid_addr(as_str(addr)) {
|
||||||
(*qr_parsed).state = 400i32;
|
(*qr_parsed).state = 400i32;
|
||||||
(*qr_parsed).text1 = dc_strdup(
|
(*qr_parsed).text1 =
|
||||||
b"Bad e-mail address.\x00" as *const u8 as *const libc::c_char,
|
dc_strdup(b"Bad e-mail address.\x00" as *const u8 as *const libc::c_char);
|
||||||
);
|
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,18 +210,14 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
|
|||||||
if ok_to_continue && !fingerprint.is_null() && strlen(fingerprint) != 40 {
|
if ok_to_continue && !fingerprint.is_null() && strlen(fingerprint) != 40 {
|
||||||
(*qr_parsed).state = 400i32;
|
(*qr_parsed).state = 400i32;
|
||||||
(*qr_parsed).text1 = dc_strdup(
|
(*qr_parsed).text1 = dc_strdup(
|
||||||
b"Bad fingerprint length in QR code.\x00" as *const u8
|
b"Bad fingerprint length in QR code.\x00" as *const u8 as *const libc::c_char,
|
||||||
as *const libc::c_char,
|
|
||||||
);
|
);
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
}
|
}
|
||||||
if ok_to_continue {
|
if ok_to_continue {
|
||||||
if !fingerprint.is_null() {
|
if !fingerprint.is_null() {
|
||||||
let peerstate = Peerstate::from_fingerprint(
|
let peerstate =
|
||||||
context,
|
Peerstate::from_fingerprint(context, &context.sql, as_str(fingerprint));
|
||||||
&context.sql,
|
|
||||||
as_str(fingerprint),
|
|
||||||
);
|
|
||||||
if addr.is_null() || invitenumber.is_null() || auth.is_null() {
|
if addr.is_null() || invitenumber.is_null() || auth.is_null() {
|
||||||
if let Some(peerstate) = peerstate {
|
if let Some(peerstate) = peerstate {
|
||||||
(*qr_parsed).state = 210i32;
|
(*qr_parsed).state = 210i32;
|
||||||
@@ -231,12 +226,8 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.as_str())
|
.map(|s| s.as_str())
|
||||||
.unwrap_or_else(|| "");
|
.unwrap_or_else(|| "");
|
||||||
(*qr_parsed).id = Contact::add_or_lookup(
|
(*qr_parsed).id =
|
||||||
context,
|
Contact::add_or_lookup(context, "", addr, Origin::UnhandledQrScan)
|
||||||
"",
|
|
||||||
addr,
|
|
||||||
Origin::UnhandledQrScan,
|
|
||||||
)
|
|
||||||
.map(|(id, _)| id)
|
.map(|(id, _)| id)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
dc_create_or_lookup_nchat_by_contact_id(
|
dc_create_or_lookup_nchat_by_contact_id(
|
||||||
@@ -247,13 +238,11 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
|
|||||||
0 as *mut libc::c_int,
|
0 as *mut libc::c_int,
|
||||||
);
|
);
|
||||||
device_msg = dc_mprintf(
|
device_msg = dc_mprintf(
|
||||||
b"%s verified.\x00" as *const u8
|
b"%s verified.\x00" as *const u8 as *const libc::c_char,
|
||||||
as *const libc::c_char,
|
|
||||||
peerstate.addr,
|
peerstate.addr,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(*qr_parsed).text1 =
|
(*qr_parsed).text1 = dc_format_fingerprint_c(fingerprint);
|
||||||
dc_format_fingerprint_c(fingerprint);
|
|
||||||
(*qr_parsed).state = 230i32
|
(*qr_parsed).state = 230i32
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -286,14 +275,10 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
|
|||||||
)
|
)
|
||||||
.map(|(id, _)| id)
|
.map(|(id, _)| id)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
} else if strstr(
|
} else if strstr(qr, b"http://\x00" as *const u8 as *const libc::c_char)
|
||||||
qr,
|
== qr as *mut libc::c_char
|
||||||
b"http://\x00" as *const u8 as *const libc::c_char,
|
|| strstr(qr, b"https://\x00" as *const u8 as *const libc::c_char)
|
||||||
) == qr as *mut libc::c_char
|
== qr as *mut libc::c_char
|
||||||
|| strstr(
|
|
||||||
qr,
|
|
||||||
b"https://\x00" as *const u8 as *const libc::c_char,
|
|
||||||
) == qr as *mut libc::c_char
|
|
||||||
{
|
{
|
||||||
(*qr_parsed).state = 332i32;
|
(*qr_parsed).state = 332i32;
|
||||||
(*qr_parsed).text1 = dc_strdup(qr)
|
(*qr_parsed).text1 = dc_strdup(qr)
|
||||||
|
|||||||
Reference in New Issue
Block a user