mirror of
https://github.com/chatmail/core.git
synced 2026-04-24 17:06:28 +03:00
@@ -485,48 +485,51 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &Context, job: &mut dc_job_t) {
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
|
||||
let server_folder = CStr::from_ptr((*msg).server_folder).to_str().unwrap();
|
||||
match inbox.mv(
|
||||
context,
|
||||
server_folder,
|
||||
(*msg).server_uid,
|
||||
CStr::from_ptr(dest_folder).to_str().unwrap(),
|
||||
&mut dest_uid,
|
||||
) as libc::c_uint
|
||||
{
|
||||
1 => {
|
||||
current_block = 6379107252614456477;
|
||||
match current_block {
|
||||
12072121998757195963 => {
|
||||
dc_update_server_uid(
|
||||
context,
|
||||
(*msg).rfc724_mid,
|
||||
dest_folder,
|
||||
dest_uid,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
if !dest_folder.is_null() {
|
||||
let server_folder = to_str((*msg).server_folder);
|
||||
|
||||
match inbox.mv(
|
||||
context,
|
||||
server_folder,
|
||||
(*msg).server_uid,
|
||||
to_str(dest_folder),
|
||||
&mut dest_uid,
|
||||
) as libc::c_uint
|
||||
{
|
||||
1 => {
|
||||
current_block = 6379107252614456477;
|
||||
match current_block {
|
||||
12072121998757195963 => {
|
||||
dc_update_server_uid(
|
||||
context,
|
||||
(*msg).rfc724_mid,
|
||||
dest_folder,
|
||||
dest_uid,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3 => {
|
||||
current_block = 12072121998757195963;
|
||||
match current_block {
|
||||
12072121998757195963 => {
|
||||
dc_update_server_uid(
|
||||
context,
|
||||
(*msg).rfc724_mid,
|
||||
dest_folder,
|
||||
dest_uid,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
3 => {
|
||||
current_block = 12072121998757195963;
|
||||
match current_block {
|
||||
12072121998757195963 => {
|
||||
dc_update_server_uid(
|
||||
context,
|
||||
(*msg).rfc724_mid,
|
||||
dest_folder,
|
||||
dest_uid,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
}
|
||||
}
|
||||
}
|
||||
0 | 2 | _ => {}
|
||||
}
|
||||
0 | 2 | _ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -589,12 +592,13 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_
|
||||
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let dest_folder = CStr::from_ptr(dest_folder).to_str().unwrap();
|
||||
match inbox.mv(context, folder, uid, dest_folder, &mut dest_uid) as libc::c_uint {
|
||||
1 => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
if !dest_folder.is_null() {
|
||||
let dest_folder = to_str(dest_folder);
|
||||
if 1 == inbox.mv(context, folder, uid, dest_folder, &mut dest_uid)
|
||||
as libc::c_uint
|
||||
{
|
||||
dc_job_try_again_later(job, 3, 0 as *const libc::c_char);
|
||||
}
|
||||
0 | _ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,10 +208,12 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
||||
.shall_stop_ongoing)
|
||||
{
|
||||
join_vg = ((*qr_scan).state == 202i32) as libc::c_int;
|
||||
let bob_a = context.bob.clone();
|
||||
let mut bob = bob_a.write().unwrap();
|
||||
bob.status = 0;
|
||||
bob.qr_scan = qr_scan;
|
||||
{
|
||||
let bob_a = context.bob.clone();
|
||||
let mut bob = bob_a.write().unwrap();
|
||||
bob.status = 0;
|
||||
bob.qr_scan = qr_scan;
|
||||
}
|
||||
if 0 != fingerprint_equals_sender(context, (*qr_scan).fingerprint, contact_chat_id)
|
||||
{
|
||||
dc_log_info(
|
||||
@@ -219,7 +221,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
||||
0i32,
|
||||
b"Taking protocol shortcut.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
bob.expects = 6;
|
||||
context.bob.clone().write().unwrap().expects = 6;
|
||||
(context.cb)(
|
||||
context,
|
||||
Event::SECUREJOIN_JOINER_PROGRESS,
|
||||
@@ -245,7 +247,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
||||
);
|
||||
free(own_fingerprint as *mut libc::c_void);
|
||||
} else {
|
||||
bob.expects = 2;
|
||||
context.bob.clone().write().unwrap().expects = 2;
|
||||
send_handshake_msg(
|
||||
context,
|
||||
contact_chat_id,
|
||||
@@ -259,6 +261,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
}
|
||||
|
||||
// Bob -> Alice
|
||||
while !(context
|
||||
.running_state
|
||||
@@ -267,7 +270,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
||||
.unwrap()
|
||||
.shall_stop_ongoing)
|
||||
{
|
||||
std::thread::sleep(std::time::Duration::from_micros(300 * 1000));
|
||||
std::thread::sleep(std::time::Duration::new(0, 3_000_000));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,11 +498,14 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
b"vc-auth-required\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
let bob_a = context.bob.clone();
|
||||
let bob = bob_a.read().unwrap();
|
||||
let scan = bob.qr_scan;
|
||||
if scan.is_null() || bob.expects != 2i32 || 0 != join_vg && (*scan).state != 202i32
|
||||
{
|
||||
let cond = {
|
||||
let bob_a = context.bob.clone();
|
||||
let bob = bob_a.read().unwrap();
|
||||
let scan = bob.qr_scan;
|
||||
scan.is_null() || bob.expects != 2 || 0 != join_vg && (*scan).state != 202
|
||||
};
|
||||
|
||||
if cond {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0i32,
|
||||
@@ -509,10 +515,13 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
// no error, just aborted somehow or a mail from another handshake
|
||||
current_block = 4378276786830486580;
|
||||
} else {
|
||||
scanned_fingerprint_of_alice = dc_strdup((*scan).fingerprint);
|
||||
auth = dc_strdup((*scan).auth);
|
||||
if 0 != join_vg {
|
||||
grpid = dc_strdup((*scan).text2)
|
||||
{
|
||||
let scan = context.bob.clone().read().unwrap().qr_scan;
|
||||
scanned_fingerprint_of_alice = dc_strdup((*scan).fingerprint);
|
||||
auth = dc_strdup((*scan).auth);
|
||||
if 0 != join_vg {
|
||||
grpid = dc_strdup((*scan).text2)
|
||||
}
|
||||
}
|
||||
if 0 == encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice) {
|
||||
could_not_establish_secure_connection(
|
||||
@@ -735,8 +744,11 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
);
|
||||
current_block = 4378276786830486580;
|
||||
} else {
|
||||
let scan = context.bob.clone().read().unwrap().qr_scan;
|
||||
if scan.is_null() || 0 != join_vg && (*scan).state != 202i32 {
|
||||
let cond = {
|
||||
let scan = context.bob.clone().read().unwrap().qr_scan;
|
||||
scan.is_null() || 0 != join_vg && (*scan).state != 202
|
||||
};
|
||||
if cond {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0i32,
|
||||
@@ -745,9 +757,12 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
);
|
||||
current_block = 4378276786830486580;
|
||||
} else {
|
||||
scanned_fingerprint_of_alice = dc_strdup((*scan).fingerprint);
|
||||
if 0 != join_vg {
|
||||
grpid = dc_strdup((*scan).text2)
|
||||
{
|
||||
let scan = context.bob.clone().read().unwrap().qr_scan;
|
||||
scanned_fingerprint_of_alice = dc_strdup((*scan).fingerprint);
|
||||
if 0 != join_vg {
|
||||
grpid = dc_strdup((*scan).text2)
|
||||
}
|
||||
}
|
||||
let mut vg_expect_encrypted: libc::c_int = 1i32;
|
||||
if 0 != join_vg {
|
||||
|
||||
@@ -1299,23 +1299,19 @@ pub unsafe fn dc_sqlite3_set_config_int64(
|
||||
ret
|
||||
}
|
||||
|
||||
pub unsafe fn dc_sqlite3_get_config_int64(
|
||||
pub fn dc_sqlite3_get_config_int64(
|
||||
context: &Context,
|
||||
sql: &dc_sqlite3_t,
|
||||
key: *const libc::c_char,
|
||||
def: int64_t,
|
||||
) -> int64_t {
|
||||
let str = dc_sqlite3_get_config(context, sql, key, 0 as *const libc::c_char);
|
||||
if str.is_null() {
|
||||
def: i64,
|
||||
) -> i64 {
|
||||
let s = unsafe { dc_sqlite3_get_config(context, sql, key, 0 as *const libc::c_char) };
|
||||
if s.is_null() {
|
||||
return def;
|
||||
}
|
||||
let mut ret = 0 as int64_t;
|
||||
sscanf(
|
||||
str,
|
||||
b"%lld\x00" as *const u8 as *const libc::c_char,
|
||||
&mut ret as *mut int64_t,
|
||||
);
|
||||
free(str as *mut libc::c_void);
|
||||
|
||||
let ret: i64 = to_str(s).parse().unwrap_or_default();
|
||||
unsafe { free(s as *mut libc::c_void) };
|
||||
ret
|
||||
}
|
||||
|
||||
|
||||
@@ -334,14 +334,12 @@ fn set_config_int64(context: &Context, key: &str, value: i64) {
|
||||
}
|
||||
|
||||
fn is_expired(context: &Context) -> bool {
|
||||
let expire_timestamp = unsafe {
|
||||
dc_sqlite3_get_config_int64(
|
||||
context,
|
||||
&context.sql.clone().read().unwrap(),
|
||||
b"oauth2_timestamp_expires\x00" as *const u8 as *const libc::c_char,
|
||||
0i32 as int64_t,
|
||||
)
|
||||
} as i64;
|
||||
let expire_timestamp = dc_sqlite3_get_config_int64(
|
||||
context,
|
||||
&context.sql.clone().read().unwrap(),
|
||||
b"oauth2_timestamp_expires\x00" as *const u8 as *const libc::c_char,
|
||||
0i32 as int64_t,
|
||||
);
|
||||
|
||||
if expire_timestamp <= 0 {
|
||||
return false;
|
||||
|
||||
4
src/x.rs
4
src/x.rs
@@ -4,8 +4,8 @@ use crate::types::*;
|
||||
pub use libc::{
|
||||
atoi, calloc, close, closedir, exit, fclose, fgets, fopen, fread, free, fseek, ftell, fwrite,
|
||||
malloc, memcmp, memcpy, memmove, memset, mkdir, open, opendir, printf, read, readdir, realloc,
|
||||
remove, sprintf, sscanf, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncmp, strncpy,
|
||||
strrchr, strspn, strstr, strtol, system, tolower, write,
|
||||
remove, sprintf, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncmp, strncpy, strrchr,
|
||||
strspn, strstr, strtol, system, tolower, write,
|
||||
};
|
||||
|
||||
pub unsafe fn strdup(s: *const libc::c_char) -> *mut libc::c_char {
|
||||
|
||||
Reference in New Issue
Block a user