mirror of
https://github.com/chatmail/core.git
synced 2026-04-25 01:16:29 +03:00
fix some locking issues, start rust-imap impl
This commit is contained in:
committed by
Lars-Magnus Skog
parent
0b3a4b4c13
commit
e7d72dfdd4
@@ -23,6 +23,7 @@ num-derive = "0.2.5"
|
||||
num-traits = "0.2.6"
|
||||
native-tls = "0.2.3"
|
||||
lettre = "0.9.0"
|
||||
imap = "1.0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.0.7"
|
||||
@@ -42,4 +43,4 @@ path = "examples/repl/main.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
vendored = ["native-tls/vendored"]
|
||||
vendored = ["native-tls/vendored"]
|
||||
|
||||
@@ -648,7 +648,7 @@ pub unsafe extern "C" fn dc_cmdline(
|
||||
)
|
||||
}
|
||||
} else if strcmp(cmd, b"has-backup\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
ret = dc_imex_has_backup(&context, context.blobdir);
|
||||
ret = dc_imex_has_backup(&context, context.get_blobdir());
|
||||
if ret.is_null() {
|
||||
ret = dc_strdup(b"No backup found.\x00" as *const u8 as *const libc::c_char)
|
||||
}
|
||||
@@ -657,7 +657,12 @@ pub unsafe extern "C" fn dc_cmdline(
|
||||
b"export-backup\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
dc_imex(&context, 11i32, context.blobdir, 0 as *const libc::c_char);
|
||||
dc_imex(
|
||||
&context,
|
||||
11i32,
|
||||
context.get_blobdir(),
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
ret = 2i32 as *mut libc::c_char
|
||||
} else if strcmp(
|
||||
cmd,
|
||||
@@ -673,16 +678,26 @@ pub unsafe extern "C" fn dc_cmdline(
|
||||
)
|
||||
}
|
||||
} else if strcmp(cmd, b"export-keys\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
dc_imex(&context, 1i32, context.blobdir, 0 as *const libc::c_char);
|
||||
dc_imex(
|
||||
&context,
|
||||
1i32,
|
||||
context.get_blobdir(),
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
ret = 2i32 as *mut libc::c_char
|
||||
} else if strcmp(cmd, b"import-keys\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
dc_imex(&context, 2i32, context.blobdir, 0 as *const libc::c_char);
|
||||
dc_imex(
|
||||
&context,
|
||||
2i32,
|
||||
context.get_blobdir(),
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
ret = 2i32 as *mut libc::c_char
|
||||
} else if strcmp(cmd, b"export-setup\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
let mut setup_code_0: *mut libc::c_char = dc_create_setup_code(&context);
|
||||
let mut file_name: *mut libc::c_char = dc_mprintf(
|
||||
b"%s/autocrypt-setup-message.html\x00" as *const u8 as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
let mut file_content: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
file_content = dc_render_setup_file(&context, setup_code_0);
|
||||
|
||||
@@ -150,7 +150,7 @@ unsafe extern "C" fn receive_event(
|
||||
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut tempFile: *mut libc::c_char = dc_get_fine_pathNfilename(
|
||||
context,
|
||||
(*context).blobdir,
|
||||
context.get_blobdir(),
|
||||
b"curl.result\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let mut cmd: *mut libc::c_char = if event == Event::HTTP_GET {
|
||||
@@ -279,12 +279,16 @@ unsafe fn start_threads(
|
||||
run_threads = 1;
|
||||
let context = c.clone();
|
||||
let h1 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
|
||||
println!("-- imap jobs");
|
||||
dc_perform_imap_jobs(&context);
|
||||
println!("-- imap fetch");
|
||||
dc_perform_imap_fetch(&context);
|
||||
if 0 != run_threads {
|
||||
println!("-- imap idle");
|
||||
dc_perform_imap_idle(&context);
|
||||
}
|
||||
}
|
||||
@@ -292,38 +296,38 @@ unsafe fn start_threads(
|
||||
|
||||
let context = c.clone();
|
||||
let h2 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
dc_perform_mvbox_fetch(&context);
|
||||
if 0 != run_threads {
|
||||
dc_perform_mvbox_idle(&context);
|
||||
}
|
||||
}
|
||||
// let ctx = context.clone();
|
||||
// let context = ctx.read().unwrap();
|
||||
// while 0 != run_threads {
|
||||
// dc_perform_mvbox_fetch(&context);
|
||||
// if 0 != run_threads {
|
||||
// dc_perform_mvbox_idle(&context);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
let context = c.clone();
|
||||
let h3 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
dc_perform_sentbox_fetch(&context);
|
||||
if 0 != run_threads {
|
||||
dc_perform_sentbox_idle(&context);
|
||||
}
|
||||
}
|
||||
// let ctx = context.clone();
|
||||
// let context = ctx.read().unwrap();
|
||||
// while 0 != run_threads {
|
||||
// dc_perform_sentbox_fetch(&context);
|
||||
// if 0 != run_threads {
|
||||
// dc_perform_sentbox_idle(&context);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
let context = c.clone();
|
||||
let h4 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
dc_perform_smtp_jobs(&context);
|
||||
if 0 != run_threads {
|
||||
dc_perform_smtp_idle(&context);
|
||||
}
|
||||
}
|
||||
// let ctx = context.clone();
|
||||
// let context = ctx.read().unwrap();
|
||||
// while 0 != run_threads {
|
||||
// dc_perform_smtp_jobs(&context);
|
||||
// if 0 != run_threads {
|
||||
// dc_perform_smtp_idle(&context);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
(h1, h2, h3, h4)
|
||||
@@ -391,8 +395,6 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
let ctx = Arc::new(RwLock::new(context));
|
||||
|
||||
loop {
|
||||
let ctx = ctx.clone();
|
||||
|
||||
/* read command */
|
||||
let cmdline = read_cmd();
|
||||
free(cmd as *mut libc::c_void);
|
||||
@@ -426,10 +428,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
dc_perform_imap_jobs(&ctx.read().unwrap());
|
||||
}
|
||||
} else if strcmp(cmd, b"configure\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
handles = {
|
||||
let ctx = ctx.clone();
|
||||
Some(start_threads(ctx))
|
||||
};
|
||||
handles = { Some(start_threads(ctx.clone())) };
|
||||
dc_configure(&ctx.read().unwrap());
|
||||
} else if strcmp(cmd, b"oauth2\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
let mut addr: *mut libc::c_char = dc_get_config(
|
||||
@@ -463,10 +462,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
} else if strcmp(cmd, b"getqr\x00" as *const u8 as *const libc::c_char) == 0i32
|
||||
|| strcmp(cmd, b"getbadqr\x00" as *const u8 as *const libc::c_char) == 0i32
|
||||
{
|
||||
handles = {
|
||||
let ctx = ctx.clone();
|
||||
Some(start_threads(ctx))
|
||||
};
|
||||
handles = Some(start_threads(ctx.clone()));
|
||||
let mut qrstr: *mut libc::c_char = dc_get_securejoin_qr(
|
||||
&ctx.read().unwrap(),
|
||||
(if !arg1.is_null() { atoi(arg1) } else { 0i32 }) as uint32_t,
|
||||
@@ -491,10 +487,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
}
|
||||
free(qrstr as *mut libc::c_void);
|
||||
} else if strcmp(cmd, b"joinqr\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
handles = {
|
||||
let ctx = ctx.clone();
|
||||
Some(start_threads(ctx))
|
||||
};
|
||||
handles = Some(start_threads(ctx.clone()));
|
||||
if !arg1.is_null() {
|
||||
dc_join_securejoin(&ctx.read().unwrap(), arg1);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extern crate deltachat;
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::sync::Arc;
|
||||
use tempfile::tempdir;
|
||||
|
||||
use deltachat::constants::Event;
|
||||
@@ -20,6 +20,10 @@ extern "C" fn cb(_ctx: &dc_context_t, event: Event, data1: usize, data2: usize)
|
||||
println!("[{:?}]", event);
|
||||
|
||||
match event {
|
||||
Event::CONFIGURE_PROGRESS => {
|
||||
println!(" progress: {}", data1);
|
||||
0
|
||||
}
|
||||
Event::HTTP_GET => {
|
||||
let url = unsafe { CStr::from_ptr(data1 as *const _).to_str().unwrap() };
|
||||
|
||||
@@ -56,19 +60,20 @@ fn main() {
|
||||
let info_s = CStr::from_ptr(info);
|
||||
println!("info: {}", info_s.to_str().unwrap());
|
||||
|
||||
let ctx = Arc::new(RwLock::new(ctx));
|
||||
|
||||
let ctx = Arc::new(ctx);
|
||||
let ctx1 = ctx.clone();
|
||||
let t1 = std::thread::spawn(move || loop {
|
||||
dc_perform_imap_jobs(&ctx1.clone().read().unwrap());
|
||||
dc_perform_imap_fetch(&ctx1.clone().read().unwrap());
|
||||
dc_perform_imap_idle(&ctx1.clone().read().unwrap());
|
||||
dc_perform_imap_jobs(&ctx1);
|
||||
dc_perform_imap_fetch(&ctx1);
|
||||
std::thread::sleep_ms(1000);
|
||||
|
||||
// dc_perform_imap_idle(&ctx1);
|
||||
});
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
let t2 = std::thread::spawn(move || loop {
|
||||
dc_perform_smtp_jobs(&ctx1.clone().read().unwrap());
|
||||
dc_perform_smtp_idle(&ctx1.clone().read().unwrap());
|
||||
// dc_perform_smtp_jobs(&ctx1);
|
||||
// dc_perform_smtp_idle(&ctx1);
|
||||
});
|
||||
|
||||
let dir = tempdir().unwrap();
|
||||
@@ -76,42 +81,31 @@ fn main() {
|
||||
|
||||
println!("opening database {:?}", dbfile);
|
||||
|
||||
dc_open(
|
||||
&mut ctx.clone().write().unwrap(),
|
||||
dbfile.as_ptr(),
|
||||
std::ptr::null(),
|
||||
);
|
||||
dc_open(&ctx, dbfile.as_ptr(), std::ptr::null());
|
||||
|
||||
println!("configuring");
|
||||
dc_set_config(
|
||||
&ctx.clone().read().unwrap(),
|
||||
&ctx,
|
||||
CString::new("addr").unwrap().as_ptr(),
|
||||
CString::new("d@testrun.org").unwrap().as_ptr(),
|
||||
);
|
||||
dc_set_config(
|
||||
&ctx.clone().read().unwrap(),
|
||||
&ctx,
|
||||
CString::new("mail_pw").unwrap().as_ptr(),
|
||||
CString::new("***").unwrap().as_ptr(),
|
||||
);
|
||||
dc_configure(&ctx.clone().read().unwrap());
|
||||
dc_configure(&ctx);
|
||||
|
||||
std::thread::sleep_ms(4000);
|
||||
|
||||
let email = CString::new("dignifiedquire@gmail.com").unwrap();
|
||||
println!("sending a message");
|
||||
let contact_id = dc_create_contact(
|
||||
&ctx.clone().read().unwrap(),
|
||||
std::ptr::null(),
|
||||
email.as_ptr(),
|
||||
);
|
||||
let chat_id = dc_create_chat_by_contact_id(&ctx.clone().read().unwrap(), contact_id);
|
||||
let contact_id = dc_create_contact(&ctx, std::ptr::null(), email.as_ptr());
|
||||
let chat_id = dc_create_chat_by_contact_id(&ctx, contact_id);
|
||||
let msg_text = CString::new("Hi, here is my first message!").unwrap();
|
||||
dc_send_text_msg(&ctx.clone().read().unwrap(), chat_id, msg_text.as_ptr());
|
||||
dc_send_text_msg(&ctx, chat_id, msg_text.as_ptr());
|
||||
|
||||
println!("fetching chats..");
|
||||
let ctx1 = ctx.clone();
|
||||
let ctx = ctx1.read().unwrap();
|
||||
|
||||
let chats = dc_get_chatlist(&ctx, 0, std::ptr::null(), 0);
|
||||
|
||||
for i in 0..dc_chatlist_get_cnt(chats) {
|
||||
@@ -134,7 +128,7 @@ fn main() {
|
||||
}
|
||||
dc_chatlist_unref(chats);
|
||||
|
||||
// let msglist = dc_get_chat_msgs(&ctx.clone().read().unwrap(), chat_id, 0, 0);
|
||||
// let msglist = dc_get_chat_msgs(&ctx, chat_id, 0, 0);
|
||||
// for i in 0..dc_array_get_cnt(msglist) {
|
||||
// let msg_id = dc_array_get_id(msglist, i);
|
||||
// let msg = dc_get_msg(context, msg_id);
|
||||
|
||||
@@ -136,62 +136,37 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
b"Cannot configure, database not opened.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
dc_imap_disconnect(context, &mut context.inbox.clone().lock().unwrap());
|
||||
dc_imap_disconnect(
|
||||
context,
|
||||
&mut context
|
||||
.sentbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
);
|
||||
dc_imap_disconnect(
|
||||
context,
|
||||
&mut context
|
||||
.mvbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
);
|
||||
context.smtp.clone().lock().unwrap().disconnect();
|
||||
context.inbox.clone().lock().unwrap().log_connect_errors = 1i32;
|
||||
context.inbox.read().unwrap().disconnect(context);
|
||||
context
|
||||
.sentbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.log_connect_errors = 1i32;
|
||||
.disconnect(context);
|
||||
context
|
||||
.mvbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.log_connect_errors = 1i32;
|
||||
.disconnect(context);
|
||||
context.smtp.clone().lock().unwrap().disconnect();
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"Configure ...\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
|
||||
println!("configure lock");
|
||||
let s_a = context.running_state.clone();
|
||||
let s = s_a.read().unwrap();
|
||||
|
||||
if s.shall_stop_ongoing {
|
||||
println!("ongoing: {:?}", s);
|
||||
if !s.shall_stop_ongoing {
|
||||
println!("configure progress");
|
||||
(context.cb)(
|
||||
context,
|
||||
Event::CONFIGURE_PROGRESS,
|
||||
@@ -205,12 +180,15 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
0i32 as uintptr_t,
|
||||
);
|
||||
param = dc_loginparam_new();
|
||||
println!("reading params");
|
||||
dc_loginparam_read(
|
||||
context,
|
||||
param,
|
||||
&context.sql.clone().read().unwrap(),
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
println!("got params");
|
||||
|
||||
if (*param).addr.is_null() {
|
||||
dc_log_error(
|
||||
context,
|
||||
@@ -846,11 +824,12 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
r_0,
|
||||
);
|
||||
free(r_0 as *mut libc::c_void);
|
||||
if 0 != dc_imap_connect(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
param,
|
||||
) {
|
||||
if 0 != context
|
||||
.inbox
|
||||
.read()
|
||||
.unwrap()
|
||||
.connect(context, param)
|
||||
{
|
||||
current_block = 14187386403465544025;
|
||||
break;
|
||||
}
|
||||
@@ -894,11 +873,12 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
r_1,
|
||||
);
|
||||
free(r_1 as *mut libc::c_void);
|
||||
if 0 != dc_imap_connect(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
param,
|
||||
) {
|
||||
if 0 != context
|
||||
.inbox
|
||||
.read()
|
||||
.unwrap()
|
||||
.connect(context, param)
|
||||
{
|
||||
current_block = 14187386403465544025;
|
||||
break;
|
||||
}
|
||||
@@ -936,11 +916,12 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
r_2,
|
||||
);
|
||||
free(r_2 as *mut libc::c_void);
|
||||
if 0 != dc_imap_connect(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
param,
|
||||
) {
|
||||
if 0 != context
|
||||
.inbox
|
||||
.read()
|
||||
.unwrap()
|
||||
.connect(context, param)
|
||||
{
|
||||
current_block = 14187386403465544025;
|
||||
break;
|
||||
}
|
||||
@@ -1184,15 +1165,14 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
} else {
|
||||
0i32
|
||||
};
|
||||
dc_configure_folders(
|
||||
context,
|
||||
&mut context
|
||||
.inbox
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
flags,
|
||||
);
|
||||
|
||||
context
|
||||
.inbox
|
||||
.read()
|
||||
.unwrap()
|
||||
.configure_folders(
|
||||
context, flags,
|
||||
);
|
||||
if !s.shall_stop_ongoing {
|
||||
(context.cb)(context,
|
||||
Event::CONFIGURE_PROGRESS,
|
||||
@@ -1303,7 +1283,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut
|
||||
}
|
||||
|
||||
if 0 != imap_connected_here {
|
||||
dc_imap_disconnect(context, &mut context.inbox.clone().lock().unwrap());
|
||||
context.inbox.read().unwrap().disconnect(context);
|
||||
}
|
||||
if 0 != smtp_connected_here {
|
||||
context.smtp.clone().lock().unwrap().disconnect();
|
||||
@@ -1331,123 +1311,6 @@ pub unsafe fn dc_free_ongoing(context: &dc_context_t) {
|
||||
s.shall_stop_ongoing = true;
|
||||
}
|
||||
|
||||
pub unsafe fn dc_configure_folders(
|
||||
context: &dc_context_t,
|
||||
imap: &mut dc_imap_t,
|
||||
flags: libc::c_int,
|
||||
) {
|
||||
let mut folder_list: *mut clist = 0 as *mut clist;
|
||||
let mut iter: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut mvbox_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut sentbox_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut fallback_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
if !(*imap).etpan.is_null() {
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"Configuring IMAP-folders.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
folder_list = list_folders(context, imap);
|
||||
fallback_folder = dc_mprintf(
|
||||
b"INBOX%c%s\x00" as *const u8 as *const libc::c_char,
|
||||
(*imap).imap_delimiter as libc::c_int,
|
||||
b"DeltaChat\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
iter = (*folder_list).first;
|
||||
while !iter.is_null() {
|
||||
let mut folder: *mut dc_imapfolder_t = (if !iter.is_null() {
|
||||
(*iter).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
}) as *mut dc_imapfolder_t;
|
||||
if strcmp(
|
||||
(*folder).name_utf8,
|
||||
b"DeltaChat\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
|| strcmp((*folder).name_utf8, fallback_folder) == 0i32
|
||||
{
|
||||
if mvbox_folder.is_null() {
|
||||
mvbox_folder = dc_strdup((*folder).name_to_select)
|
||||
}
|
||||
}
|
||||
if (*folder).meaning == 1i32 {
|
||||
if sentbox_folder.is_null() {
|
||||
sentbox_folder = dc_strdup((*folder).name_to_select)
|
||||
}
|
||||
}
|
||||
iter = if !iter.is_null() {
|
||||
(*iter).next
|
||||
} else {
|
||||
0 as *mut clistcell_s
|
||||
}
|
||||
}
|
||||
if mvbox_folder.is_null() && 0 != flags & 0x1i32 {
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"Creating MVBOX-folder \"%s\"...\x00" as *const u8 as *const libc::c_char,
|
||||
b"DeltaChat\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let mut r: libc::c_int = mailimap_create(
|
||||
(*imap).etpan,
|
||||
b"DeltaChat\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
if 0 != dc_imap_is_error(context, imap, r) {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0i32,
|
||||
b"Cannot create MVBOX-folder, using trying INBOX subfolder.\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
r = mailimap_create((*imap).etpan, fallback_folder);
|
||||
if 0 != dc_imap_is_error(context, imap, r) {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0i32,
|
||||
b"Cannot create MVBOX-folder.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
mvbox_folder = dc_strdup(fallback_folder);
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"MVBOX-folder created as INBOX subfolder.\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
mvbox_folder = dc_strdup(b"DeltaChat\x00" as *const u8 as *const libc::c_char);
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"MVBOX-folder created.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
}
|
||||
mailimap_subscribe((*imap).etpan, mvbox_folder);
|
||||
}
|
||||
dc_sqlite3_set_config_int(
|
||||
context,
|
||||
&context.sql.clone().read().unwrap(),
|
||||
b"folders_configured\x00" as *const u8 as *const libc::c_char,
|
||||
3i32,
|
||||
);
|
||||
dc_sqlite3_set_config(
|
||||
context,
|
||||
&context.sql.clone().read().unwrap(),
|
||||
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
mvbox_folder,
|
||||
);
|
||||
dc_sqlite3_set_config(
|
||||
context,
|
||||
&context.sql.clone().read().unwrap(),
|
||||
b"configured_sentbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
sentbox_folder,
|
||||
);
|
||||
}
|
||||
free_folders(folder_list);
|
||||
free(mvbox_folder as *mut libc::c_void);
|
||||
free(fallback_folder as *mut libc::c_void);
|
||||
}
|
||||
unsafe fn free_folders(mut folders: *mut clist) {
|
||||
if !folders.is_null() {
|
||||
let mut iter1: *mut clistiter = 0 as *mut clistiter;
|
||||
@@ -1470,173 +1333,7 @@ unsafe fn free_folders(mut folders: *mut clist) {
|
||||
clist_free(folders);
|
||||
};
|
||||
}
|
||||
unsafe fn list_folders(context: &dc_context_t, imap: &mut dc_imap_t) -> *mut clist {
|
||||
let mut imap_list: *mut clist = 0 as *mut clist;
|
||||
let mut iter1: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut ret_list: *mut clist = clist_new();
|
||||
let mut r: libc::c_int = 0i32;
|
||||
let mut xlist_works: libc::c_int = 0i32;
|
||||
if !(*imap).etpan.is_null() {
|
||||
if 0 != (*imap).has_xlist {
|
||||
r = mailimap_xlist(
|
||||
(*imap).etpan,
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
b"*\x00" as *const u8 as *const libc::c_char,
|
||||
&mut imap_list,
|
||||
)
|
||||
} else {
|
||||
r = mailimap_list(
|
||||
(*imap).etpan,
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
b"*\x00" as *const u8 as *const libc::c_char,
|
||||
&mut imap_list,
|
||||
)
|
||||
}
|
||||
if 0 != dc_imap_is_error(context, imap, r) || imap_list.is_null() {
|
||||
imap_list = 0 as *mut clist;
|
||||
dc_log_warning(
|
||||
context,
|
||||
0i32,
|
||||
b"Cannot get folder list.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else if (*imap_list).count <= 0i32 {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0i32,
|
||||
b"Folder list is empty.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
(*imap).imap_delimiter = '.' as i32 as libc::c_char;
|
||||
iter1 = (*imap_list).first;
|
||||
while !iter1.is_null() {
|
||||
let mut imap_folder: *mut mailimap_mailbox_list = (if !iter1.is_null() {
|
||||
(*iter1).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
})
|
||||
as *mut mailimap_mailbox_list;
|
||||
if 0 != (*imap_folder).mb_delimiter {
|
||||
(*imap).imap_delimiter = (*imap_folder).mb_delimiter
|
||||
}
|
||||
let mut ret_folder: *mut dc_imapfolder_t =
|
||||
calloc(1, ::std::mem::size_of::<dc_imapfolder_t>()) as *mut dc_imapfolder_t;
|
||||
if strcasecmp(
|
||||
(*imap_folder).mb_name,
|
||||
b"INBOX\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
(*ret_folder).name_to_select =
|
||||
dc_strdup(b"INBOX\x00" as *const u8 as *const libc::c_char)
|
||||
} else {
|
||||
(*ret_folder).name_to_select = dc_strdup((*imap_folder).mb_name)
|
||||
}
|
||||
(*ret_folder).name_utf8 = dc_decode_modified_utf7((*imap_folder).mb_name, 0i32);
|
||||
(*ret_folder).meaning = get_folder_meaning((*imap_folder).mb_flag);
|
||||
if (*ret_folder).meaning == 2i32 || (*ret_folder).meaning == 1i32 {
|
||||
xlist_works = 1i32
|
||||
}
|
||||
clist_insert_after(ret_list, (*ret_list).last, ret_folder as *mut libc::c_void);
|
||||
iter1 = if !iter1.is_null() {
|
||||
(*iter1).next
|
||||
} else {
|
||||
0 as *mut clistcell_s
|
||||
}
|
||||
}
|
||||
if 0 == xlist_works {
|
||||
iter1 = (*ret_list).first;
|
||||
while !iter1.is_null() {
|
||||
let mut ret_folder_0: *mut dc_imapfolder_t = (if !iter1.is_null() {
|
||||
(*iter1).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
})
|
||||
as *mut dc_imapfolder_t;
|
||||
(*ret_folder_0).meaning = get_folder_meaning_by_name((*ret_folder_0).name_utf8);
|
||||
iter1 = if !iter1.is_null() {
|
||||
(*iter1).next
|
||||
} else {
|
||||
0 as *mut clistcell_s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !imap_list.is_null() {
|
||||
mailimap_list_result_free(imap_list);
|
||||
}
|
||||
return ret_list;
|
||||
}
|
||||
unsafe fn get_folder_meaning_by_name(mut folder_name: *const libc::c_char) -> libc::c_int {
|
||||
// try to get the folder meaning by the name of the folder.
|
||||
// only used if the server does not support XLIST.
|
||||
let mut ret_meaning: libc::c_int = 0i32;
|
||||
// TODO: lots languages missing - maybe there is a list somewhere on other MUAs?
|
||||
// however, if we fail to find out the sent-folder,
|
||||
// only watching this folder is not working. at least, this is no show stopper.
|
||||
// CAVE: if possible, take care not to add a name here that is "sent" in one language
|
||||
// but sth. different in others - a hard job.
|
||||
static mut sent_names: *const libc::c_char =
|
||||
b",sent,sent objects,gesendet,\x00" as *const u8 as *const libc::c_char;
|
||||
let mut lower: *mut libc::c_char =
|
||||
dc_mprintf(b",%s,\x00" as *const u8 as *const libc::c_char, folder_name);
|
||||
dc_strlower_in_place(lower);
|
||||
if !strstr(sent_names, lower).is_null() {
|
||||
ret_meaning = 1i32
|
||||
}
|
||||
free(lower as *mut libc::c_void);
|
||||
return ret_meaning;
|
||||
}
|
||||
unsafe fn get_folder_meaning(mut flags: *mut mailimap_mbx_list_flags) -> libc::c_int {
|
||||
let mut ret_meaning: libc::c_int = 0i32;
|
||||
if !flags.is_null() {
|
||||
let mut iter2: *mut clistiter = 0 as *mut clistiter;
|
||||
iter2 = (*(*flags).mbf_oflags).first;
|
||||
while !iter2.is_null() {
|
||||
let mut oflag: *mut mailimap_mbx_list_oflag = (if !iter2.is_null() {
|
||||
(*iter2).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
})
|
||||
as *mut mailimap_mbx_list_oflag;
|
||||
match (*oflag).of_type {
|
||||
2 => {
|
||||
if strcasecmp(
|
||||
(*oflag).of_flag_ext,
|
||||
b"spam\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
|| strcasecmp(
|
||||
(*oflag).of_flag_ext,
|
||||
b"trash\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
|| strcasecmp(
|
||||
(*oflag).of_flag_ext,
|
||||
b"drafts\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
|| strcasecmp(
|
||||
(*oflag).of_flag_ext,
|
||||
b"junk\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
ret_meaning = 2i32
|
||||
} else if strcasecmp(
|
||||
(*oflag).of_flag_ext,
|
||||
b"sent\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
ret_meaning = 1i32
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
iter2 = if !iter2.is_null() {
|
||||
(*iter2).next
|
||||
} else {
|
||||
0 as *mut clistcell_s
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret_meaning;
|
||||
}
|
||||
|
||||
unsafe fn moz_autoconfigure(
|
||||
mut context: &dc_context_t,
|
||||
mut url: *const libc::c_char,
|
||||
@@ -1714,6 +1411,7 @@ unsafe fn moz_autoconfigure(
|
||||
free(moz_ac.in_emaillocalpart as *mut libc::c_void);
|
||||
return moz_ac.out;
|
||||
}
|
||||
|
||||
unsafe fn moz_autoconfigure_text_cb(
|
||||
userdata: *mut libc::c_void,
|
||||
text: *const libc::c_char,
|
||||
@@ -2096,11 +1794,12 @@ pub unsafe fn dc_alloc_ongoing(context: &dc_context_t) -> libc::c_int {
|
||||
|
||||
pub unsafe fn dc_connect_to_configured_imap(
|
||||
context: &dc_context_t,
|
||||
imap: &mut dc_imap_t,
|
||||
imap: &dc_imap_t,
|
||||
) -> libc::c_int {
|
||||
println!("connect to imap");
|
||||
let mut ret_connected: libc::c_int = 0i32;
|
||||
let mut param: *mut dc_loginparam_t = dc_loginparam_new();
|
||||
if 0 != dc_imap_is_connected(imap) {
|
||||
if imap.is_connected() {
|
||||
ret_connected = 1i32
|
||||
} else if dc_sqlite3_get_config_int(
|
||||
context,
|
||||
@@ -2122,10 +1821,11 @@ pub unsafe fn dc_connect_to_configured_imap(
|
||||
b"configured_\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
/*the trailing underscore is correct*/
|
||||
if !(0 == dc_imap_connect(context, imap, param)) {
|
||||
if !(0 == imap.connect(context, param)) {
|
||||
ret_connected = 2i32
|
||||
}
|
||||
}
|
||||
dc_loginparam_unref(param);
|
||||
return ret_connected;
|
||||
println!("done, {}", ret_connected);
|
||||
ret_connected
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ use crate::x::*;
|
||||
#[repr(C)]
|
||||
pub struct dc_context_t {
|
||||
pub userdata: *mut libc::c_void,
|
||||
pub dbfile: *mut libc::c_char,
|
||||
pub blobdir: *mut libc::c_char,
|
||||
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<Mutex<dc_imap_t>>,
|
||||
pub inbox: Arc<RwLock<dc_imap_t>>,
|
||||
pub perform_inbox_jobs_needed: Arc<RwLock<i32>>,
|
||||
pub probe_imap_network: Arc<RwLock<i32>>,
|
||||
pub sentbox_thread: Arc<Mutex<dc_jobthread_t>>,
|
||||
@@ -54,6 +54,24 @@ pub struct RunningState {
|
||||
pub shall_stop_ongoing: bool,
|
||||
}
|
||||
|
||||
impl dc_context_t {
|
||||
pub fn has_dbfile(&self) -> bool {
|
||||
!self.get_dbfile().is_null()
|
||||
}
|
||||
|
||||
pub fn has_blobdir(&self) -> bool {
|
||||
!self.get_blobdir().is_null()
|
||||
}
|
||||
|
||||
pub fn get_dbfile(&self) -> *const libc::c_char {
|
||||
*self.dbfile.clone().read().unwrap()
|
||||
}
|
||||
|
||||
pub fn get_blobdir(&self) -> *const libc::c_char {
|
||||
*self.blobdir.clone().read().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RunningState {
|
||||
fn default() -> Self {
|
||||
RunningState {
|
||||
@@ -112,9 +130,9 @@ pub fn dc_context_new(
|
||||
os_name: *const libc::c_char,
|
||||
) -> dc_context_t {
|
||||
dc_context_t {
|
||||
blobdir: std::ptr::null_mut(),
|
||||
dbfile: std::ptr::null_mut(),
|
||||
inbox: Arc::new(Mutex::new(unsafe {
|
||||
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(
|
||||
Some(cb_get_config),
|
||||
Some(cb_set_config),
|
||||
@@ -261,32 +279,6 @@ pub unsafe fn dc_context_unref(context: &mut dc_context_t) {
|
||||
if 0 != dc_is_open(context) {
|
||||
dc_close(context);
|
||||
}
|
||||
dc_imap_unref(context, &mut context.inbox.clone().lock().unwrap());
|
||||
dc_imap_unref(
|
||||
context,
|
||||
&mut context
|
||||
.sentbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
);
|
||||
dc_imap_unref(
|
||||
context,
|
||||
&mut context
|
||||
.mvbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
dc_sqlite3_unref(context, &mut context.sql.clone().write().unwrap());
|
||||
|
||||
dc_jobthread_exit(&mut context.sentbox_thread.clone().lock().unwrap());
|
||||
@@ -295,41 +287,36 @@ pub unsafe fn dc_context_unref(context: &mut dc_context_t) {
|
||||
free(context.os_name as *mut libc::c_void);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_close(context: &mut dc_context_t) {
|
||||
dc_imap_disconnect(context, &mut context.inbox.clone().lock().unwrap());
|
||||
dc_imap_disconnect(
|
||||
context,
|
||||
&mut context
|
||||
.sentbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
);
|
||||
dc_imap_disconnect(
|
||||
context,
|
||||
&mut context
|
||||
.mvbox_thread
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.clone()
|
||||
.lock()
|
||||
.unwrap(),
|
||||
);
|
||||
pub unsafe fn dc_close(context: &dc_context_t) {
|
||||
context.inbox.read().unwrap().disconnect(context);
|
||||
context
|
||||
.sentbox_thread
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.lock()
|
||||
.unwrap()
|
||||
.disconnect(context);
|
||||
context
|
||||
.mvbox_thread
|
||||
.lock()
|
||||
.unwrap()
|
||||
.imap
|
||||
.lock()
|
||||
.unwrap()
|
||||
.disconnect(context);
|
||||
|
||||
context.smtp.clone().lock().unwrap().disconnect();
|
||||
|
||||
if 0 != dc_sqlite3_is_open(&context.sql.clone().read().unwrap()) {
|
||||
dc_sqlite3_close(context, &mut context.sql.clone().write().unwrap());
|
||||
}
|
||||
free(context.dbfile as *mut libc::c_void);
|
||||
context.dbfile = 0 as *mut libc::c_char;
|
||||
free(context.blobdir as *mut libc::c_void);
|
||||
context.blobdir = 0 as *mut libc::c_char;
|
||||
let mut dbfile = context.dbfile.write().unwrap();
|
||||
free(*dbfile as *mut libc::c_void);
|
||||
*dbfile = 0 as *mut libc::c_char;
|
||||
let mut blobdir = context.blobdir.write().unwrap();
|
||||
free(*blobdir as *mut libc::c_void);
|
||||
*blobdir = 0 as *mut libc::c_char;
|
||||
}
|
||||
|
||||
pub unsafe fn dc_is_open(context: &dc_context_t) -> libc::c_int {
|
||||
@@ -341,7 +328,7 @@ pub unsafe fn dc_get_userdata(context: &mut dc_context_t) -> *mut libc::c_void {
|
||||
}
|
||||
|
||||
pub unsafe fn dc_open(
|
||||
context: &mut dc_context_t,
|
||||
context: &dc_context_t,
|
||||
dbfile: *const libc::c_char,
|
||||
blobdir: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
@@ -350,24 +337,18 @@ pub unsafe fn dc_open(
|
||||
return 0;
|
||||
}
|
||||
if !dbfile.is_null() {
|
||||
context.dbfile = dc_strdup(dbfile);
|
||||
*context.dbfile.write().unwrap() = dc_strdup(dbfile);
|
||||
if !blobdir.is_null() && 0 != *blobdir.offset(0isize) as libc::c_int {
|
||||
context.blobdir = dc_strdup(blobdir);
|
||||
dc_ensure_no_slash(context.blobdir);
|
||||
let dir = dc_strdup(blobdir);
|
||||
dc_ensure_no_slash(dir);
|
||||
*context.blobdir.write().unwrap() = dir;
|
||||
} else {
|
||||
context.blobdir =
|
||||
dc_mprintf(b"%s-blobs\x00" as *const u8 as *const libc::c_char, dbfile);
|
||||
dc_create_folder(context, context.blobdir);
|
||||
let dir = dc_mprintf(b"%s-blobs\x00" as *const u8 as *const libc::c_char, dbfile);
|
||||
dc_create_folder(context, dir);
|
||||
*context.blobdir.write().unwrap() = dir;
|
||||
}
|
||||
// Create/open sqlite database, this may already use the blobdir
|
||||
if !(0
|
||||
== dc_sqlite3_open(
|
||||
context,
|
||||
&mut context.sql.clone().write().unwrap(),
|
||||
dbfile,
|
||||
0i32,
|
||||
))
|
||||
{
|
||||
if !(0 == dc_sqlite3_open(context, &mut context.sql.write().unwrap(), dbfile, 0i32)) {
|
||||
success = 1i32
|
||||
}
|
||||
}
|
||||
@@ -378,7 +359,7 @@ pub unsafe fn dc_open(
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_blobdir(context: &dc_context_t) -> *mut libc::c_char {
|
||||
dc_strdup((*context).blobdir)
|
||||
dc_strdup(*context.blobdir.clone().read().unwrap())
|
||||
}
|
||||
|
||||
pub unsafe fn dc_set_config(
|
||||
@@ -836,14 +817,14 @@ pub unsafe fn dc_get_info(context: &dc_context_t) -> *mut libc::c_char {
|
||||
real_msgs,
|
||||
deaddrop_msgs,
|
||||
contacts,
|
||||
if !context.dbfile.is_null() {
|
||||
context.dbfile
|
||||
if context.has_dbfile() {
|
||||
context.get_dbfile()
|
||||
} else {
|
||||
unset
|
||||
},
|
||||
dbversion,
|
||||
if !context.blobdir.is_null() {
|
||||
context.blobdir
|
||||
if context.has_blobdir() {
|
||||
context.get_blobdir()
|
||||
} else {
|
||||
unset
|
||||
},
|
||||
|
||||
3735
src/dc_imap.rs
3735
src/dc_imap.rs
File diff suppressed because it is too large
Load Diff
@@ -977,7 +977,7 @@ unsafe fn import_backup(
|
||||
0i32,
|
||||
b"Import \"%s\" to \"%s\".\x00" as *const u8 as *const libc::c_char,
|
||||
backup_to_import,
|
||||
context.dbfile,
|
||||
context.get_dbfile(),
|
||||
);
|
||||
if 0 != dc_is_configured(context) {
|
||||
dc_log_error(
|
||||
@@ -989,22 +989,22 @@ unsafe fn import_backup(
|
||||
if 0 != dc_sqlite3_is_open(&context.sql.clone().read().unwrap()) {
|
||||
dc_sqlite3_close(context, &mut context.sql.clone().write().unwrap());
|
||||
}
|
||||
dc_delete_file(context, context.dbfile);
|
||||
if 0 != dc_file_exist(context, context.dbfile) {
|
||||
dc_delete_file(context, context.get_dbfile());
|
||||
if 0 != dc_file_exist(context, context.get_dbfile()) {
|
||||
dc_log_error(
|
||||
context,
|
||||
0i32,
|
||||
b"Cannot import backups: Cannot delete the old file.\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
} else if !(0 == dc_copy_file(context, backup_to_import, context.dbfile)) {
|
||||
} else if !(0 == dc_copy_file(context, backup_to_import, context.get_dbfile())) {
|
||||
/* error already logged */
|
||||
/* re-open copied database file */
|
||||
if !(0
|
||||
== dc_sqlite3_open(
|
||||
context,
|
||||
&mut context.sql.clone().write().unwrap(),
|
||||
context.dbfile,
|
||||
context.get_dbfile(),
|
||||
0i32,
|
||||
))
|
||||
{
|
||||
@@ -1062,7 +1062,7 @@ unsafe fn import_backup(
|
||||
free(pathNfilename as *mut libc::c_void);
|
||||
pathNfilename = dc_mprintf(
|
||||
b"%s/%s\x00" as *const u8 as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
file_name,
|
||||
);
|
||||
if !(0
|
||||
@@ -1168,15 +1168,15 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
context,
|
||||
0i32,
|
||||
b"Backup \"%s\" to \"%s\".\x00" as *const u8 as *const libc::c_char,
|
||||
context.dbfile,
|
||||
context.get_dbfile(),
|
||||
dest_pathNfilename,
|
||||
);
|
||||
if !(0 == dc_copy_file(context, context.dbfile, dest_pathNfilename)) {
|
||||
if !(0 == dc_copy_file(context, context.get_dbfile(), dest_pathNfilename)) {
|
||||
/* error already logged */
|
||||
dc_sqlite3_open(
|
||||
context,
|
||||
&mut context.sql.clone().write().unwrap(),
|
||||
context.dbfile,
|
||||
context.get_dbfile(),
|
||||
0i32,
|
||||
);
|
||||
closed = 0i32;
|
||||
@@ -1205,7 +1205,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
11487273724841241105 => {}
|
||||
_ => {
|
||||
total_files_cnt = 0i32;
|
||||
dir_handle = opendir(context.blobdir);
|
||||
dir_handle = opendir(context.get_blobdir());
|
||||
if dir_handle.is_null() {
|
||||
dc_log_error(
|
||||
context,
|
||||
@@ -1213,7 +1213,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
b"Backup: Cannot get info for blob-directory \"%s\".\x00"
|
||||
as *const u8
|
||||
as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
} else {
|
||||
loop {
|
||||
@@ -1227,7 +1227,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
dir_handle = 0 as *mut DIR;
|
||||
if total_files_cnt > 0i32 {
|
||||
/* scan directory, pass 2: copy files */
|
||||
dir_handle = opendir(context.blobdir);
|
||||
dir_handle = opendir(context.get_blobdir());
|
||||
if dir_handle.is_null() {
|
||||
dc_log_error(
|
||||
context,
|
||||
@@ -1235,7 +1235,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
b"Backup: Cannot copy from blob-directory \"%s\".\x00"
|
||||
as *const u8
|
||||
as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
current_block = 11487273724841241105;
|
||||
} else {
|
||||
@@ -1312,7 +1312,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
curr_pathNfilename = dc_mprintf(
|
||||
b"%s/%s\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
name,
|
||||
);
|
||||
free(buf);
|
||||
@@ -1359,7 +1359,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
0i32,
|
||||
b"Backup: No files to copy.\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
current_block = 2631791190359682872;
|
||||
}
|
||||
@@ -1395,7 +1395,7 @@ unsafe fn export_backup(mut context: &dc_context_t, mut dir: *const libc::c_char
|
||||
dc_sqlite3_open(
|
||||
context,
|
||||
&mut context.sql.clone().write().unwrap(),
|
||||
context.dbfile,
|
||||
context.get_dbfile(),
|
||||
0i32,
|
||||
);
|
||||
}
|
||||
|
||||
131
src/dc_job.rs
131
src/dc_job.rs
@@ -68,6 +68,7 @@ unsafe fn dc_job_perform(
|
||||
mut thread: libc::c_int,
|
||||
mut probe_network: libc::c_int,
|
||||
) {
|
||||
println!("perform job");
|
||||
let mut select_stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
|
||||
let mut job: dc_job_t = dc_job_t {
|
||||
job_id: 0,
|
||||
@@ -470,9 +471,12 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(mut context: &dc_context_t, mut job: *mut dc
|
||||
let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context);
|
||||
let mut dest_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut dest_uid: uint32_t = 0i32 as uint32_t;
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
connect_to_inbox(context);
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
|
||||
let inbox = context.inbox.read().unwrap();
|
||||
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
current_block = 2238328302157162973;
|
||||
} else {
|
||||
@@ -491,11 +495,7 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(mut context: &dc_context_t, mut job: *mut dc
|
||||
0i32,
|
||||
) < 3i32
|
||||
{
|
||||
dc_configure_folders(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
0x1i32,
|
||||
);
|
||||
inbox.configure_folders(context, 0x1i32);
|
||||
}
|
||||
dest_folder = dc_sqlite3_get_config(
|
||||
context,
|
||||
@@ -503,9 +503,8 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(mut context: &dc_context_t, mut job: *mut dc
|
||||
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
match dc_imap_move(
|
||||
match inbox.mv(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
(*msg).server_folder,
|
||||
(*msg).server_uid,
|
||||
dest_folder,
|
||||
@@ -556,31 +555,28 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(mut context: &dc_context_t, mut job: *mut dc
|
||||
/* ******************************************************************************
|
||||
* IMAP-jobs
|
||||
******************************************************************************/
|
||||
unsafe fn connect_to_inbox(mut context: &dc_context_t) -> libc::c_int {
|
||||
unsafe fn connect_to_inbox(context: &dc_context_t, inbox: &dc_imap_t) -> libc::c_int {
|
||||
let mut ret_connected: libc::c_int = 0i32;
|
||||
ret_connected =
|
||||
dc_connect_to_configured_imap(context, &mut context.inbox.clone().lock().unwrap());
|
||||
|
||||
ret_connected = dc_connect_to_configured_imap(context, inbox);
|
||||
if !(0 == ret_connected) {
|
||||
dc_imap_set_watch_folder(
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
b"INBOX\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
inbox.set_watch_folder(b"INBOX\x00" as *const u8 as *const libc::c_char);
|
||||
}
|
||||
return ret_connected;
|
||||
ret_connected
|
||||
}
|
||||
unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(
|
||||
mut context: &dc_context_t,
|
||||
mut job: *mut dc_job_t,
|
||||
) {
|
||||
|
||||
unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &dc_context_t, job: *mut dc_job_t) {
|
||||
let mut current_block: u64;
|
||||
let mut folder: *mut libc::c_char =
|
||||
dc_param_get((*job).param, 'Z' as i32, 0 as *const libc::c_char);
|
||||
let mut uid: uint32_t = dc_param_get_int((*job).param, 'z' as i32, 0i32) as uint32_t;
|
||||
let mut dest_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut dest_uid: uint32_t = 0i32 as uint32_t;
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
connect_to_inbox(context);
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
let mut inbox = context.inbox.read().unwrap();
|
||||
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
current_block = 2670689566614003383;
|
||||
} else {
|
||||
@@ -591,14 +587,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(
|
||||
}
|
||||
match current_block {
|
||||
11006700562992250127 => {
|
||||
if dc_imap_set_seen(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
folder,
|
||||
uid,
|
||||
) as libc::c_uint
|
||||
== 0i32 as libc::c_uint
|
||||
{
|
||||
if inbox.set_seen(context, folder, uid) as libc::c_uint == 0i32 as libc::c_uint {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
}
|
||||
if 0 != dc_param_get_int((*job).param, 'M' as i32, 0i32) {
|
||||
@@ -609,11 +598,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(
|
||||
0i32,
|
||||
) < 3i32
|
||||
{
|
||||
dc_configure_folders(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
0x1i32,
|
||||
);
|
||||
inbox.configure_folders(context, 0x1i32);
|
||||
}
|
||||
dest_folder = dc_sqlite3_get_config(
|
||||
context,
|
||||
@@ -621,15 +606,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(
|
||||
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
match dc_imap_move(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
folder,
|
||||
uid,
|
||||
dest_folder,
|
||||
&mut dest_uid,
|
||||
) as libc::c_uint
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -648,9 +625,11 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(
|
||||
) {
|
||||
let mut current_block: u64;
|
||||
let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context);
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
connect_to_inbox(context);
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
let inbox = context.inbox.read().unwrap();
|
||||
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
current_block = 17792648348530113339;
|
||||
} else {
|
||||
@@ -662,12 +641,8 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(
|
||||
match current_block {
|
||||
15240798224410183470 => {
|
||||
if !(0 == dc_msg_load_from_db(msg, context, (*job).foreign_id)) {
|
||||
match dc_imap_set_seen(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
(*msg).server_folder,
|
||||
(*msg).server_uid,
|
||||
) as libc::c_uint
|
||||
match inbox.set_seen(context, (*msg).server_folder, (*msg).server_uid)
|
||||
as libc::c_uint
|
||||
{
|
||||
0 => {}
|
||||
1 => {
|
||||
@@ -685,9 +660,8 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(
|
||||
1i32,
|
||||
)
|
||||
{
|
||||
match dc_imap_set_mdnsent(
|
||||
match inbox.set_mdnsent(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
(*msg).server_folder,
|
||||
(*msg).server_uid,
|
||||
) as libc::c_uint
|
||||
@@ -743,9 +717,8 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(
|
||||
1i32,
|
||||
)
|
||||
{
|
||||
match dc_imap_set_mdnsent(
|
||||
match inbox.set_mdnsent(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
(*msg).server_folder,
|
||||
(*msg).server_uid,
|
||||
) as libc::c_uint
|
||||
@@ -965,21 +938,25 @@ pub unsafe fn dc_interrupt_smtp_idle(mut context: &dc_context_t) {
|
||||
cvar.notify_one();
|
||||
}
|
||||
|
||||
pub unsafe fn dc_interrupt_imap_idle(mut context: &dc_context_t) {
|
||||
pub unsafe fn dc_interrupt_imap_idle(context: &dc_context_t) {
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"Interrupting IMAP-IDLE...\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
|
||||
*context.perform_inbox_jobs_needed.clone().write().unwrap() = 1;
|
||||
dc_imap_interrupt_idle(&mut context.inbox.clone().lock().unwrap());
|
||||
println!("inbox lock");
|
||||
*context.perform_inbox_jobs_needed.write().unwrap() = 1;
|
||||
println!("imap lock");
|
||||
context.inbox.read().unwrap().interrupt_idle();
|
||||
}
|
||||
|
||||
unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(mut context: &dc_context_t, mut job: *mut dc_job_t) {
|
||||
let mut current_block: u64;
|
||||
let mut delete_from_server: libc::c_int = 1i32;
|
||||
let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context);
|
||||
let inbox = context.inbox.read().unwrap();
|
||||
|
||||
if !(0 == dc_msg_load_from_db(msg, context, (*job).foreign_id)
|
||||
|| (*msg).rfc724_mid.is_null()
|
||||
|| *(*msg).rfc724_mid.offset(0isize) as libc::c_int == 0i32)
|
||||
@@ -996,9 +973,9 @@ unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(mut context: &dc_context_t, mut jo
|
||||
}
|
||||
/* if this is the last existing part of the message, we delete the message from the server */
|
||||
if 0 != delete_from_server {
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
connect_to_inbox(context);
|
||||
if 0 == dc_imap_is_connected(&mut context.inbox.clone().lock().unwrap()) {
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
current_block = 8913536887710889399;
|
||||
} else {
|
||||
@@ -1010,9 +987,8 @@ unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(mut context: &dc_context_t, mut jo
|
||||
match current_block {
|
||||
8913536887710889399 => {}
|
||||
_ => {
|
||||
if 0 == dc_imap_delete_msg(
|
||||
if 0 == inbox.delete_msg(
|
||||
context,
|
||||
&mut context.inbox.clone().lock().unwrap(),
|
||||
(*msg).rfc724_mid,
|
||||
(*msg).server_folder,
|
||||
(*msg).server_uid,
|
||||
@@ -1049,9 +1025,11 @@ pub unsafe fn dc_job_kill_action(mut context: &dc_context_t, mut action: libc::c
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_perform_imap_fetch(mut context: &dc_context_t) {
|
||||
pub unsafe fn dc_perform_imap_fetch(context: &dc_context_t) {
|
||||
let inbox = context.inbox.read().unwrap();
|
||||
|
||||
let mut start: libc::clock_t = clock();
|
||||
if 0 == connect_to_inbox(context) {
|
||||
if 0 == connect_to_inbox(context, &inbox) {
|
||||
return;
|
||||
}
|
||||
if dc_sqlite3_get_config_int(
|
||||
@@ -1073,14 +1051,14 @@ pub unsafe fn dc_perform_imap_fetch(mut context: &dc_context_t) {
|
||||
0i32,
|
||||
b"INBOX-fetch started...\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
dc_imap_fetch(context, &mut context.inbox.clone().lock().unwrap());
|
||||
if 0 != context.inbox.clone().lock().unwrap().should_reconnect {
|
||||
inbox.fetch(context);
|
||||
if inbox.should_reconnect() {
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"INBOX-fetch aborted, starting over...\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
dc_imap_fetch(context, &mut context.inbox.clone().lock().unwrap());
|
||||
inbox.fetch(context);
|
||||
}
|
||||
dc_log_info(
|
||||
context,
|
||||
@@ -1089,8 +1067,11 @@ pub unsafe fn dc_perform_imap_fetch(mut context: &dc_context_t) {
|
||||
clock().wrapping_sub(start) as libc::c_double * 1000.0f64 / 1000000i32 as libc::c_double,
|
||||
);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_perform_imap_idle(context: &dc_context_t) {
|
||||
connect_to_inbox(context);
|
||||
let inbox = context.inbox.read().unwrap();
|
||||
|
||||
connect_to_inbox(context, &inbox);
|
||||
|
||||
if 0 != *context.perform_inbox_jobs_needed.clone().read().unwrap() {
|
||||
dc_log_info(
|
||||
@@ -1106,7 +1087,7 @@ pub unsafe fn dc_perform_imap_idle(context: &dc_context_t) {
|
||||
0i32,
|
||||
b"INBOX-IDLE started...\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
dc_imap_idle(context, &mut context.inbox.clone().lock().unwrap());
|
||||
inbox.idle(context);
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
|
||||
@@ -104,7 +104,8 @@ pub unsafe extern "C" fn dc_jobthread_interrupt_idle(
|
||||
jobthread.name,
|
||||
);
|
||||
|
||||
dc_imap_interrupt_idle(&mut jobthread.imap.clone().lock().unwrap());
|
||||
println!("jobthread interrupt, waiting for lock");
|
||||
jobthread.imap.lock().unwrap().interrupt_idle();
|
||||
|
||||
let &(ref lock, ref cvar) = &*jobthread.state.clone();
|
||||
let mut state = lock.lock().unwrap();
|
||||
@@ -140,16 +141,16 @@ pub unsafe fn dc_jobthread_fetch(
|
||||
b"%s-fetch started...\x00" as *const u8 as *const libc::c_char,
|
||||
jobthread.name,
|
||||
);
|
||||
dc_imap_fetch(context, &mut jobthread.imap.clone().lock().unwrap());
|
||||
jobthread.imap.lock().unwrap().fetch(context);
|
||||
|
||||
if 0 != jobthread.imap.clone().lock().unwrap().should_reconnect {
|
||||
if jobthread.imap.lock().unwrap().should_reconnect() {
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
b"%s-fetch aborted, starting over...\x00" as *const u8 as *const libc::c_char,
|
||||
jobthread.name,
|
||||
);
|
||||
dc_imap_fetch(context, &mut jobthread.imap.clone().lock().unwrap());
|
||||
jobthread.imap.lock().unwrap().fetch(context);
|
||||
}
|
||||
dc_log_info(
|
||||
context,
|
||||
@@ -173,7 +174,7 @@ unsafe fn connect_to_imap(context: &dc_context_t, jobthread: &mut dc_jobthread_t
|
||||
let mut ret_connected: libc::c_int = 0i32;
|
||||
let mut mvbox_name: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
|
||||
if 0 != dc_imap_is_connected(&mut jobthread.imap.clone().lock().unwrap()) {
|
||||
if jobthread.imap.lock().unwrap().is_connected() {
|
||||
ret_connected = 1
|
||||
} else {
|
||||
ret_connected =
|
||||
@@ -186,7 +187,11 @@ unsafe fn connect_to_imap(context: &dc_context_t, jobthread: &mut dc_jobthread_t
|
||||
0,
|
||||
) < 3
|
||||
{
|
||||
dc_configure_folders(context, &mut jobthread.imap.clone().lock().unwrap(), 0x1);
|
||||
jobthread
|
||||
.imap
|
||||
.lock()
|
||||
.unwrap()
|
||||
.configure_folders(context, 0x1);
|
||||
}
|
||||
mvbox_name = dc_sqlite3_get_config(
|
||||
context,
|
||||
@@ -195,10 +200,10 @@ unsafe fn connect_to_imap(context: &dc_context_t, jobthread: &mut dc_jobthread_t
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
if mvbox_name.is_null() {
|
||||
dc_imap_disconnect(context, &mut jobthread.imap.clone().lock().unwrap());
|
||||
jobthread.imap.lock().unwrap().disconnect(context);
|
||||
ret_connected = 0;
|
||||
} else {
|
||||
dc_imap_set_watch_folder(&mut jobthread.imap.clone().lock().unwrap(), mvbox_name);
|
||||
jobthread.imap.lock().unwrap().set_watch_folder(mvbox_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +261,7 @@ pub unsafe fn dc_jobthread_idle(
|
||||
b"%s-IDLE started...\x00" as *const u8 as *const libc::c_char,
|
||||
jobthread.name,
|
||||
);
|
||||
dc_imap_idle(context, &mut jobthread.imap.clone().lock().unwrap());
|
||||
jobthread.imap.lock().unwrap().idle(context);
|
||||
dc_log_info(
|
||||
context,
|
||||
0i32,
|
||||
|
||||
@@ -56,7 +56,7 @@ pub unsafe fn dc_receive_imf(
|
||||
let mut sort_timestamp: time_t = -1i32 as time_t;
|
||||
let mut sent_timestamp: time_t = -1i32 as time_t;
|
||||
let mut rcvd_timestamp: time_t = -1i32 as time_t;
|
||||
let mut mime_parser: *mut dc_mimeparser_t = dc_mimeparser_new((*context).blobdir, context);
|
||||
let mut mime_parser: *mut dc_mimeparser_t = dc_mimeparser_new(context.get_blobdir(), context);
|
||||
let mut field: *const mailimf_field = 0 as *const mailimf_field;
|
||||
let mut mime_in_reply_to: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut mime_references: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
|
||||
@@ -936,7 +936,7 @@ pub unsafe fn dc_sqlite3_open(
|
||||
context,
|
||||
sql,
|
||||
b"backup_for\x00" as *const u8 as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
dc_ensure_no_slash(repl_from);
|
||||
if 0 != !('f' as i32 == 'f' as i32) as libc::c_int as libc::c_long {
|
||||
@@ -1478,13 +1478,13 @@ pub unsafe fn dc_housekeeping(context: &dc_context_t) {
|
||||
files_in_use.count as libc::c_int,
|
||||
);
|
||||
/* go through directory and delete unused files */
|
||||
dir_handle = opendir(context.blobdir);
|
||||
dir_handle = opendir(context.get_blobdir());
|
||||
if dir_handle.is_null() {
|
||||
dc_log_warning(
|
||||
context,
|
||||
0,
|
||||
b"Housekeeping: Cannot open %s.\x00" as *const u8 as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
} else {
|
||||
/* avoid deletion of files that are just created to build a message object */
|
||||
@@ -1529,7 +1529,7 @@ pub unsafe fn dc_housekeeping(context: &dc_context_t) {
|
||||
free(path as *mut libc::c_void);
|
||||
path = dc_mprintf(
|
||||
b"%s/%s\x00" as *const u8 as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
name,
|
||||
);
|
||||
|
||||
|
||||
@@ -1281,13 +1281,13 @@ pub unsafe fn dc_get_abs_path(
|
||||
8,
|
||||
) == 0i32
|
||||
{
|
||||
if context.blobdir.is_null() {
|
||||
if !context.has_blobdir() {
|
||||
current_block = 3805228753452640762;
|
||||
} else {
|
||||
dc_str_replace(
|
||||
&mut pathNfilename_abs,
|
||||
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
current_block = 6937071982253665452;
|
||||
}
|
||||
@@ -1600,7 +1600,7 @@ pub unsafe fn dc_is_blobdir_path(
|
||||
mut context: &dc_context_t,
|
||||
mut path: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
if strncmp(path, context.blobdir, strlen(context.blobdir)) == 0i32
|
||||
if strncmp(path, context.get_blobdir(), strlen(context.get_blobdir())) == 0i32
|
||||
|| strncmp(path, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, 8) == 0i32
|
||||
{
|
||||
return 1i32;
|
||||
@@ -1612,10 +1612,10 @@ pub unsafe fn dc_make_rel_path(mut context: &dc_context_t, mut path: *mut *mut l
|
||||
if path.is_null() || (*path).is_null() {
|
||||
return;
|
||||
}
|
||||
if strncmp(*path, context.blobdir, strlen(context.blobdir)) == 0i32 {
|
||||
if strncmp(*path, context.get_blobdir(), strlen(context.get_blobdir())) == 0i32 {
|
||||
dc_str_replace(
|
||||
path,
|
||||
context.blobdir,
|
||||
context.get_blobdir(),
|
||||
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
};
|
||||
|
||||
4
src/x.rs
4
src/x.rs
@@ -415,8 +415,8 @@ extern "C" {
|
||||
) -> libc::c_int;
|
||||
pub fn mailimap_idle(session: *mut mailimap) -> libc::c_int;
|
||||
pub fn mailimap_idle_done(session: *mut mailimap) -> libc::c_int;
|
||||
pub fn mailimap_has_idle(session: *mut mailimap) -> libc::c_int;
|
||||
pub fn mailimap_has_xlist(session: *mut mailimap) -> libc::c_int;
|
||||
pub fn mailimap_has_idle(session: *const mailimap) -> libc::c_int;
|
||||
pub fn mailimap_has_xlist(session: *const mailimap) -> libc::c_int;
|
||||
pub fn mailimap_oauth2_authenticate(
|
||||
session: *mut mailimap,
|
||||
auth_user: *const libc::c_char,
|
||||
|
||||
@@ -338,7 +338,7 @@ unsafe extern "C" fn stress_functions(context: &dc_context_t) {
|
||||
};
|
||||
let mut abs_path: *mut libc::c_char = dc_mprintf(
|
||||
b"%s/%s\x00" as *const u8 as *const libc::c_char,
|
||||
(*context).blobdir,
|
||||
context.get_blobdir(),
|
||||
b"foobar\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
if 0 != (0 == dc_is_blobdir_path(context, abs_path)) as libc::c_int as libc::c_long {
|
||||
@@ -749,7 +749,7 @@ unsafe extern "C" fn stress_functions(context: &dc_context_t) {
|
||||
} else {
|
||||
};
|
||||
mailmime_free(mime);
|
||||
let mut mimeparser: *mut dc_mimeparser_t = dc_mimeparser_new((*context).blobdir, context);
|
||||
let mut mimeparser: *mut dc_mimeparser_t = dc_mimeparser_new(context.get_blobdir(), context);
|
||||
let mut raw: *const libc::c_char =
|
||||
b"Content-Type: multipart/mixed; boundary=\"==break==\";\nSubject: outer-subject\nX-Special-A: special-a\nFoo: Bar\nChat-Version: 0.0\n\n--==break==\nContent-Type: text/plain; protected-headers=\"v1\";\nSubject: inner-subject\nX-Special-B: special-b\nFoo: Xy\nChat-Version: 1.0\n\ntest1\n\n--==break==--\n\n\x00"
|
||||
as *const u8 as *const libc::c_char;
|
||||
|
||||
Reference in New Issue
Block a user