mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
resolve last fixmes
This commit is contained in:
@@ -72,13 +72,14 @@ pub unsafe fn dc_configure(mut context: &dc_context_t) {
|
|||||||
dc_job_add(context, 900i32, 0i32, 0 as *const libc::c_char, 0i32);
|
dc_job_add(context, 900i32, 0i32, 0 as *const libc::c_char, 0i32);
|
||||||
}
|
}
|
||||||
pub unsafe fn dc_has_ongoing(mut context: &dc_context_t) -> libc::c_int {
|
pub unsafe fn dc_has_ongoing(mut context: &dc_context_t) -> libc::c_int {
|
||||||
return if 0 != context.ongoing_running
|
let s_a = context.running_state.clone();
|
||||||
|| *context.shall_stop_ongoing.clone().read().unwrap() == 0
|
let s = s_a.read().unwrap();
|
||||||
{
|
|
||||||
1i32
|
if s.ongoing_running || !s.shall_stop_ongoing {
|
||||||
|
1
|
||||||
} else {
|
} else {
|
||||||
0i32
|
0
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
pub unsafe fn dc_is_configured(mut context: &dc_context_t) -> libc::c_int {
|
pub unsafe fn dc_is_configured(mut context: &dc_context_t) -> libc::c_int {
|
||||||
return if 0
|
return if 0
|
||||||
@@ -94,13 +95,16 @@ pub unsafe fn dc_is_configured(mut context: &dc_context_t) -> libc::c_int {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
pub unsafe fn dc_stop_ongoing_process(context: &dc_context_t) {
|
pub unsafe fn dc_stop_ongoing_process(context: &dc_context_t) {
|
||||||
if 0 != context.ongoing_running && *context.shall_stop_ongoing.clone().read().unwrap() == 0 {
|
let s_a = context.running_state.clone();
|
||||||
|
let mut s = s_a.write().unwrap();
|
||||||
|
|
||||||
|
if s.ongoing_running && !s.shall_stop_ongoing {
|
||||||
dc_log_info(
|
dc_log_info(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0i32,
|
||||||
b"Signaling the ongoing process to stop ASAP.\x00" as *const u8 as *const libc::c_char,
|
b"Signaling the ongoing process to stop ASAP.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
*context.shall_stop_ongoing.clone().write().unwrap() = 1;
|
s.shall_stop_ongoing = true;
|
||||||
} else {
|
} else {
|
||||||
dc_log_info(
|
dc_log_info(
|
||||||
context,
|
context,
|
||||||
@@ -186,7 +190,10 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
0i32,
|
0i32,
|
||||||
b"Configure ...\x00" as *const u8 as *const libc::c_char,
|
b"Configure ...\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
if !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
let s_a = context.running_state.clone();
|
||||||
|
let s = s_a.read().unwrap();
|
||||||
|
|
||||||
|
if s.shall_stop_ongoing {
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -218,7 +225,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
// the used oauth2 addr may differ, check this.
|
// the used oauth2 addr may differ, check this.
|
||||||
// if dc_get_oauth2_addr() is not available in the oauth2 implementation,
|
// if dc_get_oauth2_addr() is not available in the oauth2 implementation,
|
||||||
// just use the given one.
|
// just use the given one.
|
||||||
if 0 != *context.shall_stop_ongoing.clone().read().unwrap() {
|
if s.shall_stop_ongoing {
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
@@ -245,7 +252,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
(*param).addr,
|
(*param).addr,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if 0 != *context.shall_stop_ongoing.clone().read().unwrap() {
|
if s.shall_stop_ongoing {
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
@@ -284,7 +291,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
if (*param).mail_pw.is_null() {
|
if (*param).mail_pw.is_null() {
|
||||||
(*param).mail_pw = dc_strdup(0 as *const libc::c_char)
|
(*param).mail_pw = dc_strdup(0 as *const libc::c_char)
|
||||||
}
|
}
|
||||||
if !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
if !s.shall_stop_ongoing {
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -325,12 +332,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
param_autoconfig =
|
param_autoconfig =
|
||||||
moz_autoconfigure(context, url, param);
|
moz_autoconfigure(context, url, param);
|
||||||
free(url as *mut libc::c_void);
|
free(url as *mut libc::c_void);
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
@@ -368,12 +370,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
param_autoconfig =
|
param_autoconfig =
|
||||||
moz_autoconfigure(context, url_0, param);
|
moz_autoconfigure(context, url_0, param);
|
||||||
free(url_0 as *mut libc::c_void);
|
free(url_0 as *mut libc::c_void);
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
@@ -435,12 +432,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
context, url_1, param,
|
context, url_1, param,
|
||||||
);
|
);
|
||||||
free(url_1 as *mut libc::c_void);
|
free(url_1 as *mut libc::c_void);
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
break;
|
break;
|
||||||
@@ -483,12 +475,8 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
free(
|
free(
|
||||||
url_2 as *mut libc::c_void,
|
url_2 as *mut libc::c_void,
|
||||||
);
|
);
|
||||||
if 0 != *context
|
|
||||||
.shall_stop_ongoing
|
if s.shall_stop_ongoing {
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
@@ -544,11 +532,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
free(url_3
|
free(url_3
|
||||||
as
|
as
|
||||||
*mut libc::c_void);
|
*mut libc::c_void);
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
{
|
||||||
current_block
|
current_block
|
||||||
=
|
=
|
||||||
@@ -607,9 +591,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
free(url_4
|
free(url_4
|
||||||
as
|
as
|
||||||
*mut libc::c_void);
|
*mut libc::c_void);
|
||||||
if 0
|
if s.shall_stop_ongoing
|
||||||
!=
|
|
||||||
*context.shall_stop_ongoing.clone().read().unwrap()
|
|
||||||
{
|
{
|
||||||
current_block
|
current_block
|
||||||
=
|
=
|
||||||
@@ -834,13 +816,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
b"Account settings incomplete.\x00" as *const u8
|
b"Account settings incomplete.\x00" as *const u8
|
||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
} else if !(0
|
} else if !s.shall_stop_ongoing {
|
||||||
!= *context
|
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap())
|
|
||||||
{
|
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -885,12 +861,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// probe STARTTLS/993
|
// probe STARTTLS/993
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -934,12 +905,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// probe STARTTLS/143
|
// probe STARTTLS/143
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -985,12 +951,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// next probe round with only the localpart of the email-address as the loginname
|
// next probe round with only the localpart of the email-address as the loginname
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block = 2927484062889439186;
|
current_block = 2927484062889439186;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1031,13 +992,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
2927484062889439186 => {}
|
2927484062889439186 => {}
|
||||||
_ => {
|
_ => {
|
||||||
imap_connected_here = 1i32;
|
imap_connected_here = 1i32;
|
||||||
if !(0
|
if !s.shall_stop_ongoing {
|
||||||
!= *context
|
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap())
|
|
||||||
{
|
|
||||||
(context.cb)(
|
(context.cb)(
|
||||||
context,
|
context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -1064,13 +1019,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
if !param_autoconfig.is_null() {
|
if !param_autoconfig.is_null() {
|
||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else if 0
|
} else if s.shall_stop_ongoing {
|
||||||
!= *context
|
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
@@ -1116,12 +1065,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
param,
|
param,
|
||||||
) {
|
) {
|
||||||
if 0 != *context
|
if s.shall_stop_ongoing {
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
current_block =
|
current_block =
|
||||||
2927484062889439186;
|
2927484062889439186;
|
||||||
} else {
|
} else {
|
||||||
@@ -1199,13 +1143,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
2927484062889439186 => {}
|
2927484062889439186 => {}
|
||||||
_ => {
|
_ => {
|
||||||
smtp_connected_here = 1i32;
|
smtp_connected_here = 1i32;
|
||||||
if !(0
|
if !s.shall_stop_ongoing {
|
||||||
!= *context
|
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap())
|
|
||||||
{
|
|
||||||
(context.cb)(context,
|
(context.cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 900i32
|
(if 900i32
|
||||||
@@ -1261,13 +1199,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
flags,
|
flags,
|
||||||
);
|
);
|
||||||
if !(0
|
if !s.shall_stop_ongoing {
|
||||||
!= *context
|
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap())
|
|
||||||
{
|
|
||||||
(context.cb)(context,
|
(context.cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
(if 910i32
|
(if 910i32
|
||||||
@@ -1302,11 +1234,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
as
|
as
|
||||||
*const libc::c_char,
|
*const libc::c_char,
|
||||||
1i32);
|
1i32);
|
||||||
if !(0 != *context
|
if !s.shall_stop_ongoing
|
||||||
.shall_stop_ongoing
|
|
||||||
.clone()
|
|
||||||
.read()
|
|
||||||
.unwrap())
|
|
||||||
{
|
{
|
||||||
(context.cb)(context,
|
(context.cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -1337,9 +1265,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
*const u8
|
*const u8
|
||||||
as
|
as
|
||||||
*const libc::c_char);
|
*const libc::c_char);
|
||||||
if !(0
|
if !s.shall_stop_ongoing
|
||||||
!=
|
|
||||||
*context.shall_stop_ongoing.clone().read().unwrap())
|
|
||||||
{
|
{
|
||||||
(context.cb)(context,
|
(context.cb)(context,
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -1403,10 +1329,12 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_free_ongoing(mut context: &dc_context_t) {
|
pub unsafe fn dc_free_ongoing(context: &dc_context_t) {
|
||||||
// FIXME
|
let s_a = context.running_state.clone();
|
||||||
// context.ongoing_running = 0i32;
|
let mut s = s_a.write().unwrap();
|
||||||
*context.shall_stop_ongoing.clone().write().unwrap() = 1;
|
|
||||||
|
s.ongoing_running = false;
|
||||||
|
s.shall_stop_ongoing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_configure_folders(
|
pub unsafe fn dc_configure_folders(
|
||||||
@@ -2163,10 +2091,13 @@ pub unsafe fn dc_alloc_ongoing(context: &dc_context_t) -> libc::c_int {
|
|||||||
);
|
);
|
||||||
return 0i32;
|
return 0i32;
|
||||||
}
|
}
|
||||||
// FIXME
|
let s_a = context.running_state.clone();
|
||||||
// context.ongoing_running = 1i32;
|
let mut s = s_a.write().unwrap();
|
||||||
*context.shall_stop_ongoing.clone().write().unwrap() = 0;
|
|
||||||
return 1i32;
|
s.ongoing_running = true;
|
||||||
|
s.shall_stop_ongoing = false;
|
||||||
|
|
||||||
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_connect_to_configured_imap(
|
pub unsafe fn dc_connect_to_configured_imap(
|
||||||
|
|||||||
@@ -42,13 +42,27 @@ pub struct dc_context_t {
|
|||||||
pub cmdline_sel_chat_id: u32,
|
pub cmdline_sel_chat_id: u32,
|
||||||
pub bob: Arc<RwLock<BobStatus>>,
|
pub bob: Arc<RwLock<BobStatus>>,
|
||||||
pub last_smeared_timestamp: Arc<RwLock<time_t>>,
|
pub last_smeared_timestamp: Arc<RwLock<time_t>>,
|
||||||
pub ongoing_running: i32,
|
pub running_state: Arc<RwLock<RunningState>>,
|
||||||
pub shall_stop_ongoing: Arc<RwLock<i32>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl std::marker::Send for dc_context_t {}
|
unsafe impl std::marker::Send for dc_context_t {}
|
||||||
unsafe impl std::marker::Sync for dc_context_t {}
|
unsafe impl std::marker::Sync for dc_context_t {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct RunningState {
|
||||||
|
pub ongoing_running: bool,
|
||||||
|
pub shall_stop_ongoing: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for RunningState {
|
||||||
|
fn default() -> Self {
|
||||||
|
RunningState {
|
||||||
|
ongoing_running: false,
|
||||||
|
shall_stop_ongoing: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BobStatus {
|
pub struct BobStatus {
|
||||||
pub expects: i32,
|
pub expects: i32,
|
||||||
@@ -111,8 +125,7 @@ pub fn dc_context_new(
|
|||||||
userdata,
|
userdata,
|
||||||
cb,
|
cb,
|
||||||
os_name: unsafe { dc_strdup_keep_null(os_name) },
|
os_name: unsafe { dc_strdup_keep_null(os_name) },
|
||||||
ongoing_running: 0,
|
running_state: Arc::new(RwLock::new(Default::default())),
|
||||||
shall_stop_ongoing: Arc::new(RwLock::new(1)),
|
|
||||||
sql: Arc::new(Mutex::new(dc_sqlite3_new())),
|
sql: Arc::new(Mutex::new(dc_sqlite3_new())),
|
||||||
smtp: Arc::new(Mutex::new(dc_smtp_new())),
|
smtp: Arc::new(Mutex::new(dc_smtp_new())),
|
||||||
smtp_state: Arc::new((Mutex::new(Default::default()), Condvar::new())),
|
smtp_state: Arc::new((Mutex::new(Default::default()), Condvar::new())),
|
||||||
|
|||||||
@@ -165,11 +165,23 @@ pub unsafe fn dc_initiate_key_transfer(mut context: &dc_context_t) -> *mut libc:
|
|||||||
setup_code = dc_create_setup_code(context);
|
setup_code = dc_create_setup_code(context);
|
||||||
if !setup_code.is_null() {
|
if !setup_code.is_null() {
|
||||||
/* this may require a keypair to be created. this may take a second ... */
|
/* this may require a keypair to be created. this may take a second ... */
|
||||||
if !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
if !context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing
|
||||||
|
{
|
||||||
setup_file_content = dc_render_setup_file(context, setup_code);
|
setup_file_content = dc_render_setup_file(context, setup_code);
|
||||||
if !setup_file_content.is_null() {
|
if !setup_file_content.is_null() {
|
||||||
/* encrypting may also take a while ... */
|
/* encrypting may also take a while ... */
|
||||||
if !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
if !context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing
|
||||||
|
{
|
||||||
setup_file_name = dc_get_fine_pathNfilename(
|
setup_file_name = dc_get_fine_pathNfilename(
|
||||||
context,
|
context,
|
||||||
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
|
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
|
||||||
@@ -196,7 +208,13 @@ pub unsafe fn dc_initiate_key_transfer(mut context: &dc_context_t) -> *mut libc:
|
|||||||
);
|
);
|
||||||
dc_param_set_int((*msg).param, 'S' as i32, 6i32);
|
dc_param_set_int((*msg).param, 'S' as i32, 6i32);
|
||||||
dc_param_set_int((*msg).param, 'u' as i32, 2i32);
|
dc_param_set_int((*msg).param, 'u' as i32, 2i32);
|
||||||
if !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
if !context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing
|
||||||
|
{
|
||||||
msg_id = dc_send_msg(context, chat_id, msg);
|
msg_id = dc_send_msg(context, chat_id, msg);
|
||||||
if !(msg_id == 0i32 as libc::c_uint) {
|
if !(msg_id == 0i32 as libc::c_uint) {
|
||||||
dc_msg_unref(msg);
|
dc_msg_unref(msg);
|
||||||
@@ -208,7 +226,12 @@ pub unsafe fn dc_initiate_key_transfer(mut context: &dc_context_t) -> *mut libc:
|
|||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
loop {
|
loop {
|
||||||
if 0 != *context.shall_stop_ongoing.clone().read().unwrap()
|
if context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing
|
||||||
{
|
{
|
||||||
current_block = 6116957410927263949;
|
current_block = 6116957410927263949;
|
||||||
break;
|
break;
|
||||||
@@ -1005,7 +1028,13 @@ unsafe fn import_backup(
|
|||||||
current_block = 10891380440665537214;
|
current_block = 10891380440665537214;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if 0 != *context.shall_stop_ongoing.clone().read().unwrap() {
|
if context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing
|
||||||
|
{
|
||||||
current_block = 8648553629232744886;
|
current_block = 8648553629232744886;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1223,7 +1252,12 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
|||||||
current_block = 2631791190359682872;
|
current_block = 2631791190359682872;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if 0 != *context.shall_stop_ongoing.clone().read().unwrap()
|
if context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing
|
||||||
{
|
{
|
||||||
delete_dest_file = 1i32;
|
delete_dest_file = 1i32;
|
||||||
current_block = 11487273724841241105;
|
current_block = 11487273724841241105;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use libc;
|
use libc;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use std::time::Duration;
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use crate::constants::Event;
|
use crate::constants::Event;
|
||||||
use crate::dc_chat::*;
|
use crate::dc_chat::*;
|
||||||
@@ -1249,9 +1249,7 @@ pub unsafe fn dc_perform_smtp_idle(mut context: &dc_context_t) {
|
|||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: correct time based on
|
let dur = get_next_wakeup_time(context, 5000);
|
||||||
// get_next_wakeup_time(context, 5000) + 1;
|
|
||||||
let dur = Duration::from_millis(5000);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let res = cvar.wait_timeout(state, dur).unwrap();
|
let res = cvar.wait_timeout(state, dur).unwrap();
|
||||||
@@ -1273,24 +1271,29 @@ pub unsafe fn dc_perform_smtp_idle(mut context: &dc_context_t) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_next_wakeup_time(context: &dc_context_t, thread: libc::c_int) -> time_t {
|
unsafe fn get_next_wakeup_time(context: &dc_context_t, thread: libc::c_int) -> Duration {
|
||||||
let mut wakeup_time: time_t = 0i32 as time_t;
|
let stmt = dc_sqlite3_prepare(
|
||||||
let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
|
|
||||||
stmt = dc_sqlite3_prepare(
|
|
||||||
context,
|
context,
|
||||||
&mut context.sql.clone().lock().unwrap(),
|
&mut context.sql.clone().lock().unwrap(),
|
||||||
b"SELECT MIN(desired_timestamp) FROM jobs WHERE thread=?;\x00" as *const u8
|
b"SELECT MIN(desired_timestamp) FROM jobs WHERE thread=?;\x00" as *const u8
|
||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
sqlite3_bind_int(stmt, 1i32, thread);
|
sqlite3_bind_int(stmt, 1, thread);
|
||||||
if sqlite3_step(stmt) == 100i32 {
|
|
||||||
wakeup_time = sqlite3_column_int(stmt, 0i32) as time_t
|
let mut wakeup_time = Duration::new(10 * 60, 0);
|
||||||
}
|
|
||||||
if wakeup_time == 0i32 as libc::c_long {
|
if sqlite3_step(stmt) == 100 {
|
||||||
wakeup_time = time(0 as *mut time_t) + (10i32 * 60i32) as libc::c_long
|
let t = sqlite3_column_int(stmt, 0) as u64;
|
||||||
|
let now = SystemTime::now()
|
||||||
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap();
|
||||||
|
if t > 0 {
|
||||||
|
wakeup_time = Duration::new(t, 0) - now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return wakeup_time;
|
wakeup_time
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_maybe_network(mut context: &dc_context_t) {
|
pub unsafe fn dc_maybe_network(mut context: &dc_context_t) {
|
||||||
|
|||||||
@@ -208,7 +208,13 @@ pub unsafe fn dc_join_securejoin(
|
|||||||
0i32,
|
0i32,
|
||||||
b"Unknown contact.\x00" as *const u8 as *const libc::c_char,
|
b"Unknown contact.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
} else if !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
} else if !(context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing)
|
||||||
|
{
|
||||||
join_vg = ((*qr_scan).state == 202i32) as libc::c_int;
|
join_vg = ((*qr_scan).state == 202i32) as libc::c_int;
|
||||||
let bob_a = context.bob.clone();
|
let bob_a = context.bob.clone();
|
||||||
let mut bob = bob_a.write().unwrap();
|
let mut bob = bob_a.write().unwrap();
|
||||||
@@ -262,7 +268,13 @@ pub unsafe fn dc_join_securejoin(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Bob -> Alice
|
// Bob -> Alice
|
||||||
while !(0 != *context.shall_stop_ongoing.clone().read().unwrap()) {
|
while !(context
|
||||||
|
.running_state
|
||||||
|
.clone()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.shall_stop_ongoing)
|
||||||
|
{
|
||||||
usleep((300i32 * 1000i32) as useconds_t);
|
usleep((300i32 * 1000i32) as useconds_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user