Compare commits

..

18 Commits

Author SHA1 Message Date
holger krekel
b83316bd4d try write a test for unshown messages 2019-07-22 15:52:27 +02:00
holger krekel
6f79800824 fix last two warnings 2019-07-22 11:45:41 +02:00
holger krekel
7a19963879 properly fix the QueryReturnedNoRows warning and rustfmt 2019-07-22 11:18:30 +02:00
holger krekel
cd7630360f fix fmt 2019-07-22 02:33:08 +02:00
holger krekel
4a633169e1 Merge branch 'master' into flub-nowarn 2019-07-22 01:40:56 +02:00
Floris Bruynooghe
ea8d6e8ff0 Write a deltachat.pc file at build time
This is writes pkg-config/deltachat.pc file in the target directory,
using the PREFIX environment variable at build time.  If this is
undefined at build time /usr/local is used.
2019-07-22 01:16:34 +02:00
holger krekel
065124b93b Merge branch 'master' into flub-param-names 2019-07-22 01:11:47 +02:00
holger krekel
86d290832b Merge branch 'master' into flub-py-glue-fixes 2019-07-22 01:09:58 +02:00
Alexander Krotov
56f8717a40 Show AutocryptSetupMessage independently of show-emails settings
Fixes #161
2019-07-22 00:45:17 +02:00
Alexander Krotov
4a0b2e68c8 Add DC_CMD_* constants 2019-07-22 00:45:17 +02:00
holger krekel
2576b78126 Merge branch 'master' into flub-py-glue-fixes 2019-07-22 00:39:47 +02:00
holger krekel
6a956b6008 Merge branch 'master' into flub-param-names 2019-07-22 00:36:52 +02:00
Alexander Krotov
33575e7aa3 dc_get_abs_path cleanup 2019-07-21 23:40:29 +02:00
holger krekel
8089559958 Squashed commit of the following:
commit 6bc5d1b90e
Author: holger krekel <holger@merlinux.eu>
Date:   Sun Jul 21 22:56:37 2019 +0200

    fix fmt

commit 197d94ad9d
Merge: 7ce337c 686678c
Author: holger krekel <holger@merlinux.eu>
Date:   Sun Jul 21 22:51:16 2019 +0200

    Merge remote-tracking branch 'origin/master' into eventlogging

commit 7ce337c6d0
Author: holger krekel <holger@merlinux.eu>
Date:   Sun Jul 21 22:44:27 2019 +0200

    left-over error logging

commit 10148d2e43
Author: holger krekel <holger@merlinux.eu>
Date:   Sun Jul 21 22:03:17 2019 +0200

    ignore non-utf8 parts of header fields (add comment why it shouldn't happen)
    don't throw error if no sql rows are returned

commit 69dc237ee3
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Sun Jul 21 12:56:04 2019 +0200

    fix(receive_imf): remove recursive sql call

commit df5464ea80
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Sat Jul 20 17:05:24 2019 +0200

    fix: blocked is an optional value

commit e4bf9956a5
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Sat Jul 20 16:50:56 2019 +0200

    fix(msg): handle optional in_reply_to

commit d353d9d9d8
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Sat Jul 20 16:17:25 2019 +0200

    fix(chat): remove recursive sql usage

commit 1ad45ed4d6
Author: holger krekel <holger@merlinux.eu>
Date:   Sat Jul 20 15:14:11 2019 +0200

    fix rust fmt

commit 496e980a17
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Sat Jul 20 14:34:20 2019 +0200

    use forked rusqlite

commit fa09e46ed9
Author: holger krekel <holger@merlinux.eu>
Date:   Sat Jul 20 12:37:51 2019 +0200

    another pace where we might (and in my case did) get invalid utf8

commit d6de420b9a
Author: holger krekel <holger@merlinux.eu>
Date:   Sat Jul 20 12:30:48 2019 +0200

    fix some string issues, introduce to_string_lossy such that to_string() continues to panic on non-utf8

commit 38eb708db8
Author: holger krekel <holger@merlinux.eu>
Date:   Sat Jul 20 01:17:53 2019 +0200

    for now make to_string() less strict as we often don't want to crash the whole app just because some non-proper utf8 came in (through a message we can't neccesarily congtrol)

commit 7a59da5f8f
Author: holger krekel <holger@merlinux.eu>
Date:   Fri Jul 19 22:48:39 2019 +0200

    fix linting

commit f13a1d4a2f
Author: holger krekel <holger@merlinux.eu>
Date:   Fri Jul 19 22:46:58 2019 +0200

    fix some test flakyness

commit 7b3a450918
Author: holger krekel <holger@merlinux.eu>
Date:   Fri Jul 19 22:35:07 2019 +0200

    - fix saved_mime test which broke to improper conversion of
      imf_raw_not_terminated
    - some cargo.toml updates no clue where they come from
    - log Message-ID for received messages

commit 169923b102
Author: holger krekel <holger@merlinux.eu>
Date:   Fri Jul 19 12:31:22 2019 +0200

    formatting

commit 42688a0622
Author: holger krekel <holger@merlinux.eu>
Date:   Fri Jul 19 12:24:56 2019 +0200

    remove some print statements

commit 35f3c0edd1
Merge: e7a2362 f58b1d6
Author: holger krekel <holger@merlinux.eu>
Date:   Fri Jul 19 10:25:21 2019 +0200

    Merge branch 'master' into eventlogging

commit e7a236264a
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 23:20:20 2019 +0200

    print invalid strings

commit aaa5b820d9
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 23:12:35 2019 +0200

    cleanup

commit e7f0745010
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 23:03:57 2019 +0200

    reduce direc usage of CString

commit c68e7ae14e
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 22:47:47 2019 +0200

    audit use of to_cstring and fix ub

commit 618087e5a7
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 21:38:52 2019 +0200

    fix(imap): body ptr lifetime

commit 245abb8384
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 19:44:10 2019 +0200

    remove debug

commit a3e1042001
Author: dignifiedquire <dignifiedquire@users.noreply.github.com>
Date:   Thu Jul 18 18:30:54 2019 +0200

    fix some things, add more debugging statements

commit 7b7ce9348f
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 15:11:57 2019 +0200

    fix python lint issues

commit 7a4808ba0d
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 14:35:54 2019 +0200

    cargofmt

commit 8f240f7153
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 14:03:57 2019 +0200

    (dig,hpk) pull out job collection from sql query/lock logic

commit 7d0b5d8abb
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 12:52:02 2019 +0200

    remove print statements and fix a crash

commit ee317cb1b5
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 11:38:10 2019 +0200

    fix some merge issues

commit 7b736fe635
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 11:16:38 2019 +0200

    (dig,hpk) add test and fix for wrong dbs

commit c7db15352a
Merge: 0b37167 0c5015d
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 09:59:44 2019 +0200

    Merge branch 'master' into eventlogging

commit 0b37167be8
Author: holger krekel <holger@merlinux.eu>
Date:   Thu Jul 18 00:06:05 2019 +0200

    address @dignifiedquire comments

commit 5cac4b5076
Author: holger krekel <holger@merlinux.eu>
Date:   Wed Jul 17 12:47:22 2019 +0200

    remove spurious print

commit 475a41beb3
Author: holger krekel <holger@merlinux.eu>
Date:   Wed Jul 17 12:31:12 2019 +0200

    address @dignifiedquire rustyness comment and fix changelog

commit ad4be80b4e
Author: holger krekel <holger@merlinux.eu>
Date:   Wed Jul 17 10:25:25 2019 +0200

    make smtp/imap connect() return bool instead of c-int

commit 8737c1d142
Author: holger krekel <holger@merlinux.eu>
Date:   Wed Jul 17 09:26:33 2019 +0200

    cleanup some parts, add comments

commit 964fe466cc
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 20:05:41 2019 +0200

    wip-commit which passes all tests with proper finalization

commit 43936e7db7
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 16:17:42 2019 +0200

    snapshot of my current debugging state

commit 0e80ce9c39
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 12:57:19 2019 +0200

    more aggressively skip perform API when threads are closing

commit c652bae68a
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 12:06:05 2019 +0200

    intermediate wip commit

commit bc904a495d
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 11:18:56 2019 +0200

    add some logging, and a more precise teardown for online python tests

commit 8d99444c6a
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 00:22:12 2019 +0200

    fix std

commit 9dab53e0af
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 00:20:54 2019 +0200

    rustfmt

commit 360089ac74
Author: holger krekel <holger@merlinux.eu>
Date:   Tue Jul 16 00:03:49 2019 +0200

    remove some debugging

commit e892c5cf4d
Author: holger krekel <holger@merlinux.eu>
Date:   Mon Jul 15 23:31:30 2019 +0200

    fix test for events

commit 9ad4c9a6fe
Author: holger krekel <holger@merlinux.eu>
Date:   Mon Jul 15 22:51:57 2019 +0200

    wip try test that we see INFO events from the core
2019-07-21 23:31:14 +02:00
Floris Bruynooghe
7774052911 Use DC_PARAM_* constants everywhere
Also document each type they store.  This makes existing code a little
more readable and gives some hints towards refactoring this.
2019-07-21 20:25:52 +02:00
Floris Bruynooghe
68888f6d1f Also silence warnings in test code
We can be a bit more liberal with .unwrap() here.
2019-07-21 12:03:04 +02:00
Floris Bruynooghe
31d2bc7401 Silence warnings from ignored Result values
For a few of the locations where error handling is done correctly this
does the right thing.  For most other places it gracefully ignores any
issues which is what the original code did as well.  Errors are
already logged by the called functions in those cases.
2019-07-21 00:32:33 +02:00
Floris Bruynooghe
5ee8f8cb59 Several fixes to the intergration tests
- Pass extra_link_args when using an installed libdeltachat
- Allow setting the liveconfig by envvar
- Show lifeconfig path in the pytest summary line
- Pass required envvars through tox
- Fix broken liveconfig passing in run-integration-test.sh
2019-07-20 23:28:23 +02:00
30 changed files with 621 additions and 347 deletions

12
Cargo.lock generated
View File

@@ -1093,7 +1093,7 @@ dependencies = [
[[package]]
name = "miniz_oxide"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1107,7 +1107,7 @@ dependencies = [
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz_oxide 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1374,7 +1374,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1407,7 +1407,7 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.6.1"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2782,7 +2782,7 @@ dependencies = [
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
"checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425"
"checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed"
"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d"
"checksum miniz_oxide 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5f6d7b3dd914b70db7cef7ab9dc74339ffcadf4d033464a987237bb0b9418cd4"
"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494"
"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"
@@ -2813,7 +2813,7 @@ dependencies = [
"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c"
"checksum parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a7bbaa05312363e0480e1efee133fff1a09ef4a6406b65e226b9a793c223a32"
"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pgp 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb80b37b7debf9a98dc0caca3ed40ddf1d383691208763d0458df0b91521020f"
"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18"

33
deltachat-ffi/build.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::io::Write;
use std::path::PathBuf;
use std::{env, fs};
fn main() {
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let target_path = out_path.join("../../..");
let target_triple = env::var("TARGET").unwrap();
// macOS or iOS, inherited from rpgp
let libs_priv = if target_triple.contains("apple") || target_triple.contains("darwin") {
// needed for OsRng
"-framework Security -framework Foundation"
} else {
""
};
let pkg_config = format!(
include_str!("deltachat.pc.in"),
name = "deltachat",
description = env::var("CARGO_PKG_DESCRIPTION").unwrap(),
url = env::var("CARGO_PKG_HOMEPAGE").unwrap_or("".to_string()),
version = env::var("CARGO_PKG_VERSION").unwrap(),
libs_priv = libs_priv,
prefix = env::var("PREFIX").unwrap_or("/usr/local".to_string()),
);
fs::create_dir_all(target_path.join("pkgconfig")).unwrap();
fs::File::create(target_path.join("pkgconfig").join("deltachat.pc"))
.unwrap()
.write_all(&pkg_config.as_bytes())
.unwrap();
}

View File

@@ -0,0 +1,11 @@
prefix={prefix}
libdir=${{prefix}}/lib
includedir=${{prefix}}/include
Name: {name}
Description: {description}
URL: {url}
Version: {version}
Cflags: -I${{includedir}}
Libs: -L${{libdir}} -ldeltachat
Libs.private: {libs_priv}

View File

@@ -28,7 +28,7 @@ use num_traits::FromPrimitive;
pub unsafe fn dc_reset_tables(context: &Context, bits: i32) -> i32 {
info!(context, 0, "Resetting tables ({})...", bits);
if 0 != bits & 1 {
sql::execute(context, &context.sql, "DELETE FROM jobs;", params![]);
sql::execute(context, &context.sql, "DELETE FROM jobs;", params![]).unwrap();
info!(context, 0, "(1) Jobs reset.");
}
if 0 != bits & 2 {
@@ -37,11 +37,12 @@ pub unsafe fn dc_reset_tables(context: &Context, bits: i32) -> i32 {
&context.sql,
"DELETE FROM acpeerstates;",
params![],
);
)
.unwrap();
info!(context, 0, "(2) Peerstates reset.");
}
if 0 != bits & 4 {
sql::execute(context, &context.sql, "DELETE FROM keypairs;", params![]);
sql::execute(context, &context.sql, "DELETE FROM keypairs;", params![]).unwrap();
info!(context, 0, "(4) Private keypairs reset.");
}
if 0 != bits & 8 {
@@ -50,32 +51,37 @@ pub unsafe fn dc_reset_tables(context: &Context, bits: i32) -> i32 {
&context.sql,
"DELETE FROM contacts WHERE id>9;",
params![],
);
)
.unwrap();
sql::execute(
context,
&context.sql,
"DELETE FROM chats WHERE id>9;",
params![],
);
)
.unwrap();
sql::execute(
context,
&context.sql,
"DELETE FROM chats_contacts;",
params![],
);
)
.unwrap();
sql::execute(
context,
&context.sql,
"DELETE FROM msgs WHERE id>9;",
params![],
);
)
.unwrap();
sql::execute(
context,
&context.sql,
"DELETE FROM config WHERE keyname LIKE 'imap.%' OR keyname LIKE 'configured%';",
params![],
);
sql::execute(context, &context.sql, "DELETE FROM leftgrps;", params![]);
)
.unwrap();
sql::execute(context, &context.sql, "DELETE FROM leftgrps;", params![]).unwrap();
info!(context, 0, "(8) Rest but server config reset.");
}
@@ -129,7 +135,8 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
real_spec = dc_strdup(spec);
context
.sql
.set_config(context, "import_spec", Some(as_str(real_spec)));
.set_config(context, "import_spec", Some(as_str(real_spec)))
.unwrap();
current_block = 7149356873433890176;
} else {
let rs = context.sql.get_config(context, "import_spec");

View File

@@ -86,8 +86,9 @@ fn main() {
let args = std::env::args().collect::<Vec<String>>();
assert_eq!(args.len(), 2, "missing password");
let pw = args[1].clone();
ctx.set_config(config::Config::Addr, Some("d@testrun.org"));
ctx.set_config(config::Config::MailPw, Some(&pw));
ctx.set_config(config::Config::Addr, Some("d@testrun.org"))
.unwrap();
ctx.set_config(config::Config::MailPw, Some(&pw)).unwrap();
dc_configure(&ctx);
thread::sleep(duration);

View File

@@ -31,6 +31,7 @@ def ffibuilder():
libs = ['deltachat']
objs = []
incs = []
extra_link_args = []
builder = cffi.FFI()
builder.set_source(
'deltachat.capi',
@@ -70,8 +71,8 @@ def ffibuilder():
distutils.sysconfig.customize_compiler(cc)
tmpdir = tempfile.mkdtemp()
try:
src_name = os.path.join(tmpdir, "prep.h")
dst_name = os.path.join(tmpdir, "prep2.c")
src_name = os.path.join(tmpdir, "include.h")
dst_name = os.path.join(tmpdir, "expanded.h")
with open(src_name, "w") as src_fp:
src_fp.write('#include <deltachat.h>')
cc.preprocess(source=src_name,

View File

@@ -16,6 +16,14 @@ def pytest_addoption(parser):
)
def pytest_configure(config):
cfg = config.getoption('--liveconfig')
if not cfg:
cfg = os.getenv('DCC_PY_LIVECONFIG')
if cfg:
config.option.liveconfig = cfg
@pytest.hookimpl(trylast=True)
def pytest_runtest_call(item):
# perform early finalization because we otherwise get cloberred
@@ -35,10 +43,14 @@ def pytest_report_header(config, startdir):
ac.shutdown()
finally:
os.remove(t)
return "Deltachat core={} sqlite={}".format(
info['deltachat_core_version'],
info['sqlite_version'],
)
summary = ['Deltachat core={} sqlite={}'.format(
info['deltachat_core_version'],
info['sqlite_version'],
)]
cfg = config.getoption('--liveconfig')
if cfg:
summary.append('Liveconfig: {}'.format(os.path.abspath(cfg)))
return summary
@pytest.fixture(scope="session")
@@ -74,7 +86,7 @@ def acfactory(pytestconfig, tmpdir, request):
def configlist(self):
configlist = []
for line in open(fn):
if line.strip():
if line.strip() and not line.strip().startswith('#'):
d = {}
for part in line.split():
name, value = part.split("=")

View File

@@ -283,7 +283,7 @@ class TestOnlineAccount:
ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
assert ev[1] == msg_out.id
def test_two_acocunts_send_receive(self, acfactory):
def test_two_accounts_send_receive(self, acfactory):
ac1 = acfactory.get_online_configuring_account()
ac2 = acfactory.get_online_configuring_account()
c2 = ac1.create_contact(email=ac2.get_config("addr"))
@@ -294,13 +294,48 @@ class TestOnlineAccount:
wait_successful_IMAP_SMTP_connection(ac2)
wait_configuration_progress(ac2, 1000)
msg_out = chat.send_text("message1")
txt = "message1"
msg_out = chat.send_text(txt)
# wait for other account to receive
ev = ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
assert ev[2] == msg_out.id
msg_in = ac2.get_message_by_id(msg_out.id)
assert msg_in.text == "message1"
assert msg_in.text == txt
def test_two_accounts_send_receive_encrypted(self, acfactory, lp):
lp.sec("starting accounts, waiting for configuration")
ac1 = acfactory.get_online_configuring_account()
ac2 = acfactory.get_online_configuring_account()
c2 = ac1.create_contact(email=ac2.get_config("addr"))
chat = ac1.create_chat_by_contact(c2)
assert chat.id >= const.DC_CHAT_ID_LAST_SPECIAL
wait_successful_IMAP_SMTP_connection(ac1)
wait_configuration_progress(ac1, 1000)
wait_successful_IMAP_SMTP_connection(ac2)
wait_configuration_progress(ac2, 1000)
lp.sec("sending message from ac1 to ac2")
msg_out = chat.send_text("hello")
lp.sec("wait for second account to receive")
ev = ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
assert ev[2] == msg_out.id
lp.sec("chat back with text message, encrypted from ac2 to ac1")
chat_back = ac2.create_chat_by_message(msg_out.id)
txt = "https://testflight.apple.com/join/uEMc1NxS"
msg_back = chat_back.send_text(txt)
lp.sec("wait for first account to receive")
ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
if ev[2] != msg_back.id:
ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
assert ev[2] == msg_back.id
chat_back = ac1.create_chat_by_message(msg_back.id)
msg_in = chat_back.get_messages()[-1]
assert msg_in.text == text
def test_forward_messages(self, acfactory):
ac1 = acfactory.get_online_configuring_account()

View File

@@ -13,6 +13,8 @@ commands =
passenv =
TRAVIS
DCC_RS_DEV
DCC_RS_TARGET
DCC_PY_LIVECONFIG
deps =
pytest
pytest-faulthandler

View File

@@ -23,11 +23,10 @@ if [ $? != 0 ]; then
fi
pushd python
toxargs="$@"
if [ -e liveconfig ]; then
toxargs="--liveconfig liveconfig $@"
if [ -e "./liveconfig" ]; then
export DCC_PY_LIVECONFIG=liveconfig
fi
tox $toxargs
tox "$@"
ret=$?
popd
exit $ret

View File

@@ -491,3 +491,12 @@ pub enum KeyType {
Public = 0,
Private = 1,
}
pub const DC_CMD_GROUPNAME_CHANGED: libc::c_int = 2;
pub const DC_CMD_GROUPIMAGE_CHANGED: libc::c_int = 3;
pub const DC_CMD_MEMBER_ADDED_TO_GROUP: libc::c_int = 4;
pub const DC_CMD_MEMBER_REMOVED_FROM_GROUP: libc::c_int = 5;
pub const DC_CMD_AUTOCRYPT_SETUP_MESSAGE: libc::c_int = 6;
pub const DC_CMD_SECUREJOIN_MESSAGE: libc::c_int = 7;
pub const DC_CMD_LOCATION_STREAMING_ENABLED: libc::c_int = 8;
pub const DC_CMD_LOCATION_ONLY: libc::c_int = 9;

View File

@@ -260,7 +260,7 @@ unsafe fn cb_set_config(context: &Context, key: *const libc::c_char, value: *con
} else {
Some(as_str(value))
};
context.sql.set_config(context, as_str(key), v);
context.sql.set_config(context, as_str(key), v).ok();
}
/* *

View File

@@ -152,6 +152,16 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool {
);
match res {
Err(crate::error::Error::Sql(rusqlite::Error::QueryReturnedNoRows)) => false,
Err(err) => match err {
_ => {
error!(
context,
0, "chat: failed to load from db {}: {:?}", chat_id, err
);
false
}
},
Ok(_) => {
let c = unsafe { &mut *chat };
match c.id {
@@ -174,7 +184,7 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool {
(*chat).name = dc_stock_str((*chat).context, 41);
},
_ => {
if 0 != unsafe { dc_param_exists((*chat).param, 'K' as i32) } {
if 0 != unsafe { dc_param_exists((*chat).param, DC_PARAM_SELFTALK as i32) } {
unsafe {
free((*chat).name as *mut libc::c_void);
(*chat).name = dc_stock_str((*chat).context, 2);
@@ -184,16 +194,6 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool {
}
true
}
Err(err) => match err {
QueryReturnedNoRows => false,
_ => {
error!(
context,
0, "chat: failed to load from db {}: {:?}", chat_id, err
);
false
}
},
}
}
@@ -300,7 +300,7 @@ pub unsafe fn dc_create_or_lookup_nchat_by_contact_id(
&context.sql,
format!("INSERT INTO chats_contacts (chat_id, contact_id) VALUES({}, {})", chat_id, contact_id),
params![],
);
).ok();
}
}
@@ -388,7 +388,7 @@ unsafe fn prepare_msg_common<'a>(
|| (*msg).type_0 == 50i32
|| (*msg).type_0 == 60i32
{
pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
pathNfilename = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if pathNfilename.is_null() {
error!(
context,
@@ -403,24 +403,24 @@ unsafe fn prepare_msg_common<'a>(
} else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) {
current_block = 2171833246886114521;
} else {
dc_param_set((*msg).param, 'f' as i32, pathNfilename);
dc_param_set((*msg).param, DC_PARAM_FILE as i32, pathNfilename);
if (*msg).type_0 == 60i32 || (*msg).type_0 == 20i32 {
let mut better_type: libc::c_int = 0i32;
let mut better_mime: *mut libc::c_char = 0 as *mut libc::c_char;
dc_msg_guess_msgtype_from_suffix(pathNfilename, &mut better_type, &mut better_mime);
if 0 != better_type {
(*msg).type_0 = better_type;
dc_param_set((*msg).param, 'm' as i32, better_mime);
dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, better_mime);
}
free(better_mime as *mut libc::c_void);
} else if 0 == dc_param_exists((*msg).param, 'm' as i32) {
} else if 0 == dc_param_exists((*msg).param, DC_PARAM_MIMETYPE as i32) {
let mut better_mime_0: *mut libc::c_char = 0 as *mut libc::c_char;
dc_msg_guess_msgtype_from_suffix(
pathNfilename,
0 as *mut libc::c_int,
&mut better_mime_0,
);
dc_param_set((*msg).param, 'm' as i32, better_mime_0);
dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, better_mime_0);
free(better_mime_0 as *mut libc::c_void);
}
info!(
@@ -529,8 +529,12 @@ unsafe fn prepare_msg_raw(
}
} else {
if (*chat).type_0 == 120 || (*chat).type_0 == 130 {
if dc_param_get_int((*chat).param, 'U' as i32, 0) == 1 {
dc_param_set((*chat).param, 'U' as i32, 0 as *const libc::c_char);
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 1 {
dc_param_set(
(*chat).param,
DC_PARAM_UNPROMOTED as i32,
0 as *const libc::c_char,
);
dc_chat_update_param(chat);
}
}
@@ -548,7 +552,9 @@ unsafe fn prepare_msg_raw(
.sql
.get_config_int(context, "e2ee_enabled")
.unwrap_or_else(|| 1);
if 0 != e2ee_enabled && dc_param_get_int((*msg).param, 'u' as i32, 0) == 0 {
if 0 != e2ee_enabled
&& dc_param_get_int((*msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 0) == 0
{
let mut can_encrypt = 1;
let mut all_mutual = 1;
@@ -603,9 +609,13 @@ unsafe fn prepare_msg_raw(
}
}
if 0 != do_guarantee_e2ee {
dc_param_set_int((*msg).param, 'c' as i32, 1);
dc_param_set_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
}
dc_param_set((*msg).param, 'e' as i32, 0 as *const libc::c_char);
dc_param_set(
(*msg).param,
DC_PARAM_ERRONEOUS_E2EE as i32,
0 as *const libc::c_char,
);
if 0 == dc_chat_is_self_talk(chat)
&& 0 != get_parent_mime_headers(
chat,
@@ -805,7 +815,7 @@ pub unsafe fn dc_chat_is_self_talk(chat: *const Chat) -> libc::c_int {
if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 {
return 0i32;
}
dc_param_exists((*chat).param, 'K' as i32)
dc_param_exists((*chat).param, DC_PARAM_SELFTALK as i32)
}
/*******************************************************************************
@@ -833,7 +843,7 @@ unsafe fn last_msg_in_chat_encrypted(
dc_param_set_packed(msg_param, packed_c);
free(packed_c as *mut _);
if 0 != dc_param_exists(msg_param, 'c' as i32) {
if 0 != dc_param_exists(msg_param, DC_PARAM_GUARANTEE_E2EE as i32) {
last_is_encrypted = 1;
}
dc_param_unref(msg_param);
@@ -870,13 +880,15 @@ pub unsafe fn dc_is_contact_in_chat(
.unwrap_or_default() as libc::c_int
}
// Should return Result
pub fn dc_unarchive_chat(context: &Context, chat_id: u32) {
sql::execute(
context,
&context.sql,
"UPDATE chats SET archived=0 WHERE id=?",
params![chat_id as i32],
);
)
.ok();
}
pub unsafe fn dc_send_msg<'a>(
@@ -911,7 +923,11 @@ pub unsafe fn dc_send_msg<'a>(
}
if 0 == chat_id {
let forwards = dc_param_get((*msg).param, 'P' as i32, 0 as *const libc::c_char);
let forwards = dc_param_get(
(*msg).param,
DC_PARAM_PREP_FORWARDS as i32,
0 as *const libc::c_char,
);
if !forwards.is_null() {
let mut p = forwards;
while 0 != *p {
@@ -927,7 +943,11 @@ pub unsafe fn dc_send_msg<'a>(
dc_msg_unref(copy);
}
}
dc_param_set((*msg).param, 'P' as i32, 0 as *const libc::c_char);
dc_param_set(
(*msg).param,
DC_PARAM_PREP_FORWARDS as i32,
0 as *const libc::c_char,
);
dc_msg_save_param_to_disk(msg);
}
free(forwards as *mut libc::c_void);
@@ -987,7 +1007,8 @@ unsafe fn set_draft_raw(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t
|| (*msg).type_0 == 50i32
|| (*msg).type_0 == 60i32
{
pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
pathNfilename =
dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if pathNfilename.is_null() {
current_block = 14513523936503887211;
} else if 0 != dc_msg_is_increation(msg)
@@ -997,7 +1018,7 @@ unsafe fn set_draft_raw(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t
} else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) {
current_block = 14513523936503887211;
} else {
dc_param_set((*msg).param, 'f' as i32, pathNfilename);
dc_param_set((*msg).param, DC_PARAM_FILE as i32, pathNfilename);
current_block = 4495394744059808450;
}
} else {
@@ -1559,8 +1580,14 @@ pub unsafe fn dc_add_contact_to_chat_ex(
);
} else {
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
if 0 != flags & 0x1 && dc_param_get_int((*chat).param, 'U' as i32, 0) == 1 {
dc_param_set((*chat).param, 'U' as i32, 0 as *const libc::c_char);
if 0 != flags & 0x1
&& dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 1
{
dc_param_set(
(*chat).param,
DC_PARAM_UNPROMOTED as i32,
0 as *const libc::c_char,
);
dc_chat_update_param(chat);
}
let self_addr = context
@@ -1608,7 +1635,7 @@ pub unsafe fn dc_add_contact_to_chat_ex(
match current_block {
12326129973959287090 => {}
_ => {
if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 {
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 0 {
(*msg).type_0 = 10;
(*msg).text = dc_stock_system_msg(
context,
@@ -1617,9 +1644,13 @@ pub unsafe fn dc_add_contact_to_chat_ex(
0 as *const libc::c_char,
1 as uint32_t,
);
dc_param_set_int((*msg).param, 'S' as i32, 4);
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
dc_param_set_int((*msg).param, 'F' as i32, flags);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 4);
dc_param_set(
(*msg).param,
DC_PARAM_CMD_ARG as i32,
(*contact).addr,
);
dc_param_set_int((*msg).param, DC_PARAM_CMD_ARG2 as i32, flags);
(*msg).id = dc_send_msg(context, chat_id, msg);
context.call_cb(
Event::MSGS_CHANGED,
@@ -1666,6 +1697,7 @@ pub fn dc_reset_gossiped_timestamp(context: &Context, chat_id: u32) {
dc_set_gossiped_timestamp(context, chat_id, 0);
}
// Should return Result
pub fn dc_set_gossiped_timestamp(context: &Context, chat_id: u32, timestamp: i64) {
if 0 != chat_id {
info!(
@@ -1678,7 +1710,8 @@ pub fn dc_set_gossiped_timestamp(context: &Context, chat_id: u32, timestamp: i64
&context.sql,
"UPDATE chats SET gossiped_timestamp=? WHERE id=?;",
params![timestamp, chat_id as i32],
);
)
.ok();
} else {
info!(
context,
@@ -1689,7 +1722,8 @@ pub fn dc_set_gossiped_timestamp(context: &Context, chat_id: u32, timestamp: i64
&context.sql,
"UPDATE chats SET gossiped_timestamp=?;",
params![timestamp],
);
)
.ok();
}
}
@@ -1720,7 +1754,7 @@ pub unsafe fn dc_remove_contact_from_chat(
} else {
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
if !contact.is_null() {
if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 {
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 0 {
(*msg).type_0 = 10;
if (*contact).id == 1 as libc::c_uint {
dc_set_group_explicitly_left(context, (*chat).grpid);
@@ -1740,8 +1774,8 @@ pub unsafe fn dc_remove_contact_from_chat(
1 as uint32_t,
)
}
dc_param_set_int((*msg).param, 'S' as i32, 5);
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 5);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, (*contact).addr);
(*msg).id = dc_send_msg(context, chat_id, msg);
context.call_cb(
Event::MSGS_CHANGED,
@@ -1772,6 +1806,7 @@ pub unsafe fn dc_remove_contact_from_chat(
success
}
// Should return Result
pub fn dc_set_group_explicitly_left(context: &Context, grpid: *const libc::c_char) {
if 0 == dc_is_group_explicitly_left(context, grpid) {
sql::execute(
@@ -1779,7 +1814,8 @@ pub fn dc_set_group_explicitly_left(context: &Context, grpid: *const libc::c_cha
&context.sql,
"INSERT INTO leftgrps (grpid) VALUES(?);",
params![as_str(grpid)],
);
)
.ok();
}
}
@@ -1833,7 +1869,7 @@ pub unsafe fn dc_set_chat_name(
)
.is_ok()
{
if dc_param_get_int((*chat).param, 'U' as i32, 0i32) == 0i32 {
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32) == 0i32 {
(*msg).type_0 = 10i32;
(*msg).text = dc_stock_system_msg(
context,
@@ -1842,8 +1878,8 @@ pub unsafe fn dc_set_chat_name(
new_name,
1i32 as uint32_t,
);
dc_param_set_int((*msg).param, 'S' as i32, 2i32);
dc_param_set((*msg).param, 'E' as i32, (*chat).name);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 2i32);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, (*chat).name);
(*msg).id = dc_send_msg(context, chat_id, msg);
context.call_cb(
Event::MSGS_CHANGED,
@@ -1903,11 +1939,13 @@ pub unsafe fn dc_set_chat_profile_image(
match current_block {
14766584022300871387 => {}
_ => {
dc_param_set((*chat).param, 'i' as i32, new_image_rel);
dc_param_set((*chat).param, DC_PARAM_PROFILE_IMAGE as i32, new_image_rel);
if !(0 == dc_chat_update_param(chat)) {
if dc_param_get_int((*chat).param, 'U' as i32, 0i32) == 0i32 {
dc_param_set_int((*msg).param, 'S' as i32, 3i32);
dc_param_set((*msg).param, 'E' as i32, new_image_rel);
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32)
== 0i32
{
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 3i32);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, new_image_rel);
(*msg).type_0 = 10i32;
(*msg).text = dc_stock_system_msg(
context,
@@ -1970,28 +2008,39 @@ pub unsafe fn dc_forward_msgs(
curr_timestamp = dc_create_smeared_timestamps(context, msg_cnt);
idsstr = dc_arr_to_string(msg_ids, msg_cnt);
let ids = context.sql.query_map(
format!(
"SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id",
as_str(idsstr)
),
params![],
|row| row.get::<_, i32>(0),
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
);
let ids = context
.sql
.query_map(
format!(
"SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id",
as_str(idsstr)
),
params![],
|row| row.get::<_, i32>(0),
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
)
.unwrap(); // TODO: better error handling
for id in ids.unwrap() {
for id in ids {
let src_msg_id = id;
if !dc_msg_load_from_db(msg, context, src_msg_id as u32) {
break;
}
dc_param_set_packed(original_param, (*(*msg).param).packed);
if (*msg).from_id != 1i32 as libc::c_uint {
dc_param_set_int((*msg).param, 'a' as i32, 1i32);
dc_param_set_int((*msg).param, DC_PARAM_FORWARDED as i32, 1i32);
}
dc_param_set((*msg).param, 'c' as i32, 0 as *const libc::c_char);
dc_param_set((*msg).param, 'u' as i32, 0 as *const libc::c_char);
dc_param_set((*msg).param, 'S' as i32, 0 as *const libc::c_char);
dc_param_set(
(*msg).param,
DC_PARAM_GUARANTEE_E2EE as i32,
0 as *const libc::c_char,
);
dc_param_set(
(*msg).param,
DC_PARAM_FORCE_PLAINTEXT as i32,
0 as *const libc::c_char,
);
dc_param_set((*msg).param, DC_PARAM_CMD as i32, 0 as *const libc::c_char);
let new_msg_id: uint32_t;
if (*msg).state == 18i32 {
let fresh9 = curr_timestamp;
@@ -2002,7 +2051,7 @@ pub unsafe fn dc_forward_msgs(
(*msg).id = src_msg_id as uint32_t;
let old_fwd: *mut libc::c_char = dc_param_get(
(*msg).param,
'P' as i32,
DC_PARAM_PREP_FORWARDS as i32,
b"\x00" as *const u8 as *const libc::c_char,
);
let new_fwd: *mut libc::c_char = dc_mprintf(
@@ -2010,7 +2059,7 @@ pub unsafe fn dc_forward_msgs(
old_fwd,
new_msg_id,
);
dc_param_set((*msg).param, 'P' as i32, new_fwd);
dc_param_set((*msg).param, DC_PARAM_PREP_FORWARDS as i32, new_fwd);
dc_msg_save_param_to_disk(msg);
free(new_fwd as *mut libc::c_void);
free(old_fwd as *mut libc::c_void);
@@ -2083,7 +2132,7 @@ pub unsafe fn dc_chat_get_subtitle(chat: *const Chat) -> *mut libc::c_char {
}
let mut ret: *mut libc::c_char = std::ptr::null_mut();
if (*chat).type_0 == 100 && 0 != dc_param_exists((*chat).param, 'K' as i32) {
if (*chat).type_0 == 100 && 0 != dc_param_exists((*chat).param, DC_PARAM_SELFTALK as i32) {
ret = dc_stock_str((*chat).context, 50)
} else if (*chat).type_0 == 100 {
let ret_raw: String = (*chat)
@@ -2132,7 +2181,11 @@ pub unsafe fn dc_chat_get_profile_image(chat: *const Chat) -> *mut libc::c_char
let mut contacts: *mut dc_array_t = 0 as *mut dc_array_t;
let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t;
if !(chat.is_null() || (*chat).magic != 0xc4a7c4a7u32) {
image_rel = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char);
image_rel = dc_param_get(
(*chat).param,
DC_PARAM_PROFILE_IMAGE as i32,
0 as *const libc::c_char,
);
if !image_rel.is_null() && 0 != *image_rel.offset(0isize) as libc::c_int {
image_abs = dc_get_abs_path((*chat).context, image_rel)
} else if (*chat).type_0 == 100i32 {
@@ -2192,7 +2245,7 @@ pub unsafe fn dc_chat_is_unpromoted(chat: *const Chat) -> libc::c_int {
if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 {
return 0i32;
}
dc_param_get_int((*chat).param, 'U' as i32, 0i32)
dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32)
}
// TODO should return bool /rtn

View File

@@ -174,7 +174,8 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
param.addr = oauth2_addr;
context
.sql
.set_config(context, "addr", Some(param.addr.as_str()));
.set_config(context, "addr", Some(param.addr.as_str()))
.ok();
}
if s.shall_stop_ongoing {
current_block = 2927484062889439186;
@@ -966,7 +967,8 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
context,
"configured",
1,
);
)
.ok();
if !s.shall_stop_ongoing
{
context.call_cb(

View File

@@ -418,7 +418,8 @@ pub fn dc_add_or_lookup_contact(
},
row_id
],
);
)
.ok();
if update_name {
sql::execute(
@@ -426,7 +427,7 @@ pub fn dc_add_or_lookup_contact(
&context.sql,
"UPDATE chats SET name=? WHERE type=? AND id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?);",
params![to_string(name), 100, row_id]
);
).ok();
}
unsafe { *sth_modified = 1 };
}

View File

@@ -34,9 +34,9 @@ pub unsafe fn dc_imex(
param2: *const libc::c_char,
) {
let param: *mut dc_param_t = dc_param_new();
dc_param_set_int(param, 'S' as i32, what);
dc_param_set(param, 'E' as i32, param1);
dc_param_set(param, 'F' as i32, param2);
dc_param_set_int(param, DC_PARAM_CMD as i32, what);
dc_param_set(param, DC_PARAM_CMD_ARG as i32, param1);
dc_param_set(param, DC_PARAM_CMD_ARG2 as i32, param2);
dc_job_kill_action(context, 910i32);
dc_job_add(context, 910i32, 0i32, (*param).packed, 0i32);
dc_param_unref(param);
@@ -143,15 +143,15 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
if !(chat_id == 0i32 as libc::c_uint) {
msg = dc_msg_new_untyped(context);
(*msg).type_0 = 60i32;
dc_param_set((*msg).param, 'f' as i32, setup_file_name);
dc_param_set((*msg).param, DC_PARAM_FILE as i32, setup_file_name);
dc_param_set(
(*msg).param,
'm' as i32,
DC_PARAM_MIMETYPE as i32,
b"application/autocrypt-setup\x00" as *const u8
as *const libc::c_char,
);
dc_param_set_int((*msg).param, 'S' as i32, 6i32);
dc_param_set_int((*msg).param, 'u' as i32, 2i32);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 6);
dc_param_set_int((*msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 2);
if !context
.running_state
.clone()
@@ -551,9 +551,17 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
let mut param2: *mut libc::c_char = 0 as *mut libc::c_char;
if !(0 == dc_alloc_ongoing(context)) {
ongoing_allocated_here = 1i32;
what = dc_param_get_int((*job).param, 'S' as i32, 0i32);
param1 = dc_param_get((*job).param, 'E' as i32, 0 as *const libc::c_char);
param2 = dc_param_get((*job).param, 'F' as i32, 0 as *const libc::c_char);
what = dc_param_get_int((*job).param, DC_PARAM_CMD as i32, 0);
param1 = dc_param_get(
(*job).param,
DC_PARAM_CMD_ARG as i32,
0 as *const libc::c_char,
);
param2 = dc_param_get(
(*job).param,
DC_PARAM_CMD_ARG2 as i32,
0 as *const libc::c_char,
);
if param1.is_null() {
error!(context, 0, "No Import/export dir/file given.",);
} else {
@@ -849,7 +857,6 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
if dc_write_file_safe(context, &pathNfilename, &file_blob) {
continue;
}
error!(
context,
0,
@@ -870,8 +877,9 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
);
res.and_then(|_| {
// only delete backup_blobs if all files were successfully extracted
sql::execute(context, &context.sql, "DROP TABLE backup_blobs;", params![])?;
sql::try_execute(context, &context.sql, "VACUUM;")?;
sql::try_execute(context, &context.sql, "VACUUM;").ok();
Ok(())
})
.is_ok() as libc::c_int
@@ -905,7 +913,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
sql::housekeeping(context);
sql::try_execute(context, &context.sql, "VACUUM;");
sql::try_execute(context, &context.sql, "VACUUM;").ok();
context.sql.close(context);
let mut closed = true;
info!(

View File

@@ -110,7 +110,7 @@ unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network:
},
);
match jobs {
Ok(ref res) => {}
Ok(ref _res) => {}
Err(ref err) => {
info!(context, 0, "query failed: {:?}", err);
}
@@ -302,11 +302,15 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
}
match current_block {
13109137661213826276 => {
filename = dc_param_get(job.param, 'f' as i32, 0 as *const libc::c_char);
filename = dc_param_get(job.param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if filename.is_null() {
warn!(context, 0, "Missing file name for job {}", job.job_id,);
} else if !(0 == dc_read_file(context, filename, &mut buf, &mut buf_bytes)) {
recipients = dc_param_get(job.param, 'R' as i32, 0 as *const libc::c_char);
recipients = dc_param_get(
job.param,
DC_PARAM_RECIPIENTS as i32,
0 as *const libc::c_char,
);
if recipients.is_null() {
warn!(context, 0, "Missing recipients for job {}", job.job_id,);
} else {
@@ -499,8 +503,12 @@ fn connect_to_inbox(context: &Context, inbox: &Imap) -> libc::c_int {
unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_job_t) {
let current_block: u64;
let folder: *mut libc::c_char = dc_param_get(job.param, 'Z' as i32, 0 as *const libc::c_char);
let uid: uint32_t = dc_param_get_int(job.param, 'z' as i32, 0i32) as uint32_t;
let folder: *mut libc::c_char = dc_param_get(
job.param,
DC_PARAM_SERVER_FOLDER as i32,
0 as *const libc::c_char,
);
let uid: uint32_t = dc_param_get_int(job.param, DC_PARAM_SERVER_UID as i32, 0) as uint32_t;
let mut dest_uid: uint32_t = 0i32 as uint32_t;
let inbox = context.inbox.read().unwrap();
@@ -521,7 +529,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_
if inbox.set_seen(context, folder, uid) as libc::c_uint == 0i32 as libc::c_uint {
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
}
if 0 != dc_param_get_int(job.param, 'M' as i32, 0i32) {
if 0 != dc_param_get_int(job.param, DC_PARAM_ALSO_MOVE as i32, 0i32) {
if context
.sql
.get_config_int(context, "folders_configured")
@@ -574,8 +582,12 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
}
_ => {
if 0 != dc_param_get_int((*msg).param, 'r' as i32, 0i32)
&& 0 != context
if 0 != dc_param_get_int(
(*msg).param,
DC_PARAM_WANTS_MDN as i32,
0i32,
) && 0
!= context
.sql
.get_config_int(context, "mdns_enabled")
.unwrap_or_else(|| 1)
@@ -628,7 +640,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
}
_ => {
if 0 != dc_param_get_int((*msg).param, 'r' as i32, 0i32)
if 0 != dc_param_get_int((*msg).param, DC_PARAM_WANTS_MDN as i32, 0)
&& 0 != context
.sql
.get_config_int(context, "mdns_enabled")
@@ -766,8 +778,8 @@ unsafe fn dc_add_smtp_job(
(*mimefactory).recipients_addr,
b"\x1e\x00" as *const u8 as *const libc::c_char,
);
dc_param_set(param, 'f' as i32, pathNfilename);
dc_param_set(param, 'R' as i32, recipients);
dc_param_set(param, DC_PARAM_FILE as i32, pathNfilename);
dc_param_set(param, DC_PARAM_RECIPIENTS as i32, recipients);
dc_job_add(
context,
action,
@@ -820,7 +832,7 @@ pub unsafe fn dc_job_add(
},
(timestamp + delay_seconds as i64)
]
);
).ok();
if thread == 100 {
dc_interrupt_imap_idle(context);
@@ -1167,19 +1179,19 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
{
let pathNfilename = dc_param_get(
(*mimefactory.msg).param,
'f' as i32,
DC_PARAM_FILE as i32,
0 as *const libc::c_char,
);
if !pathNfilename.is_null() {
if ((*mimefactory.msg).type_0 == 20i32 || (*mimefactory.msg).type_0 == 21i32)
&& 0 == dc_param_exists((*mimefactory.msg).param, 'w' as i32)
&& 0 == dc_param_exists((*mimefactory.msg).param, DC_PARAM_WIDTH as i32)
{
let mut buf: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
let mut buf_bytes: size_t = 0;
let mut w: uint32_t = 0;
let mut h: uint32_t = 0;
dc_param_set_int((*mimefactory.msg).param, 'w' as i32, 0i32);
dc_param_set_int((*mimefactory.msg).param, 'h' as i32, 0i32);
dc_param_set_int((*mimefactory.msg).param, DC_PARAM_WIDTH as i32, 0);
dc_param_set_int((*mimefactory.msg).param, DC_PARAM_HEIGHT as i32, 0);
if 0 != dc_read_file(
context,
pathNfilename,
@@ -1192,8 +1204,16 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
&mut w,
&mut h,
) {
dc_param_set_int((*mimefactory.msg).param, 'w' as i32, w as int32_t);
dc_param_set_int((*mimefactory.msg).param, 'h' as i32, h as int32_t);
dc_param_set_int(
(*mimefactory.msg).param,
DC_PARAM_WIDTH as i32,
w as int32_t,
);
dc_param_set_int(
(*mimefactory.msg).param,
DC_PARAM_HEIGHT as i32,
h as int32_t,
);
}
}
free(buf as *mut libc::c_void);
@@ -1205,7 +1225,7 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
/* create message */
if 0 == dc_mimefactory_render(&mut mimefactory) {
dc_set_msg_failed(context, msg_id, mimefactory.error);
} else if 0 != dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0)
} else if 0 != dc_param_get_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0)
&& 0 == mimefactory.out_encrypted
{
warn!(
@@ -1213,7 +1233,7 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
0,
"e2e encryption unavailable {} - {}",
msg_id,
dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0),
dc_param_get_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0),
);
dc_set_msg_failed(
context,
@@ -1251,9 +1271,10 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
}
}
if 0 != mimefactory.out_encrypted
&& dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0i32) == 0i32
&& dc_param_get_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0)
== 0
{
dc_param_set_int((*mimefactory.msg).param, 'c' as i32, 1i32);
dc_param_set_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
dc_msg_save_param_to_disk(mimefactory.msg);
}
dc_add_to_keyhistory(

View File

@@ -76,7 +76,7 @@ pub unsafe fn dc_send_locations_to_chat(
0 as *const libc::c_char,
0,
);
dc_param_set_int((*msg).param, 'S' as i32, 8i32);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 8);
dc_send_msg(context, chat_id, msg);
} else if 0 == seconds && is_sending_locations_before {
stock_str = dc_stock_system_msg(
@@ -690,7 +690,7 @@ pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mu
// and dc_set_location() is typically called periodically, this is ok)
let mut msg = dc_msg_new(context, 10);
(*msg).hidden = 1;
dc_param_set_int((*msg).param, 'S' as i32, 9);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 9);
dc_send_msg(context, chat_id as u32, msg);
dc_msg_unref(msg);
}

View File

@@ -91,34 +91,39 @@ pub fn dc_loginparam_write(
let prefix = prefix.as_ref();
let key = format!("{}addr", prefix);
sql.set_config(context, key, Some(&loginparam.addr));
sql.set_config(context, key, Some(&loginparam.addr)).ok();
let key = format!("{}mail_server", prefix);
sql.set_config(context, key, Some(&loginparam.mail_server));
sql.set_config(context, key, Some(&loginparam.mail_server))
.ok();
let key = format!("{}mail_port", prefix);
sql.set_config_int(context, key, loginparam.mail_port);
sql.set_config_int(context, key, loginparam.mail_port).ok();
let key = format!("{}mail_user", prefix);
sql.set_config(context, key, Some(&loginparam.mail_user));
sql.set_config(context, key, Some(&loginparam.mail_user))
.ok();
let key = format!("{}mail_pw", prefix);
sql.set_config(context, key, Some(&loginparam.mail_pw));
sql.set_config(context, key, Some(&loginparam.mail_pw)).ok();
let key = format!("{}send_server", prefix);
sql.set_config(context, key, Some(&loginparam.send_server));
sql.set_config(context, key, Some(&loginparam.send_server))
.ok();
let key = format!("{}send_port", prefix);
sql.set_config_int(context, key, loginparam.send_port);
sql.set_config_int(context, key, loginparam.send_port).ok();
let key = format!("{}send_user", prefix);
sql.set_config(context, key, Some(&loginparam.send_user));
sql.set_config(context, key, Some(&loginparam.send_user))
.ok();
let key = format!("{}send_pw", prefix);
sql.set_config(context, key, Some(&loginparam.send_pw));
sql.set_config(context, key, Some(&loginparam.send_pw)).ok();
let key = format!("{}server_flags", prefix);
sql.set_config_int(context, key, loginparam.server_flags);
sql.set_config_int(context, key, loginparam.server_flags)
.ok();
}
fn unset_empty(s: &String) -> Cow<String> {

View File

@@ -183,11 +183,11 @@ pub unsafe fn dc_mimefactory_load_msg(
)
.unwrap();
let command = dc_param_get_int((*(*factory).msg).param, 'S' as i32, 0);
let command = dc_param_get_int((*(*factory).msg).param, DC_PARAM_CMD as i32, 0);
if command == 5 {
let email_to_remove_c = dc_param_get(
(*(*factory).msg).param,
'E' as i32,
DC_PARAM_CMD_ARG as i32,
0 as *const libc::c_char,
);
let email_to_remove = to_string(email_to_remove_c);
@@ -539,9 +539,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
e2ee_guaranteed = 1;
min_verified = 2
} else {
force_plaintext = dc_param_get_int((*(*factory).msg).param, 'u' as i32, 0);
force_plaintext =
dc_param_get_int((*(*factory).msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 0);
if force_plaintext == 0 {
e2ee_guaranteed = dc_param_get_int((*(*factory).msg).param, 'c' as i32, 0)
e2ee_guaranteed =
dc_param_get_int((*(*factory).msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0)
}
}
if (*chat).gossiped_timestamp == 0
@@ -550,7 +552,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
do_gossip = 1
}
/* build header etc. */
let command: libc::c_int = dc_param_get_int((*msg).param, 'S' as i32, 0);
let command: libc::c_int = dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0);
if (*chat).type_0 == DC_CHAT_TYPE_GROUP as libc::c_int
|| (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int
{
@@ -569,8 +571,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
),
);
if command == 5 {
let email_to_remove: *mut libc::c_char =
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
let email_to_remove: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG as i32,
0 as *const libc::c_char,
);
if !email_to_remove.is_null() {
mailimf_fields_add(
imf_fields,
@@ -585,8 +590,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
}
} else if command == 4 {
do_gossip = 1;
let email_to_add: *mut libc::c_char =
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
let email_to_add: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG as i32,
0 as *const libc::c_char,
);
if !email_to_add.is_null() {
mailimf_fields_add(
imf_fields,
@@ -598,9 +606,13 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
email_to_add,
),
);
grpimage = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char)
grpimage = dc_param_get(
(*chat).param,
DC_PARAM_PROFILE_IMAGE as i32,
0 as *const libc::c_char,
)
}
if 0 != dc_param_get_int((*msg).param, 'F' as i32, 0) & 0x1 {
if 0 != dc_param_get_int((*msg).param, DC_PARAM_CMD_ARG2 as i32, 0) & 0x1 {
info!(
(*msg).context,
0,
@@ -624,13 +636,17 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
),
dc_param_get(
(*msg).param,
'E' as i32,
DC_PARAM_CMD_ARG as i32,
b"\x00" as *const u8 as *const libc::c_char,
),
),
);
} else if command == 3 {
grpimage = dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
grpimage = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG as i32,
0 as *const libc::c_char,
);
if grpimage.is_null() {
mailimf_fields_add(
imf_fields,
@@ -664,8 +680,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
placeholdertext = dc_stock_str((*factory).context, 43)
}
if command == 7 {
let step: *mut libc::c_char =
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
let step: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG as i32,
0 as *const libc::c_char,
);
if !step.is_null() {
info!(
(*msg).context,
@@ -680,8 +699,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
step,
),
);
let param2: *mut libc::c_char =
dc_param_get((*msg).param, 'F' as i32, 0 as *const libc::c_char);
let param2: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG2 as i32,
0 as *const libc::c_char,
);
if !param2.is_null() {
mailimf_fields_add(
imf_fields,
@@ -709,8 +731,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
),
);
}
let fingerprint: *mut libc::c_char =
dc_param_get((*msg).param, 'G' as i32, 0 as *const libc::c_char);
let fingerprint: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG3 as i32,
0 as *const libc::c_char,
);
if !fingerprint.is_null() {
mailimf_fields_add(
imf_fields,
@@ -723,8 +748,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
),
);
}
let grpid: *mut libc::c_char =
dc_param_get((*msg).param, 'H' as i32, 0 as *const libc::c_char);
let grpid: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_CMD_ARG4 as i32,
0 as *const libc::c_char,
);
if !grpid.is_null() {
mailimf_fields_add(
imf_fields,
@@ -741,7 +769,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
if !grpimage.is_null() {
let mut meta: *mut dc_msg_t = dc_msg_new_untyped((*factory).context);
(*meta).type_0 = DC_MSG_IMAGE as libc::c_int;
dc_param_set((*meta).param, 'f' as i32, grpimage);
dc_param_set((*meta).param, DC_PARAM_FILE as i32, grpimage);
let mut filename_as_sent: *mut libc::c_char = 0 as *mut libc::c_char;
meta_part = build_body_file(
meta,
@@ -772,7 +800,8 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
),
);
}
let duration_ms: libc::c_int = dc_param_get_int((*msg).param, 'd' as i32, 0);
let duration_ms: libc::c_int =
dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0);
if duration_ms > 0 {
mailimf_fields_add(
imf_fields,
@@ -786,7 +815,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
);
}
}
afwd_email = dc_param_exists((*msg).param, 'a' as i32);
afwd_email = dc_param_exists((*msg).param, DC_PARAM_FORWARDED as i32);
let mut fwdhint: *mut libc::c_char = 0 as *mut libc::c_char;
if 0 != afwd_email {
fwdhint = dc_strdup(
@@ -968,7 +997,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
mailmime_add_part(message, multipart);
let p1: *mut libc::c_char;
let p2: *mut libc::c_char;
if 0 != dc_param_get_int((*(*factory).msg).param, 'c' as i32, 0) {
if 0 != dc_param_get_int((*(*factory).msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) {
p1 = dc_stock_str((*factory).context, 24)
} else {
p1 = dc_msg_get_summarytext((*factory).msg, 32)
@@ -1094,7 +1123,7 @@ unsafe fn get_subject(
} else {
b"\x00" as *const u8 as *const libc::c_char
};
if dc_param_get_int((*msg).param, 'S' as i32, 0) == 6 {
if dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0) == 6 {
ret = dc_stock_str(context, 42)
} else if (*chat).type_0 == DC_CHAT_TYPE_GROUP as libc::c_int
|| (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int
@@ -1155,9 +1184,12 @@ unsafe fn build_body_file(
let mut mime_sub: *mut mailmime = 0 as *mut mailmime;
let content: *mut mailmime_content;
let pathNfilename: *mut libc::c_char =
dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
let mut mimetype: *mut libc::c_char =
dc_param_get((*msg).param, 'm' as i32, 0 as *const libc::c_char);
dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
let mut mimetype: *mut libc::c_char = dc_param_get(
(*msg).param,
DC_PARAM_MIMETYPE as i32,
0 as *const libc::c_char,
);
let suffix: *mut libc::c_char = dc_get_filesuffix_lc(pathNfilename);
let mut filename_to_send: *mut libc::c_char = 0 as *mut libc::c_char;
let mut filename_encoded: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -1316,7 +1348,7 @@ unsafe fn build_body_file(
unsafe fn is_file_size_okay(msg: *const dc_msg_t) -> libc::c_int {
let mut file_size_okay: libc::c_int = 1;
let pathNfilename: *mut libc::c_char =
dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
let bytes: uint64_t = dc_get_filebytes((*msg).context, pathNfilename);
if bytes > (49 * 1024 * 1024 / 4 * 3) as libc::c_ulonglong {
file_size_okay = 0;

View File

@@ -323,7 +323,7 @@ pub unsafe fn dc_mimeparser_parse(
while i_1 < icnt_0 {
let part_2: *mut dc_mimepart_t =
carray_get((*mimeparser).parts, i_1 as libc::c_uint) as *mut dc_mimepart_t;
dc_param_set_int((*part_2).param, 'a' as i32, 1i32);
dc_param_set_int((*part_2).param, DC_PARAM_FORWARDED as i32, 1);
i_1 += 1
}
}
@@ -348,7 +348,7 @@ pub unsafe fn dc_mimeparser_parse(
if !field_0.is_null() {
let duration_ms: libc::c_int = dc_atoi_null_is_0((*field_0).fld_value);
if duration_ms > 0i32 && duration_ms < 24i32 * 60i32 * 60i32 * 1000i32 {
dc_param_set_int((*part_3).param, 'd' as i32, duration_ms);
dc_param_set_int((*part_3).param, DC_PARAM_DURATION as i32, duration_ms);
}
}
}
@@ -385,7 +385,11 @@ pub unsafe fn dc_mimeparser_parse(
let part_4: *mut dc_mimepart_t =
dc_mimeparser_get_last_nonmeta(mimeparser);
if !part_4.is_null() {
dc_param_set_int((*part_4).param, 'r' as i32, 1i32);
dc_param_set_int(
(*part_4).param,
DC_PARAM_WANTS_MDN as i32,
1,
);
}
}
free(from_addr as *mut libc::c_void);
@@ -1486,8 +1490,8 @@ unsafe fn do_add_single_file_part(
(*part).type_0 = msg_type;
(*part).int_mimetype = mime_type;
(*part).bytes = decoded_data_bytes as libc::c_int;
dc_param_set((*part).param, 'f' as i32, pathNfilename);
dc_param_set((*part).param, 'm' as i32, raw_mime);
dc_param_set((*part).param, DC_PARAM_FILE as i32, pathNfilename);
dc_param_set((*part).param, DC_PARAM_MIMETYPE as i32, raw_mime);
if mime_type == 80i32 {
let mut w: uint32_t = 0i32 as uint32_t;
let mut h: uint32_t = 0i32 as uint32_t;
@@ -1497,8 +1501,8 @@ unsafe fn do_add_single_file_part(
&mut w,
&mut h,
) {
dc_param_set_int((*part).param, 'w' as i32, w as int32_t);
dc_param_set_int((*part).param, 'h' as i32, h as int32_t);
dc_param_set_int((*part).param, DC_PARAM_WIDTH as i32, w as int32_t);
dc_param_set_int((*part).param, DC_PARAM_HEIGHT as i32, h as int32_t);
}
}
do_add_single_part(parser, part);
@@ -1511,9 +1515,9 @@ unsafe fn do_add_single_file_part(
unsafe fn do_add_single_part(parser: &dc_mimeparser_t, part: *mut dc_mimepart_t) {
if 0 != (*parser).e2ee_helper.encrypted && (*parser).e2ee_helper.signatures.len() > 0 {
dc_param_set_int((*part).param, 'c' as i32, 1i32);
dc_param_set_int((*part).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
} else if 0 != (*parser).e2ee_helper.encrypted {
dc_param_set_int((*part).param, 'e' as i32, 0x2i32);
dc_param_set_int((*part).param, DC_PARAM_ERRONEOUS_E2EE as i32, 0x2);
}
carray_add(
(*parser).parts,

View File

@@ -142,18 +142,22 @@ pub unsafe fn dc_get_msg_info(context: &Context, msg_id: u32) -> *mut libc::c_ch
ret += ", Location sent";
}
let e2ee_errors = dc_param_get_int((*msg).param, 'e' as i32, 0);
let e2ee_errors = dc_param_get_int((*msg).param, DC_PARAM_ERRONEOUS_E2EE as i32, 0);
if 0 != e2ee_errors {
if 0 != e2ee_errors & 0x2 {
ret += ", Encrypted, no valid signature";
}
} else if 0 != dc_param_get_int((*msg).param, 'c' as i32, 0) {
} else if 0 != dc_param_get_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) {
ret += ", Encrypted";
}
ret += "\n";
p = dc_param_get((*msg).param, 'L' as i32, 0 as *const libc::c_char);
p = dc_param_get(
(*msg).param,
DC_PARAM_ERROR as i32,
0 as *const libc::c_char,
);
if !p.is_null() {
ret += &format!("Error: {}", as_str(p));
free(p as *mut libc::c_void);
@@ -184,12 +188,12 @@ pub unsafe fn dc_get_msg_info(context: &Context, msg_id: u32) -> *mut libc::c_ch
ret += &format!("Mimetype: {}\n", as_str(p));
free(p as *mut libc::c_void);
}
let w = dc_param_get_int((*msg).param, 'w' as i32, 0);
let h = dc_param_get_int((*msg).param, 'h' as i32, 0);
let w = dc_param_get_int((*msg).param, DC_PARAM_WIDTH as i32, 0);
let h = dc_param_get_int((*msg).param, DC_PARAM_HEIGHT as i32, 0);
if w != 0 || h != 0 {
ret += &format!("Dimension: {} x {}\n", w, h,);
}
let duration = dc_param_get_int((*msg).param, 'd' as i32, 0);
let duration = dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0);
if duration != 0 {
ret += &format!("Duration: {} ms\n", duration,);
}
@@ -269,9 +273,13 @@ pub unsafe fn dc_msg_get_filemime(msg: *const dc_msg_t) -> *mut libc::c_char {
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
let mut file: *mut libc::c_char = 0 as *mut libc::c_char;
if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) {
ret = dc_param_get((*msg).param, 'm' as i32, 0 as *const libc::c_char);
ret = dc_param_get(
(*msg).param,
DC_PARAM_MIMETYPE as i32,
0 as *const libc::c_char,
);
if ret.is_null() {
file = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
file = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if !file.is_null() {
dc_msg_guess_msgtype_from_suffix(file, 0 as *mut libc::c_int, &mut ret);
if ret.is_null() {
@@ -348,7 +356,7 @@ pub unsafe fn dc_msg_get_file(msg: *const dc_msg_t) -> *mut libc::c_char {
let mut file_rel: *mut libc::c_char = 0 as *mut libc::c_char;
let mut file_abs: *mut libc::c_char = 0 as *mut libc::c_char;
if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) {
file_rel = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
file_rel = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if !file_rel.is_null() {
file_abs = dc_get_abs_path((*msg).context, file_rel)
}
@@ -479,10 +487,7 @@ pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id:
}
);
match res {
Ok(_) => true,
Err(err) => false,
}
res.is_ok()
}
pub unsafe fn dc_get_mime_headers(context: &Context, msg_id: uint32_t) -> *mut libc::c_char {
@@ -701,7 +706,7 @@ pub unsafe fn dc_msg_get_filename(msg: *const dc_msg_t) -> *mut libc::c_char {
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
let mut pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char;
if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) {
pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
pathNfilename = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if !pathNfilename.is_null() {
ret = dc_get_filename(pathNfilename)
}
@@ -718,7 +723,7 @@ pub unsafe fn dc_msg_get_filebytes(msg: *const dc_msg_t) -> uint64_t {
let mut ret: uint64_t = 0i32 as uint64_t;
let mut file: *mut libc::c_char = 0 as *mut libc::c_char;
if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) {
file = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
file = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
if !file.is_null() {
ret = dc_get_filebytes((*msg).context, file)
}
@@ -733,7 +738,7 @@ pub unsafe fn dc_msg_get_width(msg: *const dc_msg_t) -> libc::c_int {
return 0i32;
}
dc_param_get_int((*msg).param, 'w' as i32, 0i32)
dc_param_get_int((*msg).param, DC_PARAM_WIDTH as i32, 0)
}
pub unsafe fn dc_msg_get_height(msg: *const dc_msg_t) -> libc::c_int {
@@ -741,7 +746,7 @@ pub unsafe fn dc_msg_get_height(msg: *const dc_msg_t) -> libc::c_int {
return 0i32;
}
dc_param_get_int((*msg).param, 'h' as i32, 0i32)
dc_param_get_int((*msg).param, DC_PARAM_HEIGHT as i32, 0)
}
pub unsafe fn dc_msg_get_duration(msg: *const dc_msg_t) -> libc::c_int {
@@ -749,7 +754,7 @@ pub unsafe fn dc_msg_get_duration(msg: *const dc_msg_t) -> libc::c_int {
return 0;
}
dc_param_get_int((*msg).param, 'd' as i32, 0i32)
dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0)
}
// TODO should return bool /rtn
@@ -757,7 +762,7 @@ pub unsafe fn dc_msg_get_showpadlock(msg: *const dc_msg_t) -> libc::c_int {
if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint {
return 0i32;
}
if dc_param_get_int((*msg).param, 'c' as i32, 0i32) != 0i32 {
if dc_param_get_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) != 0i32 {
return 1i32;
}
@@ -840,13 +845,13 @@ pub unsafe fn dc_msg_get_summarytext_by_raw(
50 => prefix = dc_stock_str(context, 10i32),
41 => prefix = dc_stock_str(context, 7i32),
40 | 60 => {
if dc_param_get_int(param, 'S' as i32, 0i32) == 6i32 {
if dc_param_get_int(param, DC_PARAM_CMD as i32, 0) == 6i32 {
prefix = dc_stock_str(context, 42i32);
append_text = 0i32
} else {
pathNfilename = dc_param_get(
param,
'f' as i32,
DC_PARAM_FILE as i32,
b"ErrFilename\x00" as *const u8 as *const libc::c_char,
);
value = dc_get_filename(pathNfilename);
@@ -866,7 +871,7 @@ pub unsafe fn dc_msg_get_summarytext_by_raw(
}
}
_ => {
if dc_param_get_int(param, 'S' as i32, 0i32) == 9i32 {
if dc_param_get_int(param, DC_PARAM_CMD as i32, 0) == 9i32 {
prefix = dc_stock_str(context, 66i32);
append_text = 0i32
}
@@ -930,7 +935,7 @@ pub unsafe fn dc_msg_is_forwarded(msg: *const dc_msg_t) -> libc::c_int {
if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint {
return 0i32;
}
return if 0 != dc_param_get_int((*msg).param, 'a' as i32, 0i32) {
return if 0 != dc_param_get_int((*msg).param, DC_PARAM_FORWARDED as i32, 0) {
1i32
} else {
0i32
@@ -942,7 +947,7 @@ pub unsafe fn dc_msg_is_info(msg: *const dc_msg_t) -> libc::c_int {
if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint {
return 0i32;
}
let cmd: libc::c_int = dc_param_get_int((*msg).param, 'S' as i32, 0i32);
let cmd: libc::c_int = dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0);
if (*msg).from_id == 2i32 as libc::c_uint
|| (*msg).to_id == 2i32 as libc::c_uint
|| 0 != cmd && cmd != 6i32
@@ -976,7 +981,7 @@ pub unsafe fn dc_msg_is_setupmessage(msg: *const dc_msg_t) -> bool {
return false;
}
if dc_param_get_int((*msg).param, 'S' as i32, 0) == 6 {
if dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0) == 6 {
true
} else {
true
@@ -1050,23 +1055,23 @@ pub unsafe fn dc_msg_set_file(
if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint {
return;
}
dc_param_set((*msg).param, 'f' as i32, file);
dc_param_set((*msg).param, 'm' as i32, filemime);
dc_param_set((*msg).param, DC_PARAM_FILE as i32, file);
dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, filemime);
}
pub unsafe fn dc_msg_set_dimension(msg: *mut dc_msg_t, width: libc::c_int, height: libc::c_int) {
if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint {
return;
}
dc_param_set_int((*msg).param, 'w' as i32, width);
dc_param_set_int((*msg).param, 'h' as i32, height);
dc_param_set_int((*msg).param, DC_PARAM_WIDTH as i32, width);
dc_param_set_int((*msg).param, DC_PARAM_HEIGHT as i32, height);
}
pub unsafe fn dc_msg_set_duration(msg: *mut dc_msg_t, duration: libc::c_int) {
if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint {
return;
}
dc_param_set_int((*msg).param, 'd' as i32, duration);
dc_param_set_int((*msg).param, DC_PARAM_DURATION as i32, duration);
}
pub unsafe fn dc_msg_latefiling_mediasize(
@@ -1077,11 +1082,11 @@ pub unsafe fn dc_msg_latefiling_mediasize(
) {
if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) {
if width > 0i32 && height > 0i32 {
dc_param_set_int((*msg).param, 'w' as i32, width);
dc_param_set_int((*msg).param, 'h' as i32, height);
dc_param_set_int((*msg).param, DC_PARAM_WIDTH as i32, width);
dc_param_set_int((*msg).param, DC_PARAM_HEIGHT as i32, height);
}
if duration > 0i32 {
dc_param_set_int((*msg).param, 'd' as i32, duration);
dc_param_set_int((*msg).param, DC_PARAM_DURATION as i32, duration);
}
dc_msg_save_param_to_disk(msg);
};
@@ -1115,13 +1120,15 @@ pub unsafe fn dc_delete_msg_from_db(context: &Context, msg_id: uint32_t) {
&context.sql,
"DELETE FROM msgs WHERE id=?;",
params![(*msg).id as i32],
);
)
.ok();
sql::execute(
context,
&context.sql,
"DELETE FROM msgs_mdns WHERE msg_id=?;",
params![(*msg).id as i32],
);
)
.ok();
}
dc_msg_unref(msg);
}
@@ -1178,7 +1185,7 @@ pub unsafe fn dc_set_msg_failed(context: &Context, msg_id: uint32_t, error: *con
(*msg).state = 24
}
if !error.is_null() {
dc_param_set((*msg).param, 'L' as i32, error);
dc_param_set((*msg).param, DC_PARAM_ERROR as i32, error);
error!(context, 0, "{}", as_str(error),);
}

View File

@@ -3,59 +3,61 @@ use crate::types::*;
use crate::x::*;
/// for msgs and jobs
pub const DC_PARAM_FILE: char = 'f';
pub const DC_PARAM_FILE: char = 'f'; // string
/// for msgs
pub const DC_PARAM_WIDTH: char = 'w';
pub const DC_PARAM_WIDTH: char = 'w'; // int
/// for msgs
pub const DC_PARAM_HEIGHT: char = 'h';
pub const DC_PARAM_HEIGHT: char = 'h'; // int
/// for msgs
pub const DC_PARAM_DURATION: char = 'd';
pub const DC_PARAM_DURATION: char = 'd'; // int
/// for msgs
pub const DC_PARAM_MIMETYPE: char = 'm';
pub const DC_PARAM_MIMETYPE: char = 'm'; // string
/// for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send
pub const DC_PARAM_GUARANTEE_E2EE: char = 'c';
pub const DC_PARAM_GUARANTEE_E2EE: char = 'c'; // int (bool?)
/// for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted
pub const DC_PARAM_ERRONEOUS_E2EE: char = 'e';
pub const DC_PARAM_ERRONEOUS_E2EE: char = 'e'; // int
/// for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0
pub const DC_PARAM_FORCE_PLAINTEXT: char = 'u';
pub const DC_PARAM_FORCE_PLAINTEXT: char = 'u'; // int (bool?)
/// for msgs: an incoming message which requests a MDN (aka read receipt)
pub const DC_PARAM_WANTS_MDN: char = 'r';
pub const DC_PARAM_WANTS_MDN: char = 'r'; // int (bool?)
/// for msgs
pub const DC_PARAM_FORWARDED: char = 'a';
pub const DC_PARAM_FORWARDED: char = 'a'; // int (bool?)
/// for msgs
pub const DC_PARAM_CMD: char = 'S';
pub const DC_PARAM_CMD: char = 'S'; // int
/// for msgs
pub const DC_PARAM_CMD_ARG: char = 'E';
pub const DC_PARAM_CMD_ARG: char = 'E'; // string
/// for msgs
pub const DC_PARAM_CMD_ARG2: char = 'F';
pub const DC_PARAM_CMD_ARG2: char = 'F'; // string
/// for msgs
pub const DC_PARAM_CMD_ARG3: char = 'G';
pub const DC_PARAM_CMD_ARG3: char = 'G'; // string
/// for msgs
pub const DC_PARAM_CMD_ARG4: char = 'H';
pub const DC_PARAM_CMD_ARG4: char = 'H'; // string
/// for msgs
pub const DC_PARAM_ERROR: char = 'L';
pub const DC_PARAM_ERROR: char = 'L'; // string
/// for msgs in PREPARING: space-separated list of message IDs of forwarded copies
pub const DC_PARAM_PREP_FORWARDS: char = 'P';
pub const DC_PARAM_PREP_FORWARDS: char = 'P'; // string
/// for msgs
pub const DC_PARAM_SET_LATITUDE: char = 'l';
pub const DC_PARAM_SET_LATITUDE: char = 'l'; // float
/// for msgs
pub const DC_PARAM_SET_LONGITUDE: char = 'n';
pub const DC_PARAM_SET_LONGITUDE: char = 'n'; // float
/// for jobs
pub const DC_PARAM_SERVER_FOLDER: char = 'Z';
pub const DC_PARAM_SERVER_FOLDER: char = 'Z'; // string
/// for jobs
pub const DC_PARAM_SERVER_UID: char = 'z';
pub const DC_PARAM_SERVER_UID: char = 'z'; // int
/// for jobs
pub const DC_PARAM_ALSO_MOVE: char = 'M';
pub const DC_PARAM_ALSO_MOVE: char = 'M'; // int (bool?)
/// for jobs: space-separated list of message recipients
pub const DC_PARAM_RECIPIENTS: char = 'R';
pub const DC_PARAM_RECIPIENTS: char = 'R'; // stringap
/// for groups
pub const DC_PARAM_UNPROMOTED: char = 'U';
pub const DC_PARAM_UNPROMOTED: char = 'U'; // int (bool?)
/// for groups and contacts
pub const DC_PARAM_PROFILE_IMAGE: char = 'i';
pub const DC_PARAM_PROFILE_IMAGE: char = 'i'; // string (bytes?)
/// for chats
pub const DC_PARAM_SELFTALK: char = 'K';
// missing: 's', 'x', 'g'
// values for DC_PARAM_FORCE_PLAINTEXT
pub const DC_FP_ADD_AUTOCRYPT_HEADER: u8 = 1;
pub const DC_FP_NO_AUTOCRYPT_HEADER: u8 = 2;

View File

@@ -56,16 +56,23 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
fragment = fragment.offset(1isize);
let param: *mut dc_param_t = dc_param_new();
dc_param_set_urlencoded(param, fragment);
addr = dc_param_get(param, 'a' as i32, 0 as *const libc::c_char);
addr = dc_param_get(param, DC_PARAM_FORWARDED as i32, 0 as *const libc::c_char);
if !addr.is_null() {
let mut urlencoded: *mut libc::c_char =
dc_param_get(param, 'n' as i32, 0 as *const libc::c_char);
let mut urlencoded: *mut libc::c_char = dc_param_get(
param,
DC_PARAM_SET_LONGITUDE as i32,
0 as *const libc::c_char,
);
if !urlencoded.is_null() {
name = dc_urldecode(urlencoded);
dc_normalize_name(name);
free(urlencoded as *mut libc::c_void);
}
invitenumber = dc_param_get(param, 'i' as i32, 0 as *const libc::c_char);
invitenumber = dc_param_get(
param,
DC_PARAM_PROFILE_IMAGE as i32,
0 as *const libc::c_char,
);
auth = dc_param_get(param, 's' as i32, 0 as *const libc::c_char);
grpid = dc_param_get(param, 'x' as i32, 0 as *const libc::c_char);
if !grpid.is_null() {

View File

@@ -215,7 +215,9 @@ pub unsafe fn dc_receive_imf(
maybe this can be optimized later,
by checking the state before the message body is downloaded */
let mut allow_creation: libc::c_int = 1;
if msgrmsg == 0 {
if mime_parser.is_system_message != DC_CMD_AUTOCRYPT_SETUP_MESSAGE
&& msgrmsg == 0
{
let show_emails = context
.sql
.get_config_int(context, "show_emails")
@@ -513,9 +515,7 @@ pub unsafe fn dc_receive_imf(
(*part).bytes,
hidden,
if 0 != save_mime_headers {
let body_string = unsafe {
std::str::from_utf8(std::slice::from_raw_parts(imf_raw_not_terminated as *const u8, imf_raw_bytes)).unwrap()
};
let body_string = std::str::from_utf8(std::slice::from_raw_parts(imf_raw_not_terminated as *const u8, imf_raw_bytes)).unwrap();
Some(body_string)
} else {
@@ -745,16 +745,24 @@ pub unsafe fn dc_receive_imf(
if 0 != mime_parser.is_send_by_messenger || 0 != mdn_consumed {
let param = dc_param_new();
let server_folder_c = to_cstring(server_folder.as_ref());
dc_param_set(param, 'Z' as i32, server_folder_c);
dc_param_set(
param,
DC_PARAM_SERVER_FOLDER as i32,
server_folder_c,
);
free(server_folder_c as *mut _);
dc_param_set_int(param, 'z' as i32, server_uid as i32);
dc_param_set_int(
param,
DC_PARAM_SERVER_UID as i32,
server_uid as i32,
);
if 0 != mime_parser.is_send_by_messenger
&& 0 != context
.sql
.get_config_int(context, "mvbox_move")
.unwrap_or_else(|| 1)
{
dc_param_set_int(param, 'M' as i32, 1);
dc_param_set_int(param, DC_PARAM_ALSO_MOVE as i32, 1);
}
dc_job_add(context, 120, 0, (*param).packed, 0);
dc_param_unref(param);
@@ -1221,7 +1229,7 @@ unsafe fn create_or_lookup_group(
if (*part).type_0 == 20 {
grpimage = dc_param_get(
(*part).param,
'f' as i32,
DC_PARAM_FILE as i32,
0 as *const libc::c_char,
);
ok = 1
@@ -1242,7 +1250,11 @@ unsafe fn create_or_lookup_group(
},
);
dc_chat_load_from_db(chat, chat_id);
dc_param_set((*chat).param, 'i' as i32, grpimage);
dc_param_set(
(*chat).param,
DC_PARAM_PROFILE_IMAGE as i32,
grpimage,
);
dc_chat_update_param(chat);
dc_chat_unref(chat);
free(grpimage as *mut libc::c_void);
@@ -1260,7 +1272,8 @@ unsafe fn create_or_lookup_group(
&context.sql,
"DELETE FROM chats_contacts WHERE chat_id=?;",
params![chat_id as i32],
);
)
.ok();
if skip.is_null() || !dc_addr_cmp(&self_addr, as_str(skip)) {
dc_add_to_chat_contacts_table(context, chat_id, 1);
}

View File

@@ -267,23 +267,23 @@ unsafe fn send_handshake_msg(
step,
);
(*msg).hidden = 1i32;
dc_param_set_int((*msg).param, 'S' as i32, 7i32);
dc_param_set((*msg).param, 'E' as i32, step);
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 7);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, step);
if !param2.is_null() {
dc_param_set((*msg).param, 'F' as i32, param2);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG2 as i32, param2);
}
if !fingerprint.is_null() {
dc_param_set((*msg).param, 'G' as i32, fingerprint);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG3 as i32, fingerprint);
}
if !grpid.is_null() {
dc_param_set((*msg).param, 'H' as i32, grpid);
dc_param_set((*msg).param, DC_PARAM_CMD_ARG4 as i32, grpid);
}
if strcmp(step, b"vg-request\x00" as *const u8 as *const libc::c_char) == 0i32
|| strcmp(step, b"vc-request\x00" as *const u8 as *const libc::c_char) == 0i32
{
dc_param_set_int((*msg).param, 'u' as i32, 1i32);
dc_param_set_int((*msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 1);
} else {
dc_param_set_int((*msg).param, 'c' as i32, 1i32);
dc_param_set_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
}
dc_send_msg(context, contact_chat_id, msg);
dc_msg_unref(msg);

View File

@@ -1078,40 +1078,28 @@ pub unsafe fn dc_get_abs_path(
context: &Context,
pathNfilename: *const libc::c_char,
) -> *mut libc::c_char {
let current_block: u64;
let mut success: libc::c_int = 0i32;
let mut pathNfilename_abs: *mut libc::c_char = 0 as *mut libc::c_char;
if !pathNfilename.is_null() {
pathNfilename_abs = dc_strdup(pathNfilename);
if strncmp(
pathNfilename_abs,
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
8,
) == 0i32
{
if !context.has_blobdir() {
current_block = 3805228753452640762;
} else {
dc_str_replace(
&mut pathNfilename_abs,
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
context.get_blobdir(),
);
current_block = 6937071982253665452;
}
} else {
current_block = 6937071982253665452;
}
match current_block {
3805228753452640762 => {}
_ => success = 1i32,
}
}
if 0 == success {
free(pathNfilename_abs as *mut libc::c_void);
pathNfilename_abs = 0 as *mut libc::c_char
if pathNfilename.is_null() {
return 0 as *mut libc::c_char;
}
let starts = strncmp(
pathNfilename,
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
8,
) == 0i32;
if starts && !context.has_blobdir() {
return 0 as *mut libc::c_char;
}
let mut pathNfilename_abs: *mut libc::c_char = dc_strdup(pathNfilename);
if starts && context.has_blobdir() {
dc_str_replace(
&mut pathNfilename_abs,
b"$BLOBDIR\x00" as *const u8 as *const libc::c_char,
context.get_blobdir(),
);
}
pathNfilename_abs
}

View File

@@ -1622,18 +1622,25 @@ impl Imap {
}
}
context.sql.set_config_int(context, "folders_configured", 3);
context
.sql
.set_config_int(context, "folders_configured", 3)
.ok();
if let Some(ref mvbox_folder) = mvbox_folder {
context
.sql
.set_config(context, "configured_mvbox_folder", Some(mvbox_folder));
.set_config(context, "configured_mvbox_folder", Some(mvbox_folder))
.ok();
}
if let Some(ref sentbox_folder) = sentbox_folder {
context.sql.set_config(
context,
"configured_sentbox_folder",
Some(sentbox_folder.name()),
);
context
.sql
.set_config(
context,
"configured_sentbox_folder",
Some(sentbox_folder.name()),
)
.ok();
}
}

View File

@@ -48,11 +48,17 @@ pub fn dc_get_oauth2_url(
redirect_uri: impl AsRef<str>,
) -> Option<String> {
if let Some(oauth2) = Oauth2::from_address(addr) {
context.sql.set_config(
context,
"oauth2_pending_redirect_uri",
Some(redirect_uri.as_ref()),
);
if context
.sql
.set_config(
context,
"oauth2_pending_redirect_uri",
Some(redirect_uri.as_ref()),
)
.is_err()
{
return None;
}
let oauth2_url = replace_in_uri(&oauth2.get_code, "$CLIENT_ID", &oauth2.client_id);
let oauth2_url = replace_in_uri(&oauth2_url, "$REDIRECT_URI", redirect_uri.as_ref());
@@ -157,10 +163,12 @@ pub fn dc_get_oauth2_access_token(
if let Some(ref token) = response.refresh_token {
context
.sql
.set_config(context, "oauth2_refresh_token", Some(token));
.set_config(context, "oauth2_refresh_token", Some(token))
.ok();
context
.sql
.set_config(context, "oauth2_refresh_token_for", Some(code.as_ref()));
.set_config(context, "oauth2_refresh_token_for", Some(code.as_ref()))
.ok();
}
// after that, save the access token.
@@ -168,7 +176,8 @@ pub fn dc_get_oauth2_access_token(
if let Some(ref token) = response.access_token {
context
.sql
.set_config(context, "oauth2_access_token", Some(token));
.set_config(context, "oauth2_access_token", Some(token))
.ok();
let expires_in = response
.expires_in
// refresh a bet before
@@ -176,12 +185,14 @@ pub fn dc_get_oauth2_access_token(
.unwrap_or_else(|| 0);
context
.sql
.set_config_int64(context, "oauth2_timestamp_expires", expires_in);
.set_config_int64(context, "oauth2_timestamp_expires", expires_in)
.ok();
if update_redirect_uri_on_success {
context
.sql
.set_config(context, "oauth2_redirect_uri", Some(redirect_uri.as_ref()));
.set_config(context, "oauth2_redirect_uri", Some(redirect_uri.as_ref()))
.ok();
}
} else {
warn!(context, 0, "Failed to find OAuth2 access token");

View File

@@ -141,6 +141,7 @@ impl Sql {
})
}
/// Execute a query which is expected to return one row.
pub fn query_row<T, P, F>(&self, sql: impl AsRef<str>, params: P, f: F) -> Result<T>
where
P: IntoIterator,
@@ -184,7 +185,9 @@ impl Sql {
}
/// Set private configuration options.
/// Setting `None` deletes the value.
///
/// Setting `None` deletes the value. On failure an error message
/// will already have been logged.
pub fn set_config(
&self,
context: &Context,
@@ -459,7 +462,7 @@ fn open(
// cannot create the tables - maybe we cannot write?
return Err(Error::SqlFailedToOpen);
} else {
sql.set_config_int(context, "dbversion", 0);
sql.set_config_int(context, "dbversion", 0)?;
}
} else {
exists_before_update = 1;
@@ -484,7 +487,7 @@ fn open(
params![],
)?;
dbversion = 1;
sql.set_config_int(context, "dbversion", 1);
sql.set_config_int(context, "dbversion", 1)?;
}
if dbversion < 2 {
sql.execute(
@@ -492,7 +495,7 @@ fn open(
params![],
)?;
dbversion = 2;
sql.set_config_int(context, "dbversion", 2);
sql.set_config_int(context, "dbversion", 2)?;
}
if dbversion < 7 {
sql.execute(
@@ -506,7 +509,7 @@ fn open(
params![],
)?;
dbversion = 7;
sql.set_config_int(context, "dbversion", 7);
sql.set_config_int(context, "dbversion", 7)?;
}
if dbversion < 10 {
sql.execute(
@@ -524,7 +527,7 @@ fn open(
params![],
)?;
dbversion = 10;
sql.set_config_int(context, "dbversion", 10);
sql.set_config_int(context, "dbversion", 10)?;
}
if dbversion < 12 {
sql.execute(
@@ -536,7 +539,7 @@ fn open(
params![],
)?;
dbversion = 12;
sql.set_config_int(context, "dbversion", 12);
sql.set_config_int(context, "dbversion", 12)?;
}
if dbversion < 17 {
sql.execute(
@@ -550,7 +553,7 @@ fn open(
)?;
sql.execute("CREATE INDEX msgs_index5 ON msgs (starred);", params![])?;
dbversion = 17;
sql.set_config_int(context, "dbversion", 17);
sql.set_config_int(context, "dbversion", 17)?;
}
if dbversion < 18 {
sql.execute(
@@ -559,7 +562,7 @@ fn open(
)?;
sql.execute("ALTER TABLE acpeerstates ADD COLUMN gossip_key;", params![])?;
dbversion = 18;
sql.set_config_int(context, "dbversion", 18);
sql.set_config_int(context, "dbversion", 18)?;
}
if dbversion < 27 {
sql.execute("DELETE FROM msgs WHERE chat_id=1 OR chat_id=2;", params![])?;
@@ -576,7 +579,7 @@ fn open(
params![],
)?;
dbversion = 27;
sql.set_config_int(context, "dbversion", 27);
sql.set_config_int(context, "dbversion", 27)?;
}
if dbversion < 34 {
sql.execute(
@@ -605,7 +608,7 @@ fn open(
)?;
recalc_fingerprints = 1;
dbversion = 34;
sql.set_config_int(context, "dbversion", 34);
sql.set_config_int(context, "dbversion", 34)?;
}
if dbversion < 39 {
sql.execute(
@@ -635,7 +638,7 @@ fn open(
)?;
}
dbversion = 39;
sql.set_config_int(context, "dbversion", 39);
sql.set_config_int(context, "dbversion", 39)?;
}
if dbversion < 40 {
sql.execute(
@@ -643,22 +646,22 @@ fn open(
params![],
)?;
dbversion = 40;
sql.set_config_int(context, "dbversion", 40);
sql.set_config_int(context, "dbversion", 40)?;
}
if dbversion < 41 {
update_file_paths = 1;
dbversion = 41;
sql.set_config_int(context, "dbversion", 41);
sql.set_config_int(context, "dbversion", 41)?;
}
if dbversion < 42 {
sql.execute("UPDATE msgs SET txt='' WHERE type!=10", params![])?;
dbversion = 42;
sql.set_config_int(context, "dbversion", 42);
sql.set_config_int(context, "dbversion", 42)?;
}
if dbversion < 44 {
sql.execute("ALTER TABLE msgs ADD COLUMN mime_headers TEXT;", params![])?;
dbversion = 44;
sql.set_config_int(context, "dbversion", 44);
sql.set_config_int(context, "dbversion", 44)?;
}
if dbversion < 46 {
sql.execute(
@@ -670,7 +673,7 @@ fn open(
params![],
)?;
dbversion = 46;
sql.set_config_int(context, "dbversion", 46);
sql.set_config_int(context, "dbversion", 46)?;
}
if dbversion < 47 {
info!(context, 0, "[migration] v47");
@@ -679,7 +682,7 @@ fn open(
params![],
)?;
dbversion = 47;
sql.set_config_int(context, "dbversion", 47);
sql.set_config_int(context, "dbversion", 47)?;
}
if dbversion < 48 {
info!(context, 0, "[migration] v48");
@@ -693,7 +696,7 @@ fn open(
assert_eq!(DC_MOVE_STATE_MOVING as libc::c_int, 3);
dbversion = 48;
sql.set_config_int(context, "dbversion", 48);
sql.set_config_int(context, "dbversion", 48)?;
}
if dbversion < 49 {
info!(context, 0, "[migration] v49");
@@ -702,15 +705,15 @@ fn open(
params![],
)?;
dbversion = 49;
sql.set_config_int(context, "dbversion", 49);
sql.set_config_int(context, "dbversion", 49)?;
}
if dbversion < 50 {
info!(context, 0, "[migration] v50");
if 0 != exists_before_update {
sql.set_config_int(context, "show_emails", 2);
sql.set_config_int(context, "show_emails", 2)?;
}
dbversion = 50;
sql.set_config_int(context, "dbversion", 50);
sql.set_config_int(context, "dbversion", 50)?;
}
if dbversion < 53 {
info!(context, 0, "[migration] v53");
@@ -743,7 +746,7 @@ fn open(
params![],
)?;
dbversion = 53;
sql.set_config_int(context, "dbversion", 53);
sql.set_config_int(context, "dbversion", 53)?;
}
if dbversion < 54 {
info!(context, 0, "[migration] v54");
@@ -753,7 +756,7 @@ fn open(
)?;
sql.execute("CREATE INDEX msgs_index6 ON msgs (location_id);", params![])?;
dbversion = 54;
sql.set_config_int(context, "dbversion", 54);
sql.set_config_int(context, "dbversion", 54)?;
}
if dbversion < 55 {
sql.execute(
@@ -761,7 +764,7 @@ fn open(
params![],
)?;
sql.set_config_int(context, "dbversion", 55);
sql.set_config_int(context, "dbversion", 55)?;
}
if 0 != recalc_fingerprints {
@@ -809,7 +812,7 @@ fn open(
NO_PARAMS,
)?;
sql.set_config(context, "backup_for", None);
sql.set_config(context, "backup_for", None)?;
}
}