diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 29d27c2b3..6ff7fcaae 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -18,7 +18,7 @@ pub const DC_VERSION_STR: &'static str = "0.43.0\x00"; // dc_context_t -pub type dc_context_t = dc_context::dc_context_t; +pub type dc_context_t = context::Context; pub type dc_callback_t = types::dc_callback_t; @@ -28,7 +28,7 @@ pub unsafe extern "C" fn dc_context_new( userdata: *mut libc::c_void, os_name: *const libc::c_char, ) -> *mut dc_context_t { - let ctx = dc_context::dc_context_new(cb, userdata, os_name); + let ctx = context::dc_context_new(cb, userdata, os_name); Box::into_raw(Box::new(ctx)) } @@ -36,89 +36,85 @@ pub unsafe extern "C" fn dc_context_new( pub unsafe extern "C" fn dc_context_unref(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &mut *context; - dc_context::dc_context_unref(context) + context::dc_context_unref(context) } #[no_mangle] -pub unsafe extern "C" fn dc_get_userdata( - context: *mut dc_context::dc_context_t, -) -> *mut libc::c_void { +pub unsafe extern "C" fn dc_get_userdata(context: *mut dc_context_t) -> *mut libc::c_void { assert!(!context.is_null()); let context = &mut *context; - dc_context::dc_get_userdata(context) + context::dc_get_userdata(context) } #[no_mangle] pub unsafe extern "C" fn dc_open( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, dbfile: *mut libc::c_char, blobdir: *mut libc::c_char, ) -> libc::c_int { assert!(!context.is_null()); let context = &mut *context; - dc_context::dc_open(context, dbfile, blobdir) + context::dc_open(context, dbfile, blobdir) } #[no_mangle] -pub unsafe extern "C" fn dc_close(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_close(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &mut *context; - dc_context::dc_close(context) + context::dc_close(context) } #[no_mangle] -pub unsafe extern "C" fn dc_is_open(context: *mut dc_context::dc_context_t) -> libc::c_int { +pub unsafe extern "C" fn dc_is_open(context: *mut dc_context_t) -> libc::c_int { assert!(!context.is_null()); let context = &mut *context; - dc_context::dc_is_open(context) + context::dc_is_open(context) } #[no_mangle] -pub unsafe extern "C" fn dc_get_blobdir( - context: *mut dc_context::dc_context_t, -) -> *mut libc::c_char { +pub unsafe extern "C" fn dc_get_blobdir(context: *mut dc_context_t) -> *mut libc::c_char { assert!(!context.is_null()); let context = &*context; - dc_context::dc_get_blobdir(context) + context::dc_get_blobdir(context) } #[no_mangle] pub unsafe extern "C" fn dc_set_config( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, key: *mut libc::c_char, value: *mut libc::c_char, ) -> libc::c_int { assert!(!context.is_null()); let context = &*context; - dc_context::dc_set_config(context, key, value) + context::dc_set_config(context, key, value) } #[no_mangle] pub unsafe extern "C" fn dc_get_config( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, key: *mut libc::c_char, ) -> *mut libc::c_char { assert!(!context.is_null()); let context = &*context; - dc_context::dc_get_config(context, key) + context::dc_get_config(context, key) } #[no_mangle] -pub unsafe extern "C" fn dc_get_info(context: *mut dc_context::dc_context_t) -> *mut libc::c_char { +pub unsafe extern "C" fn dc_get_info(context: *mut dc_context_t) -> *mut libc::c_char { assert!(!context.is_null()); let context = &*context; - dc_context::dc_get_info(context) + context::dc_get_info(context) } #[no_mangle] pub unsafe extern "C" fn dc_get_oauth2_url( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, addr: *mut libc::c_char, redirect: *mut libc::c_char, ) -> *mut libc::c_char { @@ -135,11 +131,11 @@ pub unsafe extern "C" fn dc_get_oauth2_url( #[no_mangle] pub unsafe extern "C" fn dc_get_version_str() -> *mut libc::c_char { - dc_context::dc_get_version_str() + context::dc_get_version_str() } #[no_mangle] -pub unsafe extern "C" fn dc_configure(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_configure(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -147,7 +143,7 @@ pub unsafe extern "C" fn dc_configure(context: *mut dc_context::dc_context_t) { } #[no_mangle] -pub unsafe extern "C" fn dc_is_configured(context: *mut dc_context::dc_context_t) -> libc::c_int { +pub unsafe extern "C" fn dc_is_configured(context: *mut dc_context_t) -> libc::c_int { assert!(!context.is_null()); let context = &*context; @@ -155,7 +151,7 @@ pub unsafe extern "C" fn dc_is_configured(context: *mut dc_context::dc_context_t } #[no_mangle] -pub unsafe extern "C" fn dc_perform_imap_jobs(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_imap_jobs(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -163,7 +159,7 @@ pub unsafe extern "C" fn dc_perform_imap_jobs(context: *mut dc_context::dc_conte } #[no_mangle] -pub unsafe extern "C" fn dc_perform_imap_fetch(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_imap_fetch(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -171,7 +167,7 @@ pub unsafe extern "C" fn dc_perform_imap_fetch(context: *mut dc_context::dc_cont } #[no_mangle] -pub unsafe extern "C" fn dc_perform_imap_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_imap_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -179,7 +175,7 @@ pub unsafe extern "C" fn dc_perform_imap_idle(context: *mut dc_context::dc_conte } #[no_mangle] -pub unsafe extern "C" fn dc_interrupt_imap_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_interrupt_imap_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -187,7 +183,7 @@ pub unsafe extern "C" fn dc_interrupt_imap_idle(context: *mut dc_context::dc_con } #[no_mangle] -pub unsafe extern "C" fn dc_perform_mvbox_fetch(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_mvbox_fetch(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -195,7 +191,7 @@ pub unsafe extern "C" fn dc_perform_mvbox_fetch(context: *mut dc_context::dc_con } #[no_mangle] -pub unsafe extern "C" fn dc_perform_mvbox_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_mvbox_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -203,7 +199,7 @@ pub unsafe extern "C" fn dc_perform_mvbox_idle(context: *mut dc_context::dc_cont } #[no_mangle] -pub unsafe extern "C" fn dc_interrupt_mvbox_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_interrupt_mvbox_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -211,7 +207,7 @@ pub unsafe extern "C" fn dc_interrupt_mvbox_idle(context: *mut dc_context::dc_co } #[no_mangle] -pub unsafe extern "C" fn dc_perform_sentbox_fetch(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_sentbox_fetch(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -219,7 +215,7 @@ pub unsafe extern "C" fn dc_perform_sentbox_fetch(context: *mut dc_context::dc_c } #[no_mangle] -pub unsafe extern "C" fn dc_perform_sentbox_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_sentbox_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -227,7 +223,7 @@ pub unsafe extern "C" fn dc_perform_sentbox_idle(context: *mut dc_context::dc_co } #[no_mangle] -pub unsafe extern "C" fn dc_interrupt_sentbox_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_interrupt_sentbox_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -235,7 +231,7 @@ pub unsafe extern "C" fn dc_interrupt_sentbox_idle(context: *mut dc_context::dc_ } #[no_mangle] -pub unsafe extern "C" fn dc_perform_smtp_jobs(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_smtp_jobs(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -243,7 +239,7 @@ pub unsafe extern "C" fn dc_perform_smtp_jobs(context: *mut dc_context::dc_conte } #[no_mangle] -pub unsafe extern "C" fn dc_perform_smtp_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_perform_smtp_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -251,7 +247,7 @@ pub unsafe extern "C" fn dc_perform_smtp_idle(context: *mut dc_context::dc_conte } #[no_mangle] -pub unsafe extern "C" fn dc_interrupt_smtp_idle(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_interrupt_smtp_idle(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -259,7 +255,7 @@ pub unsafe extern "C" fn dc_interrupt_smtp_idle(context: *mut dc_context::dc_con } #[no_mangle] -pub unsafe extern "C" fn dc_maybe_network(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_maybe_network(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -268,7 +264,7 @@ pub unsafe extern "C" fn dc_maybe_network(context: *mut dc_context::dc_context_t #[no_mangle] pub unsafe extern "C" fn dc_get_chatlist<'a>( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, flags: libc::c_int, query_str: *mut libc::c_char, query_id: libc::uint32_t, @@ -281,7 +277,7 @@ pub unsafe extern "C" fn dc_get_chatlist<'a>( #[no_mangle] pub unsafe extern "C" fn dc_create_chat_by_msg_id( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_id: libc::uint32_t, ) -> libc::uint32_t { assert!(!context.is_null()); @@ -292,7 +288,7 @@ pub unsafe extern "C" fn dc_create_chat_by_msg_id( #[no_mangle] pub unsafe extern "C" fn dc_create_chat_by_contact_id( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, ) -> libc::uint32_t { assert!(!context.is_null()); @@ -303,7 +299,7 @@ pub unsafe extern "C" fn dc_create_chat_by_contact_id( #[no_mangle] pub unsafe extern "C" fn dc_get_chat_id_by_contact_id( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, ) -> libc::uint32_t { assert!(!context.is_null()); @@ -314,7 +310,7 @@ pub unsafe extern "C" fn dc_get_chat_id_by_contact_id( #[no_mangle] pub unsafe extern "C" fn dc_prepare_msg( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, msg: *mut dc_msg::dc_msg_t, ) -> libc::uint32_t { @@ -326,7 +322,7 @@ pub unsafe extern "C" fn dc_prepare_msg( #[no_mangle] pub unsafe extern "C" fn dc_send_msg( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, msg: *mut dc_msg::dc_msg_t, ) -> libc::uint32_t { @@ -338,7 +334,7 @@ pub unsafe extern "C" fn dc_send_msg( #[no_mangle] pub unsafe extern "C" fn dc_send_text_msg( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, text_to_send: *mut libc::c_char, ) -> libc::uint32_t { @@ -350,7 +346,7 @@ pub unsafe extern "C" fn dc_send_text_msg( #[no_mangle] pub unsafe extern "C" fn dc_set_draft( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, msg: *mut dc_msg::dc_msg_t, ) { @@ -362,7 +358,7 @@ pub unsafe extern "C" fn dc_set_draft( #[no_mangle] pub unsafe extern "C" fn dc_get_draft<'a>( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> *mut dc_msg::dc_msg_t<'a> { assert!(!context.is_null()); @@ -373,7 +369,7 @@ pub unsafe extern "C" fn dc_get_draft<'a>( #[no_mangle] pub unsafe extern "C" fn dc_get_chat_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, flags: libc::uint32_t, marker1before: libc::uint32_t, @@ -386,7 +382,7 @@ pub unsafe extern "C" fn dc_get_chat_msgs( #[no_mangle] pub unsafe extern "C" fn dc_get_msg_cnt( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> libc::c_int { assert!(!context.is_null()); @@ -397,7 +393,7 @@ pub unsafe extern "C" fn dc_get_msg_cnt( #[no_mangle] pub unsafe extern "C" fn dc_get_fresh_msg_cnt( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> libc::c_int { assert!(!context.is_null()); @@ -408,19 +404,16 @@ pub unsafe extern "C" fn dc_get_fresh_msg_cnt( #[no_mangle] pub unsafe extern "C" fn dc_get_fresh_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, ) -> *mut dc_array::dc_array_t { assert!(!context.is_null()); let context = &*context; - dc_context::dc_get_fresh_msgs(context) + context::dc_get_fresh_msgs(context) } #[no_mangle] -pub unsafe extern "C" fn dc_marknoticed_chat( - context: *mut dc_context::dc_context_t, - chat_id: libc::uint32_t, -) { +pub unsafe extern "C" fn dc_marknoticed_chat(context: *mut dc_context_t, chat_id: libc::uint32_t) { assert!(!context.is_null()); let context = &*context; @@ -428,7 +421,7 @@ pub unsafe extern "C" fn dc_marknoticed_chat( } #[no_mangle] -pub unsafe extern "C" fn dc_marknoticed_all_chats(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_marknoticed_all_chats(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -437,7 +430,7 @@ pub unsafe extern "C" fn dc_marknoticed_all_chats(context: *mut dc_context::dc_c #[no_mangle] pub unsafe extern "C" fn dc_get_chat_media( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, msg_type: libc::c_int, or_msg_type2: libc::c_int, @@ -451,7 +444,7 @@ pub unsafe extern "C" fn dc_get_chat_media( #[no_mangle] pub unsafe extern "C" fn dc_get_next_media( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_id: libc::uint32_t, dir: libc::c_int, msg_type: libc::c_int, @@ -466,7 +459,7 @@ pub unsafe extern "C" fn dc_get_next_media( #[no_mangle] pub unsafe extern "C" fn dc_archive_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, archive: libc::c_int, ) { @@ -477,10 +470,7 @@ pub unsafe extern "C" fn dc_archive_chat( } #[no_mangle] -pub unsafe extern "C" fn dc_delete_chat( - context: *mut dc_context::dc_context_t, - chat_id: libc::uint32_t, -) { +pub unsafe extern "C" fn dc_delete_chat(context: *mut dc_context_t, chat_id: libc::uint32_t) { assert!(!context.is_null()); let context = &*context; @@ -489,7 +479,7 @@ pub unsafe extern "C" fn dc_delete_chat( #[no_mangle] pub unsafe extern "C" fn dc_get_chat_contacts( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> *mut dc_array::dc_array_t { assert!(!context.is_null()); @@ -500,19 +490,19 @@ pub unsafe extern "C" fn dc_get_chat_contacts( #[no_mangle] pub unsafe extern "C" fn dc_search_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, query: *mut libc::c_char, ) -> *mut dc_array::dc_array_t { assert!(!context.is_null()); let context = &*context; - dc_context::dc_search_msgs(context, chat_id, query) + context::dc_search_msgs(context, chat_id, query) } #[no_mangle] pub unsafe extern "C" fn dc_get_chat<'a>( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> *mut dc_chat::dc_chat_t<'a> { assert!(!context.is_null()); @@ -523,7 +513,7 @@ pub unsafe extern "C" fn dc_get_chat<'a>( #[no_mangle] pub unsafe extern "C" fn dc_create_group_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, verified: libc::c_int, name: *mut libc::c_char, ) -> libc::uint32_t { @@ -535,7 +525,7 @@ pub unsafe extern "C" fn dc_create_group_chat( #[no_mangle] pub unsafe extern "C" fn dc_is_contact_in_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, contact_id: libc::uint32_t, ) -> libc::c_int { @@ -547,7 +537,7 @@ pub unsafe extern "C" fn dc_is_contact_in_chat( #[no_mangle] pub unsafe extern "C" fn dc_add_contact_to_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, contact_id: libc::uint32_t, ) -> libc::c_int { @@ -559,7 +549,7 @@ pub unsafe extern "C" fn dc_add_contact_to_chat( #[no_mangle] pub unsafe extern "C" fn dc_remove_contact_from_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, contact_id: libc::uint32_t, ) -> libc::c_int { @@ -571,7 +561,7 @@ pub unsafe extern "C" fn dc_remove_contact_from_chat( #[no_mangle] pub unsafe extern "C" fn dc_set_chat_name( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, name: *mut libc::c_char, ) -> libc::c_int { @@ -583,7 +573,7 @@ pub unsafe extern "C" fn dc_set_chat_name( #[no_mangle] pub unsafe extern "C" fn dc_set_chat_profile_image( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, image: *mut libc::c_char, ) -> libc::c_int { @@ -595,7 +585,7 @@ pub unsafe extern "C" fn dc_set_chat_profile_image( #[no_mangle] pub unsafe extern "C" fn dc_get_msg_info( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_id: libc::uint32_t, ) -> *mut libc::c_char { assert!(!context.is_null()); @@ -606,7 +596,7 @@ pub unsafe extern "C" fn dc_get_msg_info( #[no_mangle] pub unsafe extern "C" fn dc_get_mime_headers( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_id: libc::uint32_t, ) -> *mut libc::c_char { assert!(!context.is_null()); @@ -617,7 +607,7 @@ pub unsafe extern "C" fn dc_get_mime_headers( #[no_mangle] pub unsafe extern "C" fn dc_delete_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_ids: *const libc::uint32_t, msg_cnt: libc::c_int, ) { @@ -629,7 +619,7 @@ pub unsafe extern "C" fn dc_delete_msgs( #[no_mangle] pub unsafe extern "C" fn dc_forward_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_ids: *const libc::uint32_t, msg_cnt: libc::c_int, chat_id: libc::uint32_t, @@ -642,7 +632,7 @@ pub unsafe extern "C" fn dc_forward_msgs( #[no_mangle] pub unsafe extern "C" fn dc_marknoticed_contact( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, ) { assert!(!context.is_null()); @@ -653,7 +643,7 @@ pub unsafe extern "C" fn dc_marknoticed_contact( #[no_mangle] pub unsafe extern "C" fn dc_markseen_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_ids: *const libc::uint32_t, msg_cnt: libc::c_int, ) { @@ -665,7 +655,7 @@ pub unsafe extern "C" fn dc_markseen_msgs( #[no_mangle] pub unsafe extern "C" fn dc_star_msgs( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_ids: *const libc::uint32_t, msg_cnt: libc::c_int, star: libc::c_int, @@ -678,7 +668,7 @@ pub unsafe extern "C" fn dc_star_msgs( #[no_mangle] pub unsafe extern "C" fn dc_get_msg<'a>( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_id: libc::uint32_t, ) -> *mut dc_msg::dc_msg_t<'a> { assert!(!context.is_null()); @@ -694,7 +684,7 @@ pub unsafe extern "C" fn dc_may_be_valid_addr(addr: *mut libc::c_char) -> libc:: #[no_mangle] pub unsafe extern "C" fn dc_lookup_contact_id_by_addr( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, addr: *mut libc::c_char, ) -> libc::uint32_t { assert!(!context.is_null()); @@ -705,7 +695,7 @@ pub unsafe extern "C" fn dc_lookup_contact_id_by_addr( #[no_mangle] pub unsafe extern "C" fn dc_create_contact( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, name: *mut libc::c_char, addr: *mut libc::c_char, ) -> libc::uint32_t { @@ -717,7 +707,7 @@ pub unsafe extern "C" fn dc_create_contact( #[no_mangle] pub unsafe extern "C" fn dc_add_address_book( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, addr_book: *mut libc::c_char, ) -> libc::c_int { assert!(!context.is_null()); @@ -728,7 +718,7 @@ pub unsafe extern "C" fn dc_add_address_book( #[no_mangle] pub unsafe extern "C" fn dc_get_contacts( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, flags: libc::uint32_t, query: *mut libc::c_char, ) -> *mut dc_array::dc_array_t { @@ -739,7 +729,7 @@ pub unsafe extern "C" fn dc_get_contacts( } #[no_mangle] -pub unsafe extern "C" fn dc_get_blocked_cnt(context: *mut dc_context::dc_context_t) -> libc::c_int { +pub unsafe extern "C" fn dc_get_blocked_cnt(context: *mut dc_context_t) -> libc::c_int { assert!(!context.is_null()); let context = &*context; @@ -748,7 +738,7 @@ pub unsafe extern "C" fn dc_get_blocked_cnt(context: *mut dc_context::dc_context #[no_mangle] pub unsafe extern "C" fn dc_get_blocked_contacts( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, ) -> *mut dc_array::dc_array_t { assert!(!context.is_null()); let context = &*context; @@ -758,7 +748,7 @@ pub unsafe extern "C" fn dc_get_blocked_contacts( #[no_mangle] pub unsafe extern "C" fn dc_block_contact( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, block: libc::c_int, ) { @@ -770,7 +760,7 @@ pub unsafe extern "C" fn dc_block_contact( #[no_mangle] pub unsafe extern "C" fn dc_get_contact_encrinfo( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, ) -> *mut libc::c_char { assert!(!context.is_null()); @@ -781,7 +771,7 @@ pub unsafe extern "C" fn dc_get_contact_encrinfo( #[no_mangle] pub unsafe extern "C" fn dc_delete_contact( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, ) -> libc::c_int { assert!(!context.is_null()); @@ -792,7 +782,7 @@ pub unsafe extern "C" fn dc_delete_contact( #[no_mangle] pub unsafe extern "C" fn dc_get_contact<'a>( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, contact_id: libc::uint32_t, ) -> *mut dc_contact::dc_contact_t<'a> { assert!(!context.is_null()); @@ -803,7 +793,7 @@ pub unsafe extern "C" fn dc_get_contact<'a>( #[no_mangle] pub unsafe extern "C" fn dc_imex( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, what: libc::c_int, param1: *mut libc::c_char, param2: *mut libc::c_char, @@ -816,7 +806,7 @@ pub unsafe extern "C" fn dc_imex( #[no_mangle] pub unsafe extern "C" fn dc_imex_has_backup( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, dir: *mut libc::c_char, ) -> *mut libc::c_char { assert!(!context.is_null()); @@ -826,9 +816,7 @@ pub unsafe extern "C" fn dc_imex_has_backup( } #[no_mangle] -pub unsafe extern "C" fn dc_initiate_key_transfer( - context: *mut dc_context::dc_context_t, -) -> *mut libc::c_char { +pub unsafe extern "C" fn dc_initiate_key_transfer(context: *mut dc_context_t) -> *mut libc::c_char { assert!(!context.is_null()); let context = &*context; @@ -837,7 +825,7 @@ pub unsafe extern "C" fn dc_initiate_key_transfer( #[no_mangle] pub unsafe extern "C" fn dc_continue_key_transfer( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, msg_id: libc::uint32_t, setup_code: *mut libc::c_char, ) -> libc::c_int { @@ -848,7 +836,7 @@ pub unsafe extern "C" fn dc_continue_key_transfer( } #[no_mangle] -pub unsafe extern "C" fn dc_stop_ongoing_process(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_stop_ongoing_process(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -857,7 +845,7 @@ pub unsafe extern "C" fn dc_stop_ongoing_process(context: *mut dc_context::dc_co #[no_mangle] pub unsafe extern "C" fn dc_check_qr( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, qr: *mut libc::c_char, ) -> *mut dc_lot::dc_lot_t { assert!(!context.is_null()); @@ -868,7 +856,7 @@ pub unsafe extern "C" fn dc_check_qr( #[no_mangle] pub unsafe extern "C" fn dc_get_securejoin_qr( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> *mut libc::c_char { assert!(!context.is_null()); @@ -879,7 +867,7 @@ pub unsafe extern "C" fn dc_get_securejoin_qr( #[no_mangle] pub unsafe extern "C" fn dc_join_securejoin( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, qr: *mut libc::c_char, ) -> libc::uint32_t { assert!(!context.is_null()); @@ -890,7 +878,7 @@ pub unsafe extern "C" fn dc_join_securejoin( #[no_mangle] pub unsafe extern "C" fn dc_send_locations_to_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, seconds: libc::c_int, ) { @@ -902,7 +890,7 @@ pub unsafe extern "C" fn dc_send_locations_to_chat( #[no_mangle] pub unsafe extern "C" fn dc_is_sending_locations_to_chat( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, ) -> libc::c_int { assert!(!context.is_null()); @@ -913,7 +901,7 @@ pub unsafe extern "C" fn dc_is_sending_locations_to_chat( #[no_mangle] pub unsafe extern "C" fn dc_set_location( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, latitude: libc::c_double, longitude: libc::c_double, accuracy: libc::c_double, @@ -926,7 +914,7 @@ pub unsafe extern "C" fn dc_set_location( #[no_mangle] pub unsafe extern "C" fn dc_get_locations( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, chat_id: libc::uint32_t, contact_id: libc::uint32_t, timestamp_begin: libc::time_t, @@ -939,7 +927,7 @@ pub unsafe extern "C" fn dc_get_locations( } #[no_mangle] -pub unsafe extern "C" fn dc_delete_all_locations(context: *mut dc_context::dc_context_t) { +pub unsafe extern "C" fn dc_delete_all_locations(context: *mut dc_context_t) { assert!(!context.is_null()); let context = &*context; @@ -1118,7 +1106,7 @@ pub unsafe extern "C" fn dc_chatlist_get_summary<'a>( #[no_mangle] pub unsafe extern "C" fn dc_chatlist_get_context( chatlist: *mut dc_chatlist::dc_chatlist_t, -) -> *const dc_context::dc_context_t { +) -> *const dc_context_t { assert!(!chatlist.is_null()); (*chatlist).context as *const _ } @@ -1199,7 +1187,7 @@ pub type dc_msg_t<'a> = dc_msg::dc_msg_t<'a>; #[no_mangle] pub unsafe extern "C" fn dc_msg_new<'a>( - context: *mut dc_context::dc_context_t, + context: *mut dc_context_t, viewtype: libc::c_int, ) -> *mut dc_msg::dc_msg_t<'a> { assert!(!context.is_null()); diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 215e4d5d7..3d8359ac1 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -1,46 +1,24 @@ use std::ffi::{CStr, CString}; -use std::sync::{Arc, RwLock}; use deltachat::constants::*; -use deltachat::dc_aheader::*; +use deltachat::context::*; use deltachat::dc_array::*; use deltachat::dc_chat::*; use deltachat::dc_chatlist::*; use deltachat::dc_configure::*; use deltachat::dc_contact::*; -use deltachat::dc_context::*; -use deltachat::dc_dehtml::*; -use deltachat::dc_e2ee::*; -use deltachat::dc_imap::*; use deltachat::dc_imex::*; use deltachat::dc_job::*; -use deltachat::dc_jobthread::*; -use deltachat::dc_key::*; -use deltachat::dc_keyhistory::*; -use deltachat::dc_keyring::*; use deltachat::dc_location::*; use deltachat::dc_log::*; -use deltachat::dc_loginparam::*; use deltachat::dc_lot::*; -use deltachat::dc_mimefactory::*; -use deltachat::dc_mimeparser::*; -use deltachat::dc_move::*; use deltachat::dc_msg::*; -use deltachat::dc_param::*; -use deltachat::dc_pgp::*; use deltachat::dc_qr::*; use deltachat::dc_receive_imf::*; -use deltachat::dc_saxparser::*; use deltachat::dc_securejoin::*; -use deltachat::dc_simplify::*; -use deltachat::dc_smtp::*; use deltachat::dc_sqlite3::*; -use deltachat::dc_stock::*; use deltachat::dc_strbuilder::*; -use deltachat::dc_strencode::*; -use deltachat::dc_token::*; use deltachat::dc_tools::*; -use deltachat::oauth2::*; use deltachat::peerstate::*; use deltachat::types::*; use deltachat::x::*; @@ -53,7 +31,7 @@ use num_traits::FromPrimitive; * * e.g. bitmask 7 triggers actions definded with bits 1, 2 and 4. */ -pub unsafe fn dc_reset_tables(context: &dc_context_t, bits: libc::c_int) -> libc::c_int { +pub unsafe fn dc_reset_tables(context: &Context, bits: libc::c_int) -> libc::c_int { dc_log_info( context, 0i32, @@ -142,7 +120,7 @@ pub unsafe fn dc_reset_tables(context: &dc_context_t, bits: libc::c_int) -> libc ); return 1i32; } -unsafe fn dc_poke_eml_file(context: &dc_context_t, filename: *const libc::c_char) -> libc::c_int { +unsafe fn dc_poke_eml_file(context: &Context, filename: *const libc::c_char) -> libc::c_int { /* mainly for testing, may be called by dc_import_spec() */ let mut success: libc::c_int = 0i32; let mut data: *mut libc::c_char = 0 as *mut libc::c_char; @@ -172,12 +150,12 @@ unsafe fn dc_poke_eml_file(context: &dc_context_t, filename: *const libc::c_char * For testing, import a folder with eml-files, a single eml-file, e-mail plus public key and so on. * For normal importing, use dc_imex(). * - * @private @memberof dc_context_t + * @private @memberof Context * @param context The context as created by dc_context_new(). * @param spec The file or directory to import. NULL for the last command. * @return 1=success, 0=error. */ -unsafe fn poke_spec(context: &dc_context_t, spec: *const libc::c_char) -> libc::c_int { +unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int { let mut current_block: u64; let mut success: libc::c_int = 0i32; let mut real_spec: *mut libc::c_char = 0 as *mut libc::c_char; @@ -309,7 +287,7 @@ unsafe fn poke_spec(context: &dc_context_t, spec: *const libc::c_char) -> libc:: free(suffix as *mut libc::c_void); return success; } -unsafe fn log_msg(context: &dc_context_t, prefix: *const libc::c_char, msg: *mut dc_msg_t) { +unsafe fn log_msg(context: &Context, prefix: *const libc::c_char, msg: *mut dc_msg_t) { let contact: *mut dc_contact_t = dc_get_contact(context, dc_msg_get_from_id(msg)); let contact_name: *mut libc::c_char = dc_contact_get_name(contact); let contact_id: libc::c_int = dc_contact_get_id(contact) as libc::c_int; @@ -370,7 +348,7 @@ unsafe fn log_msg(context: &dc_context_t, prefix: *const libc::c_char, msg: *mut dc_contact_unref(contact); } -unsafe fn log_msglist(context: &dc_context_t, msglist: *mut dc_array_t) { +unsafe fn log_msglist(context: &Context, msglist: *mut dc_array_t) { let mut i: libc::c_int = 0; let cnt: libc::c_int = dc_array_get_cnt(msglist) as libc::c_int; let mut lines_out: libc::c_int = 0i32; @@ -403,7 +381,7 @@ unsafe fn log_msglist(context: &dc_context_t, msglist: *mut dc_array_t) { ); }; } -unsafe fn log_contactlist(context: &dc_context_t, contacts: *mut dc_array_t) { +unsafe fn log_contactlist(context: &Context, contacts: *mut dc_array_t) { let mut contact: *mut dc_contact_t; if !dc_array_search_id(contacts, 1i32 as uint32_t, 0 as *mut size_t) { dc_array_add_id(contacts, 1i32 as uint32_t); @@ -487,7 +465,7 @@ unsafe fn chat_prefix(chat: *const dc_chat_t) -> *const libc::c_char { }; } -pub unsafe fn dc_cmdline(context: &dc_context_t, cmdline: &str) -> *mut libc::c_char { +pub unsafe fn dc_cmdline(context: &Context, cmdline: &str) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 1i32 as *mut libc::c_char; let chat_id = *context.cmdline_sel_chat_id.read().unwrap(); diff --git a/examples/repl/main.rs b/examples/repl/main.rs index 0ae30285a..a358a5e24 100644 --- a/examples/repl/main.rs +++ b/examples/repl/main.rs @@ -6,7 +6,6 @@ //! all further options can be set using the set-command (type ? for help). #![allow( - unused_imports, mutable_transmutes, non_camel_case_types, non_snake_case, @@ -21,50 +20,16 @@ use std::io::{self, Write}; use std::sync::{Arc, RwLock}; use deltachat::constants::*; -use deltachat::dc_aheader::*; -use deltachat::dc_array::*; -use deltachat::dc_chat::*; -use deltachat::dc_chatlist::*; +use deltachat::context::*; use deltachat::dc_configure::*; -use deltachat::dc_contact::*; -use deltachat::dc_context::*; -use deltachat::dc_dehtml::*; -use deltachat::dc_e2ee::*; -use deltachat::dc_imap::*; -use deltachat::dc_imex::*; use deltachat::dc_job::*; -use deltachat::dc_jobthread::*; -use deltachat::dc_key::*; -use deltachat::dc_keyhistory::*; -use deltachat::dc_keyring::*; -use deltachat::dc_location::*; -use deltachat::dc_log::*; -use deltachat::dc_loginparam::*; -use deltachat::dc_lot::*; -use deltachat::dc_mimefactory::*; -use deltachat::dc_mimeparser::*; -use deltachat::dc_move::*; -use deltachat::dc_msg::*; -use deltachat::dc_param::*; -use deltachat::dc_pgp::*; -use deltachat::dc_qr::*; -use deltachat::dc_receive_imf::*; -use deltachat::dc_saxparser::*; use deltachat::dc_securejoin::*; -use deltachat::dc_simplify::*; -use deltachat::dc_smtp::*; -use deltachat::dc_sqlite3::*; -use deltachat::dc_stock::*; -use deltachat::dc_strbuilder::*; -use deltachat::dc_strencode::*; -use deltachat::dc_token::*; use deltachat::dc_tools::*; use deltachat::oauth2::*; -use deltachat::peerstate::*; use deltachat::types::*; use deltachat::x::*; -mod cmdline; +mod cmdline; use self::cmdline::*; /* ****************************************************************************** @@ -72,7 +37,7 @@ use self::cmdline::*; ******************************************************************************/ unsafe extern "C" fn receive_event( - _context: &dc_context_t, + _context: &Context, event: Event, data1: uintptr_t, data2: uintptr_t, @@ -211,7 +176,7 @@ unsafe extern "C" fn receive_event( static mut run_threads: libc::c_int = 0i32; unsafe fn start_threads( - c: Arc>, + c: Arc>, ) -> ( std::thread::JoinHandle<()>, std::thread::JoinHandle<()>, @@ -269,7 +234,7 @@ unsafe fn start_threads( } unsafe fn stop_threads( - context: &dc_context_t, + context: &Context, handles: Option<( std::thread::JoinHandle<()>, std::thread::JoinHandle<()>, diff --git a/examples/simple.rs b/examples/simple.rs index 183853bea..0070ccd50 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -6,18 +6,18 @@ use std::{thread, time}; use tempfile::tempdir; use deltachat::constants::Event; +use deltachat::context::*; use deltachat::dc_chat::*; use deltachat::dc_chatlist::*; use deltachat::dc_configure::*; use deltachat::dc_contact::*; -use deltachat::dc_context::*; use deltachat::dc_job::{ dc_perform_imap_fetch, dc_perform_imap_idle, dc_perform_imap_jobs, dc_perform_smtp_idle, dc_perform_smtp_jobs, }; use deltachat::dc_lot::*; -extern "C" fn cb(_ctx: &dc_context_t, event: Event, data1: usize, data2: usize) -> usize { +extern "C" fn cb(_ctx: &Context, event: Event, data1: usize, data2: usize) -> usize { println!("[{:?}]", event); match event { diff --git a/src/dc_aheader.rs b/src/aheader.rs similarity index 99% rename from src/dc_aheader.rs rename to src/aheader.rs index 97c69f996..180077a0a 100644 --- a/src/dc_aheader.rs +++ b/src/aheader.rs @@ -7,7 +7,7 @@ use mmime::mailimf_types::*; use crate::constants::*; use crate::dc_contact::*; -use crate::dc_key::*; +use crate::key::*; /// Possible values for encryption preference #[derive(PartialEq, Eq, Debug, Clone, Copy, FromPrimitive, ToPrimitive)] diff --git a/src/dc_context.rs b/src/context.rs similarity index 95% rename from src/dc_context.rs rename to src/context.rs index b99656390..fbeef72de 100644 --- a/src/dc_context.rs +++ b/src/context.rs @@ -4,26 +4,26 @@ use crate::constants::*; use crate::dc_array::*; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_imap::*; use crate::dc_job::*; use crate::dc_jobthread::*; -use crate::dc_key::*; use crate::dc_log::*; use crate::dc_loginparam::*; use crate::dc_lot::dc_lot_t; use crate::dc_move::*; use crate::dc_msg::*; use crate::dc_receive_imf::*; -use crate::dc_smtp::*; use crate::dc_sqlite3::*; use crate::dc_stock::*; use crate::dc_strbuilder::*; use crate::dc_tools::*; +use crate::imap::*; +use crate::key::*; +use crate::smtp::*; use crate::types::*; use crate::x::*; #[repr(C)] -pub struct dc_context_t { +pub struct Context { pub userdata: *mut libc::c_void, pub dbfile: Arc>, pub blobdir: Arc>, @@ -44,8 +44,8 @@ pub struct dc_context_t { pub running_state: Arc>, } -unsafe impl std::marker::Send for dc_context_t {} -unsafe impl std::marker::Sync for dc_context_t {} +unsafe impl std::marker::Send for Context {} +unsafe impl std::marker::Sync for Context {} #[derive(Debug)] pub struct RunningState { @@ -53,7 +53,7 @@ pub struct RunningState { pub shall_stop_ongoing: bool, } -impl dc_context_t { +impl Context { pub fn has_dbfile(&self) -> bool { !self.get_dbfile().is_null() } @@ -127,8 +127,8 @@ pub fn dc_context_new( cb: dc_callback_t, userdata: *mut libc::c_void, os_name: *const libc::c_char, -) -> dc_context_t { - dc_context_t { +) -> Context { + Context { blobdir: Arc::new(RwLock::new(std::ptr::null_mut())), dbfile: Arc::new(RwLock::new(std::ptr::null_mut())), inbox: Arc::new(RwLock::new({ @@ -180,7 +180,7 @@ pub fn dc_context_new( } unsafe fn cb_receive_imf( - context: &dc_context_t, + context: &Context, imf_raw_not_terminated: *const libc::c_char, imf_raw_bytes: size_t, server_folder: *const libc::c_char, @@ -198,7 +198,7 @@ unsafe fn cb_receive_imf( } unsafe fn cb_precheck_imf( - context: &dc_context_t, + context: &Context, rfc724_mid: *const libc::c_char, server_folder: *const libc::c_char, server_uid: uint32_t, @@ -253,11 +253,7 @@ unsafe fn cb_precheck_imf( return rfc724_mid_exists; } -unsafe fn cb_set_config( - context: &dc_context_t, - key: *const libc::c_char, - value: *const libc::c_char, -) { +unsafe fn cb_set_config(context: &Context, key: *const libc::c_char, value: *const libc::c_char) { dc_sqlite3_set_config(context, &context.sql.clone().read().unwrap(), key, value); } @@ -266,17 +262,17 @@ unsafe fn cb_set_config( * and to handle received messages. As the imap-functions are typically used in * a separate user-thread, also these functions may be called from a different thread. * - * @private @memberof dc_context_t + * @private @memberof Context */ unsafe fn cb_get_config( - context: &dc_context_t, + context: &Context, key: *const libc::c_char, def: *const libc::c_char, ) -> *mut libc::c_char { dc_sqlite3_get_config(context, &context.sql.clone().read().unwrap(), key, def) } -pub unsafe fn dc_context_unref(context: &mut dc_context_t) { +pub unsafe fn dc_context_unref(context: &mut Context) { if 0 != dc_is_open(context) { dc_close(context); } @@ -288,7 +284,7 @@ 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: &dc_context_t) { +pub unsafe fn dc_close(context: &Context) { context.inbox.read().unwrap().disconnect(context); context .sentbox_thread @@ -316,16 +312,16 @@ pub unsafe fn dc_close(context: &dc_context_t) { *blobdir = 0 as *mut libc::c_char; } -pub unsafe fn dc_is_open(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_is_open(context: &Context) -> libc::c_int { dc_sqlite3_is_open(&context.sql.clone().read().unwrap()) } -pub unsafe fn dc_get_userdata(context: &mut dc_context_t) -> *mut libc::c_void { +pub unsafe fn dc_get_userdata(context: &mut Context) -> *mut libc::c_void { context.userdata as *mut _ } pub unsafe fn dc_open( - context: &dc_context_t, + context: &Context, dbfile: *const libc::c_char, blobdir: *const libc::c_char, ) -> libc::c_int { @@ -355,12 +351,12 @@ pub unsafe fn dc_open( success } -pub unsafe fn dc_get_blobdir(context: &dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_get_blobdir(context: &Context) -> *mut libc::c_char { dc_strdup(*context.blobdir.clone().read().unwrap()) } pub unsafe fn dc_set_config( - context: &dc_context_t, + context: &Context, key: *const libc::c_char, value: *const libc::c_char, ) -> libc::c_int { @@ -463,7 +459,7 @@ static mut config_keys: [*const libc::c_char; 33] = [ b"configured\x00" as *const u8 as *const libc::c_char, ]; -pub unsafe fn dc_get_config(context: &dc_context_t, key: *const libc::c_char) -> *mut libc::c_char { +pub unsafe fn dc_get_config(context: &Context, key: *const libc::c_char) -> *mut libc::c_char { let mut value = 0 as *mut libc::c_char; if !key.is_null() && *key.offset(0isize) as libc::c_int == 's' as i32 @@ -610,7 +606,7 @@ unsafe fn get_config_keys_str() -> *mut libc::c_char { ret.buf } -pub unsafe fn dc_get_info(context: &dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char { let unset = b"0\x00" as *const u8 as *const libc::c_char; let displayname; let temp; @@ -852,7 +848,7 @@ pub unsafe fn dc_get_version_str() -> *mut libc::c_char { dc_strdup(VERSION as *const u8 as *const libc::c_char) } -pub unsafe fn dc_get_fresh_msgs(context: &dc_context_t) -> *mut dc_array_t { +pub unsafe fn dc_get_fresh_msgs(context: &Context) -> *mut dc_array_t { let show_deaddrop = 0; let ret = dc_array_new(128 as size_t); let mut stmt = 0 as *mut sqlite3_stmt; @@ -880,7 +876,7 @@ pub unsafe fn dc_get_fresh_msgs(context: &dc_context_t) -> *mut dc_array_t { } pub unsafe fn dc_search_msgs( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, query: *const libc::c_char, ) -> *mut dc_array_t { @@ -951,10 +947,7 @@ pub unsafe fn dc_search_msgs( } } -pub unsafe fn dc_is_inbox( - _context: &dc_context_t, - folder_name: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_is_inbox(_context: &Context, folder_name: *const libc::c_char) -> libc::c_int { let mut is_inbox = 0; if !folder_name.is_null() { is_inbox = if strcasecmp( @@ -970,10 +963,7 @@ pub unsafe fn dc_is_inbox( is_inbox } -pub unsafe fn dc_is_sentbox( - context: &dc_context_t, - folder_name: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_is_sentbox(context: &Context, folder_name: *const libc::c_char) -> libc::c_int { let sentbox_name = dc_sqlite3_get_config( context, &context.sql.clone().read().unwrap(), @@ -992,7 +982,7 @@ pub unsafe fn dc_is_sentbox( is_sentbox } -pub unsafe fn dc_is_mvbox(context: &dc_context_t, folder_name: *const libc::c_char) -> libc::c_int { +pub unsafe fn dc_is_mvbox(context: &Context, folder_name: *const libc::c_char) -> libc::c_int { let mvbox_name = dc_sqlite3_get_config( context, &context.sql.clone().read().unwrap(), diff --git a/src/dc_array.rs b/src/dc_array.rs index 442d88def..f3b6c5e01 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -1,4 +1,4 @@ -use crate::dc_context::*; +use crate::context::*; use crate::dc_tools::*; use crate::types::*; use crate::x::*; diff --git a/src/dc_chat.rs b/src/dc_chat.rs index 125cb4811..07bfb3c81 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -1,8 +1,8 @@ use crate::constants::*; +use crate::context::Context; use crate::dc_array::*; use crate::dc_chatlist::*; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_job::*; use crate::dc_log::*; use crate::dc_msg::*; @@ -23,7 +23,7 @@ pub struct dc_chat_t<'a> { pub type_0: libc::c_int, pub name: *mut libc::c_char, pub archived: libc::c_int, - pub context: &'a dc_context_t, + pub context: &'a Context, pub grpid: *mut libc::c_char, pub blocked: libc::c_int, pub param: *mut dc_param_t, @@ -32,7 +32,7 @@ pub struct dc_chat_t<'a> { } // handle chats -pub unsafe fn dc_create_chat_by_msg_id(context: &dc_context_t, msg_id: uint32_t) -> uint32_t { +pub unsafe fn dc_create_chat_by_msg_id(context: &Context, msg_id: uint32_t) -> uint32_t { let mut chat_id: uint32_t = 0i32 as uint32_t; let mut send_event: libc::c_int = 0i32; let msg: *mut dc_msg_t = dc_msg_new_untyped(context); @@ -77,7 +77,7 @@ pub unsafe fn dc_create_chat_by_msg_id(context: &dc_context_t, msg_id: uint32_t) // only an indicator in a chatlist // only an indicator in a chatlist // larger chat IDs are "real" chats, their messages are "real" messages. -pub unsafe fn dc_chat_new<'a>(context: &'a dc_context_t) -> *mut dc_chat_t<'a> { +pub unsafe fn dc_chat_new<'a>(context: &'a Context) -> *mut dc_chat_t<'a> { let mut chat: *mut dc_chat_t; chat = calloc(1, ::std::mem::size_of::()) as *mut dc_chat_t; (*chat).magic = 0xc4a7c4a7u32; @@ -112,11 +112,11 @@ pub unsafe fn dc_chat_empty(mut chat: *mut dc_chat_t) { dc_param_set_packed((*chat).param, 0 as *const libc::c_char); } -pub unsafe fn dc_unblock_chat(context: &dc_context_t, chat_id: uint32_t) { +pub unsafe fn dc_unblock_chat(context: &Context, chat_id: uint32_t) { dc_block_chat(context, chat_id, 0i32); } -pub unsafe fn dc_block_chat(context: &dc_context_t, chat_id: uint32_t, new_blocking: libc::c_int) { +pub unsafe fn dc_block_chat(context: &Context, chat_id: uint32_t, new_blocking: libc::c_int) { let stmt: *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( context, @@ -212,10 +212,7 @@ unsafe fn set_from_stmt(mut chat: *mut dc_chat_t, row: *mut sqlite3_stmt) -> lib row_offset } -pub unsafe fn dc_create_chat_by_contact_id( - context: &dc_context_t, - contact_id: uint32_t, -) -> uint32_t { +pub unsafe fn dc_create_chat_by_contact_id(context: &Context, contact_id: uint32_t) -> uint32_t { let mut chat_id: uint32_t = 0i32 as uint32_t; let mut chat_blocked: libc::c_int = 0i32; let mut send_event: libc::c_int = 0i32; @@ -258,7 +255,7 @@ pub unsafe fn dc_create_chat_by_contact_id( } pub unsafe fn dc_create_or_lookup_nchat_by_contact_id( - context: &dc_context_t, + context: &Context, contact_id: uint32_t, create_blocked: libc::c_int, ret_chat_id: *mut uint32_t, @@ -365,7 +362,7 @@ pub unsafe fn dc_create_or_lookup_nchat_by_contact_id( } pub unsafe fn dc_lookup_real_nchat_by_contact_id( - context: &dc_context_t, + context: &Context, contact_id: uint32_t, ret_chat_id: *mut uint32_t, ret_chat_blocked: *mut libc::c_int, @@ -399,10 +396,7 @@ pub unsafe fn dc_lookup_real_nchat_by_contact_id( sqlite3_finalize(stmt); } -pub unsafe fn dc_get_chat_id_by_contact_id( - context: &dc_context_t, - contact_id: uint32_t, -) -> uint32_t { +pub unsafe fn dc_get_chat_id_by_contact_id(context: &Context, contact_id: uint32_t) -> uint32_t { let mut chat_id: uint32_t = 0i32 as uint32_t; let mut chat_id_blocked: libc::c_int = 0i32; dc_lookup_real_nchat_by_contact_id(context, contact_id, &mut chat_id, &mut chat_id_blocked); @@ -414,7 +408,7 @@ pub unsafe fn dc_get_chat_id_by_contact_id( } pub unsafe fn dc_prepare_msg<'a>( - context: &'a dc_context_t, + context: &'a Context, chat_id: uint32_t, mut msg: *mut dc_msg_t<'a>, ) -> uint32_t { @@ -433,7 +427,7 @@ pub unsafe fn dc_prepare_msg<'a>( } unsafe fn prepare_msg_common<'a>( - context: &'a dc_context_t, + context: &'a Context, chat_id: uint32_t, mut msg: *mut dc_msg_t<'a>, ) -> uint32_t { @@ -533,7 +527,7 @@ unsafe fn prepare_msg_common<'a>( } unsafe fn prepare_msg_raw( - context: &dc_context_t, + context: &Context, chat: *mut dc_chat_t, msg: *const dc_msg_t, timestamp: time_t, @@ -920,7 +914,7 @@ pub unsafe fn dc_chat_is_self_talk(chat: *const dc_chat_t) -> libc::c_int { ******************************************************************************/ // TODO should return bool /rtn unsafe fn last_msg_in_chat_encrypted( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, chat_id: uint32_t, ) -> libc::c_int { @@ -966,7 +960,7 @@ pub unsafe fn dc_chat_update_param(chat: *mut dc_chat_t) -> libc::c_int { } pub unsafe fn dc_is_contact_in_chat( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, ) -> libc::c_int { @@ -993,7 +987,7 @@ pub unsafe fn dc_is_contact_in_chat( ret } -pub unsafe fn dc_unarchive_chat(context: &dc_context_t, chat_id: uint32_t) { +pub unsafe fn dc_unarchive_chat(context: &Context, chat_id: uint32_t) { let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -1005,7 +999,7 @@ pub unsafe fn dc_unarchive_chat(context: &dc_context_t, chat_id: uint32_t) { } pub unsafe fn dc_send_msg<'a>( - context: &'a dc_context_t, + context: &'a Context, chat_id: uint32_t, msg: *mut dc_msg_t<'a>, ) -> uint32_t { @@ -1064,7 +1058,7 @@ pub unsafe fn dc_send_msg<'a>( } pub unsafe fn dc_send_text_msg( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, text_to_send: *const libc::c_char, ) -> uint32_t { @@ -1078,7 +1072,7 @@ pub unsafe fn dc_send_text_msg( ret } -pub unsafe fn dc_set_draft(context: &dc_context_t, chat_id: uint32_t, msg: *mut dc_msg_t) { +pub unsafe fn dc_set_draft(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t) { if chat_id <= 9i32 as libc::c_uint { return; } @@ -1093,11 +1087,7 @@ pub unsafe fn dc_set_draft(context: &dc_context_t, chat_id: uint32_t, msg: *mut } // TODO should return bool /rtn -unsafe fn set_draft_raw( - context: &dc_context_t, - chat_id: uint32_t, - msg: *mut dc_msg_t, -) -> libc::c_int { +unsafe fn set_draft_raw(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t) -> libc::c_int { let current_block: u64; // similar to as dc_set_draft() but does not emit an event let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; @@ -1178,7 +1168,7 @@ unsafe fn set_draft_raw( sth_changed } -unsafe fn get_draft_msg_id(context: &dc_context_t, chat_id: uint32_t) -> uint32_t { +unsafe fn get_draft_msg_id(context: &Context, chat_id: uint32_t) -> uint32_t { let mut draft_msg_id: uint32_t = 0i32 as uint32_t; let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, @@ -1194,7 +1184,7 @@ unsafe fn get_draft_msg_id(context: &dc_context_t, chat_id: uint32_t) -> uint32_ draft_msg_id } -pub unsafe fn dc_get_draft(context: &dc_context_t, chat_id: uint32_t) -> *mut dc_msg_t { +pub unsafe fn dc_get_draft(context: &Context, chat_id: uint32_t) -> *mut dc_msg_t { let draft_msg_id: uint32_t; let draft_msg: *mut dc_msg_t; if chat_id <= 9i32 as libc::c_uint { @@ -1214,7 +1204,7 @@ pub unsafe fn dc_get_draft(context: &dc_context_t, chat_id: uint32_t) -> *mut dc } pub unsafe fn dc_get_chat_msgs( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, flags: uint32_t, marker1before: uint32_t, @@ -1284,7 +1274,7 @@ pub unsafe fn dc_get_chat_msgs( }; } -pub unsafe fn dc_get_msg_cnt(context: &dc_context_t, chat_id: uint32_t) -> libc::c_int { +pub unsafe fn dc_get_msg_cnt(context: &Context, chat_id: uint32_t) -> libc::c_int { let mut ret: libc::c_int = 0i32; let stmt: *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( @@ -1301,7 +1291,7 @@ pub unsafe fn dc_get_msg_cnt(context: &dc_context_t, chat_id: uint32_t) -> libc: ret } -pub unsafe fn dc_get_fresh_msg_cnt(context: &dc_context_t, chat_id: uint32_t) -> libc::c_int { +pub unsafe fn dc_get_fresh_msg_cnt(context: &Context, chat_id: uint32_t) -> libc::c_int { let mut ret: libc::c_int = 0i32; let stmt: *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( @@ -1318,7 +1308,7 @@ pub unsafe fn dc_get_fresh_msg_cnt(context: &dc_context_t, chat_id: uint32_t) -> ret } -pub unsafe fn dc_marknoticed_chat(context: &dc_context_t, chat_id: uint32_t) { +pub unsafe fn dc_marknoticed_chat(context: &Context, chat_id: uint32_t) { let check: *mut sqlite3_stmt; let mut update: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; @@ -1350,7 +1340,7 @@ pub unsafe fn dc_marknoticed_chat(context: &dc_context_t, chat_id: uint32_t) { sqlite3_finalize(update); } -pub unsafe fn dc_marknoticed_all_chats(context: &dc_context_t) { +pub unsafe fn dc_marknoticed_all_chats(context: &Context) { let check: *mut sqlite3_stmt; let mut update: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; @@ -1379,7 +1369,7 @@ pub unsafe fn dc_marknoticed_all_chats(context: &dc_context_t) { } pub unsafe fn dc_get_chat_media( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, msg_type: libc::c_int, msg_type2: libc::c_int, @@ -1419,7 +1409,7 @@ pub unsafe fn dc_get_chat_media( } pub unsafe fn dc_get_next_media( - context: &dc_context_t, + context: &Context, curr_msg_id: uint32_t, dir: libc::c_int, msg_type: libc::c_int, @@ -1471,7 +1461,7 @@ pub unsafe fn dc_get_next_media( ret_msg_id } -pub unsafe fn dc_archive_chat(context: &dc_context_t, chat_id: uint32_t, archive: libc::c_int) { +pub unsafe fn dc_archive_chat(context: &Context, chat_id: uint32_t, archive: libc::c_int) { if chat_id <= 9i32 as libc::c_uint || archive != 0i32 && archive != 1i32 { return; } @@ -1503,7 +1493,7 @@ pub unsafe fn dc_archive_chat(context: &dc_context_t, chat_id: uint32_t, archive ); } -pub unsafe fn dc_delete_chat(context: &dc_context_t, chat_id: uint32_t) { +pub unsafe fn dc_delete_chat(context: &Context, chat_id: uint32_t) { /* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */ let obj: *mut dc_chat_t = dc_chat_new(context); let mut q3: *mut libc::c_char = 0 as *mut libc::c_char; @@ -1562,7 +1552,7 @@ pub unsafe fn dc_delete_chat(context: &dc_context_t, chat_id: uint32_t) { sqlite3_free(q3 as *mut libc::c_void); } -pub unsafe fn dc_get_chat_contacts(context: &dc_context_t, chat_id: uint32_t) -> *mut dc_array_t { +pub unsafe fn dc_get_chat_contacts(context: &Context, chat_id: uint32_t) -> *mut dc_array_t { /* Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a groupchat but the chats stays visible, moreover, this makes displaying lists easier) */ let ret: *mut dc_array_t = dc_array_new(100i32 as size_t); @@ -1585,7 +1575,7 @@ pub unsafe fn dc_get_chat_contacts(context: &dc_context_t, chat_id: uint32_t) -> ret } -pub unsafe fn dc_get_chat(context: &dc_context_t, chat_id: uint32_t) -> *mut dc_chat_t { +pub unsafe fn dc_get_chat(context: &Context, chat_id: uint32_t) -> *mut dc_chat_t { let mut success: libc::c_int = 0i32; let obj: *mut dc_chat_t = dc_chat_new(context); @@ -1603,7 +1593,7 @@ pub unsafe fn dc_get_chat(context: &dc_context_t, chat_id: uint32_t) -> *mut dc_ // handle group chats pub unsafe fn dc_create_group_chat( - context: &dc_context_t, + context: &Context, verified: libc::c_int, chat_name: *const libc::c_char, ) -> uint32_t { @@ -1662,7 +1652,7 @@ pub unsafe fn dc_create_group_chat( // Context functions to work with chats // TODO should return bool /rtn pub unsafe fn dc_add_to_chat_contacts_table( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, ) -> libc::c_int { @@ -1686,7 +1676,7 @@ pub unsafe fn dc_add_to_chat_contacts_table( } pub unsafe fn dc_add_contact_to_chat( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, ) -> libc::c_int { @@ -1695,7 +1685,7 @@ pub unsafe fn dc_add_contact_to_chat( // TODO should return bool /rtn pub unsafe fn dc_add_contact_to_chat_ex( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, flags: libc::c_int, @@ -1816,7 +1806,7 @@ pub unsafe fn dc_add_contact_to_chat_ex( } // TODO should return bool /rtn -unsafe fn real_group_exists(context: &dc_context_t, chat_id: uint32_t) -> libc::c_int { +unsafe fn real_group_exists(context: &Context, chat_id: uint32_t) -> libc::c_int { // check if a group or a verified group exists under the given ID let stmt: *mut sqlite3_stmt; let mut ret: libc::c_int = 0i32; @@ -1837,15 +1827,11 @@ unsafe fn real_group_exists(context: &dc_context_t, chat_id: uint32_t) -> libc:: ret } -pub unsafe fn dc_reset_gossiped_timestamp(context: &dc_context_t, chat_id: uint32_t) { +pub unsafe fn dc_reset_gossiped_timestamp(context: &Context, chat_id: uint32_t) { dc_set_gossiped_timestamp(context, chat_id, 0i32 as time_t); } -pub unsafe fn dc_set_gossiped_timestamp( - context: &dc_context_t, - chat_id: uint32_t, - timestamp: time_t, -) { +pub unsafe fn dc_set_gossiped_timestamp(context: &Context, chat_id: uint32_t, timestamp: time_t) { let stmt: *mut sqlite3_stmt; if 0 != chat_id { dc_log_info( @@ -1883,7 +1869,7 @@ pub unsafe fn dc_set_gossiped_timestamp( // TODO should return bool /rtn pub unsafe fn dc_remove_contact_from_chat( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, ) -> libc::c_int { @@ -1966,7 +1952,7 @@ pub unsafe fn dc_remove_contact_from_chat( success } -pub unsafe fn dc_set_group_explicitly_left(context: &dc_context_t, grpid: *const libc::c_char) { +pub unsafe fn dc_set_group_explicitly_left(context: &Context, grpid: *const libc::c_char) { if 0 == dc_is_group_explicitly_left(context, grpid) { let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, @@ -1981,7 +1967,7 @@ pub unsafe fn dc_set_group_explicitly_left(context: &dc_context_t, grpid: *const // TODO should return bool /rtn pub unsafe fn dc_is_group_explicitly_left( - context: &dc_context_t, + context: &Context, grpid: *const libc::c_char, ) -> libc::c_int { let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( @@ -1997,7 +1983,7 @@ pub unsafe fn dc_is_group_explicitly_left( // TODO should return bool /rtn pub unsafe fn dc_set_chat_name( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, new_name: *const libc::c_char, ) -> libc::c_int { @@ -2070,7 +2056,7 @@ pub unsafe fn dc_set_chat_name( // TODO should return bool /rtn pub unsafe fn dc_set_chat_profile_image( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, new_image: *const libc::c_char, ) -> libc::c_int { @@ -2151,7 +2137,7 @@ pub unsafe fn dc_set_chat_profile_image( } pub unsafe fn dc_forward_msgs( - context: &dc_context_t, + context: &Context, msg_ids: *const uint32_t, msg_cnt: libc::c_int, chat_id: uint32_t, @@ -2315,7 +2301,7 @@ pub unsafe fn dc_chat_get_subtitle(chat: *const dc_chat_t) -> *mut libc::c_char }; } -pub unsafe fn dc_get_chat_contact_cnt(context: &dc_context_t, chat_id: uint32_t) -> libc::c_int { +pub unsafe fn dc_get_chat_contact_cnt(context: &Context, chat_id: uint32_t) -> libc::c_int { let mut ret: libc::c_int = 0i32; let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, @@ -2416,7 +2402,7 @@ pub unsafe fn dc_chat_is_sending_locations(chat: *const dc_chat_t) -> libc::c_in (*chat).is_sending_locations } -pub unsafe fn dc_get_chat_cnt(context: &dc_context_t) -> size_t { +pub unsafe fn dc_get_chat_cnt(context: &Context) -> size_t { let mut ret: size_t = 0i32 as size_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(*context.sql.clone().read().unwrap()).cobj.is_null() { @@ -2436,7 +2422,7 @@ pub unsafe fn dc_get_chat_cnt(context: &dc_context_t) -> size_t { } pub unsafe fn dc_get_chat_id_by_grpid( - context: &dc_context_t, + context: &Context, grpid: *const libc::c_char, ret_blocked: *mut libc::c_int, ret_verified: *mut libc::c_int, @@ -2471,11 +2457,7 @@ pub unsafe fn dc_get_chat_id_by_grpid( chat_id } -pub unsafe fn dc_add_device_msg( - context: &dc_context_t, - chat_id: uint32_t, - text: *const libc::c_char, -) { +pub unsafe fn dc_add_device_msg(context: &Context, chat_id: uint32_t, text: *const libc::c_char) { let msg_id: uint32_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let rfc724_mid: *mut libc::c_char = dc_create_outgoing_rfc724_mid( diff --git a/src/dc_chatlist.rs b/src/dc_chatlist.rs index b1761e885..0332bb9e7 100644 --- a/src/dc_chatlist.rs +++ b/src/dc_chatlist.rs @@ -1,7 +1,7 @@ +use crate::context::*; use crate::dc_array::*; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_context::*; use crate::dc_lot::*; use crate::dc_msg::*; use crate::dc_sqlite3::*; @@ -15,14 +15,14 @@ use crate::x::*; #[repr(C)] pub struct dc_chatlist_t<'a> { pub magic: uint32_t, - pub context: &'a dc_context_t, + pub context: &'a Context, pub cnt: size_t, pub chatNlastmsg_ids: *mut dc_array_t, } // handle chatlists pub unsafe fn dc_get_chatlist<'a>( - context: &'a dc_context_t, + context: &'a Context, listflags: libc::c_int, query_str: *const libc::c_char, query_id: uint32_t, @@ -80,7 +80,7 @@ pub unsafe fn dc_get_chatlist<'a>( * Rendering the deaddrop in the described way * would not add extra work in the UI then. */ -pub unsafe fn dc_chatlist_new(context: &dc_context_t) -> *mut dc_chatlist_t { +pub unsafe fn dc_chatlist_new(context: &Context) -> *mut dc_chatlist_t { let mut chatlist: *mut dc_chatlist_t; chatlist = calloc(1, ::std::mem::size_of::()) as *mut dc_chatlist_t; if chatlist.is_null() { @@ -233,7 +233,7 @@ unsafe fn dc_chatlist_load_from_db( } // Context functions to work with chatlist -pub unsafe fn dc_get_archived_cnt(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_get_archived_cnt(context: &Context) -> libc::c_int { let mut ret: libc::c_int = 0i32; let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, @@ -248,7 +248,7 @@ pub unsafe fn dc_get_archived_cnt(context: &dc_context_t) -> libc::c_int { ret } -unsafe fn get_last_deaddrop_fresh_msg(context: &dc_context_t) -> uint32_t { +unsafe fn get_last_deaddrop_fresh_msg(context: &Context) -> uint32_t { let mut ret: uint32_t = 0i32 as uint32_t; let stmt: *mut sqlite3_stmt; stmt = diff --git a/src/dc_configure.rs b/src/dc_configure.rs index 1765bd79f..f0aeccdff 100644 --- a/src/dc_configure.rs +++ b/src/dc_configure.rs @@ -1,7 +1,6 @@ use crate::constants::Event; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_e2ee::*; -use crate::dc_imap::*; use crate::dc_job::*; use crate::dc_log::*; use crate::dc_loginparam::*; @@ -9,6 +8,7 @@ use crate::dc_saxparser::*; use crate::dc_sqlite3::*; use crate::dc_strencode::*; use crate::dc_tools::*; +use crate::imap::*; use crate::oauth2::*; use crate::types::*; use crate::x::*; @@ -55,7 +55,7 @@ pub struct outlk_autodiscover_t { pub redirect: *mut libc::c_char, } // connect -pub unsafe fn dc_configure(context: &dc_context_t) { +pub unsafe fn dc_configure(context: &Context) { if 0 != dc_has_ongoing(context) { dc_log_warning( context, @@ -68,7 +68,7 @@ pub unsafe fn dc_configure(context: &dc_context_t) { dc_job_kill_action(context, 900i32); dc_job_add(context, 900i32, 0i32, 0 as *const libc::c_char, 0i32); } -pub unsafe fn dc_has_ongoing(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_has_ongoing(context: &Context) -> libc::c_int { let s_a = context.running_state.clone(); let s = s_a.read().unwrap(); @@ -78,7 +78,7 @@ pub unsafe fn dc_has_ongoing(context: &dc_context_t) -> libc::c_int { 0 } } -pub unsafe fn dc_is_configured(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_is_configured(context: &Context) -> libc::c_int { return if 0 != dc_sqlite3_get_config_int( context, @@ -91,7 +91,7 @@ pub unsafe fn dc_is_configured(context: &dc_context_t) -> libc::c_int { 0i32 }; } -pub unsafe fn dc_stop_ongoing_process(context: &dc_context_t) { +pub unsafe fn dc_stop_ongoing_process(context: &Context) { let s_a = context.running_state.clone(); let mut s = s_a.write().unwrap(); @@ -111,7 +111,7 @@ pub unsafe fn dc_stop_ongoing_process(context: &dc_context_t) { }; } // the other dc_job_do_DC_JOB_*() functions are declared static in the c-file -pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _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 mut current_block: u64; let mut success: libc::c_int = 0i32; @@ -1295,7 +1295,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &dc_context_t, _job: *mut ); } -pub unsafe fn dc_free_ongoing(context: &dc_context_t) { +pub unsafe fn dc_free_ongoing(context: &Context) { let s_a = context.running_state.clone(); let mut s = s_a.write().unwrap(); @@ -1304,7 +1304,7 @@ pub unsafe fn dc_free_ongoing(context: &dc_context_t) { } unsafe fn moz_autoconfigure( - context: &dc_context_t, + context: &Context, url: *const libc::c_char, param_in: *const dc_loginparam_t, ) -> *mut dc_loginparam_t { @@ -1522,7 +1522,7 @@ unsafe fn moz_autoconfigure_starttag_cb( }; } -fn read_autoconf_file(context: &dc_context_t, url: *const libc::c_char) -> *mut libc::c_char { +fn read_autoconf_file(context: &Context, url: *const libc::c_char) -> *mut libc::c_char { info!(context, 0, "Testing %s ...", url); match reqwest::Client::new() @@ -1540,7 +1540,7 @@ fn read_autoconf_file(context: &dc_context_t, url: *const libc::c_char) -> *mut } unsafe fn outlk_autodiscover( - context: &dc_context_t, + context: &Context, url__: *const libc::c_char, param_in: *const dc_loginparam_t, ) -> *mut dc_loginparam_t { @@ -1719,7 +1719,7 @@ unsafe fn outlk_autodiscover_starttag_cb( (*outlk_ad).tag_config = 5i32 }; } -pub unsafe fn dc_alloc_ongoing(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_alloc_ongoing(context: &Context) -> libc::c_int { if 0 != dc_has_ongoing(context) { dc_log_warning( context, @@ -1738,7 +1738,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: &Imap) -> libc::c_int { +pub unsafe fn dc_connect_to_configured_imap(context: &Context, imap: &Imap) -> libc::c_int { let mut ret_connected: libc::c_int = 0i32; let param: *mut dc_loginparam_t = dc_loginparam_new(); if imap.is_connected() { diff --git a/src/dc_contact.rs b/src/dc_contact.rs index c26eeacd8..099dbf7be 100644 --- a/src/dc_contact.rs +++ b/src/dc_contact.rs @@ -1,16 +1,16 @@ +use crate::aheader::EncryptPreference; use crate::constants::Event; -use crate::dc_aheader::EncryptPreference; +use crate::context::Context; +use crate::context::*; use crate::dc_array::*; -use crate::dc_context::dc_context_t; -use crate::dc_context::*; use crate::dc_e2ee::*; -use crate::dc_key::*; use crate::dc_log::*; use crate::dc_loginparam::*; use crate::dc_sqlite3::*; use crate::dc_stock::*; use crate::dc_strbuilder::*; use crate::dc_tools::*; +use crate::key::*; use crate::peerstate::*; use crate::types::*; use crate::x::*; @@ -19,7 +19,7 @@ use crate::x::*; #[repr(C)] pub struct dc_contact_t<'a> { pub magic: uint32_t, - pub context: &'a dc_context_t, + pub context: &'a Context, pub id: uint32_t, pub name: *mut libc::c_char, pub authname: *mut libc::c_char, @@ -28,7 +28,7 @@ pub struct dc_contact_t<'a> { pub origin: libc::c_int, } -pub unsafe fn dc_marknoticed_contact(context: &dc_context_t, contact_id: uint32_t) { +pub unsafe fn dc_marknoticed_contact(context: &Context, contact_id: uint32_t) { let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -68,7 +68,7 @@ pub unsafe fn dc_may_be_valid_addr(addr: *const libc::c_char) -> bool { } pub unsafe fn dc_lookup_contact_id_by_addr( - context: &dc_context_t, + context: &Context, addr: *const libc::c_char, ) -> uint32_t { let mut contact_id: libc::c_int = 0i32; @@ -131,7 +131,7 @@ pub unsafe fn dc_addr_normalize(addr: *const libc::c_char) -> *mut libc::c_char } pub unsafe fn dc_create_contact( - context: &dc_context_t, + context: &Context, name: *const libc::c_char, addr: *const libc::c_char, ) -> uint32_t { @@ -159,11 +159,7 @@ pub unsafe fn dc_create_contact( contact_id } -pub unsafe fn dc_block_contact( - context: &dc_context_t, - contact_id: uint32_t, - new_blocking: libc::c_int, -) { +pub unsafe fn dc_block_contact(context: &Context, contact_id: uint32_t, new_blocking: libc::c_int) { let current_block: u64; let mut send_event: libc::c_int = 0i32; let contact: *mut dc_contact_t = dc_contact_new(context); @@ -241,7 +237,7 @@ pub unsafe fn dc_block_contact( * dc_create_contact() or dc_add_address_book()) * only affect the given-name. */ -pub unsafe fn dc_contact_new<'a>(context: &'a dc_context_t) -> *mut dc_contact_t<'a> { +pub unsafe fn dc_contact_new<'a>(context: &'a Context) -> *mut dc_contact_t<'a> { let mut contact: *mut dc_contact_t; contact = calloc(1, ::std::mem::size_of::()) as *mut dc_contact_t; if contact.is_null() { @@ -346,7 +342,7 @@ pub unsafe fn dc_contact_load_from_db( success } -pub unsafe fn dc_is_contact_blocked(context: &dc_context_t, contact_id: uint32_t) -> bool { +pub unsafe fn dc_is_contact_blocked(context: &Context, contact_id: uint32_t) -> bool { let mut is_blocked = false; let contact: *mut dc_contact_t = dc_contact_new(context); if dc_contact_load_from_db(contact, &context.sql.clone().read().unwrap(), contact_id) { @@ -361,7 +357,7 @@ pub unsafe fn dc_is_contact_blocked(context: &dc_context_t, contact_id: uint32_t /*can be NULL*/ pub unsafe fn dc_add_or_lookup_contact( - context: &dc_context_t, + context: &Context, name: *const libc::c_char, addr__: *const libc::c_char, origin: libc::c_int, @@ -548,10 +544,7 @@ pub unsafe fn dc_add_or_lookup_contact( row_id } -pub unsafe fn dc_add_address_book( - context: &dc_context_t, - adr_book: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_add_address_book(context: &Context, adr_book: *const libc::c_char) -> libc::c_int { let mut lines: *mut carray = 0 as *mut carray; let mut i: size_t; let iCnt: size_t; @@ -625,7 +618,7 @@ pub unsafe fn dc_normalize_name(full_name: *mut libc::c_char) { } pub unsafe fn dc_get_contacts( - context: &dc_context_t, + context: &Context, listflags: uint32_t, query: *const libc::c_char, ) -> *mut dc_array_t { @@ -725,7 +718,7 @@ pub unsafe fn dc_get_contacts( ret } -pub unsafe fn dc_get_blocked_cnt(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_get_blocked_cnt(context: &Context) -> libc::c_int { let mut ret: libc::c_int = 0i32; let stmt: *mut sqlite3_stmt; @@ -744,7 +737,7 @@ pub unsafe fn dc_get_blocked_cnt(context: &dc_context_t) -> libc::c_int { ret } -pub unsafe fn dc_get_blocked_contacts(context: &dc_context_t) -> *mut dc_array_t { +pub unsafe fn dc_get_blocked_contacts(context: &Context) -> *mut dc_array_t { let ret: *mut dc_array_t = dc_array_new(100i32 as size_t); let stmt: *mut sqlite3_stmt; @@ -764,7 +757,7 @@ pub unsafe fn dc_get_blocked_contacts(context: &dc_context_t) -> *mut dc_array_t } pub unsafe fn dc_get_contact_encrinfo( - context: &dc_context_t, + context: &Context, contact_id: uint32_t, ) -> *mut libc::c_char { let mut ret: dc_strbuilder_t; @@ -930,7 +923,7 @@ unsafe fn cat_fingerprint( }; } -pub unsafe fn dc_delete_contact(context: &dc_context_t, contact_id: uint32_t) -> bool { +pub unsafe fn dc_delete_contact(context: &Context, contact_id: uint32_t) -> bool { let mut success = false; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !(contact_id <= 9i32 as libc::c_uint) { @@ -976,7 +969,7 @@ pub unsafe fn dc_delete_contact(context: &dc_context_t, contact_id: uint32_t) -> success } -pub unsafe fn dc_get_contact(context: &dc_context_t, contact_id: uint32_t) -> *mut dc_contact_t { +pub unsafe fn dc_get_contact(context: &Context, contact_id: uint32_t) -> *mut dc_contact_t { let mut ret: *mut dc_contact_t = dc_contact_new(context); if !dc_contact_load_from_db(ret, &context.sql.clone().read().unwrap(), contact_id) { dc_contact_unref(ret); @@ -1153,10 +1146,7 @@ pub unsafe fn dc_addr_cmp(addr1: *const libc::c_char, addr2: *const libc::c_char ret } -pub unsafe fn dc_addr_equals_self( - context: &dc_context_t, - addr: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_addr_equals_self(context: &Context, addr: *const libc::c_char) -> libc::c_int { let mut ret: libc::c_int = 0i32; let mut normalized_addr: *mut libc::c_char = 0 as *mut libc::c_char; let mut self_addr: *mut libc::c_char = 0 as *mut libc::c_char; @@ -1182,7 +1172,7 @@ pub unsafe fn dc_addr_equals_self( } pub unsafe fn dc_addr_equals_contact( - context: &dc_context_t, + context: &Context, addr: *const libc::c_char, contact_id: uint32_t, ) -> bool { @@ -1204,7 +1194,7 @@ pub unsafe fn dc_addr_equals_contact( } // Context functions to work with contacts -pub unsafe fn dc_get_real_contact_cnt(context: &dc_context_t) -> size_t { +pub unsafe fn dc_get_real_contact_cnt(context: &Context) -> size_t { let mut ret: size_t = 0i32 as size_t; let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if !context.sql.clone().read().unwrap().cobj.is_null() { @@ -1223,7 +1213,7 @@ pub unsafe fn dc_get_real_contact_cnt(context: &dc_context_t) -> size_t { } pub unsafe fn dc_get_contact_origin( - context: &dc_context_t, + context: &Context, contact_id: uint32_t, mut ret_blocked: *mut libc::c_int, ) -> libc::c_int { @@ -1246,7 +1236,7 @@ pub unsafe fn dc_get_contact_origin( ret } -pub unsafe fn dc_real_contact_exists(context: &dc_context_t, contact_id: uint32_t) -> bool { +pub unsafe fn dc_real_contact_exists(context: &Context, contact_id: uint32_t) -> bool { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut ret = false; if !(context.sql.clone().read().unwrap().cobj.is_null() || contact_id <= 9i32 as libc::c_uint) { @@ -1265,7 +1255,7 @@ pub unsafe fn dc_real_contact_exists(context: &dc_context_t, contact_id: uint32_ } pub unsafe fn dc_scaleup_contact_origin( - context: &dc_context_t, + context: &Context, contact_id: uint32_t, origin: libc::c_int, ) { diff --git a/src/dc_e2ee.rs b/src/dc_e2ee.rs index 31bc9b753..47863a70a 100644 --- a/src/dc_e2ee.rs +++ b/src/dc_e2ee.rs @@ -15,17 +15,17 @@ use mmime::mailprivacy_prepare_mime; use mmime::mmapstring::*; use mmime::{mailmime_substitute, MAILIMF_NO_ERROR, MAIL_NO_ERROR}; -use crate::dc_aheader::*; -use crate::dc_context::dc_context_t; -use crate::dc_key::*; -use crate::dc_keyring::*; +use crate::aheader::*; +use crate::context::Context; use crate::dc_log::*; use crate::dc_mimeparser::*; -use crate::dc_pgp::*; use crate::dc_securejoin::*; use crate::dc_sqlite3::*; use crate::dc_tools::*; +use crate::key::*; +use crate::keyring::*; use crate::peerstate::*; +use crate::pgp::*; use crate::types::*; use crate::x::*; @@ -57,7 +57,7 @@ impl Default for dc_e2ee_helper_t { } pub unsafe fn dc_e2ee_encrypt( - context: &dc_context_t, + context: &Context, recipients_addr: *const clist, force_unencrypted: libc::c_int, e2ee_guaranteed: libc::c_int, @@ -506,7 +506,7 @@ unsafe fn new_data_part( * Generate Keypairs ******************************************************************************/ unsafe fn load_or_generate_self_public_key( - context: &dc_context_t, + context: &Context, self_addr: *const libc::c_char, _random_data_mime: *mut mailmime, ) -> Option { @@ -576,7 +576,7 @@ unsafe fn load_or_generate_self_public_key( /* returns 1 if sth. was decrypted, 0 in other cases */ pub unsafe fn dc_e2ee_decrypt( - context: &dc_context_t, + context: &Context, in_out_message: *mut mailmime, helper: &mut dc_e2ee_helper_t, ) { @@ -698,7 +698,7 @@ pub unsafe fn dc_e2ee_decrypt( } unsafe fn update_gossip_peerstates( - context: &dc_context_t, + context: &Context, message_time: time_t, imffields: *mut mailimf_fields, gossip_headers: *const mailimf_fields, @@ -776,7 +776,7 @@ unsafe fn update_gossip_peerstates( // TODO should return bool /rtn unsafe fn decrypt_recursive( - context: &dc_context_t, + context: &Context, mime: *mut mailmime, private_keyring: &Keyring, public_keyring_for_validate: &Keyring, @@ -883,7 +883,7 @@ unsafe fn decrypt_recursive( } unsafe fn decrypt_part( - _context: &dc_context_t, + _context: &Context, mime: *mut mailmime, private_keyring: &Keyring, public_keyring_for_validate: &Keyring, @@ -1114,7 +1114,7 @@ pub unsafe fn dc_e2ee_thanks(helper: &mut dc_e2ee_helper_t) { /* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */ // TODO should return bool /rtn -pub unsafe fn dc_ensure_secret_key_exists(context: &dc_context_t) -> libc::c_int { +pub unsafe fn dc_ensure_secret_key_exists(context: &Context) -> libc::c_int { /* normally, the key is generated as soon as the first mail is send (this is to gain some extra-random-seed by the message content and the timespan between program start and message sending) */ let mut success: libc::c_int = 0i32; diff --git a/src/dc_imex.rs b/src/dc_imex.rs index 0abb39df2..77d6b91bd 100644 --- a/src/dc_imex.rs +++ b/src/dc_imex.rs @@ -6,21 +6,21 @@ use mmime::other::*; use rand::{thread_rng, Rng}; use crate::constants::*; +use crate::context::Context; use crate::dc_chat::*; use crate::dc_configure::*; -use crate::dc_context::dc_context_t; use crate::dc_e2ee::*; use crate::dc_job::*; -use crate::dc_key::*; use crate::dc_log::*; use crate::dc_loginparam::*; use crate::dc_msg::*; use crate::dc_param::*; -use crate::dc_pgp::*; use crate::dc_sqlite3::*; use crate::dc_stock::*; use crate::dc_strbuilder::*; use crate::dc_tools::*; +use crate::key::*; +use crate::pgp::*; use crate::types::*; use crate::x::*; @@ -30,7 +30,7 @@ use crate::x::*; // param1 is a directory where the backup is written to // param1 is the file with the backup to import pub unsafe fn dc_imex( - context: &dc_context_t, + context: &Context, what: libc::c_int, param1: *const libc::c_char, param2: *const libc::c_char, @@ -45,7 +45,7 @@ pub unsafe fn dc_imex( } pub unsafe fn dc_imex_has_backup( - context: &dc_context_t, + context: &Context, dir_name: *const libc::c_char, ) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; @@ -124,10 +124,7 @@ pub unsafe fn dc_imex_has_backup( ret } -pub unsafe fn dc_check_password( - context: &dc_context_t, - test_pw: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_check_password(context: &Context, test_pw: *const libc::c_char) -> libc::c_int { /* Check if the given password matches the configured mail_pw. This is to prompt the user before starting eg. an export; this is mainly to avoid doing people bad thinkgs if they have short access to the device. When we start supporting OAuth some day, we should think this over, maybe force the user to re-authenticate himself with the Android password. */ @@ -156,7 +153,7 @@ pub unsafe fn dc_check_password( success } -pub unsafe fn dc_initiate_key_transfer(context: &dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char { let current_block: u64; let mut success: libc::c_int = 0i32; let mut setup_code: *mut libc::c_char; @@ -284,7 +281,7 @@ pub unsafe fn dc_initiate_key_transfer(context: &dc_context_t) -> *mut libc::c_c } pub unsafe extern "C" fn dc_render_setup_file( - context: &dc_context_t, + context: &Context, passphrase: *const libc::c_char, ) -> *mut libc::c_char { let stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; @@ -369,7 +366,7 @@ pub unsafe extern "C" fn dc_render_setup_file( ret_setupfilecontent } -pub unsafe fn dc_create_setup_code(_context: &dc_context_t) -> *mut libc::c_char { +pub unsafe fn dc_create_setup_code(_context: &Context) -> *mut libc::c_char { let mut random_val: uint16_t; let mut i: libc::c_int; let mut ret: dc_strbuilder_t = dc_strbuilder_t { @@ -407,7 +404,7 @@ pub unsafe fn dc_create_setup_code(_context: &dc_context_t) -> *mut libc::c_char // TODO should return bool /rtn pub unsafe fn dc_continue_key_transfer( - context: &dc_context_t, + context: &Context, msg_id: uint32_t, setup_code: *const libc::c_char, ) -> libc::c_int { @@ -485,7 +482,7 @@ pub unsafe fn dc_continue_key_transfer( // TODO should return bool /rtn unsafe fn set_self_key( - context: &dc_context_t, + context: &Context, armored: *const libc::c_char, set_default: libc::c_int, ) -> libc::c_int { @@ -622,7 +619,7 @@ unsafe fn set_self_key( } pub unsafe fn dc_decrypt_setup_file( - _context: &dc_context_t, + _context: &Context, passphrase: *const libc::c_char, filecontent: *const libc::c_char, ) -> *mut libc::c_char { @@ -680,7 +677,7 @@ pub unsafe fn dc_decrypt_setup_file( } pub unsafe fn dc_normalize_setup_code( - _context: &dc_context_t, + _context: &Context, in_0: *const libc::c_char, ) -> *mut libc::c_char { if in_0.is_null() { @@ -721,7 +718,7 @@ pub unsafe fn dc_normalize_setup_code( out.buf } -pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &dc_context_t, job: *mut dc_job_t) { +pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t) { let mut current_block: u64; let mut success: libc::c_int = 0i32; let mut ongoing_allocated_here: libc::c_int = 0i32; @@ -981,10 +978,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &dc_context_t, job: *mut dc_jo ******************************************************************************/ // TODO should return bool /rtn -unsafe fn import_backup( - context: &dc_context_t, - backup_to_import: *const libc::c_char, -) -> libc::c_int { +unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char) -> libc::c_int { let current_block: u64; let mut success: libc::c_int = 0i32; let mut processed_files_cnt: libc::c_int = 0i32; @@ -1142,7 +1136,7 @@ unsafe fn import_backup( /* the FILE_PROGRESS macro calls the callback with the permille of files processed. The macro avoids weird values of 0% or 100% while still working. */ // TODO should return bool /rtn -unsafe fn export_backup(context: &dc_context_t, dir: *const libc::c_char) -> libc::c_int { +unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_int { let mut current_block: u64; let mut success: libc::c_int = 0i32; let mut closed: libc::c_int = 0i32; @@ -1440,7 +1434,7 @@ unsafe fn export_backup(context: &dc_context_t, dir: *const libc::c_char) -> lib /******************************************************************************* * Classic key import ******************************************************************************/ -unsafe fn import_self_keys(context: &dc_context_t, dir_name: *const libc::c_char) -> libc::c_int { +unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) -> libc::c_int { /* hint: even if we switch to import Autocrypt Setup Files, we should leave the possibility to import plain ASC keys, at least keys without a password, if we do not want to implement a password entry function. Importing ASC keys is useful to use keys in Delta Chat used by any other non-Autocrypt-PGP implementation. @@ -1571,7 +1565,7 @@ unsafe fn import_self_keys(context: &dc_context_t, dir_name: *const libc::c_char } // TODO should return bool /rtn -unsafe fn export_self_keys(context: &dc_context_t, dir: *const libc::c_char) -> libc::c_int { +unsafe fn export_self_keys(context: &Context, dir: *const libc::c_char) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut export_errors: libc::c_int = 0i32; let mut id: libc::c_int; @@ -1618,7 +1612,7 @@ unsafe fn export_self_keys(context: &dc_context_t, dir: *const libc::c_char) -> ******************************************************************************/ // TODO should return bool /rtn unsafe fn export_key_to_asc_file( - context: &dc_context_t, + context: &Context, dir: *const libc::c_char, id: libc::c_int, key: &Key, diff --git a/src/dc_job.rs b/src/dc_job.rs index 8909c28ee..157949555 100644 --- a/src/dc_job.rs +++ b/src/dc_job.rs @@ -6,13 +6,11 @@ use std::time::{Duration, SystemTime}; use rand::{thread_rng, Rng}; use crate::constants::Event; +use crate::context::Context; use crate::dc_chat::*; use crate::dc_configure::*; -use crate::dc_context::dc_context_t; -use crate::dc_imap::*; use crate::dc_imex::*; use crate::dc_jobthread::*; -use crate::dc_keyhistory::*; use crate::dc_location::*; use crate::dc_log::*; use crate::dc_loginparam::*; @@ -21,6 +19,8 @@ use crate::dc_msg::*; use crate::dc_param::*; use crate::dc_sqlite3::*; use crate::dc_tools::*; +use crate::imap::*; +use crate::keyhistory::*; use crate::types::*; use crate::x::*; @@ -48,7 +48,7 @@ pub struct dc_job_t { pub pending_error: *mut libc::c_char, } -pub unsafe fn dc_perform_imap_jobs(context: &dc_context_t) { +pub unsafe fn dc_perform_imap_jobs(context: &Context) { dc_log_info( context, 0i32, @@ -66,7 +66,7 @@ pub unsafe fn dc_perform_imap_jobs(context: &dc_context_t) { b"INBOX-jobs ended.\x00" as *const u8 as *const libc::c_char, ); } -unsafe fn dc_job_perform(context: &dc_context_t, 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) { let mut select_stmt: *mut sqlite3_stmt; let mut job = dc_job_t { job_id: 0, @@ -252,7 +252,7 @@ unsafe fn dc_job_perform(context: &dc_context_t, thread: libc::c_int, probe_netw sqlite3_finalize(select_stmt); } -unsafe fn dc_job_delete(context: &dc_context_t, job: &dc_job_t) { +unsafe fn dc_job_delete(context: &Context, job: &dc_job_t) { let delete_stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -278,7 +278,7 @@ unsafe fn get_backoff_time_offset(c_tries: libc::c_int) -> time_t { } seconds as time_t } -unsafe fn dc_job_update(context: &dc_context_t, job: &dc_job_t) { +unsafe fn dc_job_update(context: &Context, job: &dc_job_t) { let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -292,7 +292,7 @@ unsafe fn dc_job_update(context: &dc_context_t, job: &dc_job_t) { sqlite3_step(stmt); sqlite3_finalize(stmt); } -unsafe fn dc_suspend_smtp_thread(context: &dc_context_t, suspend: libc::c_int) { +unsafe fn dc_suspend_smtp_thread(context: &Context, suspend: libc::c_int) { context.smtp_state.0.lock().unwrap().suspended = suspend; if 0 != suspend { loop { @@ -303,7 +303,7 @@ unsafe fn dc_suspend_smtp_thread(context: &dc_context_t, suspend: libc::c_int) { } } } -unsafe fn dc_job_do_DC_JOB_SEND(context: &dc_context_t, job: &mut dc_job_t) { +unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) { let mut current_block: u64; let mut filename: *mut libc::c_char = 0 as *mut libc::c_char; let mut buf: *mut libc::c_void = 0 as *mut libc::c_void; @@ -446,7 +446,7 @@ pub unsafe fn dc_job_try_again_later( job.pending_error = dc_strdup_keep_null(pending_error); } -unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &dc_context_t, job: &mut dc_job_t) { +unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &Context, job: &mut dc_job_t) { let mut current_block: u64; let msg: *mut dc_msg_t = dc_msg_new_untyped(context); let mut dest_folder: *mut libc::c_char = 0 as *mut libc::c_char; @@ -537,7 +537,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: &Imap) -> libc::c_int { +unsafe fn connect_to_inbox(context: &Context, inbox: &Imap) -> libc::c_int { let ret_connected: libc::c_int; ret_connected = dc_connect_to_configured_imap(context, inbox); @@ -547,7 +547,7 @@ unsafe fn connect_to_inbox(context: &dc_context_t, inbox: &Imap) -> libc::c_int ret_connected } -unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &dc_context_t, job: &mut dc_job_t) { +unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_job_t) { let current_block: u64; let folder: *mut libc::c_char = dc_param_get(job.param, 'Z' as i32, 0 as *const libc::c_char); let uid: uint32_t = dc_param_get_int(job.param, 'z' as i32, 0i32) as uint32_t; @@ -602,7 +602,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &dc_context_t, job: &mu free(folder as *mut libc::c_void); free(dest_folder as *mut libc::c_void); } -unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &dc_context_t, job: &mut dc_job_t) { +unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_job_t) { let mut current_block: u64; let msg: *mut dc_msg_t = dc_msg_new_untyped(context); let inbox = context.inbox.read().unwrap(); @@ -744,7 +744,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &dc_context_t, job: &mu } dc_msg_unref(msg); } -unsafe fn dc_send_mdn(context: &dc_context_t, msg_id: uint32_t) { +unsafe fn dc_send_mdn(context: &Context, msg_id: uint32_t) { let mut mimefactory: dc_mimefactory_t = dc_mimefactory_t { from_addr: 0 as *mut libc::c_char, from_displayname: 0 as *mut libc::c_char, @@ -787,7 +787,7 @@ unsafe fn dc_send_mdn(context: &dc_context_t, msg_id: uint32_t) { * @return 1=success, 0=error */ unsafe fn dc_add_smtp_job( - context: &dc_context_t, + context: &Context, action: libc::c_int, mimefactory: *mut dc_mimefactory_t, ) -> libc::c_int { @@ -851,7 +851,7 @@ unsafe fn dc_add_smtp_job( return success; } pub unsafe fn dc_job_add( - context: &dc_context_t, + context: &Context, action: libc::c_int, foreign_id: libc::c_int, param: *const libc::c_char, @@ -901,7 +901,7 @@ pub unsafe fn dc_job_add( dc_interrupt_smtp_idle(context); }; } -pub unsafe fn dc_interrupt_smtp_idle(context: &dc_context_t) { +pub unsafe fn dc_interrupt_smtp_idle(context: &Context) { dc_log_info( context, 0i32, @@ -916,7 +916,7 @@ pub unsafe fn dc_interrupt_smtp_idle(context: &dc_context_t) { cvar.notify_one(); } -pub unsafe fn dc_interrupt_imap_idle(context: &dc_context_t) { +pub unsafe fn dc_interrupt_imap_idle(context: &Context) { dc_log_info( context, 0i32, @@ -927,7 +927,7 @@ pub unsafe fn dc_interrupt_imap_idle(context: &dc_context_t) { context.inbox.read().unwrap().interrupt_idle(); } -unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(context: &dc_context_t, job: &mut dc_job_t) { +unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(context: &Context, job: &mut dc_job_t) { let mut current_block: u64; let mut delete_from_server: libc::c_int = 1i32; let msg: *mut dc_msg_t = dc_msg_new_untyped(context); @@ -987,7 +987,7 @@ unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(context: &dc_context_t, job: &mut } /* delete all pending jobs with the given action */ -pub unsafe fn dc_job_kill_action(context: &dc_context_t, action: libc::c_int) { +pub unsafe fn dc_job_kill_action(context: &Context, action: libc::c_int) { let stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -998,7 +998,7 @@ pub unsafe fn dc_job_kill_action(context: &dc_context_t, action: libc::c_int) { sqlite3_finalize(stmt); } -pub unsafe fn dc_perform_imap_fetch(context: &dc_context_t) { +pub unsafe fn dc_perform_imap_fetch(context: &Context) { let inbox = context.inbox.read().unwrap(); let start: libc::clock_t = clock(); @@ -1041,7 +1041,7 @@ pub unsafe fn dc_perform_imap_fetch(context: &dc_context_t) { ); } -pub unsafe fn dc_perform_imap_idle(context: &dc_context_t) { +pub unsafe fn dc_perform_imap_idle(context: &Context) { let inbox = context.inbox.read().unwrap(); connect_to_inbox(context, &inbox); @@ -1068,7 +1068,7 @@ pub unsafe fn dc_perform_imap_idle(context: &dc_context_t) { ); } -pub unsafe fn dc_perform_mvbox_fetch(context: &dc_context_t) { +pub unsafe fn dc_perform_mvbox_fetch(context: &Context) { let use_network: libc::c_int = dc_sqlite3_get_config_int( context, &context.sql.clone().read().unwrap(), @@ -1082,7 +1082,7 @@ pub unsafe fn dc_perform_mvbox_fetch(context: &dc_context_t) { ); } -pub unsafe fn dc_perform_mvbox_idle(context: &dc_context_t) { +pub unsafe fn dc_perform_mvbox_idle(context: &Context) { let use_network: libc::c_int = dc_sqlite3_get_config_int( context, &context.sql.clone().read().unwrap(), @@ -1096,11 +1096,11 @@ pub unsafe fn dc_perform_mvbox_idle(context: &dc_context_t) { ); } -pub unsafe fn dc_interrupt_mvbox_idle(context: &dc_context_t) { +pub unsafe fn dc_interrupt_mvbox_idle(context: &Context) { dc_jobthread_interrupt_idle(context, &context.mvbox_thread.clone().read().unwrap()); } -pub unsafe fn dc_perform_sentbox_fetch(context: &dc_context_t) { +pub unsafe fn dc_perform_sentbox_fetch(context: &Context) { let use_network: libc::c_int = dc_sqlite3_get_config_int( context, &context.sql.clone().read().unwrap(), @@ -1114,7 +1114,7 @@ pub unsafe fn dc_perform_sentbox_fetch(context: &dc_context_t) { ); } -pub unsafe fn dc_perform_sentbox_idle(context: &dc_context_t) { +pub unsafe fn dc_perform_sentbox_idle(context: &Context) { let use_network: libc::c_int = dc_sqlite3_get_config_int( context, &context.sql.clone().read().unwrap(), @@ -1128,11 +1128,11 @@ pub unsafe fn dc_perform_sentbox_idle(context: &dc_context_t) { ); } -pub unsafe fn dc_interrupt_sentbox_idle(context: &dc_context_t) { +pub unsafe fn dc_interrupt_sentbox_idle(context: &Context) { dc_jobthread_interrupt_idle(context, &context.sentbox_thread.clone().read().unwrap()); } -pub unsafe fn dc_perform_smtp_jobs(context: &dc_context_t) { +pub unsafe fn dc_perform_smtp_jobs(context: &Context) { let probe_smtp_network = { let &(ref lock, _) = &*context.smtp_state.clone(); let mut state = lock.lock().unwrap(); @@ -1173,7 +1173,7 @@ pub unsafe fn dc_perform_smtp_jobs(context: &dc_context_t) { } } -pub unsafe fn dc_perform_smtp_idle(context: &dc_context_t) { +pub unsafe fn dc_perform_smtp_idle(context: &Context) { dc_log_info( context, 0i32, @@ -1213,7 +1213,7 @@ pub unsafe fn dc_perform_smtp_idle(context: &dc_context_t) { ); } -unsafe fn get_next_wakeup_time(context: &dc_context_t, thread: libc::c_int) -> Duration { +unsafe fn get_next_wakeup_time(context: &Context, thread: libc::c_int) -> Duration { let stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -1243,7 +1243,7 @@ unsafe fn get_next_wakeup_time(context: &dc_context_t, thread: libc::c_int) -> D wakeup_time } -pub unsafe fn dc_maybe_network(context: &dc_context_t) { +pub unsafe fn dc_maybe_network(context: &Context) { { let &(ref lock, _) = &*context.smtp_state.clone(); let mut state = lock.lock().unwrap(); @@ -1258,7 +1258,7 @@ pub unsafe fn dc_maybe_network(context: &dc_context_t) { dc_interrupt_sentbox_idle(context); } -pub unsafe fn dc_job_action_exists(context: &dc_context_t, action: libc::c_int) -> libc::c_int { +pub unsafe fn dc_job_action_exists(context: &Context, action: libc::c_int) -> libc::c_int { let job_exists: libc::c_int; let stmt; stmt = dc_sqlite3_prepare( @@ -1272,7 +1272,7 @@ pub unsafe fn dc_job_action_exists(context: &dc_context_t, action: libc::c_int) return job_exists; } /* special case for DC_JOB_SEND_MSG_TO_SMTP */ -pub unsafe fn dc_job_send_msg(context: &dc_context_t, msg_id: uint32_t) -> libc::c_int { +pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut mimefactory = dc_mimefactory_t { from_addr: 0 as *mut libc::c_char, diff --git a/src/dc_jobthread.rs b/src/dc_jobthread.rs index 941144126..66be904bd 100644 --- a/src/dc_jobthread.rs +++ b/src/dc_jobthread.rs @@ -1,11 +1,11 @@ use std::sync::{Arc, Condvar, Mutex}; +use crate::context::Context; use crate::dc_configure::*; -use crate::dc_context::dc_context_t; -use crate::dc_imap::Imap; use crate::dc_log::*; use crate::dc_sqlite3::*; use crate::dc_tools::*; +use crate::imap::Imap; use crate::x::*; #[repr(C)] @@ -45,7 +45,7 @@ pub unsafe fn dc_jobthread_exit(jobthread: &mut dc_jobthread_t) { } pub unsafe fn dc_jobthread_suspend( - context: &dc_context_t, + context: &Context, jobthread: &dc_jobthread_t, suspend: libc::c_int, ) { @@ -85,7 +85,7 @@ pub unsafe fn dc_jobthread_suspend( } } -pub unsafe fn dc_jobthread_interrupt_idle(context: &dc_context_t, jobthread: &dc_jobthread_t) { +pub unsafe fn dc_jobthread_interrupt_idle(context: &Context, jobthread: &dc_jobthread_t) { { jobthread.state.0.lock().unwrap().jobs_needed = 1; } @@ -107,7 +107,7 @@ pub unsafe fn dc_jobthread_interrupt_idle(context: &dc_context_t, jobthread: &dc } pub unsafe fn dc_jobthread_fetch( - context: &dc_context_t, + context: &Context, jobthread: &mut dc_jobthread_t, use_network: libc::c_int, ) { @@ -162,7 +162,7 @@ pub unsafe fn dc_jobthread_fetch( * the typical fetch, idle, interrupt-idle ******************************************************************************/ -unsafe fn connect_to_imap(context: &dc_context_t, jobthread: &dc_jobthread_t) -> libc::c_int { +unsafe fn connect_to_imap(context: &Context, jobthread: &dc_jobthread_t) -> libc::c_int { let mut ret_connected: libc::c_int; let mut mvbox_name: *mut libc::c_char = 0 as *mut libc::c_char; @@ -200,7 +200,7 @@ unsafe fn connect_to_imap(context: &dc_context_t, jobthread: &dc_jobthread_t) -> } pub unsafe fn dc_jobthread_idle( - context: &dc_context_t, + context: &Context, jobthread: &dc_jobthread_t, use_network: libc::c_int, ) { diff --git a/src/dc_location.rs b/src/dc_location.rs index 8796f6da6..695b27dbc 100644 --- a/src/dc_location.rs +++ b/src/dc_location.rs @@ -1,7 +1,7 @@ use crate::constants::Event; +use crate::context::*; use crate::dc_array::*; use crate::dc_chat::*; -use crate::dc_context::*; use crate::dc_job::*; use crate::dc_log::*; use crate::dc_msg::*; @@ -40,7 +40,7 @@ pub struct dc_kml_t { // location streaming pub unsafe fn dc_send_locations_to_chat( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, seconds: libc::c_int, ) { @@ -119,16 +119,13 @@ pub unsafe fn dc_send_locations_to_chat( /******************************************************************************* * job to send locations out to all chats that want them ******************************************************************************/ -unsafe fn schedule_MAYBE_SEND_LOCATIONS(context: &dc_context_t, flags: libc::c_int) { +unsafe fn schedule_MAYBE_SEND_LOCATIONS(context: &Context, flags: libc::c_int) { if 0 != flags & 0x1i32 || 0 == dc_job_action_exists(context, 5005i32) { dc_job_add(context, 5005i32, 0i32, 0 as *const libc::c_char, 60i32); }; } -pub unsafe fn dc_is_sending_locations_to_chat( - context: &dc_context_t, - chat_id: uint32_t, -) -> libc::c_int { +pub unsafe fn dc_is_sending_locations_to_chat(context: &Context, chat_id: uint32_t) -> libc::c_int { let mut is_sending_locations: libc::c_int = 0i32; let stmt: *mut sqlite3_stmt; @@ -159,7 +156,7 @@ pub unsafe fn dc_is_sending_locations_to_chat( } pub unsafe fn dc_set_location( - context: &dc_context_t, + context: &Context, latitude: libc::c_double, longitude: libc::c_double, accuracy: libc::c_double, @@ -211,7 +208,7 @@ pub unsafe fn dc_set_location( } pub unsafe fn dc_get_locations( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, timestamp_from: time_t, @@ -298,7 +295,7 @@ unsafe fn is_marker(txt: *const libc::c_char) -> libc::c_int { 0 } -pub unsafe fn dc_delete_all_locations(context: &dc_context_t) { +pub unsafe fn dc_delete_all_locations(context: &Context) { let stmt: *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( @@ -318,7 +315,7 @@ pub unsafe fn dc_delete_all_locations(context: &dc_context_t) { } pub unsafe fn dc_get_location_kml( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, last_added_location_id: *mut uint32_t, ) -> *mut libc::c_char { @@ -488,11 +485,7 @@ pub unsafe fn dc_get_message_kml( ret } -pub unsafe fn dc_set_kml_sent_timestamp( - context: &dc_context_t, - chat_id: uint32_t, - timestamp: time_t, -) { +pub unsafe fn dc_set_kml_sent_timestamp(context: &Context, chat_id: uint32_t, timestamp: time_t) { let stmt: *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( context, @@ -506,11 +499,7 @@ pub unsafe fn dc_set_kml_sent_timestamp( sqlite3_finalize(stmt); } -pub unsafe fn dc_set_msg_location_id( - context: &dc_context_t, - msg_id: uint32_t, - location_id: uint32_t, -) { +pub unsafe fn dc_set_msg_location_id(context: &Context, msg_id: uint32_t, location_id: uint32_t) { let stmt: *mut sqlite3_stmt; stmt = dc_sqlite3_prepare( context, @@ -524,7 +513,7 @@ pub unsafe fn dc_set_msg_location_id( } pub unsafe fn dc_save_locations( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, contact_id: uint32_t, locations: *const dc_array_t, @@ -588,7 +577,7 @@ pub unsafe fn dc_save_locations( } pub unsafe fn dc_kml_parse( - context: &dc_context_t, + context: &Context, content: *const libc::c_char, content_bytes: size_t, ) -> *mut dc_kml_t { @@ -777,7 +766,7 @@ pub unsafe fn dc_kml_unref(kml: *mut dc_kml_t) { free(kml as *mut libc::c_void); } -pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &dc_context_t, _job: *mut dc_job_t) { +pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mut dc_job_t) { let stmt_chats: *mut sqlite3_stmt; let mut stmt_locations: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let now: time_t = time(0 as *mut time_t); @@ -850,7 +839,7 @@ pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &dc_context_t, _job sqlite3_finalize(stmt_locations); } -pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(context: &dc_context_t, job: &mut dc_job_t) { +pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(context: &Context, job: &mut dc_job_t) { // this function is called when location-streaming _might_ have ended for a chat. // the function checks, if location-streaming is really ended; // if so, a device-message is added if not yet done. diff --git a/src/dc_log.rs b/src/dc_log.rs index 5b20ff888..9fbd3b087 100644 --- a/src/dc_log.rs +++ b/src/dc_log.rs @@ -1,11 +1,11 @@ use crate::constants::Event; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_tools::*; use crate::types::*; use crate::x::*; pub unsafe extern "C" fn dc_log_event( - context: &dc_context_t, + context: &Context, event_code: Event, data1: libc::c_int, msg: *const libc::c_char, @@ -22,7 +22,7 @@ usually not reported using dc_log_error() - its up to the caller to decide, what should be reported or done. However, these "Normal" errors are usually logged by dc_log_warning(). */ unsafe fn log_vprintf( - context: &dc_context_t, + context: &Context, event: Event, data1: libc::c_int, msg_format: *const libc::c_char, @@ -49,7 +49,7 @@ unsafe fn log_vprintf( } pub unsafe extern "C" fn dc_log_event_seq( - context: &dc_context_t, + context: &Context, event_code: Event, sequence_start: *mut libc::c_int, msg: *const libc::c_char, @@ -63,7 +63,7 @@ pub unsafe extern "C" fn dc_log_event_seq( } pub unsafe extern "C" fn dc_log_error( - context: &dc_context_t, + context: &Context, data1: libc::c_int, msg: *const libc::c_char, va_1: ... @@ -72,7 +72,7 @@ pub unsafe extern "C" fn dc_log_error( } pub unsafe extern "C" fn dc_log_warning( - context: &dc_context_t, + context: &Context, data1: libc::c_int, msg: *const libc::c_char, va_2: ... @@ -81,7 +81,7 @@ pub unsafe extern "C" fn dc_log_warning( } pub unsafe extern "C" fn dc_log_info( - context: &dc_context_t, + context: &Context, data1: libc::c_int, msg: *const libc::c_char, va_3: ... diff --git a/src/dc_loginparam.rs b/src/dc_loginparam.rs index b30a64175..3475f2499 100644 --- a/src/dc_loginparam.rs +++ b/src/dc_loginparam.rs @@ -1,4 +1,4 @@ -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_sqlite3::*; use crate::dc_strbuilder::*; use crate::dc_tools::*; @@ -63,7 +63,7 @@ pub unsafe fn dc_loginparam_empty(mut loginparam: *mut dc_loginparam_t) { } pub unsafe fn dc_loginparam_read( - context: &dc_context_t, + context: &Context, loginparam: *mut dc_loginparam_t, sql: &dc_sqlite3_t, prefix: *const libc::c_char, @@ -144,7 +144,7 @@ pub unsafe fn dc_loginparam_read( } pub unsafe fn dc_loginparam_write( - context: &dc_context_t, + context: &Context, loginparam: *const dc_loginparam_t, sql: &dc_sqlite3_t, prefix: *const libc::c_char, diff --git a/src/dc_lot.rs b/src/dc_lot.rs index 47b74de3a..075cee01f 100644 --- a/src/dc_lot.rs +++ b/src/dc_lot.rs @@ -1,6 +1,6 @@ +use crate::context::Context; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_msg::*; use crate::dc_stock::*; use crate::dc_tools::*; @@ -129,7 +129,7 @@ pub unsafe fn dc_lot_fill( msg: *const dc_msg_t, chat: *const dc_chat_t, contact: *const dc_contact_t, - context: &dc_context_t, + context: &Context, ) { if lot.is_null() || (*lot).magic != 0x107107i32 as libc::c_uint || msg.is_null() { return; diff --git a/src/dc_mimefactory.rs b/src/dc_mimefactory.rs index e7465c188..849db340c 100644 --- a/src/dc_mimefactory.rs +++ b/src/dc_mimefactory.rs @@ -8,9 +8,9 @@ use mmime::mmapstring::*; use mmime::other::*; use crate::constants::VERSION; +use crate::context::Context; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_e2ee::*; use crate::dc_location::*; use crate::dc_log::*; @@ -45,7 +45,7 @@ pub struct dc_mimefactory_t<'a> { pub out_gossiped: libc::c_int, pub out_last_added_location_id: uint32_t, pub error: *mut libc::c_char, - pub context: &'a dc_context_t, + pub context: &'a Context, } pub type dc_mimefactory_loaded_t = libc::c_uint; @@ -53,10 +53,7 @@ pub const DC_MF_MDN_LOADED: dc_mimefactory_loaded_t = 2; pub const DC_MF_MSG_LOADED: dc_mimefactory_loaded_t = 1; pub const DC_MF_NOTHING_LOADED: dc_mimefactory_loaded_t = 0; -pub unsafe fn dc_mimefactory_init<'a>( - factory: *mut dc_mimefactory_t<'a>, - context: &'a dc_context_t, -) { +pub unsafe fn dc_mimefactory_init<'a>(factory: *mut dc_mimefactory_t<'a>, context: &'a Context) { if factory.is_null() { return; } diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index e04091eaf..a21bca76a 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -11,8 +11,8 @@ use mmime::mailmime_types::*; use mmime::mmapstring::*; use mmime::other::*; +use crate::context::Context; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_e2ee::*; use crate::dc_location::*; use crate::dc_log::*; @@ -26,8 +26,8 @@ use crate::types::*; use crate::x::*; /* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322 -dc_mimeparser_t has no deep dependencies to dc_context_t or to the database -(dc_context_t is used for logging only). */ +dc_mimeparser_t has no deep dependencies to Context or to the database +(Context is used for logging only). */ #[derive(Copy, Clone)] #[repr(C)] pub struct dc_mimepart_t { @@ -55,7 +55,7 @@ pub struct dc_mimeparser_t<'a> { pub decrypting_failed: libc::c_int, pub e2ee_helper: dc_e2ee_helper_t, pub is_forwarded: libc::c_int, - pub context: &'a dc_context_t, + pub context: &'a Context, pub reports: *mut carray, pub is_system_message: libc::c_int, pub location_kml: *mut dc_kml_t, @@ -70,7 +70,7 @@ pub unsafe fn dc_no_compound_msgs() { // deprecated: flag to switch generation of compound messages on and off. static mut s_generate_compound_msgs: libc::c_int = 1i32; -pub unsafe fn dc_mimeparser_new(context: &dc_context_t) -> dc_mimeparser_t { +pub unsafe fn dc_mimeparser_new(context: &Context) -> dc_mimeparser_t { dc_mimeparser_t { parts: carray_new(16i32 as libc::c_uint), mimeroot: std::ptr::null_mut(), @@ -825,7 +825,7 @@ unsafe fn dc_mimeparser_parse_mime_recursive( unsafe fn hash_header( out: &mut HashMap, in_0: *const mailimf_fields, - _context: &dc_context_t, + _context: &Context, ) { if in_0.is_null() { return; diff --git a/src/dc_move.rs b/src/dc_move.rs index 065bbf720..547ad9611 100644 --- a/src/dc_move.rs +++ b/src/dc_move.rs @@ -1,12 +1,12 @@ use crate::constants::*; -use crate::dc_context::*; +use crate::context::*; use crate::dc_job::*; use crate::dc_msg::*; use crate::dc_sqlite3::*; use crate::types::*; pub unsafe fn dc_do_heuristics_moves( - context: &dc_context_t, + context: &Context, folder: *const libc::c_char, msg_id: uint32_t, ) { diff --git a/src/dc_msg.rs b/src/dc_msg.rs index 786131fb9..e05bc1dfb 100644 --- a/src/dc_msg.rs +++ b/src/dc_msg.rs @@ -1,17 +1,17 @@ use crate::constants::*; +use crate::context::*; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_context::*; use crate::dc_job::*; use crate::dc_log::*; use crate::dc_lot::dc_lot_t; use crate::dc_lot::*; use crate::dc_param::*; -use crate::dc_pgp::*; use crate::dc_sqlite3::*; use crate::dc_stock::*; use crate::dc_strbuilder::*; use crate::dc_tools::*; +use crate::pgp::*; use crate::types::*; use crate::x::*; @@ -32,7 +32,7 @@ pub struct dc_msg_t<'a> { pub timestamp_sent: time_t, pub timestamp_rcvd: time_t, pub text: *mut libc::c_char, - pub context: &'a dc_context_t, + pub context: &'a Context, pub rfc724_mid: *mut libc::c_char, pub in_reply_to: *mut libc::c_char, pub server_folder: *mut libc::c_char, @@ -45,7 +45,7 @@ pub struct dc_msg_t<'a> { } // handle messages -pub unsafe fn dc_get_msg_info(context: &dc_context_t, msg_id: uint32_t) -> *mut libc::c_char { +pub unsafe fn dc_get_msg_info(context: &Context, msg_id: uint32_t) -> *mut libc::c_char { let e2ee_errors: libc::c_int; let w: libc::c_int; let h: libc::c_int; @@ -285,7 +285,7 @@ pub unsafe fn dc_get_msg_info(context: &dc_context_t, msg_id: uint32_t) -> *mut ret.buf } -pub unsafe fn dc_msg_new_untyped<'a>(context: &'a dc_context_t) -> *mut dc_msg_t<'a> { +pub unsafe fn dc_msg_new_untyped<'a>(context: &'a Context) -> *mut dc_msg_t<'a> { dc_msg_new(context, 0i32) } @@ -299,10 +299,7 @@ pub unsafe fn dc_msg_new_untyped<'a>(context: &'a dc_context_t) -> *mut dc_msg_t // to check if a mail was sent, use dc_msg_is_sent() // approx. max. lenght returned by dc_msg_get_text() // approx. max. lenght returned by dc_get_msg_info() -pub unsafe fn dc_msg_new<'a>( - context: &'a dc_context_t, - viewtype: libc::c_int, -) -> *mut dc_msg_t<'a> { +pub unsafe fn dc_msg_new<'a>(context: &'a Context, viewtype: libc::c_int) -> *mut dc_msg_t<'a> { let mut msg: *mut dc_msg_t; msg = calloc(1, ::std::mem::size_of::()) as *mut dc_msg_t; if msg.is_null() { @@ -506,7 +503,7 @@ pub unsafe fn dc_msg_get_timestamp(msg: *const dc_msg_t) -> time_t { pub unsafe fn dc_msg_load_from_db<'a>( msg: *mut dc_msg_t<'a>, - context: &'a dc_context_t, + context: &'a Context, id: uint32_t, ) -> bool { let mut success = false; @@ -611,7 +608,7 @@ unsafe fn dc_msg_set_from_stmt( 1 } -pub unsafe fn dc_get_mime_headers(context: &dc_context_t, msg_id: uint32_t) -> *mut libc::c_char { +pub unsafe fn dc_get_mime_headers(context: &Context, msg_id: uint32_t) -> *mut libc::c_char { let mut eml = 0 as *mut libc::c_char; let stmt: *mut sqlite3_stmt; @@ -630,11 +627,7 @@ pub unsafe fn dc_get_mime_headers(context: &dc_context_t, msg_id: uint32_t) -> * eml } -pub unsafe fn dc_delete_msgs( - context: &dc_context_t, - msg_ids: *const uint32_t, - msg_cnt: libc::c_int, -) { +pub unsafe fn dc_delete_msgs(context: &Context, msg_ids: *const uint32_t, msg_cnt: libc::c_int) { if msg_ids.is_null() || msg_cnt <= 0i32 { return; } @@ -663,7 +656,7 @@ pub unsafe fn dc_delete_msgs( }; } -pub unsafe fn dc_update_msg_chat_id(context: &dc_context_t, msg_id: uint32_t, chat_id: uint32_t) { +pub unsafe fn dc_update_msg_chat_id(context: &Context, msg_id: uint32_t, chat_id: uint32_t) { let stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -675,11 +668,7 @@ pub unsafe fn dc_update_msg_chat_id(context: &dc_context_t, msg_id: uint32_t, ch sqlite3_finalize(stmt); } -pub unsafe fn dc_markseen_msgs( - context: &dc_context_t, - msg_ids: *const uint32_t, - msg_cnt: libc::c_int, -) { +pub unsafe fn dc_markseen_msgs(context: &Context, msg_ids: *const uint32_t, msg_cnt: libc::c_int) { let mut i: libc::c_int; let mut send_event: libc::c_int = 0i32; let mut curr_state: libc::c_int; @@ -735,7 +724,7 @@ pub unsafe fn dc_markseen_msgs( sqlite3_finalize(stmt); } -pub unsafe fn dc_update_msg_state(context: &dc_context_t, msg_id: uint32_t, state: libc::c_int) { +pub unsafe fn dc_update_msg_state(context: &Context, msg_id: uint32_t, state: libc::c_int) { let stmt = dc_sqlite3_prepare( context, &context.sql.clone().read().unwrap(), @@ -748,7 +737,7 @@ pub unsafe fn dc_update_msg_state(context: &dc_context_t, msg_id: uint32_t, stat } pub unsafe fn dc_star_msgs( - context: &dc_context_t, + context: &Context, msg_ids: *const uint32_t, msg_cnt: libc::c_int, star: libc::c_int, @@ -772,7 +761,7 @@ pub unsafe fn dc_star_msgs( sqlite3_finalize(stmt); } -pub unsafe fn dc_get_msg<'a>(context: &'a dc_context_t, msg_id: uint32_t) -> *mut dc_msg_t<'a> { +pub unsafe fn dc_get_msg<'a>(context: &'a Context, msg_id: uint32_t) -> *mut dc_msg_t<'a> { let mut success: libc::c_int = 0i32; let obj: *mut dc_msg_t = dc_msg_new_untyped(context); if dc_msg_load_from_db(obj, context, msg_id) { @@ -984,7 +973,7 @@ pub unsafe fn dc_msg_get_summarytext_by_raw( text: *const libc::c_char, param: *mut dc_param_t, approx_characters: libc::c_int, - context: &dc_context_t, + context: &Context, ) -> *mut libc::c_char { /* get a summary text, result must be free()'d, never returns NULL. */ let mut ret; @@ -1261,16 +1250,13 @@ pub unsafe fn dc_msg_save_param_to_disk(msg: *mut dc_msg_t) { sqlite3_finalize(stmt); } -pub unsafe fn dc_msg_new_load<'a>( - context: &'a dc_context_t, - msg_id: uint32_t, -) -> *mut dc_msg_t<'a> { +pub unsafe fn dc_msg_new_load<'a>(context: &'a Context, msg_id: uint32_t) -> *mut dc_msg_t<'a> { let msg = dc_msg_new_untyped(context); dc_msg_load_from_db(msg, context, msg_id); msg } -pub unsafe fn dc_delete_msg_from_db(context: &dc_context_t, msg_id: uint32_t) { +pub unsafe fn dc_delete_msg_from_db(context: &Context, msg_id: uint32_t) { let msg: *mut dc_msg_t = dc_msg_new_untyped(context); let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if dc_msg_load_from_db(msg, context, msg_id) { @@ -1303,7 +1289,7 @@ The value is also used for CC:-summaries */ // Context functions to work with messages -pub unsafe fn dc_msg_exists(context: &dc_context_t, msg_id: uint32_t) -> libc::c_int { +pub unsafe fn dc_msg_exists(context: &Context, msg_id: uint32_t) -> libc::c_int { let mut msg_exists = 0; let mut stmt = 0 as *mut sqlite3_stmt; @@ -1328,7 +1314,7 @@ pub unsafe fn dc_msg_exists(context: &dc_context_t, msg_id: uint32_t) -> libc::c } pub unsafe fn dc_update_msg_move_state( - context: &dc_context_t, + context: &Context, rfc724_mid: *const libc::c_char, state: dc_move_state_t, ) { @@ -1345,11 +1331,7 @@ pub unsafe fn dc_update_msg_move_state( sqlite3_finalize(stmt); } -pub unsafe fn dc_set_msg_failed( - context: &dc_context_t, - msg_id: uint32_t, - error: *const libc::c_char, -) { +pub unsafe fn dc_set_msg_failed(context: &Context, msg_id: uint32_t, error: *const libc::c_char) { let mut msg = dc_msg_new_untyped(context); let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; if dc_msg_load_from_db(msg, context, msg_id) { @@ -1387,7 +1369,7 @@ pub unsafe fn dc_set_msg_failed( /* returns 1 if an event should be send */ pub unsafe fn dc_mdn_from_ext( - context: &dc_context_t, + context: &Context, from_id: uint32_t, rfc724_mid: *const libc::c_char, timestamp_sent: time_t, @@ -1503,7 +1485,7 @@ pub unsafe fn dc_mdn_from_ext( } /* the number of messages assigned to real chat (!=deaddrop, !=trash) */ -pub unsafe fn dc_get_real_msg_cnt(context: &dc_context_t) -> size_t { +pub unsafe fn dc_get_real_msg_cnt(context: &Context) -> size_t { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut ret: size_t = 0i32 as size_t; if !(*&context.sql.clone().read().unwrap()).cobj.is_null() { @@ -1528,7 +1510,7 @@ pub unsafe fn dc_get_real_msg_cnt(context: &dc_context_t) -> size_t { ret } -pub unsafe fn dc_get_deaddrop_msg_cnt(context: &dc_context_t) -> size_t { +pub unsafe fn dc_get_deaddrop_msg_cnt(context: &Context) -> size_t { let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt; let mut ret: size_t = 0i32 as size_t; if !context.sql.clone().read().unwrap().cobj.is_null() { @@ -1545,10 +1527,7 @@ pub unsafe fn dc_get_deaddrop_msg_cnt(context: &dc_context_t) -> size_t { ret } -pub unsafe fn dc_rfc724_mid_cnt( - context: &dc_context_t, - rfc724_mid: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_rfc724_mid_cnt(context: &Context, rfc724_mid: *const libc::c_char) -> libc::c_int { /* check the number of messages with the same rfc724_mid */ let mut ret: libc::c_int = 0i32; let mut stmt = 0 as *mut sqlite3_stmt; @@ -1570,7 +1549,7 @@ pub unsafe fn dc_rfc724_mid_cnt( } pub unsafe fn dc_rfc724_mid_exists( - context: &dc_context_t, + context: &Context, rfc724_mid: *const libc::c_char, ret_server_folder: *mut *mut libc::c_char, ret_server_uid: *mut uint32_t, @@ -1608,7 +1587,7 @@ pub unsafe fn dc_rfc724_mid_exists( } pub unsafe fn dc_update_server_uid( - context: &dc_context_t, + context: &Context, rfc724_mid: *const libc::c_char, server_folder: *const libc::c_char, server_uid: uint32_t, diff --git a/src/dc_qr.rs b/src/dc_qr.rs index 027fd3b01..8eab42086 100644 --- a/src/dc_qr.rs +++ b/src/dc_qr.rs @@ -1,12 +1,12 @@ +use crate::context::Context; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; -use crate::dc_key::*; use crate::dc_log::*; use crate::dc_lot::*; use crate::dc_param::*; use crate::dc_strencode::*; use crate::dc_tools::*; +use crate::key::*; use crate::peerstate::*; use crate::types::*; use crate::x::*; @@ -21,7 +21,7 @@ use crate::x::*; // text1=text // text1=URL // text1=error string -pub unsafe fn dc_check_qr(context: &dc_context_t, qr: *const libc::c_char) -> *mut dc_lot_t { +pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc_lot_t { let mut current_block: u64; let mut payload: *mut libc::c_char = 0 as *mut libc::c_char; // must be normalized, if set diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 092fbaa2f..fb0150b4c 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -7,10 +7,10 @@ use mmime::mmapstring::*; use mmime::other::*; use crate::constants::*; +use crate::context::Context; use crate::dc_array::*; use crate::dc_chat::*; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_job::*; use crate::dc_location::*; use crate::dc_log::*; @@ -18,7 +18,6 @@ use crate::dc_mimeparser::*; use crate::dc_move::*; use crate::dc_msg::*; use crate::dc_param::*; -use crate::dc_pgp::dc_hash_sha256; use crate::dc_securejoin::*; use crate::dc_sqlite3::*; use crate::dc_stock::*; @@ -26,11 +25,12 @@ use crate::dc_strbuilder::*; use crate::dc_strencode::*; use crate::dc_tools::*; use crate::peerstate::*; +use crate::pgp::dc_hash_sha256; use crate::types::*; use crate::x::*; pub unsafe fn dc_receive_imf( - context: &dc_context_t, + context: &Context, imf_raw_not_terminated: *const libc::c_char, imf_raw_bytes: size_t, server_folder: *const libc::c_char, @@ -1014,7 +1014,7 @@ pub unsafe fn dc_receive_imf( * Misc. Tools ******************************************************************************/ unsafe fn calc_timestamps( - context: &dc_context_t, + context: &Context, chat_id: uint32_t, from_id: uint32_t, message_timestamp: time_t, @@ -1066,7 +1066,7 @@ which tries to create or find out the chat_id by: So when the function returns, the caller has the group id matching the current state of the group. */ unsafe fn create_or_lookup_group( - context: &dc_context_t, + context: &Context, mime_parser: &mut dc_mimeparser_t, allow_creation: libc::c_int, create_blocked: libc::c_int, @@ -1531,7 +1531,7 @@ unsafe fn create_or_lookup_group( * Handle groups for received messages ******************************************************************************/ unsafe fn create_or_lookup_adhoc_group( - context: &dc_context_t, + context: &Context, mime_parser: &dc_mimeparser_t, allow_creation: libc::c_int, create_blocked: libc::c_int, @@ -1645,7 +1645,7 @@ unsafe fn create_or_lookup_adhoc_group( }; } unsafe fn create_group_record( - context: &dc_context_t, + context: &Context, grpid: *const libc::c_char, grpname: *const libc::c_char, create_blocked: libc::c_int, @@ -1679,10 +1679,7 @@ unsafe fn create_group_record( sqlite3_finalize(stmt); return chat_id; } -unsafe fn create_adhoc_grp_id( - context: &dc_context_t, - member_ids: *mut dc_array_t, -) -> *mut libc::c_char { +unsafe fn create_adhoc_grp_id(context: &Context, member_ids: *mut dc_array_t) -> *mut libc::c_char { /* algorithm: - sort normalized, lowercased, e-mail addresses alphabetically - put all e-mail addresses into a single string, separate the addresss by a single comma @@ -1766,7 +1763,7 @@ unsafe fn create_adhoc_grp_id( return ret; } unsafe fn search_chat_ids_by_contact_ids( - context: &dc_context_t, + context: &Context, unsorted_contact_ids: *const dc_array_t, ) -> *mut dc_array_t { /* searches chat_id's by the given contact IDs, may return zero, one or more chat_id's */ @@ -1834,7 +1831,7 @@ unsafe fn search_chat_ids_by_contact_ids( return chat_ids; } unsafe fn check_verified_properties( - context: &dc_context_t, + context: &Context, mimeparser: &dc_mimeparser_t, from_id: uint32_t, to_ids: *const dc_array_t, @@ -1989,7 +1986,7 @@ unsafe fn set_better_msg(mime_parser: &dc_mimeparser_t, better_msg: *mut *mut li }; } unsafe fn dc_is_reply_to_known_message( - context: &dc_context_t, + context: &Context, mime_parser: &dc_mimeparser_t, ) -> libc::c_int { /* check if the message is a reply to a known message; the replies are identified by the Message-ID from @@ -2037,10 +2034,7 @@ unsafe fn dc_is_reply_to_known_message( } return 0i32; } -unsafe fn is_known_rfc724_mid_in_list( - context: &dc_context_t, - mid_list: *const clist, -) -> libc::c_int { +unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> libc::c_int { if !mid_list.is_null() { let mut cur: *mut clistiter; cur = (*mid_list).first; @@ -2067,10 +2061,7 @@ unsafe fn is_known_rfc724_mid_in_list( /* ****************************************************************************** * Check if a message is a reply to a known message (messenger or non-messenger) ******************************************************************************/ -unsafe fn is_known_rfc724_mid( - context: &dc_context_t, - rfc724_mid: *const libc::c_char, -) -> libc::c_int { +unsafe fn is_known_rfc724_mid(context: &Context, rfc724_mid: *const libc::c_char) -> libc::c_int { let mut is_known: libc::c_int = 0i32; if !rfc724_mid.is_null() { let stmt: *mut sqlite3_stmt = @@ -2086,7 +2077,7 @@ unsafe fn is_known_rfc724_mid( return is_known; } unsafe fn dc_is_reply_to_messenger_message( - context: &dc_context_t, + context: &Context, mime_parser: &dc_mimeparser_t, ) -> libc::c_int { /* function checks, if the message defined by mime_parser references a message send by us from Delta Chat. @@ -2127,10 +2118,7 @@ unsafe fn dc_is_reply_to_messenger_message( } return 0i32; } -unsafe fn is_msgrmsg_rfc724_mid_in_list( - context: &dc_context_t, - mid_list: *const clist, -) -> libc::c_int { +unsafe fn is_msgrmsg_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> libc::c_int { if !mid_list.is_null() { let mut cur: *mut clistiter = (*mid_list).first; while !cur.is_null() { @@ -2156,10 +2144,7 @@ unsafe fn is_msgrmsg_rfc724_mid_in_list( /* ****************************************************************************** * Check if a message is a reply to any messenger message ******************************************************************************/ -unsafe fn is_msgrmsg_rfc724_mid( - context: &dc_context_t, - rfc724_mid: *const libc::c_char, -) -> libc::c_int { +unsafe fn is_msgrmsg_rfc724_mid(context: &Context, rfc724_mid: *const libc::c_char) -> libc::c_int { let mut is_msgrmsg: libc::c_int = 0i32; if !rfc724_mid.is_null() { let stmt: *mut sqlite3_stmt = dc_sqlite3_prepare( @@ -2177,7 +2162,7 @@ unsafe fn is_msgrmsg_rfc724_mid( return is_msgrmsg; } unsafe fn dc_add_or_lookup_contacts_by_address_list( - context: &dc_context_t, + context: &Context, adr_list: *const mailimf_address_list, origin: libc::c_int, ids: *mut dc_array_t, @@ -2227,7 +2212,7 @@ unsafe fn dc_add_or_lookup_contacts_by_address_list( } } unsafe fn dc_add_or_lookup_contacts_by_mailbox_list( - context: &dc_context_t, + context: &Context, mb_list: *const mailimf_mailbox_list, origin: libc::c_int, ids: *mut dc_array_t, @@ -2264,7 +2249,7 @@ unsafe fn dc_add_or_lookup_contacts_by_mailbox_list( * Add contacts to database on receiving messages ******************************************************************************/ unsafe fn add_or_lookup_contact_by_addr( - context: &dc_context_t, + context: &Context, display_name_enc: *const libc::c_char, addr_spec: *const libc::c_char, origin: libc::c_int, diff --git a/src/dc_securejoin.rs b/src/dc_securejoin.rs index e599a3b72..919480c06 100644 --- a/src/dc_securejoin.rs +++ b/src/dc_securejoin.rs @@ -1,14 +1,13 @@ use mmime::mailimf_types::*; +use crate::aheader::EncryptPreference; use crate::constants::Event; -use crate::dc_aheader::EncryptPreference; +use crate::context::Context; use crate::dc_array::*; use crate::dc_chat::*; use crate::dc_configure::*; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_e2ee::*; -use crate::dc_key::*; use crate::dc_log::*; use crate::dc_lot::*; use crate::dc_mimeparser::*; @@ -20,12 +19,13 @@ use crate::dc_stock::*; use crate::dc_strencode::*; use crate::dc_token::*; use crate::dc_tools::*; +use crate::key::*; use crate::peerstate::*; use crate::types::*; use crate::x::*; pub unsafe fn dc_get_securejoin_qr( - context: &dc_context_t, + context: &Context, group_chat_id: uint32_t, ) -> *mut libc::c_char { let current_block: u64; @@ -147,7 +147,7 @@ pub unsafe fn dc_get_securejoin_qr( }; } -unsafe fn get_self_fingerprint(context: &dc_context_t) -> *mut libc::c_char { +unsafe fn get_self_fingerprint(context: &Context) -> *mut libc::c_char { let self_addr = dc_sqlite3_get_config( context, &context.sql.clone().read().unwrap(), @@ -167,7 +167,7 @@ unsafe fn get_self_fingerprint(context: &dc_context_t) -> *mut libc::c_char { std::ptr::null_mut() } -pub unsafe fn dc_join_securejoin(context: &dc_context_t, qr: *const libc::c_char) -> uint32_t { +pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) -> uint32_t { /* ========================================================== ==== Bob - the joiner's side ===== ==== Step 2 in "Setup verified contact" protocol ===== @@ -298,7 +298,7 @@ pub unsafe fn dc_join_securejoin(context: &dc_context_t, qr: *const libc::c_char } unsafe fn send_handshake_msg( - context: &dc_context_t, + context: &Context, contact_chat_id: uint32_t, step: *const libc::c_char, param2: *const libc::c_char, @@ -334,7 +334,7 @@ unsafe fn send_handshake_msg( dc_msg_unref(msg); } -unsafe fn chat_id_2_contact_id(context: &dc_context_t, contact_chat_id: uint32_t) -> uint32_t { +unsafe fn chat_id_2_contact_id(context: &Context, contact_chat_id: uint32_t) -> uint32_t { let mut contact_id: uint32_t = 0i32 as uint32_t; let contacts: *mut dc_array_t = dc_get_chat_contacts(context, contact_chat_id); if !(dc_array_get_cnt(contacts) != 1) { @@ -346,7 +346,7 @@ unsafe fn chat_id_2_contact_id(context: &dc_context_t, contact_chat_id: uint32_t } unsafe fn fingerprint_equals_sender( - context: &dc_context_t, + context: &Context, fingerprint: *const libc::c_char, contact_chat_id: uint32_t, ) -> libc::c_int { @@ -383,7 +383,7 @@ unsafe fn fingerprint_equals_sender( /* library private: secure-join */ pub unsafe fn dc_handle_securejoin_handshake( - context: &dc_context_t, + context: &Context, mimeparser: &dc_mimeparser_t, contact_id: uint32_t, ) -> libc::c_int { @@ -894,12 +894,12 @@ pub unsafe fn dc_handle_securejoin_handshake( ret } -unsafe fn end_bobs_joining(context: &dc_context_t, status: libc::c_int) { +unsafe fn end_bobs_joining(context: &Context, status: libc::c_int) { context.bob.clone().write().unwrap().status = status; dc_stop_ongoing_process(context); } -unsafe fn secure_connection_established(context: &dc_context_t, contact_chat_id: uint32_t) { +unsafe fn secure_connection_established(context: &Context, contact_chat_id: uint32_t) { let contact_id: uint32_t = chat_id_2_contact_id(context, contact_chat_id); let contact: *mut dc_contact_t = dc_get_contact(context, contact_id); let msg: *mut libc::c_char = dc_stock_str_repl_string( @@ -943,7 +943,7 @@ unsafe fn lookup_field( } unsafe fn could_not_establish_secure_connection( - context: &dc_context_t, + context: &Context, contact_chat_id: uint32_t, details: *const libc::c_char, ) { @@ -971,7 +971,7 @@ unsafe fn could_not_establish_secure_connection( } unsafe fn mark_peer_as_verified( - context: &dc_context_t, + context: &Context, fingerprint: *const libc::c_char, ) -> libc::c_int { let mut success = 0; @@ -1043,7 +1043,7 @@ unsafe fn encrypted_and_signed( 1 } -pub unsafe fn dc_handle_degrade_event(context: &dc_context_t, peerstate: &Peerstate) { +pub unsafe fn dc_handle_degrade_event(context: &Context, peerstate: &Peerstate) { let stmt; let contact_id: uint32_t; let mut contact_chat_id: uint32_t = 0i32 as uint32_t; diff --git a/src/dc_sqlite3.rs b/src/dc_sqlite3.rs index 24c573536..25eaf7bae 100644 --- a/src/dc_sqlite3.rs +++ b/src/dc_sqlite3.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use crate::constants::*; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_log::*; use crate::dc_param::*; use crate::dc_tools::*; @@ -23,13 +23,13 @@ pub fn dc_sqlite3_new() -> dc_sqlite3_t { } } -pub unsafe fn dc_sqlite3_unref(context: &dc_context_t, sql: &mut dc_sqlite3_t) { +pub unsafe fn dc_sqlite3_unref(context: &Context, sql: &mut dc_sqlite3_t) { if !sql.cobj.is_null() { dc_sqlite3_close(context, sql); } } -pub unsafe fn dc_sqlite3_close(context: &dc_context_t, sql: &mut dc_sqlite3_t) { +pub unsafe fn dc_sqlite3_close(context: &Context, sql: &mut dc_sqlite3_t) { if !sql.cobj.is_null() { sqlite3_close(sql.cobj); sql.cobj = 0 as *mut sqlite3 @@ -43,7 +43,7 @@ pub unsafe fn dc_sqlite3_close(context: &dc_context_t, sql: &mut dc_sqlite3_t) { } pub unsafe fn dc_sqlite3_open( - context: &dc_context_t, + context: &Context, sql: &mut dc_sqlite3_t, dbfile: *const libc::c_char, flags: libc::c_int, @@ -1000,7 +1000,7 @@ pub unsafe fn dc_sqlite3_open( // handle configurations, private pub unsafe fn dc_sqlite3_set_config( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, key: *const libc::c_char, value: *const libc::c_char, @@ -1089,7 +1089,7 @@ pub unsafe fn dc_sqlite3_set_config( /* tools, these functions are compatible to the corresponding sqlite3_* functions */ /* the result mus be freed using sqlite3_finalize() */ pub unsafe fn dc_sqlite3_prepare( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, querystr: *const libc::c_char, ) -> *mut sqlite3_stmt { @@ -1117,7 +1117,7 @@ pub unsafe fn dc_sqlite3_prepare( } pub unsafe extern "C" fn dc_sqlite3_log_error( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, msg_format: *const libc::c_char, va: ... @@ -1156,7 +1156,7 @@ pub unsafe fn dc_sqlite3_is_open(sql: &dc_sqlite3_t) -> libc::c_int { /* the returned string must be free()'d, returns NULL on errors */ pub unsafe fn dc_sqlite3_get_config( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, key: *const libc::c_char, def: *const libc::c_char, @@ -1184,7 +1184,7 @@ pub unsafe fn dc_sqlite3_get_config( } pub unsafe fn dc_sqlite3_execute( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, querystr: *const libc::c_char, ) -> libc::c_int { @@ -1209,7 +1209,7 @@ pub unsafe fn dc_sqlite3_execute( } pub unsafe fn dc_sqlite3_set_config_int( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, key: *const libc::c_char, value: int32_t, @@ -1228,7 +1228,7 @@ pub unsafe fn dc_sqlite3_set_config_int( } pub unsafe fn dc_sqlite3_get_config_int( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, key: *const libc::c_char, def: int32_t, @@ -1243,7 +1243,7 @@ pub unsafe fn dc_sqlite3_get_config_int( } pub unsafe fn dc_sqlite3_table_exists( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, name: *const libc::c_char, ) -> libc::c_int { @@ -1282,7 +1282,7 @@ pub unsafe fn dc_sqlite3_table_exists( } pub unsafe fn dc_sqlite3_set_config_int64( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, key: *const libc::c_char, value: int64_t, @@ -1300,7 +1300,7 @@ pub unsafe fn dc_sqlite3_set_config_int64( } pub unsafe fn dc_sqlite3_get_config_int64( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, key: *const libc::c_char, def: int64_t, @@ -1320,7 +1320,7 @@ pub unsafe fn dc_sqlite3_get_config_int64( } pub unsafe fn dc_sqlite3_try_execute( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, querystr: *const libc::c_char, ) -> libc::c_int { @@ -1347,7 +1347,7 @@ pub unsafe fn dc_sqlite3_try_execute( } pub unsafe fn dc_sqlite3_get_rowid( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, table: *const libc::c_char, field: *const libc::c_char, @@ -1373,7 +1373,7 @@ pub unsafe fn dc_sqlite3_get_rowid( } pub unsafe fn dc_sqlite3_get_rowid2( - context: &dc_context_t, + context: &Context, sql: &dc_sqlite3_t, table: *const libc::c_char, field: *const libc::c_char, @@ -1402,7 +1402,7 @@ pub unsafe fn dc_sqlite3_get_rowid2( id } -pub unsafe fn dc_housekeeping(context: &dc_context_t) { +pub unsafe fn dc_housekeeping(context: &Context) { let stmt; let dir_handle; let mut dir_entry; @@ -1596,7 +1596,7 @@ unsafe fn maybe_add_file(files_in_use: &mut HashSet, file: *const libc:: } unsafe fn maybe_add_from_param( - context: &dc_context_t, + context: &Context, files_in_use: &mut HashSet, query: *const libc::c_char, param_id: libc::c_int, diff --git a/src/dc_stock.rs b/src/dc_stock.rs index efd9c39d5..93d6e267a 100644 --- a/src/dc_stock.rs +++ b/src/dc_stock.rs @@ -1,21 +1,17 @@ use crate::constants::Event; +use crate::context::Context; use crate::dc_contact::*; -use crate::dc_context::dc_context_t; use crate::dc_tools::*; use crate::types::*; use crate::x::*; /* Return the string with the given ID by calling DC_EVENT_GET_STRING. The result must be free()'d! */ -pub unsafe fn dc_stock_str(context: &dc_context_t, id: libc::c_int) -> *mut libc::c_char { +pub unsafe fn dc_stock_str(context: &Context, id: libc::c_int) -> *mut libc::c_char { return get_string(context, id, 0i32); } -unsafe fn get_string( - context: &dc_context_t, - id: libc::c_int, - qty: libc::c_int, -) -> *mut libc::c_char { +unsafe fn get_string(context: &Context, id: libc::c_int, qty: libc::c_int) -> *mut libc::c_char { let mut ret: *mut libc::c_char; ret = ((*context).cb)( @@ -216,7 +212,7 @@ unsafe fn default_string(id: libc::c_int) -> *mut libc::c_char { /* Replaces the first `%1$s` in the given String-ID by the given value. The result must be free()'d! */ pub unsafe fn dc_stock_str_repl_string( - context: &dc_context_t, + context: &Context, id: libc::c_int, to_insert: *const libc::c_char, ) -> *mut libc::c_char { @@ -236,7 +232,7 @@ pub unsafe fn dc_stock_str_repl_string( } pub unsafe fn dc_stock_str_repl_int( - context: &dc_context_t, + context: &Context, id: libc::c_int, to_insert_int: libc::c_int, ) -> *mut libc::c_char { @@ -263,7 +259,7 @@ pub unsafe fn dc_stock_str_repl_int( /* Replaces the first `%1$s` and `%2$s` in the given String-ID by the two given strings. The result must be free()'d! */ pub unsafe fn dc_stock_str_repl_string2( - context: &dc_context_t, + context: &Context, id: libc::c_int, to_insert: *const libc::c_char, to_insert2: *const libc::c_char, @@ -295,7 +291,7 @@ pub unsafe fn dc_stock_str_repl_string2( /* Misc. */ pub unsafe fn dc_stock_system_msg( - context: &dc_context_t, + context: &Context, str_id: libc::c_int, mut param1: *const libc::c_char, param2: *const libc::c_char, diff --git a/src/dc_token.rs b/src/dc_token.rs index 6483d38a7..bc33fe529 100644 --- a/src/dc_token.rs +++ b/src/dc_token.rs @@ -1,4 +1,4 @@ -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_sqlite3::*; use crate::dc_tools::*; use crate::types::*; @@ -10,7 +10,7 @@ pub const DC_TOKEN_AUTH: dc_tokennamespc_t = 110; pub const DC_TOKEN_INVITENUMBER: dc_tokennamespc_t = 100; // Functions to read/write token from/to the database. A token is any string associated with a key. pub unsafe fn dc_token_save( - context: &dc_context_t, + context: &Context, namespc: dc_tokennamespc_t, foreign_id: uint32_t, token: *const libc::c_char, @@ -33,7 +33,7 @@ pub unsafe fn dc_token_save( sqlite3_finalize(stmt); } pub unsafe fn dc_token_lookup( - context: &dc_context_t, + context: &Context, namespc: dc_tokennamespc_t, foreign_id: uint32_t, ) -> *mut libc::c_char { @@ -55,7 +55,7 @@ pub unsafe fn dc_token_lookup( } pub unsafe fn dc_token_exists( - context: &dc_context_t, + context: &Context, namespc: dc_tokennamespc_t, token: *const libc::c_char, ) -> libc::c_int { diff --git a/src/dc_tools.rs b/src/dc_tools.rs index d6b1f6933..bb7bf204a 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -3,15 +3,15 @@ use std::fs; use mmime::mailimf_types::*; use rand::{thread_rng, Rng}; +use crate::context::Context; use crate::dc_array::*; -use crate::dc_context::dc_context_t; use crate::dc_log::*; use crate::dc_strbuilder::*; use crate::types::*; use crate::x::*; /* Some tools and enhancements to the used libraries, there should be -no references to dc_context_t and other "larger" classes here. */ +no references to Context and other "larger" classes here. */ // for carray etc. /* ** library-private **********************************************************/ /* math tools */ @@ -867,7 +867,7 @@ pub unsafe fn dc_gm2local_offset() -> time_t { } /* timesmearing */ -pub unsafe fn dc_smeared_time(context: &dc_context_t) -> time_t { +pub unsafe fn dc_smeared_time(context: &Context) -> time_t { /* function returns a corrected time(NULL) */ let mut now: time_t = time(0 as *mut time_t); let ts = *context.last_smeared_timestamp.clone().read().unwrap(); @@ -878,7 +878,7 @@ pub unsafe fn dc_smeared_time(context: &dc_context_t) -> time_t { now } -pub unsafe fn dc_create_smeared_timestamp(context: &dc_context_t) -> time_t { +pub unsafe fn dc_create_smeared_timestamp(context: &Context) -> time_t { let now: time_t = time(0 as *mut time_t); let mut ret: time_t = now; @@ -893,7 +893,7 @@ pub unsafe fn dc_create_smeared_timestamp(context: &dc_context_t) -> time_t { ret } -pub unsafe fn dc_create_smeared_timestamps(context: &dc_context_t, count: libc::c_int) -> time_t { +pub unsafe fn dc_create_smeared_timestamps(context: &Context, count: libc::c_int) -> time_t { /* get a range to timestamps that can be used uniquely */ let now = time(0 as *mut time_t); let start = now + (if count < 5 { count } else { 5 }) as time_t - count as time_t; @@ -1252,7 +1252,7 @@ pub unsafe fn dc_get_filemeta( } pub unsafe fn dc_get_abs_path( - context: &dc_context_t, + context: &Context, pathNfilename: *const libc::c_char, ) -> *mut libc::c_char { let current_block: u64; @@ -1292,10 +1292,7 @@ pub unsafe fn dc_get_abs_path( pathNfilename_abs } -pub unsafe fn dc_file_exist( - context: &dc_context_t, - pathNfilename: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_file_exist(context: &Context, pathNfilename: *const libc::c_char) -> libc::c_int { let pathNfilename_abs = dc_get_abs_path(context, pathNfilename); if pathNfilename_abs.is_null() { return 0; @@ -1314,10 +1311,7 @@ pub unsafe fn dc_file_exist( exist as libc::c_int } -pub unsafe fn dc_get_filebytes( - context: &dc_context_t, - pathNfilename: *const libc::c_char, -) -> uint64_t { +pub unsafe fn dc_get_filebytes(context: &Context, pathNfilename: *const libc::c_char) -> uint64_t { let pathNfilename_abs = dc_get_abs_path(context, pathNfilename); if pathNfilename_abs.is_null() { return 0; @@ -1337,10 +1331,7 @@ pub unsafe fn dc_get_filebytes( filebytes as uint64_t } -pub unsafe fn dc_delete_file( - context: &dc_context_t, - pathNfilename: *const libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_delete_file(context: &Context, pathNfilename: *const libc::c_char) -> libc::c_int { let mut success: libc::c_int = 0i32; let pathNfilename_abs = dc_get_abs_path(context, pathNfilename); if pathNfilename_abs.is_null() { @@ -1377,7 +1368,7 @@ pub unsafe fn dc_delete_file( } pub unsafe fn dc_copy_file( - context: &dc_context_t, + context: &Context, src: *const libc::c_char, dest: *const libc::c_char, ) -> libc::c_int { @@ -1414,7 +1405,7 @@ pub unsafe fn dc_copy_file( } pub unsafe fn dc_create_folder( - context: &dc_context_t, + context: &Context, pathNfilename: *const libc::c_char, ) -> libc::c_int { let mut success = 0; @@ -1446,7 +1437,7 @@ pub unsafe fn dc_create_folder( } pub unsafe fn dc_write_file( - context: &dc_context_t, + context: &Context, pathNfilename: *const libc::c_char, buf: *const libc::c_void, buf_bytes: size_t, @@ -1483,7 +1474,7 @@ pub unsafe fn dc_write_file( } pub unsafe fn dc_read_file( - context: &dc_context_t, + context: &Context, pathNfilename: *const libc::c_char, buf: *mut *mut libc::c_void, buf_bytes: *mut size_t, @@ -1529,7 +1520,7 @@ pub unsafe fn dc_read_file( } pub unsafe fn dc_get_fine_pathNfilename( - context: &dc_context_t, + context: &Context, pathNfolder: *const libc::c_char, desired_filenameNsuffix__: *const libc::c_char, ) -> *mut libc::c_char { @@ -1586,7 +1577,7 @@ pub unsafe fn dc_get_fine_pathNfilename( } // TODO should return bool /rtn -pub unsafe fn dc_is_blobdir_path(context: &dc_context_t, path: *const libc::c_char) -> libc::c_int { +pub unsafe fn dc_is_blobdir_path(context: &Context, path: *const libc::c_char) -> libc::c_int { 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 { @@ -1596,7 +1587,7 @@ pub unsafe fn dc_is_blobdir_path(context: &dc_context_t, path: *const libc::c_ch 0 } -pub unsafe fn dc_make_rel_path(context: &dc_context_t, path: *mut *mut libc::c_char) { +pub unsafe fn dc_make_rel_path(context: &Context, path: *mut *mut libc::c_char) { if path.is_null() || (*path).is_null() { return; } @@ -1610,10 +1601,7 @@ pub unsafe fn dc_make_rel_path(context: &dc_context_t, path: *mut *mut libc::c_c } // TODO should return bool /rtn -pub unsafe fn dc_make_rel_and_copy( - context: &dc_context_t, - path: *mut *mut libc::c_char, -) -> libc::c_int { +pub unsafe fn dc_make_rel_and_copy(context: &Context, path: *mut *mut libc::c_char) -> libc::c_int { let mut success: libc::c_int = 0i32; let mut filename: *mut libc::c_char = 0 as *mut libc::c_char; let mut blobdir_path: *mut libc::c_char = 0 as *mut libc::c_char; diff --git a/src/dc_imap.rs b/src/imap.rs similarity index 98% rename from src/dc_imap.rs rename to src/imap.rs index dfb664cba..e39d32f87 100644 --- a/src/dc_imap.rs +++ b/src/imap.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, Condvar, Mutex, RwLock}; use std::time::{Duration, SystemTime}; use crate::constants::*; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_log::*; use crate::dc_loginparam::*; use crate::dc_sqlite3::*; @@ -371,7 +371,7 @@ impl Imap { self.config.read().unwrap().should_reconnect } - fn setup_handle_if_needed(&self, context: &dc_context_t) -> libc::c_int { + fn setup_handle_if_needed(&self, context: &Context) -> libc::c_int { if self.should_reconnect() { self.unsetup_handle(context); } @@ -475,7 +475,7 @@ impl Imap { } } - fn unsetup_handle(&self, context: &dc_context_t) { + fn unsetup_handle(&self, context: &Context) { let session = self.session.lock().unwrap().0.take(); if session.is_some() { match session.unwrap().close() { @@ -516,7 +516,7 @@ impl Imap { cfg.watch_folder = None; } - pub fn connect(&self, context: &dc_context_t, lp: *const dc_loginparam_t) -> libc::c_int { + pub fn connect(&self, context: &Context, lp: *const dc_loginparam_t) -> libc::c_int { if lp.is_null() { return 0; } @@ -585,7 +585,7 @@ impl Imap { } } - pub fn disconnect(&self, context: &dc_context_t) { + pub fn disconnect(&self, context: &Context) { if self.is_connected() { self.unsetup_handle(context); self.free_connect_params(); @@ -597,7 +597,7 @@ impl Imap { self.config.write().unwrap().watch_folder = Some(to_string(watch_folder)); } - pub fn fetch(&self, context: &dc_context_t) -> libc::c_int { + pub fn fetch(&self, context: &Context) -> libc::c_int { if !self.is_connected() { return 0; } @@ -621,7 +621,7 @@ impl Imap { } } - fn select_folder>(&self, context: &dc_context_t, folder: Option) -> usize { + fn select_folder>(&self, context: &Context, folder: Option) -> usize { if self.session.lock().unwrap().0.is_none() { let mut cfg = self.config.write().unwrap(); cfg.selected_folder = None; @@ -695,11 +695,7 @@ impl Imap { 1 } - fn get_config_last_seen_uid>( - &self, - context: &dc_context_t, - folder: S, - ) -> (u32, u32) { + fn get_config_last_seen_uid>(&self, context: &Context, folder: S) -> (u32, u32) { let key = format!("imap.mailbox.{}", folder.as_ref()); let val1 = unsafe { (self.get_config)( @@ -721,7 +717,7 @@ impl Imap { ) } - fn fetch_from_single_folder>(&self, context: &dc_context_t, folder: S) -> usize { + fn fetch_from_single_folder>(&self, context: &Context, folder: S) -> usize { if !self.is_connected() { info!( context, @@ -916,7 +912,7 @@ impl Imap { fn set_config_last_seen_uid>( &self, - context: &dc_context_t, + context: &Context, folder: S, uidvalidity: u32, lastseenuid: u32, @@ -935,7 +931,7 @@ impl Imap { fn fetch_single_msg>( &self, - context: &dc_context_t, + context: &Context, folder: S, server_uid: u32, ) -> usize { @@ -1031,7 +1027,7 @@ impl Imap { } } - pub fn idle(&self, context: &dc_context_t) { + pub fn idle(&self, context: &Context) { if !self.config.read().unwrap().can_idle { return self.fake_idle(context); } @@ -1126,7 +1122,7 @@ impl Imap { *watch = false; } - fn fake_idle(&self, context: &dc_context_t) { + fn fake_idle(&self, context: &Context) { // Idle using timeouts. This is also needed if we're not yet configured - // in this case, we're waiting for a configure job let fake_idle_start_time = SystemTime::now(); @@ -1194,7 +1190,7 @@ impl Imap { pub fn mv, S2: AsRef>( &self, - context: &dc_context_t, + context: &Context, folder: S1, uid: u32, dest_folder: S2, @@ -1325,7 +1321,7 @@ impl Imap { } } - pub fn set_seen>(&self, context: &dc_context_t, folder: S, uid: u32) -> usize { + pub fn set_seen>(&self, context: &Context, folder: S, uid: u32) -> usize { let mut res = DC_RETRY_LATER; if uid == 0 { @@ -1366,7 +1362,7 @@ impl Imap { } } - pub fn set_mdnsent>(&self, context: &dc_context_t, folder: S, uid: u32) -> usize { + pub fn set_mdnsent>(&self, context: &Context, folder: S, uid: u32) -> usize { // returns 0=job should be retried later, 1=job done, 2=job done and flag just set let mut res = DC_RETRY_LATER; let set = format!("{}", uid); @@ -1484,7 +1480,7 @@ impl Imap { // only returns 0 on connection problems; we should try later again in this case * pub fn delete_msg, S2: AsRef>( &self, - context: &dc_context_t, + context: &Context, message_id: S1, folder: S2, server_uid: &mut u32, @@ -1575,7 +1571,7 @@ impl Imap { } } - pub fn configure_folders(&self, context: &dc_context_t, flags: libc::c_int) { + pub fn configure_folders(&self, context: &Context, flags: libc::c_int) { if !self.is_connected() { return; } @@ -1670,7 +1666,7 @@ impl Imap { fn list_folders( &self, - context: &dc_context_t, + context: &Context, ) -> Option>> { if let Some(ref mut session) = self.session.lock().unwrap().0 { // TODO: use xlist when available diff --git a/src/dc_key.rs b/src/key.rs similarity index 97% rename from src/dc_key.rs rename to src/key.rs index af3fba42c..ddd64f9ed 100644 --- a/src/dc_key.rs +++ b/src/key.rs @@ -9,7 +9,7 @@ use pgp::ser::Serialize; use pgp::types::{KeyTrait, SecretKeyTrait}; use crate::constants::*; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_log::*; use crate::dc_sqlite3::*; use crate::dc_tools::*; @@ -143,7 +143,7 @@ impl Key { } pub fn from_self_public( - context: &dc_context_t, + context: &Context, self_addr: *const libc::c_char, sql: &dc_sqlite3_t, ) -> Option { @@ -173,7 +173,7 @@ impl Key { } pub fn from_self_private( - context: &dc_context_t, + context: &Context, self_addr: *const libc::c_char, sql: &dc_sqlite3_t, ) -> Option { @@ -270,7 +270,7 @@ impl Key { unsafe { strdup(buf_c.as_ptr()) } } - pub fn write_asc_to_file(&self, file: *const libc::c_char, context: &dc_context_t) -> bool { + pub fn write_asc_to_file(&self, file: *const libc::c_char, context: &Context) -> bool { if file.is_null() { return false; } @@ -333,7 +333,7 @@ impl Key { } pub fn dc_key_save_self_keypair( - context: &dc_context_t, + context: &Context, public_key: &Key, private_key: &Key, addr: *const libc::c_char, @@ -455,7 +455,7 @@ mod tests { #[test] fn test_from_slice_roundtrip() { let (public_key, private_key) = - crate::dc_pgp::dc_pgp_create_keypair(CString::new("hello").unwrap().as_ptr()).unwrap(); + crate::pgp::dc_pgp_create_keypair(CString::new("hello").unwrap().as_ptr()).unwrap(); let binary = public_key.to_bytes(); let public_key2 = Key::from_slice(&binary, KeyType::Public).expect("invalid public key"); diff --git a/src/dc_keyhistory.rs b/src/keyhistory.rs similarity index 79% rename from src/dc_keyhistory.rs rename to src/keyhistory.rs index beb077042..285b795f3 100644 --- a/src/dc_keyhistory.rs +++ b/src/keyhistory.rs @@ -1,10 +1,10 @@ -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::types::*; /* yes: uppercase */ /* library private: key-history */ pub fn dc_add_to_keyhistory( - _context: &dc_context_t, + _context: &Context, _rfc724_mid: *const libc::c_char, _sending_time: time_t, _addr: *const libc::c_char, diff --git a/src/dc_keyring.rs b/src/keyring.rs similarity index 93% rename from src/dc_keyring.rs rename to src/keyring.rs index ff28187f0..18180052a 100644 --- a/src/dc_keyring.rs +++ b/src/keyring.rs @@ -1,9 +1,9 @@ use std::borrow::Cow; use crate::constants::*; -use crate::dc_context::dc_context_t; -use crate::dc_key::*; +use crate::context::Context; use crate::dc_sqlite3::*; +use crate::key::*; use crate::types::*; #[derive(Default, Clone, Debug)] @@ -30,7 +30,7 @@ impl<'a> Keyring<'a> { pub fn load_self_private_for_decrypting( &mut self, - context: &dc_context_t, + context: &Context, self_addr: *const libc::c_char, sql: &dc_sqlite3_t, ) -> bool { diff --git a/src/lib.rs b/src/lib.rs index 5cdab0454..1e48a2f8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,29 +22,30 @@ extern crate smallvec; #[macro_use] pub mod dc_log; +pub mod aheader; +pub mod constants; +pub mod context; +pub mod imap; +pub mod key; +pub mod keyhistory; +pub mod keyring; pub mod oauth2; pub mod peerstate; +pub mod pgp; +pub mod smtp; pub mod types; pub mod x; -pub mod constants; - -pub mod dc_aheader; pub mod dc_array; pub mod dc_chat; pub mod dc_chatlist; pub mod dc_configure; pub mod dc_contact; -pub mod dc_context; pub mod dc_dehtml; pub mod dc_e2ee; -pub mod dc_imap; pub mod dc_imex; pub mod dc_job; pub mod dc_jobthread; -pub mod dc_key; -pub mod dc_keyhistory; -pub mod dc_keyring; pub mod dc_location; pub mod dc_loginparam; pub mod dc_lot; @@ -53,13 +54,11 @@ pub mod dc_mimeparser; pub mod dc_move; pub mod dc_msg; pub mod dc_param; -pub mod dc_pgp; pub mod dc_qr; pub mod dc_receive_imf; pub mod dc_saxparser; pub mod dc_securejoin; pub mod dc_simplify; -pub mod dc_smtp; pub mod dc_sqlite3; pub mod dc_stock; pub mod dc_strbuilder; diff --git a/src/oauth2.rs b/src/oauth2.rs index ef6540a60..5eafa3a7e 100644 --- a/src/oauth2.rs +++ b/src/oauth2.rs @@ -4,7 +4,7 @@ use std::ffi::CString; use percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; use serde::Deserialize; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_log::*; use crate::dc_sqlite3::*; use crate::dc_tools::*; @@ -48,7 +48,7 @@ struct Response { } pub fn dc_get_oauth2_url( - context: &dc_context_t, + context: &Context, addr: impl AsRef, redirect_uri: impl AsRef, ) -> Option { @@ -70,7 +70,7 @@ pub fn dc_get_oauth2_url( // The following function may block due http-requests; // must not be called from the main thread or by the ui! pub fn dc_get_oauth2_access_token( - context: &dc_context_t, + context: &Context, addr: impl AsRef, code: impl AsRef, flags: usize, @@ -191,7 +191,7 @@ pub fn dc_get_oauth2_access_token( } pub fn dc_get_oauth2_addr( - context: &dc_context_t, + context: &Context, addr: impl AsRef, code: impl AsRef, ) -> Option { @@ -239,7 +239,7 @@ impl Oauth2 { } } - fn get_addr(&self, context: &dc_context_t, access_token: impl AsRef) -> Option { + fn get_addr(&self, context: &Context, access_token: impl AsRef) -> Option { let userinfo_url = self.get_userinfo.unwrap_or_else(|| ""); let userinfo_url = replace_in_uri(&userinfo_url, "$ACCESS_TOKEN", access_token); @@ -292,7 +292,7 @@ impl Oauth2 { } } -fn get_config(context: &dc_context_t, key: &str) -> Option { +fn get_config(context: &Context, key: &str) -> Option { let key_c = CString::new(key).unwrap(); let res = unsafe { dc_sqlite3_get_config( @@ -309,7 +309,7 @@ fn get_config(context: &dc_context_t, key: &str) -> Option { Some(to_string(res)) } -fn set_config(context: &dc_context_t, key: &str, value: &str) { +fn set_config(context: &Context, key: &str, value: &str) { let key_c = CString::new(key).unwrap(); let value_c = CString::new(value).unwrap(); unsafe { @@ -322,7 +322,7 @@ fn set_config(context: &dc_context_t, key: &str, value: &str) { }; } -fn set_config_int64(context: &dc_context_t, key: &str, value: i64) { +fn set_config_int64(context: &Context, key: &str, value: i64) { let key_c = CString::new(key).unwrap(); unsafe { dc_sqlite3_set_config_int64( @@ -334,7 +334,7 @@ fn set_config_int64(context: &dc_context_t, key: &str, value: i64) { }; } -fn is_expired(context: &dc_context_t) -> bool { +fn is_expired(context: &Context) -> bool { let expire_timestamp = unsafe { dc_sqlite3_get_config_int64( context, diff --git a/src/peerstate.rs b/src/peerstate.rs index 2b5a6c37d..21e058acb 100644 --- a/src/peerstate.rs +++ b/src/peerstate.rs @@ -3,18 +3,18 @@ use std::ffi::CString; use num_traits::FromPrimitive; +use crate::aheader::*; use crate::constants::*; -use crate::dc_aheader::*; +use crate::context::Context; use crate::dc_chat::*; -use crate::dc_context::dc_context_t; -use crate::dc_key::*; use crate::dc_sqlite3::*; use crate::dc_tools::{to_cstring, to_string}; +use crate::key::*; use crate::types::*; /// Peerstate represents the state of an Autocrypt peer. pub struct Peerstate<'a> { - pub context: &'a dc_context_t, + pub context: &'a Context, pub addr: Option, pub last_seen: u64, pub last_seen_autocrypt: u64, @@ -73,7 +73,7 @@ impl VerifiedKey { } impl<'a> Peerstate<'a> { - pub fn new(context: &'a dc_context_t) -> Self { + pub fn new(context: &'a Context) -> Self { Peerstate { context, addr: None, @@ -100,7 +100,7 @@ impl<'a> Peerstate<'a> { } } - pub fn from_header(context: &'a dc_context_t, header: &Aheader, message_time: u64) -> Self { + pub fn from_header(context: &'a Context, header: &Aheader, message_time: u64) -> Self { let mut res = Self::new(context); res.addr = Some(header.addr.clone()); @@ -114,11 +114,7 @@ impl<'a> Peerstate<'a> { res } - pub fn from_gossip( - context: &'a dc_context_t, - gossip_header: &Aheader, - message_time: u64, - ) -> Self { + pub fn from_gossip(context: &'a Context, gossip_header: &Aheader, message_time: u64) -> Self { let mut res = Self::new(context); res.addr = Some(gossip_header.addr.clone()); @@ -130,7 +126,7 @@ impl<'a> Peerstate<'a> { res } - pub fn from_addr(context: &'a dc_context_t, sql: &dc_sqlite3_t, addr: &str) -> Option { + pub fn from_addr(context: &'a Context, sql: &dc_sqlite3_t, addr: &str) -> Option { let mut res = None; let stmt = unsafe { @@ -151,7 +147,7 @@ impl<'a> Peerstate<'a> { } pub fn from_fingerprint( - context: &'a dc_context_t, + context: &'a Context, sql: &dc_sqlite3_t, fingerprint: &str, ) -> Option { @@ -180,7 +176,7 @@ impl<'a> Peerstate<'a> { res } - fn from_stmt(context: &'a dc_context_t, stmt: *mut sqlite3_stmt) -> Self { + fn from_stmt(context: &'a Context, stmt: *mut sqlite3_stmt) -> Self { let mut res = Self::new(context); res.addr = Some(to_string(unsafe { diff --git a/src/dc_pgp.rs b/src/pgp.rs similarity index 99% rename from src/dc_pgp.rs rename to src/pgp.rs index 0b91550c6..423ac0f3d 100644 --- a/src/dc_pgp.rs +++ b/src/pgp.rs @@ -12,9 +12,9 @@ use pgp::types::{CompressionAlgorithm, KeyTrait, SecretKeyTrait, StringToKey}; use rand::thread_rng; use sha2::{Digest, Sha256}; -use crate::dc_key::*; -use crate::dc_keyring::*; use crate::dc_tools::*; +use crate::key::*; +use crate::keyring::*; use crate::types::*; use crate::x::*; diff --git a/src/dc_smtp.rs b/src/smtp.rs similarity index 97% rename from src/dc_smtp.rs rename to src/smtp.rs index 5bcf70713..0365f2b24 100644 --- a/src/dc_smtp.rs +++ b/src/smtp.rs @@ -5,7 +5,7 @@ use lettre::*; use crate::constants::Event; use crate::constants::*; -use crate::dc_context::dc_context_t; +use crate::context::Context; use crate::dc_log::*; use crate::dc_loginparam::*; use crate::dc_tools::*; @@ -48,7 +48,7 @@ impl Smtp { } /// Connect using the provided login params - pub fn connect(&mut self, context: &dc_context_t, lp: *const dc_loginparam_t) -> usize { + pub fn connect(&mut self, context: &Context, lp: *const dc_loginparam_t) -> usize { if lp.is_null() { return 0; } @@ -153,7 +153,7 @@ impl Smtp { pub fn send<'a>( &mut self, - context: &dc_context_t, + context: &Context, recipients: Vec, body: Vec, ) -> usize { diff --git a/src/types.rs b/src/types.rs index 21de554de..53037ef40 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,5 @@ use crate::constants::Event; -use crate::dc_context::dc_context_t; +use crate::context::Context; pub use libc::{dirent, tm, DIR, FILE}; pub use libsqlite3_sys::*; @@ -25,7 +25,7 @@ pub type uint64_t = libc::c_ulonglong; /** * Callback function that should be given to dc_context_new(). * - * @memberof dc_context_t + * @memberof Context * @param context The context object as returned by dc_context_new(). * @param event one of the @ref DC_EVENT constants * @param data1 depends on the event parameter @@ -33,12 +33,12 @@ pub type uint64_t = libc::c_ulonglong; * @return return 0 unless stated otherwise in the event parameter documentation */ pub type dc_callback_t = - unsafe extern "C" fn(_: &dc_context_t, _: Event, _: uintptr_t, _: uintptr_t) -> uintptr_t; + unsafe extern "C" fn(_: &Context, _: Event, _: uintptr_t, _: uintptr_t) -> uintptr_t; pub type dc_move_state_t = u32; pub type dc_receive_imf_t = unsafe fn( - _: &dc_context_t, + _: &Context, _: *const libc::c_char, _: size_t, _: *const libc::c_char, @@ -47,22 +47,15 @@ pub type dc_receive_imf_t = unsafe fn( ) -> (); /* Purpose: Reading from IMAP servers with no dependencies to the database. -dc_context_t is only used for logging and to get information about +Context is only used for logging and to get information about the online state. */ -pub type dc_precheck_imf_t = unsafe fn( - _: &dc_context_t, - _: *const libc::c_char, - _: *const libc::c_char, - _: u32, -) -> libc::c_int; +pub type dc_precheck_imf_t = + unsafe fn(_: &Context, _: *const libc::c_char, _: *const libc::c_char, _: u32) -> libc::c_int; pub type dc_set_config_t = - unsafe fn(_: &dc_context_t, _: *const libc::c_char, _: *const libc::c_char) -> (); -pub type dc_get_config_t = unsafe fn( - _: &dc_context_t, - _: *const libc::c_char, - _: *const libc::c_char, -) -> *mut libc::c_char; + unsafe fn(_: &Context, _: *const libc::c_char, _: *const libc::c_char) -> (); +pub type dc_get_config_t = + unsafe fn(_: &Context, _: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; pub type sqlite_int64 = libc::int64_t; pub type sqlite3_int64 = sqlite_int64; diff --git a/tests/stress.rs b/tests/stress.rs index ecb0daa0e..e4f11b519 100644 --- a/tests/stress.rs +++ b/tests/stress.rs @@ -7,24 +7,24 @@ use mmime::mailimf_types::*; use tempfile::{tempdir, TempDir}; use deltachat::constants::*; +use deltachat::context::*; use deltachat::dc_array::*; use deltachat::dc_configure::*; -use deltachat::dc_context::*; use deltachat::dc_imex::*; -use deltachat::dc_key::*; -use deltachat::dc_keyring::*; use deltachat::dc_location::*; use deltachat::dc_lot::*; use deltachat::dc_mimeparser::*; use deltachat::dc_param::*; -use deltachat::dc_pgp::*; use deltachat::dc_qr::*; use deltachat::dc_saxparser::*; use deltachat::dc_securejoin::*; use deltachat::dc_strbuilder::*; use deltachat::dc_strencode::*; use deltachat::dc_tools::*; +use deltachat::key::*; +use deltachat::keyring::*; use deltachat::oauth2::*; +use deltachat::pgp::*; use deltachat::types::*; use deltachat::x::*; use libc; @@ -39,7 +39,7 @@ static mut S_EM_SETUPFILE: *const libc::c_char = b"-----BEGIN PGP MESSAGE-----\nPassphrase-Format: numeric9x4\nPassphrase-Begin: 17\n\n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\nmngm1QCMMw2v/j8=\n=9sJE\n-----END PGP MESSAGE-----\n\x00" as *const u8 as *const libc::c_char; -unsafe fn stress_functions(context: &dc_context_t) { +unsafe fn stress_functions(context: &Context) { let mut saxparser: dc_saxparser_t = dc_saxparser_t { starttag_cb: None, endtag_cb: None, @@ -2385,7 +2385,7 @@ fn test_encryption_decryption() { } unsafe extern "C" fn cb( - _context: &dc_context_t, + _context: &Context, _event: Event, _data1: uintptr_t, _data2: uintptr_t, @@ -2395,7 +2395,7 @@ unsafe extern "C" fn cb( #[allow(dead_code)] struct TestContext { - ctx: dc_context_t, + ctx: Context, dir: TempDir, }