mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 18:06:35 +03:00
cleanup imap and smtp code a bit
This commit is contained in:
@@ -1751,10 +1751,7 @@ pub unsafe fn dc_alloc_ongoing(context: &dc_context_t) -> libc::c_int {
|
||||
1
|
||||
}
|
||||
|
||||
pub unsafe fn dc_connect_to_configured_imap(
|
||||
context: &dc_context_t,
|
||||
imap: &dc_imap_t,
|
||||
) -> libc::c_int {
|
||||
pub unsafe fn dc_connect_to_configured_imap(context: &dc_context_t, imap: &Imap) -> libc::c_int {
|
||||
let mut ret_connected: libc::c_int = 0i32;
|
||||
let mut param: *mut dc_loginparam_t = dc_loginparam_new();
|
||||
if imap.is_connected() {
|
||||
|
||||
@@ -28,7 +28,7 @@ pub struct dc_context_t {
|
||||
pub dbfile: Arc<RwLock<*mut libc::c_char>>,
|
||||
pub blobdir: Arc<RwLock<*mut libc::c_char>>,
|
||||
pub sql: Arc<RwLock<dc_sqlite3_t>>,
|
||||
pub inbox: Arc<RwLock<dc_imap_t>>,
|
||||
pub inbox: Arc<RwLock<Imap>>,
|
||||
pub perform_inbox_jobs_needed: Arc<RwLock<i32>>,
|
||||
pub probe_imap_network: Arc<RwLock<i32>>,
|
||||
pub sentbox_thread: Arc<Mutex<dc_jobthread_t>>,
|
||||
@@ -132,7 +132,7 @@ pub fn dc_context_new(
|
||||
blobdir: Arc::new(RwLock::new(std::ptr::null_mut())),
|
||||
dbfile: Arc::new(RwLock::new(std::ptr::null_mut())),
|
||||
inbox: Arc::new(RwLock::new({
|
||||
dc_imap_new(
|
||||
Imap::new(
|
||||
cb_get_config,
|
||||
cb_set_config,
|
||||
cb_precheck_imf,
|
||||
@@ -154,7 +154,7 @@ pub fn dc_context_new(
|
||||
dc_jobthread_init(
|
||||
b"SENTBOX\x00" as *const u8 as *const libc::c_char,
|
||||
b"configured_sentbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
dc_imap_new(
|
||||
Imap::new(
|
||||
cb_get_config,
|
||||
cb_set_config,
|
||||
cb_precheck_imf,
|
||||
@@ -166,7 +166,7 @@ pub fn dc_context_new(
|
||||
dc_jobthread_init(
|
||||
b"MVBOX\x00" as *const u8 as *const libc::c_char,
|
||||
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
dc_imap_new(
|
||||
Imap::new(
|
||||
cb_get_config,
|
||||
cb_set_config,
|
||||
cb_precheck_imf,
|
||||
|
||||
@@ -21,7 +21,7 @@ const BODY_FLAGS: &'static str = "(FLAGS BODY.PEEK[])";
|
||||
const FETCH_FLAGS: &'static str = "(FLAGS)";
|
||||
|
||||
#[repr(C)]
|
||||
pub struct dc_imap_t {
|
||||
pub struct Imap {
|
||||
config: Arc<RwLock<ImapConfig>>,
|
||||
watch: Arc<(Mutex<bool>, Condvar)>,
|
||||
|
||||
@@ -312,23 +312,14 @@ impl Default for ImapConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dc_imap_new(
|
||||
get_config: dc_get_config_t,
|
||||
set_config: dc_set_config_t,
|
||||
precheck_imf: dc_precheck_imf_t,
|
||||
receive_imf: dc_receive_imf_t,
|
||||
) -> dc_imap_t {
|
||||
dc_imap_t::new(get_config, set_config, precheck_imf, receive_imf)
|
||||
}
|
||||
|
||||
impl dc_imap_t {
|
||||
impl Imap {
|
||||
pub fn new(
|
||||
get_config: dc_get_config_t,
|
||||
set_config: dc_set_config_t,
|
||||
precheck_imf: dc_precheck_imf_t,
|
||||
receive_imf: dc_receive_imf_t,
|
||||
) -> Self {
|
||||
dc_imap_t {
|
||||
Imap {
|
||||
session: Arc::new(Mutex::new(None)),
|
||||
// idle: Arc::new(Mutex::new(None)),
|
||||
config: Arc::new(RwLock::new(ImapConfig::default())),
|
||||
|
||||
@@ -554,7 +554,7 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &dc_context_t, job: &mut dc_job_t)
|
||||
/* ******************************************************************************
|
||||
* IMAP-jobs
|
||||
******************************************************************************/
|
||||
unsafe fn connect_to_inbox(context: &dc_context_t, inbox: &dc_imap_t) -> libc::c_int {
|
||||
unsafe fn connect_to_inbox(context: &dc_context_t, inbox: &Imap) -> libc::c_int {
|
||||
let mut ret_connected: libc::c_int;
|
||||
|
||||
ret_connected = dc_connect_to_configured_imap(context, inbox);
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::sync::{Arc, Condvar, Mutex};
|
||||
|
||||
use crate::dc_configure::*;
|
||||
use crate::dc_context::dc_context_t;
|
||||
use crate::dc_imap::dc_imap_t;
|
||||
use crate::dc_imap::Imap;
|
||||
use crate::dc_log::*;
|
||||
use crate::dc_sqlite3::*;
|
||||
use crate::dc_tools::*;
|
||||
@@ -13,14 +13,14 @@ use crate::x::*;
|
||||
pub struct dc_jobthread_t {
|
||||
pub name: *mut libc::c_char,
|
||||
pub folder_config_name: *mut libc::c_char,
|
||||
pub imap: dc_imap_t,
|
||||
pub imap: Imap,
|
||||
pub state: Arc<(Mutex<JobState>, Condvar)>,
|
||||
}
|
||||
|
||||
pub unsafe fn dc_jobthread_init(
|
||||
name: *const libc::c_char,
|
||||
folder_config_name: *const libc::c_char,
|
||||
imap: dc_imap_t,
|
||||
imap: Imap,
|
||||
) -> dc_jobthread_t {
|
||||
dc_jobthread_t {
|
||||
name: dc_strdup(name),
|
||||
|
||||
@@ -54,14 +54,7 @@ impl Smtp {
|
||||
}
|
||||
|
||||
if self.is_connected() {
|
||||
unsafe {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0,
|
||||
b"SMTP already connected.\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
};
|
||||
|
||||
warn!(context, 0, "SMTP already connected.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -140,7 +133,7 @@ impl Smtp {
|
||||
|
||||
let client = lettre::smtp::SmtpClient::new((domain, port), security)
|
||||
.expect("failed to construct stmp client")
|
||||
// .smtp_utf8(true)
|
||||
.smtp_utf8(true)
|
||||
.credentials(creds)
|
||||
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited);
|
||||
|
||||
@@ -182,14 +175,7 @@ impl Smtp {
|
||||
let msg = CString::new(error_msg).unwrap();
|
||||
self.error = unsafe { libc::strdup(msg.as_ptr()) };
|
||||
|
||||
unsafe {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0,
|
||||
b"%s\x00" as *const u8 as *const libc::c_char,
|
||||
msg,
|
||||
);
|
||||
}
|
||||
warn!(context, 0, "%s", msg,);
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user