mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
Merge branch 'master' into fix_securejoin_closure
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
version: 2.1
|
version: 2.1
|
||||||
|
|
||||||
executors:
|
executors:
|
||||||
default:
|
default:
|
||||||
docker:
|
docker:
|
||||||
@@ -153,11 +152,12 @@ jobs:
|
|||||||
- wheelhouse
|
- wheelhouse
|
||||||
|
|
||||||
upload_docs_wheels:
|
upload_docs_wheels:
|
||||||
machine: True
|
machine: true
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: workspace
|
at: workspace
|
||||||
|
- run: pyenv global 3.5.2
|
||||||
- run: ls -laR workspace
|
- run: ls -laR workspace
|
||||||
- run: ci_scripts/ci_upload.sh workspace/py-docs workspace/wheelhouse
|
- run: ci_scripts/ci_upload.sh workspace/py-docs workspace/wheelhouse
|
||||||
|
|
||||||
|
|||||||
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -479,7 +479,7 @@ dependencies = [
|
|||||||
"lazy_static 1.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)",
|
||||||
"lettre 0.9.2 (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)",
|
"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)",
|
"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-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)",
|
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -1192,8 +1192,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mmime"
|
name = "mmime"
|
||||||
version = "0.1.1"
|
version = "0.1.2-alpha.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/dignifiedquire/mmime?rev=bccd2c2#bccd2c2c89e9241e05f321c963f638affdccad96"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"charset 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"charset 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -2884,7 +2884,7 @@ dependencies = [
|
|||||||
"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10"
|
"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 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 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 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 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"
|
"checksum nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ num-traits = "0.2.6"
|
|||||||
native-tls = "0.2.3"
|
native-tls = "0.2.3"
|
||||||
lettre = "0.9.0"
|
lettre = "0.9.0"
|
||||||
imap = "1.0.1"
|
imap = "1.0.1"
|
||||||
mmime = "0.1.0"
|
mmime = { git = "https://github.com/dignifiedquire/mmime", rev = "bccd2c2" }
|
||||||
base64 = "0.10"
|
base64 = "0.10"
|
||||||
charset = "0.1"
|
charset = "0.1"
|
||||||
percent-encoding = "2.0"
|
percent-encoding = "2.0"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ echo -----------------------
|
|||||||
# Bundle external shared libraries into the wheels
|
# Bundle external shared libraries into the wheels
|
||||||
pushd $WHEELHOUSEDIR
|
pushd $WHEELHOUSEDIR
|
||||||
|
|
||||||
pip install devpi-client
|
pip3 install devpi-client
|
||||||
devpi use https://m.devpi.net
|
devpi use https://m.devpi.net
|
||||||
devpi login dc --password $DEVPI_LOGIN
|
devpi login dc --password $DEVPI_LOGIN
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ if [ -n "$TESTS" ]; then
|
|||||||
# see https://github.com/deltachat/deltachat-core-rust/issues/331
|
# 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
|
tox --workdir "$TOXWORKDIR" -e lint,py35,py36,py37,auditwheels
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
[tox]
|
[tox]
|
||||||
# make sure to update environment list in travis.yml and appveyor.yml
|
# make sure to update environment list in travis.yml and appveyor.yml
|
||||||
envlist =
|
envlist =
|
||||||
py27
|
|
||||||
py35
|
py35
|
||||||
lint
|
lint
|
||||||
auditwheels
|
auditwheels
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ pub enum Config {
|
|||||||
E2eeEnabled,
|
E2eeEnabled,
|
||||||
#[strum(props(default = "1"))]
|
#[strum(props(default = "1"))]
|
||||||
MdnsEnabled,
|
MdnsEnabled,
|
||||||
|
#[strum(props(default = "1"))]
|
||||||
InboxWatch,
|
InboxWatch,
|
||||||
#[strum(props(default = "1"))]
|
#[strum(props(default = "1"))]
|
||||||
SentboxWatch,
|
SentboxWatch,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
|||||||
|
|
||||||
use crate::constants::Event;
|
use crate::constants::Event;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_e2ee::*;
|
|
||||||
use crate::dc_loginparam::*;
|
use crate::dc_loginparam::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::e2ee;
|
||||||
use crate::imap::*;
|
use crate::imap::*;
|
||||||
use crate::job::*;
|
use crate::job::*;
|
||||||
use crate::oauth2::*;
|
use crate::oauth2::*;
|
||||||
@@ -589,7 +589,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: &Job) {
|
|||||||
.ok();
|
.ok();
|
||||||
if !s.shall_stop_ongoing {
|
if !s.shall_stop_ongoing {
|
||||||
progress!(context, 920);
|
progress!(context, 920);
|
||||||
dc_ensure_secret_key_exists(context);
|
e2ee::ensure_secret_key_exists(context);
|
||||||
success = true;
|
success = true;
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ use crate::aheader::EncryptPreference;
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_e2ee::*;
|
|
||||||
use crate::dc_loginparam::*;
|
use crate::dc_loginparam::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::e2ee;
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use crate::key::*;
|
use crate::key::*;
|
||||||
use crate::message::MessageState;
|
use crate::message::MessageState;
|
||||||
@@ -603,7 +603,7 @@ impl<'a> Contact<'a> {
|
|||||||
});
|
});
|
||||||
ret += &p;
|
ret += &p;
|
||||||
if self_key.is_none() {
|
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);
|
self_key = Key::from_self_public(context, &loginparam.addr, &context.sql);
|
||||||
}
|
}
|
||||||
let p = context.stock_str(StockMessage::FingerPrints);
|
let p = context.stock_str(StockMessage::FingerPrints);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use crate::chat::*;
|
|||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::dc_loginparam::*;
|
use crate::dc_loginparam::*;
|
||||||
use crate::dc_move::*;
|
|
||||||
use crate::dc_receive_imf::*;
|
use crate::dc_receive_imf::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
use crate::imap::*;
|
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 {
|
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_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 {
|
if 0 != mark_seen {
|
||||||
job_add(
|
job_add(
|
||||||
context,
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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::configure::*;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_e2ee::*;
|
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::e2ee;
|
||||||
use crate::error::*;
|
use crate::error::*;
|
||||||
use crate::job::*;
|
use crate::job::*;
|
||||||
use crate::key::*;
|
use crate::key::*;
|
||||||
@@ -196,7 +196,7 @@ pub fn dc_render_setup_file(context: &Context, passphrase: &str) -> Result<Strin
|
|||||||
passphrase.len() >= 2,
|
passphrase.len() >= 2,
|
||||||
"Passphrase must be at least 2 chars long."
|
"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)
|
let private_key = Key::from_self_private(context, self_addr, &context.sql)
|
||||||
.ok_or(format_err!("Failed to get private key."))?;
|
.ok_or(format_err!("Failed to get private key."))?;
|
||||||
let ac_headers = match context
|
let ac_headers = match context
|
||||||
@@ -522,7 +522,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: &Job) {
|
|||||||
} else {
|
} else {
|
||||||
if what == 1 || what == 11 {
|
if what == 1 || what == 11 {
|
||||||
/* before we export anything, make sure the private key exists */
|
/* 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!(
|
error!(
|
||||||
context,
|
context,
|
||||||
0,
|
0,
|
||||||
@@ -712,7 +712,7 @@ The macro avoids weird values of 0% or 100% while still working. */
|
|||||||
// TODO should return bool /rtn
|
// TODO should return bool /rtn
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_int {
|
unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_int {
|
||||||
let mut current_block: u64;
|
let mut ok_to_continue: bool;
|
||||||
let mut success: libc::c_int = 0;
|
let mut success: libc::c_int = 0;
|
||||||
|
|
||||||
let mut delete_dest_file: 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()
|
.is_err()
|
||||||
{
|
{
|
||||||
/* error already logged */
|
/* error already logged */
|
||||||
current_block = 11487273724841241105;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
current_block = 14648156034262866959;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
current_block = 14648156034262866959;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
match current_block {
|
if ok_to_continue {
|
||||||
11487273724841241105 => {}
|
let mut total_files_cnt = 0;
|
||||||
_ => {
|
let dir = std::path::Path::new(as_str(context.get_blobdir()));
|
||||||
let mut total_files_cnt = 0;
|
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
||||||
let dir = std::path::Path::new(as_str(context.get_blobdir()));
|
total_files_cnt += dir_handle.filter(|r| r.is_ok()).count();
|
||||||
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);
|
info!(context, 0, "EXPORT: total_files_cnt={}", total_files_cnt);
|
||||||
if total_files_cnt > 0 {
|
if total_files_cnt > 0 {
|
||||||
// scan directory, pass 2: copy files
|
// scan directory, pass 2: copy files
|
||||||
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
if let Ok(dir_handle) = std::fs::read_dir(dir) {
|
||||||
sql.prepare(
|
sql.prepare(
|
||||||
"INSERT INTO backup_blobs (file_name, file_content) VALUES (?, ?);",
|
"INSERT INTO backup_blobs (file_name, file_content) VALUES (?, ?);",
|
||||||
move |mut stmt, _| {
|
move |mut stmt, _| {
|
||||||
let mut processed_files_cnt = 0;
|
let mut processed_files_cnt = 0;
|
||||||
for entry in dir_handle {
|
for entry in dir_handle {
|
||||||
if entry.is_err() {
|
if entry.is_err() {
|
||||||
current_block = 2631791190359682872;
|
ok_to_continue = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
@@ -805,7 +803,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
|||||||
.shall_stop_ongoing
|
.shall_stop_ongoing
|
||||||
{
|
{
|
||||||
delete_dest_file = 1;
|
delete_dest_file = 1;
|
||||||
current_block = 11487273724841241105;
|
ok_to_continue = false;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
processed_files_cnt += 1;
|
processed_files_cnt += 1;
|
||||||
@@ -850,7 +848,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
|||||||
&curr_pathNfilename,
|
&curr_pathNfilename,
|
||||||
);
|
);
|
||||||
/* this is not recoverable! writing to the sqlite database should work! */
|
/* this is not recoverable! writing to the sqlite database should work! */
|
||||||
current_block = 11487273724841241105;
|
ok_to_continue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -862,43 +860,39 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap();
|
||||||
} else {
|
|
||||||
error!(
|
|
||||||
context,
|
|
||||||
0,
|
|
||||||
"Backup: Cannot copy from blob-directory \"{}\".",
|
|
||||||
as_str(context.get_blobdir()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
info!(context, 0, "Backup: No files to copy.",);
|
error!(
|
||||||
current_block = 2631791190359682872;
|
context,
|
||||||
}
|
0,
|
||||||
match current_block {
|
"Backup: Cannot copy from blob-directory \"{}\".",
|
||||||
11487273724841241105 => {}
|
as_str(context.get_blobdir()),
|
||||||
_ => {
|
);
|
||||||
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 {
|
} else {
|
||||||
error!(
|
info!(context, 0, "Backup: No files to copy.",);
|
||||||
context,
|
ok_to_continue = true;
|
||||||
0,
|
}
|
||||||
"Backup: Cannot get info for blob-directory \"{}\".",
|
if ok_to_continue {
|
||||||
as_str(context.get_blobdir())
|
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::constants::*;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::context::{dc_get_version_str, Context};
|
use crate::context::{dc_get_version_str, Context};
|
||||||
use crate::dc_e2ee::*;
|
|
||||||
use crate::dc_strencode::*;
|
use crate::dc_strencode::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::e2ee::*;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::location;
|
use crate::location;
|
||||||
use crate::message::*;
|
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 force_plaintext: libc::c_int = 0;
|
||||||
let mut do_gossip: libc::c_int = 0;
|
let mut do_gossip: libc::c_int = 0;
|
||||||
let mut grpimage = None;
|
let mut grpimage = None;
|
||||||
let mut e2ee_helper = dc_e2ee_helper_t {
|
let mut e2ee_helper = E2eeHelper::default();
|
||||||
encryption_successfull: 0,
|
|
||||||
cdata_to_free: ptr::null_mut(),
|
|
||||||
encrypted: 0,
|
|
||||||
signatures: Default::default(),
|
|
||||||
gossipped_addr: Default::default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if factory.loaded as libc::c_uint == DC_MF_NOTHING_LOADED as libc::c_int as libc::c_uint
|
if factory.loaded as libc::c_uint == DC_MF_NOTHING_LOADED as libc::c_int as libc::c_uint
|
||||||
|| !factory.out.is_null()
|
|| !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 {
|
if force_plaintext != 2 {
|
||||||
dc_e2ee_encrypt(
|
e2ee_helper.encrypt(
|
||||||
factory.context,
|
factory.context,
|
||||||
factory.recipients_addr,
|
factory.recipients_addr,
|
||||||
force_plaintext,
|
force_plaintext,
|
||||||
@@ -1041,10 +1035,9 @@ pub unsafe fn dc_mimefactory_render(factory: &mut dc_mimefactory_t) -> libc::c_i
|
|||||||
min_verified,
|
min_verified,
|
||||||
do_gossip,
|
do_gossip,
|
||||||
message,
|
message,
|
||||||
&mut e2ee_helper,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if 0 != e2ee_helper.encryption_successfull {
|
if e2ee_helper.encryption_successfull {
|
||||||
factory.out_encrypted = 1;
|
factory.out_encrypted = 1;
|
||||||
if 0 != do_gossip {
|
if 0 != do_gossip {
|
||||||
factory.out_gossiped = 1
|
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);
|
factory.out = mmap_string_new(b"\x00" as *const u8 as *const libc::c_char);
|
||||||
mailmime_write_mem(factory.out, &mut col, message);
|
mailmime_write_mem(factory.out, &mut col, message);
|
||||||
success = 1
|
success = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !message.is_null() {
|
if !message.is_null() {
|
||||||
mailmime_free(message);
|
mailmime_free(message);
|
||||||
}
|
}
|
||||||
dc_e2ee_thanks(&mut e2ee_helper);
|
e2ee_helper.thanks();
|
||||||
free(message_text as *mut libc::c_void);
|
free(message_text as *mut libc::c_void);
|
||||||
free(message_text2 as *mut libc::c_void);
|
free(message_text2 as *mut libc::c_void);
|
||||||
free(subject_str 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::constants::Viewtype;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_e2ee::*;
|
|
||||||
use crate::dc_simplify::*;
|
use crate::dc_simplify::*;
|
||||||
use crate::dc_strencode::*;
|
use crate::dc_strencode::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::e2ee::*;
|
||||||
use crate::location;
|
use crate::location;
|
||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
@@ -43,7 +43,6 @@ pub struct dc_mimepart_t {
|
|||||||
/* *
|
/* *
|
||||||
* @class dc_mimeparser_t
|
* @class dc_mimeparser_t
|
||||||
*/
|
*/
|
||||||
#[derive(Clone)]
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct dc_mimeparser_t<'a> {
|
pub struct dc_mimeparser_t<'a> {
|
||||||
pub parts: Vec<dc_mimepart_t>,
|
pub parts: Vec<dc_mimepart_t>,
|
||||||
@@ -54,7 +53,7 @@ pub struct dc_mimeparser_t<'a> {
|
|||||||
pub subject: *mut libc::c_char,
|
pub subject: *mut libc::c_char,
|
||||||
pub is_send_by_messenger: bool,
|
pub is_send_by_messenger: bool,
|
||||||
pub decrypting_failed: libc::c_int,
|
pub decrypting_failed: libc::c_int,
|
||||||
pub e2ee_helper: dc_e2ee_helper_t,
|
pub e2ee_helper: E2eeHelper,
|
||||||
pub is_forwarded: libc::c_int,
|
pub is_forwarded: libc::c_int,
|
||||||
pub context: &'a Context,
|
pub context: &'a Context,
|
||||||
pub reports: Vec<*mut mailmime>,
|
pub reports: Vec<*mut mailmime>,
|
||||||
@@ -109,7 +108,7 @@ unsafe fn dc_mimeparser_empty(mimeparser: &mut dc_mimeparser_t) {
|
|||||||
mimeparser.is_forwarded = 0i32;
|
mimeparser.is_forwarded = 0i32;
|
||||||
mimeparser.reports.clear();
|
mimeparser.reports.clear();
|
||||||
mimeparser.decrypting_failed = 0i32;
|
mimeparser.decrypting_failed = 0i32;
|
||||||
dc_e2ee_thanks(&mut mimeparser.e2ee_helper);
|
mimeparser.e2ee_helper.thanks();
|
||||||
|
|
||||||
mimeparser.location_kml = None;
|
mimeparser.location_kml = None;
|
||||||
mimeparser.message_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,
|
&mut mimeparser.mimeroot,
|
||||||
);
|
);
|
||||||
if r == MAILIMF_NO_ERROR as libc::c_int && !mimeparser.mimeroot.is_null() {
|
if r == MAILIMF_NO_ERROR as libc::c_int && !mimeparser.mimeroot.is_null() {
|
||||||
dc_e2ee_decrypt(
|
mimeparser
|
||||||
mimeparser.context,
|
.e2ee_helper
|
||||||
mimeparser.mimeroot,
|
.decrypt(mimeparser.context, mimeparser.mimeroot);
|
||||||
&mut mimeparser.e2ee_helper,
|
|
||||||
);
|
|
||||||
let mimeparser_ref = &mut mimeparser;
|
let mimeparser_ref = &mut mimeparser;
|
||||||
dc_mimeparser_parse_mime_recursive(mimeparser_ref, mimeparser_ref.mimeroot);
|
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 {
|
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)
|
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) {
|
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);
|
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);
|
part.param.set_int(Param::ErroneousE2ee, 0x2);
|
||||||
}
|
}
|
||||||
parser.parts.push(part);
|
parser.parts.push(part);
|
||||||
@@ -1818,19 +1815,22 @@ mod tests {
|
|||||||
let mut mimeparser = dc_mimeparser_parse(&context.ctx, &raw[..]);
|
let mut mimeparser = dc_mimeparser_parse(&context.ctx, &raw[..]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
as_str(mimeparser.subject as *const libc::c_char),
|
&to_string(mimeparser.subject as *const libc::c_char),
|
||||||
"inner-subject",
|
"inner-subject",
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut of: *mut mailimf_optional_field =
|
let mut of: *mut mailimf_optional_field =
|
||||||
dc_mimeparser_lookup_optional_field(&mimeparser, "X-Special-A");
|
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");
|
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");
|
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);
|
assert_eq!(mimeparser.parts.len(), 1);
|
||||||
|
|
||||||
dc_mimeparser_unref(&mut mimeparser);
|
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::chat::{self, Chat};
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::context::Context;
|
use crate::context::{do_heuristics_moves, Context};
|
||||||
use crate::dc_mimeparser::*;
|
use crate::dc_mimeparser::*;
|
||||||
use crate::dc_move::*;
|
|
||||||
use crate::dc_securejoin::*;
|
use crate::dc_securejoin::*;
|
||||||
use crate::dc_strencode::*;
|
use crate::dc_strencode::*;
|
||||||
use crate::dc_tools::*;
|
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);
|
cleanup(mime_in_reply_to, mime_references, txt_raw);
|
||||||
|
|
||||||
Ok(())
|
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());
|
verify_fail("This message is not encrypted".into());
|
||||||
return 0;
|
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 {
|
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;
|
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 !fld_in_reply_to.is_null() {
|
||||||
if 0 != is_known_rfc724_mid_in_list(
|
if is_known_rfc724_mid_in_list(context, (*(*field).fld_data.fld_in_reply_to).mid_list) {
|
||||||
context,
|
|
||||||
(*(*field).fld_data.fld_in_reply_to).mid_list,
|
|
||||||
) {
|
|
||||||
return 1;
|
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 {
|
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;
|
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||||
if !fld_references.is_null() {
|
if !fld_references.is_null() {
|
||||||
if 0 != is_known_rfc724_mid_in_list(
|
if is_known_rfc724_mid_in_list(context, (*(*field).fld_data.fld_references).mid_list) {
|
||||||
context,
|
|
||||||
(*(*field).fld_data.fld_references).mid_list,
|
|
||||||
) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1898,29 +1891,18 @@ unsafe fn dc_is_reply_to_known_message(
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> libc::c_int {
|
unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist) -> bool {
|
||||||
if !mid_list.is_null() {
|
if mid_list.is_null() {
|
||||||
let mut cur: *mut clistiter;
|
return false;
|
||||||
cur = (*mid_list).first;
|
}
|
||||||
while !cur.is_null() {
|
|
||||||
if 0 != is_known_rfc724_mid(
|
for data in &*mid_list {
|
||||||
context,
|
if 0 != is_known_rfc724_mid(context, data.cast()) {
|
||||||
(if !cur.is_null() {
|
return true;
|
||||||
(*cur).data
|
|
||||||
} else {
|
|
||||||
ptr::null_mut()
|
|
||||||
}) as *const libc::c_char,
|
|
||||||
) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
cur = if !cur.is_null() {
|
|
||||||
(*cur).next
|
|
||||||
} else {
|
|
||||||
ptr::null_mut()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a message is a reply to a known message (messenger or non-messenger).
|
/// 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::constants::*;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_e2ee::*;
|
|
||||||
use crate::dc_mimeparser::*;
|
use crate::dc_mimeparser::*;
|
||||||
use crate::dc_token::*;
|
use crate::dc_token::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::e2ee::*;
|
||||||
use crate::key::*;
|
use crate::key::*;
|
||||||
use crate::lot::LotState;
|
use crate::lot::LotState;
|
||||||
use crate::message::*;
|
use crate::message::*;
|
||||||
@@ -43,21 +43,25 @@ pub unsafe fn dc_get_securejoin_qr(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut fingerprint = ptr::null_mut();
|
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;
|
let mut qr: Option<String> = None;
|
||||||
|
|
||||||
dc_ensure_secret_key_exists(context).ok();
|
ensure_secret_key_exists(context).ok();
|
||||||
invitenumber = dc_token_lookup(context, DC_TOKEN_INVITENUMBER, group_chat_id);
|
let invitenumber = dc_token_lookup(context, DC_TOKEN_INVITENUMBER, group_chat_id)
|
||||||
if invitenumber.is_null() {
|
.unwrap_or_else(|| {
|
||||||
invitenumber = dc_create_id().strdup();
|
let invitenumber_s = dc_create_id();
|
||||||
dc_token_save(context, DC_TOKEN_INVITENUMBER, group_chat_id, invitenumber);
|
dc_token_save(
|
||||||
}
|
context,
|
||||||
auth = dc_token_lookup(context, DC_TOKEN_AUTH, group_chat_id);
|
DC_TOKEN_INVITENUMBER,
|
||||||
if auth.is_null() {
|
group_chat_id,
|
||||||
auth = dc_create_id().strdup();
|
&invitenumber_s,
|
||||||
dc_token_save(context, DC_TOKEN_AUTH, group_chat_id, auth);
|
);
|
||||||
}
|
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 self_addr = context.sql.get_config(context, "configured_addr");
|
||||||
|
|
||||||
if self_addr.is_none() {
|
if self_addr.is_none() {
|
||||||
@@ -92,8 +96,8 @@ pub unsafe fn dc_get_securejoin_qr(
|
|||||||
self_addr_urlencoded,
|
self_addr_urlencoded,
|
||||||
&group_name_urlencoded,
|
&group_name_urlencoded,
|
||||||
&chat.grpid,
|
&chat.grpid,
|
||||||
as_str(invitenumber),
|
&invitenumber,
|
||||||
as_str(auth),
|
&auth,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
@@ -108,8 +112,8 @@ pub unsafe fn dc_get_securejoin_qr(
|
|||||||
as_str(fingerprint),
|
as_str(fingerprint),
|
||||||
self_addr_urlencoded,
|
self_addr_urlencoded,
|
||||||
self_name_urlencoded,
|
self_name_urlencoded,
|
||||||
as_str(invitenumber),
|
&invitenumber,
|
||||||
as_str(auth),
|
&auth,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,7 +143,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
|
|||||||
let mut join_vg: libc::c_int = 0i32;
|
let mut join_vg: libc::c_int = 0i32;
|
||||||
|
|
||||||
info!(context, 0, "Requesting secure-join ...",);
|
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);
|
ongoing_allocated = dc_alloc_ongoing(context);
|
||||||
|
|
||||||
if !(ongoing_allocated == 0i32) {
|
if !(ongoing_allocated == 0i32) {
|
||||||
@@ -368,7 +372,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
mimeparser: &dc_mimeparser_t,
|
mimeparser: &dc_mimeparser_t,
|
||||||
contact_id: uint32_t,
|
contact_id: uint32_t,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
let mut current_block: u64;
|
let mut ok_to_continue: bool;
|
||||||
let step: *const libc::c_char;
|
let step: *const libc::c_char;
|
||||||
let join_vg: libc::c_int;
|
let join_vg: libc::c_int;
|
||||||
let mut own_fingerprint: *mut libc::c_char = ptr::null_mut();
|
let mut own_fingerprint: *mut libc::c_char = ptr::null_mut();
|
||||||
@@ -412,10 +416,10 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
invitenumber = lookup_field(mimeparser, "Secure-Join-Invitenumber");
|
invitenumber = lookup_field(mimeparser, "Secure-Join-Invitenumber");
|
||||||
if invitenumber.is_null() {
|
if invitenumber.is_null() {
|
||||||
warn!(context, 0, "Secure-join denied (invitenumber missing).",);
|
warn!(context, 0, "Secure-join denied (invitenumber missing).",);
|
||||||
current_block = 4378276786830486580;
|
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).",);
|
warn!(context, 0, "Secure-join denied (bad invitenumber).",);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
info!(context, 0, "Secure-join requested.",);
|
info!(context, 0, "Secure-join requested.",);
|
||||||
|
|
||||||
@@ -436,7 +440,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
ptr::null(),
|
ptr::null(),
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
current_block = 10256747982273457880;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
} else if strcmp(
|
} else if strcmp(
|
||||||
step,
|
step,
|
||||||
@@ -458,7 +462,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
if cond {
|
if cond {
|
||||||
warn!(context, 0, "auth-required message out of sync.",);
|
warn!(context, 0, "auth-required message out of sync.",);
|
||||||
// no error, just aborted somehow or a mail from another handshake
|
// no error, just aborted somehow or a mail from another handshake
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
let scanned_fingerprint_of_alice = context
|
let scanned_fingerprint_of_alice = context
|
||||||
.bob
|
.bob
|
||||||
@@ -501,14 +505,14 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
could_not_establish_secure_connection(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
contact_chat_id,
|
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
|
b"No valid signature.\x00" as *const u8 as *const libc::c_char
|
||||||
} else {
|
} else {
|
||||||
b"Not encrypted.\x00" as *const u8 as *const libc::c_char
|
b"Not encrypted.\x00" as *const u8 as *const libc::c_char
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
end_bobs_joining(context, 0i32);
|
end_bobs_joining(context, 0i32);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else if 0
|
} else if 0
|
||||||
== fingerprint_equals_sender(
|
== fingerprint_equals_sender(
|
||||||
context,
|
context,
|
||||||
@@ -523,7 +527,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
end_bobs_joining(context, 0i32);
|
end_bobs_joining(context, 0i32);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
info!(context, 0, "Fingerprint verified.",);
|
info!(context, 0, "Fingerprint verified.",);
|
||||||
own_fingerprint = get_self_fingerprint(context);
|
own_fingerprint = get_self_fingerprint(context);
|
||||||
@@ -546,7 +550,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
own_fingerprint,
|
own_fingerprint,
|
||||||
grpid,
|
grpid,
|
||||||
);
|
);
|
||||||
current_block = 10256747982273457880;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if strcmp(
|
} else if strcmp(
|
||||||
@@ -571,14 +575,14 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
contact_chat_id,
|
contact_chat_id,
|
||||||
b"Fingerprint not provided.\x00" as *const u8 as *const libc::c_char,
|
b"Fingerprint not provided.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else if !encrypted_and_signed(mimeparser, as_str(fingerprint)) {
|
} else if !encrypted_and_signed(mimeparser, as_str(fingerprint)) {
|
||||||
could_not_establish_secure_connection(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
contact_chat_id,
|
contact_chat_id,
|
||||||
b"Auth not encrypted.\x00" as *const u8 as *const libc::c_char,
|
b"Auth not encrypted.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else if 0
|
} else if 0
|
||||||
== fingerprint_equals_sender(context, as_str(fingerprint), contact_chat_id)
|
== fingerprint_equals_sender(context, as_str(fingerprint), contact_chat_id)
|
||||||
{
|
{
|
||||||
@@ -588,7 +592,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
b"Fingerprint mismatch on inviter-side.\x00" as *const u8
|
b"Fingerprint mismatch on inviter-side.\x00" as *const u8
|
||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
info!(context, 0, "Fingerprint verified.",);
|
info!(context, 0, "Fingerprint verified.",);
|
||||||
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
|
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
|
||||||
@@ -600,14 +604,14 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
contact_chat_id,
|
contact_chat_id,
|
||||||
b"Auth not provided.\x00" as *const u8 as *const libc::c_char,
|
b"Auth not provided.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
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(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
contact_chat_id,
|
contact_chat_id,
|
||||||
b"Auth invalid.\x00" as *const u8 as *const libc::c_char,
|
b"Auth invalid.\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else if 0 == mark_peer_as_verified(context, as_str(fingerprint)) {
|
} else if 0 == mark_peer_as_verified(context, as_str(fingerprint)) {
|
||||||
could_not_establish_secure_connection(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
@@ -615,7 +619,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
b"Fingerprint mismatch on inviter-side.\x00" as *const u8
|
b"Fingerprint mismatch on inviter-side.\x00" as *const u8
|
||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
Contact::scaleup_origin_by_id(
|
Contact::scaleup_origin_by_id(
|
||||||
context,
|
context,
|
||||||
@@ -640,7 +644,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
chat::get_chat_id_by_grpid(context, &grpid, None, ptr::null_mut());
|
chat::get_chat_id_by_grpid(context, &grpid, None, ptr::null_mut());
|
||||||
if group_chat_id == 0i32 as libc::c_uint {
|
if group_chat_id == 0i32 as libc::c_uint {
|
||||||
error!(context, 0, "Chat {} not found.", &grpid);
|
error!(context, 0, "Chat {} not found.", &grpid);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
chat::add_contact_to_chat_ex(
|
chat::add_contact_to_chat_ex(
|
||||||
context,
|
context,
|
||||||
@@ -648,7 +652,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
contact_id,
|
contact_id,
|
||||||
0x1i32,
|
0x1i32,
|
||||||
);
|
);
|
||||||
current_block = 10256747982273457880;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
send_handshake_msg(
|
send_handshake_msg(
|
||||||
@@ -664,7 +668,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
1000i32 as uintptr_t,
|
1000i32 as uintptr_t,
|
||||||
);
|
);
|
||||||
current_block = 10256747982273457880;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -682,7 +686,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
}
|
}
|
||||||
if context.bob.read().unwrap().expects != 6 {
|
if context.bob.read().unwrap().expects != 6 {
|
||||||
info!(context, 0, "Message belongs to a different handshake.",);
|
info!(context, 0, "Message belongs to a different handshake.",);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
let cond = {
|
let cond = {
|
||||||
let bob = context.bob.read().unwrap();
|
let bob = context.bob.read().unwrap();
|
||||||
@@ -695,7 +699,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
context,
|
context,
|
||||||
0, "Message out of sync or belongs to a different handshake.",
|
0, "Message out of sync or belongs to a different handshake.",
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
let scanned_fingerprint_of_alice = context
|
let scanned_fingerprint_of_alice = context
|
||||||
.bob
|
.bob
|
||||||
@@ -745,78 +749,66 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
as *const libc::c_char,
|
as *const libc::c_char,
|
||||||
);
|
);
|
||||||
end_bobs_joining(context, 0i32);
|
end_bobs_joining(context, 0i32);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
current_block = 5195798230510548452;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
current_block = 5195798230510548452;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
match current_block {
|
if ok_to_continue {
|
||||||
4378276786830486580 => {}
|
if 0 == mark_peer_as_verified(context, &scanned_fingerprint_of_alice) {
|
||||||
_ => {
|
could_not_establish_secure_connection(
|
||||||
if 0 == mark_peer_as_verified(
|
|
||||||
context,
|
context,
|
||||||
&scanned_fingerprint_of_alice,
|
contact_chat_id,
|
||||||
) {
|
b"Fingerprint mismatch on joiner-side.\x00" as *const u8
|
||||||
could_not_establish_secure_connection(
|
as *const libc::c_char,
|
||||||
|
);
|
||||||
|
ok_to_continue = false;
|
||||||
|
} else {
|
||||||
|
Contact::scaleup_origin_by_id(
|
||||||
|
context,
|
||||||
|
contact_id,
|
||||||
|
Origin::SecurejoinJoined,
|
||||||
|
);
|
||||||
|
context.call_cb(
|
||||||
|
Event::CONTACTS_CHANGED,
|
||||||
|
0i32 as uintptr_t,
|
||||||
|
0i32 as uintptr_t,
|
||||||
|
);
|
||||||
|
if 0 != join_vg {
|
||||||
|
if !addr_equals_self(
|
||||||
context,
|
context,
|
||||||
contact_chat_id,
|
as_str(lookup_field(mimeparser, "Chat-Group-Member-Added")),
|
||||||
b"Fingerprint mismatch on joiner-side.\x00" as *const u8
|
) {
|
||||||
as *const libc::c_char,
|
info!(
|
||||||
);
|
|
||||||
current_block = 4378276786830486580;
|
|
||||||
} else {
|
|
||||||
Contact::scaleup_origin_by_id(
|
|
||||||
context,
|
|
||||||
contact_id,
|
|
||||||
Origin::SecurejoinJoined,
|
|
||||||
);
|
|
||||||
context.call_cb(
|
|
||||||
Event::CONTACTS_CHANGED,
|
|
||||||
0i32 as uintptr_t,
|
|
||||||
0i32 as uintptr_t,
|
|
||||||
);
|
|
||||||
if 0 != join_vg {
|
|
||||||
if !addr_equals_self(
|
|
||||||
context,
|
|
||||||
as_str(lookup_field(
|
|
||||||
mimeparser,
|
|
||||||
"Chat-Group-Member-Added",
|
|
||||||
)),
|
|
||||||
) {
|
|
||||||
info!(
|
|
||||||
context,
|
context,
|
||||||
0,
|
0,
|
||||||
"Message belongs to a different handshake (scaled up contact anyway to allow creation of group)."
|
"Message belongs to a different handshake (scaled up contact anyway to allow creation of group)."
|
||||||
);
|
);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
|
||||||
current_block = 9180031981464905198;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
current_block = 9180031981464905198;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
match current_block {
|
} else {
|
||||||
4378276786830486580 => {}
|
ok_to_continue = true;
|
||||||
_ => {
|
}
|
||||||
secure_connection_established(context, contact_chat_id);
|
if ok_to_continue {
|
||||||
context.bob.write().unwrap().expects = 0;
|
secure_connection_established(context, contact_chat_id);
|
||||||
if 0 != join_vg {
|
context.bob.write().unwrap().expects = 0;
|
||||||
send_handshake_msg(
|
if 0 != join_vg {
|
||||||
context,
|
send_handshake_msg(
|
||||||
contact_chat_id,
|
context,
|
||||||
b"vg-member-added-received\x00" as *const u8
|
contact_chat_id,
|
||||||
as *const libc::c_char,
|
b"vg-member-added-received\x00" as *const u8
|
||||||
"",
|
as *const libc::c_char,
|
||||||
ptr::null(),
|
"",
|
||||||
"",
|
ptr::null(),
|
||||||
);
|
"",
|
||||||
}
|
);
|
||||||
end_bobs_joining(context, 1i32);
|
|
||||||
current_block = 10256747982273457880;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
end_bobs_joining(context, 1i32);
|
||||||
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -834,7 +826,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
if let Ok(contact) = Contact::get_by_id(context, contact_id) {
|
if let Ok(contact) = Contact::get_by_id(context, contact_id) {
|
||||||
if contact.is_verified() == VerifiedStatus::Unverified {
|
if contact.is_verified() == VerifiedStatus::Unverified {
|
||||||
warn!(context, 0, "vg-member-added-received invalid.",);
|
warn!(context, 0, "vg-member-added-received invalid.",);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
context.call_cb(
|
context.call_cb(
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
@@ -846,21 +838,18 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
1000i32 as uintptr_t,
|
1000i32 as uintptr_t,
|
||||||
);
|
);
|
||||||
current_block = 10256747982273457880;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!(context, 0, "vg-member-added-received invalid.",);
|
warn!(context, 0, "vg-member-added-received invalid.",);
|
||||||
current_block = 4378276786830486580;
|
ok_to_continue = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
current_block = 10256747982273457880;
|
ok_to_continue = true;
|
||||||
}
|
}
|
||||||
match current_block {
|
if ok_to_continue {
|
||||||
4378276786830486580 => {}
|
if 0 != ret & 0x2i32 {
|
||||||
_ => {
|
ret |= 0x4i32
|
||||||
if 0 != ret & 0x2i32 {
|
|
||||||
ret |= 0x4i32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -955,7 +944,7 @@ unsafe fn encrypted_and_signed(
|
|||||||
mimeparser: &dc_mimeparser_t,
|
mimeparser: &dc_mimeparser_t,
|
||||||
expected_fingerprint: impl AsRef<str>,
|
expected_fingerprint: impl AsRef<str>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if 0 == mimeparser.e2ee_helper.encrypted {
|
if !mimeparser.e2ee_helper.encrypted {
|
||||||
warn!(mimeparser.context, 0, "Message not encrypted.",);
|
warn!(mimeparser.context, 0, "Message not encrypted.",);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,17 +14,14 @@ pub fn dc_token_save(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
namespc: dc_tokennamespc_t,
|
namespc: dc_tokennamespc_t,
|
||||||
foreign_id: u32,
|
foreign_id: u32,
|
||||||
token: *const libc::c_char,
|
token: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if token.is_null() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// foreign_id may be 0
|
// foreign_id may be 0
|
||||||
sql::execute(
|
sql::execute(
|
||||||
context,
|
context,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
"INSERT INTO tokens (namespc, foreign_id, token, timestamp) VALUES (?, ?, ?, ?);",
|
"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()
|
.is_ok()
|
||||||
}
|
}
|
||||||
@@ -33,33 +30,21 @@ pub fn dc_token_lookup(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
namespc: dc_tokennamespc_t,
|
namespc: dc_tokennamespc_t,
|
||||||
foreign_id: u32,
|
foreign_id: u32,
|
||||||
) -> *mut libc::c_char {
|
) -> Option<String> {
|
||||||
context
|
context.sql.query_row_col::<_, String>(
|
||||||
.sql
|
context,
|
||||||
.query_row_col::<_, String>(
|
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
||||||
context,
|
params![namespc as i32, foreign_id as i32],
|
||||||
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
0,
|
||||||
params![namespc as i32, foreign_id as i32],
|
)
|
||||||
0,
|
|
||||||
)
|
|
||||||
.map(|s| unsafe { s.strdup() })
|
|
||||||
.unwrap_or_else(|| std::ptr::null_mut())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_token_exists(
|
pub fn dc_token_exists(context: &Context, namespc: dc_tokennamespc_t, token: &str) -> bool {
|
||||||
context: &Context,
|
|
||||||
namespc: dc_tokennamespc_t,
|
|
||||||
token: *const libc::c_char,
|
|
||||||
) -> bool {
|
|
||||||
if token.is_null() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.exists(
|
.exists(
|
||||||
"SELECT id FROM tokens WHERE namespc=? AND token=?;",
|
"SELECT id FROM tokens WHERE namespc=? AND token=?;",
|
||||||
params![namespc as i32, as_str(token)],
|
params![namespc as i32, token],
|
||||||
)
|
)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,7 @@ pub mod configure;
|
|||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod contact;
|
pub mod contact;
|
||||||
pub mod context;
|
pub mod context;
|
||||||
|
mod e2ee;
|
||||||
mod imap;
|
mod imap;
|
||||||
pub mod job;
|
pub mod job;
|
||||||
mod job_thread;
|
mod job_thread;
|
||||||
@@ -51,12 +52,10 @@ pub mod x;
|
|||||||
|
|
||||||
pub mod dc_array;
|
pub mod dc_array;
|
||||||
mod dc_dehtml;
|
mod dc_dehtml;
|
||||||
mod dc_e2ee;
|
|
||||||
pub mod dc_imex;
|
pub mod dc_imex;
|
||||||
mod dc_loginparam;
|
mod dc_loginparam;
|
||||||
mod dc_mimefactory;
|
mod dc_mimefactory;
|
||||||
pub mod dc_mimeparser;
|
pub mod dc_mimeparser;
|
||||||
mod dc_move;
|
|
||||||
pub mod dc_receive_imf;
|
pub mod dc_receive_imf;
|
||||||
pub mod dc_securejoin;
|
pub mod dc_securejoin;
|
||||||
mod dc_simplify;
|
mod dc_simplify;
|
||||||
|
|||||||
Reference in New Issue
Block a user