mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
cleanup some parts, add comments
This commit is contained in:
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cargo build -p deltachat_ffi --release
|
cargo build -p deltachat_ffi
|
||||||
rm -rf build/ src/deltachat/*.so
|
rm -rf build/ src/deltachat/*.so
|
||||||
DCC_RS_DEV=`pwd`/.. pip install -e .
|
DCC_RS_DEV=`pwd`/.. pip install -e .
|
||||||
|
|||||||
@@ -114,11 +114,10 @@ pub unsafe fn dc_stop_ongoing_process(context: &Context) {
|
|||||||
pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_job_t) {
|
pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_job_t) {
|
||||||
let flags: libc::c_int;
|
let flags: libc::c_int;
|
||||||
let mut current_block: u64;
|
let mut current_block: u64;
|
||||||
let mut success: libc::c_int = 0i32;
|
let mut success = false;
|
||||||
let mut imap_connected_here: libc::c_int = 0i32;
|
let mut imap_connected_here = false;
|
||||||
let mut smtp_connected_here: libc::c_int = 0i32;
|
let mut smtp_connected_here = false;
|
||||||
let mut ongoing_allocated_here: libc::c_int = 0i32;
|
let mut ongoing_allocated_here = false;
|
||||||
let mvbox_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
|
||||||
let mut param: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t;
|
let mut param: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t;
|
||||||
/* just a pointer inside param, must not be freed! */
|
/* just a pointer inside param, must not be freed! */
|
||||||
let mut param_domain: *mut libc::c_char;
|
let mut param_domain: *mut libc::c_char;
|
||||||
@@ -126,7 +125,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
|||||||
let mut param_autoconfig: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t;
|
let mut param_autoconfig: *mut dc_loginparam_t = 0 as *mut dc_loginparam_t;
|
||||||
|
|
||||||
if !(0 == dc_alloc_ongoing(context)) {
|
if !(0 == dc_alloc_ongoing(context)) {
|
||||||
ongoing_allocated_here = 1i32;
|
ongoing_allocated_here = true;
|
||||||
if !context.sql.is_open() {
|
if !context.sql.is_open() {
|
||||||
dc_log_error(
|
dc_log_error(
|
||||||
context,
|
context,
|
||||||
@@ -950,7 +949,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
|||||||
match current_block {
|
match current_block {
|
||||||
2927484062889439186 => {}
|
2927484062889439186 => {}
|
||||||
_ => {
|
_ => {
|
||||||
imap_connected_here = 1i32;
|
imap_connected_here = true;
|
||||||
if !s.shall_stop_ongoing {
|
if !s.shall_stop_ongoing {
|
||||||
context.call_cb(
|
context.call_cb(
|
||||||
Event::CONFIGURE_PROGRESS,
|
Event::CONFIGURE_PROGRESS,
|
||||||
@@ -1094,7 +1093,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
|||||||
match current_block {
|
match current_block {
|
||||||
2927484062889439186 => {}
|
2927484062889439186 => {}
|
||||||
_ => {
|
_ => {
|
||||||
smtp_connected_here = 1i32;
|
smtp_connected_here = true;
|
||||||
if !s.shall_stop_ongoing {
|
if !s.shall_stop_ongoing {
|
||||||
context.call_cb(Event::CONFIGURE_PROGRESS,
|
context.call_cb(Event::CONFIGURE_PROGRESS,
|
||||||
(if 900i32
|
(if 900i32
|
||||||
@@ -1205,14 +1204,8 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
|||||||
as
|
as
|
||||||
uintptr_t);
|
uintptr_t);
|
||||||
dc_ensure_secret_key_exists(context);
|
dc_ensure_secret_key_exists(context);
|
||||||
success = 1i32;
|
success = true;
|
||||||
dc_log_info(context,
|
info!(context, 0, "Configure completed.");
|
||||||
0i32,
|
|
||||||
b"Configure completed.\x00"
|
|
||||||
as
|
|
||||||
*const u8
|
|
||||||
as
|
|
||||||
*const libc::c_char);
|
|
||||||
if !s.shall_stop_ongoing
|
if !s.shall_stop_ongoing
|
||||||
{
|
{
|
||||||
context.call_cb(Event::CONFIGURE_PROGRESS,
|
context.call_cb(Event::CONFIGURE_PROGRESS,
|
||||||
@@ -1255,26 +1248,23 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if imap_connected_here {
|
||||||
if 0 != imap_connected_here {
|
// XXX why do we want to disconnect here?
|
||||||
context.inbox.read().unwrap().disconnect(context);
|
// context.inbox.read().unwrap().disconnect(context);
|
||||||
|
info!(context, 0, "Skipping INBOX/IMAP disconnect");
|
||||||
}
|
}
|
||||||
if 0 != smtp_connected_here {
|
if smtp_connected_here {
|
||||||
context.smtp.clone().lock().unwrap().disconnect();
|
// XXX why do we want to disconnect here?
|
||||||
|
// context.smtp.clone().lock().unwrap().disconnect();
|
||||||
|
info!(context, 0, "Skipping SMTP disconnect");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
dc_loginparam_unref(param);
|
dc_loginparam_unref(param);
|
||||||
dc_loginparam_unref(param_autoconfig);
|
dc_loginparam_unref(param_autoconfig);
|
||||||
free(param_addr_urlencoded as *mut libc::c_void);
|
free(param_addr_urlencoded as *mut libc::c_void);
|
||||||
if 0 != ongoing_allocated_here {
|
if ongoing_allocated_here {
|
||||||
dc_free_ongoing(context);
|
dc_free_ongoing(context);
|
||||||
}
|
}
|
||||||
free(mvbox_folder as *mut libc::c_void);
|
context.call_cb(Event::CONFIGURE_PROGRESS, if success { 1000 } else { 0 }, 0);
|
||||||
context.call_cb(
|
|
||||||
Event::CONFIGURE_PROGRESS,
|
|
||||||
(if 0 != success { 1000i32 } else { 0i32 }) as uintptr_t,
|
|
||||||
0i32 as uintptr_t,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_free_ongoing(context: &Context) {
|
pub unsafe fn dc_free_ongoing(context: &Context) {
|
||||||
|
|||||||
@@ -49,22 +49,14 @@ pub struct dc_job_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_perform_imap_jobs(context: &Context) {
|
pub unsafe fn dc_perform_imap_jobs(context: &Context) {
|
||||||
info!(
|
info!(context, 0, "dc_perform_imap_jobs starting.",);
|
||||||
context,
|
|
||||||
0,
|
|
||||||
"dc_perform_imap_jobs starting.",
|
|
||||||
);
|
|
||||||
|
|
||||||
let probe_imap_network = *context.probe_imap_network.clone().read().unwrap();
|
let probe_imap_network = *context.probe_imap_network.clone().read().unwrap();
|
||||||
*context.probe_imap_network.write().unwrap() = 0;
|
*context.probe_imap_network.write().unwrap() = 0;
|
||||||
*context.perform_inbox_jobs_needed.write().unwrap() = 0;
|
*context.perform_inbox_jobs_needed.write().unwrap() = 0;
|
||||||
|
|
||||||
dc_job_perform(context, 100, probe_imap_network);
|
dc_job_perform(context, 100, probe_imap_network);
|
||||||
info!(
|
info!(context, 0, "dc_perform_imap_jobs ended.",);
|
||||||
context,
|
|
||||||
0,
|
|
||||||
"dc_perform_imap_jobs ended.",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network: libc::c_int) {
|
unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network: libc::c_int) {
|
||||||
|
|||||||
27
src/imap.rs
27
src/imap.rs
@@ -471,11 +471,14 @@ impl Imap {
|
|||||||
|
|
||||||
fn unsetup_handle(&self, context: &Context) {
|
fn unsetup_handle(&self, context: &Context) {
|
||||||
info!(context, 0, "IMAP unsetup_handle starts");
|
info!(context, 0, "IMAP unsetup_handle starts");
|
||||||
// self.interrupt_idle();
|
|
||||||
/*
|
// XXX the next line currently can block even if all threads
|
||||||
{
|
// terminated already
|
||||||
let session = self.session.lock().unwrap().take();
|
let session = self.session.lock().unwrap().take();
|
||||||
info!(context, 0, "IMAP unsetup_handle step1");
|
info!(
|
||||||
|
context,
|
||||||
|
0, "IMAP unsetup_handle step1 (acquired session.lock)"
|
||||||
|
);
|
||||||
if session.is_some() {
|
if session.is_some() {
|
||||||
match session.unwrap().close() {
|
match session.unwrap().close() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
@@ -484,9 +487,10 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
info!(
|
||||||
*/
|
context,
|
||||||
info!(context, 0, "IMAP unsetup_handle step 2.");
|
0, "IMAP unsetup_handle step 2 (closing down stream)."
|
||||||
|
);
|
||||||
let stream = self.stream.write().unwrap().take();
|
let stream = self.stream.write().unwrap().take();
|
||||||
if stream.is_some() {
|
if stream.is_some() {
|
||||||
match stream.unwrap().shutdown(net::Shutdown::Both) {
|
match stream.unwrap().shutdown(net::Shutdown::Both) {
|
||||||
@@ -497,12 +501,9 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(context, 0, "IMAP unsetup_handle step 3.");
|
info!(context, 0, "IMAP unsetup_handle step 3 (clearing config).");
|
||||||
{
|
self.config.write().unwrap().selected_folder = None;
|
||||||
let mut cfg = self.config.write().unwrap();
|
self.config.write().unwrap().selected_mailbox = None;
|
||||||
cfg.selected_folder = None;
|
|
||||||
cfg.selected_mailbox = None;
|
|
||||||
}
|
|
||||||
info!(context, 0, "IMAP unsetup_handle step 4 (disconnected).",);
|
info!(context, 0, "IMAP unsetup_handle step 4 (disconnected).",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user