mirror of
https://github.com/chatmail/core.git
synced 2026-04-03 22:12:11 +03:00
Compare commits
28 Commits
fix_progre
...
fix_set_pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f101439175 | ||
|
|
18b70bff0e | ||
|
|
d4bd9187d6 | ||
|
|
712f5a9782 | ||
|
|
29d4f6888d | ||
|
|
5b47409fb0 | ||
|
|
8077fdeddb | ||
|
|
6f290e249f | ||
|
|
a655f2cbba | ||
|
|
0cb42f840d | ||
|
|
99aabef7f3 | ||
|
|
7d51c6e4f4 | ||
|
|
f463fb3759 | ||
|
|
cb0eb0e68e | ||
|
|
8009f220fc | ||
|
|
4f1551b91f | ||
|
|
6ba37a135e | ||
|
|
dab514d8bc | ||
|
|
8342b29618 | ||
|
|
e05944c6cb | ||
|
|
88a81f5737 | ||
|
|
9cf6ca045c | ||
|
|
ba381d0d0b | ||
|
|
033ebc7ce3 | ||
|
|
6292219551 | ||
|
|
523141597e | ||
|
|
cfed5c914c | ||
|
|
20f9bb3b14 |
@@ -13,7 +13,7 @@ restore-workspace: &restore-workspace
|
||||
restore-cache: &restore-cache
|
||||
restore_cache:
|
||||
keys:
|
||||
- cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
|
||||
- cargo-v1-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
|
||||
- repo-source-{{ .Branch }}-{{ .Revision }}
|
||||
|
||||
commands:
|
||||
@@ -53,10 +53,11 @@ jobs:
|
||||
command: cargo generate-lockfile
|
||||
- restore_cache:
|
||||
keys:
|
||||
- cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
|
||||
- cargo-v1-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
|
||||
- run: rustup install $(cat rust-toolchain)
|
||||
- run: rustup default $(cat rust-toolchain)
|
||||
- run: rustup component add --toolchain $(cat rust-toolchain) rustfmt
|
||||
- run: rustup component add --toolchain $(cat rust-toolchain) clippy-preview
|
||||
- run: cargo update
|
||||
- run: cargo fetch
|
||||
- run: rustc +stable --version
|
||||
@@ -67,7 +68,7 @@ jobs:
|
||||
paths:
|
||||
- crate
|
||||
- save_cache:
|
||||
key: cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
|
||||
key: cargo-v1-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
|
||||
paths:
|
||||
- "~/.cargo"
|
||||
- "~/.rustup"
|
||||
@@ -160,6 +161,15 @@ jobs:
|
||||
- run: ls -laR workspace
|
||||
- run: ci_scripts/ci_upload.sh workspace/py-docs workspace/wheelhouse
|
||||
|
||||
clippy:
|
||||
executor: default
|
||||
steps:
|
||||
- *restore-workspace
|
||||
- *restore-cache
|
||||
- run:
|
||||
name: Run cargo clippy
|
||||
command: cargo clippy --all
|
||||
|
||||
|
||||
workflows:
|
||||
version: 2.1
|
||||
@@ -175,6 +185,10 @@ workflows:
|
||||
requires:
|
||||
- cargo_fetch
|
||||
|
||||
- clippy:
|
||||
requires:
|
||||
- cargo_fetch
|
||||
|
||||
# Linux Desktop 64bit
|
||||
- test_x86_64-unknown-linux-gnu:
|
||||
requires:
|
||||
|
||||
167
Cargo.lock
generated
167
Cargo.lock
generated
@@ -1,18 +1,5 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "addr"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"psl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rental 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.0.3"
|
||||
@@ -212,6 +199,11 @@ name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.3.2"
|
||||
@@ -236,6 +228,18 @@ dependencies = [
|
||||
"ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cast5"
|
||||
version = "0.6.0"
|
||||
@@ -458,9 +462,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat"
|
||||
version = "1.0.0-alpha.3"
|
||||
version = "1.0.0-alpha.4"
|
||||
dependencies = [
|
||||
"addr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -471,6 +474,7 @@ dependencies = [
|
||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure_derive 0.1.5 (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 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -512,9 +516,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat_ffi"
|
||||
version = "1.0.0-alpha.3"
|
||||
version = "1.0.0-alpha.4"
|
||||
dependencies = [
|
||||
"deltachat 1.0.0-alpha.3",
|
||||
"deltachat 1.0.0-alpha.4",
|
||||
"human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -756,6 +760,11 @@ dependencies = [
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.1.26"
|
||||
@@ -901,6 +910,16 @@ dependencies = [
|
||||
"unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image-meta"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"skeptic 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imap"
|
||||
version = "1.0.2"
|
||||
@@ -1569,39 +1588,6 @@ dependencies = [
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psl"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"psl-codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psl-codegen"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"psl-lexer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sequence_trie 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psl-lexer"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "publicsuffix"
|
||||
version = "1.5.2"
|
||||
@@ -1614,6 +1600,14 @@ dependencies = [
|
||||
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "1.2.2"
|
||||
@@ -1844,25 +1838,6 @@ dependencies = [
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rental"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rental-impl 0.5.4 (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.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.9.19"
|
||||
@@ -1976,6 +1951,14 @@ name = "safemem"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.15"
|
||||
@@ -2033,6 +2016,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2040,11 +2024,6 @@ name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "sequence_trie"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.98"
|
||||
@@ -2123,6 +2102,21 @@ name = "siphasher"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "skeptic"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.2"
|
||||
@@ -2561,6 +2555,16 @@ name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "want"
|
||||
version = "0.2.0"
|
||||
@@ -2679,7 +2683,6 @@ dependencies = [
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum addr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22199dd03e5cff19ede8c2b835c93460f998b4716e225d06d740d925ceac5d75"
|
||||
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
|
||||
"checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9"
|
||||
"checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d"
|
||||
@@ -2705,9 +2708,11 @@ dependencies = [
|
||||
"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 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"
|
||||
"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
|
||||
"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101"
|
||||
"checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe"
|
||||
"checksum cast5 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ce5759b4c52ca74f9a98421817c882f1fd9b0071ae41cd61ab9f9d059c04fd6"
|
||||
"checksum cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ce400c638d48ee0e9ab75aef7997609ec57367ccfe1463f21bf53c3eca67bf46"
|
||||
"checksum cfb-mode 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "190e7b55d3a27cf8879becf61035a141cbc783f3258a41d16d1706719f991345"
|
||||
@@ -2763,6 +2768,7 @@ dependencies = [
|
||||
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
||||
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
||||
"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8"
|
||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462"
|
||||
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
||||
@@ -2776,6 +2782,7 @@ dependencies = [
|
||||
"checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
|
||||
"checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
|
||||
"checksum image-meta 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b00861cbbb254a627d8acc0cec786b484297d896ab8f20fdc8e28536a3e918ef"
|
||||
"checksum imap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "178392198cb2716f4fe34b86a1bf1de1240a3e31136a199b16490fa87538fa25"
|
||||
"checksum imap-proto 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4e77b1d61faf028893531b071cc5584cdd02b6186cebe7f7168ffd8d591339a"
|
||||
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
|
||||
@@ -2846,10 +2853,8 @@ dependencies = [
|
||||
"checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
|
||||
"checksum pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8b3f4e0475def7d9c2e5de8e5a1306949849761e107b360d03e98eafaffd61"
|
||||
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||
"checksum psl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0fcd4da9d98f254ad641dd081207cc14fcbec95dd58ee62ffc9b96f0684fd6c2"
|
||||
"checksum psl-codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "06f94f31e4f36b42e21b831d20bf0efc805b2155624697fb86f987b666518c3b"
|
||||
"checksum psl-lexer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cf84fe23023e855b9a9d038a1b08d5c438d3961d2ced6c2b2358b29fbf74a63"
|
||||
"checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d"
|
||||
"checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15"
|
||||
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||
"checksum r2d2 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bc42ce75d9f4447fb2a04bbe1ed5d18dd949104572850ec19b164e274919f81b"
|
||||
@@ -2875,8 +2880,6 @@ dependencies = [
|
||||
"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc"
|
||||
"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c"
|
||||
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
|
||||
"checksum rental 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "01916ebd9fc2e81978a5dc9542a2fa47f5bb2ca3402e14c7cc42d6e3c5123e1f"
|
||||
"checksum rental-impl 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "82260d54cf2cbe9608df161f7e7c98e81fae702aa13af9e4d5d39dc2ffb25ab6"
|
||||
"checksum reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0777154c2c3eb54f5c480db01de845652d941e47191277cc673634c3853939"
|
||||
"checksum ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a"
|
||||
"checksum rsa 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6ad8d3632f6745bb671c8637e2aa44015537c5e384789d2ea3235739301ed1e0"
|
||||
@@ -2886,6 +2889,7 @@ dependencies = [
|
||||
"checksum rustyline 4.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f47ea1ceb347d2deae482d655dc8eef4bd82363d3329baffa3818bd76fea48b"
|
||||
"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
|
||||
"checksum safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e133ccc4f4d1cd4f89cc8a7ff618287d56dc7f638b8e38fc32c5fdcadc339dd5"
|
||||
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
|
||||
"checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339"
|
||||
"checksum scheduled-thread-pool 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd07742e081ff6c077f5f6b283f12f32b9e7cc765b316160d66289b74546fbb3"
|
||||
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||
@@ -2895,7 +2899,6 @@ dependencies = [
|
||||
"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"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum sequence_trie 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1ee22067b7ccd072eeb64454b9c6e1b33b61cd0d49e895fd48676a184580e0c3"
|
||||
"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113"
|
||||
"checksum serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "01e69e1b8a631f245467ee275b8c757b818653c6d704cdbcaeb56b56767b529c"
|
||||
"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704"
|
||||
@@ -2904,6 +2907,7 @@ dependencies = [
|
||||
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
|
||||
"checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf"
|
||||
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
|
||||
"checksum skeptic 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fb8ed853fdc19ce09752d63f3a2e5b5158aeb261520cd75eb618bd60305165"
|
||||
"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.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
|
||||
@@ -2957,6 +2961,7 @@ dependencies = [
|
||||
"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95"
|
||||
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"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 winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat"
|
||||
version = "1.0.0-alpha.3"
|
||||
version = "1.0.0-alpha.4"
|
||||
authors = ["dignifiedquire <dignifiedquire@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MPL"
|
||||
@@ -37,7 +37,6 @@ rustyline = "4.1.0"
|
||||
lazy_static = "1.3.0"
|
||||
regex = "1.1.6"
|
||||
rusqlite = { version = "0.20", features = ["bundled"] }
|
||||
addr = "0.2.0"
|
||||
r2d2_sqlite = "0.12.0"
|
||||
r2d2 = "0.8.5"
|
||||
strum = "0.15.0"
|
||||
@@ -46,6 +45,7 @@ thread-local-object = "0.1.0"
|
||||
backtrace = "0.3.33"
|
||||
byteorder = "1.3.1"
|
||||
itertools = "0.8.0"
|
||||
image-meta = "0.1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.0"
|
||||
|
||||
@@ -39,7 +39,7 @@ if [ -n "$TESTS" ]; then
|
||||
# run tox
|
||||
# XXX we don't run liveconfig tests because they hang sometimes
|
||||
# see https://github.com/deltachat/deltachat-core-rust/issues/331
|
||||
unset DCC_PY_LIVECONFIG
|
||||
# unset DCC_PY_LIVECONFIG
|
||||
|
||||
tox --workdir "$TOXWORKDIR" -e lint,py27,py35,py36,py37,auditwheels
|
||||
popd
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat_ffi"
|
||||
version = "1.0.0-alpha.3"
|
||||
version = "1.0.0-alpha.4"
|
||||
description = "Deltachat FFI"
|
||||
authors = ["dignifiedquire <dignifiedquire@gmail.com>"]
|
||||
edition = "2018"
|
||||
@@ -25,4 +25,3 @@ default = ["vendored", "nightly", "ringbuf"]
|
||||
vendored = ["deltachat/vendored"]
|
||||
nightly = ["deltachat/nightly"]
|
||||
ringbuf = ["deltachat/ringbuf"]
|
||||
|
||||
|
||||
@@ -372,14 +372,10 @@ void dc_delete_all_locations (dc_context_t*);
|
||||
*/
|
||||
void dc_array_unref (dc_array_t*);
|
||||
|
||||
void dc_array_add_uint (dc_array_t*, uintptr_t);
|
||||
void dc_array_add_id (dc_array_t*, uint32_t);
|
||||
void dc_array_add_ptr (dc_array_t*, void*);
|
||||
|
||||
size_t dc_array_get_cnt (const dc_array_t*);
|
||||
uintptr_t dc_array_get_uint (const dc_array_t*, size_t index);
|
||||
uint32_t dc_array_get_id (const dc_array_t*, size_t index);
|
||||
void* dc_array_get_ptr (const dc_array_t*, size_t index);
|
||||
double dc_array_get_latitude (const dc_array_t*, size_t index);
|
||||
double dc_array_get_longitude (const dc_array_t*, size_t index);
|
||||
double dc_array_get_accuracy (const dc_array_t*, size_t index);
|
||||
@@ -391,7 +387,7 @@ char* dc_array_get_marker (const dc_array_t*, size_t index);
|
||||
int dc_array_is_independent (const dc_array_t*, size_t index);
|
||||
|
||||
int dc_array_search_id (const dc_array_t*, uint32_t needle, size_t* indx);
|
||||
const uintptr_t* dc_array_get_raw (const dc_array_t*);
|
||||
const uint32_t* dc_array_get_raw (const dc_array_t*);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -645,7 +645,7 @@ pub unsafe extern "C" fn dc_set_chat_profile_image(
|
||||
assert!(chat_id > constants::DC_CHAT_ID_LAST_SPECIAL as u32);
|
||||
let context = &*context;
|
||||
|
||||
dc_chat::dc_set_chat_profile_image(context, chat_id, image)
|
||||
dc_chat::dc_set_chat_profile_image(context, chat_id, &dc_tools::to_string(image)) as libc::c_int
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -837,7 +837,7 @@ pub unsafe extern "C" fn dc_get_blocked_contacts(
|
||||
assert!(!context.is_null());
|
||||
let context = &*context;
|
||||
|
||||
Contact::get_all_blocked(context)
|
||||
dc_array_t::from(Contact::get_all_blocked(context)).into_raw()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -1064,24 +1064,12 @@ pub unsafe extern "C" fn dc_array_unref(a: *mut dc_array::dc_array_t) {
|
||||
dc_array::dc_array_unref(a)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_add_uint(array: *mut dc_array_t, item: libc::uintptr_t) {
|
||||
assert!(!array.is_null());
|
||||
|
||||
dc_array::dc_array_add_uint(array, item)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_add_id(array: *mut dc_array_t, item: libc::c_uint) {
|
||||
assert!(!array.is_null());
|
||||
|
||||
dc_array::dc_array_add_id(array, item)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_add_ptr(array: *mut dc_array_t, item: *mut libc::c_void) {
|
||||
assert!(!array.is_null());
|
||||
|
||||
dc_array::dc_array_add_ptr(array, item)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_get_cnt(array: *const dc_array_t) -> libc::size_t {
|
||||
@@ -1090,15 +1078,6 @@ pub unsafe extern "C" fn dc_array_get_cnt(array: *const dc_array_t) -> libc::siz
|
||||
dc_array::dc_array_get_cnt(array)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_get_uint(
|
||||
array: *const dc_array_t,
|
||||
index: libc::size_t,
|
||||
) -> libc::uintptr_t {
|
||||
assert!(!array.is_null());
|
||||
|
||||
dc_array::dc_array_get_uint(array, index)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_get_id(
|
||||
array: *const dc_array_t,
|
||||
index: libc::size_t,
|
||||
@@ -1108,15 +1087,6 @@ pub unsafe extern "C" fn dc_array_get_id(
|
||||
dc_array::dc_array_get_id(array, index)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_get_ptr(
|
||||
array: *const dc_array_t,
|
||||
index: libc::size_t,
|
||||
) -> *mut libc::c_void {
|
||||
assert!(!array.is_null());
|
||||
|
||||
dc_array::dc_array_get_ptr(array, index)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_get_latitude(
|
||||
array: *const dc_array_t,
|
||||
index: libc::size_t,
|
||||
@@ -1201,7 +1171,7 @@ pub unsafe extern "C" fn dc_array_search_id(
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_array_get_raw(array: *const dc_array_t) -> *const libc::size_t {
|
||||
pub unsafe extern "C" fn dc_array_get_raw(array: *const dc_array_t) -> *const u32 {
|
||||
assert!(!array.is_null());
|
||||
|
||||
dc_array::dc_array_get_raw(array)
|
||||
|
||||
@@ -810,15 +810,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
||||
ensure!(!sel_chat.is_null(), "No chat selected.");
|
||||
ensure!(!arg1.is_empty(), "Argument <image> missing.");
|
||||
|
||||
if 0 != dc_set_chat_profile_image(
|
||||
context,
|
||||
dc_chat_get_id(sel_chat),
|
||||
if !arg1.is_empty() {
|
||||
arg1_c
|
||||
} else {
|
||||
std::ptr::null_mut()
|
||||
},
|
||||
) {
|
||||
if dc_set_chat_profile_image(context, dc_chat_get_id(sel_chat), arg1) {
|
||||
println!("Chat image set");
|
||||
} else {
|
||||
bail!("Failed to set chat image");
|
||||
@@ -1126,20 +1118,10 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
||||
}
|
||||
"fileinfo" => {
|
||||
ensure!(!arg1.is_empty(), "Argument <file> missing.");
|
||||
let mut buf = 0 as *mut libc::c_uchar;
|
||||
let mut buf_bytes = 0;
|
||||
let mut w = 0;
|
||||
let mut h = 0;
|
||||
|
||||
if 0 != dc_read_file(
|
||||
context,
|
||||
arg1_c,
|
||||
&mut buf as *mut *mut libc::c_uchar as *mut *mut libc::c_void,
|
||||
&mut buf_bytes,
|
||||
) {
|
||||
dc_get_filemeta(buf as *const libc::c_void, buf_bytes, &mut w, &mut h);
|
||||
println!("width={}, height={}", w, h,);
|
||||
free(buf as *mut libc::c_void);
|
||||
if let Some(buf) = dc_read_file_safe(context, &arg1) {
|
||||
let (width, height) = dc_get_filemeta(&buf)?;
|
||||
println!("width={}, height={}", width, height);
|
||||
} else {
|
||||
bail!("Command failed.");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
//!
|
||||
//! Usage: cargo run --example repl --release -- <databasefile>
|
||||
//! All further options can be set using the set-command (type ? for help).
|
||||
#![feature(ptr_cast)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate deltachat;
|
||||
|
||||
@@ -37,16 +37,3 @@ Message
|
||||
.. autoclass:: deltachat.message.Message
|
||||
:members:
|
||||
|
||||
MessageType
|
||||
------------
|
||||
|
||||
.. autoclass:: deltachat.message.MessageType
|
||||
:members:
|
||||
|
||||
MessageState
|
||||
------------
|
||||
|
||||
.. autoclass:: deltachat.message.MessageState
|
||||
:members:
|
||||
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ Playing around on the commandline
|
||||
----------------------------------
|
||||
|
||||
Once you have :doc:`installed deltachat bindings <install>`
|
||||
you can start playing from the python interpreter commandline::
|
||||
|
||||
you can start playing from the python interpreter commandline.
|
||||
For example you can type ``python`` and then::
|
||||
|
||||
# instantiate and configure deltachat account
|
||||
@@ -23,7 +22,7 @@ For example you can type ``python`` and then::
|
||||
# create a contact and send a message
|
||||
contact = ac.create_contact("someother@email.address")
|
||||
chat = ac.create_chat_by_contact(contact)
|
||||
chat.send_text_message("hi from the python interpreter command line")
|
||||
chat.send_text("hi from the python interpreter command line")
|
||||
|
||||
Checkout our :doc:`api` for the various high-level things you can do
|
||||
to send/receive messages, create contacts and chats.
|
||||
|
||||
@@ -1 +1 @@
|
||||
nightly-2019-07-10
|
||||
nightly-2019-08-13
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::dc_msg::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::error::Result;
|
||||
use crate::stock::StockMessage;
|
||||
use std::ptr;
|
||||
|
||||
/// An object representing a single chatlist in memory.
|
||||
///
|
||||
@@ -290,7 +291,7 @@ impl<'a> Chatlist<'a> {
|
||||
};
|
||||
|
||||
if (*chat).id == DC_CHAT_ID_ARCHIVED_LINK as u32 {
|
||||
(*ret).text2 = dc_strdup(0 as *const libc::c_char)
|
||||
(*ret).text2 = dc_strdup(ptr::null())
|
||||
} else if lastmsg.is_null() || (*lastmsg).from_id == DC_CONTACT_ID_UNDEFINED as u32 {
|
||||
(*ret).text2 = self.context.stock_str(StockMessage::NoMessages).strdup();
|
||||
} else {
|
||||
|
||||
@@ -71,7 +71,7 @@ impl Context {
|
||||
let rel_path = self.sql.get_config(self, key);
|
||||
rel_path.map(|p| dc_get_abs_path_safe(self, &p).to_str().unwrap().to_string())
|
||||
}
|
||||
Config::SysVersion => Some(std::str::from_utf8(DC_VERSION_STR).unwrap().into()),
|
||||
Config::SysVersion => Some((&*DC_VERSION_STR).clone()),
|
||||
Config::SysMsgsizeMaxRecommended => Some(format!("{}", 24 * 1024 * 1024 / 4 * 3)),
|
||||
Config::SysConfigKeys => Some(get_config_keys_string()),
|
||||
_ => self.sql.get_config(self, key),
|
||||
@@ -120,8 +120,7 @@ impl Context {
|
||||
value
|
||||
};
|
||||
|
||||
let ret = self.sql.set_config(self, key, val);
|
||||
ret
|
||||
self.sql.set_config(self, key, val)
|
||||
}
|
||||
_ => self.sql.set_config(self, key, value),
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
//! Constants
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use deltachat_derive::*;
|
||||
|
||||
pub const DC_VERSION_STR: &'static [u8; 14] = b"1.0.0-alpha.3\x00";
|
||||
lazy_static! {
|
||||
pub static ref DC_VERSION_STR: String = env!("CARGO_PKG_VERSION").to_string();
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql)]
|
||||
|
||||
@@ -7,7 +7,6 @@ use crate::aheader::EncryptPreference;
|
||||
use crate::config::Config;
|
||||
use crate::constants::*;
|
||||
use crate::context::Context;
|
||||
use crate::dc_array::*;
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_loginparam::*;
|
||||
use crate::dc_tools::*;
|
||||
@@ -564,24 +563,19 @@ impl<'a> Contact<'a> {
|
||||
}
|
||||
|
||||
/// Get blocked contacts.
|
||||
pub fn get_all_blocked(context: &Context) -> *mut dc_array_t {
|
||||
pub fn get_all_blocked(context: &Context) -> Vec<u32> {
|
||||
context
|
||||
.sql
|
||||
.query_map(
|
||||
"SELECT id FROM contacts WHERE id>? AND blocked!=0 ORDER BY LOWER(name||addr),id;",
|
||||
params![DC_CONTACT_ID_LAST_SPECIAL as i32],
|
||||
|row| row.get::<_, i32>(0),
|
||||
|row| row.get::<_, u32>(0),
|
||||
|ids| {
|
||||
let mut ret = Vec::new();
|
||||
|
||||
for id in ids {
|
||||
ret.push(id? as u32);
|
||||
}
|
||||
|
||||
Ok(dc_array_t::from(ret).into_raw())
|
||||
ids.collect::<std::result::Result<Vec<_>, _>>()
|
||||
.map_err(Into::into)
|
||||
},
|
||||
)
|
||||
.unwrap_or_else(|_| std::ptr::null_mut())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Returns a textual summary of the encryption state for the contact.
|
||||
@@ -915,20 +909,7 @@ pub fn get_first_name<'a>(full_name: &'a str) -> &'a str {
|
||||
|
||||
/// Returns false if addr is an invalid address, otherwise true.
|
||||
pub fn may_be_valid_addr(addr: &str) -> bool {
|
||||
if addr.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let at = addr.find('@').unwrap_or_default();
|
||||
if at < 1 {
|
||||
return false;
|
||||
}
|
||||
let dot = addr.find('.').unwrap_or_default();
|
||||
if dot < 1 || dot > addr.len() - 3 || dot < at + 2 {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
addr.parse::<EmailAddress>().is_ok()
|
||||
}
|
||||
|
||||
pub fn addr_normalize(addr: &str) -> &str {
|
||||
|
||||
@@ -19,10 +19,13 @@ use crate::smtp::*;
|
||||
use crate::sql::Sql;
|
||||
use crate::types::*;
|
||||
use crate::x::*;
|
||||
use std::ptr;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub struct Context {
|
||||
pub userdata: *mut libc::c_void,
|
||||
pub dbfile: Arc<RwLock<*mut libc::c_char>>,
|
||||
pub dbfile: Arc<RwLock<Option<PathBuf>>>,
|
||||
pub blobdir: Arc<RwLock<*mut libc::c_char>>,
|
||||
pub sql: Sql,
|
||||
pub inbox: Arc<RwLock<Imap>>,
|
||||
@@ -54,15 +57,17 @@ pub struct RunningState {
|
||||
|
||||
impl Context {
|
||||
pub fn has_dbfile(&self) -> bool {
|
||||
!self.get_dbfile().is_null()
|
||||
self.get_dbfile().is_some()
|
||||
}
|
||||
|
||||
pub fn has_blobdir(&self) -> bool {
|
||||
!self.get_blobdir().is_null()
|
||||
}
|
||||
|
||||
pub fn get_dbfile(&self) -> *const libc::c_char {
|
||||
*self.dbfile.clone().read().unwrap()
|
||||
pub fn get_dbfile(&self) -> Option<PathBuf> {
|
||||
(*self.dbfile.clone().read().unwrap())
|
||||
.as_ref()
|
||||
.map(|x| x.clone())
|
||||
}
|
||||
|
||||
pub fn get_blobdir(&self) -> *const libc::c_char {
|
||||
@@ -129,7 +134,7 @@ pub fn dc_context_new(
|
||||
) -> Context {
|
||||
Context {
|
||||
blobdir: Arc::new(RwLock::new(std::ptr::null_mut())),
|
||||
dbfile: Arc::new(RwLock::new(std::ptr::null_mut())),
|
||||
dbfile: Arc::new(RwLock::new(None)),
|
||||
inbox: Arc::new(RwLock::new({
|
||||
Imap::new(
|
||||
cb_get_config,
|
||||
@@ -140,7 +145,7 @@ pub fn dc_context_new(
|
||||
})),
|
||||
userdata,
|
||||
cb,
|
||||
os_name: os_name,
|
||||
os_name,
|
||||
running_state: Arc::new(RwLock::new(Default::default())),
|
||||
sql: Sql::new(),
|
||||
smtp: Arc::new(Mutex::new(Smtp::new())),
|
||||
@@ -201,7 +206,7 @@ unsafe fn cb_precheck_imf(
|
||||
) -> libc::c_int {
|
||||
let mut rfc724_mid_exists: libc::c_int = 0i32;
|
||||
let msg_id: uint32_t;
|
||||
let mut old_server_folder: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut old_server_folder: *mut libc::c_char = ptr::null_mut();
|
||||
let mut old_server_uid: uint32_t = 0i32 as uint32_t;
|
||||
let mut mark_seen: libc::c_int = 0i32;
|
||||
msg_id = dc_rfc724_mid_exists(
|
||||
@@ -240,7 +245,7 @@ unsafe fn cb_precheck_imf(
|
||||
}
|
||||
}
|
||||
free(old_server_folder as *mut libc::c_void);
|
||||
return rfc724_mid_exists;
|
||||
rfc724_mid_exists
|
||||
}
|
||||
|
||||
fn cb_set_config(context: &Context, key: &str, value: Option<&str>) {
|
||||
@@ -281,18 +286,14 @@ pub unsafe fn dc_close(context: &Context) {
|
||||
|
||||
context.sql.close(context);
|
||||
let mut dbfile = context.dbfile.write().unwrap();
|
||||
free(*dbfile as *mut libc::c_void);
|
||||
*dbfile = 0 as *mut libc::c_char;
|
||||
*dbfile = None;
|
||||
let mut blobdir = context.blobdir.write().unwrap();
|
||||
free(*blobdir as *mut libc::c_void);
|
||||
*blobdir = 0 as *mut libc::c_char;
|
||||
*blobdir = ptr::null_mut();
|
||||
}
|
||||
|
||||
pub unsafe fn dc_is_open(context: &Context) -> libc::c_int {
|
||||
match context.sql.is_open() {
|
||||
true => 1,
|
||||
false => 0,
|
||||
}
|
||||
context.sql.is_open() as libc::c_int
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_userdata(context: &mut Context) -> *mut libc::c_void {
|
||||
@@ -304,8 +305,8 @@ pub unsafe fn dc_open(context: &Context, dbfile: &str, blobdir: Option<&str>) ->
|
||||
if 0 != dc_is_open(context) {
|
||||
return false;
|
||||
}
|
||||
*context.dbfile.write().unwrap() = dbfile.strdup();
|
||||
if blobdir.is_some() && blobdir.unwrap().len() > 0 {
|
||||
*context.dbfile.write().unwrap() = Some(PathBuf::from(dbfile));
|
||||
if blobdir.is_some() && !blobdir.unwrap().is_empty() {
|
||||
let dir = dc_ensure_no_slash_safe(blobdir.unwrap()).strdup();
|
||||
*context.blobdir.write().unwrap() = dir;
|
||||
} else {
|
||||
@@ -439,7 +440,7 @@ pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char {
|
||||
public_key_count={}\n\
|
||||
fingerprint={}\n\
|
||||
level=awesome\n",
|
||||
as_str(DC_VERSION_STR as *const u8 as *const _),
|
||||
&*DC_VERSION_STR,
|
||||
rusqlite::version(),
|
||||
sqlite3_threadsafe(),
|
||||
// arch
|
||||
@@ -448,11 +449,10 @@ pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char {
|
||||
real_msgs,
|
||||
deaddrop_msgs,
|
||||
contacts,
|
||||
if context.has_dbfile() {
|
||||
as_str(context.get_dbfile())
|
||||
} else {
|
||||
unset
|
||||
},
|
||||
context
|
||||
.get_dbfile()
|
||||
.as_ref()
|
||||
.map_or(unset, |p| p.to_str().unwrap()),
|
||||
dbversion,
|
||||
if context.has_blobdir() {
|
||||
as_str(context.get_blobdir())
|
||||
@@ -481,7 +481,7 @@ pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char {
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_version_str() -> *mut libc::c_char {
|
||||
dc_strdup(DC_VERSION_STR as *const u8 as *const libc::c_char)
|
||||
(&*DC_VERSION_STR).strdup()
|
||||
}
|
||||
|
||||
pub fn dc_get_fresh_msgs(context: &Context) -> *mut dc_array_t {
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::types::*;
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum dc_array_t {
|
||||
Locations(Vec<dc_location>),
|
||||
Uint(Vec<uintptr_t>),
|
||||
Uint(Vec<u32>),
|
||||
}
|
||||
|
||||
impl dc_array_t {
|
||||
@@ -24,18 +24,14 @@ impl dc_array_t {
|
||||
Box::into_raw(Box::new(self))
|
||||
}
|
||||
|
||||
pub fn add_uint(&mut self, item: uintptr_t) {
|
||||
pub fn add_id(&mut self, item: uint32_t) {
|
||||
if let Self::Uint(array) = self {
|
||||
array.push(item);
|
||||
} else {
|
||||
panic!("Attempt to add uint to array of other type");
|
||||
panic!("Attempt to add id to array of other type");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_id(&mut self, item: uint32_t) {
|
||||
self.add_uint(item as uintptr_t);
|
||||
}
|
||||
|
||||
pub fn add_location(&mut self, location: dc_location) {
|
||||
if let Self::Locations(array) = self {
|
||||
array.push(location)
|
||||
@@ -44,14 +40,6 @@ impl dc_array_t {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_uint(&self, index: usize) -> uintptr_t {
|
||||
if let Self::Uint(array) = self {
|
||||
array[index]
|
||||
} else {
|
||||
panic!("Attempt to get uint from array of other type");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_id(&self, index: usize) -> uint32_t {
|
||||
match self {
|
||||
Self::Locations(array) => array[index].location_id,
|
||||
@@ -59,14 +47,6 @@ impl dc_array_t {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ptr(&self, index: size_t) -> *mut libc::c_void {
|
||||
if let Self::Uint(array) = self {
|
||||
array[index] as *mut libc::c_void
|
||||
} else {
|
||||
panic!("Not an array of pointers");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_location(&self, index: usize) -> &dc_location {
|
||||
if let Self::Locations(array) = self {
|
||||
&array[index]
|
||||
@@ -125,7 +105,7 @@ impl dc_array_t {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn search_id(&self, needle: uintptr_t) -> Option<usize> {
|
||||
pub fn search_id(&self, needle: u32) -> Option<usize> {
|
||||
if let Self::Uint(array) = self {
|
||||
for (i, &u) in array.iter().enumerate() {
|
||||
if u == needle {
|
||||
@@ -149,7 +129,7 @@ impl dc_array_t {
|
||||
|
||||
impl From<Vec<u32>> for dc_array_t {
|
||||
fn from(array: Vec<u32>) -> Self {
|
||||
dc_array_t::Uint(array.iter().map(|&x| x as uintptr_t).collect())
|
||||
dc_array_t::Uint(array)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,40 +144,21 @@ pub unsafe fn dc_array_unref(array: *mut dc_array_t) {
|
||||
Box::from_raw(array);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_add_uint(array: *mut dc_array_t, item: uintptr_t) {
|
||||
assert!(!array.is_null());
|
||||
(*array).add_uint(item);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_add_id(array: *mut dc_array_t, item: uint32_t) {
|
||||
assert!(!array.is_null());
|
||||
(*array).add_id(item);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_add_ptr(array: *mut dc_array_t, item: *mut libc::c_void) {
|
||||
dc_array_add_uint(array, item as uintptr_t);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_cnt(array: *const dc_array_t) -> size_t {
|
||||
assert!(!array.is_null());
|
||||
(*array).len()
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_uint(array: *const dc_array_t, index: size_t) -> uintptr_t {
|
||||
assert!(!array.is_null());
|
||||
(*array).get_uint(index)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_id(array: *const dc_array_t, index: size_t) -> uint32_t {
|
||||
assert!(!array.is_null());
|
||||
(*array).get_id(index)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_ptr(array: *const dc_array_t, index: size_t) -> *mut libc::c_void {
|
||||
assert!(!array.is_null());
|
||||
(*array).get_ptr(index)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_latitude(array: *const dc_array_t, index: size_t) -> libc::c_double {
|
||||
assert!(!array.is_null());
|
||||
(*array).get_latitude(index)
|
||||
@@ -274,7 +235,7 @@ pub unsafe fn dc_array_search_id(
|
||||
) -> bool {
|
||||
assert!(!array.is_null());
|
||||
|
||||
if let Some(i) = (*array).search_id(needle as uintptr_t) {
|
||||
if let Some(i) = (*array).search_id(needle) {
|
||||
if !ret_index.is_null() {
|
||||
*ret_index = i
|
||||
}
|
||||
@@ -284,7 +245,7 @@ pub unsafe fn dc_array_search_id(
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_raw(array: *const dc_array_t) -> *const uintptr_t {
|
||||
pub unsafe fn dc_array_get_raw(array: *const dc_array_t) -> *const u32 {
|
||||
assert!(!array.is_null());
|
||||
|
||||
if let dc_array_t::Uint(v) = &*array {
|
||||
@@ -403,5 +364,4 @@ mod tests {
|
||||
}
|
||||
unsafe { dc_array_get_id(arr, 1000) };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
186
src/dc_chat.rs
186
src/dc_chat.rs
@@ -13,6 +13,7 @@ use crate::sql::{self, Sql};
|
||||
use crate::stock::StockMessage;
|
||||
use crate::types::*;
|
||||
use crate::x::*;
|
||||
use std::ptr;
|
||||
|
||||
/**
|
||||
* @class dc_chat_t
|
||||
@@ -92,11 +93,11 @@ pub unsafe fn dc_chat_empty(mut chat: *mut Chat) {
|
||||
return;
|
||||
}
|
||||
free((*chat).name as *mut libc::c_void);
|
||||
(*chat).name = 0 as *mut libc::c_char;
|
||||
(*chat).name = ptr::null_mut();
|
||||
(*chat).type_0 = 0i32;
|
||||
(*chat).id = 0i32 as uint32_t;
|
||||
free((*chat).grpid as *mut libc::c_void);
|
||||
(*chat).grpid = 0 as *mut libc::c_char;
|
||||
(*chat).grpid = ptr::null_mut();
|
||||
(*chat).blocked = 0i32;
|
||||
(*chat).gossiped_timestamp = 0;
|
||||
(*chat).param = Params::new();
|
||||
@@ -179,6 +180,22 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool {
|
||||
.strdup();
|
||||
},
|
||||
_ => {
|
||||
unsafe {
|
||||
if (*chat).type_0 == DC_CHAT_TYPE_SINGLE {
|
||||
free((*chat).name as *mut libc::c_void);
|
||||
let contacts = dc_get_chat_contacts((*chat).context, (*chat).id);
|
||||
let mut chat_name = "Err [Name not found]".to_owned();
|
||||
if !(*contacts).is_empty() {
|
||||
if let Ok(contact) =
|
||||
Contact::get_by_id((*chat).context, contacts[0])
|
||||
{
|
||||
chat_name = contact.get_display_name().to_owned();
|
||||
}
|
||||
}
|
||||
(*chat).name = (&chat_name).strdup();
|
||||
}
|
||||
}
|
||||
|
||||
if unsafe { &(*chat).param }.exists(Param::Selftalk) {
|
||||
unsafe {
|
||||
free((*chat).name as *mut libc::c_void);
|
||||
@@ -216,7 +233,7 @@ pub unsafe fn dc_create_chat_by_contact_id(context: &Context, contact_id: uint32
|
||||
contact_id,
|
||||
0i32,
|
||||
&mut chat_id,
|
||||
0 as *mut libc::c_int,
|
||||
ptr::null_mut(),
|
||||
);
|
||||
if 0 != chat_id {
|
||||
send_event = 1;
|
||||
@@ -333,11 +350,11 @@ pub unsafe fn dc_get_chat_id_by_contact_id(context: &Context, contact_id: uint32
|
||||
let mut chat_id: uint32_t = 0i32 as uint32_t;
|
||||
let mut chat_id_blocked: libc::c_int = 0i32;
|
||||
dc_lookup_real_nchat_by_contact_id(context, contact_id, &mut chat_id, &mut chat_id_blocked);
|
||||
return if 0 != chat_id_blocked {
|
||||
if 0 != chat_id_blocked {
|
||||
0i32 as libc::c_uint
|
||||
} else {
|
||||
chat_id
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn dc_prepare_msg<'a>(
|
||||
@@ -355,7 +372,7 @@ pub unsafe fn dc_prepare_msg<'a>(
|
||||
(*msg).chat_id as uintptr_t,
|
||||
(*msg).id as uintptr_t,
|
||||
);
|
||||
return msg_id;
|
||||
msg_id
|
||||
}
|
||||
|
||||
pub fn msgtype_has_file(msgtype: Viewtype) -> bool {
|
||||
@@ -421,11 +438,7 @@ unsafe fn prepare_msg_common<'a>(
|
||||
} else if !(*msg).param.exists(Param::MimeType) {
|
||||
let mut better_mime = std::ptr::null_mut();
|
||||
|
||||
dc_msg_guess_msgtype_from_suffix(
|
||||
pathNfilename,
|
||||
0 as *mut Viewtype,
|
||||
&mut better_mime,
|
||||
);
|
||||
dc_msg_guess_msgtype_from_suffix(pathNfilename, ptr::null_mut(), &mut better_mime);
|
||||
|
||||
if !better_mime.is_null() {
|
||||
(*msg).param.set(Param::MimeType, as_str(better_mime));
|
||||
@@ -477,12 +490,12 @@ unsafe fn prepare_msg_raw(
|
||||
let mut do_guarantee_e2ee: libc::c_int;
|
||||
let e2ee_enabled: libc::c_int;
|
||||
let mut OK_TO_CONTINUE = true;
|
||||
let mut parent_rfc724_mid = 0 as *mut libc::c_char;
|
||||
let mut parent_references = 0 as *mut libc::c_char;
|
||||
let mut parent_in_reply_to = 0 as *mut libc::c_char;
|
||||
let mut new_rfc724_mid = 0 as *mut libc::c_char;
|
||||
let mut new_references = 0 as *mut libc::c_char;
|
||||
let mut new_in_reply_to = 0 as *mut libc::c_char;
|
||||
let mut parent_rfc724_mid = ptr::null_mut();
|
||||
let mut parent_references = ptr::null_mut();
|
||||
let mut parent_in_reply_to = ptr::null_mut();
|
||||
let mut new_rfc724_mid = ptr::null_mut();
|
||||
let mut new_references = ptr::null_mut();
|
||||
let mut new_in_reply_to = ptr::null_mut();
|
||||
let mut msg_id = 0;
|
||||
let mut to_id = 0;
|
||||
let mut location_id = 0;
|
||||
@@ -508,7 +521,7 @@ unsafe fn prepare_msg_raw(
|
||||
if (*chat).type_0 == 120 || (*chat).type_0 == 130 {
|
||||
(*chat).grpid
|
||||
} else {
|
||||
0 as *mut libc::c_char
|
||||
ptr::null_mut()
|
||||
},
|
||||
from_c.as_ptr(),
|
||||
);
|
||||
@@ -1052,12 +1065,12 @@ pub unsafe fn dc_get_draft(context: &Context, chat_id: uint32_t) -> *mut dc_msg_
|
||||
}
|
||||
draft_msg_id = get_draft_msg_id(context, chat_id);
|
||||
if draft_msg_id == 0i32 as libc::c_uint {
|
||||
return 0 as *mut dc_msg_t;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
draft_msg = dc_msg_new_untyped(context);
|
||||
if !dc_msg_load_from_db(draft_msg, context, draft_msg_id) {
|
||||
dc_msg_unref(draft_msg);
|
||||
return 0 as *mut dc_msg_t;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
|
||||
draft_msg
|
||||
@@ -1269,7 +1282,7 @@ pub unsafe fn dc_get_next_media(
|
||||
) -> uint32_t {
|
||||
let mut ret_msg_id: uint32_t = 0i32 as uint32_t;
|
||||
let msg: *mut dc_msg_t = dc_msg_new_untyped(context);
|
||||
let mut list: *mut dc_array_t = 0 as *mut dc_array_t;
|
||||
let mut list: *mut dc_array_t = ptr::null_mut();
|
||||
let mut i: libc::c_int;
|
||||
let cnt: libc::c_int;
|
||||
|
||||
@@ -1307,7 +1320,9 @@ pub unsafe fn dc_get_next_media(
|
||||
}
|
||||
}
|
||||
|
||||
dc_array_unref(list);
|
||||
if !list.is_null() {
|
||||
dc_array_unref(list);
|
||||
}
|
||||
dc_msg_unref(msg);
|
||||
ret_msg_id
|
||||
}
|
||||
@@ -1436,11 +1451,11 @@ pub unsafe fn dc_get_chat(context: &Context, chat_id: uint32_t) -> *mut Chat {
|
||||
}
|
||||
|
||||
if 0 != success {
|
||||
return obj;
|
||||
obj
|
||||
} else {
|
||||
dc_chat_unref(obj);
|
||||
return 0 as *mut Chat;
|
||||
};
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
|
||||
// handle group chats
|
||||
@@ -1533,7 +1548,7 @@ pub unsafe fn dc_add_contact_to_chat_ex(
|
||||
let contact = contact.unwrap();
|
||||
|
||||
/*this also makes sure, not contacts are added to special or normal chats*/
|
||||
if !(0 == real_group_exists(context, chat_id)
|
||||
if !(!real_group_exists(context, chat_id)
|
||||
|| !Contact::real_exists_by_id(context, contact_id)
|
||||
&& contact_id != DC_CONTACT_ID_SELF as u32
|
||||
|| !dc_chat_load_from_db(chat, chat_id))
|
||||
@@ -1615,11 +1630,10 @@ pub unsafe fn dc_add_contact_to_chat_ex(
|
||||
success
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
fn real_group_exists(context: &Context, chat_id: u32) -> libc::c_int {
|
||||
fn real_group_exists(context: &Context, chat_id: u32) -> bool {
|
||||
// check if a group or a verified group exists under the given ID
|
||||
if !context.sql.is_open() || chat_id <= 9 {
|
||||
return 02;
|
||||
return false;
|
||||
}
|
||||
|
||||
context
|
||||
@@ -1628,7 +1642,7 @@ fn real_group_exists(context: &Context, chat_id: u32) -> libc::c_int {
|
||||
"SELECT id FROM chats WHERE id=? AND (type=120 OR type=130);",
|
||||
params![chat_id as i32],
|
||||
)
|
||||
.unwrap_or_default() as libc::c_int
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn dc_reset_gossiped_timestamp(context: &Context, chat_id: u32) {
|
||||
@@ -1680,7 +1694,7 @@ pub unsafe fn dc_remove_contact_from_chat(
|
||||
{
|
||||
/* we do not check if "contact_id" exists but just delete all records with the id from chats_contacts */
|
||||
/* this allows to delete pending references to deleted contacts. Of course, this should _not_ happen. */
|
||||
if !(0 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
|
||||
if !(!real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
|
||||
if !(dc_is_contact_in_chat(context, chat_id, 1 as uint32_t) == 1) {
|
||||
log_event!(
|
||||
context,
|
||||
@@ -1779,7 +1793,7 @@ pub unsafe fn dc_set_chat_name(
|
||||
|| *new_name.offset(0isize) as libc::c_int == 0i32
|
||||
|| chat_id <= 9i32 as libc::c_uint)
|
||||
{
|
||||
if !(0i32 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
|
||||
if !(!real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
|
||||
if strcmp((*chat).name, new_name) == 0i32 {
|
||||
success = 1i32
|
||||
} else if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) {
|
||||
@@ -1839,76 +1853,62 @@ pub unsafe fn dc_set_chat_name(
|
||||
success
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn dc_set_chat_profile_image(
|
||||
context: &Context,
|
||||
chat_id: uint32_t,
|
||||
new_image: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
let mut OK_TO_CONTINUE = true;
|
||||
let mut success: libc::c_int = 0i32;
|
||||
new_image: impl AsRef<str>,
|
||||
) -> bool {
|
||||
if chat_id <= 9 {
|
||||
return false;
|
||||
}
|
||||
let chat: *mut Chat = dc_chat_new(context);
|
||||
let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context);
|
||||
let mut new_image_rel: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
if !(chat_id <= 9i32 as libc::c_uint) {
|
||||
if !(0i32 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
|
||||
if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) {
|
||||
log_event!(
|
||||
context,
|
||||
Event::ERROR_SELF_NOT_IN_GROUP,
|
||||
0,
|
||||
"Cannot set chat profile image; self not in group.",
|
||||
let mut success = false;
|
||||
|
||||
if real_group_exists(context, chat_id) && dc_chat_load_from_db(chat, chat_id) {
|
||||
if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) {
|
||||
log_event!(
|
||||
context,
|
||||
Event::ERROR_SELF_NOT_IN_GROUP,
|
||||
0,
|
||||
"Cannot set chat profile image; self not in group.",
|
||||
);
|
||||
} else {
|
||||
(*chat).param.set(Param::ProfileImage, new_image.as_ref());
|
||||
if !(0 == dc_chat_update_param(chat)) {
|
||||
if (*chat).param.get_int(Param::Unpromoted).unwrap_or_default() == 0 {
|
||||
(*msg).param.set_int(Param::Cmd, 3);
|
||||
(*msg).param.set(Param::Arg, new_image.as_ref());
|
||||
(*msg).type_0 = Viewtype::Text;
|
||||
(*msg).text = Some(context.stock_system_msg(
|
||||
if new_image.as_ref().is_empty() {
|
||||
StockMessage::MsgGrpImgDeleted
|
||||
} else {
|
||||
StockMessage::MsgGrpImgChanged
|
||||
},
|
||||
"",
|
||||
"",
|
||||
DC_CONTACT_ID_SELF as uint32_t,
|
||||
));
|
||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||
context.call_cb(
|
||||
Event::MSGS_CHANGED,
|
||||
chat_id as uintptr_t,
|
||||
(*msg).id as uintptr_t,
|
||||
);
|
||||
}
|
||||
context.call_cb(
|
||||
Event::CHAT_MODIFIED,
|
||||
chat_id as uintptr_t,
|
||||
0i32 as uintptr_t,
|
||||
);
|
||||
} else {
|
||||
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
|
||||
if !new_image.is_null() {
|
||||
new_image_rel = dc_strdup(new_image);
|
||||
if !dc_make_rel_and_copy(context, &mut new_image_rel) {
|
||||
OK_TO_CONTINUE = false;
|
||||
}
|
||||
}
|
||||
if OK_TO_CONTINUE {
|
||||
(*chat)
|
||||
.param
|
||||
.set(Param::ProfileImage, as_str(new_image_rel));
|
||||
if !(0 == dc_chat_update_param(chat)) {
|
||||
if (*chat).param.get_int(Param::Unpromoted).unwrap_or_default() == 0 {
|
||||
(*msg).param.set_int(Param::Cmd, 3);
|
||||
(*msg).param.set(Param::Arg, as_str(new_image_rel));
|
||||
(*msg).type_0 = Viewtype::Text;
|
||||
(*msg).text = Some(context.stock_system_msg(
|
||||
if !new_image_rel.is_null() {
|
||||
StockMessage::MsgGrpImgChanged
|
||||
} else {
|
||||
StockMessage::MsgGrpImgDeleted
|
||||
},
|
||||
"",
|
||||
"",
|
||||
DC_CONTACT_ID_SELF as uint32_t,
|
||||
));
|
||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||
context.call_cb(
|
||||
Event::MSGS_CHANGED,
|
||||
chat_id as uintptr_t,
|
||||
(*msg).id as uintptr_t,
|
||||
);
|
||||
}
|
||||
context.call_cb(
|
||||
Event::CHAT_MODIFIED,
|
||||
chat_id as uintptr_t,
|
||||
0i32 as uintptr_t,
|
||||
);
|
||||
success = 1i32
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dc_chat_unref(chat);
|
||||
dc_msg_unref(msg);
|
||||
free(new_image_rel as *mut libc::c_void);
|
||||
|
||||
success
|
||||
}
|
||||
@@ -2066,11 +2066,11 @@ pub unsafe fn dc_chat_get_subtitle(chat: *const Chat) -> *mut libc::c_char {
|
||||
.strdup();
|
||||
}
|
||||
}
|
||||
return if !ret.is_null() {
|
||||
if !ret.is_null() {
|
||||
ret
|
||||
} else {
|
||||
dc_strdup(b"Err\x00" as *const u8 as *const libc::c_char)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dc_get_chat_contact_cnt(context: &Context, chat_id: u32) -> libc::c_int {
|
||||
@@ -2221,7 +2221,7 @@ pub fn dc_add_device_msg(context: &Context, chat_id: uint32_t, text: *const libc
|
||||
}
|
||||
let rfc724_mid = unsafe {
|
||||
dc_create_outgoing_rfc724_mid(
|
||||
0 as *const libc::c_char,
|
||||
ptr::null(),
|
||||
b"@device\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -12,18 +12,17 @@ use crate::oauth2::*;
|
||||
use crate::param::Params;
|
||||
use crate::types::*;
|
||||
use crate::x::*;
|
||||
use std::ptr;
|
||||
|
||||
macro_rules! progress {
|
||||
($context:tt, $progress:expr) => {
|
||||
assert!(
|
||||
$progress >= 0 && $progress <= 1000,
|
||||
"value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success"
|
||||
);
|
||||
$context.call_cb(
|
||||
Event::CONFIGURE_PROGRESS,
|
||||
(if $progress < 1 {
|
||||
1
|
||||
} else if $progress > 1000 {
|
||||
1000
|
||||
} else {
|
||||
$progress
|
||||
}) as uintptr_t,
|
||||
$progress as uintptr_t,
|
||||
0 as uintptr_t,
|
||||
);
|
||||
};
|
||||
@@ -151,7 +150,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
||||
let s = s_a.read().unwrap();
|
||||
|
||||
if !s.shall_stop_ongoing {
|
||||
progress!(context, 0);
|
||||
progress!(context, 1);
|
||||
|
||||
let mut param = dc_loginparam_read(context, &context.sql, "");
|
||||
if param.addr.is_empty() {
|
||||
@@ -187,13 +186,13 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
||||
ok_to_continue0 = true;
|
||||
}
|
||||
if ok_to_continue0 {
|
||||
let parsed: addr::Result<addr::Email> = param.addr.parse();
|
||||
let parsed: Result<EmailAddress, _> = param.addr.parse();
|
||||
let mut ok_to_continue7 = false;
|
||||
if parsed.is_err() {
|
||||
error!(context, 0, "Bad email-address.");
|
||||
} else {
|
||||
let parsed = parsed.unwrap();
|
||||
let param_domain = parsed.host();
|
||||
let param_domain = parsed.domain;
|
||||
let param_addr_urlencoded =
|
||||
utf8_percent_encode(¶m.addr, NON_ALPHANUMERIC).to_string();
|
||||
|
||||
@@ -731,7 +730,7 @@ unsafe fn moz_autoconfigure(
|
||||
starttag_cb: None,
|
||||
endtag_cb: None,
|
||||
text_cb: None,
|
||||
userdata: 0 as *mut libc::c_void,
|
||||
userdata: ptr::null_mut(),
|
||||
};
|
||||
dc_saxparser_init(
|
||||
&mut saxparser,
|
||||
@@ -793,12 +792,12 @@ unsafe fn moz_autoconfigure_text_cb(
|
||||
match (*moz_ac).tag_config {
|
||||
10 => {
|
||||
(*moz_ac).out.mail_server = to_string(val);
|
||||
val = 0 as *mut libc::c_char
|
||||
val = ptr::null_mut();
|
||||
}
|
||||
11 => (*moz_ac).out.mail_port = dc_atoi_null_is_0(val),
|
||||
12 => {
|
||||
(*moz_ac).out.mail_user = to_string(val);
|
||||
val = 0 as *mut libc::c_char
|
||||
val = ptr::null_mut();
|
||||
}
|
||||
13 => {
|
||||
if strcasecmp(val, b"ssl\x00" as *const u8 as *const libc::c_char) == 0 {
|
||||
@@ -817,12 +816,12 @@ unsafe fn moz_autoconfigure_text_cb(
|
||||
match (*moz_ac).tag_config {
|
||||
10 => {
|
||||
(*moz_ac).out.send_server = to_string(val);
|
||||
val = 0 as *mut libc::c_char
|
||||
val = ptr::null_mut();
|
||||
}
|
||||
11 => (*moz_ac).out.send_port = as_str(val).parse().unwrap_or_default(),
|
||||
12 => {
|
||||
(*moz_ac).out.send_user = to_string(val);
|
||||
val = 0 as *mut libc::c_char
|
||||
val = ptr::null_mut();
|
||||
}
|
||||
13 => {
|
||||
if strcasecmp(val, b"ssl\x00" as *const u8 as *const libc::c_char) == 0 {
|
||||
@@ -926,7 +925,7 @@ unsafe fn outlk_autodiscover(
|
||||
url__: &str,
|
||||
param_in: &dc_loginparam_t,
|
||||
) -> Option<dc_loginparam_t> {
|
||||
let mut xml_raw: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut xml_raw: *mut libc::c_char = ptr::null_mut();
|
||||
let mut url = url__.strdup();
|
||||
let mut outlk_ad = outlk_autodiscover_t {
|
||||
in_0: param_in,
|
||||
@@ -934,8 +933,8 @@ unsafe fn outlk_autodiscover(
|
||||
out_imap_set: 0,
|
||||
out_smtp_set: 0,
|
||||
tag_config: 0,
|
||||
config: [0 as *mut libc::c_char; 6],
|
||||
redirect: 0 as *mut libc::c_char,
|
||||
config: [ptr::null_mut(); 6],
|
||||
redirect: ptr::null_mut(),
|
||||
};
|
||||
let ok_to_continue;
|
||||
let mut i = 0;
|
||||
@@ -982,7 +981,7 @@ unsafe fn outlk_autodiscover(
|
||||
|
||||
outlk_clean_config(&mut outlk_ad);
|
||||
free(xml_raw as *mut libc::c_void);
|
||||
xml_raw = 0 as *mut libc::c_char;
|
||||
xml_raw = ptr::null_mut();
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use lazy_static::lazy_static;
|
||||
use crate::dc_saxparser::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::x::*;
|
||||
use std::ptr;
|
||||
|
||||
lazy_static! {
|
||||
static ref LINE_RE: regex::Regex = regex::Regex::new(r"(\r?\n)+").unwrap();
|
||||
@@ -38,7 +39,7 @@ pub unsafe fn dc_dehtml(buf_terminated: *mut libc::c_char) -> *mut libc::c_char
|
||||
starttag_cb: None,
|
||||
endtag_cb: None,
|
||||
text_cb: None,
|
||||
userdata: 0 as *mut libc::c_void,
|
||||
userdata: ptr::null_mut(),
|
||||
};
|
||||
dc_saxparser_init(
|
||||
&mut saxparser,
|
||||
|
||||
107
src/dc_e2ee.rs
107
src/dc_e2ee.rs
@@ -2,6 +2,7 @@
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
use std::str::FromStr;
|
||||
|
||||
use mmime::clist::*;
|
||||
@@ -145,7 +146,7 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
iter1 = if !iter1.is_null() {
|
||||
(*iter1).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,19 +171,19 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
mailprivacy_prepare_mime(in_out_message);
|
||||
let mut part_to_encrypt: *mut mailmime =
|
||||
(*in_out_message).mm_data.mm_message.mm_msg_mime;
|
||||
(*part_to_encrypt).mm_parent = 0 as *mut mailmime;
|
||||
(*part_to_encrypt).mm_parent = ptr::null_mut();
|
||||
let imffields_encrypted: *mut mailimf_fields = mailimf_fields_new_empty();
|
||||
/* mailmime_new_message_data() calls mailmime_fields_new_with_version() which would add the unwanted MIME-Version:-header */
|
||||
let message_to_encrypt: *mut mailmime = mailmime_new(
|
||||
MAILMIME_MESSAGE as libc::c_int,
|
||||
0 as *const libc::c_char,
|
||||
ptr::null(),
|
||||
0i32 as size_t,
|
||||
mailmime_fields_new_empty(),
|
||||
mailmime_get_content_message(),
|
||||
0 as *mut mailmime_data,
|
||||
0 as *mut mailmime_data,
|
||||
0 as *mut mailmime_data,
|
||||
0 as *mut clist,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
imffields_encrypted,
|
||||
part_to_encrypt,
|
||||
);
|
||||
@@ -214,7 +215,7 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
let field: *mut mailimf_field = (if !cur.is_null() {
|
||||
(*cur).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
ptr::null_mut()
|
||||
})
|
||||
as *mut mailimf_field;
|
||||
if !field.is_null() {
|
||||
@@ -265,28 +266,28 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
imffields_unprotected,
|
||||
mailimf_field_new(
|
||||
MAILIMF_FIELD_SUBJECT as libc::c_int,
|
||||
0 as *mut mailimf_return,
|
||||
0 as *mut mailimf_orig_date,
|
||||
0 as *mut mailimf_from,
|
||||
0 as *mut mailimf_sender,
|
||||
0 as *mut mailimf_to,
|
||||
0 as *mut mailimf_cc,
|
||||
0 as *mut mailimf_bcc,
|
||||
0 as *mut mailimf_message_id,
|
||||
0 as *mut mailimf_orig_date,
|
||||
0 as *mut mailimf_from,
|
||||
0 as *mut mailimf_sender,
|
||||
0 as *mut mailimf_reply_to,
|
||||
0 as *mut mailimf_to,
|
||||
0 as *mut mailimf_cc,
|
||||
0 as *mut mailimf_bcc,
|
||||
0 as *mut mailimf_message_id,
|
||||
0 as *mut mailimf_in_reply_to,
|
||||
0 as *mut mailimf_references,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
subject,
|
||||
0 as *mut mailimf_comments,
|
||||
0 as *mut mailimf_keywords,
|
||||
0 as *mut mailimf_optional_field,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
),
|
||||
);
|
||||
clist_insert_after(
|
||||
@@ -314,7 +315,7 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
|
||||
/* create MIME-structure that will contain the encrypted text */
|
||||
let mut encrypted_part: *mut mailmime = new_data_part(
|
||||
0 as *mut libc::c_void,
|
||||
ptr::null_mut(),
|
||||
0i32 as size_t,
|
||||
b"multipart/encrypted\x00" as *const u8 as *const libc::c_char
|
||||
as *mut libc::c_char,
|
||||
@@ -400,7 +401,7 @@ unsafe fn new_data_part(
|
||||
let encoding_type: libc::c_int;
|
||||
let content_type_str: *mut libc::c_char;
|
||||
let mut do_encoding: libc::c_int;
|
||||
encoding = 0 as *mut mailmime_mechanism;
|
||||
encoding = ptr::null_mut();
|
||||
if default_content_type.is_null() {
|
||||
content_type_str =
|
||||
b"application/octet-stream\x00" as *const u8 as *const libc::c_char as *mut libc::c_char
|
||||
@@ -435,7 +436,7 @@ unsafe fn new_data_part(
|
||||
} else {
|
||||
encoding_type = default_encoding
|
||||
}
|
||||
encoding = mailmime_mechanism_new(encoding_type, 0 as *mut libc::c_char);
|
||||
encoding = mailmime_mechanism_new(encoding_type, ptr::null_mut());
|
||||
if encoding.is_null() {
|
||||
ok_to_continue = false;
|
||||
}
|
||||
@@ -443,10 +444,10 @@ unsafe fn new_data_part(
|
||||
if ok_to_continue {
|
||||
mime_fields = mailmime_fields_new_with_data(
|
||||
encoding,
|
||||
0 as *mut libc::c_char,
|
||||
0 as *mut libc::c_char,
|
||||
0 as *mut mailmime_disposition,
|
||||
0 as *mut mailmime_language,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
);
|
||||
if mime_fields.is_null() {
|
||||
ok_to_continue = false;
|
||||
@@ -476,7 +477,7 @@ unsafe fn new_data_part(
|
||||
mailmime_content_free(content);
|
||||
}
|
||||
}
|
||||
return 0 as *mut mailmime;
|
||||
ptr::null_mut()
|
||||
}
|
||||
|
||||
/// Load public key from database or generate a new one.
|
||||
@@ -539,10 +540,10 @@ pub unsafe fn dc_e2ee_decrypt(
|
||||
/*just a pointer into mailmime structure, must not be freed*/
|
||||
let imffields: *mut mailimf_fields = mailmime_find_mailimf_fields(in_out_message);
|
||||
let mut message_time = 0;
|
||||
let mut from: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut from: *mut libc::c_char = ptr::null_mut();
|
||||
let mut private_keyring = Keyring::default();
|
||||
let mut public_keyring_for_validate = Keyring::default();
|
||||
let mut gossip_headers: *mut mailimf_fields = 0 as *mut mailimf_fields;
|
||||
let mut gossip_headers: *mut mailimf_fields = ptr::null_mut();
|
||||
if !(in_out_message.is_null() || imffields.is_null()) {
|
||||
let mut field: *mut mailimf_field =
|
||||
mailimf_find_field(imffields, MAILIMF_FIELD_FROM as libc::c_int);
|
||||
@@ -646,7 +647,7 @@ unsafe fn update_gossip_peerstates(
|
||||
let field: *mut mailimf_field = (if !cur1.is_null() {
|
||||
(*cur1).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
ptr::null_mut()
|
||||
}) as *mut mailimf_field;
|
||||
if (*field).fld_type == MAILIMF_FIELD_OPTIONAL_FIELD as libc::c_int {
|
||||
let optional_field: *const mailimf_optional_field =
|
||||
@@ -698,7 +699,7 @@ unsafe fn update_gossip_peerstates(
|
||||
cur1 = if !cur1.is_null() {
|
||||
(*cur1).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +732,7 @@ unsafe fn decrypt_recursive(
|
||||
{
|
||||
cur = (*(*mime).mm_data.mm_multipart.mm_mp_list).first;
|
||||
while !cur.is_null() {
|
||||
let mut decrypted_mime: *mut mailmime = 0 as *mut mailmime;
|
||||
let mut decrypted_mime: *mut mailmime = ptr::null_mut();
|
||||
if 0 != decrypt_part(
|
||||
context,
|
||||
(if !cur.is_null() {
|
||||
@@ -746,7 +747,7 @@ unsafe fn decrypt_recursive(
|
||||
) {
|
||||
if (*ret_gossip_headers).is_null() && ret_valid_signatures.len() > 0 {
|
||||
let mut dummy: size_t = 0i32 as size_t;
|
||||
let mut test: *mut mailimf_fields = 0 as *mut mailimf_fields;
|
||||
let mut test: *mut mailimf_fields = ptr::null_mut();
|
||||
if mailimf_envelope_and_optional_fields_parse(
|
||||
(*decrypted_mime).mm_mime_start,
|
||||
(*decrypted_mime).mm_length,
|
||||
@@ -777,7 +778,7 @@ unsafe fn decrypt_recursive(
|
||||
(if !cur.is_null() {
|
||||
(*cur).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
ptr::null_mut()
|
||||
}) as *mut mailmime,
|
||||
private_keyring,
|
||||
public_keyring_for_validate,
|
||||
@@ -790,7 +791,7 @@ unsafe fn decrypt_recursive(
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -825,12 +826,12 @@ unsafe fn decrypt_part(
|
||||
let mime_data: *mut mailmime_data;
|
||||
let mut mime_transfer_encoding: libc::c_int = MAILMIME_MECHANISM_BINARY as libc::c_int;
|
||||
/* mmap_string_unref()'d if set */
|
||||
let mut transfer_decoding_buffer: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut transfer_decoding_buffer: *mut libc::c_char = ptr::null_mut();
|
||||
/* must not be free()'d */
|
||||
let mut decoded_data: *const libc::c_char = 0 as *const libc::c_char;
|
||||
let mut decoded_data: *const libc::c_char = ptr::null_mut();
|
||||
let mut decoded_data_bytes: size_t = 0i32 as size_t;
|
||||
let mut sth_decrypted: libc::c_int = 0i32;
|
||||
*ret_decrypted_mime = 0 as *mut mailmime;
|
||||
*ret_decrypted_mime = ptr::null_mut();
|
||||
mime_data = (*mime).mm_data.mm_single;
|
||||
/* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */
|
||||
if !((*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int
|
||||
@@ -844,7 +845,7 @@ unsafe fn decrypt_part(
|
||||
let field: *mut mailmime_field = (if !cur.is_null() {
|
||||
(*cur).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
ptr::null_mut()
|
||||
}) as *mut mailmime_field;
|
||||
if !field.is_null() {
|
||||
if (*field).fld_type == MAILMIME_FIELD_TRANSFER_ENCODING as libc::c_int
|
||||
@@ -856,7 +857,7 @@ unsafe fn decrypt_part(
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -912,7 +913,7 @@ unsafe fn decrypt_part(
|
||||
let plain_buf = plain.as_ptr() as *const libc::c_char;
|
||||
|
||||
let mut index: size_t = 0i32 as size_t;
|
||||
let mut decrypted_mime: *mut mailmime = 0 as *mut mailmime;
|
||||
let mut decrypted_mime: *mut mailmime = ptr::null_mut();
|
||||
if mailmime_parse(
|
||||
plain_buf as *const _,
|
||||
plain_bytes,
|
||||
@@ -1010,7 +1011,7 @@ unsafe fn contains_report(mime: *mut mailmime) -> libc::c_int {
|
||||
(if !cur.is_null() {
|
||||
(*cur).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
ptr::null_mut()
|
||||
}) as *mut mailmime,
|
||||
) {
|
||||
return 1i32;
|
||||
@@ -1033,7 +1034,7 @@ unsafe fn contains_report(mime: *mut mailmime) -> libc::c_int {
|
||||
/* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling this function, in_out_message cannot be used any longer! */
|
||||
pub unsafe fn dc_e2ee_thanks(helper: &mut dc_e2ee_helper_t) {
|
||||
free(helper.cdata_to_free);
|
||||
helper.cdata_to_free = 0 as *mut libc::c_void;
|
||||
helper.cdata_to_free = ptr::null_mut();
|
||||
}
|
||||
|
||||
/// Ensures a private key exists for the configured user.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
use mmime::mailmime_content::*;
|
||||
use mmime::mmapstring::*;
|
||||
@@ -61,7 +62,7 @@ pub unsafe fn dc_imex_has_backup(
|
||||
"Backup check: Cannot open directory \"{}\".\x00",
|
||||
dir_name.display(),
|
||||
);
|
||||
return 0 as *mut libc::c_char;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let mut newest_backup_time = 0;
|
||||
let mut newest_backup_path: Option<std::path::PathBuf> = None;
|
||||
@@ -100,8 +101,8 @@ pub unsafe fn dc_imex_has_backup(
|
||||
}
|
||||
|
||||
pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
|
||||
let mut setup_file_name: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut msg: *mut dc_msg_t = 0 as *mut dc_msg_t;
|
||||
let mut setup_file_name: *mut libc::c_char = ptr::null_mut();
|
||||
let mut msg: *mut dc_msg_t = ptr::null_mut();
|
||||
if dc_alloc_ongoing(context) == 0 {
|
||||
return std::ptr::null_mut();
|
||||
}
|
||||
@@ -159,7 +160,7 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
|
||||
let msg_id = dc_send_msg(context, chat_id, msg);
|
||||
if msg_id != 0 {
|
||||
dc_msg_unref(msg);
|
||||
msg = 0 as *mut dc_msg_t;
|
||||
msg = ptr::null_mut();
|
||||
info!(context, 0, "Wait for setup message being sent ...",);
|
||||
loop {
|
||||
if context
|
||||
@@ -285,12 +286,12 @@ pub unsafe fn dc_continue_key_transfer(
|
||||
setup_code: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
let mut success: libc::c_int = 0i32;
|
||||
let mut msg: *mut dc_msg_t = 0 as *mut dc_msg_t;
|
||||
let mut filename: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut filecontent: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut msg: *mut dc_msg_t = ptr::null_mut();
|
||||
let mut filename: *mut libc::c_char = ptr::null_mut();
|
||||
let mut filecontent: *mut libc::c_char = ptr::null_mut();
|
||||
let mut filebytes: size_t = 0i32 as size_t;
|
||||
let mut armored_key: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut norm_sc: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut armored_key: *mut libc::c_char = ptr::null_mut();
|
||||
let mut norm_sc: *mut libc::c_char = ptr::null_mut();
|
||||
if !(msg_id <= 9i32 as libc::c_uint || setup_code.is_null()) {
|
||||
msg = dc_get_msg(context, msg_id);
|
||||
if msg.is_null()
|
||||
@@ -423,19 +424,19 @@ pub unsafe fn dc_decrypt_setup_file(
|
||||
filecontent: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
let fc_buf: *mut libc::c_char;
|
||||
let mut fc_headerline: *const libc::c_char = 0 as *const libc::c_char;
|
||||
let mut fc_base64: *const libc::c_char = 0 as *const libc::c_char;
|
||||
let mut binary: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut fc_headerline: *const libc::c_char = ptr::null();
|
||||
let mut fc_base64: *const libc::c_char = ptr::null();
|
||||
let mut binary: *mut libc::c_char = ptr::null_mut();
|
||||
let mut binary_bytes: size_t = 0i32 as size_t;
|
||||
let mut indx: size_t = 0i32 as size_t;
|
||||
|
||||
let mut payload: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut payload: *mut libc::c_char = ptr::null_mut();
|
||||
fc_buf = dc_strdup(filecontent);
|
||||
if dc_split_armored_data(
|
||||
fc_buf,
|
||||
&mut fc_headerline,
|
||||
0 as *mut *const libc::c_char,
|
||||
0 as *mut *const libc::c_char,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
&mut fc_base64,
|
||||
) && !fc_headerline.is_null()
|
||||
&& strcmp(
|
||||
@@ -479,7 +480,7 @@ pub unsafe fn dc_normalize_setup_code(
|
||||
in_0: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
if in_0.is_null() {
|
||||
return 0 as *mut libc::c_char;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let mut out = String::new();
|
||||
let mut outlen;
|
||||
@@ -596,7 +597,10 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
|
||||
0,
|
||||
"Import \"{}\" to \"{}\".",
|
||||
as_str(backup_to_import),
|
||||
as_str(context.get_dbfile()),
|
||||
context
|
||||
.get_dbfile()
|
||||
.as_ref()
|
||||
.map_or("<<None>>", |p| p.to_str().unwrap())
|
||||
);
|
||||
|
||||
if 0 != dc_is_configured(context) {
|
||||
@@ -604,8 +608,8 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
|
||||
return 0;
|
||||
}
|
||||
&context.sql.close(&context);
|
||||
dc_delete_file(context, as_path(context.get_dbfile()));
|
||||
if dc_file_exist(context, as_path(context.get_dbfile())) {
|
||||
dc_delete_file(context, context.get_dbfile().unwrap());
|
||||
if dc_file_exist(context, context.get_dbfile().unwrap()) {
|
||||
error!(
|
||||
context,
|
||||
0, "Cannot import backups: Cannot delete the old file.",
|
||||
@@ -616,13 +620,16 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
|
||||
if !dc_copy_file(
|
||||
context,
|
||||
as_path(backup_to_import),
|
||||
as_path(context.get_dbfile()),
|
||||
context.get_dbfile().unwrap(),
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
/* error already logged */
|
||||
/* re-open copied database file */
|
||||
if !context.sql.open(&context, as_path(context.get_dbfile()), 0) {
|
||||
if !context
|
||||
.sql
|
||||
.open(&context, &context.get_dbfile().unwrap(), 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -741,15 +748,20 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
context,
|
||||
0,
|
||||
"Backup \"{}\" to \"{}\".",
|
||||
as_str(context.get_dbfile()),
|
||||
context
|
||||
.get_dbfile()
|
||||
.as_ref()
|
||||
.map_or("<<None>>", |p| p.to_str().unwrap()),
|
||||
as_str(dest_pathNfilename),
|
||||
);
|
||||
if dc_copy_file(
|
||||
context,
|
||||
as_path(context.get_dbfile()),
|
||||
context.get_dbfile().unwrap(),
|
||||
as_path(dest_pathNfilename),
|
||||
) {
|
||||
context.sql.open(&context, as_path(context.get_dbfile()), 0);
|
||||
context
|
||||
.sql
|
||||
.open(&context, &context.get_dbfile().unwrap(), 0);
|
||||
closed = false;
|
||||
/* add all files as blobs to the database copy (this does not require the source to be locked, neigher the destination as it is used only here) */
|
||||
/*for logging only*/
|
||||
@@ -905,7 +917,9 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
}
|
||||
}
|
||||
if closed {
|
||||
context.sql.open(&context, as_path(context.get_dbfile()), 0);
|
||||
context
|
||||
.sql
|
||||
.open(&context, &context.get_dbfile().unwrap(), 0);
|
||||
}
|
||||
if 0 != delete_dest_file {
|
||||
dc_delete_file(context, as_path(dest_pathNfilename));
|
||||
@@ -926,16 +940,16 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
|
||||
Maybe we should make the "default" key handlong also a little bit smarter
|
||||
(currently, the last imported key is the standard key unless it contains the string "legacy" in its name) */
|
||||
let mut imported_cnt: libc::c_int = 0;
|
||||
let mut suffix: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut path_plus_name: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut suffix: *mut libc::c_char = ptr::null_mut();
|
||||
let mut path_plus_name: *mut libc::c_char = ptr::null_mut();
|
||||
let mut set_default: libc::c_int;
|
||||
let mut buf: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut buf: *mut libc::c_char = ptr::null_mut();
|
||||
let mut buf_bytes: size_t = 0 as size_t;
|
||||
// a pointer inside buf, MUST NOT be free()'d
|
||||
let mut private_key: *const libc::c_char;
|
||||
let mut buf2: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut buf2: *mut libc::c_char = ptr::null_mut();
|
||||
// a pointer inside buf2, MUST NOT be free()'d
|
||||
let mut buf2_headerline: *const libc::c_char = 0 as *const libc::c_char;
|
||||
let mut buf2_headerline: *const libc::c_char = ptr::null_mut();
|
||||
if !dir_name.is_null() {
|
||||
let dir = std::path::Path::new(as_str(dir_name));
|
||||
let dir_handle = std::fs::read_dir(dir);
|
||||
@@ -970,7 +984,7 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
|
||||
);
|
||||
info!(context, 0, "Checking: {}", as_str(path_plus_name));
|
||||
free(buf as *mut libc::c_void);
|
||||
buf = 0 as *mut libc::c_char;
|
||||
buf = ptr::null_mut();
|
||||
if 0 == dc_read_file(
|
||||
context,
|
||||
path_plus_name,
|
||||
|
||||
104
src/dc_job.rs
104
src/dc_job.rs
@@ -1,6 +1,7 @@
|
||||
use mmime::mmapstring::*;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
use std::time::Duration;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
@@ -101,10 +102,8 @@ unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network:
|
||||
Ok(job)
|
||||
},
|
||||
|jobs| {
|
||||
let res = jobs
|
||||
.collect::<Result<Vec<dc_job_t>, _>>()
|
||||
.map_err(Into::into);
|
||||
res
|
||||
jobs.collect::<Result<Vec<dc_job_t>, _>>()
|
||||
.map_err(Into::into)
|
||||
},
|
||||
);
|
||||
match jobs {
|
||||
@@ -294,7 +293,7 @@ unsafe fn dc_suspend_smtp_thread(context: &Context, suspend: bool) {
|
||||
unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
|
||||
let ok_to_continue;
|
||||
let mut filename: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut buf: *mut libc::c_void = 0 as *mut libc::c_void;
|
||||
let mut buf: *mut libc::c_void = ptr::null_mut();
|
||||
let mut buf_bytes: size_t = 0i32 as size_t;
|
||||
|
||||
/* connect to SMTP server, if not yet done */
|
||||
@@ -303,7 +302,7 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
|
||||
let connected = context.smtp.lock().unwrap().connect(context, &loginparam);
|
||||
|
||||
if !connected {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3i32, ptr::null());
|
||||
ok_to_continue = false;
|
||||
} else {
|
||||
ok_to_continue = true;
|
||||
@@ -352,18 +351,15 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
|
||||
if ok_to_continue1 {
|
||||
/* send message */
|
||||
let body = std::slice::from_raw_parts(buf as *const u8, buf_bytes).to_vec();
|
||||
if 0 == context
|
||||
.smtp
|
||||
.lock()
|
||||
.unwrap()
|
||||
.send(context, recipients_list, body)
|
||||
{
|
||||
context.smtp.lock().unwrap().disconnect();
|
||||
dc_job_try_again_later(
|
||||
job,
|
||||
-1i32,
|
||||
(*&mut context.smtp.clone().lock().unwrap()).error,
|
||||
);
|
||||
|
||||
// hold the smtp lock during sending of a job and
|
||||
// its ok/error response processing. Note that if a message
|
||||
// was sent we need to mark it in the database as we
|
||||
// otherwise might send it twice.
|
||||
let mut sock = context.smtp.lock().unwrap();
|
||||
if 0 == sock.send(context, recipients_list, body) {
|
||||
sock.disconnect();
|
||||
dc_job_try_again_later(job, -1i32, sock.error);
|
||||
} else {
|
||||
dc_delete_file(context, filename_s);
|
||||
if 0 != job.foreign_id {
|
||||
@@ -414,7 +410,7 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &Context, job: &mut dc_job_t) {
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3i32, ptr::null());
|
||||
ok_to_continue = false;
|
||||
} else {
|
||||
ok_to_continue = true;
|
||||
@@ -446,7 +442,7 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &Context, job: &mut dc_job_t) {
|
||||
) as libc::c_uint
|
||||
{
|
||||
1 => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3i32, ptr::null());
|
||||
}
|
||||
3 => {
|
||||
dc_update_server_uid(context, (*msg).rfc724_mid, &dest_folder, dest_uid);
|
||||
@@ -486,7 +482,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3, ptr::null());
|
||||
ok_to_continue = false;
|
||||
} else {
|
||||
ok_to_continue = true;
|
||||
@@ -496,7 +492,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_
|
||||
}
|
||||
if ok_to_continue {
|
||||
if inbox.set_seen(context, &folder, uid) == 0 {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3i32, ptr::null());
|
||||
}
|
||||
if 0 != job.param.get_int(Param::AlsoMove).unwrap_or_default() {
|
||||
if context
|
||||
@@ -526,7 +522,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_
|
||||
if !inbox.is_connected() {
|
||||
connect_to_inbox(context, &inbox);
|
||||
if !inbox.is_connected() {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3i32, ptr::null());
|
||||
ok_to_continue = false;
|
||||
} else {
|
||||
ok_to_continue = true;
|
||||
@@ -540,7 +536,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_
|
||||
match inbox.set_seen(context, server_folder, (*msg).server_uid) as libc::c_uint {
|
||||
0 => {}
|
||||
1 => {
|
||||
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
|
||||
dc_job_try_again_later(job, 3i32, ptr::null());
|
||||
}
|
||||
_ => {
|
||||
if 0 != (*msg).param.get_int(Param::WantsMdn).unwrap_or_default()
|
||||
@@ -570,25 +566,25 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_
|
||||
}
|
||||
unsafe fn dc_send_mdn(context: &Context, msg_id: uint32_t) {
|
||||
let mut mimefactory: dc_mimefactory_t = dc_mimefactory_t {
|
||||
from_addr: 0 as *mut libc::c_char,
|
||||
from_displayname: 0 as *mut libc::c_char,
|
||||
selfstatus: 0 as *mut libc::c_char,
|
||||
recipients_names: 0 as *mut clist,
|
||||
recipients_addr: 0 as *mut clist,
|
||||
from_addr: ptr::null_mut(),
|
||||
from_displayname: ptr::null_mut(),
|
||||
selfstatus: ptr::null_mut(),
|
||||
recipients_names: ptr::null_mut(),
|
||||
recipients_addr: ptr::null_mut(),
|
||||
timestamp: 0,
|
||||
rfc724_mid: 0 as *mut libc::c_char,
|
||||
rfc724_mid: ptr::null_mut(),
|
||||
loaded: DC_MF_NOTHING_LOADED,
|
||||
msg: 0 as *mut dc_msg_t,
|
||||
chat: 0 as *mut Chat,
|
||||
msg: ptr::null_mut(),
|
||||
chat: ptr::null_mut(),
|
||||
increation: 0,
|
||||
in_reply_to: 0 as *mut libc::c_char,
|
||||
references: 0 as *mut libc::c_char,
|
||||
in_reply_to: ptr::null_mut(),
|
||||
references: ptr::null_mut(),
|
||||
req_mdn: 0,
|
||||
out: 0 as *mut MMAPString,
|
||||
out: ptr::null_mut(),
|
||||
out_encrypted: 0,
|
||||
out_gossiped: 0,
|
||||
out_last_added_location_id: 0,
|
||||
error: 0 as *mut libc::c_char,
|
||||
error: ptr::null_mut(),
|
||||
context,
|
||||
};
|
||||
dc_mimefactory_init(&mut mimefactory, context);
|
||||
@@ -671,7 +667,7 @@ unsafe fn dc_add_smtp_job(
|
||||
}
|
||||
free(recipients as *mut libc::c_void);
|
||||
free(pathNfilename as *mut libc::c_void);
|
||||
return success;
|
||||
success
|
||||
}
|
||||
|
||||
pub unsafe fn dc_job_add(
|
||||
@@ -1040,43 +1036,25 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
|
||||
} else {
|
||||
// no redo, no IMAP. moreover, as the data does not exist, there is no need in calling dc_set_msg_failed()
|
||||
if msgtype_has_file((*mimefactory.msg).type_0) {
|
||||
let pathNfilename = (*mimefactory.msg)
|
||||
.param
|
||||
.get(Param::File)
|
||||
.unwrap_or_default()
|
||||
.strdup();
|
||||
if strlen(pathNfilename) > 0 {
|
||||
if let Some(pathNfilename) = (*mimefactory.msg).param.get(Param::File) {
|
||||
if ((*mimefactory.msg).type_0 == Viewtype::Image
|
||||
|| (*mimefactory.msg).type_0 == Viewtype::Gif)
|
||||
&& !(*mimefactory.msg).param.exists(Param::Width)
|
||||
{
|
||||
let mut buf = 0 as *mut libc::c_uchar;
|
||||
let mut buf_bytes: size_t = 0;
|
||||
let mut w = 0;
|
||||
let mut h = 0;
|
||||
(*mimefactory.msg).param.set_int(Param::Width, 0);
|
||||
(*mimefactory.msg).param.set_int(Param::Height, 0);
|
||||
if 0 != dc_read_file(
|
||||
context,
|
||||
pathNfilename,
|
||||
&mut buf as *mut *mut libc::c_uchar as *mut *mut libc::c_void,
|
||||
&mut buf_bytes,
|
||||
) {
|
||||
if 0 != dc_get_filemeta(
|
||||
buf as *const libc::c_void,
|
||||
buf_bytes,
|
||||
&mut w,
|
||||
&mut h,
|
||||
) {
|
||||
(*mimefactory.msg).param.set_int(Param::Width, w as i32);
|
||||
(*mimefactory.msg).param.set_int(Param::Height, h as i32);
|
||||
|
||||
if let Some(buf) = dc_read_file_safe(context, pathNfilename) {
|
||||
if let Ok((width, height)) = dc_get_filemeta(&buf) {
|
||||
(*mimefactory.msg).param.set_int(Param::Width, width as i32);
|
||||
(*mimefactory.msg)
|
||||
.param
|
||||
.set_int(Param::Height, height as i32);
|
||||
}
|
||||
}
|
||||
free(buf as *mut libc::c_void);
|
||||
dc_msg_save_param_to_disk(mimefactory.msg);
|
||||
}
|
||||
}
|
||||
free(pathNfilename as *mut libc::c_void);
|
||||
}
|
||||
/* create message */
|
||||
if 0 == dc_mimefactory_render(&mut mimefactory) {
|
||||
|
||||
@@ -239,10 +239,10 @@ pub fn dc_get_locations(
|
||||
accuracy: row.get(3)?,
|
||||
timestamp: row.get(4)?,
|
||||
independent: row.get(5)?,
|
||||
msg_id: msg_id,
|
||||
msg_id,
|
||||
contact_id: row.get(7)?,
|
||||
chat_id: row.get(8)?,
|
||||
marker: marker,
|
||||
marker,
|
||||
};
|
||||
Ok(loc)
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::ptr;
|
||||
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
use crate::context::Context;
|
||||
use crate::context::{dc_get_version_str, Context};
|
||||
use crate::dc_chat::*;
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_location::*;
|
||||
@@ -478,18 +478,19 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
.map(|s| format!("/{}", s))
|
||||
.unwrap_or_default();
|
||||
let os_part = CString::new(os_part).expect("String -> CString conversion failed");
|
||||
|
||||
let version = dc_get_version_str();
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
mailimf_field_new_custom(
|
||||
strdup(b"X-Mailer\x00" as *const u8 as *const libc::c_char),
|
||||
dc_mprintf(
|
||||
b"Delta Chat Core %s%s\x00" as *const u8 as *const libc::c_char,
|
||||
DC_VERSION_STR as *const u8 as *const libc::c_char,
|
||||
version,
|
||||
os_part.as_ptr(),
|
||||
),
|
||||
),
|
||||
);
|
||||
free(version.cast());
|
||||
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -960,12 +961,14 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
message_text = format!("{}\r\n", p2).strdup();
|
||||
let human_mime_part: *mut mailmime = build_body_text(message_text);
|
||||
mailmime_add_part(multipart, human_mime_part);
|
||||
let version = dc_get_version_str();
|
||||
message_text2 =
|
||||
dc_mprintf(b"Reporting-UA: Delta Chat %s\r\nOriginal-Recipient: rfc822;%s\r\nFinal-Recipient: rfc822;%s\r\nOriginal-Message-ID: <%s>\r\nDisposition: manual-action/MDN-sent-automatically; displayed\r\n\x00"
|
||||
as *const u8 as *const libc::c_char,
|
||||
DC_VERSION_STR as *const u8 as *const libc::c_char,
|
||||
version,
|
||||
(*factory).from_addr, (*factory).from_addr,
|
||||
(*(*factory).msg).rfc724_mid);
|
||||
free(version.cast());
|
||||
let content_type_0: *mut mailmime_content = mailmime_content_new_with_str(
|
||||
b"message/disposition-notification\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
|
||||
@@ -1379,11 +1379,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
|
||||
free(file_suffix as *mut libc::c_void);
|
||||
free(desired_filename as *mut libc::c_void);
|
||||
free(raw_mime as *mut libc::c_void);
|
||||
return if mimeparser.parts.len() > old_part_count {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
(mimeparser.parts.len() > old_part_count) as libc::c_int
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
@@ -1419,16 +1415,15 @@ unsafe fn do_add_single_file_part(
|
||||
part.param.set(Param::File, as_str(pathNfilename));
|
||||
part.param.set(Param::MimeType, as_str(raw_mime));
|
||||
if mime_type == 80 {
|
||||
let mut w = 0;
|
||||
let mut h = 0;
|
||||
if 0 != dc_get_filemeta(
|
||||
decoded_data as *const libc::c_void,
|
||||
decoded_data_bytes,
|
||||
&mut w,
|
||||
&mut h,
|
||||
) {
|
||||
part.param.set_int(Param::Width, w as i32);
|
||||
part.param.set_int(Param::Height, h as i32);
|
||||
assert!(!decoded_data.is_null(), "invalid image data");
|
||||
let data = std::slice::from_raw_parts(
|
||||
decoded_data as *const u8,
|
||||
decoded_data_bytes as usize,
|
||||
);
|
||||
|
||||
if let Ok((width, height)) = dc_get_filemeta(data) {
|
||||
part.param.set_int(Param::Width, width as i32);
|
||||
part.param.set_int(Param::Height, height as i32);
|
||||
}
|
||||
}
|
||||
do_add_single_part(parser, part);
|
||||
|
||||
@@ -419,11 +419,11 @@ pub unsafe fn dc_msg_get_timestamp(msg: *const dc_msg_t) -> i64 {
|
||||
if msg.is_null() {
|
||||
return 0;
|
||||
}
|
||||
return if 0 != (*msg).timestamp_sent {
|
||||
if 0 != (*msg).timestamp_sent {
|
||||
(*msg).timestamp_sent
|
||||
} else {
|
||||
(*msg).timestamp_sort
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id: u32) -> bool {
|
||||
@@ -1048,11 +1048,11 @@ pub unsafe fn dc_msg_get_setupcodebegin(msg: *const dc_msg_t) -> *mut libc::c_ch
|
||||
}
|
||||
free(filename as *mut libc::c_void);
|
||||
free(buf as *mut libc::c_void);
|
||||
return if !ret.is_null() {
|
||||
if !ret.is_null() {
|
||||
ret
|
||||
} else {
|
||||
dc_strdup(0 as *const libc::c_char)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn dc_msg_set_text(mut msg: *mut dc_msg_t, text: *const libc::c_char) {
|
||||
@@ -1201,9 +1201,9 @@ pub fn dc_update_msg_move_state(
|
||||
}
|
||||
|
||||
fn msgstate_can_fail(state: i32) -> bool {
|
||||
return DC_STATE_OUT_PREPARING == state
|
||||
DC_STATE_OUT_PREPARING == state
|
||||
|| DC_STATE_OUT_PENDING == state
|
||||
|| DC_STATE_OUT_DELIVERED == state;
|
||||
|| DC_STATE_OUT_DELIVERED == state
|
||||
}
|
||||
|
||||
pub unsafe fn dc_set_msg_failed(context: &Context, msg_id: uint32_t, error: *const libc::c_char) {
|
||||
|
||||
@@ -8,6 +8,7 @@ use mmime::mailmime_types::*;
|
||||
use mmime::mmapstring::*;
|
||||
use mmime::other::*;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::ptr;
|
||||
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
@@ -772,7 +773,7 @@ unsafe fn lookup_field(
|
||||
) -> Option<*const mailimf_field> {
|
||||
let field = dc_mimeparser_lookup_field(parser, name);
|
||||
if !field.is_null() && (*field).fld_type == typ as libc::c_int {
|
||||
return Some(field);
|
||||
Some(field)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -1506,8 +1507,12 @@ unsafe fn create_or_lookup_adhoc_group(
|
||||
ret_chat_id_blocked: *mut libc::c_int,
|
||||
chat_id: u32,
|
||||
chat_id_blocked: i32| {
|
||||
dc_array_unref(member_ids);
|
||||
dc_array_unref(chat_ids);
|
||||
if !member_ids.is_null() {
|
||||
dc_array_unref(member_ids);
|
||||
}
|
||||
if !chat_ids.is_null() {
|
||||
dc_array_unref(chat_ids);
|
||||
}
|
||||
free(chat_ids_str as *mut libc::c_void);
|
||||
free(grpid as *mut libc::c_void);
|
||||
free(grpname as *mut libc::c_void);
|
||||
@@ -1957,7 +1962,7 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> libc::c_int {
|
||||
@@ -1978,11 +1983,11 @@ unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist)
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
/// Check if a message is a reply to a known message (messenger or non-messenger).
|
||||
@@ -2035,7 +2040,7 @@ unsafe fn dc_is_reply_to_messenger_message(
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
unsafe fn is_msgrmsg_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> libc::c_int {
|
||||
@@ -2055,11 +2060,11 @@ unsafe fn is_msgrmsg_rfc724_mid_in_list(context: &Context, mid_list: *const clis
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
/// Check if a message is a reply to any messenger message.
|
||||
|
||||
@@ -442,7 +442,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
grpid = dc_strdup((*scan).text2)
|
||||
}
|
||||
}
|
||||
if 0 == encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice) {
|
||||
if !encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice) {
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
contact_chat_id,
|
||||
@@ -518,7 +518,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
b"Fingerprint not provided.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
current_block = 4378276786830486580;
|
||||
} else if 0 == encrypted_and_signed(mimeparser, fingerprint) {
|
||||
} else if !encrypted_and_signed(mimeparser, fingerprint) {
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
contact_chat_id,
|
||||
@@ -664,7 +664,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
}
|
||||
}
|
||||
if 0 != vg_expect_encrypted {
|
||||
if 0 == encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice) {
|
||||
if !encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice) {
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
contact_chat_id,
|
||||
@@ -883,22 +883,21 @@ unsafe fn mark_peer_as_verified(
|
||||
* Tools: Misc.
|
||||
******************************************************************************/
|
||||
|
||||
// TODO should return bool
|
||||
unsafe fn encrypted_and_signed(
|
||||
mimeparser: &dc_mimeparser_t,
|
||||
expected_fingerprint: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
) -> bool {
|
||||
if 0 == mimeparser.e2ee_helper.encrypted {
|
||||
warn!(mimeparser.context, 0, "Message not encrypted.",);
|
||||
return 0i32;
|
||||
return false;
|
||||
}
|
||||
if mimeparser.e2ee_helper.signatures.len() <= 0 {
|
||||
warn!(mimeparser.context, 0, "Message not signed.",);
|
||||
return 0i32;
|
||||
return false;
|
||||
}
|
||||
if expected_fingerprint.is_null() {
|
||||
warn!(mimeparser.context, 0, "Fingerprint for comparison missing.",);
|
||||
return 0i32;
|
||||
return false;
|
||||
}
|
||||
if !mimeparser
|
||||
.e2ee_helper
|
||||
@@ -911,10 +910,10 @@ unsafe fn encrypted_and_signed(
|
||||
"Message does not match expected fingerprint {}.",
|
||||
as_str(expected_fingerprint),
|
||||
);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
1
|
||||
true
|
||||
}
|
||||
|
||||
pub unsafe fn dc_handle_degrade_event(context: &Context, peerstate: &Peerstate) {
|
||||
|
||||
@@ -691,11 +691,11 @@ pub unsafe fn dc_decode_ext_header(to_decode: *const libc::c_char) -> *mut libc:
|
||||
}
|
||||
}
|
||||
free(charset as *mut libc::c_void);
|
||||
return if !decoded.is_null() {
|
||||
if !decoded.is_null() {
|
||||
decoded
|
||||
} else {
|
||||
dc_strdup(to_decode)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn print_hex(target: *mut libc::c_char, cur: *const libc::c_char) {
|
||||
|
||||
419
src/dc_tools.rs
419
src/dc_tools.rs
@@ -1,7 +1,8 @@
|
||||
use std::borrow::Cow;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::fs;
|
||||
use std::str::FromStr;
|
||||
use std::time::SystemTime;
|
||||
use std::{fmt, fs, ptr};
|
||||
|
||||
use chrono::{Local, TimeZone};
|
||||
use mmime::mailimf_types::*;
|
||||
@@ -13,14 +14,14 @@ use crate::error::Error;
|
||||
use crate::types::*;
|
||||
use crate::x::*;
|
||||
|
||||
const ELLIPSE: &'static str = "[...]";
|
||||
const ELLIPSE: &str = "[...]";
|
||||
|
||||
/* Some tools and enhancements to the used libraries, there should be
|
||||
no references to Context and other "larger" classes here. */
|
||||
/* ** library-private **********************************************************/
|
||||
/* math tools */
|
||||
pub fn dc_exactly_one_bit_set(v: libc::c_int) -> bool {
|
||||
0 != v && 0 == v & v - 1i32
|
||||
0 != v && 0 == v & (v - 1)
|
||||
}
|
||||
|
||||
/// Duplicates a string
|
||||
@@ -67,11 +68,11 @@ pub unsafe fn dc_strdup(s: *const libc::c_char) -> *mut libc::c_char {
|
||||
/// }
|
||||
/// ```
|
||||
pub unsafe fn dc_strdup_keep_null(s: *const libc::c_char) -> *mut libc::c_char {
|
||||
return if !s.is_null() {
|
||||
if !s.is_null() {
|
||||
dc_strdup(s)
|
||||
} else {
|
||||
0 as *mut libc::c_char
|
||||
};
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn dc_atoi_null_is_0(s: *const libc::c_char) -> libc::c_int {
|
||||
@@ -107,7 +108,7 @@ pub unsafe fn dc_str_replace(
|
||||
pub unsafe fn dc_ftoa(f: libc::c_double) -> *mut libc::c_char {
|
||||
// hack around printf(%f) that may return `,` as decimal point on mac
|
||||
let test: *mut libc::c_char = dc_mprintf(b"%f\x00" as *const u8 as *const libc::c_char, 1.2f64);
|
||||
*test.offset(2isize) = 0i32 as libc::c_char;
|
||||
*test.offset(2isize) = 0 as libc::c_char;
|
||||
let mut str: *mut libc::c_char = dc_mprintf(b"%f\x00" as *const u8 as *const libc::c_char, f);
|
||||
dc_str_replace(
|
||||
&mut str,
|
||||
@@ -153,9 +154,9 @@ pub unsafe fn dc_rtrim(buf: *mut libc::c_char) {
|
||||
}
|
||||
*cur.offset(
|
||||
(if 0 != libc::isspace(*cur as libc::c_int) {
|
||||
0i32
|
||||
0
|
||||
} else {
|
||||
1i32
|
||||
1
|
||||
}) as isize,
|
||||
) = '\u{0}' as i32 as libc::c_uchar
|
||||
};
|
||||
@@ -182,17 +183,17 @@ pub unsafe fn dc_str_contains(
|
||||
needle: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
if haystack.is_null() || needle.is_null() {
|
||||
return 0i32;
|
||||
return 0;
|
||||
}
|
||||
if !strstr(haystack, needle).is_null() {
|
||||
return 1i32;
|
||||
return 1;
|
||||
}
|
||||
let haystack_lower: *mut libc::c_char = dc_strlower(haystack);
|
||||
let needle_lower: *mut libc::c_char = dc_strlower(needle);
|
||||
let ret: libc::c_int = if !strstr(haystack_lower, needle_lower).is_null() {
|
||||
1i32
|
||||
let ret = if !strstr(haystack_lower, needle_lower).is_null() {
|
||||
1
|
||||
} else {
|
||||
0i32
|
||||
0
|
||||
};
|
||||
free(haystack_lower as *mut libc::c_void);
|
||||
free(needle_lower as *mut libc::c_void);
|
||||
@@ -207,10 +208,10 @@ pub unsafe fn dc_null_terminate(
|
||||
) -> *mut libc::c_char {
|
||||
let out: *mut libc::c_char = malloc(bytes as usize + 1) as *mut libc::c_char;
|
||||
assert!(!out.is_null());
|
||||
if !in_0.is_null() && bytes > 0i32 {
|
||||
if !in_0.is_null() && bytes > 0 {
|
||||
strncpy(out, in_0, bytes as usize);
|
||||
}
|
||||
*out.offset(bytes as isize) = 0i32 as libc::c_char;
|
||||
*out.offset(bytes as isize) = 0 as libc::c_char;
|
||||
|
||||
out
|
||||
}
|
||||
@@ -244,7 +245,7 @@ pub unsafe fn dc_remove_cr_chars(buf: *mut libc::c_char) {
|
||||
}
|
||||
p1 = p1.offset(1isize)
|
||||
}
|
||||
*p2 = 0i32 as libc::c_char;
|
||||
*p2 = 0 as libc::c_char;
|
||||
}
|
||||
|
||||
pub unsafe fn dc_unify_lineends(buf: *mut libc::c_char) {
|
||||
@@ -266,39 +267,39 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
||||
let ix: libc::c_int;
|
||||
let mut n: libc::c_int;
|
||||
let mut j: libc::c_int;
|
||||
i = 0i32;
|
||||
i = 0;
|
||||
ix = p1len;
|
||||
's_36: loop {
|
||||
if !(i < ix) {
|
||||
break;
|
||||
}
|
||||
c = *p1.offset(i as isize) as libc::c_int;
|
||||
if c > 0i32 && c <= 0x7fi32 {
|
||||
n = 0i32
|
||||
} else if c & 0xe0i32 == 0xc0i32 {
|
||||
n = 1i32
|
||||
} else if c == 0xedi32
|
||||
&& i < ix - 1i32
|
||||
&& *p1.offset((i + 1i32) as isize) as libc::c_int & 0xa0i32 == 0xa0i32
|
||||
if c > 0 && c <= 0x7f {
|
||||
n = 0
|
||||
} else if c & 0xe0 == 0xc0 {
|
||||
n = 1
|
||||
} else if c == 0xed
|
||||
&& i < ix - 1
|
||||
&& *p1.offset((i + 1) as isize) as libc::c_int & 0xa0 == 0xa0
|
||||
{
|
||||
/* U+d800 to U+dfff */
|
||||
OK_TO_CONTINUE = false;
|
||||
break;
|
||||
} else if c & 0xf0i32 == 0xe0i32 {
|
||||
n = 2i32
|
||||
} else if c & 0xf8i32 == 0xf0i32 {
|
||||
n = 3i32
|
||||
} else if c & 0xf0 == 0xe0 {
|
||||
n = 2
|
||||
} else if c & 0xf8 == 0xf0 {
|
||||
n = 3
|
||||
} else {
|
||||
//else if ((c & 0xFC) == 0xF8) { n=4; } /* 111110bb - not valid in https://tools.ietf.org/html/rfc3629 */
|
||||
//else if ((c & 0xFE) == 0xFC) { n=5; } /* 1111110b - not valid in https://tools.ietf.org/html/rfc3629 */
|
||||
OK_TO_CONTINUE = false;
|
||||
break;
|
||||
}
|
||||
j = 0i32;
|
||||
j = 0;
|
||||
while j < n && i < ix {
|
||||
/* n bytes matching 10bbbbbb follow ? */
|
||||
i += 1;
|
||||
if i == ix || *p1.offset(i as isize) as libc::c_int & 0xc0i32 != 0x80i32 {
|
||||
if i == ix || *p1.offset(i as isize) as libc::c_int & 0xc0 != 0x80 {
|
||||
OK_TO_CONTINUE = false;
|
||||
break 's_36;
|
||||
}
|
||||
@@ -308,7 +309,7 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
||||
}
|
||||
if OK_TO_CONTINUE == false {
|
||||
while 0 != *p1 {
|
||||
if *p1 as libc::c_int > 0x7fi32 {
|
||||
if *p1 as libc::c_int > 0x7f {
|
||||
*p1 = '_' as i32 as libc::c_uchar
|
||||
}
|
||||
p1 = p1.offset(1isize)
|
||||
@@ -319,15 +320,17 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
||||
|
||||
pub unsafe fn dc_utf8_strlen(s: *const libc::c_char) -> size_t {
|
||||
if s.is_null() {
|
||||
return 0i32 as size_t;
|
||||
return 0;
|
||||
}
|
||||
let mut i: size_t = 0i32 as size_t;
|
||||
let mut j: size_t = 0i32 as size_t;
|
||||
while 0 != *s.offset(i as isize) {
|
||||
if *s.offset(i as isize) as libc::c_int & 0xc0i32 != 0x80i32 {
|
||||
|
||||
let mut i = 0;
|
||||
let mut j: size_t = 0;
|
||||
|
||||
while 0 != *s.add(i) {
|
||||
if *s.offset(i as isize) as libc::c_int & 0xc0 != 0x80 {
|
||||
j = j.wrapping_add(1)
|
||||
}
|
||||
i = i.wrapping_add(1)
|
||||
i += 1;
|
||||
}
|
||||
|
||||
j
|
||||
@@ -360,12 +363,12 @@ pub unsafe fn dc_truncate_n_unwrap_str(
|
||||
} else {
|
||||
b" [...]\x00" as *const u8 as *const libc::c_char
|
||||
};
|
||||
let mut lastIsCharacter: libc::c_int = 0i32;
|
||||
let mut lastIsCharacter: libc::c_int = 0;
|
||||
/* force unsigned - otherwise the `> ' '` comparison will fail */
|
||||
let mut p1: *mut libc::c_uchar = buf as *mut libc::c_uchar;
|
||||
while 0 != *p1 {
|
||||
if *p1 as libc::c_int > ' ' as i32 {
|
||||
lastIsCharacter = 1i32
|
||||
lastIsCharacter = 1
|
||||
} else if 0 != lastIsCharacter {
|
||||
let used_bytes: size_t = (p1 as uintptr_t).wrapping_sub(buf as uintptr_t) as size_t;
|
||||
if dc_utf8_strnlen(buf, used_bytes) >= approx_characters as usize {
|
||||
@@ -375,7 +378,7 @@ pub unsafe fn dc_truncate_n_unwrap_str(
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
lastIsCharacter = 0i32;
|
||||
lastIsCharacter = 0;
|
||||
if 0 != do_unwrap {
|
||||
*p1 = ' ' as i32 as libc::c_uchar
|
||||
}
|
||||
@@ -392,15 +395,14 @@ pub unsafe fn dc_truncate_n_unwrap_str(
|
||||
|
||||
unsafe fn dc_utf8_strnlen(s: *const libc::c_char, n: size_t) -> size_t {
|
||||
if s.is_null() {
|
||||
return 0i32 as size_t;
|
||||
return 0;
|
||||
}
|
||||
let mut i: size_t = 0i32 as size_t;
|
||||
let mut j: size_t = 0i32 as size_t;
|
||||
while i < n {
|
||||
if *s.offset(i as isize) as libc::c_int & 0xc0i32 != 0x80i32 {
|
||||
|
||||
let mut j: size_t = 0;
|
||||
for i in 0..n {
|
||||
if *s.add(i) as libc::c_int & 0xc0 != 0x80 {
|
||||
j = j.wrapping_add(1)
|
||||
}
|
||||
i = i.wrapping_add(1)
|
||||
}
|
||||
|
||||
j
|
||||
@@ -439,7 +441,7 @@ pub unsafe fn dc_insert_breaks(
|
||||
break_every: libc::c_int,
|
||||
break_chars: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
if in_0.is_null() || break_every <= 0i32 || break_chars.is_null() {
|
||||
if in_0.is_null() || break_every <= 0 || break_chars.is_null() {
|
||||
return dc_strdup(in_0);
|
||||
}
|
||||
let mut out_len = strlen(in_0);
|
||||
@@ -448,7 +450,7 @@ pub unsafe fn dc_insert_breaks(
|
||||
out_len += (out_len / break_every as usize + 1) * break_chars_len + 1;
|
||||
let out: *mut libc::c_char = malloc(out_len) as *mut libc::c_char;
|
||||
if out.is_null() {
|
||||
return 0 as *mut libc::c_char;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let mut i: *const libc::c_char = in_0;
|
||||
let mut o: *mut libc::c_char = out;
|
||||
@@ -461,11 +463,11 @@ pub unsafe fn dc_insert_breaks(
|
||||
chars_added += 1;
|
||||
if chars_added == break_every && 0 != *i as libc::c_int {
|
||||
strcpy(o, break_chars);
|
||||
o = o.offset(break_chars_len as isize);
|
||||
chars_added = 0i32
|
||||
o = o.add(break_chars_len);
|
||||
chars_added = 0
|
||||
}
|
||||
}
|
||||
*o = 0i32 as libc::c_char;
|
||||
*o = 0 as libc::c_char;
|
||||
|
||||
out
|
||||
}
|
||||
@@ -482,7 +484,7 @@ pub unsafe fn dc_str_from_clist(
|
||||
let rfc724_mid = (if !cur.is_null() {
|
||||
(*cur).data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
ptr::null_mut()
|
||||
}) as *const libc::c_char;
|
||||
|
||||
if !rfc724_mid.is_null() {
|
||||
@@ -494,7 +496,7 @@ pub unsafe fn dc_str_from_clist(
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -522,7 +524,7 @@ pub unsafe fn dc_str_to_clist(
|
||||
(*list).last,
|
||||
strndup(p1, p2.wrapping_offset_from(p1) as libc::c_ulong) as *mut libc::c_void,
|
||||
);
|
||||
p1 = p2.offset(strlen(delimiter) as isize)
|
||||
p1 = p2.add(strlen(delimiter))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,8 +547,8 @@ pub fn dc_str_to_color_safe(s: impl AsRef<str>) -> u32 {
|
||||
let str_lower = s.as_ref().to_lowercase();
|
||||
let mut checksum = 0;
|
||||
let bytes = str_lower.as_bytes();
|
||||
for i in 0..str_lower.len() {
|
||||
checksum += (i + 1) * bytes[i] as usize;
|
||||
for (i, byte) in bytes.iter().enumerate() {
|
||||
checksum += (i + 1) * *byte as usize;
|
||||
checksum %= 0xffffff;
|
||||
}
|
||||
let color_index = checksum % COLORS.len();
|
||||
@@ -555,35 +557,21 @@ pub fn dc_str_to_color_safe(s: impl AsRef<str>) -> u32 {
|
||||
}
|
||||
|
||||
pub unsafe fn dc_str_to_color(str: *const libc::c_char) -> libc::c_int {
|
||||
let str_lower: *mut libc::c_char = dc_strlower(str);
|
||||
let mut checksum: libc::c_int = 0i32;
|
||||
let str_len: libc::c_int = strlen(str_lower) as libc::c_int;
|
||||
let mut i: libc::c_int = 0i32;
|
||||
while i < str_len {
|
||||
checksum += (i + 1i32) * *str_lower.offset(i as isize) as libc::c_int;
|
||||
checksum %= 0xffffffi32;
|
||||
i += 1
|
||||
}
|
||||
let color_index: libc::c_int = (checksum as libc::c_ulong).wrapping_rem(
|
||||
(::std::mem::size_of::<[uint32_t; 16]>() as libc::c_ulong)
|
||||
.wrapping_div(::std::mem::size_of::<uint32_t>() as libc::c_ulong),
|
||||
) as libc::c_int;
|
||||
free(str_lower as *mut libc::c_void);
|
||||
|
||||
COLORS[color_index as usize] as libc::c_int
|
||||
dc_str_to_color_safe(as_str(str)) as libc::c_int
|
||||
}
|
||||
|
||||
/* clist tools */
|
||||
/* calls free() for each item content */
|
||||
pub unsafe fn clist_free_content(haystack: *const clist) {
|
||||
let mut iter: *mut clistiter = (*haystack).first;
|
||||
let mut iter = (*haystack).first;
|
||||
|
||||
while !iter.is_null() {
|
||||
free((*iter).data);
|
||||
(*iter).data = 0 as *mut libc::c_void;
|
||||
(*iter).data = ptr::null_mut();
|
||||
iter = if !iter.is_null() {
|
||||
(*iter).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -592,15 +580,16 @@ pub unsafe fn clist_search_string_nocase(
|
||||
haystack: *const clist,
|
||||
needle: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
let mut iter: *mut clistiter = (*haystack).first;
|
||||
let mut iter = (*haystack).first;
|
||||
|
||||
while !iter.is_null() {
|
||||
if strcasecmp((*iter).data as *const libc::c_char, needle) == 0i32 {
|
||||
return 1i32;
|
||||
if strcasecmp((*iter).data as *const libc::c_char, needle) == 0 {
|
||||
return 1;
|
||||
}
|
||||
iter = if !iter.is_null() {
|
||||
(*iter).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,11 +612,11 @@ pub unsafe fn dc_timestamp_from_date(date_time: *mut mailimf_date_time) -> i64 {
|
||||
);
|
||||
|
||||
let (zone_hour, zone_min) = if (*date_time).dt_zone >= 0 {
|
||||
((*date_time).dt_zone / 100i32, (*date_time).dt_zone % 100i32)
|
||||
((*date_time).dt_zone / 100, (*date_time).dt_zone % 100)
|
||||
} else {
|
||||
(
|
||||
-(-(*date_time).dt_zone / 100i32),
|
||||
-(-(*date_time).dt_zone % 100i32),
|
||||
-(-(*date_time).dt_zone / 100),
|
||||
-(-(*date_time).dt_zone % 100),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -735,12 +724,12 @@ pub unsafe fn dc_create_incoming_rfc724_mid(
|
||||
contact_ids_to: *mut dc_array_t,
|
||||
) -> *mut libc::c_char {
|
||||
if contact_ids_to.is_null() || dc_array_get_cnt(contact_ids_to) == 0 {
|
||||
return 0 as *mut libc::c_char;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
/* find out the largest receiver ID (we could also take the smallest, but it should be unique) */
|
||||
let mut i: size_t = 0i32 as size_t;
|
||||
let icnt: size_t = dc_array_get_cnt(contact_ids_to);
|
||||
let mut largest_id_to: uint32_t = 0i32 as uint32_t;
|
||||
let mut i = 0;
|
||||
let icnt = dc_array_get_cnt(contact_ids_to);
|
||||
let mut largest_id_to = 0;
|
||||
while i < icnt {
|
||||
let cur_id: uint32_t = dc_array_get_id(contact_ids_to, i);
|
||||
if cur_id > largest_id_to {
|
||||
@@ -765,7 +754,7 @@ pub unsafe fn dc_create_outgoing_rfc724_mid(
|
||||
- this function is called for all outgoing messages.
|
||||
- the message ID should be globally unique
|
||||
- do not add a counter or any private data as as this may give unneeded information to the receiver */
|
||||
let mut rand1: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut rand1: *mut libc::c_char = ptr::null_mut();
|
||||
let rand2: *mut libc::c_char = dc_create_id().strdup();
|
||||
let ret: *mut libc::c_char;
|
||||
let mut at_hostname: *const libc::c_char = strchr(from_addr, '@' as i32);
|
||||
@@ -841,25 +830,22 @@ pub unsafe fn dc_extract_grpid_from_rfc724_mid_list(list: *const clist) -> *mut
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
0 as *mut clistcell
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0 as *mut libc::c_char
|
||||
ptr::null_mut()
|
||||
}
|
||||
|
||||
/* file tools */
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn dc_ensure_no_slash(pathNfilename: *mut libc::c_char) {
|
||||
let path_len = strlen(pathNfilename);
|
||||
if path_len > 0 {
|
||||
if *pathNfilename.offset((path_len - 1) as isize) as libc::c_int == '/' as i32
|
||||
|| *pathNfilename.offset((path_len - 1) as isize) as libc::c_int == '\\' as i32
|
||||
{
|
||||
*pathNfilename.offset((path_len - 1) as isize) = 0 as libc::c_char
|
||||
}
|
||||
};
|
||||
if path_len > 0 && *pathNfilename.add(path_len - 1) as libc::c_int == '/' as i32
|
||||
|| *pathNfilename.add(path_len - 1) as libc::c_int == '\\' as i32
|
||||
{
|
||||
*pathNfilename.add(path_len - 1) = 0 as libc::c_char;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dc_ensure_no_slash_safe(path: &str) -> &str {
|
||||
@@ -891,10 +877,10 @@ pub unsafe fn dc_get_filename(pathNfilename: *const libc::c_char) -> *mut libc::
|
||||
}
|
||||
if !p.is_null() {
|
||||
p = p.offset(1isize);
|
||||
return dc_strdup(p);
|
||||
dc_strdup(p)
|
||||
} else {
|
||||
return dc_strdup(pathNfilename);
|
||||
};
|
||||
dc_strdup(pathNfilename)
|
||||
}
|
||||
}
|
||||
|
||||
// the case of the suffix is preserved
|
||||
@@ -914,9 +900,9 @@ pub unsafe fn dc_split_filename(
|
||||
let p1: *mut libc::c_char = strrchr(basename, '.' as i32);
|
||||
if !p1.is_null() {
|
||||
suffix = dc_strdup(p1);
|
||||
*p1 = 0i32 as libc::c_char
|
||||
*p1 = 0 as libc::c_char
|
||||
} else {
|
||||
suffix = dc_strdup(0 as *const libc::c_char)
|
||||
suffix = dc_strdup(ptr::null())
|
||||
}
|
||||
if !ret_basename.is_null() {
|
||||
*ret_basename = basename
|
||||
@@ -941,90 +927,14 @@ pub unsafe fn dc_get_filesuffix_lc(pathNfilename: *const libc::c_char) -> *mut l
|
||||
}
|
||||
}
|
||||
|
||||
0 as *mut libc::c_char
|
||||
ptr::null_mut()
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_filemeta(
|
||||
buf_start: *const libc::c_void,
|
||||
buf_bytes: size_t,
|
||||
ret_width: *mut uint32_t,
|
||||
ret_height: *mut uint32_t,
|
||||
) -> libc::c_int {
|
||||
/* Strategy:
|
||||
reading GIF dimensions requires the first 10 bytes of the file
|
||||
reading PNG dimensions requires the first 24 bytes of the file
|
||||
reading JPEG dimensions requires scanning through jpeg chunks
|
||||
In all formats, the file is at least 24 bytes big, so we'll read that always
|
||||
inspired by http://www.cplusplus.com/forum/beginner/45217/ */
|
||||
let buf: *const libc::c_uchar = buf_start as *const libc::c_uchar;
|
||||
if buf_bytes < 24 {
|
||||
return 0i32;
|
||||
}
|
||||
if *buf.offset(0isize) as libc::c_int == 0xffi32
|
||||
&& *buf.offset(1isize) as libc::c_int == 0xd8i32
|
||||
&& *buf.offset(2isize) as libc::c_int == 0xffi32
|
||||
{
|
||||
let mut pos = 2;
|
||||
while *buf.offset(pos as isize) as libc::c_int == 0xffi32 {
|
||||
if *buf.offset((pos + 1) as isize) as libc::c_int == 0xc0i32
|
||||
|| *buf.offset((pos + 1) as isize) as libc::c_int == 0xc1i32
|
||||
|| *buf.offset((pos + 1) as isize) as libc::c_int == 0xc2i32
|
||||
|| *buf.offset((pos + 1) as isize) as libc::c_int == 0xc3i32
|
||||
|| *buf.offset((pos + 1) as isize) as libc::c_int == 0xc9i32
|
||||
|| *buf.offset((pos + 1) as isize) as libc::c_int == 0xcai32
|
||||
|| *buf.offset((pos + 1) as isize) as libc::c_int == 0xcbi32
|
||||
{
|
||||
*ret_height = (((*buf.offset((pos + 5) as isize) as libc::c_int) << 8i32)
|
||||
+ *buf.offset((pos + 6) as isize) as libc::c_int)
|
||||
as uint32_t;
|
||||
*ret_width = (((*buf.offset((pos + 7) as isize) as libc::c_int) << 8i32)
|
||||
+ *buf.offset((pos + 8) as isize) as libc::c_int)
|
||||
as uint32_t;
|
||||
return 1i32;
|
||||
}
|
||||
pos += 2
|
||||
+ ((*buf.offset((pos + 2) as isize) as libc::c_int) << 8)
|
||||
+ *buf.offset((pos + 3) as isize) as libc::c_int;
|
||||
if (pos + 12) > buf_bytes as libc::c_int {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if *buf.offset(0isize) as libc::c_int == 'G' as i32
|
||||
&& *buf.offset(1isize) as libc::c_int == 'I' as i32
|
||||
&& *buf.offset(2isize) as libc::c_int == 'F' as i32
|
||||
{
|
||||
*ret_width = (*buf.offset(6isize) as libc::c_int
|
||||
+ ((*buf.offset(7isize) as libc::c_int) << 8i32)) as uint32_t;
|
||||
*ret_height = (*buf.offset(8isize) as libc::c_int
|
||||
+ ((*buf.offset(9isize) as libc::c_int) << 8i32)) as uint32_t;
|
||||
return 1i32;
|
||||
}
|
||||
if *buf.offset(0isize) as libc::c_int == 0x89i32
|
||||
&& *buf.offset(1isize) as libc::c_int == 'P' as i32
|
||||
&& *buf.offset(2isize) as libc::c_int == 'N' as i32
|
||||
&& *buf.offset(3isize) as libc::c_int == 'G' as i32
|
||||
&& *buf.offset(4isize) as libc::c_int == 0xdi32
|
||||
&& *buf.offset(5isize) as libc::c_int == 0xai32
|
||||
&& *buf.offset(6isize) as libc::c_int == 0x1ai32
|
||||
&& *buf.offset(7isize) as libc::c_int == 0xai32
|
||||
&& *buf.offset(12isize) as libc::c_int == 'I' as i32
|
||||
&& *buf.offset(13isize) as libc::c_int == 'H' as i32
|
||||
&& *buf.offset(14isize) as libc::c_int == 'D' as i32
|
||||
&& *buf.offset(15isize) as libc::c_int == 'R' as i32
|
||||
{
|
||||
*ret_width = (((*buf.offset(16isize) as libc::c_int) << 24i32)
|
||||
+ ((*buf.offset(17isize) as libc::c_int) << 16i32)
|
||||
+ ((*buf.offset(18isize) as libc::c_int) << 8i32)
|
||||
+ ((*buf.offset(19isize) as libc::c_int) << 0i32)) as uint32_t;
|
||||
*ret_height = (((*buf.offset(20isize) as libc::c_int) << 24i32)
|
||||
+ ((*buf.offset(21isize) as libc::c_int) << 16i32)
|
||||
+ ((*buf.offset(22isize) as libc::c_int) << 8i32)
|
||||
+ ((*buf.offset(23isize) as libc::c_int) << 0i32)) as uint32_t;
|
||||
return 1i32;
|
||||
}
|
||||
/// Returns the `(width, height)` of the given image buffer.
|
||||
pub fn dc_get_filemeta(buf: &[u8]) -> Result<(u32, u32), Error> {
|
||||
let meta = image_meta::load_from_buf(buf)?;
|
||||
|
||||
0
|
||||
Ok((meta.dimensions.width, meta.dimensions.height))
|
||||
}
|
||||
|
||||
/// Expand paths relative to $BLOBDIR into absolute paths.
|
||||
@@ -1053,17 +963,17 @@ pub unsafe fn dc_get_abs_path(
|
||||
pathNfilename: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
if pathNfilename.is_null() {
|
||||
return 0 as *mut libc::c_char;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
|
||||
let starts = strncmp(
|
||||
pathNfilename,
|
||||
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
|
||||
8,
|
||||
) == 0i32;
|
||||
) == 0;
|
||||
|
||||
if starts && !context.has_blobdir() {
|
||||
return 0 as *mut libc::c_char;
|
||||
return ptr::null_mut();
|
||||
}
|
||||
|
||||
let mut pathNfilename_abs: *mut libc::c_char = dc_strdup(pathNfilename);
|
||||
@@ -1222,22 +1132,23 @@ pub unsafe fn dc_get_fine_pathNfilename(
|
||||
pathNfolder: *const libc::c_char,
|
||||
desired_filenameNsuffix__: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut ret: *mut libc::c_char = ptr::null_mut();
|
||||
let pathNfolder_wo_slash: *mut libc::c_char;
|
||||
let filenameNsuffix: *mut libc::c_char;
|
||||
let mut basename: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut dotNSuffix: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut basename: *mut libc::c_char = ptr::null_mut();
|
||||
let mut dotNSuffix: *mut libc::c_char = ptr::null_mut();
|
||||
let now = time();
|
||||
let mut i: libc::c_int = 0i32;
|
||||
|
||||
pathNfolder_wo_slash = dc_strdup(pathNfolder);
|
||||
dc_ensure_no_slash(pathNfolder_wo_slash);
|
||||
filenameNsuffix = dc_strdup(desired_filenameNsuffix__);
|
||||
dc_validate_filename(filenameNsuffix);
|
||||
dc_split_filename(filenameNsuffix, &mut basename, &mut dotNSuffix);
|
||||
while i < 1000i32 {
|
||||
|
||||
for i in 0..1000i64 {
|
||||
/*no deadlocks, please*/
|
||||
if 0 != i {
|
||||
let idx = if i < 100 { i as i64 } else { now + i as i64 };
|
||||
let idx = if i < 100 { i } else { now + i };
|
||||
ret = dc_mprintf(
|
||||
b"%s/%s-%lu%s\x00" as *const u8 as *const libc::c_char,
|
||||
pathNfolder_wo_slash,
|
||||
@@ -1256,12 +1167,11 @@ pub unsafe fn dc_get_fine_pathNfilename(
|
||||
if !dc_file_exist(context, as_path(ret)) {
|
||||
/* fine filename found */
|
||||
break;
|
||||
} else {
|
||||
free(ret as *mut libc::c_void);
|
||||
ret = 0 as *mut libc::c_char;
|
||||
i += 1
|
||||
}
|
||||
free(ret as *mut libc::c_void);
|
||||
ret = ptr::null_mut();
|
||||
}
|
||||
|
||||
free(filenameNsuffix as *mut libc::c_void);
|
||||
free(basename as *mut libc::c_void);
|
||||
free(dotNSuffix as *mut libc::c_void);
|
||||
@@ -1271,15 +1181,15 @@ pub unsafe fn dc_get_fine_pathNfilename(
|
||||
}
|
||||
|
||||
pub unsafe fn dc_is_blobdir_path(context: &Context, path: *const libc::c_char) -> bool {
|
||||
return strncmp(path, context.get_blobdir(), strlen(context.get_blobdir())) == 0
|
||||
|| strncmp(path, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, 8) == 0;
|
||||
strncmp(path, context.get_blobdir(), strlen(context.get_blobdir())) == 0
|
||||
|| strncmp(path, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, 8) == 0
|
||||
}
|
||||
|
||||
pub unsafe fn dc_make_rel_path(context: &Context, path: *mut *mut libc::c_char) {
|
||||
if path.is_null() || (*path).is_null() {
|
||||
return;
|
||||
}
|
||||
if strncmp(*path, context.get_blobdir(), strlen(context.get_blobdir())) == 0i32 {
|
||||
if strncmp(*path, context.get_blobdir(), strlen(context.get_blobdir())) == 0 {
|
||||
dc_str_replace(
|
||||
path,
|
||||
context.get_blobdir(),
|
||||
@@ -1290,8 +1200,8 @@ pub unsafe fn dc_make_rel_path(context: &Context, path: *mut *mut libc::c_char)
|
||||
|
||||
pub unsafe fn dc_make_rel_and_copy(context: &Context, path: *mut *mut libc::c_char) -> bool {
|
||||
let mut success = false;
|
||||
let mut filename: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut blobdir_path: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut filename: *mut libc::c_char = ptr::null_mut();
|
||||
let mut blobdir_path: *mut libc::c_char = ptr::null_mut();
|
||||
if !(path.is_null() || (*path).is_null()) {
|
||||
if dc_is_blobdir_path(context, *path) {
|
||||
dc_make_rel_path(context, path);
|
||||
@@ -1311,7 +1221,7 @@ pub unsafe fn dc_make_rel_and_copy(context: &Context, path: *mut *mut libc::c_ch
|
||||
{
|
||||
free(*path as *mut libc::c_void);
|
||||
*path = blobdir_path;
|
||||
blobdir_path = 0 as *mut libc::c_char;
|
||||
blobdir_path = ptr::null_mut();
|
||||
dc_make_rel_path(context, path);
|
||||
success = true;
|
||||
}
|
||||
@@ -1555,6 +1465,69 @@ pub fn time() -> i64 {
|
||||
.as_secs() as i64
|
||||
}
|
||||
|
||||
/// Very simple email address wrapper.
|
||||
///
|
||||
/// Represents an email address, right now just the `name@domain` portion.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use deltachat::dc_tools::EmailAddress;
|
||||
/// let email = match EmailAddress::new("someone@example.com") {
|
||||
/// Ok(addr) => addr,
|
||||
/// Err(e) => panic!("Error parsing address, error was {}", e),
|
||||
/// };
|
||||
/// assert_eq!(&email.local, "someone");
|
||||
/// assert_eq!(&email.domain, "example.com");
|
||||
/// assert_eq!(email.to_string(), "someone@example.com");
|
||||
/// ```
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct EmailAddress {
|
||||
pub local: String,
|
||||
pub domain: String,
|
||||
}
|
||||
|
||||
impl EmailAddress {
|
||||
pub fn new(input: &str) -> Result<Self, Error> {
|
||||
input.parse::<EmailAddress>()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for EmailAddress {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}@{}", self.local, self.domain)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for EmailAddress {
|
||||
type Err = Error;
|
||||
|
||||
/// Performs a dead-simple parse of an email address.
|
||||
fn from_str(input: &str) -> Result<EmailAddress, Error> {
|
||||
ensure!(!input.is_empty(), "empty string is not valid");
|
||||
let parts: Vec<&str> = input.rsplitn(2, '@').collect();
|
||||
|
||||
ensure!(parts.len() > 1, "missing '@' character");
|
||||
let local = parts[1];
|
||||
let domain = parts[0];
|
||||
|
||||
ensure!(
|
||||
!local.is_empty(),
|
||||
"empty string is not valid for local part"
|
||||
);
|
||||
ensure!(domain.len() > 3, "domain is too short");
|
||||
|
||||
let dot = domain.find('.');
|
||||
ensure!(dot.is_some(), "invalid domain");
|
||||
ensure!(dot.unwrap() < domain.len() - 2, "invalid domain");
|
||||
|
||||
Ok(EmailAddress {
|
||||
local: local.to_string(),
|
||||
domain: domain.to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1733,7 +1706,7 @@ mod tests {
|
||||
unsafe {
|
||||
let str: *mut libc::c_char = dc_insert_breaks(
|
||||
b"just1234tes\x00" as *const u8 as *const libc::c_char,
|
||||
4i32,
|
||||
4,
|
||||
b"--\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1749,7 +1722,7 @@ mod tests {
|
||||
unsafe {
|
||||
let str: *mut libc::c_char = dc_insert_breaks(
|
||||
b"just1234t\x00" as *const u8 as *const libc::c_char,
|
||||
4i32,
|
||||
4,
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1765,7 +1738,7 @@ mod tests {
|
||||
unsafe {
|
||||
let str: *mut libc::c_char = dc_insert_breaks(
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
4i32,
|
||||
4,
|
||||
b"---\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1818,10 +1791,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_dc_str_to_clist_1() {
|
||||
unsafe {
|
||||
let list: *mut clist = dc_str_to_clist(
|
||||
0 as *const libc::c_char,
|
||||
b" \x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let list = dc_str_to_clist(ptr::null(), b" \x00" as *const u8 as *const libc::c_char);
|
||||
assert_eq!((*list).count, 0);
|
||||
clist_free_content(list);
|
||||
clist_free(list);
|
||||
@@ -1940,7 +1910,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_dc_replace_bad_utf8_chars_4() {
|
||||
unsafe {
|
||||
dc_replace_bad_utf8_chars(0 as *mut libc::c_char);
|
||||
dc_replace_bad_utf8_chars(ptr::null_mut());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2114,4 +2084,31 @@ mod tests {
|
||||
let grpid = dc_extract_grpid_from_rfc724_mid(mid);
|
||||
assert_eq!(grpid, Some("1234567890123456"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_emailaddress_parse() {
|
||||
assert_eq!(EmailAddress::new("").is_ok(), false);
|
||||
assert_eq!(
|
||||
EmailAddress::new("user@domain.tld").unwrap(),
|
||||
EmailAddress {
|
||||
local: "user".into(),
|
||||
domain: "domain.tld".into(),
|
||||
}
|
||||
);
|
||||
assert_eq!(EmailAddress::new("uuu").is_ok(), false);
|
||||
assert_eq!(EmailAddress::new("dd.tt").is_ok(), false);
|
||||
assert_eq!(EmailAddress::new("tt.dd@uu").is_ok(), false);
|
||||
assert_eq!(EmailAddress::new("u@d").is_ok(), false);
|
||||
assert_eq!(EmailAddress::new("u@d.").is_ok(), false);
|
||||
assert_eq!(EmailAddress::new("u@d.t").is_ok(), false);
|
||||
assert_eq!(
|
||||
EmailAddress::new("u@d.tt").unwrap(),
|
||||
EmailAddress {
|
||||
local: "u".into(),
|
||||
domain: "d.tt".into(),
|
||||
}
|
||||
);
|
||||
assert_eq!(EmailAddress::new("u@.tt").is_ok(), false);
|
||||
assert_eq!(EmailAddress::new("@d.tt").is_ok(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ pub enum Error {
|
||||
Io(std::io::Error),
|
||||
#[fail(display = "{:?}", _0)]
|
||||
Message(String),
|
||||
#[fail(display = "{:?}", _0)]
|
||||
Image(image_meta::ImageError),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
@@ -46,6 +48,12 @@ impl From<std::io::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<image_meta::ImageError> for Error {
|
||||
fn from(err: image_meta::ImageError) -> Error {
|
||||
Error::Image(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! bail {
|
||||
($e:expr) => {
|
||||
|
||||
99
src/imap.rs
99
src/imap.rs
@@ -1,6 +1,9 @@
|
||||
use std::ffi::CString;
|
||||
use std::net;
|
||||
use std::sync::{Arc, Condvar, Mutex, RwLock};
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc, Condvar, Mutex, RwLock,
|
||||
};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use crate::constants::*;
|
||||
@@ -18,9 +21,9 @@ pub const DC_ALREADY_DONE: usize = 2;
|
||||
pub const DC_RETRY_LATER: usize = 1;
|
||||
pub const DC_FAILED: usize = 0;
|
||||
|
||||
const PREFETCH_FLAGS: &'static str = "(UID ENVELOPE)";
|
||||
const BODY_FLAGS: &'static str = "(FLAGS BODY.PEEK[])";
|
||||
const FETCH_FLAGS: &'static str = "(FLAGS)";
|
||||
const PREFETCH_FLAGS: &str = "(UID ENVELOPE)";
|
||||
const BODY_FLAGS: &str = "(FLAGS BODY.PEEK[])";
|
||||
const FETCH_FLAGS: &str = "(FLAGS)";
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Imap {
|
||||
@@ -35,6 +38,8 @@ pub struct Imap {
|
||||
session: Arc<Mutex<Option<Session>>>,
|
||||
stream: Arc<RwLock<Option<net::TcpStream>>>,
|
||||
connected: Arc<Mutex<bool>>,
|
||||
|
||||
should_reconnect: AtomicBool,
|
||||
}
|
||||
|
||||
struct OAuth2 {
|
||||
@@ -199,8 +204,8 @@ impl Session {
|
||||
|
||||
pub fn create<S: AsRef<str>>(&mut self, mailbox_name: S) -> imap::error::Result<()> {
|
||||
match self {
|
||||
Session::Secure(i) => i.subscribe(mailbox_name),
|
||||
Session::Insecure(i) => i.subscribe(mailbox_name),
|
||||
Session::Secure(i) => i.create(mailbox_name),
|
||||
Session::Insecure(i) => i.create(mailbox_name),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,8 +265,8 @@ impl Session {
|
||||
|
||||
pub fn idle(&mut self) -> imap::error::Result<IdleHandle> {
|
||||
match self {
|
||||
Session::Secure(i) => i.idle().map(|h| IdleHandle::Secure(h)),
|
||||
Session::Insecure(i) => i.idle().map(|h| IdleHandle::Insecure(h)),
|
||||
Session::Secure(i) => i.idle().map(IdleHandle::Secure),
|
||||
Session::Insecure(i) => i.idle().map(IdleHandle::Insecure),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +318,6 @@ pub struct ImapConfig {
|
||||
pub selected_folder: Option<String>,
|
||||
pub selected_mailbox: Option<imap::types::Mailbox>,
|
||||
pub selected_folder_needs_expunge: bool,
|
||||
pub should_reconnect: bool,
|
||||
pub can_idle: bool,
|
||||
pub has_xlist: bool,
|
||||
pub imap_delimiter: char,
|
||||
@@ -332,7 +336,6 @@ impl Default for ImapConfig {
|
||||
selected_folder: None,
|
||||
selected_mailbox: None,
|
||||
selected_folder_needs_expunge: false,
|
||||
should_reconnect: false,
|
||||
can_idle: false,
|
||||
has_xlist: false,
|
||||
imap_delimiter: '.',
|
||||
@@ -360,6 +363,7 @@ impl Imap {
|
||||
precheck_imf,
|
||||
receive_imf,
|
||||
connected: Arc::new(Mutex::new(false)),
|
||||
should_reconnect: AtomicBool::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +372,7 @@ impl Imap {
|
||||
}
|
||||
|
||||
pub fn should_reconnect(&self) -> bool {
|
||||
self.config.read().unwrap().should_reconnect
|
||||
self.should_reconnect.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
fn setup_handle_if_needed(&self, context: &Context) -> bool {
|
||||
@@ -381,7 +385,7 @@ impl Imap {
|
||||
}
|
||||
|
||||
if self.is_connected() && self.stream.read().unwrap().is_some() {
|
||||
self.config.write().unwrap().should_reconnect = false;
|
||||
self.should_reconnect.store(false, Ordering::Relaxed);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -451,7 +455,7 @@ impl Imap {
|
||||
}
|
||||
};
|
||||
|
||||
self.config.write().unwrap().should_reconnect = false;
|
||||
self.should_reconnect.store(false, Ordering::Relaxed);
|
||||
|
||||
match login_res {
|
||||
Ok((session, stream)) => {
|
||||
@@ -539,7 +543,7 @@ impl Imap {
|
||||
let mut config = self.config.write().unwrap();
|
||||
config.addr = addr.to_string();
|
||||
config.imap_server = imap_server.to_string();
|
||||
config.imap_port = imap_port.into();
|
||||
config.imap_port = imap_port;
|
||||
config.imap_user = imap_user.to_string();
|
||||
config.imap_pw = imap_pw.to_string();
|
||||
config.server_flags = server_flags;
|
||||
@@ -550,14 +554,12 @@ impl Imap {
|
||||
return false;
|
||||
}
|
||||
|
||||
let teardown: bool;
|
||||
|
||||
match &mut *self.session.lock().unwrap() {
|
||||
let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().unwrap() {
|
||||
Some(ref mut session) => {
|
||||
if let Ok(caps) = session.capabilities() {
|
||||
if !context.sql.is_open() {
|
||||
warn!(context, 0, "IMAP-LOGIN as {} ok but ABORTING", lp.mail_user,);
|
||||
teardown = true;
|
||||
(true, false, false)
|
||||
} else {
|
||||
let can_idle = caps.has("IDLE");
|
||||
let has_xlist = caps.has("XLIST");
|
||||
@@ -574,24 +576,23 @@ impl Imap {
|
||||
lp.mail_user,
|
||||
caps_list,
|
||||
);
|
||||
self.config.write().unwrap().can_idle = can_idle;
|
||||
self.config.write().unwrap().has_xlist = has_xlist;
|
||||
*self.connected.lock().unwrap() = true;
|
||||
teardown = false;
|
||||
(false, can_idle, has_xlist)
|
||||
}
|
||||
} else {
|
||||
teardown = true;
|
||||
(true, false, false)
|
||||
}
|
||||
}
|
||||
None => {
|
||||
teardown = true;
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -689,9 +690,8 @@ impl Imap {
|
||||
err
|
||||
);
|
||||
|
||||
let mut config = self.config.write().unwrap();
|
||||
config.selected_folder = None;
|
||||
config.should_reconnect = true;
|
||||
self.config.write().unwrap().selected_folder = None;
|
||||
self.should_reconnect.store(true, Ordering::Relaxed);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -777,7 +777,7 @@ impl Imap {
|
||||
match session.fetch(set, PREFETCH_FLAGS) {
|
||||
Ok(list) => list,
|
||||
Err(_err) => {
|
||||
self.config.write().unwrap().should_reconnect = true;
|
||||
self.should_reconnect.store(true, Ordering::Relaxed);
|
||||
info!(
|
||||
context,
|
||||
0,
|
||||
@@ -822,7 +822,7 @@ impl Imap {
|
||||
match session.uid_fetch(set, PREFETCH_FLAGS) {
|
||||
Ok(list) => list,
|
||||
Err(err) => {
|
||||
eprintln!("fetch err: {:?}", err);
|
||||
warn!(context, 0, "failed to fetch uids: {}", err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -928,15 +928,13 @@ impl Imap {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let mut retry_later = false;
|
||||
|
||||
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) {
|
||||
Ok(msgs) => msgs,
|
||||
Err(err) => {
|
||||
self.config.write().unwrap().should_reconnect = true;
|
||||
self.should_reconnect.store(true, Ordering::Relaxed);
|
||||
warn!(
|
||||
context,
|
||||
0,
|
||||
@@ -946,17 +944,11 @@ impl Imap {
|
||||
self.should_reconnect(),
|
||||
err
|
||||
);
|
||||
|
||||
if self.should_reconnect() {
|
||||
// maybe we should also retry on other errors, however, we should check this carefully, as this may result in a dead lock!
|
||||
retry_later = true;
|
||||
}
|
||||
|
||||
return if retry_later { 0 } else { 1 };
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return if retry_later { 0 } else { 1 };
|
||||
return 1;
|
||||
};
|
||||
|
||||
if msgs.is_empty() {
|
||||
@@ -1004,11 +996,7 @@ impl Imap {
|
||||
}
|
||||
}
|
||||
|
||||
if retry_later {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
1
|
||||
}
|
||||
|
||||
pub fn idle(&self, context: &Context) {
|
||||
@@ -1073,7 +1061,7 @@ impl Imap {
|
||||
context,
|
||||
0, "IMAP-IDLE wait cancelled, we will reconnect soon."
|
||||
);
|
||||
self.config.write().unwrap().should_reconnect = true;
|
||||
self.should_reconnect.store(true, Ordering::Relaxed);
|
||||
}
|
||||
_ => {
|
||||
warn!(context, 0, "IMAP-IDLE returns unknown value: {}", err);
|
||||
@@ -1576,20 +1564,23 @@ impl Imap {
|
||||
info!(context, 0, "MVBOX-folder created.",);
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("create error: {:?}", err);
|
||||
warn!(
|
||||
context,
|
||||
0, "Cannot create MVBOX-folder, using trying INBOX subfolder."
|
||||
0,
|
||||
"Cannot create MVBOX-folder, using trying INBOX subfolder. ({})",
|
||||
err
|
||||
);
|
||||
|
||||
match session.create(&fallback_folder) {
|
||||
Ok(_) => {
|
||||
mvbox_folder = Some(fallback_folder);
|
||||
info!(context, 0, "MVBOX-folder created as INBOX subfolder.",);
|
||||
info!(
|
||||
context,
|
||||
0, "MVBOX-folder created as INBOX subfolder. ({})", err
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("create error: {:?}", err);
|
||||
warn!(context, 0, "Cannot create MVBOX-folder.",);
|
||||
warn!(context, 0, "Cannot create MVBOX-folder. ({})", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ impl Key {
|
||||
}
|
||||
|
||||
pub fn from_slice(bytes: &[u8], key_type: KeyType) -> Option<Self> {
|
||||
if 0 == bytes.len() {
|
||||
if bytes.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let res: Result<Key, _> = match key_type {
|
||||
@@ -283,7 +283,7 @@ impl Key {
|
||||
Key::Public(_) => None,
|
||||
Key::Secret(k) => {
|
||||
let pub_key = k.public_key();
|
||||
pub_key.sign(k, || "".into()).map(|k| Key::Public(k)).ok()
|
||||
pub_key.sign(k, || "".into()).map(Key::Public).ok()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
#![feature(c_variadic, ptr_wrapping_offset_from, ptr_cast)]
|
||||
#![deny(clippy::correctness)]
|
||||
// TODO: make all of these errors, such that clippy actually passes.
|
||||
#![warn(clippy::all, clippy::perf, clippy::not_unsafe_ptr_arg_deref)]
|
||||
// This is nice, but for now just annoying.
|
||||
#![allow(clippy::unreadable_literal)]
|
||||
#![feature(ptr_wrapping_offset_from)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
|
||||
13
src/pgp.rs
13
src/pgp.rs
@@ -2,6 +2,7 @@ use std::collections::HashSet;
|
||||
use std::convert::TryInto;
|
||||
use std::ffi::CStr;
|
||||
use std::io::Cursor;
|
||||
use std::ptr;
|
||||
|
||||
use pgp::composed::{
|
||||
Deserializable, KeyType as PgpKeyType, Message, SecretKeyParamsBuilder, SignedPublicKey,
|
||||
@@ -29,19 +30,19 @@ pub unsafe fn dc_split_armored_data(
|
||||
let mut line: *mut libc::c_char = buf;
|
||||
let mut p1: *mut libc::c_char = buf;
|
||||
let mut p2: *mut libc::c_char;
|
||||
let mut headerline: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut base64: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut headerline: *mut libc::c_char = ptr::null_mut();
|
||||
let mut base64: *mut libc::c_char = ptr::null_mut();
|
||||
if !ret_headerline.is_null() {
|
||||
*ret_headerline = 0 as *const libc::c_char
|
||||
}
|
||||
if !ret_setupcodebegin.is_null() {
|
||||
*ret_setupcodebegin = 0 as *const libc::c_char
|
||||
*ret_setupcodebegin = ptr::null_mut();
|
||||
}
|
||||
if !ret_preferencrypt.is_null() {
|
||||
*ret_preferencrypt = 0 as *const libc::c_char
|
||||
*ret_preferencrypt = ptr::null();
|
||||
}
|
||||
if !ret_base64.is_null() {
|
||||
*ret_base64 = 0 as *const libc::c_char
|
||||
*ret_base64 = ptr::null();
|
||||
}
|
||||
if !(buf.is_null() || ret_headerline.is_null()) {
|
||||
dc_remove_cr_chars(buf);
|
||||
@@ -143,7 +144,7 @@ pub fn dc_pgp_create_keypair(addr: impl AsRef<str>) -> Option<(Key, Key)> {
|
||||
.key_type(PgpKeyType::Rsa(2048))
|
||||
.can_create_certificates(true)
|
||||
.can_sign(true)
|
||||
.primary_user_id(user_id.into())
|
||||
.primary_user_id(user_id)
|
||||
.passphrase(None)
|
||||
.preferred_symmetric_algorithms(smallvec![
|
||||
SymmetricKeyAlgorithm::AES256,
|
||||
|
||||
12
src/sql.rs
12
src/sql.rs
@@ -286,7 +286,7 @@ impl Sql {
|
||||
|
||||
fn table_exists(conn: &Connection, name: impl AsRef<str>) -> Result<bool> {
|
||||
let mut exists = false;
|
||||
conn.pragma(None, "table_info", &format!("{}", name.as_ref()), |_row| {
|
||||
conn.pragma(None, "table_info", &name.as_ref().to_string(), |_row| {
|
||||
// will only be executed if the info was found
|
||||
exists = true;
|
||||
Ok(())
|
||||
@@ -830,7 +830,7 @@ where
|
||||
&err,
|
||||
querystr.as_ref()
|
||||
);
|
||||
Err(err.into())
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1003,10 +1003,10 @@ pub fn housekeeping(context: &Context) {
|
||||
let name_f = entry.file_name();
|
||||
let name_s = name_f.to_string_lossy();
|
||||
|
||||
if is_file_in_use(&mut files_in_use, None, &name_s)
|
||||
|| is_file_in_use(&mut files_in_use, Some(".increation"), &name_s)
|
||||
|| is_file_in_use(&mut files_in_use, Some(".waveform"), &name_s)
|
||||
|| is_file_in_use(&mut files_in_use, Some("-preview.jpg"), &name_s)
|
||||
if is_file_in_use(&files_in_use, None, &name_s)
|
||||
|| is_file_in_use(&files_in_use, Some(".increation"), &name_s)
|
||||
|| is_file_in_use(&files_in_use, Some(".waveform"), &name_s)
|
||||
|| is_file_in_use(&files_in_use, Some("-preview.jpg"), &name_s)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user