mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
feat: enforce Debug implementations and remove mod types
This commit is contained in:
committed by
Floris Bruynooghe
parent
c2501258b6
commit
f31f341a50
43
Cargo.lock
generated
43
Cargo.lock
generated
@@ -470,6 +470,15 @@ dependencies = [
|
|||||||
"syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "debug_stub_derive"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deltachat"
|
name = "deltachat"
|
||||||
version = "1.0.0-alpha.4"
|
version = "1.0.0-alpha.4"
|
||||||
@@ -481,6 +490,7 @@ dependencies = [
|
|||||||
"cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"charset 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"charset 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"debug_stub_derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"deltachat_derive 0.1.0",
|
"deltachat_derive 0.1.0",
|
||||||
"escaper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"escaper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -1723,6 +1733,11 @@ dependencies = [
|
|||||||
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "0.3.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "0.6.13"
|
version = "0.6.13"
|
||||||
@@ -2338,6 +2353,16 @@ name = "subtle"
|
|||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "0.11.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "0.14.9"
|
version = "0.14.9"
|
||||||
@@ -2368,6 +2393,14 @@ dependencies = [
|
|||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synom"
|
||||||
|
version = "0.11.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
@@ -2641,6 +2674,11 @@ name = "unicode-width"
|
|||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2912,6 +2950,7 @@ dependencies = [
|
|||||||
"checksum darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fcfbcb0c5961907597a7d1148e3af036268f2b773886b8bb3eeb1e1281d3d3d6"
|
"checksum darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fcfbcb0c5961907597a7d1148e3af036268f2b773886b8bb3eeb1e1281d3d3d6"
|
||||||
"checksum darling_core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6afc018370c3bff3eb51f89256a6bdb18b4fdcda72d577982a14954a7a0b402c"
|
"checksum darling_core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6afc018370c3bff3eb51f89256a6bdb18b4fdcda72d577982a14954a7a0b402c"
|
||||||
"checksum darling_macro 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d8dac1c6f1d29a41c4712b4400f878cb4fcc4c7628f298dd75038e024998d1"
|
"checksum darling_macro 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d8dac1c6f1d29a41c4712b4400f878cb4fcc4c7628f298dd75038e024998d1"
|
||||||
|
"checksum debug_stub_derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "496b7f8a2f853313c3ca370641d7ff3e42c32974fdccda8f0684599ed0a3ff6b"
|
||||||
"checksum derive_builder 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ac53fa6a3cda160df823a9346442525dcaf1e171999a1cf23e67067e4fd64d4"
|
"checksum derive_builder 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ac53fa6a3cda160df823a9346442525dcaf1e171999a1cf23e67067e4fd64d4"
|
||||||
"checksum derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0288a23da9333c246bb18c143426074a6ae96747995c5819d2947b64cd942b37"
|
"checksum derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0288a23da9333c246bb18c143426074a6ae96747995c5819d2947b64cd942b37"
|
||||||
"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839"
|
"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839"
|
||||||
@@ -3039,6 +3078,7 @@ dependencies = [
|
|||||||
"checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15"
|
"checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15"
|
||||||
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
||||||
"checksum quick-xml 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c2b074258da4f2ccb1c450380c5bd8e77db2508de2161f574c70930d8e880482"
|
"checksum quick-xml 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c2b074258da4f2ccb1c450380c5bd8e77db2508de2161f574c70930d8e880482"
|
||||||
|
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
|
||||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||||
"checksum quote 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49d77c41ca8767f2f41394c11a4eebccab83da25e7cc035387a3125f02be90a3"
|
"checksum quote 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49d77c41ca8767f2f41394c11a4eebccab83da25e7cc035387a3125f02be90a3"
|
||||||
"checksum r2d2 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bc42ce75d9f4447fb2a04bbe1ed5d18dd949104572850ec19b164e274919f81b"
|
"checksum r2d2 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bc42ce75d9f4447fb2a04bbe1ed5d18dd949104572850ec19b164e274919f81b"
|
||||||
@@ -3106,9 +3146,11 @@ dependencies = [
|
|||||||
"checksum strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f"
|
"checksum strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f"
|
||||||
"checksum strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e"
|
"checksum strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e"
|
||||||
"checksum subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01f40907d9ffc762709e4ff3eb4a6f6b41b650375a3f09ac92b641942b7fb082"
|
"checksum subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01f40907d9ffc762709e4ff3eb4a6f6b41b650375a3f09ac92b641942b7fb082"
|
||||||
|
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
|
||||||
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
|
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
|
||||||
"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
||||||
"checksum syn 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2ae5cd13590144ea968ba5d5520da7a4c08415861014399b5b349f74591c375f"
|
"checksum syn 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2ae5cd13590144ea968ba5d5520da7a4c08415861014399b5b349f74591c375f"
|
||||||
|
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
|
||||||
"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
|
"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
|
||||||
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||||
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
||||||
@@ -3138,6 +3180,7 @@ dependencies = [
|
|||||||
"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
|
"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
|
||||||
"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9"
|
"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9"
|
||||||
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
|
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
|
||||||
|
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
|
||||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||||
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ quick-xml = "0.15.0"
|
|||||||
escaper = "0.1.0"
|
escaper = "0.1.0"
|
||||||
bitflags = "1.1.0"
|
bitflags = "1.1.0"
|
||||||
jetscii = "0.4.4"
|
jetscii = "0.4.4"
|
||||||
|
debug_stub_derive = "0.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.0"
|
tempfile = "3.0"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ use deltachat::message::*;
|
|||||||
use deltachat::peerstate::*;
|
use deltachat::peerstate::*;
|
||||||
use deltachat::qr::*;
|
use deltachat::qr::*;
|
||||||
use deltachat::sql;
|
use deltachat::sql;
|
||||||
use deltachat::types::*;
|
|
||||||
use deltachat::x::*;
|
use deltachat::x::*;
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ unsafe fn dc_poke_eml_file(context: &Context, filename: *const libc::c_char) ->
|
|||||||
/* mainly for testing, may be called by dc_import_spec() */
|
/* mainly for testing, may be called by dc_import_spec() */
|
||||||
let mut success: libc::c_int = 0i32;
|
let mut success: libc::c_int = 0i32;
|
||||||
let mut data: *mut libc::c_char = ptr::null_mut();
|
let mut data: *mut libc::c_char = ptr::null_mut();
|
||||||
let mut data_bytes: size_t = 0;
|
let mut data_bytes = 0;
|
||||||
if !(dc_read_file(
|
if !(dc_read_file(
|
||||||
context,
|
context,
|
||||||
filename,
|
filename,
|
||||||
@@ -199,7 +198,11 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
|
|||||||
as_str(real_spec)
|
as_str(real_spec)
|
||||||
);
|
);
|
||||||
if read_cnt > 0 {
|
if read_cnt > 0 {
|
||||||
context.call_cb(Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t);
|
context.call_cb(
|
||||||
|
Event::MSGS_CHANGED,
|
||||||
|
0 as libc::uintptr_t,
|
||||||
|
0 as libc::uintptr_t,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
success = 1
|
success = 1
|
||||||
}
|
}
|
||||||
@@ -615,7 +618,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if location::is_sending_locations_to_chat(context, 0 as uint32_t) {
|
if location::is_sending_locations_to_chat(context, 0) {
|
||||||
info!(context, "Location streaming enabled.");
|
info!(context, "Location streaming enabled.");
|
||||||
}
|
}
|
||||||
println!("{} chats", cnt);
|
println!("{} chats", cnt);
|
||||||
@@ -664,7 +667,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
|||||||
"createchat" => {
|
"createchat" => {
|
||||||
ensure!(!arg1.is_empty(), "Argument <contact-id> missing.");
|
ensure!(!arg1.is_empty(), "Argument <contact-id> missing.");
|
||||||
let contact_id: libc::c_int = arg1.parse()?;
|
let contact_id: libc::c_int = arg1.parse()?;
|
||||||
let chat_id = chat::create_by_contact_id(context, contact_id as uint32_t)?;
|
let chat_id = chat::create_by_contact_id(context, contact_id as u32)?;
|
||||||
|
|
||||||
println!("Single#{} created successfully.", chat_id,);
|
println!("Single#{} created successfully.", chat_id,);
|
||||||
}
|
}
|
||||||
@@ -696,7 +699,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
|||||||
if chat::add_contact_to_chat(
|
if chat::add_contact_to_chat(
|
||||||
context,
|
context,
|
||||||
sel_chat.as_ref().unwrap().get_id(),
|
sel_chat.as_ref().unwrap().get_id(),
|
||||||
contact_id_0 as uint32_t,
|
contact_id_0 as u32,
|
||||||
) {
|
) {
|
||||||
println!("Contact added to chat.");
|
println!("Contact added to chat.");
|
||||||
} else {
|
} else {
|
||||||
@@ -710,7 +713,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
|||||||
chat::remove_contact_from_chat(
|
chat::remove_contact_from_chat(
|
||||||
context,
|
context,
|
||||||
sel_chat.as_ref().unwrap().get_id(),
|
sel_chat.as_ref().unwrap().get_id(),
|
||||||
contact_id_1 as uint32_t,
|
contact_id_1 as u32,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
println!("Contact added to chat.");
|
println!("Contact added to chat.");
|
||||||
@@ -1017,7 +1020,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
|||||||
ensure!(!arg1.is_empty(), "Argument <id> missing.");
|
ensure!(!arg1.is_empty(), "Argument <id> missing.");
|
||||||
let event = arg1.parse()?;
|
let event = arg1.parse()?;
|
||||||
let event = Event::from_u32(event).ok_or(format_err!("Event::from_u32({})", event))?;
|
let event = Event::from_u32(event).ok_or(format_err!("Event::from_u32({})", event))?;
|
||||||
let r = context.call_cb(event, 0 as uintptr_t, 0 as uintptr_t);
|
let r = context.call_cb(event, 0 as libc::uintptr_t, 0 as libc::uintptr_t);
|
||||||
println!(
|
println!(
|
||||||
"Sending event {:?}({}), received value {}.",
|
"Sending event {:?}({}), received value {}.",
|
||||||
event, event as usize, r as libc::c_int,
|
event, event as usize, r as libc::c_int,
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use deltachat::dc_tools::*;
|
|||||||
use deltachat::job::*;
|
use deltachat::job::*;
|
||||||
use deltachat::oauth2::*;
|
use deltachat::oauth2::*;
|
||||||
use deltachat::securejoin::*;
|
use deltachat::securejoin::*;
|
||||||
use deltachat::types::*;
|
|
||||||
use deltachat::x::*;
|
use deltachat::x::*;
|
||||||
use rustyline::completion::{Completer, FilenameCompleter, Pair};
|
use rustyline::completion::{Completer, FilenameCompleter, Pair};
|
||||||
use rustyline::config::OutputStreamType;
|
use rustyline::config::OutputStreamType;
|
||||||
@@ -47,9 +46,9 @@ use self::cmdline::*;
|
|||||||
fn receive_event(
|
fn receive_event(
|
||||||
_context: &Context,
|
_context: &Context,
|
||||||
event: Event,
|
event: Event,
|
||||||
data1: uintptr_t,
|
data1: libc::uintptr_t,
|
||||||
data2: uintptr_t,
|
data2: libc::uintptr_t,
|
||||||
) -> uintptr_t {
|
) -> libc::uintptr_t {
|
||||||
match event {
|
match event {
|
||||||
Event::GET_STRING => {}
|
Event::GET_STRING => {}
|
||||||
Event::INFO => {
|
Event::INFO => {
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
|
use libc::uintptr_t;
|
||||||
|
|
||||||
use crate::chatlist::*;
|
use crate::chatlist::*;
|
||||||
use crate::config::*;
|
use crate::config::*;
|
||||||
@@ -13,15 +16,13 @@ use crate::message::*;
|
|||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::sql::{self, Sql};
|
use crate::sql::{self, Sql};
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
use std::ptr;
|
|
||||||
|
|
||||||
/// An object representing a single chat in memory.
|
/// An object representing a single chat in memory.
|
||||||
/// Chat objects are created using eg. `Chat::load_from_db`
|
/// Chat objects are created using eg. `Chat::load_from_db`
|
||||||
/// and are not updated on database changes;
|
/// and are not updated on database changes;
|
||||||
/// if you want an update, you have to recreate the object.
|
/// if you want an update, you have to recreate the object.
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Chat {
|
pub struct Chat {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
pub typ: Chattype,
|
pub typ: Chattype,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ use crate::stock::StockMessage;
|
|||||||
/// first entry and only present on new messages, there is the rough idea that it can be optionally always
|
/// first entry and only present on new messages, there is the rough idea that it can be optionally always
|
||||||
/// present and sorted into the list by date. Rendering the deaddrop in the described way
|
/// present and sorted into the list by date. Rendering the deaddrop in the described way
|
||||||
/// would not add extra work in the UI then.
|
/// would not add extra work in the UI then.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Chatlist {
|
pub struct Chatlist {
|
||||||
/// Stores pairs of `chat_id, message_id`
|
/// Stores pairs of `chat_id, message_id`
|
||||||
ids: Vec<(u32, u32)>,
|
ids: Vec<(u32, u32)>,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use libc::uintptr_t;
|
||||||
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
||||||
|
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
@@ -9,7 +10,6 @@ use crate::job::*;
|
|||||||
use crate::login_param::LoginParam;
|
use crate::login_param::LoginParam;
|
||||||
use crate::oauth2::*;
|
use crate::oauth2::*;
|
||||||
use crate::param::Params;
|
use crate::param::Params;
|
||||||
use crate::types::*;
|
|
||||||
|
|
||||||
mod auto_outlook;
|
mod auto_outlook;
|
||||||
use auto_outlook::outlk_autodiscover;
|
use auto_outlook::outlk_autodiscover;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use deltachat_derive::*;
|
use deltachat_derive::*;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use libc::uintptr_t;
|
||||||
use rusqlite;
|
use rusqlite;
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use crate::aheader::EncryptPreference;
|
use crate::aheader::EncryptPreference;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
@@ -16,7 +18,6 @@ use crate::message::MessageState;
|
|||||||
use crate::peerstate::*;
|
use crate::peerstate::*;
|
||||||
use crate::sql;
|
use crate::sql;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
|
|
||||||
/// Contacts with at least this origin value are shown in the contact list.
|
/// Contacts with at least this origin value are shown in the contact list.
|
||||||
const DC_ORIGIN_MIN_CONTACT_LIST: i32 = 0x100;
|
const DC_ORIGIN_MIN_CONTACT_LIST: i32 = 0x100;
|
||||||
@@ -31,6 +32,7 @@ const DC_ORIGIN_MIN_CONTACT_LIST: i32 = 0x100;
|
|||||||
/// For this purpose, internally, two names are tracked -
|
/// For this purpose, internally, two names are tracked -
|
||||||
/// authorized-name and given-name.
|
/// authorized-name and given-name.
|
||||||
/// By default, these names are equal, but functions working with contact names
|
/// By default, these names are equal, but functions working with contact names
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Contact {
|
pub struct Contact {
|
||||||
/// The contact ID.
|
/// The contact ID.
|
||||||
///
|
///
|
||||||
|
|||||||
123
src/context.rs
123
src/context.rs
@@ -1,12 +1,11 @@
|
|||||||
|
use libc::uintptr_t;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::ptr;
|
|
||||||
use std::sync::{Arc, Condvar, Mutex, RwLock};
|
use std::sync::{Arc, Condvar, Mutex, RwLock};
|
||||||
|
|
||||||
use crate::chat::*;
|
use crate::chat::*;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::dc_receive_imf::*;
|
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
use crate::error::*;
|
use crate::error::*;
|
||||||
use crate::imap::*;
|
use crate::imap::*;
|
||||||
@@ -19,8 +18,6 @@ use crate::message::*;
|
|||||||
use crate::param::Params;
|
use crate::param::Params;
|
||||||
use crate::smtp::*;
|
use crate::smtp::*;
|
||||||
use crate::sql::Sql;
|
use crate::sql::Sql;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
|
||||||
|
|
||||||
/// Callback function type for [Context]
|
/// Callback function type for [Context]
|
||||||
///
|
///
|
||||||
@@ -37,6 +34,7 @@ use crate::x::*;
|
|||||||
/// description at [Event].
|
/// description at [Event].
|
||||||
pub type ContextCallback = dyn Fn(&Context, Event, uintptr_t, uintptr_t) -> uintptr_t + Send + Sync;
|
pub type ContextCallback = dyn Fn(&Context, Event, uintptr_t, uintptr_t) -> uintptr_t + Send + Sync;
|
||||||
|
|
||||||
|
#[derive(DebugStub)]
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
pub(crate) dbfile: PathBuf,
|
pub(crate) dbfile: PathBuf,
|
||||||
pub(crate) blobdir: PathBuf,
|
pub(crate) blobdir: PathBuf,
|
||||||
@@ -49,6 +47,7 @@ pub struct Context {
|
|||||||
pub smtp: Arc<Mutex<Smtp>>,
|
pub smtp: Arc<Mutex<Smtp>>,
|
||||||
pub smtp_state: Arc<(Mutex<SmtpState>, Condvar)>,
|
pub smtp_state: Arc<(Mutex<SmtpState>, Condvar)>,
|
||||||
pub oauth2_critical: Arc<Mutex<()>>,
|
pub oauth2_critical: Arc<Mutex<()>>,
|
||||||
|
#[debug_stub = "Callback"]
|
||||||
pub cb: Box<ContextCallback>,
|
pub cb: Box<ContextCallback>,
|
||||||
pub os_name: Option<String>,
|
pub os_name: Option<String>,
|
||||||
pub cmdline_sel_chat_id: Arc<RwLock<u32>>,
|
pub cmdline_sel_chat_id: Arc<RwLock<u32>>,
|
||||||
@@ -91,14 +90,7 @@ impl Context {
|
|||||||
let ctx = Context {
|
let ctx = Context {
|
||||||
blobdir,
|
blobdir,
|
||||||
dbfile,
|
dbfile,
|
||||||
inbox: Arc::new(RwLock::new({
|
inbox: Arc::new(RwLock::new(Imap::new())),
|
||||||
Imap::new(
|
|
||||||
cb_get_config,
|
|
||||||
cb_set_config,
|
|
||||||
cb_precheck_imf,
|
|
||||||
cb_receive_imf,
|
|
||||||
)
|
|
||||||
})),
|
|
||||||
cb,
|
cb,
|
||||||
os_name: Some(os_name),
|
os_name: Some(os_name),
|
||||||
running_state: Arc::new(RwLock::new(Default::default())),
|
running_state: Arc::new(RwLock::new(Default::default())),
|
||||||
@@ -112,22 +104,12 @@ impl Context {
|
|||||||
sentbox_thread: Arc::new(RwLock::new(JobThread::new(
|
sentbox_thread: Arc::new(RwLock::new(JobThread::new(
|
||||||
"SENTBOX",
|
"SENTBOX",
|
||||||
"configured_sentbox_folder",
|
"configured_sentbox_folder",
|
||||||
Imap::new(
|
Imap::new(),
|
||||||
cb_get_config,
|
|
||||||
cb_set_config,
|
|
||||||
cb_precheck_imf,
|
|
||||||
cb_receive_imf,
|
|
||||||
),
|
|
||||||
))),
|
))),
|
||||||
mvbox_thread: Arc::new(RwLock::new(JobThread::new(
|
mvbox_thread: Arc::new(RwLock::new(JobThread::new(
|
||||||
"MVBOX",
|
"MVBOX",
|
||||||
"configured_mvbox_folder",
|
"configured_mvbox_folder",
|
||||||
Imap::new(
|
Imap::new(),
|
||||||
cb_get_config,
|
|
||||||
cb_set_config,
|
|
||||||
cb_precheck_imf,
|
|
||||||
cb_receive_imf,
|
|
||||||
),
|
|
||||||
))),
|
))),
|
||||||
probe_imap_network: Arc::new(RwLock::new(false)),
|
probe_imap_network: Arc::new(RwLock::new(false)),
|
||||||
perform_inbox_jobs_needed: Arc::new(RwLock::new(false)),
|
perform_inbox_jobs_needed: Arc::new(RwLock::new(false)),
|
||||||
@@ -178,7 +160,7 @@ impl Default for RunningState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct BobStatus {
|
pub struct BobStatus {
|
||||||
pub expects: i32,
|
pub expects: i32,
|
||||||
pub status: i32,
|
pub status: i32,
|
||||||
@@ -194,89 +176,6 @@ pub struct SmtpState {
|
|||||||
pub probe_network: bool,
|
pub probe_network: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn cb_receive_imf(
|
|
||||||
context: &Context,
|
|
||||||
imf_raw_not_terminated: *const libc::c_char,
|
|
||||||
imf_raw_bytes: size_t,
|
|
||||||
server_folder: &str,
|
|
||||||
server_uid: uint32_t,
|
|
||||||
flags: uint32_t,
|
|
||||||
) {
|
|
||||||
dc_receive_imf(
|
|
||||||
context,
|
|
||||||
imf_raw_not_terminated,
|
|
||||||
imf_raw_bytes,
|
|
||||||
server_folder,
|
|
||||||
server_uid,
|
|
||||||
flags,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn cb_precheck_imf(
|
|
||||||
context: &Context,
|
|
||||||
rfc724_mid: *const libc::c_char,
|
|
||||||
server_folder: &str,
|
|
||||||
server_uid: uint32_t,
|
|
||||||
) -> libc::c_int {
|
|
||||||
let mut rfc724_mid_exists: libc::c_int = 0i32;
|
|
||||||
let msg_id: uint32_t;
|
|
||||||
let mut old_server_folder: *mut libc::c_char = ptr::null_mut();
|
|
||||||
let mut old_server_uid: uint32_t = 0i32 as uint32_t;
|
|
||||||
let mut mark_seen: libc::c_int = 0i32;
|
|
||||||
msg_id = dc_rfc724_mid_exists(
|
|
||||||
context,
|
|
||||||
rfc724_mid,
|
|
||||||
&mut old_server_folder,
|
|
||||||
&mut old_server_uid,
|
|
||||||
);
|
|
||||||
if msg_id != 0i32 as libc::c_uint {
|
|
||||||
rfc724_mid_exists = 1i32;
|
|
||||||
if *old_server_folder.offset(0isize) as libc::c_int == 0i32
|
|
||||||
&& old_server_uid == 0i32 as libc::c_uint
|
|
||||||
{
|
|
||||||
info!(context, "[move] detected bbc-self {}", as_str(rfc724_mid),);
|
|
||||||
mark_seen = 1i32
|
|
||||||
} else if as_str(old_server_folder) != server_folder {
|
|
||||||
info!(
|
|
||||||
context,
|
|
||||||
"[move] detected moved message {}",
|
|
||||||
as_str(rfc724_mid),
|
|
||||||
);
|
|
||||||
dc_update_msg_move_state(context, rfc724_mid, MoveState::Stay);
|
|
||||||
}
|
|
||||||
if as_str(old_server_folder) != server_folder || old_server_uid != server_uid {
|
|
||||||
dc_update_server_uid(context, rfc724_mid, server_folder, server_uid);
|
|
||||||
}
|
|
||||||
do_heuristics_moves(context, server_folder, msg_id);
|
|
||||||
if 0 != mark_seen {
|
|
||||||
job_add(
|
|
||||||
context,
|
|
||||||
Action::MarkseenMsgOnImap,
|
|
||||||
msg_id as libc::c_int,
|
|
||||||
Params::new(),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(old_server_folder as *mut libc::c_void);
|
|
||||||
rfc724_mid_exists
|
|
||||||
}
|
|
||||||
|
|
||||||
fn cb_set_config(context: &Context, key: &str, value: Option<&str>) {
|
|
||||||
context.sql.set_config(context, key, value).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* The following three callback are given to dc_imap_new() to read/write configuration
|
|
||||||
* 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 Context
|
|
||||||
*/
|
|
||||||
fn cb_get_config(context: &Context, key: &str) -> Option<String> {
|
|
||||||
context.sql.get_config(context, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ******************************************************************************
|
/* ******************************************************************************
|
||||||
* INI-handling, Information
|
* INI-handling, Information
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@@ -386,7 +285,7 @@ pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char {
|
|||||||
level=awesome\n",
|
level=awesome\n",
|
||||||
&*DC_VERSION_STR,
|
&*DC_VERSION_STR,
|
||||||
rusqlite::version(),
|
rusqlite::version(),
|
||||||
sqlite3_threadsafe(),
|
rusqlite::ffi::sqlite3_threadsafe(),
|
||||||
// arch
|
// arch
|
||||||
(::std::mem::size_of::<*mut libc::c_void>()).wrapping_mul(8),
|
(::std::mem::size_of::<*mut libc::c_void>()).wrapping_mul(8),
|
||||||
chats,
|
chats,
|
||||||
@@ -448,11 +347,7 @@ pub fn dc_get_fresh_msgs(context: &Context) -> Vec<u32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn dc_search_msgs(
|
pub fn dc_search_msgs(context: &Context, chat_id: u32, query: *const libc::c_char) -> Vec<u32> {
|
||||||
context: &Context,
|
|
||||||
chat_id: uint32_t,
|
|
||||||
query: *const libc::c_char,
|
|
||||||
) -> Vec<u32> {
|
|
||||||
if query.is_null() {
|
if query.is_null() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use crate::location::Location;
|
use crate::location::Location;
|
||||||
use crate::types::*;
|
|
||||||
|
|
||||||
/* * the structure behind dc_array_t */
|
/* * the structure behind dc_array_t */
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub enum dc_array_t {
|
pub enum dc_array_t {
|
||||||
Locations(Vec<Location>),
|
Locations(Vec<Location>),
|
||||||
@@ -19,7 +18,7 @@ impl dc_array_t {
|
|||||||
dc_array_t::Locations(Vec::with_capacity(capacity))
|
dc_array_t::Locations(Vec::with_capacity(capacity))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_id(&mut self, item: uint32_t) {
|
pub fn add_id(&mut self, item: u32) {
|
||||||
if let Self::Uint(array) = self {
|
if let Self::Uint(array) = self {
|
||||||
array.push(item);
|
array.push(item);
|
||||||
} else {
|
} else {
|
||||||
@@ -35,10 +34,10 @@ impl dc_array_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_id(&self, index: usize) -> uint32_t {
|
pub fn get_id(&self, index: usize) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
Self::Locations(array) => array[index].location_id,
|
Self::Locations(array) => array[index].location_id,
|
||||||
Self::Uint(array) => array[index] as uint32_t,
|
Self::Uint(array) => array[index] as u32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use std::ffi::CString;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
use libc::uintptr_t;
|
||||||
use mmime::mailmime_content::*;
|
use mmime::mailmime_content::*;
|
||||||
use mmime::mmapstring::*;
|
use mmime::mmapstring::*;
|
||||||
use mmime::other::*;
|
use mmime::other::*;
|
||||||
@@ -22,7 +23,6 @@ use crate::param::*;
|
|||||||
use crate::pgp::*;
|
use crate::pgp::*;
|
||||||
use crate::sql::{self, Sql};
|
use crate::sql::{self, Sql};
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
// import/export and tools
|
// import/export and tools
|
||||||
@@ -242,7 +242,7 @@ pub fn dc_render_setup_file(context: &Context, passphrase: &str) -> Result<Strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_create_setup_code(_context: &Context) -> String {
|
pub fn dc_create_setup_code(_context: &Context) -> String {
|
||||||
let mut random_val: uint16_t;
|
let mut random_val: u16;
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ pub fn dc_create_setup_code(_context: &Context) -> String {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
random_val = (random_val as libc::c_int % 10000) as uint16_t;
|
random_val = (random_val as libc::c_int % 10000) as u16;
|
||||||
ret += &format!(
|
ret += &format!(
|
||||||
"{}{:04}",
|
"{}{:04}",
|
||||||
if 0 != i { "-" } else { "" },
|
if 0 != i { "-" } else { "" },
|
||||||
@@ -266,7 +266,7 @@ pub fn dc_create_setup_code(_context: &Context) -> String {
|
|||||||
|
|
||||||
pub unsafe fn dc_continue_key_transfer(
|
pub unsafe fn dc_continue_key_transfer(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
msg_id: uint32_t,
|
msg_id: u32,
|
||||||
setup_code: *const libc::c_char,
|
setup_code: *const libc::c_char,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut success = false;
|
let mut success = false;
|
||||||
@@ -405,8 +405,8 @@ pub unsafe fn dc_decrypt_setup_file(
|
|||||||
let mut fc_headerline: *const libc::c_char = ptr::null();
|
let mut fc_headerline: *const libc::c_char = ptr::null();
|
||||||
let mut fc_base64: *const libc::c_char = ptr::null();
|
let mut fc_base64: *const libc::c_char = ptr::null();
|
||||||
let mut binary: *mut libc::c_char = ptr::null_mut();
|
let mut binary: *mut libc::c_char = ptr::null_mut();
|
||||||
let mut binary_bytes: size_t = 0i32 as size_t;
|
let mut binary_bytes: libc::size_t = 0;
|
||||||
let mut indx: size_t = 0i32 as size_t;
|
let mut indx: libc::size_t = 0;
|
||||||
|
|
||||||
let mut payload: *mut libc::c_char = ptr::null_mut();
|
let mut payload: *mut libc::c_char = ptr::null_mut();
|
||||||
fc_buf = dc_strdup(filecontent);
|
fc_buf = dc_strdup(filecontent);
|
||||||
@@ -872,7 +872,7 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
|
|||||||
let mut path_plus_name: *mut libc::c_char = ptr::null_mut();
|
let mut path_plus_name: *mut libc::c_char = ptr::null_mut();
|
||||||
let mut set_default: libc::c_int;
|
let mut set_default: libc::c_int;
|
||||||
let mut buf: *mut libc::c_char = ptr::null_mut();
|
let mut buf: *mut libc::c_char = ptr::null_mut();
|
||||||
let mut buf_bytes: size_t = 0 as size_t;
|
let mut buf_bytes: libc::size_t = 0;
|
||||||
// a pointer inside buf, MUST NOT be free()'d
|
// a pointer inside buf, MUST NOT be free()'d
|
||||||
let mut private_key: *const libc::c_char;
|
let mut private_key: *const libc::c_char;
|
||||||
let mut buf2: *mut libc::c_char = ptr::null_mut();
|
let mut buf2: *mut libc::c_char = ptr::null_mut();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use std::ffi::CString;
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use chrono::TimeZone;
|
use chrono::TimeZone;
|
||||||
|
use mmime::clist::*;
|
||||||
use mmime::mailimf_types::*;
|
use mmime::mailimf_types::*;
|
||||||
use mmime::mailimf_types_helper::*;
|
use mmime::mailimf_types_helper::*;
|
||||||
use mmime::mailmime_disposition::*;
|
use mmime::mailmime_disposition::*;
|
||||||
@@ -23,7 +24,6 @@ use crate::location;
|
|||||||
use crate::message::*;
|
use crate::message::*;
|
||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -46,7 +46,7 @@ pub struct dc_mimefactory_t<'a> {
|
|||||||
pub out: *mut MMAPString,
|
pub out: *mut MMAPString,
|
||||||
pub out_encrypted: libc::c_int,
|
pub out_encrypted: libc::c_int,
|
||||||
pub out_gossiped: libc::c_int,
|
pub out_gossiped: libc::c_int,
|
||||||
pub out_last_added_location_id: uint32_t,
|
pub out_last_added_location_id: u32,
|
||||||
pub error: *mut libc::c_char,
|
pub error: *mut libc::c_char,
|
||||||
pub context: &'a Context,
|
pub context: &'a Context,
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ unsafe fn load_from(factory: &mut dc_mimefactory_t) {
|
|||||||
|
|
||||||
pub unsafe fn dc_mimefactory_load_mdn<'a>(
|
pub unsafe fn dc_mimefactory_load_mdn<'a>(
|
||||||
context: &'a Context,
|
context: &'a Context,
|
||||||
msg_id: uint32_t,
|
msg_id: u32,
|
||||||
) -> Result<dc_mimefactory_t, Error> {
|
) -> Result<dc_mimefactory_t, Error> {
|
||||||
if 0 == context
|
if 0 == context
|
||||||
.sql
|
.sql
|
||||||
@@ -1248,7 +1248,7 @@ unsafe fn build_body_file(
|
|||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
0 as size_t,
|
0 as libc::size_t,
|
||||||
mailmime_parameter_new(
|
mailmime_parameter_new(
|
||||||
strdup(
|
strdup(
|
||||||
b"filename*\x00" as *const u8 as *const libc::c_char,
|
b"filename*\x00" as *const u8 as *const libc::c_char,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::ffi::{CStr, CString};
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use charset::Charset;
|
use charset::Charset;
|
||||||
|
use mmime::clist::*;
|
||||||
use mmime::mailimf::*;
|
use mmime::mailimf::*;
|
||||||
use mmime::mailimf_types::*;
|
use mmime::mailimf_types::*;
|
||||||
use mmime::mailmime::*;
|
use mmime::mailmime::*;
|
||||||
@@ -22,13 +23,12 @@ use crate::e2ee::*;
|
|||||||
use crate::location;
|
use crate::location;
|
||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
/* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322
|
/* 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 Context or to the database
|
dc_mimeparser_t has no deep dependencies to Context or to the database
|
||||||
(Context is used for logging only). */
|
(Context is used for logging only). */
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct dc_mimepart_t {
|
pub struct dc_mimepart_t {
|
||||||
pub type_0: Viewtype,
|
pub type_0: Viewtype,
|
||||||
@@ -43,7 +43,7 @@ pub struct dc_mimepart_t {
|
|||||||
/* *
|
/* *
|
||||||
* @class dc_mimeparser_t
|
* @class dc_mimeparser_t
|
||||||
*/
|
*/
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types, missing_debug_implementations)]
|
||||||
pub struct dc_mimeparser_t<'a> {
|
pub struct dc_mimeparser_t<'a> {
|
||||||
pub parts: Vec<dc_mimepart_t>,
|
pub parts: Vec<dc_mimepart_t>,
|
||||||
pub mimeroot: *mut mailmime,
|
pub mimeroot: *mut mailmime,
|
||||||
@@ -114,7 +114,7 @@ const DC_MIMETYPE_AC_SETUP_FILE: i32 = 111;
|
|||||||
|
|
||||||
pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_mimeparser_t<'a> {
|
pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_mimeparser_t<'a> {
|
||||||
let r: libc::c_int;
|
let r: libc::c_int;
|
||||||
let mut index: size_t = 0i32 as size_t;
|
let mut index: libc::size_t = 0;
|
||||||
let optional_field: *mut mailimf_optional_field;
|
let optional_field: *mut mailimf_optional_field;
|
||||||
let mut mimeparser = dc_mimeparser_new(context);
|
let mut mimeparser = dc_mimeparser_new(context);
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_m
|
|||||||
);
|
);
|
||||||
if !dn_field.is_null() && dc_mimeparser_get_last_nonmeta(&mut mimeparser).is_some() {
|
if !dn_field.is_null() && dc_mimeparser_get_last_nonmeta(&mut mimeparser).is_some() {
|
||||||
let mut mb_list: *mut mailimf_mailbox_list = ptr::null_mut();
|
let mut mb_list: *mut mailimf_mailbox_list = ptr::null_mut();
|
||||||
let mut index_0: size_t = 0i32 as size_t;
|
let mut index_0: libc::size_t = 0;
|
||||||
if mailimf_mailbox_list_parse(
|
if mailimf_mailbox_list_parse(
|
||||||
(*dn_field).fld_value,
|
(*dn_field).fld_value,
|
||||||
strlen((*dn_field).fld_value),
|
strlen((*dn_field).fld_value),
|
||||||
@@ -459,7 +459,7 @@ unsafe fn dc_mimeparser_parse_mime_recursive(
|
|||||||
return 0i32;
|
return 0i32;
|
||||||
}
|
}
|
||||||
if mimeparser.header_protected.is_null() {
|
if mimeparser.header_protected.is_null() {
|
||||||
let mut dummy: size_t = 0i32 as size_t;
|
let mut dummy: libc::size_t = 0;
|
||||||
if mailimf_envelope_and_optional_fields_parse(
|
if mailimf_envelope_and_optional_fields_parse(
|
||||||
(*mime).mm_mime_start,
|
(*mime).mm_mime_start,
|
||||||
(*mime).mm_length,
|
(*mime).mm_length,
|
||||||
@@ -1298,7 +1298,7 @@ unsafe fn do_add_single_file_part(
|
|||||||
mime_type: libc::c_int,
|
mime_type: libc::c_int,
|
||||||
raw_mime: &str,
|
raw_mime: &str,
|
||||||
decoded_data: *const libc::c_char,
|
decoded_data: *const libc::c_char,
|
||||||
decoded_data_bytes: size_t,
|
decoded_data_bytes: libc::size_t,
|
||||||
desired_filename: *const libc::c_char,
|
desired_filename: *const libc::c_char,
|
||||||
) {
|
) {
|
||||||
let pathNfilename: *mut libc::c_char;
|
let pathNfilename: *mut libc::c_char;
|
||||||
@@ -1353,14 +1353,14 @@ unsafe fn do_add_single_part(parser: &mut dc_mimeparser_t, mut part: dc_mimepart
|
|||||||
pub unsafe fn mailmime_transfer_decode(
|
pub unsafe fn mailmime_transfer_decode(
|
||||||
mime: *mut mailmime,
|
mime: *mut mailmime,
|
||||||
ret_decoded_data: *mut *const libc::c_char,
|
ret_decoded_data: *mut *const libc::c_char,
|
||||||
ret_decoded_data_bytes: *mut size_t,
|
ret_decoded_data_bytes: *mut libc::size_t,
|
||||||
ret_to_mmap_string_unref: *mut *mut libc::c_char,
|
ret_to_mmap_string_unref: *mut *mut libc::c_char,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut mime_transfer_encoding: libc::c_int = MAILMIME_MECHANISM_BINARY as libc::c_int;
|
let mut mime_transfer_encoding: libc::c_int = MAILMIME_MECHANISM_BINARY as libc::c_int;
|
||||||
let mime_data: *mut mailmime_data;
|
let mime_data: *mut mailmime_data;
|
||||||
/* must not be free()'d */
|
/* must not be free()'d */
|
||||||
let decoded_data: *const libc::c_char;
|
let decoded_data: *const libc::c_char;
|
||||||
let mut decoded_data_bytes: size_t = 0i32 as size_t;
|
let mut decoded_data_bytes: libc::size_t = 0;
|
||||||
/* mmap_string_unref()'d if set */
|
/* mmap_string_unref()'d if set */
|
||||||
let mut transfer_decoding_buffer: *mut libc::c_char = ptr::null_mut();
|
let mut transfer_decoding_buffer: *mut libc::c_char = ptr::null_mut();
|
||||||
if mime.is_null()
|
if mime.is_null()
|
||||||
@@ -1409,7 +1409,7 @@ pub unsafe fn mailmime_transfer_decode(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let r: libc::c_int;
|
let r: libc::c_int;
|
||||||
let mut current_index: size_t = 0i32 as size_t;
|
let mut current_index = 0;
|
||||||
r = mailmime_part_parse(
|
r = mailmime_part_parse(
|
||||||
(*mime_data).dt_data.dt_text.dt_data,
|
(*mime_data).dt_data.dt_text.dt_data,
|
||||||
(*mime_data).dt_data.dt_text.dt_length,
|
(*mime_data).dt_data.dt_text.dt_length,
|
||||||
@@ -1722,7 +1722,7 @@ mod tests {
|
|||||||
let txt: *const libc::c_char =
|
let txt: *const libc::c_char =
|
||||||
b"FieldA: ValueA\nFieldB: ValueB\n\x00" as *const u8 as *const libc::c_char;
|
b"FieldA: ValueA\nFieldB: ValueB\n\x00" as *const u8 as *const libc::c_char;
|
||||||
let mut mime: *mut mailmime = ptr::null_mut();
|
let mut mime: *mut mailmime = ptr::null_mut();
|
||||||
let mut dummy: size_t = 0i32 as size_t;
|
let mut dummy = 0;
|
||||||
let res = mailmime_parse(txt, strlen(txt), &mut dummy, &mut mime);
|
let res = mailmime_parse(txt, strlen(txt), &mut dummy, &mut mime);
|
||||||
|
|
||||||
assert_eq!(res, MAIL_NO_ERROR as libc::c_int);
|
assert_eq!(res, MAIL_NO_ERROR as libc::c_int);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ use std::ffi::CString;
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use itertools::join;
|
use itertools::join;
|
||||||
|
use libc::uintptr_t;
|
||||||
|
use mmime::clist::*;
|
||||||
use mmime::mailimf::*;
|
use mmime::mailimf::*;
|
||||||
use mmime::mailimf_types::*;
|
use mmime::mailimf_types::*;
|
||||||
use mmime::mailmime::*;
|
use mmime::mailmime::*;
|
||||||
@@ -27,14 +29,13 @@ use crate::peerstate::*;
|
|||||||
use crate::securejoin::handle_securejoin_handshake;
|
use crate::securejoin::handle_securejoin_handshake;
|
||||||
use crate::sql;
|
use crate::sql;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
/// Receive a message and add it to the database.
|
/// Receive a message and add it to the database.
|
||||||
pub unsafe fn dc_receive_imf(
|
pub unsafe fn dc_receive_imf(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
imf_raw_not_terminated: *const libc::c_char,
|
imf_raw_not_terminated: *const libc::c_char,
|
||||||
imf_raw_bytes: size_t,
|
imf_raw_bytes: libc::size_t,
|
||||||
server_folder: impl AsRef<str>,
|
server_folder: impl AsRef<str>,
|
||||||
server_uid: u32,
|
server_uid: u32,
|
||||||
flags: u32,
|
flags: u32,
|
||||||
@@ -260,7 +261,7 @@ unsafe fn add_parts(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
mut mime_parser: &mut dc_mimeparser_t,
|
mut mime_parser: &mut dc_mimeparser_t,
|
||||||
imf_raw_not_terminated: *const libc::c_char,
|
imf_raw_not_terminated: *const libc::c_char,
|
||||||
imf_raw_bytes: size_t,
|
imf_raw_bytes: libc::size_t,
|
||||||
incoming: i32,
|
incoming: i32,
|
||||||
incoming_origin: &mut Origin,
|
incoming_origin: &mut Origin,
|
||||||
server_folder: impl AsRef<str>,
|
server_folder: impl AsRef<str>,
|
||||||
@@ -1028,7 +1029,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
create_blocked: Blocked,
|
create_blocked: Blocked,
|
||||||
from_id: u32,
|
from_id: u32,
|
||||||
to_ids: &mut Vec<u32>,
|
to_ids: &mut Vec<u32>,
|
||||||
ret_chat_id: *mut uint32_t,
|
ret_chat_id: *mut u32,
|
||||||
ret_chat_id_blocked: &mut Blocked,
|
ret_chat_id_blocked: &mut Blocked,
|
||||||
) {
|
) {
|
||||||
let group_explicitly_left: bool;
|
let group_explicitly_left: bool;
|
||||||
@@ -1050,7 +1051,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
|
|
||||||
let cleanup = |grpname: *mut libc::c_char,
|
let cleanup = |grpname: *mut libc::c_char,
|
||||||
failure_reason: *mut libc::c_char,
|
failure_reason: *mut libc::c_char,
|
||||||
ret_chat_id: *mut uint32_t,
|
ret_chat_id: *mut u32,
|
||||||
ret_chat_id_blocked: &mut Blocked,
|
ret_chat_id_blocked: &mut Blocked,
|
||||||
chat_id: u32,
|
chat_id: u32,
|
||||||
chat_id_blocked: Blocked| {
|
chat_id_blocked: Blocked| {
|
||||||
@@ -1218,7 +1219,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
&& 0 == check_verified_properties(
|
&& 0 == check_verified_properties(
|
||||||
context,
|
context,
|
||||||
mime_parser,
|
mime_parser,
|
||||||
from_id as uint32_t,
|
from_id as u32,
|
||||||
to_ids,
|
to_ids,
|
||||||
&mut failure_reason,
|
&mut failure_reason,
|
||||||
)
|
)
|
||||||
@@ -1256,7 +1257,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
if 0 == check_verified_properties(
|
if 0 == check_verified_properties(
|
||||||
context,
|
context,
|
||||||
mime_parser,
|
mime_parser,
|
||||||
from_id as uint32_t,
|
from_id as u32,
|
||||||
to_ids,
|
to_ids,
|
||||||
&mut failure_reason,
|
&mut failure_reason,
|
||||||
) {
|
) {
|
||||||
@@ -1444,7 +1445,7 @@ unsafe fn create_or_lookup_adhoc_group(
|
|||||||
create_blocked: Blocked,
|
create_blocked: Blocked,
|
||||||
from_id: u32,
|
from_id: u32,
|
||||||
to_ids: &mut Vec<u32>,
|
to_ids: &mut Vec<u32>,
|
||||||
ret_chat_id: *mut uint32_t,
|
ret_chat_id: *mut u32,
|
||||||
ret_chat_id_blocked: &mut Blocked,
|
ret_chat_id_blocked: &mut Blocked,
|
||||||
) {
|
) {
|
||||||
// if we're here, no grpid was found, check there is an existing ad-hoc
|
// if we're here, no grpid was found, check there is an existing ad-hoc
|
||||||
@@ -1454,7 +1455,7 @@ unsafe fn create_or_lookup_adhoc_group(
|
|||||||
let mut grpname = ptr::null_mut();
|
let mut grpname = ptr::null_mut();
|
||||||
|
|
||||||
let cleanup = |grpname: *mut libc::c_char,
|
let cleanup = |grpname: *mut libc::c_char,
|
||||||
ret_chat_id: *mut uint32_t,
|
ret_chat_id: *mut u32,
|
||||||
ret_chat_id_blocked: &mut Blocked,
|
ret_chat_id_blocked: &mut Blocked,
|
||||||
chat_id: u32,
|
chat_id: u32,
|
||||||
chat_id_blocked: Blocked| {
|
chat_id_blocked: Blocked| {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use mmime::other::*;
|
|||||||
use percent_encoding::{percent_decode, utf8_percent_encode, AsciiSet, CONTROLS};
|
use percent_encoding::{percent_decode, utf8_percent_encode, AsciiSet, CONTROLS};
|
||||||
|
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +65,7 @@ pub unsafe fn dc_encode_header_words(to_encode: *const libc::c_char) -> *mut lib
|
|||||||
b"utf-8\x00" as *const u8 as *const libc::c_char,
|
b"utf-8\x00" as *const u8 as *const libc::c_char,
|
||||||
mmapstr,
|
mmapstr,
|
||||||
begin,
|
begin,
|
||||||
end.wrapping_offset_from(begin) as size_t,
|
end.wrapping_offset_from(begin) as libc::size_t,
|
||||||
) {
|
) {
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
continue;
|
continue;
|
||||||
@@ -82,7 +81,7 @@ pub unsafe fn dc_encode_header_words(to_encode: *const libc::c_char) -> *mut lib
|
|||||||
if mmap_string_append_len(
|
if mmap_string_append_len(
|
||||||
mmapstr,
|
mmapstr,
|
||||||
end,
|
end,
|
||||||
cur.wrapping_offset_from(end) as size_t,
|
cur.wrapping_offset_from(end) as libc::size_t,
|
||||||
)
|
)
|
||||||
.is_null()
|
.is_null()
|
||||||
{
|
{
|
||||||
@@ -93,7 +92,7 @@ pub unsafe fn dc_encode_header_words(to_encode: *const libc::c_char) -> *mut lib
|
|||||||
} else if mmap_string_append_len(
|
} else if mmap_string_append_len(
|
||||||
mmapstr,
|
mmapstr,
|
||||||
begin,
|
begin,
|
||||||
cur.wrapping_offset_from(begin) as size_t,
|
cur.wrapping_offset_from(begin) as libc::size_t,
|
||||||
)
|
)
|
||||||
.is_null()
|
.is_null()
|
||||||
{
|
{
|
||||||
@@ -122,10 +121,10 @@ unsafe fn quote_word(
|
|||||||
display_charset: *const libc::c_char,
|
display_charset: *const libc::c_char,
|
||||||
mmapstr: *mut MMAPString,
|
mmapstr: *mut MMAPString,
|
||||||
word: *const libc::c_char,
|
word: *const libc::c_char,
|
||||||
size: size_t,
|
size: libc::size_t,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut cur: *const libc::c_char;
|
let mut cur: *const libc::c_char;
|
||||||
let mut i: size_t = 0i32 as size_t;
|
let mut i = 0;
|
||||||
let mut hex: [libc::c_char; 4] = [0; 4];
|
let mut hex: [libc::c_char; 4] = [0; 4];
|
||||||
// let mut col: libc::c_int = 0i32;
|
// let mut col: libc::c_int = 0i32;
|
||||||
if mmap_string_append(mmapstr, b"=?\x00" as *const u8 as *const libc::c_char).is_null() {
|
if mmap_string_append(mmapstr, b"=?\x00" as *const u8 as *const libc::c_char).is_null() {
|
||||||
@@ -188,7 +187,7 @@ unsafe fn get_word(
|
|||||||
{
|
{
|
||||||
cur = cur.offset(1isize)
|
cur = cur.offset(1isize)
|
||||||
}
|
}
|
||||||
*pto_be_quoted = to_be_quoted(begin, cur.wrapping_offset_from(begin) as size_t);
|
*pto_be_quoted = to_be_quoted(begin, cur.wrapping_offset_from(begin) as libc::size_t);
|
||||||
*pend = cur;
|
*pend = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,9 +196,9 @@ unsafe fn get_word(
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* see comment below */
|
/* see comment below */
|
||||||
unsafe fn to_be_quoted(word: *const libc::c_char, size: size_t) -> bool {
|
unsafe fn to_be_quoted(word: *const libc::c_char, size: libc::size_t) -> bool {
|
||||||
let mut cur: *const libc::c_char = word;
|
let mut cur: *const libc::c_char = word;
|
||||||
let mut i: size_t = 0i32 as size_t;
|
let mut i = 0;
|
||||||
while i < size {
|
while i < size {
|
||||||
match *cur as libc::c_int {
|
match *cur as libc::c_int {
|
||||||
44 | 58 | 33 | 34 | 35 | 36 | 64 | 91 | 92 | 93 | 94 | 96 | 123 | 124 | 125 | 126
|
44 | 58 | 33 | 34 | 35 | 36 | 64 | 91 | 92 | 93 | 94 | 96 | 123 | 124 | 125 | 126
|
||||||
@@ -222,7 +221,7 @@ pub unsafe fn dc_decode_header_words(in_0: *const libc::c_char) -> *mut libc::c_
|
|||||||
return ptr::null_mut();
|
return ptr::null_mut();
|
||||||
}
|
}
|
||||||
let mut out: *mut libc::c_char = ptr::null_mut();
|
let mut out: *mut libc::c_char = ptr::null_mut();
|
||||||
let mut cur_token: size_t = 0i32 as size_t;
|
let mut cur_token = 0;
|
||||||
let r: libc::c_int = mailmime_encoded_phrase_parse(
|
let r: libc::c_int = mailmime_encoded_phrase_parse(
|
||||||
b"iso-8859-1\x00" as *const u8 as *const libc::c_char,
|
b"iso-8859-1\x00" as *const u8 as *const libc::c_char,
|
||||||
in_0,
|
in_0,
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ use std::time::SystemTime;
|
|||||||
use std::{fmt, fs, ptr};
|
use std::{fmt, fs, ptr};
|
||||||
|
|
||||||
use chrono::{Local, TimeZone};
|
use chrono::{Local, TimeZone};
|
||||||
|
use itertools::max;
|
||||||
|
use libc::uintptr_t;
|
||||||
|
use mmime::clist::*;
|
||||||
use mmime::mailimf_types::*;
|
use mmime::mailimf_types::*;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
use itertools::max;
|
|
||||||
|
|
||||||
/* Some tools and enhancements to the used libraries, there should be
|
/* Some tools and enhancements to the used libraries, there should be
|
||||||
no references to Context and other "larger" classes here. */
|
no references to Context and other "larger" classes here. */
|
||||||
/* ** library-private **********************************************************/
|
/* ** library-private **********************************************************/
|
||||||
@@ -98,7 +98,7 @@ pub unsafe fn dc_str_replace(
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dc_ltrim(buf: *mut libc::c_char) {
|
unsafe fn dc_ltrim(buf: *mut libc::c_char) {
|
||||||
let mut len: size_t;
|
let mut len: libc::size_t;
|
||||||
let mut cur: *const libc::c_uchar;
|
let mut cur: *const libc::c_uchar;
|
||||||
if !buf.is_null() && 0 != *buf as libc::c_int {
|
if !buf.is_null() && 0 != *buf as libc::c_int {
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
@@ -118,7 +118,7 @@ unsafe fn dc_ltrim(buf: *mut libc::c_char) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dc_rtrim(buf: *mut libc::c_char) {
|
unsafe fn dc_rtrim(buf: *mut libc::c_char) {
|
||||||
let mut len: size_t;
|
let mut len: libc::size_t;
|
||||||
let mut cur: *mut libc::c_uchar;
|
let mut cur: *mut libc::c_uchar;
|
||||||
if !buf.is_null() && 0 != *buf as libc::c_int {
|
if !buf.is_null() && 0 != *buf as libc::c_int {
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
@@ -301,9 +301,9 @@ pub unsafe fn dc_truncate_n_unwrap_str(
|
|||||||
if *p1 as libc::c_int > ' ' as i32 {
|
if *p1 as libc::c_int > ' ' as i32 {
|
||||||
lastIsCharacter = 1
|
lastIsCharacter = 1
|
||||||
} else if 0 != lastIsCharacter {
|
} else if 0 != lastIsCharacter {
|
||||||
let used_bytes: size_t = (p1 as uintptr_t).wrapping_sub(buf as uintptr_t) as size_t;
|
let used_bytes = (p1 as uintptr_t).wrapping_sub(buf as uintptr_t) as libc::size_t;
|
||||||
if dc_utf8_strnlen(buf, used_bytes) >= approx_characters as usize {
|
if dc_utf8_strnlen(buf, used_bytes) >= approx_characters as usize {
|
||||||
let buf_bytes: size_t = strlen(buf);
|
let buf_bytes = strlen(buf);
|
||||||
if buf_bytes.wrapping_sub(used_bytes) >= strlen(ellipse_utf8) {
|
if buf_bytes.wrapping_sub(used_bytes) >= strlen(ellipse_utf8) {
|
||||||
strcpy(p1 as *mut libc::c_char, ellipse_utf8);
|
strcpy(p1 as *mut libc::c_char, ellipse_utf8);
|
||||||
}
|
}
|
||||||
@@ -324,12 +324,12 @@ pub unsafe fn dc_truncate_n_unwrap_str(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dc_utf8_strnlen(s: *const libc::c_char, n: size_t) -> size_t {
|
unsafe fn dc_utf8_strnlen(s: *const libc::c_char, n: libc::size_t) -> libc::size_t {
|
||||||
if s.is_null() {
|
if s.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut j: size_t = 0;
|
let mut j: libc::size_t = 0;
|
||||||
for i in 0..n {
|
for i in 0..n {
|
||||||
if *s.add(i) as libc::c_int & 0xc0 != 0x80 {
|
if *s.add(i) as libc::c_int & 0xc0 != 0x80 {
|
||||||
j = j.wrapping_add(1)
|
j = j.wrapping_add(1)
|
||||||
@@ -543,7 +543,7 @@ pub fn dc_create_id() -> String {
|
|||||||
- the group-id should be a string with the characters [a-zA-Z0-9\-_] */
|
- the group-id should be a string with the characters [a-zA-Z0-9\-_] */
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
let buf: [uint32_t; 3] = [rng.gen(), rng.gen(), rng.gen()];
|
let buf: [u32; 3] = [rng.gen(), rng.gen(), rng.gen()];
|
||||||
|
|
||||||
encode_66bits_as_base64(buf[0usize], buf[1usize], buf[2usize])
|
encode_66bits_as_base64(buf[0usize], buf[1usize], buf[2usize])
|
||||||
}
|
}
|
||||||
@@ -808,10 +808,10 @@ pub fn dc_file_exist(context: &Context, path: impl AsRef<std::path::Path>) -> bo
|
|||||||
dc_get_abs_path(context, &path).exists()
|
dc_get_abs_path(context, &path).exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_get_filebytes(context: &Context, path: impl AsRef<std::path::Path>) -> uint64_t {
|
pub fn dc_get_filebytes(context: &Context, path: impl AsRef<std::path::Path>) -> u64 {
|
||||||
let path_abs = dc_get_abs_path(context, &path);
|
let path_abs = dc_get_abs_path(context, &path);
|
||||||
match fs::metadata(&path_abs) {
|
match fs::metadata(&path_abs) {
|
||||||
Ok(meta) => meta.len() as uint64_t,
|
Ok(meta) => meta.len() as u64,
|
||||||
Err(_err) => 0,
|
Err(_err) => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -881,7 +881,7 @@ pub unsafe fn dc_write_file(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
pathNfilename: *const libc::c_char,
|
pathNfilename: *const libc::c_char,
|
||||||
buf: *const libc::c_void,
|
buf: *const libc::c_void,
|
||||||
buf_bytes: size_t,
|
buf_bytes: libc::size_t,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
let bytes = std::slice::from_raw_parts(buf as *const u8, buf_bytes);
|
let bytes = std::slice::from_raw_parts(buf as *const u8, buf_bytes);
|
||||||
|
|
||||||
@@ -912,7 +912,7 @@ pub unsafe fn dc_read_file(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
pathNfilename: *const libc::c_char,
|
pathNfilename: *const libc::c_char,
|
||||||
buf: *mut *mut libc::c_void,
|
buf: *mut *mut libc::c_void,
|
||||||
buf_bytes: *mut size_t,
|
buf_bytes: *mut libc::size_t,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
if pathNfilename.is_null() {
|
if pathNfilename.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
17
src/e2ee.rs
17
src/e2ee.rs
@@ -30,10 +30,9 @@ use crate::keyring::*;
|
|||||||
use crate::peerstate::*;
|
use crate::peerstate::*;
|
||||||
use crate::pgp::*;
|
use crate::pgp::*;
|
||||||
use crate::securejoin::handle_degrade_event;
|
use crate::securejoin::handle_degrade_event;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct E2eeHelper {
|
pub struct E2eeHelper {
|
||||||
pub encryption_successfull: bool,
|
pub encryption_successfull: bool,
|
||||||
cdata_to_free: Option<Box<dyn Any>>,
|
cdata_to_free: Option<Box<dyn Any>>,
|
||||||
@@ -166,7 +165,7 @@ impl E2eeHelper {
|
|||||||
let message_to_encrypt: *mut mailmime = mailmime_new(
|
let message_to_encrypt: *mut mailmime = mailmime_new(
|
||||||
MAILMIME_MESSAGE as libc::c_int,
|
MAILMIME_MESSAGE as libc::c_int,
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
0i32 as size_t,
|
0 as libc::size_t,
|
||||||
mailmime_fields_new_empty(),
|
mailmime_fields_new_empty(),
|
||||||
mailmime_get_content_message(),
|
mailmime_get_content_message(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
@@ -312,7 +311,7 @@ impl E2eeHelper {
|
|||||||
/* create MIME-structure that will contain the encrypted text */
|
/* create MIME-structure that will contain the encrypted text */
|
||||||
let mut encrypted_part: *mut mailmime = new_data_part(
|
let mut encrypted_part: *mut mailmime = new_data_part(
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
0i32 as size_t,
|
0 as libc::size_t,
|
||||||
b"multipart/encrypted\x00" as *const u8
|
b"multipart/encrypted\x00" as *const u8
|
||||||
as *const libc::c_char
|
as *const libc::c_char
|
||||||
as *mut libc::c_char,
|
as *mut libc::c_char,
|
||||||
@@ -494,7 +493,7 @@ impl E2eeHelper {
|
|||||||
|
|
||||||
unsafe fn new_data_part(
|
unsafe fn new_data_part(
|
||||||
data: *mut libc::c_void,
|
data: *mut libc::c_void,
|
||||||
data_bytes: size_t,
|
data_bytes: libc::size_t,
|
||||||
default_content_type: *mut libc::c_char,
|
default_content_type: *mut libc::c_char,
|
||||||
default_encoding: libc::c_int,
|
default_encoding: libc::c_int,
|
||||||
) -> *mut mailmime {
|
) -> *mut mailmime {
|
||||||
@@ -745,7 +744,7 @@ unsafe fn decrypt_recursive(
|
|||||||
&mut decrypted_mime,
|
&mut decrypted_mime,
|
||||||
) {
|
) {
|
||||||
if (*ret_gossip_headers).is_null() && ret_valid_signatures.len() > 0 {
|
if (*ret_gossip_headers).is_null() && ret_valid_signatures.len() > 0 {
|
||||||
let mut dummy: size_t = 0i32 as size_t;
|
let mut dummy: libc::size_t = 0i32 as libc::size_t;
|
||||||
let mut test: *mut mailimf_fields = ptr::null_mut();
|
let mut test: *mut mailimf_fields = ptr::null_mut();
|
||||||
if mailimf_envelope_and_optional_fields_parse(
|
if mailimf_envelope_and_optional_fields_parse(
|
||||||
(*decrypted_mime).mm_mime_start,
|
(*decrypted_mime).mm_mime_start,
|
||||||
@@ -832,7 +831,7 @@ unsafe fn decrypt_part(
|
|||||||
let mut transfer_decoding_buffer: *mut libc::c_char = ptr::null_mut();
|
let mut transfer_decoding_buffer: *mut libc::c_char = ptr::null_mut();
|
||||||
/* must not be free()'d */
|
/* must not be free()'d */
|
||||||
let mut decoded_data: *const libc::c_char = ptr::null_mut();
|
let mut decoded_data: *const libc::c_char = ptr::null_mut();
|
||||||
let mut decoded_data_bytes: size_t = 0i32 as size_t;
|
let mut decoded_data_bytes: libc::size_t = 0;
|
||||||
let mut sth_decrypted = false;
|
let mut sth_decrypted = false;
|
||||||
|
|
||||||
*ret_decrypted_mime = ptr::null_mut();
|
*ret_decrypted_mime = ptr::null_mut();
|
||||||
@@ -878,7 +877,7 @@ unsafe fn decrypt_part(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let r: libc::c_int;
|
let r: libc::c_int;
|
||||||
let mut current_index: size_t = 0i32 as size_t;
|
let mut current_index: libc::size_t = 0;
|
||||||
r = mailmime_part_parse(
|
r = mailmime_part_parse(
|
||||||
(*mime_data).dt_data.dt_text.dt_data,
|
(*mime_data).dt_data.dt_text.dt_data,
|
||||||
(*mime_data).dt_data.dt_text.dt_length,
|
(*mime_data).dt_data.dt_text.dt_length,
|
||||||
@@ -915,7 +914,7 @@ unsafe fn decrypt_part(
|
|||||||
let plain_bytes = plain.len();
|
let plain_bytes = plain.len();
|
||||||
let plain_buf = plain.as_ptr() as *const libc::c_char;
|
let plain_buf = plain.as_ptr() as *const libc::c_char;
|
||||||
|
|
||||||
let mut index: size_t = 0i32 as size_t;
|
let mut index: libc::size_t = 0;
|
||||||
let mut decrypted_mime: *mut mailmime = ptr::null_mut();
|
let mut decrypted_mime: *mut mailmime = ptr::null_mut();
|
||||||
if mailmime_parse(
|
if mailmime_parse(
|
||||||
plain_buf as *const _,
|
plain_buf as *const _,
|
||||||
|
|||||||
89
src/imap.rs
89
src/imap.rs
@@ -1,5 +1,6 @@
|
|||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::net;
|
use std::net;
|
||||||
|
use std::ptr;
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
Arc, Condvar, Mutex, RwLock,
|
Arc, Condvar, Mutex, RwLock,
|
||||||
@@ -7,11 +8,15 @@ use std::sync::{
|
|||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::context::Context;
|
use crate::context::{do_heuristics_moves, Context};
|
||||||
|
use crate::dc_receive_imf::dc_receive_imf;
|
||||||
use crate::dc_tools::CStringExt;
|
use crate::dc_tools::CStringExt;
|
||||||
|
use crate::dc_tools::*;
|
||||||
|
use crate::job::{job_add, Action};
|
||||||
use crate::login_param::LoginParam;
|
use crate::login_param::LoginParam;
|
||||||
|
use crate::message::{dc_rfc724_mid_exists, dc_update_msg_move_state, dc_update_server_uid};
|
||||||
use crate::oauth2::dc_get_oauth2_access_token;
|
use crate::oauth2::dc_get_oauth2_access_token;
|
||||||
use crate::types::*;
|
use crate::param::Params;
|
||||||
|
|
||||||
const DC_IMAP_SEEN: usize = 0x0001;
|
const DC_IMAP_SEEN: usize = 0x0001;
|
||||||
const DC_REGENERATE: usize = 0x01;
|
const DC_REGENERATE: usize = 0x01;
|
||||||
@@ -25,15 +30,11 @@ const PREFETCH_FLAGS: &str = "(UID ENVELOPE)";
|
|||||||
const BODY_FLAGS: &str = "(FLAGS BODY.PEEK[])";
|
const BODY_FLAGS: &str = "(FLAGS BODY.PEEK[])";
|
||||||
const FETCH_FLAGS: &str = "(FLAGS)";
|
const FETCH_FLAGS: &str = "(FLAGS)";
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Imap {
|
pub struct Imap {
|
||||||
config: Arc<RwLock<ImapConfig>>,
|
config: Arc<RwLock<ImapConfig>>,
|
||||||
watch: Arc<(Mutex<bool>, Condvar)>,
|
watch: Arc<(Mutex<bool>, Condvar)>,
|
||||||
|
|
||||||
get_config: dc_get_config_t,
|
|
||||||
set_config: dc_set_config_t,
|
|
||||||
precheck_imf: dc_precheck_imf_t,
|
|
||||||
receive_imf: dc_receive_imf_t,
|
|
||||||
|
|
||||||
session: Arc<Mutex<Option<Session>>>,
|
session: Arc<Mutex<Option<Session>>>,
|
||||||
stream: Arc<RwLock<Option<net::TcpStream>>>,
|
stream: Arc<RwLock<Option<net::TcpStream>>>,
|
||||||
connected: Arc<Mutex<bool>>,
|
connected: Arc<Mutex<bool>>,
|
||||||
@@ -41,6 +42,7 @@ pub struct Imap {
|
|||||||
should_reconnect: AtomicBool,
|
should_reconnect: AtomicBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct OAuth2 {
|
struct OAuth2 {
|
||||||
user: String,
|
user: String,
|
||||||
access_token: String,
|
access_token: String,
|
||||||
@@ -65,6 +67,7 @@ enum FolderMeaning {
|
|||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum Client {
|
enum Client {
|
||||||
Secure(
|
Secure(
|
||||||
imap::Client<native_tls::TlsStream<net::TcpStream>>,
|
imap::Client<native_tls::TlsStream<net::TcpStream>>,
|
||||||
@@ -73,11 +76,13 @@ enum Client {
|
|||||||
Insecure(imap::Client<net::TcpStream>, net::TcpStream),
|
Insecure(imap::Client<net::TcpStream>, net::TcpStream),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum Session {
|
enum Session {
|
||||||
Secure(imap::Session<native_tls::TlsStream<net::TcpStream>>),
|
Secure(imap::Session<native_tls::TlsStream<net::TcpStream>>),
|
||||||
Insecure(imap::Session<net::TcpStream>),
|
Insecure(imap::Session<net::TcpStream>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum IdleHandle<'a> {
|
enum IdleHandle<'a> {
|
||||||
Secure(imap::extensions::idle::Handle<'a, native_tls::TlsStream<net::TcpStream>>),
|
Secure(imap::extensions::idle::Handle<'a, native_tls::TlsStream<net::TcpStream>>),
|
||||||
Insecure(imap::extensions::idle::Handle<'a, net::TcpStream>),
|
Insecure(imap::extensions::idle::Handle<'a, net::TcpStream>),
|
||||||
@@ -307,6 +312,7 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct ImapConfig {
|
struct ImapConfig {
|
||||||
pub addr: String,
|
pub addr: String,
|
||||||
pub imap_server: String,
|
pub imap_server: String,
|
||||||
@@ -346,21 +352,12 @@ impl Default for ImapConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Imap {
|
impl Imap {
|
||||||
pub fn new(
|
pub fn new() -> Self {
|
||||||
get_config: dc_get_config_t,
|
|
||||||
set_config: dc_set_config_t,
|
|
||||||
precheck_imf: dc_precheck_imf_t,
|
|
||||||
receive_imf: dc_receive_imf_t,
|
|
||||||
) -> Self {
|
|
||||||
Imap {
|
Imap {
|
||||||
session: Arc::new(Mutex::new(None)),
|
session: Arc::new(Mutex::new(None)),
|
||||||
stream: Arc::new(RwLock::new(None)),
|
stream: Arc::new(RwLock::new(None)),
|
||||||
config: Arc::new(RwLock::new(ImapConfig::default())),
|
config: Arc::new(RwLock::new(ImapConfig::default())),
|
||||||
watch: Arc::new((Mutex::new(false), Condvar::new())),
|
watch: Arc::new((Mutex::new(false), Condvar::new())),
|
||||||
get_config,
|
|
||||||
set_config,
|
|
||||||
precheck_imf,
|
|
||||||
receive_imf,
|
|
||||||
connected: Arc::new(Mutex::new(false)),
|
connected: Arc::new(Mutex::new(false)),
|
||||||
should_reconnect: AtomicBool::new(false),
|
should_reconnect: AtomicBool::new(false),
|
||||||
}
|
}
|
||||||
@@ -694,7 +691,7 @@ impl Imap {
|
|||||||
|
|
||||||
fn get_config_last_seen_uid<S: AsRef<str>>(&self, context: &Context, folder: S) -> (u32, u32) {
|
fn get_config_last_seen_uid<S: AsRef<str>>(&self, context: &Context, folder: S) -> (u32, u32) {
|
||||||
let key = format!("imap.mailbox.{}", folder.as_ref());
|
let key = format!("imap.mailbox.{}", folder.as_ref());
|
||||||
if let Some(entry) = (self.get_config)(context, &key) {
|
if let Some(entry) = context.sql.get_config(context, &key) {
|
||||||
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
||||||
let mut parts = entry.split(':');
|
let mut parts = entry.split(':');
|
||||||
(
|
(
|
||||||
@@ -828,7 +825,7 @@ impl Imap {
|
|||||||
|
|
||||||
if 0 == unsafe {
|
if 0 == unsafe {
|
||||||
let message_id_c = CString::yolo(message_id);
|
let message_id_c = CString::yolo(message_id);
|
||||||
(self.precheck_imf)(context, message_id_c.as_ptr(), folder.as_ref(), cur_uid)
|
precheck_imf(context, message_id_c.as_ptr(), folder.as_ref(), cur_uid)
|
||||||
} {
|
} {
|
||||||
// check passed, go fetch the rest
|
// check passed, go fetch the rest
|
||||||
if self.fetch_single_msg(context, &folder, cur_uid) == 0 {
|
if self.fetch_single_msg(context, &folder, cur_uid) == 0 {
|
||||||
@@ -892,7 +889,7 @@ impl Imap {
|
|||||||
let key = format!("imap.mailbox.{}", folder.as_ref());
|
let key = format!("imap.mailbox.{}", folder.as_ref());
|
||||||
let val = format!("{}:{}", uidvalidity, lastseenuid);
|
let val = format!("{}:{}", uidvalidity, lastseenuid);
|
||||||
|
|
||||||
(self.set_config)(context, &key, Some(&val));
|
context.sql.set_config(context, &key, Some(&val)).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_single_msg<S: AsRef<str>>(
|
fn fetch_single_msg<S: AsRef<str>>(
|
||||||
@@ -962,7 +959,7 @@ impl Imap {
|
|||||||
if !is_deleted && msg.body().is_some() {
|
if !is_deleted && msg.body().is_some() {
|
||||||
let body = msg.body().unwrap();
|
let body = msg.body().unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
(self.receive_imf)(
|
dc_receive_imf(
|
||||||
context,
|
context,
|
||||||
body.as_ptr() as *const libc::c_char,
|
body.as_ptr() as *const libc::c_char,
|
||||||
body.len(),
|
body.len(),
|
||||||
@@ -1647,3 +1644,53 @@ fn get_folder_meaning(folder_name: &imap::types::Name) -> FolderMeaning {
|
|||||||
_ => res,
|
_ => res,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe fn precheck_imf(
|
||||||
|
context: &Context,
|
||||||
|
rfc724_mid: *const libc::c_char,
|
||||||
|
server_folder: &str,
|
||||||
|
server_uid: u32,
|
||||||
|
) -> libc::c_int {
|
||||||
|
let mut rfc724_mid_exists: libc::c_int = 0i32;
|
||||||
|
let msg_id: u32;
|
||||||
|
let mut old_server_folder: *mut libc::c_char = ptr::null_mut();
|
||||||
|
let mut old_server_uid: u32 = 0i32 as u32;
|
||||||
|
let mut mark_seen: libc::c_int = 0i32;
|
||||||
|
msg_id = dc_rfc724_mid_exists(
|
||||||
|
context,
|
||||||
|
rfc724_mid,
|
||||||
|
&mut old_server_folder,
|
||||||
|
&mut old_server_uid,
|
||||||
|
);
|
||||||
|
if msg_id != 0i32 as libc::c_uint {
|
||||||
|
rfc724_mid_exists = 1i32;
|
||||||
|
if *old_server_folder.offset(0isize) as libc::c_int == 0i32
|
||||||
|
&& old_server_uid == 0i32 as libc::c_uint
|
||||||
|
{
|
||||||
|
info!(context, "[move] detected bbc-self {}", as_str(rfc724_mid),);
|
||||||
|
mark_seen = 1i32
|
||||||
|
} else if as_str(old_server_folder) != server_folder {
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"[move] detected moved message {}",
|
||||||
|
as_str(rfc724_mid),
|
||||||
|
);
|
||||||
|
dc_update_msg_move_state(context, rfc724_mid, MoveState::Stay);
|
||||||
|
}
|
||||||
|
if as_str(old_server_folder) != server_folder || old_server_uid != server_uid {
|
||||||
|
dc_update_server_uid(context, rfc724_mid, server_folder, server_uid);
|
||||||
|
}
|
||||||
|
do_heuristics_moves(context, server_folder, msg_id);
|
||||||
|
if 0 != mark_seen {
|
||||||
|
job_add(
|
||||||
|
context,
|
||||||
|
Action::MarkseenMsgOnImap,
|
||||||
|
msg_id as libc::c_int,
|
||||||
|
Params::new(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
libc::free(old_server_folder as *mut libc::c_void);
|
||||||
|
rfc724_mid_exists
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ use std::ptr;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use deltachat_derive::{FromSql, ToSql};
|
use deltachat_derive::{FromSql, ToSql};
|
||||||
|
use libc::uintptr_t;
|
||||||
|
use mmime::clist::*;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
|
||||||
use crate::chat;
|
use crate::chat;
|
||||||
@@ -18,7 +20,6 @@ use crate::login_param::LoginParam;
|
|||||||
use crate::message::*;
|
use crate::message::*;
|
||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::sql;
|
use crate::sql;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
/// Thread IDs
|
/// Thread IDs
|
||||||
@@ -642,7 +643,7 @@ pub fn job_action_exists(context: &Context, action: Action) -> bool {
|
|||||||
|
|
||||||
/* special case for DC_JOB_SEND_MSG_TO_SMTP */
|
/* special case for DC_JOB_SEND_MSG_TO_SMTP */
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe fn job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_int {
|
pub unsafe fn job_send_msg(context: &Context, msg_id: u32) -> libc::c_int {
|
||||||
let mut success = 0;
|
let mut success = 0;
|
||||||
|
|
||||||
/* load message data */
|
/* load message data */
|
||||||
@@ -988,7 +989,7 @@ fn connect_to_inbox(context: &Context, inbox: &Imap) -> libc::c_int {
|
|||||||
ret_connected
|
ret_connected
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_mdn(context: &Context, msg_id: uint32_t) {
|
fn send_mdn(context: &Context, msg_id: u32) {
|
||||||
if let Ok(mut mimefactory) = unsafe { dc_mimefactory_load_mdn(context, msg_id) } {
|
if let Ok(mut mimefactory) = unsafe { dc_mimefactory_load_mdn(context, msg_id) } {
|
||||||
if unsafe { dc_mimefactory_render(context, &mut mimefactory) } {
|
if unsafe { dc_mimefactory_render(context, &mut mimefactory) } {
|
||||||
add_smtp_job(context, Action::SendMdn, &mut mimefactory);
|
add_smtp_job(context, Action::SendMdn, &mut mimefactory);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use crate::configure::*;
|
|||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::imap::Imap;
|
use crate::imap::Imap;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct JobThread {
|
pub struct JobThread {
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
pub folder_config_name: &'static str,
|
pub folder_config_name: &'static str,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![deny(clippy::correctness)]
|
#![deny(clippy::correctness, missing_debug_implementations)]
|
||||||
// TODO: make all of these errors, such that clippy actually passes.
|
// TODO: make all of these errors, such that clippy actually passes.
|
||||||
#![warn(clippy::all, clippy::perf, clippy::not_unsafe_ptr_arg_deref)]
|
#![warn(clippy::all, clippy::perf, clippy::not_unsafe_ptr_arg_deref)]
|
||||||
// This is nice, but for now just annoying.
|
// This is nice, but for now just annoying.
|
||||||
@@ -18,6 +18,8 @@ extern crate strum;
|
|||||||
extern crate strum_macros;
|
extern crate strum_macros;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate jetscii;
|
extern crate jetscii;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate debug_stub_derive;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod log;
|
mod log;
|
||||||
@@ -49,7 +51,6 @@ pub mod qr;
|
|||||||
mod smtp;
|
mod smtp;
|
||||||
pub mod sql;
|
pub mod sql;
|
||||||
mod stock;
|
mod stock;
|
||||||
pub mod types;
|
|
||||||
pub mod x;
|
pub mod x;
|
||||||
|
|
||||||
pub mod dc_array;
|
pub mod dc_array;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
use libc::uintptr_t;
|
||||||
use quick_xml;
|
use quick_xml;
|
||||||
use quick_xml::events::{BytesEnd, BytesStart, BytesText};
|
use quick_xml::events::{BytesEnd, BytesStart, BytesText};
|
||||||
|
|
||||||
@@ -13,7 +14,6 @@ use crate::message::*;
|
|||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::sql;
|
use crate::sql;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
|
|
||||||
// location handling
|
// location handling
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use deltachat_derive::{FromSql, ToSql};
|
use deltachat_derive::{FromSql, ToSql};
|
||||||
|
use libc::uintptr_t;
|
||||||
use phf::phf_map;
|
use phf::phf_map;
|
||||||
|
|
||||||
use crate::chat::{self, Chat};
|
use crate::chat::{self, Chat};
|
||||||
@@ -17,7 +18,6 @@ use crate::param::*;
|
|||||||
use crate::pgp::*;
|
use crate::pgp::*;
|
||||||
use crate::sql;
|
use crate::sql;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
/// In practice, the user additionally cuts the string himself pixel-accurate.
|
/// In practice, the user additionally cuts the string himself pixel-accurate.
|
||||||
@@ -136,7 +136,7 @@ impl Lot {
|
|||||||
/// to check if a mail was sent, use dc_msg_is_sent()
|
/// to check if a mail was sent, use dc_msg_is_sent()
|
||||||
/// approx. max. length returned by dc_msg_get_text()
|
/// approx. max. length returned by dc_msg_get_text()
|
||||||
/// approx. max. length returned by dc_get_msg_info()
|
/// approx. max. length returned by dc_get_msg_info()
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
pub from_id: u32,
|
pub from_id: u32,
|
||||||
@@ -680,7 +680,7 @@ pub unsafe fn dc_msg_get_filename(msg: &Message) -> *mut libc::c_char {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_msg_get_filebytes(context: &Context, msg: &Message) -> uint64_t {
|
pub fn dc_msg_get_filebytes(context: &Context, msg: &Message) -> u64 {
|
||||||
if let Some(file) = msg.param.get(Param::File) {
|
if let Some(file) = msg.param.get(Param::File) {
|
||||||
return dc_get_filebytes(context, &file);
|
return dc_get_filebytes(context, &file);
|
||||||
}
|
}
|
||||||
@@ -1146,7 +1146,7 @@ pub fn dc_get_real_msg_cnt(context: &Context) -> libc::c_int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_get_deaddrop_msg_cnt(context: &Context) -> size_t {
|
pub fn dc_get_deaddrop_msg_cnt(context: &Context) -> libc::size_t {
|
||||||
match context.sql.query_row(
|
match context.sql.query_row(
|
||||||
"SELECT COUNT(*) \
|
"SELECT COUNT(*) \
|
||||||
FROM msgs m LEFT JOIN chats c ON c.id=m.chat_id \
|
FROM msgs m LEFT JOIN chats c ON c.id=m.chat_id \
|
||||||
@@ -1154,7 +1154,7 @@ pub fn dc_get_deaddrop_msg_cnt(context: &Context) -> size_t {
|
|||||||
rusqlite::NO_PARAMS,
|
rusqlite::NO_PARAMS,
|
||||||
|row| row.get::<_, isize>(0),
|
|row| row.get::<_, isize>(0),
|
||||||
) {
|
) {
|
||||||
Ok(res) => res as size_t,
|
Ok(res) => res as libc::size_t,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(context, "dc_get_deaddrop_msg_cnt() failed. {}", err);
|
error!(context, "dc_get_deaddrop_msg_cnt() failed. {}", err);
|
||||||
0
|
0
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use rand::thread_rng;
|
|||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
use crate::key::*;
|
use crate::key::*;
|
||||||
use crate::keyring::*;
|
use crate::keyring::*;
|
||||||
use crate::types::*;
|
|
||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
pub unsafe fn dc_split_armored_data(
|
pub unsafe fn dc_split_armored_data(
|
||||||
@@ -25,7 +24,7 @@ pub unsafe fn dc_split_armored_data(
|
|||||||
ret_base64: *mut *const libc::c_char,
|
ret_base64: *mut *const libc::c_char,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut success = false;
|
let mut success = false;
|
||||||
let mut line_chars: size_t = 0i32 as size_t;
|
let mut line_chars: libc::size_t = 0;
|
||||||
let mut line: *mut libc::c_char = buf;
|
let mut line: *mut libc::c_char = buf;
|
||||||
let mut p1: *mut libc::c_char = buf;
|
let mut p1: *mut libc::c_char = buf;
|
||||||
let mut p2: *mut libc::c_char;
|
let mut p2: *mut libc::c_char;
|
||||||
@@ -105,7 +104,7 @@ pub unsafe fn dc_split_armored_data(
|
|||||||
}
|
}
|
||||||
p1 = p1.offset(1isize);
|
p1 = p1.offset(1isize);
|
||||||
line = p1;
|
line = p1;
|
||||||
line_chars = 0i32 as size_t
|
line_chars = 0;
|
||||||
} else {
|
} else {
|
||||||
p1 = p1.offset(1isize);
|
p1 = p1.offset(1isize);
|
||||||
line_chars = line_chars.wrapping_add(1)
|
line_chars = line_chars.wrapping_add(1)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ use crate::peerstate::*;
|
|||||||
use crate::qr::check_qr;
|
use crate::qr::check_qr;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
use crate::token;
|
use crate::token;
|
||||||
use crate::types::*;
|
|
||||||
|
|
||||||
pub const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.');
|
pub const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.');
|
||||||
|
|
||||||
@@ -31,7 +30,11 @@ macro_rules! progress {
|
|||||||
$progress >= 0 && $progress <= 1000,
|
$progress >= 0 && $progress <= 1000,
|
||||||
"value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success"
|
"value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success"
|
||||||
);
|
);
|
||||||
$context.call_cb($event, $contact_id as uintptr_t, $progress as uintptr_t);
|
$context.call_cb(
|
||||||
|
$event,
|
||||||
|
$contact_id as libc::uintptr_t,
|
||||||
|
$progress as libc::uintptr_t,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ macro_rules! get_qr_attr {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_get_securejoin_qr(context: &Context, group_chat_id: uint32_t) -> Option<String> {
|
pub fn dc_get_securejoin_qr(context: &Context, group_chat_id: u32) -> Option<String> {
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
==== Alice - the inviter side ====
|
==== Alice - the inviter side ====
|
||||||
==== Step 1 in "Setup verified contact" protocol ====
|
==== Step 1 in "Setup verified contact" protocol ====
|
||||||
@@ -148,7 +151,7 @@ fn get_self_fingerprint(context: &Context) -> Option<String> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_join_securejoin(context: &Context, qr: &str) -> uint32_t {
|
pub fn dc_join_securejoin(context: &Context, qr: &str) -> u32 {
|
||||||
let cleanup =
|
let cleanup =
|
||||||
|context: &Context, contact_chat_id: u32, ongoing_allocated: bool, join_vg: bool| {
|
|context: &Context, contact_chat_id: u32, ongoing_allocated: bool, join_vg: bool| {
|
||||||
let mut bob = context.bob.write().unwrap();
|
let mut bob = context.bob.write().unwrap();
|
||||||
@@ -171,13 +174,13 @@ pub fn dc_join_securejoin(context: &Context, qr: &str) -> uint32_t {
|
|||||||
if ongoing_allocated {
|
if ongoing_allocated {
|
||||||
dc_free_ongoing(context);
|
dc_free_ongoing(context);
|
||||||
}
|
}
|
||||||
ret_chat_id as uint32_t
|
ret_chat_id as u32
|
||||||
};
|
};
|
||||||
/* ==========================================================
|
/* ==========================================================
|
||||||
==== Bob - the joiner's side =====
|
==== Bob - the joiner's side =====
|
||||||
==== Step 2 in "Setup verified contact" protocol =====
|
==== Step 2 in "Setup verified contact" protocol =====
|
||||||
========================================================== */
|
========================================================== */
|
||||||
let mut contact_chat_id: uint32_t = 0;
|
let mut contact_chat_id: u32 = 0;
|
||||||
let mut join_vg: bool = false;
|
let mut join_vg: bool = false;
|
||||||
|
|
||||||
info!(context, "Requesting secure-join ...",);
|
info!(context, "Requesting secure-join ...",);
|
||||||
@@ -269,7 +272,7 @@ fn check_exit(context: &Context) -> bool {
|
|||||||
|
|
||||||
fn send_handshake_msg(
|
fn send_handshake_msg(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
contact_chat_id: uint32_t,
|
contact_chat_id: u32,
|
||||||
step: &str,
|
step: &str,
|
||||||
param2: impl AsRef<str>,
|
param2: impl AsRef<str>,
|
||||||
fingerprint: Option<String>,
|
fingerprint: Option<String>,
|
||||||
@@ -306,7 +309,7 @@ fn send_handshake_msg(
|
|||||||
chat::send_msg(context, contact_chat_id, &mut msg).unwrap();
|
chat::send_msg(context, contact_chat_id, &mut msg).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn chat_id_2_contact_id(context: &Context, contact_chat_id: uint32_t) -> uint32_t {
|
fn chat_id_2_contact_id(context: &Context, contact_chat_id: u32) -> u32 {
|
||||||
let contacts = chat::get_chat_contacts(context, contact_chat_id);
|
let contacts = chat::get_chat_contacts(context, contact_chat_id);
|
||||||
if contacts.len() == 1 {
|
if contacts.len() == 1 {
|
||||||
contacts[0]
|
contacts[0]
|
||||||
@@ -342,7 +345,7 @@ fn fingerprint_equals_sender(
|
|||||||
pub fn handle_securejoin_handshake(
|
pub fn handle_securejoin_handshake(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
mimeparser: &dc_mimeparser_t,
|
mimeparser: &dc_mimeparser_t,
|
||||||
contact_id: uint32_t,
|
contact_id: u32,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
let own_fingerprint: String;
|
let own_fingerprint: String;
|
||||||
|
|
||||||
@@ -644,8 +647,8 @@ fn end_bobs_joining(context: &Context, status: libc::c_int) {
|
|||||||
dc_stop_ongoing_process(context);
|
dc_stop_ongoing_process(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn secure_connection_established(context: &Context, contact_chat_id: uint32_t) {
|
fn secure_connection_established(context: &Context, contact_chat_id: u32) {
|
||||||
let contact_id: uint32_t = chat_id_2_contact_id(context, contact_chat_id);
|
let contact_id: u32 = chat_id_2_contact_id(context, contact_chat_id);
|
||||||
let contact = Contact::get_by_id(context, contact_id);
|
let contact = Contact::get_by_id(context, contact_id);
|
||||||
let addr = if let Ok(ref contact) = contact {
|
let addr = if let Ok(ref contact) = contact {
|
||||||
contact.get_addr()
|
contact.get_addr()
|
||||||
@@ -675,11 +678,7 @@ fn lookup_field(mimeparser: &dc_mimeparser_t, key: &str) -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn could_not_establish_secure_connection(
|
fn could_not_establish_secure_connection(context: &Context, contact_chat_id: u32, details: &str) {
|
||||||
context: &Context,
|
|
||||||
contact_chat_id: uint32_t,
|
|
||||||
details: &str,
|
|
||||||
) {
|
|
||||||
let contact_id = chat_id_2_contact_id(context, contact_chat_id);
|
let contact_id = chat_id_2_contact_id(context, contact_chat_id);
|
||||||
let contact = Contact::get_by_id(context, contact_id);
|
let contact = Contact::get_by_id(context, contact_id);
|
||||||
let msg = context.stock_string_repl_str(
|
let msg = context.stock_string_repl_str(
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ use crate::context::Context;
|
|||||||
use crate::login_param::LoginParam;
|
use crate::login_param::LoginParam;
|
||||||
use crate::oauth2::*;
|
use crate::oauth2::*;
|
||||||
|
|
||||||
|
#[derive(DebugStub)]
|
||||||
pub struct Smtp {
|
pub struct Smtp {
|
||||||
|
#[debug_stub(some = "SmtpTransport")]
|
||||||
transport: Option<lettre::smtp::SmtpTransport>,
|
transport: Option<lettre::smtp::SmtpTransport>,
|
||||||
transport_connected: bool,
|
transport_connected: bool,
|
||||||
/// Email address we are sending from.
|
/// Email address we are sending from.
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ use crate::peerstate::*;
|
|||||||
const DC_OPEN_READONLY: usize = 0x01;
|
const DC_OPEN_READONLY: usize = 0x01;
|
||||||
|
|
||||||
/// A wrapper around the underlying Sqlite3 object.
|
/// A wrapper around the underlying Sqlite3 object.
|
||||||
|
#[derive(DebugStub)]
|
||||||
pub struct Sql {
|
pub struct Sql {
|
||||||
pool: RwLock<Option<r2d2::Pool<r2d2_sqlite::SqliteConnectionManager>>>,
|
pool: RwLock<Option<r2d2::Pool<r2d2_sqlite::SqliteConnectionManager>>>,
|
||||||
|
#[debug_stub = "ThreadLocal<String>"]
|
||||||
in_use: Arc<ThreadLocal<String>>,
|
in_use: Arc<ThreadLocal<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ mod tests {
|
|||||||
use crate::test_utils::*;
|
use crate::test_utils::*;
|
||||||
|
|
||||||
use crate::constants::DC_CONTACT_ID_SELF;
|
use crate::constants::DC_CONTACT_ID_SELF;
|
||||||
use crate::types::uintptr_t;
|
use libc::uintptr_t;
|
||||||
|
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
|
|
||||||
|
|||||||
31
src/types.rs
31
src/types.rs
@@ -1,31 +0,0 @@
|
|||||||
#![allow(non_camel_case_types)]
|
|
||||||
use crate::context::Context;
|
|
||||||
|
|
||||||
pub use mmime::clist::*;
|
|
||||||
pub use rusqlite::ffi::*;
|
|
||||||
|
|
||||||
pub type dc_receive_imf_t = unsafe fn(
|
|
||||||
_: &Context,
|
|
||||||
_: *const libc::c_char,
|
|
||||||
_: size_t,
|
|
||||||
_: &str,
|
|
||||||
_: uint32_t,
|
|
||||||
_: uint32_t,
|
|
||||||
) -> ();
|
|
||||||
|
|
||||||
/* Purpose: Reading from IMAP servers with no dependencies to the database.
|
|
||||||
Context is only used for logging and to get information about
|
|
||||||
the online state. */
|
|
||||||
|
|
||||||
pub type dc_precheck_imf_t =
|
|
||||||
unsafe fn(_: &Context, _: *const libc::c_char, _: &str, _: u32) -> libc::c_int;
|
|
||||||
pub type dc_set_config_t = fn(_: &Context, _: &str, _: Option<&str>) -> ();
|
|
||||||
pub type dc_get_config_t = fn(_: &Context, _: &str) -> Option<String>;
|
|
||||||
|
|
||||||
pub type int32_t = i32;
|
|
||||||
pub type uintptr_t = libc::uintptr_t;
|
|
||||||
pub type size_t = libc::size_t;
|
|
||||||
pub type uint32_t = libc::c_uint;
|
|
||||||
pub type uint8_t = libc::c_uchar;
|
|
||||||
pub type uint16_t = libc::c_ushort;
|
|
||||||
pub type uint64_t = u64;
|
|
||||||
@@ -15,7 +15,6 @@ use deltachat::dc_tools::*;
|
|||||||
use deltachat::keyring::*;
|
use deltachat::keyring::*;
|
||||||
use deltachat::oauth2::*;
|
use deltachat::oauth2::*;
|
||||||
use deltachat::pgp::*;
|
use deltachat::pgp::*;
|
||||||
use deltachat::types::*;
|
|
||||||
use deltachat::x::*;
|
use deltachat::x::*;
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
@@ -44,14 +43,11 @@ unsafe fn stress_functions(context: &Context) {
|
|||||||
context,
|
context,
|
||||||
b"$BLOBDIR/foobar\x00" as *const u8 as *const libc::c_char,
|
b"$BLOBDIR/foobar\x00" as *const u8 as *const libc::c_char,
|
||||||
b"content\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
b"content\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
7i32 as size_t,
|
7,
|
||||||
);
|
);
|
||||||
assert!(dc_file_exist(context, "$BLOBDIR/foobar",));
|
assert!(dc_file_exist(context, "$BLOBDIR/foobar",));
|
||||||
assert!(!dc_file_exist(context, "$BLOBDIR/foobarx"));
|
assert!(!dc_file_exist(context, "$BLOBDIR/foobarx"));
|
||||||
assert_eq!(
|
assert_eq!(dc_get_filebytes(context, "$BLOBDIR/foobar",), 7);
|
||||||
dc_get_filebytes(context, "$BLOBDIR/foobar",),
|
|
||||||
7i32 as libc::c_ulonglong
|
|
||||||
);
|
|
||||||
|
|
||||||
let abs_path = context
|
let abs_path = context
|
||||||
.get_blobdir()
|
.get_blobdir()
|
||||||
@@ -68,7 +64,7 @@ unsafe fn stress_functions(context: &Context) {
|
|||||||
assert_eq!(dc_get_filebytes(context, "$BLOBDIR/dada",), 7);
|
assert_eq!(dc_get_filebytes(context, "$BLOBDIR/dada",), 7);
|
||||||
|
|
||||||
let mut buf: *mut libc::c_void = ptr::null_mut();
|
let mut buf: *mut libc::c_void = ptr::null_mut();
|
||||||
let mut buf_bytes: size_t = 0;
|
let mut buf_bytes: libc::size_t = 0;
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
dc_read_file(
|
dc_read_file(
|
||||||
@@ -108,7 +104,7 @@ unsafe fn stress_functions(context: &Context) {
|
|||||||
context,
|
context,
|
||||||
fn0,
|
fn0,
|
||||||
b"content\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
b"content\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
7i32 as size_t,
|
7,
|
||||||
);
|
);
|
||||||
let fn1: *mut libc::c_char = dc_get_fine_pathNfilename(
|
let fn1: *mut libc::c_char = dc_get_fine_pathNfilename(
|
||||||
context,
|
context,
|
||||||
@@ -566,7 +562,12 @@ fn test_encryption_decryption() {
|
|||||||
assert_eq!(plain, original_text);
|
assert_eq!(plain, original_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cb(_context: &Context, _event: Event, _data1: uintptr_t, _data2: uintptr_t) -> uintptr_t {
|
fn cb(
|
||||||
|
_context: &Context,
|
||||||
|
_event: Event,
|
||||||
|
_data1: libc::uintptr_t,
|
||||||
|
_data2: libc::uintptr_t,
|
||||||
|
) -> libc::uintptr_t {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user