diff --git a/Cargo.lock b/Cargo.lock index 80eb67a55..ca250ecf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,6 +50,11 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "anyhow" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "arrayref" version = "0.3.5" @@ -68,6 +73,115 @@ name = "ascii_utils" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "async-attributes" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "async-imap" +version = "0.1.0" +dependencies = [ + "async-attributes 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "async-std 0.99.12 (git+https://github.com/async-rs/async-std)", + "async-tls 0.5.0 (git+https://github.com/async-rs/async-tls)", + "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures_codec 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "imap-proto 0.9.1 (git+https://github.com/dignifiedquire/tokio-imap?branch=async-imap)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rental 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "stop-token 0.1.1 (git+https://github.com/dignifiedquire/stop-token)", +] + +[[package]] +name = "async-macros" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "async-std" +version = "0.99.12" +source = "git+https://github.com/async-rs/async-std#89d611628ab92387a2df94787fc9d23f4fe81a90" +dependencies = [ + "async-macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "async-task 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "async-std" +version = "0.99.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "async-macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "async-task 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "async-task" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "async-tls" +version = "0.5.0" +source = "git+https://github.com/async-rs/async-tls#cd44fd7adfc24632c07a941c2daf4e05dc68be9e" +dependencies = [ + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki-roots 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.13" @@ -110,6 +224,11 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bit-set" version = "0.5.1" @@ -189,6 +308,19 @@ dependencies = [ "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "broadcaster" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "buf_redux" version = "0.8.4" @@ -204,6 +336,11 @@ name = "bufstream" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bumpalo" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byte-tools" version = "0.3.1" @@ -377,6 +514,14 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam-channel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam-deque" version = "0.7.1" @@ -482,6 +627,9 @@ dependencies = [ name = "deltachat" version = "1.0.0-beta.7" dependencies = [ + "async-imap 0.1.0", + "async-std 0.99.12 (git+https://github.com/async-rs/async-std)", + "async-tls 0.5.0 (git+https://github.com/async-rs/async-tls)", "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -495,7 +643,6 @@ dependencies = [ "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "image-meta 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "imap 1.0.2 (git+https://github.com/deltachat/rust-imap)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "jetscii 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -795,6 +942,48 @@ name = "futures" version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-core-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "futures-cpupool" version = "0.1.8" @@ -804,6 +993,95 @@ dependencies = [ "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-sink-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-timer" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-util-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures_codec" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.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 = "generic-array" version = "0.12.3" @@ -1002,25 +1280,10 @@ dependencies = [ "skeptic 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "imap" -version = "1.0.2" -source = "git+https://github.com/deltachat/rust-imap#cdcfb2ebb704676d0ea740153d3afe0b19729929" -dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "imap-proto 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "imap-proto" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.9.1" +source = "git+https://github.com/dignifiedquire/tokio-imap?branch=async-imap#b03e5e07aa066c6a27a55e465a9660cdc99bf1c3" dependencies = [ "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1059,6 +1322,14 @@ name = "jetscii" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "js-sys" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "keccak" version = "0.1.0" @@ -1073,6 +1344,14 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "kv-log-macro" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1243,6 +1522,16 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "miow" version = "0.2.1" @@ -1401,6 +1690,11 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "once_cell" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -1550,6 +1844,16 @@ dependencies = [ "zeroize 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pin-project-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "pkg-config" version = "0.3.16" @@ -1581,6 +1885,21 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -1887,6 +2206,25 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rental" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rental-impl 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rental-impl" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "reqwest" version = "0.9.22" @@ -1920,6 +2258,20 @@ dependencies = [ "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ring" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ripemd160" version = "0.8.0" @@ -1984,6 +2336,18 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustls" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", + "sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rusty-fork" version = "0.2.2" @@ -2060,6 +2424,15 @@ name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "security-framework" version = "0.3.1" @@ -2201,16 +2574,35 @@ name = "smallvec" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sourcefile" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "spin" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "stable_deref_trait" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "static_assertions" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "stop-token" +version = "0.1.1" +source = "git+https://github.com/dignifiedquire/stop-token#26b184598e2b1a4a45293b90a719a3f373c2257b" +dependencies = [ + "async-std 0.99.12 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "stream-cipher" version = "0.3.2" @@ -2597,6 +2989,11 @@ dependencies = [ "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "untrusted" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "url" version = "1.7.2" @@ -2687,6 +3084,107 @@ name = "wasi" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wasm-bindgen" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasm-bindgen-webidl" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "web-sys" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webpki" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webpki-roots" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "weedle" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi" version = "0.2.8" @@ -2810,14 +3308,22 @@ dependencies = [ "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "57114fc2a6cc374bce195d3482057c846e706d252ff3604363449695684d7a0d" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum ascii_utils 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" +"checksum async-attributes 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423" +"checksum async-macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e421d59b24c1feea2496e409b3e0a8de23e5fc130a2ddc0b012e551f3b272bba" +"checksum async-std 0.99.12 (git+https://github.com/async-rs/async-std)" = "" +"checksum async-std 0.99.12 (registry+https://github.com/rust-lang/crates.io-index)" = "44501a9f7961bb539b67be0c428b3694e26557046a52759ca7eaf790030a64cc" +"checksum async-task 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de6bd58f7b9cc49032559422595c81cbfcf04db2f2133592f70af19e258a1ced" +"checksum async-tls 0.5.0 (git+https://github.com/async-rs/async-tls)" = "" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +"checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" "checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" "checksum bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" @@ -2828,8 +3334,10 @@ dependencies = [ "checksum block-modes 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "31aa8410095e39fdb732909fb5730a48d5bd7c2e3cd76bd1b07b3dbea130c529" "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum blowfish 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aeb80d00f2688459b8542068abd974cfb101e7a82182414a99b5026c0d85cc3" +"checksum broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "07a1446420a56f1030271649ba0da46d23239b3a68c73591cea5247f15a788a0" "checksum buf_redux 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" "checksum bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" +"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b92204551573580e078dc80017f36a213eb77a0450e4ddd8cfa0f3f2d1f0178f" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -2852,6 +3360,7 @@ dependencies = [ "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" "checksum crc24 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fd121741cf3eb82c08dd3023eb55bf2665e5f60ec20f89760cf836ae4562e6a0" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" @@ -2893,7 +3402,22 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" +"checksum futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-timer 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7946248e9429ff093345d3e8fdf4eb0f9b2d79091611c9c14f744971a6f8be45" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" +"checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" +"checksum futures_codec 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8efb8edac092482013e203af800eef158349c8bbf461edff59c5dd2d3c00e87" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" @@ -2914,15 +3438,16 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" "checksum image-meta 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b00861cbbb254a627d8acc0cec786b484297d896ab8f20fdc8e28536a3e918ef" -"checksum imap 1.0.2 (git+https://github.com/deltachat/rust-imap)" = "" -"checksum imap-proto 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b92ca529b24c5f80a950abe993d3883df6fe6791d4a46b1fda1eb339796c589" +"checksum imap-proto 0.9.1 (git+https://github.com/dignifiedquire/tokio-imap?branch=async-imap)" = "" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "87fa75c9dea7b07be3138c49abbb83fd4bea199b5cdc76f9804458edc5da0d6e" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum jetscii 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5f25cca2463cb19dbb1061eb3bd38a8b5e4ce1cc5a5a9fc0e02de486d92b9b05" +"checksum js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d8657b7ca06a6044ece477f6900bf7670f8b5fd0cce177a1d7094eef51e0adf4" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum lettre 0.9.2 (git+https://github.com/deltachat/lettre)" = "" "checksum lexical-core 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2304bccb228c4b020f3a4835d247df0a02a7c4686098d4167762cfbbe4c5cb14" @@ -2943,6 +3468,7 @@ dependencies = [ "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" +"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" @@ -2957,6 +3483,7 @@ dependencies = [ "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +"checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum openssl 0.10.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2f372b2b53ce10fb823a337aaa674e3a7d072b957c6264d0f4ff0bd86e657449" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" @@ -2970,10 +3497,14 @@ dependencies = [ "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum pgp 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a14471cfc3855455f5bbb639e367cedd69fbce71b32bfb83aff20c3deafce36e" +"checksum pin-project-lite 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f1f61fedcfa3b402e157c23e235b1ab6c30d52c219492c63504059e2bdd3408" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" "checksum pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "717ee476b1690853d222af4634056d830b5197ffd747726a9a1eee6da9f49074" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f" @@ -3007,13 +3538,17 @@ dependencies = [ "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +"checksum rental 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" +"checksum rental-impl 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" "checksum reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)" = "2c2064233e442ce85c77231ebd67d9eca395207dec2127fe0bbedde4bd29a650" +"checksum ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6747f8da1f2b1fabbee1aaa4eb8a11abf9adef0bf58a41cee45db5d59cecdfac" "checksum ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" "checksum rsa 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5108a8bbfb84fe77d829d77d5a89255dcd189dfe5c4de5a33d0a47f12808bb15" "checksum rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a194373ef527035645a1bc21b10dc2125f73497e6e155771233eb187aedd051" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" "checksum rusty-fork 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3dd93264e10c577503e926bd1430193eeb5d21b059148910082245309b424fae" "checksum rustyline 4.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f47ea1ceb347d2deae482d655dc8eef4bd82363d3329baffa3818bd76fea48b" "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" @@ -3023,6 +3558,7 @@ dependencies = [ "checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" "checksum scheduled-thread-pool 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd07742e081ff6c077f5f6b283f12f32b9e7cc765b316160d66289b74546fbb3" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" "checksum security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eee63d0f4a9ec776eeb30e220f0bc1e092c3ad744b2a379e3993070364d3adc2" "checksum security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9636f8989cbf61385ae4824b98c1aaa54c994d7d8b41f11c601ed799f0549a56" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -3038,8 +3574,11 @@ dependencies = [ "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slice-deque 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffddf594f5f597f63533d897427a570dbaa9feabaaa06595b74b71b7014507d7" "checksum smallvec 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cefaa50e76a6f10b86f36e640eb1739eafbd4084865067778463913e43a77ff3" +"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" +"checksum stop-token 0.1.1 (git+https://github.com/dignifiedquire/stop-token)" = "" "checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" @@ -3084,6 +3623,7 @@ dependencies = [ "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 unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" +"checksum untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" "checksum utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" @@ -3096,6 +3636,16 @@ dependencies = [ "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" "checksum want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +"checksum wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c4568ae1b4e07ca907b1a4de41174eaa3e5be4066c024475586b7842725f69a9" +"checksum wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5a00cfdce37367770062065fd3abb9278cbae86a0d918cacd0978a7acd51b481" +"checksum wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7c568f4d3cf6d7c1d72b165daf778fb0d6e09a24f96ac14fc8c4f66a96e86b72" +"checksum wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "430d12539ae324d16097b399e9d07a6d5ce0173b2a61a2d02346ca7c198daffe" +"checksum wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "8ae7167f0bbffd7fac2b12da0fa1f834c1d84671a1ae3c93ac8bde2e97179c39" +"checksum wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "3021567c515a746a64ad0b269d120d46e687c0c95702a4750623db935ae6b5e7" +"checksum web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "ce8e893e021539beb87de8f06e77bdb390a3ab0db4cfeb569c4e377b55ed20de" +"checksum webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e664e770ac0110e2384769bcc59ed19e329d81f555916a6e072714957b81b4" +"checksum webpki-roots 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" +"checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index 1f9231109..d97728340 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,10 @@ num-derive = "0.2.5" num-traits = "0.2.6" native-tls = "0.2.3" lettre = { git = "https://github.com/deltachat/lettre", branch = "master" } -imap = { git = "https://github.com/deltachat/rust-imap", branch = "master" } +# imap = { git = "https://github.com/deltachat/rust-imap", branch = "master" } +async-imap = { path = "../../async-imap" }#, git = "https://github.com/dignifiedquire/async-imap", branch = "master" } +async-tls = { git = "https://github.com/async-rs/async-tls", branch = "master" } +async-std = { git = "https://github.com/async-rs/async-std", branch = "master", features = ["unstable"] } base64 = "0.10" charset = "0.1" percent-encoding = "2.0" diff --git a/rust-toolchain b/rust-toolchain index e52479f6b..202ebf953 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2019-08-13 +nightly-2019-09-12 diff --git a/src/configure/mod.rs b/src/configure/mod.rs index aa8e72d92..c7bec3ba7 100644 --- a/src/configure/mod.rs +++ b/src/configure/mod.rs @@ -569,7 +569,7 @@ fn try_smtp_one_param(context: &Context, param: &LoginParam) -> Option { pub fn dc_connect_to_configured_imap(context: &Context, imap: &Imap) -> libc::c_int { let mut ret_connected = 0; - if imap.is_connected() { + if async_std::task::block_on(async move { imap.is_connected().await }) { ret_connected = 1 } else if !context.sql.get_raw_config_bool(context, "configured") { warn!(context, "Not configured, cannot connect.",); diff --git a/src/imap.rs b/src/imap.rs index 9eb572616..4135271f3 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1,7 +1,11 @@ -use std::net; +use async_std::net; +use async_std::prelude::*; +use async_std::sync::{Arc, Mutex, RwLock}; +use async_std::task; + use std::sync::{ atomic::{AtomicBool, Ordering}, - Arc, Condvar, Mutex, RwLock, + Condvar, }; use std::time::{Duration, SystemTime}; @@ -12,7 +16,7 @@ use crate::dc_receive_imf::dc_receive_imf; use crate::error::Error; use crate::events::Event; use crate::job::{connect_to_inbox, job_add, Action}; -use crate::login_param::{dc_build_tls, CertificateChecks, LoginParam}; +use crate::login_param::{CertificateChecks, LoginParam}; use crate::message::{self, update_msg_move_state, update_server_uid}; use crate::oauth2::dc_get_oauth2_access_token; use crate::param::Params; @@ -40,7 +44,6 @@ pub struct Imap { watch: Arc<(Mutex, Condvar)>, session: Arc>>, - stream: Arc>>, connected: Arc>, should_reconnect: AtomicBool, @@ -52,7 +55,7 @@ struct OAuth2 { access_token: String, } -impl imap::Authenticator for OAuth2 { +impl async_imap::Authenticator for OAuth2 { type Response = String; #[allow(unused_variables)] @@ -73,251 +76,306 @@ enum FolderMeaning { #[derive(Debug)] enum Client { - Secure( - imap::Client>, - net::TcpStream, - ), - Insecure(imap::Client, net::TcpStream), + Secure(async_imap::Client>), + Insecure(async_imap::Client), } #[derive(Debug)] enum Session { - Secure(imap::Session>), - Insecure(imap::Session), + Secure(async_imap::Session>), + Insecure(async_imap::Session), } #[derive(Debug)] -enum IdleHandle<'a> { - Secure(imap::extensions::idle::Handle<'a, native_tls::TlsStream>), - Insecure(imap::extensions::idle::Handle<'a, net::TcpStream>), +enum IdleHandle { + Secure(async_imap::extensions::idle::Handle>), + Insecure(async_imap::extensions::idle::Handle), } -impl<'a> IdleHandle<'a> { - pub fn set_keepalive(&mut self, interval: Duration) { - match self { - IdleHandle::Secure(i) => i.set_keepalive(interval), - IdleHandle::Insecure(i) => i.set_keepalive(interval), - } - } - - pub fn wait_keepalive(self) -> imap::error::Result { - match self { - IdleHandle::Secure(i) => i.wait_keepalive(), - IdleHandle::Insecure(i) => i.wait_keepalive(), - } - } -} +impl IdleHandle {} impl Client { - pub fn connect_secure>( + pub async fn connect_secure>( addr: A, domain: S, certificate_checks: CertificateChecks, - ) -> imap::error::Result { - let stream = net::TcpStream::connect(addr)?; - let tls = dc_build_tls(certificate_checks).unwrap(); + ) -> async_imap::error::Result { + let stream = net::TcpStream::connect(addr).await?; + let tls = async_tls::TlsConnector::new(); - let s = stream.try_clone().expect("cloning the stream failed"); - let tls_stream = native_tls::TlsConnector::connect(&tls, domain.as_ref(), s)?; + let tls_stream = tls.connect(domain.as_ref(), stream)?.await?; - let mut client = imap::Client::new(tls_stream); + let mut client = async_imap::Client::new(tls_stream); if std::env::var(DCC_IMAP_DEBUG).is_ok() { client.debug = true; } - client.read_greeting()?; - Ok(Client::Secure(client, stream)) + let _greeting = client + .read_response() + .await + .expect("failed to read greeting"); + + Ok(Client::Secure(client)) } - pub fn connect_insecure(addr: A) -> imap::error::Result { - let stream = net::TcpStream::connect(addr)?; + pub async fn connect_insecure( + addr: A, + ) -> async_imap::error::Result { + let stream = net::TcpStream::connect(addr).await?; - let mut client = imap::Client::new(stream.try_clone().unwrap()); + let mut client = async_imap::Client::new(stream); if std::env::var(DCC_IMAP_DEBUG).is_ok() { client.debug = true; } - client.read_greeting()?; + let _greeting = client + .read_response() + .await + .expect("failed to read greeting"); - Ok(Client::Insecure(client, stream)) + Ok(Client::Insecure(client)) } - pub fn secure>( + pub async fn secure>( self, domain: S, certificate_checks: CertificateChecks, - ) -> imap::error::Result { + ) -> async_imap::error::Result { match self { - Client::Insecure(client, stream) => { - let tls = dc_build_tls(certificate_checks).unwrap(); + Client::Insecure(client) => { + let tls = async_tls::TlsConnector::new(); - let client_sec = client.secure(domain, &tls)?; + let client_sec = client.secure(domain, &tls).await?; - Ok(Client::Secure(client_sec, stream)) + Ok(Client::Secure(client_sec)) } // Nothing to do - Client::Secure(_, _) => Ok(self), + Client::Secure(_) => Ok(self), } } - pub fn authenticate>( + pub async fn authenticate>( self, auth_type: S, authenticator: &A, - ) -> Result<(Session, net::TcpStream), (imap::error::Error, Client)> { + ) -> Result { match self { - Client::Secure(i, stream) => match i.authenticate(auth_type, authenticator) { - Ok(session) => Ok((Session::Secure(session), stream)), - Err((err, c)) => Err((err, Client::Secure(c, stream))), + Client::Secure(i) => match i.authenticate(auth_type, authenticator).await { + Ok(session) => Ok(Session::Secure(session)), + Err((err, c)) => Err((err, Client::Secure(c))), }, - Client::Insecure(i, stream) => match i.authenticate(auth_type, authenticator) { - Ok(session) => Ok((Session::Insecure(session), stream)), - Err((err, c)) => Err((err, Client::Insecure(c, stream))), + Client::Insecure(i) => match i.authenticate(auth_type, authenticator).await { + Ok(session) => Ok(Session::Insecure(session)), + Err((err, c)) => Err((err, Client::Insecure(c))), }, } } - pub fn login, P: AsRef>( + pub async fn login, P: AsRef>( self, username: U, password: P, - ) -> Result<(Session, net::TcpStream), (imap::error::Error, Client)> { + ) -> Result { match self { - Client::Secure(i, stream) => match i.login(username, password) { - Ok(session) => Ok((Session::Secure(session), stream)), - Err((err, c)) => Err((err, Client::Secure(c, stream))), + Client::Secure(i) => match i.login(username, password).await { + Ok(session) => Ok(Session::Secure(session)), + Err((err, c)) => Err((err, Client::Secure(c))), }, - Client::Insecure(i, stream) => match i.login(username, password) { - Ok(session) => Ok((Session::Insecure(session), stream)), - Err((err, c)) => Err((err, Client::Insecure(c, stream))), + Client::Insecure(i) => match i.login(username, password).await { + Ok(session) => Ok(Session::Insecure(session)), + Err((err, c)) => Err((err, Client::Insecure(c))), }, } } } impl Session { - pub fn capabilities( + pub async fn capabilities( &mut self, - ) -> imap::error::Result> { - match self { - Session::Secure(i) => i.capabilities(), - Session::Insecure(i) => i.capabilities(), - } + ) -> async_imap::error::Result { + let res = match self { + Session::Secure(i) => i.capabilities().await?, + Session::Insecure(i) => i.capabilities().await?, + }; + + Ok(res) } - pub fn list( + pub async fn list( &mut self, reference_name: Option<&str>, mailbox_pattern: Option<&str>, - ) -> imap::error::Result>> { - match self { - Session::Secure(i) => i.list(reference_name, mailbox_pattern), - Session::Insecure(i) => i.list(reference_name, mailbox_pattern), - } + ) -> async_imap::error::Result> { + let res = match self { + Session::Secure(i) => { + i.list(reference_name, mailbox_pattern) + .await? + .collect::>() + .await? + } + Session::Insecure(i) => { + i.list(reference_name, mailbox_pattern) + .await? + .collect::>() + .await? + } + }; + Ok(res) } - pub fn create>(&mut self, mailbox_name: S) -> imap::error::Result<()> { - match self { - Session::Secure(i) => i.create(mailbox_name), - Session::Insecure(i) => i.create(mailbox_name), - } - } - - pub fn subscribe>(&mut self, mailbox: S) -> imap::error::Result<()> { - match self { - Session::Secure(i) => i.subscribe(mailbox), - Session::Insecure(i) => i.subscribe(mailbox), - } - } - - pub fn close(&mut self) -> imap::error::Result<()> { - match self { - Session::Secure(i) => i.close(), - Session::Insecure(i) => i.close(), - } - } - - pub fn select>( + pub async fn create>( &mut self, mailbox_name: S, - ) -> imap::error::Result { + ) -> async_imap::error::Result<()> { match self { - Session::Secure(i) => i.select(mailbox_name), - Session::Insecure(i) => i.select(mailbox_name), + Session::Secure(i) => i.create(mailbox_name).await?, + Session::Insecure(i) => i.create(mailbox_name).await?, } + Ok(()) } - pub fn fetch( + pub async fn subscribe>(&mut self, mailbox: S) -> async_imap::error::Result<()> { + match self { + Session::Secure(i) => i.subscribe(mailbox).await?, + Session::Insecure(i) => i.subscribe(mailbox).await?, + } + Ok(()) + } + + pub async fn close(&mut self) -> async_imap::error::Result<()> { + match self { + Session::Secure(i) => i.close().await?, + Session::Insecure(i) => i.close().await?, + } + Ok(()) + } + + pub async fn select>( + &mut self, + mailbox_name: S, + ) -> async_imap::error::Result { + let mbox = match self { + Session::Secure(i) => i.select(mailbox_name).await?, + Session::Insecure(i) => i.select(mailbox_name).await?, + }; + + Ok(mbox) + } + + pub async fn fetch( &mut self, sequence_set: S1, query: S2, - ) -> imap::error::Result>> + ) -> async_imap::error::Result> where S1: AsRef, S2: AsRef, { - match self { - Session::Secure(i) => i.fetch(sequence_set, query), - Session::Insecure(i) => i.fetch(sequence_set, query), - } + let res = match self { + Session::Secure(i) => { + i.fetch(sequence_set, query) + .await? + .collect::>() + .await? + } + Session::Insecure(i) => { + i.fetch(sequence_set, query) + .await? + .collect::>() + .await? + } + }; + Ok(res) } - pub fn uid_fetch( + pub async fn uid_fetch( &mut self, uid_set: S1, query: S2, - ) -> imap::error::Result>> + ) -> async_imap::error::Result> where S1: AsRef, S2: AsRef, { + let res = match self { + Session::Secure(i) => { + i.uid_fetch(uid_set, query) + .await? + .collect::>() + .await? + } + Session::Insecure(i) => { + i.uid_fetch(uid_set, query) + .await? + .collect::>() + .await? + } + }; + + Ok(res) + } + + pub async fn idle(self) -> IdleHandle { match self { - Session::Secure(i) => i.uid_fetch(uid_set, query), - Session::Insecure(i) => i.uid_fetch(uid_set, query), + Session::Secure(i) => { + let h = i.idle(); + IdleHandle::Secure(h) + } + Session::Insecure(i) => { + let h = i.idle(); + IdleHandle::Insecure(h) + } } } - pub fn idle(&mut self) -> imap::error::Result { - match self { - Session::Secure(i) => i.idle().map(IdleHandle::Secure), - Session::Insecure(i) => i.idle().map(IdleHandle::Insecure), - } - } - - pub fn uid_store( + pub async fn uid_store( &mut self, uid_set: S1, query: S2, - ) -> imap::error::Result>> + ) -> async_imap::error::Result> where S1: AsRef, S2: AsRef, { - match self { - Session::Secure(i) => i.uid_store(uid_set, query), - Session::Insecure(i) => i.uid_store(uid_set, query), - } + let res = match self { + Session::Secure(i) => { + i.uid_store(uid_set, query) + .await? + .collect::>() + .await? + } + Session::Insecure(i) => { + i.uid_store(uid_set, query) + .await? + .collect::>() + .await? + } + }; + Ok(res) } - pub fn uid_mv, S2: AsRef>( + pub async fn uid_mv, S2: AsRef>( &mut self, uid_set: S1, mailbox_name: S2, - ) -> imap::error::Result<()> { + ) -> async_imap::error::Result<()> { match self { - Session::Secure(i) => i.uid_mv(uid_set, mailbox_name), - Session::Insecure(i) => i.uid_mv(uid_set, mailbox_name), + Session::Secure(i) => i.uid_mv(uid_set, mailbox_name).await?, + Session::Insecure(i) => i.uid_mv(uid_set, mailbox_name).await?, } + Ok(()) } - pub fn uid_copy, S2: AsRef>( + pub async fn uid_copy, S2: AsRef>( &mut self, uid_set: S1, mailbox_name: S2, - ) -> imap::error::Result<()> { + ) -> async_imap::error::Result<()> { match self { - Session::Secure(i) => i.uid_copy(uid_set, mailbox_name), - Session::Insecure(i) => i.uid_copy(uid_set, mailbox_name), + Session::Secure(i) => i.uid_copy(uid_set, mailbox_name).await?, + Session::Insecure(i) => i.uid_copy(uid_set, mailbox_name).await?, } + + Ok(()) } } @@ -331,7 +389,7 @@ struct ImapConfig { pub certificate_checks: CertificateChecks, pub server_flags: usize, pub selected_folder: Option, - pub selected_mailbox: Option, + pub selected_mailbox: Option, pub selected_folder_needs_expunge: bool, pub can_idle: bool, pub has_xlist: bool, @@ -364,7 +422,6 @@ impl Imap { pub fn new() -> Self { Imap { session: Arc::new(Mutex::new(None)), - stream: Arc::new(RwLock::new(None)), config: Arc::new(RwLock::new(ImapConfig::default())), watch: Arc::new((Mutex::new(false), Condvar::new())), connected: Arc::new(Mutex::new(false)), @@ -372,8 +429,8 @@ impl Imap { } } - pub fn is_connected(&self) -> bool { - *self.connected.lock().unwrap() + pub async fn is_connected(&self) -> bool { + *self.connected.lock().await } pub fn should_reconnect(&self) -> bool { @@ -381,134 +438,139 @@ impl Imap { } fn setup_handle_if_needed(&self, context: &Context) -> bool { - if self.config.read().unwrap().imap_server.is_empty() { - return false; - } - - if self.should_reconnect() { - self.unsetup_handle(context); - } - - if self.is_connected() && self.stream.read().unwrap().is_some() { - self.should_reconnect.store(false, Ordering::Relaxed); - return true; - } - - let server_flags = self.config.read().unwrap().server_flags as i32; - - let connection_res: imap::error::Result = - if (server_flags & (DC_LP_IMAP_SOCKET_STARTTLS | DC_LP_IMAP_SOCKET_PLAIN)) != 0 { - let config = self.config.read().unwrap(); - let imap_server: &str = config.imap_server.as_ref(); - let imap_port = config.imap_port; - - Client::connect_insecure((imap_server, imap_port)).and_then(|client| { - if (server_flags & DC_LP_IMAP_SOCKET_STARTTLS) != 0 { - client.secure(imap_server, config.certificate_checks) - } else { - Ok(client) - } - }) - } else { - let config = self.config.read().unwrap(); - let imap_server: &str = config.imap_server.as_ref(); - let imap_port = config.imap_port; - - Client::connect_secure( - (imap_server, imap_port), - imap_server, - config.certificate_checks, - ) - }; - - let login_res = match connection_res { - Ok(client) => { - let config = self.config.read().unwrap(); - let imap_user: &str = config.imap_user.as_ref(); - let imap_pw: &str = config.imap_pw.as_ref(); - - if (server_flags & DC_LP_AUTH_OAUTH2) != 0 { - let addr: &str = config.addr.as_ref(); - - if let Some(token) = dc_get_oauth2_access_token(context, addr, imap_pw, true) { - let auth = OAuth2 { - user: imap_user.into(), - access_token: token, - }; - client.authenticate("XOAUTH2", &auth) - } else { - return false; - } - } else { - client.login(imap_user, imap_pw) - } - } - Err(err) => { - let config = self.config.read().unwrap(); - let imap_server: &str = config.imap_server.as_ref(); - let imap_port = config.imap_port; - let message = context.stock_string_repl_str2( - StockMessage::ServerResponse, - format!("{}:{}", imap_server, imap_port), - format!("{}", err), - ); - - emit_event!(context, Event::ErrorNetwork(message)); - + task::block_on(async move { + if self.config.read().await.imap_server.is_empty() { return false; } - }; - self.should_reconnect.store(false, Ordering::Relaxed); - - match login_res { - Ok((session, stream)) => { - *self.session.lock().unwrap() = Some(session); - *self.stream.write().unwrap() = Some(stream); - true + if self.should_reconnect() { + self.unsetup_handle(context).await; } - Err((err, _)) => { - let imap_user = self.config.read().unwrap().imap_user.to_owned(); - let message = context.stock_string_repl_str(StockMessage::CannotLogin, &imap_user); - emit_event!( - context, - Event::ErrorNetwork(format!("{} ({})", message, err)) - ); - self.unsetup_handle(context); - - false + if self.is_connected().await { + self.should_reconnect.store(false, Ordering::Relaxed); + return true; } - } + + let server_flags = self.config.read().await.server_flags as i32; + + let connection_res: async_imap::error::Result = + if (server_flags & (DC_LP_IMAP_SOCKET_STARTTLS | DC_LP_IMAP_SOCKET_PLAIN)) != 0 { + let config = self.config.read().await; + let imap_server: &str = config.imap_server.as_ref(); + let imap_port = config.imap_port; + + match Client::connect_insecure((imap_server, imap_port)).await { + Ok(client) => { + if (server_flags & DC_LP_IMAP_SOCKET_STARTTLS) != 0 { + let res = + client.secure(imap_server, config.certificate_checks).await; + res + } else { + Ok(client) + } + } + Err(err) => Err(err), + } + } else { + let config = self.config.read().await; + let imap_server: &str = config.imap_server.as_ref(); + let imap_port = config.imap_port; + + let res = Client::connect_secure( + (imap_server, imap_port), + imap_server, + config.certificate_checks, + ) + .await; + res + }; + + let login_res = match connection_res { + Ok(client) => { + let config = self.config.read().await; + let imap_user: &str = config.imap_user.as_ref(); + let imap_pw: &str = config.imap_pw.as_ref(); + + if (server_flags & DC_LP_AUTH_OAUTH2) != 0 { + let addr: &str = config.addr.as_ref(); + + if let Some(token) = + dc_get_oauth2_access_token(context, addr, imap_pw, true) + { + let auth = OAuth2 { + user: imap_user.into(), + access_token: token, + }; + let res = client.authenticate("XOAUTH2", &auth).await; + res + } else { + return false; + } + } else { + let res = client.login(imap_user, imap_pw).await; + res + } + } + Err(err) => { + let config = self.config.read().await; + let imap_server: &str = config.imap_server.as_ref(); + let imap_port = config.imap_port; + let message = context.stock_string_repl_str2( + StockMessage::ServerResponse, + format!("{}:{}", imap_server, imap_port), + format!("{}", err), + ); + + emit_event!(context, Event::ErrorNetwork(message)); + + return false; + } + }; + + self.should_reconnect.store(false, Ordering::Relaxed); + + match login_res { + Ok(session) => { + *self.session.lock().await = Some(session); + true + } + Err((err, _)) => { + let imap_user = self.config.read().await.imap_user.to_owned(); + let message = + context.stock_string_repl_str(StockMessage::CannotLogin, &imap_user); + + emit_event!( + context, + Event::ErrorNetwork(format!("{} ({})", message, err)) + ); + self.unsetup_handle(context).await; + + false + } + } + }) } - fn unsetup_handle(&self, context: &Context) { - info!(context, "IMAP unsetup_handle step 1 (closing down stream)."); - let stream = self.stream.write().unwrap().take(); - if let Some(stream) = stream { - if let Err(err) = stream.shutdown(net::Shutdown::Both) { - warn!(context, "failed to shutdown connection: {:?}", err); - } - } - + async fn unsetup_handle(&self, context: &Context) { info!( context, "IMAP unsetup_handle step 2 (acquiring session.lock)" ); - if let Some(mut session) = self.session.lock().unwrap().take() { - if let Err(err) = session.close() { + if let Some(mut session) = self.session.lock().await.take() { + if let Err(err) = session.close().await { warn!(context, "failed to close connection: {:?}", err); } } info!(context, "IMAP unsetup_handle step 3 (clearing config)."); - self.config.write().unwrap().selected_folder = None; - self.config.write().unwrap().selected_mailbox = None; - info!(context, "IMAP unsetup_handle step 4 (disconnected).",); + self.config.write().await.selected_folder = None; + self.config.write().await.selected_mailbox = None; + info!(context, "IMAP unsetup_handle step 4 (disconnected)."); } - fn free_connect_params(&self) { - let mut cfg = self.config.write().unwrap(); + async fn free_connect_params(&self) { + let mut cfg = self.config.write().await; cfg.addr = "".into(); cfg.imap_server = "".into(); @@ -523,118 +585,126 @@ impl Imap { } pub fn connect(&self, context: &Context, lp: &LoginParam) -> bool { - if lp.mail_server.is_empty() || lp.mail_user.is_empty() || lp.mail_pw.is_empty() { - return false; - } + task::block_on(async move { + if lp.mail_server.is_empty() || lp.mail_user.is_empty() || lp.mail_pw.is_empty() { + return false; + } - if self.is_connected() { - return true; - } + if self.is_connected().await { + return true; + } - { - let addr = &lp.addr; - let imap_server = &lp.mail_server; - let imap_port = lp.mail_port as u16; - let imap_user = &lp.mail_user; - let imap_pw = &lp.mail_pw; - let server_flags = lp.server_flags as usize; + { + let addr = &lp.addr; + let imap_server = &lp.mail_server; + let imap_port = lp.mail_port as u16; + let imap_user = &lp.mail_user; + let imap_pw = &lp.mail_pw; + let server_flags = lp.server_flags as usize; - let mut config = self.config.write().unwrap(); - config.addr = addr.to_string(); - config.imap_server = imap_server.to_string(); - config.imap_port = imap_port; - config.imap_user = imap_user.to_string(); - config.imap_pw = imap_pw.to_string(); - config.certificate_checks = lp.imap_certificate_checks; - config.server_flags = server_flags; - } + let mut config = self.config.write().await; + config.addr = addr.to_string(); + config.imap_server = imap_server.to_string(); + config.imap_port = imap_port; + config.imap_user = imap_user.to_string(); + config.imap_pw = imap_pw.to_string(); + config.certificate_checks = lp.imap_certificate_checks; + config.server_flags = server_flags; + } - if !self.setup_handle_if_needed(context) { - self.free_connect_params(); - return false; - } + if !self.setup_handle_if_needed(context) { + self.free_connect_params().await; + return false; + } - let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().unwrap() { - Some(ref mut session) => match session.capabilities() { - Ok(caps) => { - if !context.sql.is_open() { - warn!(context, "IMAP-LOGIN as {} ok but ABORTING", lp.mail_user,); - (true, false, false) - } else { - let can_idle = caps.has_str("IDLE"); - let has_xlist = caps.has_str("XLIST"); - let caps_list = caps - .iter() - .fold(String::new(), |s, c| s + &format!(" {:?}", c)); - emit_event!( - context, - Event::ImapConnected(format!( - "IMAP-LOGIN as {}, capabilities: {}", - lp.mail_user, caps_list, - )) - ); - (false, can_idle, has_xlist) + let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().await { + Some(ref mut session) => match session.capabilities().await { + Ok(caps) => { + if !context.sql.is_open() { + warn!(context, "IMAP-LOGIN as {} ok but ABORTING", lp.mail_user,); + (true, false, false) + } else { + let can_idle = caps.has_str("IDLE"); + let has_xlist = caps.has_str("XLIST"); + let caps_list = caps + .iter() + .fold(String::new(), |s, c| s + &format!(" {:?}", c)); + emit_event!( + context, + Event::ImapConnected(format!( + "IMAP-LOGIN as {}, capabilities: {}", + lp.mail_user, caps_list, + )) + ); + (false, can_idle, has_xlist) + } } - } - Err(err) => { - info!(context, "CAPABILITY command error: {}", err); - (true, false, false) - } - }, - None => (true, false, false), - }; + Err(err) => { + info!(context, "CAPABILITY command error: {}", err); + (true, false, false) + } + }, + None => (true, false, false), + }; - if teardown { - self.unsetup_handle(context); - self.free_connect_params(); - false - } else { - self.config.write().unwrap().can_idle = can_idle; - self.config.write().unwrap().has_xlist = has_xlist; - *self.connected.lock().unwrap() = true; - true - } + if teardown { + self.unsetup_handle(context).await; + self.free_connect_params().await; + false + } else { + self.config.write().await.can_idle = can_idle; + self.config.write().await.has_xlist = has_xlist; + *self.connected.lock().await = true; + true + } + }) } pub fn disconnect(&self, context: &Context) { - if self.is_connected() { - self.unsetup_handle(context); - self.free_connect_params(); - *self.connected.lock().unwrap() = false; - } + task::block_on(async move { + if self.is_connected().await { + self.unsetup_handle(context).await; + self.free_connect_params().await; + *self.connected.lock().await = false; + } + }); } pub fn set_watch_folder(&self, watch_folder: String) { - self.config.write().unwrap().watch_folder = Some(watch_folder); + task::block_on(async move { + self.config.write().await.watch_folder = Some(watch_folder); + }); } pub fn fetch(&self, context: &Context) -> bool { - if !self.is_connected() || !context.sql.is_open() { - return false; - } - - self.setup_handle_if_needed(context); - - let watch_folder = self.config.read().unwrap().watch_folder.to_owned(); - - if let Some(ref watch_folder) = watch_folder { - // as during the fetch commands, new messages may arrive, we fetch until we do not - // get any more. if IDLE is called directly after, there is only a small chance that - // messages are missed and delayed until the next IDLE call - loop { - if self.fetch_from_single_folder(context, watch_folder) == 0 { - break; - } + task::block_on(async move { + if !self.is_connected().await || !context.sql.is_open() { + return false; } - true - } else { - false - } + + self.setup_handle_if_needed(context); + + let watch_folder = self.config.read().await.watch_folder.to_owned(); + + if let Some(ref watch_folder) = watch_folder { + // as during the fetch commands, new messages may arrive, we fetch until we do not + // get any more. if IDLE is called directly after, there is only a small chance that + // messages are missed and delayed until the next IDLE call + loop { + if self.fetch_from_single_folder(context, watch_folder).await == 0 { + break; + } + } + true + } else { + false + } + }) } - fn select_folder>(&self, context: &Context, folder: Option) -> usize { - if self.session.lock().unwrap().is_none() { - let mut cfg = self.config.write().unwrap(); + async fn select_folder>(&self, context: &Context, folder: Option) -> usize { + if self.session.lock().await.is_none() { + let mut cfg = self.config.write().await; cfg.selected_folder = None; cfg.selected_folder_needs_expunge = false; return 0; @@ -643,7 +713,7 @@ impl Imap { // if there is a new folder and the new folder is equal to the selected one, there's nothing to do. // if there is _no_ new folder, we continue as we might want to expunge below. if let Some(ref folder) = folder { - if let Some(ref selected_folder) = self.config.read().unwrap().selected_folder { + if let Some(ref selected_folder) = self.config.read().await.selected_folder { if folder.as_ref() == selected_folder { return 1; } @@ -651,15 +721,15 @@ impl Imap { } // deselect existing folder, if needed (it's also done implicitly by SELECT, however, without EXPUNGE then) - let needs_expunge = { self.config.read().unwrap().selected_folder_needs_expunge }; + let needs_expunge = { self.config.read().await.selected_folder_needs_expunge }; if needs_expunge { - if let Some(ref folder) = self.config.read().unwrap().selected_folder { + if let Some(ref folder) = self.config.read().await.selected_folder { info!(context, "Expunge messages in \"{}\".", folder); // A CLOSE-SELECT is considerably faster than an EXPUNGE-SELECT, see // https://tools.ietf.org/html/rfc3501#section-6.4.2 - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.close() { + if let Some(ref mut session) = &mut *self.session.lock().await { + match session.close().await { Ok(_) => { info!(context, "close/expunge succeeded"); } @@ -672,15 +742,15 @@ impl Imap { return 0; } } - self.config.write().unwrap().selected_folder_needs_expunge = false; + self.config.write().await.selected_folder_needs_expunge = false; } // select new folder if let Some(ref folder) = folder { - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.select(folder) { + if let Some(ref mut session) = &mut *self.session.lock().await { + match session.select(folder).await { Ok(mailbox) => { - let mut config = self.config.write().unwrap(); + let mut config = self.config.write().await; config.selected_folder = Some(folder.as_ref().to_string()); config.selected_mailbox = Some(mailbox); } @@ -692,7 +762,7 @@ impl Imap { err ); - self.config.write().unwrap().selected_folder = None; + self.config.write().await.selected_folder = None; self.should_reconnect.store(true, Ordering::Relaxed); return 0; } @@ -727,8 +797,8 @@ impl Imap { } } - fn fetch_from_single_folder>(&self, context: &Context, folder: S) -> usize { - if !self.is_connected() { + async fn fetch_from_single_folder>(&self, context: &Context, folder: S) -> usize { + if !self.is_connected().await { info!( context, "Cannot fetch from \"{}\" - not connected.", @@ -738,7 +808,7 @@ impl Imap { return 0; } - if self.select_folder(context, Some(&folder)) == 0 { + if self.select_folder(context, Some(&folder)).await == 0 { info!( context, "Cannot select folder \"{}\" for fetching.", @@ -751,7 +821,7 @@ impl Imap { // compare last seen UIDVALIDITY against the current one let (mut uid_validity, mut last_seen_uid) = self.get_config_last_seen_uid(context, &folder); - let config = self.config.read().unwrap(); + let config = self.config.read().await; let mailbox = config.selected_mailbox.as_ref().expect("just selected"); if mailbox.uid_validity.is_none() { @@ -783,10 +853,10 @@ impl Imap { return 0; } - let list = if let Some(ref mut session) = &mut *self.session.lock().unwrap() { + let list = if let Some(ref mut session) = &mut *self.session.lock().await { // `FETCH (UID)` let set = format!("{}", mailbox.exists); - match session.fetch(set, PREFETCH_FLAGS) { + match session.fetch(set, PREFETCH_FLAGS).await { Ok(list) => list, Err(_err) => { self.should_reconnect.store(true, Ordering::Relaxed); @@ -825,11 +895,11 @@ impl Imap { let mut read_errors = 0; let mut new_last_seen_uid = 0; - let list = if let Some(ref mut session) = &mut *self.session.lock().unwrap() { + let list = if let Some(ref mut session) = &mut *self.session.lock().await { // fetch messages with larger UID than the last one seen // (`UID FETCH lastseenuid+1:*)`, see RFC 4549 let set = format!("{}:*", last_seen_uid + 1); - match session.uid_fetch(set, PREFETCH_FLAGS) { + match session.uid_fetch(set, PREFETCH_FLAGS).await { Ok(list) => list, Err(err) => { warn!(context, "failed to fetch uids: {}", err); @@ -850,7 +920,7 @@ impl Imap { if !precheck_imf(context, &message_id, folder.as_ref(), cur_uid) { // 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).await == 0 { info!( context, "Read error for message {} from \"{}\", trying over later.", @@ -914,7 +984,7 @@ impl Imap { context.sql.set_raw_config(context, &key, Some(&val)).ok(); } - fn fetch_single_msg>( + async fn fetch_single_msg>( &self, context: &Context, folder: S, @@ -923,14 +993,14 @@ impl Imap { // the function returns: // 0 the caller should try over again later // or 1 if the messages should be treated as received, the caller should not try to read the message again (even if no database entries are returned) - if !self.is_connected() { + if !self.is_connected().await { return 0; } let set = format!("{}", server_uid); - let msgs = if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.uid_fetch(set, BODY_FLAGS) { + let msgs = if let Some(ref mut session) = &mut *self.session.lock().await { + match session.uid_fetch(set, BODY_FLAGS).await { Ok(msgs) => msgs, Err(err) => { self.should_reconnect.store(true, Ordering::Relaxed); @@ -960,12 +1030,12 @@ impl Imap { let msg = &msgs[0]; // XXX put flags into a set and pass them to dc_receive_imf - let is_deleted = msg.flags().iter().any(|flag| match flag { - imap::types::Flag::Deleted => true, + let is_deleted = msg.flags().any(|flag| match flag { + async_imap::types::Flag::Deleted => true, _ => false, }); - let is_seen = msg.flags().iter().any(|flag| match flag { - imap::types::Flag::Seen => true, + let is_seen = msg.flags().any(|flag| match flag { + async_imap::types::Flag::Seen => true, _ => false, }); @@ -983,113 +1053,27 @@ impl Imap { } pub fn idle(&self, context: &Context) { - if !self.config.read().unwrap().can_idle { - return self.fake_idle(context); - } + task::block_on(async move { + if !self.config.read().await.can_idle { + self.fake_idle(context).await; + return; + } - self.setup_handle_if_needed(context); + self.setup_handle_if_needed(context); - let watch_folder = self.config.read().unwrap().watch_folder.clone(); - if self.select_folder(context, watch_folder.as_ref()) == 0 { - warn!(context, "IMAP-IDLE not setup.",); + let watch_folder = self.config.read().await.watch_folder.clone(); + if self.select_folder(context, watch_folder.as_ref()).await == 0 { + warn!(context, "IMAP-IDLE not setup."); - return self.fake_idle(context); - } + self.fake_idle(context).await; + return; + } - let session = self.session.clone(); - let mut worker = Some({ - let (sender, receiver) = std::sync::mpsc::channel(); - let v = self.watch.clone(); - - info!(context, "IMAP-IDLE SPAWNING"); - std::thread::spawn(move || { - let &(ref lock, ref cvar) = &*v; - if let Some(ref mut session) = &mut *session.lock().unwrap() { - loop { - let res = match session.idle() { - Ok(mut idle) => { - // most servers do not allow more than ~28 minutes; stay clearly below that. - // a good value that is also used by other MUAs is 23 minutes. - // if needed, the ui can call dc_imap_interrupt_idle() to trigger a reconnect. - // idle.set_keepalive(Duration::from_secs(23 * 60)); - idle.set_keepalive(Duration::from_secs(23 * 60)); - idle.wait_keepalive() - } - Err(err) => { - let _ = sender.send(Err(imap::error::Error::Bad(err.to_string()))); - break; - } - }; - match res { - Ok(true) => { - let _ = sender.send(Ok(())); - break; - } - Ok(false) => {} // continue loop - Err(err) => { - let _ = sender.send(Err(imap::error::Error::Bad(format!( - "wait_keepalive failed {}", - err - )))); - break; - } - } - } - // Trigger condvar - let mut watch = lock.lock().unwrap(); - *watch = true; - cvar.notify_one(); - } - }); - receiver + // TODO: IMPLEMENT ME }); - - let &(ref lock, ref cvar) = &*self.watch.clone(); - let mut watch = lock.lock().unwrap(); - - let handle_res = |res| match res { - Ok(()) => { - info!(context, "IMAP-IDLE has data."); - } - Err(err) => match err { - imap::error::Error::Io(_) - | imap::error::Error::ConnectionLost - | imap::error::Error::Bad(_) => { - info!(context, "IMAP-IDLE wait cancelled, we will reconnect soon."); - self.unsetup_handle(context); - info!(context, "IMAP-IDLE has SHUTDOWN"); - self.should_reconnect.store(true, Ordering::Relaxed); - } - _ => { - warn!(context, "IMAP-IDLE returns unknown value: {}", err); - } - }, - }; - - loop { - if let Ok(res) = worker.as_ref().unwrap().try_recv() { - handle_res(res); - break; - } else { - let res = cvar.wait(watch).unwrap(); - watch = res; - if *watch { - if let Ok(res) = worker.as_ref().unwrap().try_recv() { - handle_res(res); - } else { - info!(context, "IMAP-IDLE interrupted"); - } - - drop(worker.take()); - break; - } - } - } - - *watch = false; } - fn fake_idle(&self, context: &Context) { + async fn fake_idle(&self, context: &Context) { // Idle using timeouts. This is also needed if we're not yet configured - // in this case, we're waiting for a configure job let fake_idle_start_time = SystemTime::now(); @@ -1109,59 +1093,56 @@ impl Imap { Duration::new(60, 0) }; - let &(ref lock, ref cvar) = &*self.watch.clone(); - let mut watch = lock.lock().unwrap(); + // TODO: implement me better - loop { - let res = cvar.wait_timeout(watch, seconds_to_wait).unwrap(); - watch = res.0; - if *watch { - do_fake_idle = false; - } - if *watch || res.1.timed_out() { - break; - } - } + // let &(ref lock, ref cvar) = &*self.watch.clone(); + // let mut watch = lock.lock().await; - *watch = false; + // loop { + // let res = cvar.wait_timeout(watch, seconds_to_wait).await; + // watch = res.0; + // if *watch { + // do_fake_idle = false; + // } + // if *watch || res.1.timed_out() { + // break; + // } + // } - if !do_fake_idle { - return; - } + // *watch = false; - // check if we want to finish fake-idling. - if !self.is_connected() { - // try to connect with proper login params - // (setup_handle_if_needed might not know about them if we - // never successfully connected) - if dc_connect_to_configured_imap(context, &self) != 0 { - return; - } - // we cannot connect, wait long next time (currently 60 secs, see above) - wait_long = true; - continue; - } - // we are connected, let's see if fetching messages results - // in anything. If so, we behave as if IDLE had data but - // will have already fetched the messages so perform_*_fetch - // will not find any new. + // if !do_fake_idle { + // return; + // } - let watch_folder = self.config.read().unwrap().watch_folder.clone(); - if let Some(watch_folder) = watch_folder { - if 0 != self.fetch_from_single_folder(context, watch_folder) { - do_fake_idle = false; - } - } + // // check if we want to finish fake-idling. + // if !self.is_connected() { + // // try to connect with proper login params + // // (setup_handle_if_needed might not know about them if we + // // never successfully connected) + // if dc_connect_to_configured_imap(context, &self) != 0 { + // return; + // } + // // we cannot connect, wait long next time (currently 60 secs, see above) + // wait_long = true; + // continue; + // } + // // we are connected, let's see if fetching messages results + // // in anything. If so, we behave as if IDLE had data but + // // will have already fetched the messages so perform_*_fetch + // // will not find any new. + + // let watch_folder = self.config.read().await.watch_folder.clone(); + // if let Some(watch_folder) = watch_folder { + // if 0 != self.fetch_from_single_folder(context, watch_folder) { + // do_fake_idle = false; + // } + // } } } pub fn interrupt_idle(&self) { - // interrupt idle - let &(ref lock, ref cvar) = &*self.watch.clone(); - let mut watch = lock.lock().unwrap(); - - *watch = true; - cvar.notify_one(); + // TODO: implement me } pub fn mv( @@ -1172,72 +1153,77 @@ impl Imap { dest_folder: &str, dest_uid: &mut u32, ) -> ImapResult { - if folder == dest_folder { - info!( - context, - "Skip moving message; message {}/{} is already in {}...", folder, uid, dest_folder, - ); - return ImapResult::AlreadyDone; - } - if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, uid) { - return imapresult; - } - // we are connected, and the folder is selected - - // XXX Rust-Imap provides no target uid on mv, so just set it to 0 - *dest_uid = 0; - - let set = format!("{}", uid); - let display_folder_id = format!("{}/{}", folder, uid); - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.uid_mv(&set, &dest_folder) { - Ok(_) => { - emit_event!( - context, - Event::ImapMessageMoved(format!( - "IMAP Message {} moved to {}", - display_folder_id, dest_folder - )) - ); - return ImapResult::Success; - } - Err(err) => { - warn!( - context, - "Cannot move message, fallback to COPY/DELETE {}/{} to {}: {}", - folder, - uid, - dest_folder, - err - ); - } + task::block_on(async move { + if folder == dest_folder { + info!( + context, + "Skip moving message; message {}/{} is already in {}...", + folder, + uid, + dest_folder, + ); + return ImapResult::AlreadyDone; } - } else { - unreachable!(); - }; + if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, uid) { + return imapresult; + } + // we are connected, and the folder is selected - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.uid_copy(&set, &dest_folder) { - Ok(_) => { - if !self.add_flag_finalized(context, uid, "\\Deleted") { - warn!(context, "Cannot mark {} as \"Deleted\" after copy.", uid); - ImapResult::Failed - } else { - self.config.write().unwrap().selected_folder_needs_expunge = true; - ImapResult::Success + // XXX Rust-Imap provides no target uid on mv, so just set it to 0 + *dest_uid = 0; + + let set = format!("{}", uid); + let display_folder_id = format!("{}/{}", folder, uid); + if let Some(ref mut session) = &mut *self.session.lock().await { + match session.uid_mv(&set, &dest_folder).await { + Ok(_) => { + emit_event!( + context, + Event::ImapMessageMoved(format!( + "IMAP Message {} moved to {}", + display_folder_id, dest_folder + )) + ); + return ImapResult::Success; + } + Err(err) => { + warn!( + context, + "Cannot move message, fallback to COPY/DELETE {}/{} to {}: {}", + folder, + uid, + dest_folder, + err + ); } } - Err(err) => { - warn!(context, "Could not copy message: {}", err); - ImapResult::Failed + } else { + unreachable!(); + }; + + if let Some(ref mut session) = &mut *self.session.lock().await { + match session.uid_copy(&set, &dest_folder).await { + Ok(_) => { + if !self.add_flag_finalized(context, uid, "\\Deleted").await { + warn!(context, "Cannot mark {} as \"Deleted\" after copy.", uid); + ImapResult::Failed + } else { + self.config.write().await.selected_folder_needs_expunge = true; + ImapResult::Success + } + } + Err(err) => { + warn!(context, "Could not copy message: {}", err); + ImapResult::Failed + } } + } else { + unreachable!(); } - } else { - unreachable!(); - } + }) } - fn add_flag_finalized(&self, context: &Context, server_uid: u32, flag: &str) -> bool { + async fn add_flag_finalized(&self, context: &Context, server_uid: u32, flag: &str) -> bool { // return true if we successfully set the flag or we otherwise // think add_flag should not be retried: Disconnection during setting // the flag, or other imap-errors, returns true as well. @@ -1247,16 +1233,21 @@ impl Imap { return true; // might be moved but we don't want to have a stuck job } let s = server_uid.to_string(); - self.add_flag_finalized_with_set(context, &s, flag) + self.add_flag_finalized_with_set(context, &s, flag).await } - fn add_flag_finalized_with_set(&self, context: &Context, uid_set: &str, flag: &str) -> bool { + async fn add_flag_finalized_with_set( + &self, + context: &Context, + uid_set: &str, + flag: &str, + ) -> bool { if self.should_reconnect() { return false; } - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { + if let Some(ref mut session) = &mut *self.session.lock().await { let query = format!("+FLAGS ({})", flag); - match session.uid_store(uid_set, &query) { + match session.uid_store(uid_set, &query).await { Ok(_) => {} Err(err) => { warn!( @@ -1277,41 +1268,45 @@ impl Imap { folder: &str, uid: u32, ) -> Option { - if uid == 0 { - return Some(ImapResult::Failed); - } else if !self.is_connected() { - connect_to_inbox(context, &self); - if !self.is_connected() { - return Some(ImapResult::RetryLater); + task::block_on(async move { + if uid == 0 { + return Some(ImapResult::Failed); + } else if !self.is_connected().await { + connect_to_inbox(context, &self); + if !self.is_connected().await { + return Some(ImapResult::RetryLater); + } } - } - if self.select_folder(context, Some(&folder)) == 0 { - warn!( - context, - "Cannot select folder {} for preparing IMAP operation", folder - ); - Some(ImapResult::RetryLater) - } else { - None - } + if self.select_folder(context, Some(&folder)).await == 0 { + warn!( + context, + "Cannot select folder {} for preparing IMAP operation", folder + ); + Some(ImapResult::RetryLater) + } else { + None + } + }) } pub fn set_seen(&self, context: &Context, folder: &str, uid: u32) -> ImapResult { - if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, uid) { - return imapresult; - } - // we are connected, and the folder is selected - info!(context, "Marking message {}/{} as seen...", folder, uid,); + task::block_on(async move { + if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, uid) { + return imapresult; + } + // we are connected, and the folder is selected + info!(context, "Marking message {}/{} as seen...", folder, uid,); - if self.add_flag_finalized(context, uid, "\\Seen") { - ImapResult::Success - } else { - warn!( - context, - "Cannot mark message {} in folder {} as seen, ignoring.", uid, folder - ); - ImapResult::Failed - } + if self.add_flag_finalized(context, uid, "\\Seen").await { + ImapResult::Success + } else { + warn!( + context, + "Cannot mark message {} in folder {} as seen, ignoring.", uid, folder + ); + ImapResult::Failed + } + }) } // only returns 0 on connection problems; we should try later again in this case * @@ -1322,204 +1317,215 @@ impl Imap { folder: &str, uid: &mut u32, ) -> ImapResult { - if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, *uid) { - return imapresult; - } - // we are connected, and the folder is selected - - let set = format!("{}", uid); - let display_imap_id = format!("{}/{}", folder, uid); - - // double-check that we are deleting the correct message-id - // this comes at the expense of another imap query - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.uid_fetch(set, PREFETCH_FLAGS) { - Ok(msgs) => { - if msgs.is_empty() { - warn!( - context, - "Cannot delete on IMAP, {}: imap entry gone '{}'", - display_imap_id, - message_id, - ); - return ImapResult::Failed; - } - let remote_message_id = - prefetch_get_message_id(msgs.first().unwrap()).unwrap_or_default(); - - if remote_message_id != message_id { - warn!( - context, - "Cannot delete on IMAP, {}: remote message-id '{}' != '{}'", - display_imap_id, - remote_message_id, - message_id, - ); - } - *uid = 0; - } - Err(err) => { - warn!( - context, - "Cannot delete {} on IMAP: {}", display_imap_id, err - ); - *uid = 0; - } + task::block_on(async move { + if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, *uid) { + return imapresult; } - } + // we are connected, and the folder is selected - // mark the message for deletion - if !self.add_flag_finalized(context, *uid, "\\Deleted") { - warn!( - context, - "Cannot mark message {} as \"Deleted\".", display_imap_id - ); - ImapResult::Failed - } else { - emit_event!( - context, - Event::ImapMessageDeleted(format!( - "IMAP Message {} marked as deleted [{}]", - display_imap_id, message_id - )) - ); - self.config.write().unwrap().selected_folder_needs_expunge = true; - ImapResult::Success - } - } + let set = format!("{}", uid); + let display_imap_id = format!("{}/{}", folder, uid); - pub fn configure_folders(&self, context: &Context, flags: libc::c_int) { - if !self.is_connected() { - return; - } + // double-check that we are deleting the correct message-id + // this comes at the expense of another imap query + if let Some(ref mut session) = &mut *self.session.lock().await { + match session.uid_fetch(set, PREFETCH_FLAGS).await { + Ok(msgs) => { + if msgs.is_empty() { + warn!( + context, + "Cannot delete on IMAP, {}: imap entry gone '{}'", + display_imap_id, + message_id, + ); + return ImapResult::Failed; + } + let remote_message_id = + prefetch_get_message_id(msgs.first().unwrap()).unwrap_or_default(); - info!(context, "Configuring IMAP-folders."); - - let folders = self.list_folders(context).unwrap(); - let delimiter = self.config.read().unwrap().imap_delimiter; - let fallback_folder = format!("INBOX{}DeltaChat", delimiter); - - let mut mvbox_folder = folders - .iter() - .find(|folder| folder.name() == "DeltaChat" || folder.name() == fallback_folder) - .map(|n| n.name().to_string()); - - let sentbox_folder = folders - .iter() - .find(|folder| match get_folder_meaning(folder) { - FolderMeaning::SentObjects => true, - _ => false, - }); - - if mvbox_folder.is_none() && 0 != (flags as usize & DC_CREATE_MVBOX) { - info!(context, "Creating MVBOX-folder \"DeltaChat\"...",); - - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - match session.create("DeltaChat") { - Ok(_) => { - mvbox_folder = Some("DeltaChat".into()); - - info!(context, "MVBOX-folder created.",); + if remote_message_id != message_id { + warn!( + context, + "Cannot delete on IMAP, {}: remote message-id '{}' != '{}'", + display_imap_id, + remote_message_id, + message_id, + ); + } + *uid = 0; } Err(err) => { warn!( context, - "Cannot create MVBOX-folder, using trying INBOX subfolder. ({})", err + "Cannot delete {} on IMAP: {}", display_imap_id, err ); + *uid = 0; + } + } + } - match session.create(&fallback_folder) { - Ok(_) => { - mvbox_folder = Some(fallback_folder); - info!( - context, - "MVBOX-folder created as INBOX subfolder. ({})", err - ); - } - Err(err) => { - warn!(context, "Cannot create MVBOX-folder. ({})", err); + // mark the message for deletion + if !self.add_flag_finalized(context, *uid, "\\Deleted").await { + warn!( + context, + "Cannot mark message {} as \"Deleted\".", display_imap_id + ); + ImapResult::Failed + } else { + emit_event!( + context, + Event::ImapMessageDeleted(format!( + "IMAP Message {} marked as deleted [{}]", + display_imap_id, message_id + )) + ); + self.config.write().await.selected_folder_needs_expunge = true; + ImapResult::Success + } + }) + } + + pub fn configure_folders(&self, context: &Context, flags: libc::c_int) { + task::block_on(async move { + if !self.is_connected().await { + return; + } + + info!(context, "Configuring IMAP-folders."); + + if let Some(ref mut session) = &mut *self.session.lock().await { + let folders = self + .list_folders(session, context) + .await + .expect("no folders found"); + let delimiter = self.config.read().await.imap_delimiter; + let fallback_folder = format!("INBOX{}DeltaChat", delimiter); + + let mut mvbox_folder = folders + .iter() + .find(|folder| folder.name() == "DeltaChat" || folder.name() == fallback_folder) + .map(|n| n.name().to_string()); + + let sentbox_folder = + folders + .iter() + .find(|folder| match get_folder_meaning(folder) { + FolderMeaning::SentObjects => true, + _ => false, + }); + + if mvbox_folder.is_none() && 0 != (flags as usize & DC_CREATE_MVBOX) { + info!(context, "Creating MVBOX-folder \"DeltaChat\"...",); + + match session.create("DeltaChat").await { + Ok(_) => { + mvbox_folder = Some("DeltaChat".into()); + + info!(context, "MVBOX-folder created.",); + } + Err(err) => { + warn!( + context, + "Cannot create MVBOX-folder, using trying INBOX subfolder. ({})", + err + ); + + match session.create(&fallback_folder).await { + Ok(_) => { + mvbox_folder = Some(fallback_folder); + info!( + context, + "MVBOX-folder created as INBOX subfolder. ({})", err + ); + } + Err(err) => { + warn!(context, "Cannot create MVBOX-folder. ({})", err); + } } } } + // SUBSCRIBE is needed to make the folder visible to the LSUB command + // that may be used by other MUAs to list folders. + // for the LIST command, the folder is always visible. + if let Some(ref mvbox) = mvbox_folder { + // TODO: better error handling + session.subscribe(mvbox).await.expect("failed to subscribe"); + } } - // SUBSCRIBE is needed to make the folder visible to the LSUB command - // that may be used by other MUAs to list folders. - // for the LIST command, the folder is always visible. - if let Some(ref mvbox) = mvbox_folder { - // TODO: better error handling - session.subscribe(mvbox).expect("failed to subscribe"); + + context + .sql + .set_raw_config_int(context, "folders_configured", 3) + .ok(); + if let Some(ref mvbox_folder) = mvbox_folder { + context + .sql + .set_raw_config(context, "configured_mvbox_folder", Some(mvbox_folder)) + .ok(); + } + if let Some(ref sentbox_folder) = sentbox_folder { + context + .sql + .set_raw_config( + context, + "configured_sentbox_folder", + Some(sentbox_folder.name()), + ) + .ok(); } } - } - - context - .sql - .set_raw_config_int(context, "folders_configured", 3) - .ok(); - if let Some(ref mvbox_folder) = mvbox_folder { - context - .sql - .set_raw_config(context, "configured_mvbox_folder", Some(mvbox_folder)) - .ok(); - } - if let Some(ref sentbox_folder) = sentbox_folder { - context - .sql - .set_raw_config( - context, - "configured_sentbox_folder", - Some(sentbox_folder.name()), - ) - .ok(); - } + }) } - fn list_folders( + async fn list_folders<'a>( &self, + session: &'a mut Session, context: &Context, - ) -> Option>> { - if let Some(ref mut session) = &mut *self.session.lock().unwrap() { - // TODO: use xlist when available - match session.list(Some(""), Some("*")) { - Ok(list) => { - if list.is_empty() { - warn!(context, "Folder list is empty.",); - } - Some(list) - } - Err(err) => { - eprintln!("list error: {:?}", err); - warn!(context, "Cannot get folder list.",); - - None + ) -> Option> { + // TODO: use xlist when available + match session.list(Some(""), Some("*")).await { + Ok(list) => { + if list.is_empty() { + warn!(context, "Folder list is empty.",); } + Some(list) + } + Err(err) => { + eprintln!("list error: {:?}", err); + warn!(context, "Cannot get folder list.",); + + None } - } else { - None } } pub fn empty_folder(&self, context: &Context, folder: &str) { - info!(context, "emptying folder {}", folder); + task::block_on(async move { + info!(context, "emptying folder {}", folder); - if folder.is_empty() || self.select_folder(context, Some(&folder)) == 0 { - warn!(context, "Cannot select folder '{}' for emptying", folder); - return; - } - - if !self.add_flag_finalized_with_set(context, SELECT_ALL, "\\Deleted") { - warn!(context, "Cannot empty folder {}", folder); - } else { - // we now trigger expunge to actually delete messages - self.config.write().unwrap().selected_folder_needs_expunge = true; - if self.select_folder::(context, None) == 0 { - warn!( - context, - "could not perform expunge on empty-marked folder {}", folder - ); - } else { - emit_event!(context, Event::ImapFolderEmptied(folder.to_string())); + if folder.is_empty() || self.select_folder(context, Some(&folder)).await == 0 { + warn!(context, "Cannot select folder '{}' for emptying", folder); + return; } - } + + if !self + .add_flag_finalized_with_set(context, SELECT_ALL, "\\Deleted") + .await + { + warn!(context, "Cannot empty folder {}", folder); + } else { + // we now trigger expunge to actually delete messages + self.config.write().await.selected_folder_needs_expunge = true; + if self.select_folder::(context, None).await == 0 { + warn!( + context, + "could not perform expunge on empty-marked folder {}", folder + ); + } else { + emit_event!(context, Event::ImapFolderEmptied(folder.to_string())); + } + } + }); } } @@ -1529,7 +1535,7 @@ impl Imap { // only watching this folder is not working. at least, this is no show stopper. // CAVE: if possible, take care not to add a name here that is "sent" in one language // but sth. different in others - a hard job. -fn get_folder_meaning_by_name(folder_name: &imap::types::Name) -> FolderMeaning { +fn get_folder_meaning_by_name(folder_name: &async_imap::types::Name) -> FolderMeaning { let sent_names = vec!["sent", "sent objects", "gesendet"]; let lower = folder_name.name().to_lowercase(); @@ -1540,7 +1546,7 @@ fn get_folder_meaning_by_name(folder_name: &imap::types::Name) -> FolderMeaning } } -fn get_folder_meaning(folder_name: &imap::types::Name) -> FolderMeaning { +fn get_folder_meaning(folder_name: &async_imap::types::Name) -> FolderMeaning { if folder_name.attributes().is_empty() { return FolderMeaning::Unknown; } @@ -1550,7 +1556,7 @@ fn get_folder_meaning(folder_name: &imap::types::Name) -> FolderMeaning { for attr in folder_name.attributes() { match attr { - imap::types::NameAttribute::Custom(ref label) => { + async_imap::types::NameAttribute::Custom(ref label) => { if special_names.iter().find(|s| *s == label).is_some() { res = FolderMeaning::Other; } else if label == "\\Sent" { @@ -1594,7 +1600,7 @@ fn precheck_imf(context: &Context, rfc724_mid: &str, server_folder: &str, server } } -fn prefetch_get_message_id(prefetch_msg: &imap::types::Fetch) -> Result { +fn prefetch_get_message_id(prefetch_msg: &async_imap::types::Fetch) -> Result { let message_id = prefetch_msg.envelope().unwrap().message_id.unwrap(); wrapmime::parse_message_id(&message_id) } diff --git a/src/job_thread.rs b/src/job_thread.rs index 369078c04..8204a98e0 100644 --- a/src/job_thread.rs +++ b/src/job_thread.rs @@ -107,7 +107,7 @@ impl JobThread { } fn connect_to_imap(&self, context: &Context) -> bool { - if self.imap.is_connected() { + if async_std::task::block_on(async move { self.imap.is_connected().await }) { return true; }