mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
move function order / filestructure like in c core
This commit is contained in:
committed by
holger krekel
parent
65adff4bdd
commit
906b901e3d
@@ -42,17 +42,7 @@ pub unsafe fn configure(context: &Context) {
|
|||||||
job_kill_action(context, Action::ConfigureImap);
|
job_kill_action(context, Action::ConfigureImap);
|
||||||
job_add(context, Action::ConfigureImap, 0, Params::new(), 0);
|
job_add(context, Action::ConfigureImap, 0, Params::new(), 0);
|
||||||
}
|
}
|
||||||
|
/// Check if the context is already configured.
|
||||||
unsafe fn dc_has_ongoing(context: &Context) -> libc::c_int {
|
|
||||||
let s_a = context.running_state.clone();
|
|
||||||
let s = s_a.read().unwrap();
|
|
||||||
|
|
||||||
if s.ongoing_running || !s.shall_stop_ongoing {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn dc_is_configured(context: &Context) -> libc::c_int {
|
pub fn dc_is_configured(context: &Context) -> libc::c_int {
|
||||||
if context
|
if context
|
||||||
.sql
|
.sql
|
||||||
@@ -65,19 +55,21 @@ pub fn dc_is_configured(context: &Context) -> libc::c_int {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Check if there is an ongoing process.
|
||||||
pub fn dc_stop_ongoing_process(context: &Context) {
|
unsafe fn dc_has_ongoing(context: &Context) -> libc::c_int {
|
||||||
let s_a = context.running_state.clone();
|
let s_a = context.running_state.clone();
|
||||||
let mut s = s_a.write().unwrap();
|
let s = s_a.read().unwrap();
|
||||||
|
|
||||||
if s.ongoing_running && !s.shall_stop_ongoing {
|
if s.ongoing_running || !s.shall_stop_ongoing {
|
||||||
info!(context, 0, "Signaling the ongoing process to stop ASAP.",);
|
1
|
||||||
s.shall_stop_ongoing = true;
|
|
||||||
} else {
|
} else {
|
||||||
info!(context, 0, "No ongoing process to stop.",);
|
0
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Configure JOB
|
||||||
|
******************************************************************************/
|
||||||
// the other dc_job_do_DC_JOB_*() functions are declared static in the c-file
|
// the other dc_job_do_DC_JOB_*() functions are declared static in the c-file
|
||||||
#[allow(non_snake_case, unused_must_use)]
|
#[allow(non_snake_case, unused_must_use)]
|
||||||
pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: &Job) {
|
pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: &Job) {
|
||||||
@@ -645,31 +637,11 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: &Job) {
|
|||||||
progress!(context, (if success { 1000 } else { 0 }));
|
progress!(context, (if success { 1000 } else { 0 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_free_ongoing(context: &Context) {
|
/* File Structure like in C: */
|
||||||
let s_a = context.running_state.clone();
|
|
||||||
let mut s = s_a.write().unwrap();
|
|
||||||
|
|
||||||
s.ongoing_running = false;
|
|
||||||
s.shall_stop_ongoing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn dc_alloc_ongoing(context: &Context) -> libc::c_int {
|
|
||||||
if 0 != dc_has_ongoing(context) {
|
|
||||||
warn!(
|
|
||||||
context,
|
|
||||||
0, "There is already another ongoing process running.",
|
|
||||||
);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
let s_a = context.running_state.clone();
|
|
||||||
let mut s = s_a.write().unwrap();
|
|
||||||
|
|
||||||
s.ongoing_running = true;
|
|
||||||
s.shall_stop_ongoing = false;
|
|
||||||
|
|
||||||
1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Connect to configured account
|
||||||
|
******************************************************************************/
|
||||||
pub fn dc_connect_to_configured_imap(context: &Context, imap: &Imap) -> libc::c_int {
|
pub fn dc_connect_to_configured_imap(context: &Context, imap: &Imap) -> libc::c_int {
|
||||||
let mut ret_connected = 0;
|
let mut ret_connected = 0;
|
||||||
|
|
||||||
@@ -694,6 +666,52 @@ pub fn dc_connect_to_configured_imap(context: &Context, imap: &Imap) -> libc::c_
|
|||||||
ret_connected
|
ret_connected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Configure a Context
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/// Request an ongoing process to start.
|
||||||
|
/// Returns 0=process started, 1=not started, there is running another process
|
||||||
|
pub unsafe fn dc_alloc_ongoing(context: &Context) -> libc::c_int {
|
||||||
|
if 0 != dc_has_ongoing(context) {
|
||||||
|
warn!(
|
||||||
|
context,
|
||||||
|
0, "There is already another ongoing process running.",
|
||||||
|
);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
let s_a = context.running_state.clone();
|
||||||
|
let mut s = s_a.write().unwrap();
|
||||||
|
|
||||||
|
s.ongoing_running = true;
|
||||||
|
s.shall_stop_ongoing = false;
|
||||||
|
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Frees the process allocated with dc_alloc_ongoing() - independingly of dc_shall_stop_ongoing.
|
||||||
|
/// If dc_alloc_ongoing() fails, this function MUST NOT be called.
|
||||||
|
pub unsafe fn dc_free_ongoing(context: &Context) {
|
||||||
|
let s_a = context.running_state.clone();
|
||||||
|
let mut s = s_a.write().unwrap();
|
||||||
|
|
||||||
|
s.ongoing_running = false;
|
||||||
|
s.shall_stop_ongoing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Signal an ongoing process to stop.
|
||||||
|
pub fn dc_stop_ongoing_process(context: &Context) {
|
||||||
|
let s_a = context.running_state.clone();
|
||||||
|
let mut s = s_a.write().unwrap();
|
||||||
|
|
||||||
|
if s.ongoing_running && !s.shall_stop_ongoing {
|
||||||
|
info!(context, 0, "Signaling the ongoing process to stop ASAP.",);
|
||||||
|
s.shall_stop_ongoing = true;
|
||||||
|
} else {
|
||||||
|
info!(context, 0, "No ongoing process to stop.",);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn read_autoconf_file(context: &Context, url: *const libc::c_char) -> *mut libc::c_char {
|
pub fn read_autoconf_file(context: &Context, url: *const libc::c_char) -> *mut libc::c_char {
|
||||||
info!(context, 0, "Testing {} ...", to_string(url));
|
info!(context, 0, "Testing {} ...", to_string(url));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user