mirror of
https://github.com/chatmail/core.git
synced 2026-06-25 00:56:39 +03:00
Compare commits
23 Commits
fix_upload
...
provider-o
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0c014d7e2 | ||
|
|
46520edd87 | ||
|
|
14daa99802 | ||
|
|
4f9f67a477 | ||
|
|
85f182067c | ||
|
|
66ab6874f8 | ||
|
|
906b901e3d | ||
|
|
65adff4bdd | ||
|
|
e60fc0dc30 | ||
|
|
ffd719962c | ||
|
|
1a1f0c0a7c | ||
|
|
3944592c09 | ||
|
|
a5f862a564 | ||
|
|
489f25940f | ||
|
|
6288909481 | ||
|
|
c95f134963 | ||
|
|
024c2883c0 | ||
|
|
d7b0ecad75 | ||
|
|
50947b81c0 | ||
|
|
e5a1b721f1 | ||
|
|
aeb1a88e7a | ||
|
|
c406675d6a | ||
|
|
1ec193991b |
48
Cargo.lock
generated
48
Cargo.lock
generated
@@ -474,12 +474,12 @@ dependencies = [
|
||||
"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)",
|
||||
"imap 1.0.2 (git+https://github.com/jonhoo/rust-imap?rev=31e2490d2203a837d8830736bcb183831ec4894d)",
|
||||
"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)",
|
||||
"lettre 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mmime 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mmime 0.1.2-alpha.0 (git+https://github.com/dignifiedquire/mmime?rev=bccd2c2)",
|
||||
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -507,6 +507,17 @@ dependencies = [
|
||||
"thread-local-object 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deltachat-provider-overview"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deltachat_derive"
|
||||
version = "0.1.0"
|
||||
@@ -520,9 +531,11 @@ name = "deltachat_ffi"
|
||||
version = "1.0.0-alpha.4"
|
||||
dependencies = [
|
||||
"deltachat 1.0.0-alpha.4",
|
||||
"deltachat-provider-overview 0.1.0",
|
||||
"human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -791,6 +804,11 @@ name = "glob"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.1.26"
|
||||
@@ -949,12 +967,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "imap"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+https://github.com/jonhoo/rust-imap?rev=31e2490d2203a837d8830736bcb183831ec4894d#31e2490d2203a837d8830736bcb183831ec4894d"
|
||||
dependencies = [
|
||||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imap-proto 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imap-proto 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -962,7 +980,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "imap-proto"
|
||||
version = "0.7.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1192,8 +1210,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mmime"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
version = "0.1.2-alpha.0"
|
||||
source = "git+https://github.com/dignifiedquire/mmime?rev=bccd2c2#bccd2c2c89e9241e05f321c963f638affdccad96"
|
||||
dependencies = [
|
||||
"charset 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2733,6 +2751,14 @@ dependencies = [
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "0.6.0"
|
||||
@@ -2841,6 +2867,7 @@ dependencies = [
|
||||
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
||||
"checksum getrandom 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2512b3191f22e2763a5db387f1c9409379772e2050841722eb4a8c4f497bf096"
|
||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
"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"
|
||||
@@ -2855,8 +2882,8 @@ dependencies = [
|
||||
"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 imap 1.0.2 (git+https://github.com/jonhoo/rust-imap?rev=31e2490d2203a837d8830736bcb183831ec4894d)" = "<none>"
|
||||
"checksum imap-proto 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a588218700a1f56790d585596d5edd879dd19c2fc554b34277e1c999249d787"
|
||||
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
|
||||
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
||||
"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
|
||||
@@ -2884,7 +2911,7 @@ dependencies = [
|
||||
"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10"
|
||||
"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23"
|
||||
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
|
||||
"checksum mmime 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a1246fa340840c36f1fca1507db82463fbc4c2f7763fe84bfde666c7381e0593"
|
||||
"checksum mmime 0.1.2-alpha.0 (git+https://github.com/dignifiedquire/mmime?rev=bccd2c2)" = "<none>"
|
||||
"checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e"
|
||||
"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
|
||||
"checksum nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b"
|
||||
@@ -3051,5 +3078,6 @@ dependencies = [
|
||||
"checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e"
|
||||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
"checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538"
|
||||
"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d"
|
||||
"checksum zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e68403b858b6af538b11614e62dfe9ab2facba9f13a0cafb974855cfb495ec95"
|
||||
"checksum zeroize_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3f07490820219949839d0027b965ffdd659d75be9220c00798762e36c6cd281"
|
||||
|
||||
@@ -23,8 +23,8 @@ num-derive = "0.2.5"
|
||||
num-traits = "0.2.6"
|
||||
native-tls = "0.2.3"
|
||||
lettre = "0.9.0"
|
||||
imap = "1.0.1"
|
||||
mmime = "0.1.0"
|
||||
imap = { git = "https://github.com/jonhoo/rust-imap", rev = "31e2490d2203a837d8830736bcb183831ec4894d" }
|
||||
mmime = { git = "https://github.com/dignifiedquire/mmime", rev = "bccd2c2" }
|
||||
base64 = "0.10"
|
||||
charset = "0.1"
|
||||
percent-encoding = "2.0"
|
||||
|
||||
@@ -34,7 +34,6 @@ echo -----------------------
|
||||
# Bundle external shared libraries into the wheels
|
||||
pushd $WHEELHOUSEDIR
|
||||
|
||||
pip3 install -U setuptools
|
||||
pip3 install devpi-client
|
||||
devpi use https://m.devpi.net
|
||||
devpi login dc --password $DEVPI_LOGIN
|
||||
|
||||
@@ -41,7 +41,7 @@ if [ -n "$TESTS" ]; then
|
||||
# see https://github.com/deltachat/deltachat-core-rust/issues/331
|
||||
# unset DCC_PY_LIVECONFIG
|
||||
|
||||
tox --workdir "$TOXWORKDIR" -e lint,py27,py35,py36,py37,auditwheels
|
||||
tox --workdir "$TOXWORKDIR" -e lint,py35,py36,py37,auditwheels
|
||||
popd
|
||||
fi
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ libc = "0.2"
|
||||
human-panic = "1.0.1"
|
||||
num-traits = "0.2.6"
|
||||
|
||||
deltachat-provider-overview = { path = "../../../deltachat-provider-overview" }
|
||||
# serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
[features]
|
||||
default = ["vendored", "nightly", "ringbuf"]
|
||||
vendored = ["deltachat/vendored"]
|
||||
|
||||
@@ -441,7 +441,11 @@ char* dc_get_info (dc_context_t* context);
|
||||
*/
|
||||
char* dc_get_oauth2_url (dc_context_t* context, const char* addr, const char* redirect_uri);
|
||||
|
||||
/**
|
||||
* Get the provider information from our provider overview as json object.
|
||||
*/
|
||||
|
||||
char* dc_get_json_provider_info_from_email (char* email);
|
||||
|
||||
// connect
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ use std::convert::TryInto;
|
||||
use std::ptr;
|
||||
use std::str::FromStr;
|
||||
|
||||
extern crate deltachat_provider_overview;
|
||||
|
||||
use deltachat::contact::Contact;
|
||||
use deltachat::dc_tools::{as_str, dc_strdup, StrExt};
|
||||
use deltachat::*;
|
||||
@@ -2530,6 +2532,19 @@ fn as_opt_str<'a>(s: *const libc::c_char) -> Option<&'a str> {
|
||||
Some(dc_tools::as_str(s))
|
||||
}
|
||||
|
||||
pub unsafe extern "C" fn dc_get_json_provider_info_from_email(
|
||||
email: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
let option = deltachat_provider_overview::get_provider_info(
|
||||
deltachat_provider_overview::get_domain_from_email(dc_tools::as_str(email)),
|
||||
);
|
||||
if let Some(provider) = option {
|
||||
serde_json::to_string(provider.0).unwrap().strdup()
|
||||
} else {
|
||||
dc_strdup(ptr::null())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ResultExt<T> {
|
||||
fn unwrap_or_log_default(self, context: &context::Context, message: &str) -> T;
|
||||
fn log_err(&self, context: &context::Context, message: &str);
|
||||
|
||||
@@ -72,10 +72,10 @@ then cargo-build and install the deltachat bindings::
|
||||
python install_python_bindings.py
|
||||
|
||||
The bindings will be installed in release mode but with debug symbols.
|
||||
The release mode is neccessary because some tests generate RSA keys
|
||||
The release mode is necessary because some tests generate RSA keys
|
||||
which is prohibitively slow in debug mode.
|
||||
|
||||
After succcessul binding installation you can finally run the tests::
|
||||
After successful binding installation you can finally run the tests::
|
||||
|
||||
pytest -v tests
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[tox]
|
||||
# make sure to update environment list in travis.yml and appveyor.yml
|
||||
envlist =
|
||||
py27
|
||||
py35
|
||||
lint
|
||||
auditwheels
|
||||
|
||||
@@ -33,6 +33,7 @@ pub enum Config {
|
||||
E2eeEnabled,
|
||||
#[strum(props(default = "1"))]
|
||||
MdnsEnabled,
|
||||
#[strum(props(default = "1"))]
|
||||
InboxWatch,
|
||||
#[strum(props(default = "1"))]
|
||||
SentboxWatch,
|
||||
|
||||
1000
src/configure/mod.rs
1000
src/configure/mod.rs
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,9 @@ use crate::aheader::EncryptPreference;
|
||||
use crate::config::Config;
|
||||
use crate::constants::*;
|
||||
use crate::context::Context;
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_loginparam::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::e2ee;
|
||||
use crate::error::Result;
|
||||
use crate::key::*;
|
||||
use crate::message::MessageState;
|
||||
@@ -603,7 +603,7 @@ impl<'a> Contact<'a> {
|
||||
});
|
||||
ret += &p;
|
||||
if self_key.is_none() {
|
||||
dc_ensure_secret_key_exists(context)?;
|
||||
e2ee::ensure_secret_key_exists(context)?;
|
||||
self_key = Key::from_self_public(context, &loginparam.addr, &context.sql);
|
||||
}
|
||||
let p = context.stock_str(StockMessage::FingerPrints);
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::chat::*;
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
use crate::dc_loginparam::*;
|
||||
use crate::dc_move::*;
|
||||
use crate::dc_receive_imf::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::imap::*;
|
||||
@@ -228,7 +227,7 @@ unsafe fn cb_precheck_imf(
|
||||
if as_str(old_server_folder) != server_folder || old_server_uid != server_uid {
|
||||
dc_update_server_uid(context, rfc724_mid, server_folder, server_uid);
|
||||
}
|
||||
dc_do_heuristics_moves(context, server_folder, msg_id);
|
||||
do_heuristics_moves(context, server_folder, msg_id);
|
||||
if 0 != mark_seen {
|
||||
job_add(
|
||||
context,
|
||||
@@ -575,6 +574,45 @@ pub fn dc_is_mvbox(context: &Context, folder_name: impl AsRef<str>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn do_heuristics_moves(context: &Context, folder: &str, msg_id: u32) {
|
||||
if context
|
||||
.sql
|
||||
.get_config_int(context, "mvbox_move")
|
||||
.unwrap_or_else(|| 1)
|
||||
== 0
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if !dc_is_inbox(context, folder) && !dc_is_sentbox(context, folder) {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Ok(msg) = dc_msg_new_load(context, msg_id) {
|
||||
if dc_msg_is_setupmessage(&msg) {
|
||||
// do not move setup messages;
|
||||
// there may be a non-delta device that wants to handle it
|
||||
return;
|
||||
}
|
||||
|
||||
if dc_is_mvbox(context, folder) {
|
||||
dc_update_msg_move_state(context, msg.rfc724_mid, MoveState::Stay);
|
||||
}
|
||||
|
||||
// 1 = dc message, 2 = reply to dc message
|
||||
if 0 != msg.is_dc_message {
|
||||
job_add(
|
||||
context,
|
||||
Action::MoveMsg,
|
||||
msg.id as libc::c_int,
|
||||
Params::new(),
|
||||
0,
|
||||
);
|
||||
dc_update_msg_move_state(context, msg.rfc724_mid, MoveState::Moving);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
106
src/dc_imex.rs
106
src/dc_imex.rs
@@ -11,8 +11,8 @@ use crate::config::Config;
|
||||
use crate::configure::*;
|
||||
use crate::constants::*;
|
||||
use crate::context::Context;
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::e2ee;
|
||||
use crate::error::*;
|
||||
use crate::job::*;
|
||||
use crate::key::*;
|
||||
@@ -196,7 +196,7 @@ pub fn dc_render_setup_file(context: &Context, passphrase: &str) -> Result<Strin
|
||||
passphrase.len() >= 2,
|
||||
"Passphrase must be at least 2 chars long."
|
||||
);
|
||||
let self_addr = dc_ensure_secret_key_exists(context)?;
|
||||
let self_addr = e2ee::ensure_secret_key_exists(context)?;
|
||||
let private_key = Key::from_self_private(context, self_addr, &context.sql)
|
||||
.ok_or(format_err!("Failed to get private key."))?;
|
||||
let ac_headers = match context
|
||||
@@ -522,7 +522,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: &Job) {
|
||||
} else {
|
||||
if what == 1 || what == 11 {
|
||||
/* before we export anything, make sure the private key exists */
|
||||
if dc_ensure_secret_key_exists(context).is_err() {
|
||||
if e2ee::ensure_secret_key_exists(context).is_err() {
|
||||
error!(
|
||||
context,
|
||||
0,
|
||||
@@ -712,7 +712,7 @@ The macro avoids weird values of 0% or 100% while still working. */
|
||||
// TODO should return bool /rtn
|
||||
#[allow(non_snake_case)]
|
||||
unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_int {
|
||||
let mut current_block: u64;
|
||||
let mut ok_to_continue: bool;
|
||||
let mut success: libc::c_int = 0;
|
||||
|
||||
let mut delete_dest_file: libc::c_int = 0;
|
||||
@@ -768,32 +768,30 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
.is_err()
|
||||
{
|
||||
/* error already logged */
|
||||
current_block = 11487273724841241105;
|
||||
ok_to_continue = false;
|
||||
} else {
|
||||
current_block = 14648156034262866959;
|
||||
ok_to_continue = true;
|
||||
}
|
||||
} else {
|
||||
current_block = 14648156034262866959;
|
||||
ok_to_continue = true;
|
||||
}
|
||||
match current_block {
|
||||
11487273724841241105 => {}
|
||||
_ => {
|
||||
let mut total_files_cnt = 0;
|
||||
let dir = std::path::Path::new(as_str(context.get_blobdir()));
|
||||
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
||||
total_files_cnt += dir_handle.filter(|r| r.is_ok()).count();
|
||||
if ok_to_continue {
|
||||
let mut total_files_cnt = 0;
|
||||
let dir = std::path::Path::new(as_str(context.get_blobdir()));
|
||||
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
||||
total_files_cnt += dir_handle.filter(|r| r.is_ok()).count();
|
||||
|
||||
info!(context, 0, "EXPORT: total_files_cnt={}", total_files_cnt);
|
||||
if total_files_cnt > 0 {
|
||||
// scan directory, pass 2: copy files
|
||||
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
||||
sql.prepare(
|
||||
info!(context, 0, "EXPORT: total_files_cnt={}", total_files_cnt);
|
||||
if total_files_cnt > 0 {
|
||||
// scan directory, pass 2: copy files
|
||||
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
||||
sql.prepare(
|
||||
"INSERT INTO backup_blobs (file_name, file_content) VALUES (?, ?);",
|
||||
move |mut stmt, _| {
|
||||
let mut processed_files_cnt = 0;
|
||||
for entry in dir_handle {
|
||||
if entry.is_err() {
|
||||
current_block = 2631791190359682872;
|
||||
ok_to_continue = true;
|
||||
break;
|
||||
}
|
||||
let entry = entry.unwrap();
|
||||
@@ -805,7 +803,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
.shall_stop_ongoing
|
||||
{
|
||||
delete_dest_file = 1;
|
||||
current_block = 11487273724841241105;
|
||||
ok_to_continue = false;
|
||||
break;
|
||||
} else {
|
||||
processed_files_cnt += 1;
|
||||
@@ -850,7 +848,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
&curr_pathNfilename,
|
||||
);
|
||||
/* this is not recoverable! writing to the sqlite database should work! */
|
||||
current_block = 11487273724841241105;
|
||||
ok_to_continue = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -862,43 +860,39 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
Ok(())
|
||||
}
|
||||
).unwrap();
|
||||
} else {
|
||||
error!(
|
||||
context,
|
||||
0,
|
||||
"Backup: Cannot copy from blob-directory \"{}\".",
|
||||
as_str(context.get_blobdir()),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
info!(context, 0, "Backup: No files to copy.",);
|
||||
current_block = 2631791190359682872;
|
||||
}
|
||||
match current_block {
|
||||
11487273724841241105 => {}
|
||||
_ => {
|
||||
if sql
|
||||
.set_config_int(context, "backup_time", now as i32)
|
||||
.is_ok()
|
||||
{
|
||||
context.call_cb(
|
||||
Event::IMEX_FILE_WRITTEN,
|
||||
dest_pathNfilename as uintptr_t,
|
||||
0,
|
||||
);
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
error!(
|
||||
context,
|
||||
0,
|
||||
"Backup: Cannot copy from blob-directory \"{}\".",
|
||||
as_str(context.get_blobdir()),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
error!(
|
||||
context,
|
||||
0,
|
||||
"Backup: Cannot get info for blob-directory \"{}\".",
|
||||
as_str(context.get_blobdir())
|
||||
);
|
||||
};
|
||||
}
|
||||
info!(context, 0, "Backup: No files to copy.",);
|
||||
ok_to_continue = true;
|
||||
}
|
||||
if ok_to_continue {
|
||||
if sql
|
||||
.set_config_int(context, "backup_time", now as i32)
|
||||
.is_ok()
|
||||
{
|
||||
context.call_cb(
|
||||
Event::IMEX_FILE_WRITTEN,
|
||||
dest_pathNfilename as uintptr_t,
|
||||
0,
|
||||
);
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error!(
|
||||
context,
|
||||
0,
|
||||
"Backup: Cannot get info for blob-directory \"{}\".",
|
||||
as_str(context.get_blobdir())
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ use crate::chat::{self, Chat};
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
use crate::context::{dc_get_version_str, Context};
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_strencode::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::e2ee::*;
|
||||
use crate::error::Error;
|
||||
use crate::location;
|
||||
use crate::message::*;
|
||||
@@ -353,13 +353,7 @@ pub unsafe fn dc_mimefactory_render(factory: &mut dc_mimefactory_t) -> libc::c_i
|
||||
let mut force_plaintext: libc::c_int = 0;
|
||||
let mut do_gossip: libc::c_int = 0;
|
||||
let mut grpimage = None;
|
||||
let mut e2ee_helper = dc_e2ee_helper_t {
|
||||
encryption_successfull: 0,
|
||||
cdata_to_free: ptr::null_mut(),
|
||||
encrypted: 0,
|
||||
signatures: Default::default(),
|
||||
gossipped_addr: Default::default(),
|
||||
};
|
||||
let mut e2ee_helper = E2eeHelper::default();
|
||||
|
||||
if factory.loaded as libc::c_uint == DC_MF_NOTHING_LOADED as libc::c_int as libc::c_uint
|
||||
|| !factory.out.is_null()
|
||||
@@ -1033,7 +1027,7 @@ pub unsafe fn dc_mimefactory_render(factory: &mut dc_mimefactory_t) -> libc::c_i
|
||||
),
|
||||
);
|
||||
if force_plaintext != 2 {
|
||||
dc_e2ee_encrypt(
|
||||
e2ee_helper.encrypt(
|
||||
factory.context,
|
||||
factory.recipients_addr,
|
||||
force_plaintext,
|
||||
@@ -1041,10 +1035,9 @@ pub unsafe fn dc_mimefactory_render(factory: &mut dc_mimefactory_t) -> libc::c_i
|
||||
min_verified,
|
||||
do_gossip,
|
||||
message,
|
||||
&mut e2ee_helper,
|
||||
);
|
||||
}
|
||||
if 0 != e2ee_helper.encryption_successfull {
|
||||
if e2ee_helper.encryption_successfull {
|
||||
factory.out_encrypted = 1;
|
||||
if 0 != do_gossip {
|
||||
factory.out_gossiped = 1
|
||||
@@ -1052,14 +1045,14 @@ pub unsafe fn dc_mimefactory_render(factory: &mut dc_mimefactory_t) -> libc::c_i
|
||||
}
|
||||
factory.out = mmap_string_new(b"\x00" as *const u8 as *const libc::c_char);
|
||||
mailmime_write_mem(factory.out, &mut col, message);
|
||||
success = 1
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if !message.is_null() {
|
||||
mailmime_free(message);
|
||||
}
|
||||
dc_e2ee_thanks(&mut e2ee_helper);
|
||||
e2ee_helper.thanks();
|
||||
free(message_text as *mut libc::c_void);
|
||||
free(message_text2 as *mut libc::c_void);
|
||||
free(subject_str as *mut libc::c_void);
|
||||
|
||||
@@ -15,10 +15,10 @@ use mmime::other::*;
|
||||
use crate::constants::Viewtype;
|
||||
use crate::contact::*;
|
||||
use crate::context::Context;
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_simplify::*;
|
||||
use crate::dc_strencode::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::e2ee::*;
|
||||
use crate::location;
|
||||
use crate::param::*;
|
||||
use crate::stock::StockMessage;
|
||||
@@ -43,7 +43,6 @@ pub struct dc_mimepart_t {
|
||||
/* *
|
||||
* @class dc_mimeparser_t
|
||||
*/
|
||||
#[derive(Clone)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct dc_mimeparser_t<'a> {
|
||||
pub parts: Vec<dc_mimepart_t>,
|
||||
@@ -54,7 +53,7 @@ pub struct dc_mimeparser_t<'a> {
|
||||
pub subject: *mut libc::c_char,
|
||||
pub is_send_by_messenger: bool,
|
||||
pub decrypting_failed: libc::c_int,
|
||||
pub e2ee_helper: dc_e2ee_helper_t,
|
||||
pub e2ee_helper: E2eeHelper,
|
||||
pub is_forwarded: libc::c_int,
|
||||
pub context: &'a Context,
|
||||
pub reports: Vec<*mut mailmime>,
|
||||
@@ -109,7 +108,7 @@ unsafe fn dc_mimeparser_empty(mimeparser: &mut dc_mimeparser_t) {
|
||||
mimeparser.is_forwarded = 0i32;
|
||||
mimeparser.reports.clear();
|
||||
mimeparser.decrypting_failed = 0i32;
|
||||
dc_e2ee_thanks(&mut mimeparser.e2ee_helper);
|
||||
mimeparser.e2ee_helper.thanks();
|
||||
|
||||
mimeparser.location_kml = None;
|
||||
mimeparser.message_kml = None;
|
||||
@@ -135,14 +134,12 @@ pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_m
|
||||
&mut mimeparser.mimeroot,
|
||||
);
|
||||
if r == MAILIMF_NO_ERROR as libc::c_int && !mimeparser.mimeroot.is_null() {
|
||||
dc_e2ee_decrypt(
|
||||
mimeparser.context,
|
||||
mimeparser.mimeroot,
|
||||
&mut mimeparser.e2ee_helper,
|
||||
);
|
||||
mimeparser
|
||||
.e2ee_helper
|
||||
.decrypt(mimeparser.context, mimeparser.mimeroot);
|
||||
let mimeparser_ref = &mut mimeparser;
|
||||
dc_mimeparser_parse_mime_recursive(mimeparser_ref, mimeparser_ref.mimeroot);
|
||||
let field: *mut mailimf_field = dc_mimeparser_lookup_field(&mut mimeparser, "Subject");
|
||||
let field: *mut mailimf_field = dc_mimeparser_lookup_field(&mimeparser, "Subject");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_SUBJECT as libc::c_int {
|
||||
mimeparser.subject = dc_decode_header_words((*(*field).fld_data.fld_subject).sbj_value)
|
||||
}
|
||||
@@ -1361,9 +1358,9 @@ unsafe fn do_add_single_file_part(
|
||||
}
|
||||
|
||||
unsafe fn do_add_single_part(parser: &mut dc_mimeparser_t, mut part: dc_mimepart_t) {
|
||||
if 0 != (*parser).e2ee_helper.encrypted && (*parser).e2ee_helper.signatures.len() > 0 {
|
||||
if (*parser).e2ee_helper.encrypted && (*parser).e2ee_helper.signatures.len() > 0 {
|
||||
part.param.set_int(Param::GuranteeE2ee, 1);
|
||||
} else if 0 != (*parser).e2ee_helper.encrypted {
|
||||
} else if (*parser).e2ee_helper.encrypted {
|
||||
part.param.set_int(Param::ErroneousE2ee, 0x2);
|
||||
}
|
||||
parser.parts.push(part);
|
||||
@@ -1818,19 +1815,22 @@ mod tests {
|
||||
let mut mimeparser = dc_mimeparser_parse(&context.ctx, &raw[..]);
|
||||
|
||||
assert_eq!(
|
||||
as_str(mimeparser.subject as *const libc::c_char),
|
||||
&to_string(mimeparser.subject as *const libc::c_char),
|
||||
"inner-subject",
|
||||
);
|
||||
|
||||
let mut of: *mut mailimf_optional_field =
|
||||
dc_mimeparser_lookup_optional_field(&mimeparser, "X-Special-A");
|
||||
assert_eq!(as_str((*of).fld_value as *const libc::c_char), "special-a",);
|
||||
assert_eq!(
|
||||
&to_string((*of).fld_value as *const libc::c_char),
|
||||
"special-a",
|
||||
);
|
||||
|
||||
of = dc_mimeparser_lookup_optional_field(&mimeparser, "Foo");
|
||||
assert_eq!(as_str((*of).fld_value as *const libc::c_char), "Bar",);
|
||||
assert_eq!(&to_string((*of).fld_value as *const libc::c_char), "Bar",);
|
||||
|
||||
of = dc_mimeparser_lookup_optional_field(&mimeparser, "Chat-Version");
|
||||
assert_eq!(as_str((*of).fld_value as *const libc::c_char), "1.0",);
|
||||
assert_eq!(&to_string((*of).fld_value as *const libc::c_char), "1.0",);
|
||||
assert_eq!(mimeparser.parts.len(), 1);
|
||||
|
||||
dc_mimeparser_unref(&mut mimeparser);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
use crate::constants::*;
|
||||
use crate::context::*;
|
||||
use crate::job::*;
|
||||
use crate::message::*;
|
||||
use crate::param::Params;
|
||||
|
||||
pub unsafe fn dc_do_heuristics_moves(context: &Context, folder: &str, msg_id: u32) {
|
||||
if context
|
||||
.sql
|
||||
.get_config_int(context, "mvbox_move")
|
||||
.unwrap_or_else(|| 1)
|
||||
== 0
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if !dc_is_inbox(context, folder) && !dc_is_sentbox(context, folder) {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Ok(msg) = dc_msg_new_load(context, msg_id) {
|
||||
if dc_msg_is_setupmessage(&msg) {
|
||||
// do not move setup messages;
|
||||
// there may be a non-delta device that wants to handle it
|
||||
return;
|
||||
}
|
||||
|
||||
if dc_is_mvbox(context, folder) {
|
||||
dc_update_msg_move_state(context, msg.rfc724_mid, MoveState::Stay);
|
||||
}
|
||||
|
||||
// 1 = dc message, 2 = reply to dc message
|
||||
if 0 != msg.is_dc_message {
|
||||
job_add(
|
||||
context,
|
||||
Action::MoveMsg,
|
||||
msg.id as libc::c_int,
|
||||
Params::new(),
|
||||
0,
|
||||
);
|
||||
dc_update_msg_move_state(context, msg.rfc724_mid, MoveState::Moving);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,8 @@ use sha2::{Digest, Sha256};
|
||||
use crate::chat::{self, Chat};
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
use crate::context::Context;
|
||||
use crate::context::{do_heuristics_moves, Context};
|
||||
use crate::dc_mimeparser::*;
|
||||
use crate::dc_move::*;
|
||||
use crate::dc_securejoin::*;
|
||||
use crate::dc_strencode::*;
|
||||
use crate::dc_tools::*;
|
||||
@@ -735,7 +734,7 @@ unsafe fn add_parts(
|
||||
}
|
||||
}
|
||||
|
||||
dc_do_heuristics_moves(context, server_folder.as_ref(), *insert_msg_id);
|
||||
do_heuristics_moves(context, server_folder.as_ref(), *insert_msg_id);
|
||||
cleanup(mime_in_reply_to, mime_references, txt_raw);
|
||||
|
||||
Ok(())
|
||||
@@ -1762,7 +1761,7 @@ unsafe fn check_verified_properties(
|
||||
}
|
||||
};
|
||||
|
||||
if 0 == mimeparser.e2ee_helper.encrypted {
|
||||
if mimeparser.e2ee_helper.encrypted {
|
||||
verify_fail("This message is not encrypted".into());
|
||||
return 0;
|
||||
}
|
||||
@@ -1875,10 +1874,7 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
||||
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||
if !fld_in_reply_to.is_null() {
|
||||
if 0 != is_known_rfc724_mid_in_list(
|
||||
context,
|
||||
(*(*field).fld_data.fld_in_reply_to).mid_list,
|
||||
) {
|
||||
if is_known_rfc724_mid_in_list(context, (*(*field).fld_data.fld_in_reply_to).mid_list) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1887,10 +1883,7 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int {
|
||||
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||
if !fld_references.is_null() {
|
||||
if 0 != is_known_rfc724_mid_in_list(
|
||||
context,
|
||||
(*(*field).fld_data.fld_references).mid_list,
|
||||
) {
|
||||
if is_known_rfc724_mid_in_list(context, (*(*field).fld_data.fld_references).mid_list) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1898,29 +1891,18 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
0
|
||||
}
|
||||
|
||||
unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> libc::c_int {
|
||||
if !mid_list.is_null() {
|
||||
let mut cur: *mut clistiter;
|
||||
cur = (*mid_list).first;
|
||||
while !cur.is_null() {
|
||||
if 0 != is_known_rfc724_mid(
|
||||
context,
|
||||
(if !cur.is_null() {
|
||||
(*cur).data
|
||||
} else {
|
||||
ptr::null_mut()
|
||||
}) as *const libc::c_char,
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
cur = if !cur.is_null() {
|
||||
(*cur).next
|
||||
} else {
|
||||
ptr::null_mut()
|
||||
}
|
||||
unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> bool {
|
||||
if mid_list.is_null() {
|
||||
return false;
|
||||
}
|
||||
|
||||
for data in &*mid_list {
|
||||
if 0 != is_known_rfc724_mid(context, data.cast()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
0
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Check if a message is a reply to a known message (messenger or non-messenger).
|
||||
|
||||
@@ -8,10 +8,10 @@ use crate::configure::*;
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
use crate::context::Context;
|
||||
use crate::dc_e2ee::*;
|
||||
use crate::dc_mimeparser::*;
|
||||
use crate::dc_token::*;
|
||||
use crate::dc_tools::*;
|
||||
use crate::e2ee::*;
|
||||
use crate::key::*;
|
||||
use crate::lot::LotState;
|
||||
use crate::message::*;
|
||||
@@ -32,27 +32,29 @@ pub unsafe fn dc_get_securejoin_qr(
|
||||
========================================================= */
|
||||
|
||||
let mut fingerprint = ptr::null_mut();
|
||||
let mut invitenumber: *mut libc::c_char;
|
||||
let mut auth: *mut libc::c_char;
|
||||
let mut qr: Option<String> = None;
|
||||
|
||||
dc_ensure_secret_key_exists(context).ok();
|
||||
invitenumber = dc_token_lookup(context, DC_TOKEN_INVITENUMBER, group_chat_id);
|
||||
if invitenumber.is_null() {
|
||||
invitenumber = dc_create_id().strdup();
|
||||
dc_token_save(context, DC_TOKEN_INVITENUMBER, group_chat_id, invitenumber);
|
||||
}
|
||||
auth = dc_token_lookup(context, DC_TOKEN_AUTH, group_chat_id);
|
||||
if auth.is_null() {
|
||||
auth = dc_create_id().strdup();
|
||||
dc_token_save(context, DC_TOKEN_AUTH, group_chat_id, auth);
|
||||
}
|
||||
ensure_secret_key_exists(context).ok();
|
||||
let invitenumber = dc_token_lookup(context, DC_TOKEN_INVITENUMBER, group_chat_id)
|
||||
.unwrap_or_else(|| {
|
||||
let invitenumber_s = dc_create_id();
|
||||
dc_token_save(
|
||||
context,
|
||||
DC_TOKEN_INVITENUMBER,
|
||||
group_chat_id,
|
||||
&invitenumber_s,
|
||||
);
|
||||
invitenumber_s
|
||||
});
|
||||
let auth = dc_token_lookup(context, DC_TOKEN_AUTH, group_chat_id).unwrap_or_else(|| {
|
||||
let auth_s = dc_create_id();
|
||||
dc_token_save(context, DC_TOKEN_AUTH, group_chat_id, &auth_s);
|
||||
auth_s
|
||||
});
|
||||
let self_addr = context.sql.get_config(context, "configured_addr");
|
||||
|
||||
let cleanup = |fingerprint| {
|
||||
free(fingerprint as *mut libc::c_void);
|
||||
free(invitenumber as *mut libc::c_void);
|
||||
free(auth as *mut libc::c_void);
|
||||
|
||||
if let Some(qr) = qr {
|
||||
qr.strdup()
|
||||
@@ -93,8 +95,8 @@ pub unsafe fn dc_get_securejoin_qr(
|
||||
self_addr_urlencoded,
|
||||
&group_name_urlencoded,
|
||||
&chat.grpid,
|
||||
as_str(invitenumber),
|
||||
as_str(auth),
|
||||
&invitenumber,
|
||||
&auth,
|
||||
))
|
||||
} else {
|
||||
error!(
|
||||
@@ -109,8 +111,8 @@ pub unsafe fn dc_get_securejoin_qr(
|
||||
as_str(fingerprint),
|
||||
self_addr_urlencoded,
|
||||
self_name_urlencoded,
|
||||
as_str(invitenumber),
|
||||
as_str(auth),
|
||||
&invitenumber,
|
||||
&auth,
|
||||
))
|
||||
};
|
||||
|
||||
@@ -140,7 +142,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
||||
let mut join_vg: libc::c_int = 0i32;
|
||||
|
||||
info!(context, 0, "Requesting secure-join ...",);
|
||||
dc_ensure_secret_key_exists(context).ok();
|
||||
ensure_secret_key_exists(context).ok();
|
||||
ongoing_allocated = dc_alloc_ongoing(context);
|
||||
|
||||
if !(ongoing_allocated == 0i32) {
|
||||
@@ -414,7 +416,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
if invitenumber.is_null() {
|
||||
warn!(context, 0, "Secure-join denied (invitenumber missing).",);
|
||||
ok_to_continue = false;
|
||||
} else if !dc_token_exists(context, DC_TOKEN_INVITENUMBER, invitenumber) {
|
||||
} else if !dc_token_exists(context, DC_TOKEN_INVITENUMBER, as_str(invitenumber)) {
|
||||
warn!(context, 0, "Secure-join denied (bad invitenumber).",);
|
||||
ok_to_continue = false;
|
||||
} else {
|
||||
@@ -502,7 +504,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
contact_chat_id,
|
||||
if 0 != mimeparser.e2ee_helper.encrypted {
|
||||
if mimeparser.e2ee_helper.encrypted {
|
||||
b"No valid signature.\x00" as *const u8 as *const libc::c_char
|
||||
} else {
|
||||
b"Not encrypted.\x00" as *const u8 as *const libc::c_char
|
||||
@@ -602,7 +604,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
b"Auth not provided.\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
ok_to_continue = false;
|
||||
} else if !dc_token_exists(context, DC_TOKEN_AUTH, auth_0) {
|
||||
} else if !dc_token_exists(context, DC_TOKEN_AUTH, as_str(auth_0)) {
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
contact_chat_id,
|
||||
@@ -941,7 +943,7 @@ unsafe fn encrypted_and_signed(
|
||||
mimeparser: &dc_mimeparser_t,
|
||||
expected_fingerprint: impl AsRef<str>,
|
||||
) -> bool {
|
||||
if 0 == mimeparser.e2ee_helper.encrypted {
|
||||
if !mimeparser.e2ee_helper.encrypted {
|
||||
warn!(mimeparser.context, 0, "Message not encrypted.",);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,17 +14,14 @@ pub fn dc_token_save(
|
||||
context: &Context,
|
||||
namespc: dc_tokennamespc_t,
|
||||
foreign_id: u32,
|
||||
token: *const libc::c_char,
|
||||
token: &str,
|
||||
) -> bool {
|
||||
if token.is_null() {
|
||||
return false;
|
||||
}
|
||||
// foreign_id may be 0
|
||||
sql::execute(
|
||||
context,
|
||||
&context.sql,
|
||||
"INSERT INTO tokens (namespc, foreign_id, token, timestamp) VALUES (?, ?, ?, ?);",
|
||||
params![namespc as i32, foreign_id as i32, as_str(token), time()],
|
||||
params![namespc as i32, foreign_id as i32, token, time()],
|
||||
)
|
||||
.is_ok()
|
||||
}
|
||||
@@ -33,33 +30,21 @@ pub fn dc_token_lookup(
|
||||
context: &Context,
|
||||
namespc: dc_tokennamespc_t,
|
||||
foreign_id: u32,
|
||||
) -> *mut libc::c_char {
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, String>(
|
||||
context,
|
||||
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
||||
params![namespc as i32, foreign_id as i32],
|
||||
0,
|
||||
)
|
||||
.map(|s| unsafe { s.strdup() })
|
||||
.unwrap_or_else(|| std::ptr::null_mut())
|
||||
) -> Option<String> {
|
||||
context.sql.query_row_col::<_, String>(
|
||||
context,
|
||||
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
||||
params![namespc as i32, foreign_id as i32],
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn dc_token_exists(
|
||||
context: &Context,
|
||||
namespc: dc_tokennamespc_t,
|
||||
token: *const libc::c_char,
|
||||
) -> bool {
|
||||
if token.is_null() {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn dc_token_exists(context: &Context, namespc: dc_tokennamespc_t, token: &str) -> bool {
|
||||
context
|
||||
.sql
|
||||
.exists(
|
||||
"SELECT id FROM tokens WHERE namespc=? AND token=?;",
|
||||
params![namespc as i32, as_str(token)],
|
||||
params![namespc as i32, token],
|
||||
)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
22
src/imap.rs
22
src/imap.rs
@@ -548,19 +548,17 @@ impl Imap {
|
||||
}
|
||||
|
||||
let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().unwrap() {
|
||||
Some(ref mut session) => {
|
||||
if let Ok(caps) = session.capabilities() {
|
||||
Some(ref mut session) => match session.capabilities() {
|
||||
Ok(caps) => {
|
||||
if !context.sql.is_open() {
|
||||
warn!(context, 0, "IMAP-LOGIN as {} ok but ABORTING", lp.mail_user,);
|
||||
(true, false, false)
|
||||
} else {
|
||||
let can_idle = caps.has("IDLE");
|
||||
let has_xlist = caps.has("XLIST");
|
||||
let caps_list = caps.iter().fold(String::new(), |mut s, c| {
|
||||
s += " ";
|
||||
s += c;
|
||||
s
|
||||
});
|
||||
let can_idle = caps.has_str("IDLE");
|
||||
let has_xlist = caps.has_str("XLIST");
|
||||
let caps_list = caps
|
||||
.iter()
|
||||
.fold(String::new(), |s, c| s + &format!(" {:?}", c));
|
||||
log_event!(
|
||||
context,
|
||||
Event::IMAP_CONNECTED,
|
||||
@@ -571,10 +569,12 @@ impl Imap {
|
||||
);
|
||||
(false, can_idle, has_xlist)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
Err(err) => {
|
||||
info!(context, 0, "CAPABILITY command error: {}", err);
|
||||
(true, false, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
None => (true, false, false),
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ pub mod configure;
|
||||
pub mod constants;
|
||||
pub mod contact;
|
||||
pub mod context;
|
||||
mod e2ee;
|
||||
mod imap;
|
||||
pub mod job;
|
||||
mod job_thread;
|
||||
@@ -51,12 +52,10 @@ pub mod x;
|
||||
|
||||
pub mod dc_array;
|
||||
mod dc_dehtml;
|
||||
mod dc_e2ee;
|
||||
pub mod dc_imex;
|
||||
mod dc_loginparam;
|
||||
mod dc_mimefactory;
|
||||
pub mod dc_mimeparser;
|
||||
mod dc_move;
|
||||
pub mod dc_receive_imf;
|
||||
pub mod dc_securejoin;
|
||||
mod dc_simplify;
|
||||
|
||||
Reference in New Issue
Block a user