mirror of
https://github.com/chatmail/core.git
synced 2026-04-10 01:22:11 +03:00
Compare commits
48 Commits
fix_unshow
...
eventloggi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bc5d1b90e | ||
|
|
197d94ad9d | ||
|
|
7ce337c6d0 | ||
|
|
10148d2e43 | ||
|
|
69dc237ee3 | ||
|
|
df5464ea80 | ||
|
|
e4bf9956a5 | ||
|
|
d353d9d9d8 | ||
|
|
1ad45ed4d6 | ||
|
|
496e980a17 | ||
|
|
fa09e46ed9 | ||
|
|
d6de420b9a | ||
|
|
38eb708db8 | ||
|
|
7a59da5f8f | ||
|
|
f13a1d4a2f | ||
|
|
7b3a450918 | ||
|
|
169923b102 | ||
|
|
42688a0622 | ||
|
|
35f3c0edd1 | ||
|
|
e7a236264a | ||
|
|
aaa5b820d9 | ||
|
|
e7f0745010 | ||
|
|
c68e7ae14e | ||
|
|
618087e5a7 | ||
|
|
245abb8384 | ||
|
|
a3e1042001 | ||
|
|
7b7ce9348f | ||
|
|
7a4808ba0d | ||
|
|
8f240f7153 | ||
|
|
7d0b5d8abb | ||
|
|
ee317cb1b5 | ||
|
|
7b736fe635 | ||
|
|
c7db15352a | ||
|
|
0b37167be8 | ||
|
|
5cac4b5076 | ||
|
|
475a41beb3 | ||
|
|
ad4be80b4e | ||
|
|
8737c1d142 | ||
|
|
964fe466cc | ||
|
|
43936e7db7 | ||
|
|
0e80ce9c39 | ||
|
|
c652bae68a | ||
|
|
bc904a495d | ||
|
|
8d99444c6a | ||
|
|
9dab53e0af | ||
|
|
360089ac74 | ||
|
|
e892c5cf4d | ||
|
|
9ad4c9a6fe |
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -1093,7 +1093,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.2.3"
|
||||
version = "0.2.2"
|
||||
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.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide 0.2.2 (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.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot_core 0.6.1 (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.2"
|
||||
version = "0.6.1"
|
||||
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.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5f6d7b3dd914b70db7cef7ab9dc74339ffcadf4d033464a987237bb0b9418cd4"
|
||||
"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d"
|
||||
"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.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
|
||||
"checksum parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a7bbaa05312363e0480e1efee133fff1a09ef4a6406b65e226b9a793c223a32"
|
||||
"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"
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
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();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
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}
|
||||
@@ -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![]).unwrap();
|
||||
sql::execute(context, &context.sql, "DELETE FROM jobs;", params![]);
|
||||
info!(context, 0, "(1) Jobs reset.");
|
||||
}
|
||||
if 0 != bits & 2 {
|
||||
@@ -37,12 +37,11 @@ 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![]).unwrap();
|
||||
sql::execute(context, &context.sql, "DELETE FROM keypairs;", params![]);
|
||||
info!(context, 0, "(4) Private keypairs reset.");
|
||||
}
|
||||
if 0 != bits & 8 {
|
||||
@@ -51,37 +50,32 @@ 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![],
|
||||
)
|
||||
.unwrap();
|
||||
sql::execute(context, &context.sql, "DELETE FROM leftgrps;", params![]).unwrap();
|
||||
);
|
||||
sql::execute(context, &context.sql, "DELETE FROM leftgrps;", params![]);
|
||||
info!(context, 0, "(8) Rest but server config reset.");
|
||||
}
|
||||
|
||||
@@ -135,8 +129,7 @@ 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)))
|
||||
.unwrap();
|
||||
.set_config(context, "import_spec", Some(as_str(real_spec)));
|
||||
current_block = 7149356873433890176;
|
||||
} else {
|
||||
let rs = context.sql.get_config(context, "import_spec");
|
||||
|
||||
@@ -86,9 +86,8 @@ 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"))
|
||||
.unwrap();
|
||||
ctx.set_config(config::Config::MailPw, Some(&pw)).unwrap();
|
||||
ctx.set_config(config::Config::Addr, Some("d@testrun.org"));
|
||||
ctx.set_config(config::Config::MailPw, Some(&pw));
|
||||
dc_configure(&ctx);
|
||||
|
||||
thread::sleep(duration);
|
||||
|
||||
@@ -31,7 +31,6 @@ def ffibuilder():
|
||||
libs = ['deltachat']
|
||||
objs = []
|
||||
incs = []
|
||||
extra_link_args = []
|
||||
builder = cffi.FFI()
|
||||
builder.set_source(
|
||||
'deltachat.capi',
|
||||
@@ -71,8 +70,8 @@ def ffibuilder():
|
||||
distutils.sysconfig.customize_compiler(cc)
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
try:
|
||||
src_name = os.path.join(tmpdir, "include.h")
|
||||
dst_name = os.path.join(tmpdir, "expanded.h")
|
||||
src_name = os.path.join(tmpdir, "prep.h")
|
||||
dst_name = os.path.join(tmpdir, "prep2.c")
|
||||
with open(src_name, "w") as src_fp:
|
||||
src_fp.write('#include <deltachat.h>')
|
||||
cc.preprocess(source=src_name,
|
||||
|
||||
@@ -16,14 +16,6 @@ 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
|
||||
@@ -43,14 +35,10 @@ def pytest_report_header(config, startdir):
|
||||
ac.shutdown()
|
||||
finally:
|
||||
os.remove(t)
|
||||
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
|
||||
return "Deltachat core={} sqlite={}".format(
|
||||
info['deltachat_core_version'],
|
||||
info['sqlite_version'],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@@ -86,7 +74,7 @@ def acfactory(pytestconfig, tmpdir, request):
|
||||
def configlist(self):
|
||||
configlist = []
|
||||
for line in open(fn):
|
||||
if line.strip() and not line.strip().startswith('#'):
|
||||
if line.strip():
|
||||
d = {}
|
||||
for part in line.split():
|
||||
name, value = part.split("=")
|
||||
|
||||
@@ -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_accounts_send_receive(self, acfactory):
|
||||
def test_two_acocunts_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,48 +294,13 @@ class TestOnlineAccount:
|
||||
wait_successful_IMAP_SMTP_connection(ac2)
|
||||
wait_configuration_progress(ac2, 1000)
|
||||
|
||||
txt = "message1"
|
||||
msg_out = chat.send_text(txt)
|
||||
msg_out = chat.send_text("message1")
|
||||
|
||||
# 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 == 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
|
||||
assert msg_in.text == "message1"
|
||||
|
||||
def test_forward_messages(self, acfactory):
|
||||
ac1 = acfactory.get_online_configuring_account()
|
||||
|
||||
@@ -13,8 +13,6 @@ commands =
|
||||
passenv =
|
||||
TRAVIS
|
||||
DCC_RS_DEV
|
||||
DCC_RS_TARGET
|
||||
DCC_PY_LIVECONFIG
|
||||
deps =
|
||||
pytest
|
||||
pytest-faulthandler
|
||||
|
||||
@@ -23,10 +23,11 @@ if [ $? != 0 ]; then
|
||||
fi
|
||||
|
||||
pushd python
|
||||
if [ -e "./liveconfig" ]; then
|
||||
export DCC_PY_LIVECONFIG=liveconfig
|
||||
toxargs="$@"
|
||||
if [ -e liveconfig ]; then
|
||||
toxargs="--liveconfig liveconfig $@"
|
||||
fi
|
||||
tox "$@"
|
||||
tox $toxargs
|
||||
ret=$?
|
||||
popd
|
||||
exit $ret
|
||||
|
||||
@@ -491,12 +491,3 @@ 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;
|
||||
|
||||
@@ -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).ok();
|
||||
context.sql.set_config(context, as_str(key), v);
|
||||
}
|
||||
|
||||
/* *
|
||||
|
||||
187
src/dc_chat.rs
187
src/dc_chat.rs
@@ -152,16 +152,6 @@ 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 {
|
||||
@@ -184,7 +174,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, DC_PARAM_SELFTALK as i32) } {
|
||||
if 0 != unsafe { dc_param_exists((*chat).param, 'K' as i32) } {
|
||||
unsafe {
|
||||
free((*chat).name as *mut libc::c_void);
|
||||
(*chat).name = dc_stock_str((*chat).context, 2);
|
||||
@@ -194,6 +184,16 @@ 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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
pathNfilename = dc_param_get((*msg).param, 'f' 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, DC_PARAM_FILE as i32, pathNfilename);
|
||||
dc_param_set((*msg).param, 'f' 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, DC_PARAM_MIMETYPE as i32, better_mime);
|
||||
dc_param_set((*msg).param, 'm' as i32, better_mime);
|
||||
}
|
||||
free(better_mime as *mut libc::c_void);
|
||||
} else if 0 == dc_param_exists((*msg).param, DC_PARAM_MIMETYPE as i32) {
|
||||
} else if 0 == dc_param_exists((*msg).param, 'm' 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, DC_PARAM_MIMETYPE as i32, better_mime_0);
|
||||
dc_param_set((*msg).param, 'm' as i32, better_mime_0);
|
||||
free(better_mime_0 as *mut libc::c_void);
|
||||
}
|
||||
info!(
|
||||
@@ -529,12 +529,8 @@ unsafe fn prepare_msg_raw(
|
||||
}
|
||||
} else {
|
||||
if (*chat).type_0 == 120 || (*chat).type_0 == 130 {
|
||||
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,
|
||||
);
|
||||
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);
|
||||
dc_chat_update_param(chat);
|
||||
}
|
||||
}
|
||||
@@ -552,9 +548,7 @@ 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, DC_PARAM_FORCE_PLAINTEXT as i32, 0) == 0
|
||||
{
|
||||
if 0 != e2ee_enabled && dc_param_get_int((*msg).param, 'u' as i32, 0) == 0 {
|
||||
let mut can_encrypt = 1;
|
||||
let mut all_mutual = 1;
|
||||
|
||||
@@ -609,13 +603,9 @@ unsafe fn prepare_msg_raw(
|
||||
}
|
||||
}
|
||||
if 0 != do_guarantee_e2ee {
|
||||
dc_param_set_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
|
||||
dc_param_set_int((*msg).param, 'c' as i32, 1);
|
||||
}
|
||||
dc_param_set(
|
||||
(*msg).param,
|
||||
DC_PARAM_ERRONEOUS_E2EE as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
dc_param_set((*msg).param, 'e' as i32, 0 as *const libc::c_char);
|
||||
if 0 == dc_chat_is_self_talk(chat)
|
||||
&& 0 != get_parent_mime_headers(
|
||||
chat,
|
||||
@@ -815,7 +805,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, DC_PARAM_SELFTALK as i32)
|
||||
dc_param_exists((*chat).param, 'K' as i32)
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -843,7 +833,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, DC_PARAM_GUARANTEE_E2EE as i32) {
|
||||
if 0 != dc_param_exists(msg_param, 'c' as i32) {
|
||||
last_is_encrypted = 1;
|
||||
}
|
||||
dc_param_unref(msg_param);
|
||||
@@ -880,15 +870,13 @@ 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>(
|
||||
@@ -923,11 +911,7 @@ pub unsafe fn dc_send_msg<'a>(
|
||||
}
|
||||
|
||||
if 0 == chat_id {
|
||||
let forwards = dc_param_get(
|
||||
(*msg).param,
|
||||
DC_PARAM_PREP_FORWARDS as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let forwards = dc_param_get((*msg).param, 'P' as i32, 0 as *const libc::c_char);
|
||||
if !forwards.is_null() {
|
||||
let mut p = forwards;
|
||||
while 0 != *p {
|
||||
@@ -943,11 +927,7 @@ pub unsafe fn dc_send_msg<'a>(
|
||||
dc_msg_unref(copy);
|
||||
}
|
||||
}
|
||||
dc_param_set(
|
||||
(*msg).param,
|
||||
DC_PARAM_PREP_FORWARDS as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
dc_param_set((*msg).param, 'P' as i32, 0 as *const libc::c_char);
|
||||
dc_msg_save_param_to_disk(msg);
|
||||
}
|
||||
free(forwards as *mut libc::c_void);
|
||||
@@ -1007,8 +987,7 @@ 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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
|
||||
if pathNfilename.is_null() {
|
||||
current_block = 14513523936503887211;
|
||||
} else if 0 != dc_msg_is_increation(msg)
|
||||
@@ -1018,7 +997,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, DC_PARAM_FILE as i32, pathNfilename);
|
||||
dc_param_set((*msg).param, 'f' as i32, pathNfilename);
|
||||
current_block = 4495394744059808450;
|
||||
}
|
||||
} else {
|
||||
@@ -1580,14 +1559,8 @@ 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, DC_PARAM_UNPROMOTED as i32, 0) == 1
|
||||
{
|
||||
dc_param_set(
|
||||
(*chat).param,
|
||||
DC_PARAM_UNPROMOTED as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
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);
|
||||
dc_chat_update_param(chat);
|
||||
}
|
||||
let self_addr = context
|
||||
@@ -1635,7 +1608,7 @@ pub unsafe fn dc_add_contact_to_chat_ex(
|
||||
match current_block {
|
||||
12326129973959287090 => {}
|
||||
_ => {
|
||||
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 0 {
|
||||
if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 {
|
||||
(*msg).type_0 = 10;
|
||||
(*msg).text = dc_stock_system_msg(
|
||||
context,
|
||||
@@ -1644,13 +1617,9 @@ 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, 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);
|
||||
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);
|
||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||
context.call_cb(
|
||||
Event::MSGS_CHANGED,
|
||||
@@ -1697,7 +1666,6 @@ 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!(
|
||||
@@ -1710,8 +1678,7 @@ 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,
|
||||
@@ -1722,8 +1689,7 @@ pub fn dc_set_gossiped_timestamp(context: &Context, chat_id: u32, timestamp: i64
|
||||
&context.sql,
|
||||
"UPDATE chats SET gossiped_timestamp=?;",
|
||||
params![timestamp],
|
||||
)
|
||||
.ok();
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1754,7 +1720,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, DC_PARAM_UNPROMOTED as i32, 0) == 0 {
|
||||
if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 {
|
||||
(*msg).type_0 = 10;
|
||||
if (*contact).id == 1 as libc::c_uint {
|
||||
dc_set_group_explicitly_left(context, (*chat).grpid);
|
||||
@@ -1774,8 +1740,8 @@ pub unsafe fn dc_remove_contact_from_chat(
|
||||
1 as uint32_t,
|
||||
)
|
||||
}
|
||||
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);
|
||||
dc_param_set_int((*msg).param, 'S' as i32, 5);
|
||||
dc_param_set((*msg).param, 'E' as i32, (*contact).addr);
|
||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||
context.call_cb(
|
||||
Event::MSGS_CHANGED,
|
||||
@@ -1806,7 +1772,6 @@ 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(
|
||||
@@ -1814,8 +1779,7 @@ 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();
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1869,7 +1833,7 @@ pub unsafe fn dc_set_chat_name(
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32) == 0i32 {
|
||||
if dc_param_get_int((*chat).param, 'U' as i32, 0i32) == 0i32 {
|
||||
(*msg).type_0 = 10i32;
|
||||
(*msg).text = dc_stock_system_msg(
|
||||
context,
|
||||
@@ -1878,8 +1842,8 @@ pub unsafe fn dc_set_chat_name(
|
||||
new_name,
|
||||
1i32 as uint32_t,
|
||||
);
|
||||
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);
|
||||
dc_param_set_int((*msg).param, 'S' as i32, 2i32);
|
||||
dc_param_set((*msg).param, 'E' as i32, (*chat).name);
|
||||
(*msg).id = dc_send_msg(context, chat_id, msg);
|
||||
context.call_cb(
|
||||
Event::MSGS_CHANGED,
|
||||
@@ -1939,13 +1903,11 @@ pub unsafe fn dc_set_chat_profile_image(
|
||||
match current_block {
|
||||
14766584022300871387 => {}
|
||||
_ => {
|
||||
dc_param_set((*chat).param, DC_PARAM_PROFILE_IMAGE as i32, new_image_rel);
|
||||
dc_param_set((*chat).param, 'i' as i32, new_image_rel);
|
||||
if !(0 == dc_chat_update_param(chat)) {
|
||||
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);
|
||||
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);
|
||||
(*msg).type_0 = 10i32;
|
||||
(*msg).text = dc_stock_system_msg(
|
||||
context,
|
||||
@@ -2008,39 +1970,28 @@ 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),
|
||||
)
|
||||
.unwrap(); // TODO: better error handling
|
||||
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),
|
||||
);
|
||||
|
||||
for id in ids {
|
||||
for id in ids.unwrap() {
|
||||
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, DC_PARAM_FORWARDED as i32, 1i32);
|
||||
dc_param_set_int((*msg).param, 'a' as i32, 1i32);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
let new_msg_id: uint32_t;
|
||||
if (*msg).state == 18i32 {
|
||||
let fresh9 = curr_timestamp;
|
||||
@@ -2051,7 +2002,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,
|
||||
DC_PARAM_PREP_FORWARDS as i32,
|
||||
'P' as i32,
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let new_fwd: *mut libc::c_char = dc_mprintf(
|
||||
@@ -2059,7 +2010,7 @@ pub unsafe fn dc_forward_msgs(
|
||||
old_fwd,
|
||||
new_msg_id,
|
||||
);
|
||||
dc_param_set((*msg).param, DC_PARAM_PREP_FORWARDS as i32, new_fwd);
|
||||
dc_param_set((*msg).param, 'P' 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);
|
||||
@@ -2132,7 +2083,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, DC_PARAM_SELFTALK as i32) {
|
||||
if (*chat).type_0 == 100 && 0 != dc_param_exists((*chat).param, 'K' as i32) {
|
||||
ret = dc_stock_str((*chat).context, 50)
|
||||
} else if (*chat).type_0 == 100 {
|
||||
let ret_raw: String = (*chat)
|
||||
@@ -2181,11 +2132,7 @@ 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,
|
||||
DC_PARAM_PROFILE_IMAGE as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
image_rel = dc_param_get((*chat).param, 'i' 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 {
|
||||
@@ -2245,7 +2192,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, DC_PARAM_UNPROMOTED as i32, 0i32)
|
||||
dc_param_get_int((*chat).param, 'U' as i32, 0i32)
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
|
||||
@@ -174,8 +174,7 @@ 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()))
|
||||
.ok();
|
||||
.set_config(context, "addr", Some(param.addr.as_str()));
|
||||
}
|
||||
if s.shall_stop_ongoing {
|
||||
current_block = 2927484062889439186;
|
||||
@@ -967,8 +966,7 @@ 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(
|
||||
|
||||
@@ -418,8 +418,7 @@ pub fn dc_add_or_lookup_contact(
|
||||
},
|
||||
row_id
|
||||
],
|
||||
)
|
||||
.ok();
|
||||
);
|
||||
|
||||
if update_name {
|
||||
sql::execute(
|
||||
@@ -427,7 +426,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 };
|
||||
}
|
||||
|
||||
@@ -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, 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_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_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, DC_PARAM_FILE as i32, setup_file_name);
|
||||
dc_param_set((*msg).param, 'f' as i32, setup_file_name);
|
||||
dc_param_set(
|
||||
(*msg).param,
|
||||
DC_PARAM_MIMETYPE as i32,
|
||||
'm' as i32,
|
||||
b"application/autocrypt-setup\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
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);
|
||||
dc_param_set_int((*msg).param, 'S' as i32, 6i32);
|
||||
dc_param_set_int((*msg).param, 'u' as i32, 2i32);
|
||||
if !context
|
||||
.running_state
|
||||
.clone()
|
||||
@@ -551,17 +551,9 @@ 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, 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,
|
||||
);
|
||||
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);
|
||||
if param1.is_null() {
|
||||
error!(context, 0, "No Import/export dir/file given.",);
|
||||
} else {
|
||||
@@ -857,6 +849,7 @@ 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,
|
||||
@@ -877,9 +870,8 @@ 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;").ok();
|
||||
sql::try_execute(context, &context.sql, "VACUUM;")?;
|
||||
Ok(())
|
||||
})
|
||||
.is_ok() as libc::c_int
|
||||
@@ -913,7 +905,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
|
||||
sql::housekeeping(context);
|
||||
|
||||
sql::try_execute(context, &context.sql, "VACUUM;").ok();
|
||||
sql::try_execute(context, &context.sql, "VACUUM;");
|
||||
context.sql.close(context);
|
||||
let mut closed = true;
|
||||
info!(
|
||||
|
||||
@@ -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,15 +302,11 @@ 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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
filename = dc_param_get(job.param, 'f' 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,
|
||||
DC_PARAM_RECIPIENTS as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
recipients = dc_param_get(job.param, 'R' as i32, 0 as *const libc::c_char);
|
||||
if recipients.is_null() {
|
||||
warn!(context, 0, "Missing recipients for job {}", job.job_id,);
|
||||
} else {
|
||||
@@ -503,12 +499,8 @@ 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,
|
||||
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 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 mut dest_uid: uint32_t = 0i32 as uint32_t;
|
||||
let inbox = context.inbox.read().unwrap();
|
||||
|
||||
@@ -529,7 +521,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, DC_PARAM_ALSO_MOVE as i32, 0i32) {
|
||||
if 0 != dc_param_get_int(job.param, 'M' as i32, 0i32) {
|
||||
if context
|
||||
.sql
|
||||
.get_config_int(context, "folders_configured")
|
||||
@@ -582,12 +574,8 @@ 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,
|
||||
DC_PARAM_WANTS_MDN as i32,
|
||||
0i32,
|
||||
) && 0
|
||||
!= context
|
||||
if 0 != dc_param_get_int((*msg).param, 'r' as i32, 0i32)
|
||||
&& 0 != context
|
||||
.sql
|
||||
.get_config_int(context, "mdns_enabled")
|
||||
.unwrap_or_else(|| 1)
|
||||
@@ -640,7 +628,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, DC_PARAM_WANTS_MDN as i32, 0)
|
||||
if 0 != dc_param_get_int((*msg).param, 'r' as i32, 0i32)
|
||||
&& 0 != context
|
||||
.sql
|
||||
.get_config_int(context, "mdns_enabled")
|
||||
@@ -778,8 +766,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, DC_PARAM_FILE as i32, pathNfilename);
|
||||
dc_param_set(param, DC_PARAM_RECIPIENTS as i32, recipients);
|
||||
dc_param_set(param, 'f' as i32, pathNfilename);
|
||||
dc_param_set(param, 'R' as i32, recipients);
|
||||
dc_job_add(
|
||||
context,
|
||||
action,
|
||||
@@ -832,7 +820,7 @@ pub unsafe fn dc_job_add(
|
||||
},
|
||||
(timestamp + delay_seconds as i64)
|
||||
]
|
||||
).ok();
|
||||
);
|
||||
|
||||
if thread == 100 {
|
||||
dc_interrupt_imap_idle(context);
|
||||
@@ -1179,19 +1167,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,
|
||||
DC_PARAM_FILE as i32,
|
||||
'f' 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, DC_PARAM_WIDTH as i32)
|
||||
&& 0 == dc_param_exists((*mimefactory.msg).param, 'w' 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, DC_PARAM_WIDTH as i32, 0);
|
||||
dc_param_set_int((*mimefactory.msg).param, DC_PARAM_HEIGHT as i32, 0);
|
||||
dc_param_set_int((*mimefactory.msg).param, 'w' as i32, 0i32);
|
||||
dc_param_set_int((*mimefactory.msg).param, 'h' as i32, 0i32);
|
||||
if 0 != dc_read_file(
|
||||
context,
|
||||
pathNfilename,
|
||||
@@ -1204,16 +1192,8 @@ 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,
|
||||
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,
|
||||
);
|
||||
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);
|
||||
}
|
||||
}
|
||||
free(buf as *mut libc::c_void);
|
||||
@@ -1225,7 +1205,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, DC_PARAM_GUARANTEE_E2EE as i32, 0)
|
||||
} else if 0 != dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0)
|
||||
&& 0 == mimefactory.out_encrypted
|
||||
{
|
||||
warn!(
|
||||
@@ -1233,7 +1213,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, DC_PARAM_GUARANTEE_E2EE as i32, 0),
|
||||
dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0),
|
||||
);
|
||||
dc_set_msg_failed(
|
||||
context,
|
||||
@@ -1271,10 +1251,9 @@ 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, DC_PARAM_GUARANTEE_E2EE as i32, 0)
|
||||
== 0
|
||||
&& dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0i32) == 0i32
|
||||
{
|
||||
dc_param_set_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
|
||||
dc_param_set_int((*mimefactory.msg).param, 'c' as i32, 1i32);
|
||||
dc_msg_save_param_to_disk(mimefactory.msg);
|
||||
}
|
||||
dc_add_to_keyhistory(
|
||||
|
||||
@@ -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, DC_PARAM_CMD as i32, 8);
|
||||
dc_param_set_int((*msg).param, 'S' as i32, 8i32);
|
||||
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, DC_PARAM_CMD as i32, 9);
|
||||
dc_param_set_int((*msg).param, 'S' as i32, 9);
|
||||
dc_send_msg(context, chat_id as u32, msg);
|
||||
dc_msg_unref(msg);
|
||||
}
|
||||
|
||||
@@ -91,39 +91,34 @@ pub fn dc_loginparam_write(
|
||||
let prefix = prefix.as_ref();
|
||||
|
||||
let key = format!("{}addr", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.addr)).ok();
|
||||
sql.set_config(context, key, Some(&loginparam.addr));
|
||||
|
||||
let key = format!("{}mail_server", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.mail_server))
|
||||
.ok();
|
||||
sql.set_config(context, key, Some(&loginparam.mail_server));
|
||||
|
||||
let key = format!("{}mail_port", prefix);
|
||||
sql.set_config_int(context, key, loginparam.mail_port).ok();
|
||||
sql.set_config_int(context, key, loginparam.mail_port);
|
||||
|
||||
let key = format!("{}mail_user", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.mail_user))
|
||||
.ok();
|
||||
sql.set_config(context, key, Some(&loginparam.mail_user));
|
||||
|
||||
let key = format!("{}mail_pw", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.mail_pw)).ok();
|
||||
sql.set_config(context, key, Some(&loginparam.mail_pw));
|
||||
|
||||
let key = format!("{}send_server", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.send_server))
|
||||
.ok();
|
||||
sql.set_config(context, key, Some(&loginparam.send_server));
|
||||
|
||||
let key = format!("{}send_port", prefix);
|
||||
sql.set_config_int(context, key, loginparam.send_port).ok();
|
||||
sql.set_config_int(context, key, loginparam.send_port);
|
||||
|
||||
let key = format!("{}send_user", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.send_user))
|
||||
.ok();
|
||||
sql.set_config(context, key, Some(&loginparam.send_user));
|
||||
|
||||
let key = format!("{}send_pw", prefix);
|
||||
sql.set_config(context, key, Some(&loginparam.send_pw)).ok();
|
||||
sql.set_config(context, key, Some(&loginparam.send_pw));
|
||||
|
||||
let key = format!("{}server_flags", prefix);
|
||||
sql.set_config_int(context, key, loginparam.server_flags)
|
||||
.ok();
|
||||
sql.set_config_int(context, key, loginparam.server_flags);
|
||||
}
|
||||
|
||||
fn unset_empty(s: &String) -> Cow<String> {
|
||||
|
||||
@@ -183,11 +183,11 @@ pub unsafe fn dc_mimefactory_load_msg(
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let command = dc_param_get_int((*(*factory).msg).param, DC_PARAM_CMD as i32, 0);
|
||||
let command = dc_param_get_int((*(*factory).msg).param, 'S' as i32, 0);
|
||||
if command == 5 {
|
||||
let email_to_remove_c = dc_param_get(
|
||||
(*(*factory).msg).param,
|
||||
DC_PARAM_CMD_ARG as i32,
|
||||
'E' as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let email_to_remove = to_string(email_to_remove_c);
|
||||
@@ -539,11 +539,9 @@ 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, DC_PARAM_FORCE_PLAINTEXT as i32, 0);
|
||||
force_plaintext = dc_param_get_int((*(*factory).msg).param, 'u' as i32, 0);
|
||||
if force_plaintext == 0 {
|
||||
e2ee_guaranteed =
|
||||
dc_param_get_int((*(*factory).msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0)
|
||||
e2ee_guaranteed = dc_param_get_int((*(*factory).msg).param, 'c' as i32, 0)
|
||||
}
|
||||
}
|
||||
if (*chat).gossiped_timestamp == 0
|
||||
@@ -552,7 +550,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, DC_PARAM_CMD as i32, 0);
|
||||
let command: libc::c_int = dc_param_get_int((*msg).param, 'S' 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
|
||||
{
|
||||
@@ -571,11 +569,8 @@ 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,
|
||||
DC_PARAM_CMD_ARG as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let email_to_remove: *mut libc::c_char =
|
||||
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
|
||||
if !email_to_remove.is_null() {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -590,11 +585,8 @@ 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,
|
||||
DC_PARAM_CMD_ARG as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let email_to_add: *mut libc::c_char =
|
||||
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
|
||||
if !email_to_add.is_null() {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -606,13 +598,9 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
email_to_add,
|
||||
),
|
||||
);
|
||||
grpimage = dc_param_get(
|
||||
(*chat).param,
|
||||
DC_PARAM_PROFILE_IMAGE as i32,
|
||||
0 as *const libc::c_char,
|
||||
)
|
||||
grpimage = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char)
|
||||
}
|
||||
if 0 != dc_param_get_int((*msg).param, DC_PARAM_CMD_ARG2 as i32, 0) & 0x1 {
|
||||
if 0 != dc_param_get_int((*msg).param, 'F' as i32, 0) & 0x1 {
|
||||
info!(
|
||||
(*msg).context,
|
||||
0,
|
||||
@@ -636,17 +624,13 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
),
|
||||
dc_param_get(
|
||||
(*msg).param,
|
||||
DC_PARAM_CMD_ARG as i32,
|
||||
'E' as i32,
|
||||
b"\x00" as *const u8 as *const libc::c_char,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if command == 3 {
|
||||
grpimage = dc_param_get(
|
||||
(*msg).param,
|
||||
DC_PARAM_CMD_ARG as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
grpimage = dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
|
||||
if grpimage.is_null() {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -680,11 +664,8 @@ 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,
|
||||
DC_PARAM_CMD_ARG as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let step: *mut libc::c_char =
|
||||
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
|
||||
if !step.is_null() {
|
||||
info!(
|
||||
(*msg).context,
|
||||
@@ -699,11 +680,8 @@ 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,
|
||||
DC_PARAM_CMD_ARG2 as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let param2: *mut libc::c_char =
|
||||
dc_param_get((*msg).param, 'F' as i32, 0 as *const libc::c_char);
|
||||
if !param2.is_null() {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -731,11 +709,8 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
),
|
||||
);
|
||||
}
|
||||
let fingerprint: *mut libc::c_char = dc_param_get(
|
||||
(*msg).param,
|
||||
DC_PARAM_CMD_ARG3 as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let fingerprint: *mut libc::c_char =
|
||||
dc_param_get((*msg).param, 'G' as i32, 0 as *const libc::c_char);
|
||||
if !fingerprint.is_null() {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -748,11 +723,8 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
),
|
||||
);
|
||||
}
|
||||
let grpid: *mut libc::c_char = dc_param_get(
|
||||
(*msg).param,
|
||||
DC_PARAM_CMD_ARG4 as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let grpid: *mut libc::c_char =
|
||||
dc_param_get((*msg).param, 'H' as i32, 0 as *const libc::c_char);
|
||||
if !grpid.is_null() {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -769,7 +741,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, DC_PARAM_FILE as i32, grpimage);
|
||||
dc_param_set((*meta).param, 'f' as i32, grpimage);
|
||||
let mut filename_as_sent: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
meta_part = build_body_file(
|
||||
meta,
|
||||
@@ -800,8 +772,7 @@ 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, DC_PARAM_DURATION as i32, 0);
|
||||
let duration_ms: libc::c_int = dc_param_get_int((*msg).param, 'd' as i32, 0);
|
||||
if duration_ms > 0 {
|
||||
mailimf_fields_add(
|
||||
imf_fields,
|
||||
@@ -815,7 +786,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
|
||||
);
|
||||
}
|
||||
}
|
||||
afwd_email = dc_param_exists((*msg).param, DC_PARAM_FORWARDED as i32);
|
||||
afwd_email = dc_param_exists((*msg).param, 'a' as i32);
|
||||
let mut fwdhint: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
if 0 != afwd_email {
|
||||
fwdhint = dc_strdup(
|
||||
@@ -997,7 +968,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, DC_PARAM_GUARANTEE_E2EE as i32, 0) {
|
||||
if 0 != dc_param_get_int((*(*factory).msg).param, 'c' as i32, 0) {
|
||||
p1 = dc_stock_str((*factory).context, 24)
|
||||
} else {
|
||||
p1 = dc_msg_get_summarytext((*factory).msg, 32)
|
||||
@@ -1123,7 +1094,7 @@ unsafe fn get_subject(
|
||||
} else {
|
||||
b"\x00" as *const u8 as *const libc::c_char
|
||||
};
|
||||
if dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0) == 6 {
|
||||
if dc_param_get_int((*msg).param, 'S' 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
|
||||
@@ -1184,12 +1155,9 @@ 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, 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,
|
||||
);
|
||||
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);
|
||||
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;
|
||||
@@ -1348,7 +1316,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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
dc_param_get((*msg).param, 'f' 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;
|
||||
|
||||
@@ -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, DC_PARAM_FORWARDED as i32, 1);
|
||||
dc_param_set_int((*part_2).param, 'a' as i32, 1i32);
|
||||
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, DC_PARAM_DURATION as i32, duration_ms);
|
||||
dc_param_set_int((*part_3).param, 'd' as i32, duration_ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,11 +385,7 @@ 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,
|
||||
DC_PARAM_WANTS_MDN as i32,
|
||||
1,
|
||||
);
|
||||
dc_param_set_int((*part_4).param, 'r' as i32, 1i32);
|
||||
}
|
||||
}
|
||||
free(from_addr as *mut libc::c_void);
|
||||
@@ -1490,8 +1486,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, DC_PARAM_FILE as i32, pathNfilename);
|
||||
dc_param_set((*part).param, DC_PARAM_MIMETYPE as i32, raw_mime);
|
||||
dc_param_set((*part).param, 'f' as i32, pathNfilename);
|
||||
dc_param_set((*part).param, 'm' 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;
|
||||
@@ -1501,8 +1497,8 @@ unsafe fn do_add_single_file_part(
|
||||
&mut w,
|
||||
&mut h,
|
||||
) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
do_add_single_part(parser, part);
|
||||
@@ -1515,9 +1511,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, DC_PARAM_GUARANTEE_E2EE as i32, 1);
|
||||
dc_param_set_int((*part).param, 'c' as i32, 1i32);
|
||||
} else if 0 != (*parser).e2ee_helper.encrypted {
|
||||
dc_param_set_int((*part).param, DC_PARAM_ERRONEOUS_E2EE as i32, 0x2);
|
||||
dc_param_set_int((*part).param, 'e' as i32, 0x2i32);
|
||||
}
|
||||
carray_add(
|
||||
(*parser).parts,
|
||||
|
||||
@@ -142,22 +142,18 @@ 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, DC_PARAM_ERRONEOUS_E2EE as i32, 0);
|
||||
let e2ee_errors = dc_param_get_int((*msg).param, 'e' 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, DC_PARAM_GUARANTEE_E2EE as i32, 0) {
|
||||
} else if 0 != dc_param_get_int((*msg).param, 'c' as i32, 0) {
|
||||
ret += ", Encrypted";
|
||||
}
|
||||
|
||||
ret += "\n";
|
||||
p = dc_param_get(
|
||||
(*msg).param,
|
||||
DC_PARAM_ERROR as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
p = dc_param_get((*msg).param, 'L' 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);
|
||||
@@ -188,12 +184,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, DC_PARAM_WIDTH as i32, 0);
|
||||
let h = dc_param_get_int((*msg).param, DC_PARAM_HEIGHT as i32, 0);
|
||||
let w = dc_param_get_int((*msg).param, 'w' as i32, 0);
|
||||
let h = dc_param_get_int((*msg).param, 'h' as i32, 0);
|
||||
if w != 0 || h != 0 {
|
||||
ret += &format!("Dimension: {} x {}\n", w, h,);
|
||||
}
|
||||
let duration = dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0);
|
||||
let duration = dc_param_get_int((*msg).param, 'd' as i32, 0);
|
||||
if duration != 0 {
|
||||
ret += &format!("Duration: {} ms\n", duration,);
|
||||
}
|
||||
@@ -273,13 +269,9 @@ 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,
|
||||
DC_PARAM_MIMETYPE as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
ret = dc_param_get((*msg).param, 'm' as i32, 0 as *const libc::c_char);
|
||||
if ret.is_null() {
|
||||
file = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
file = dc_param_get((*msg).param, 'f' 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() {
|
||||
@@ -356,7 +348,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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
file_rel = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
|
||||
if !file_rel.is_null() {
|
||||
file_abs = dc_get_abs_path((*msg).context, file_rel)
|
||||
}
|
||||
@@ -487,7 +479,10 @@ pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id:
|
||||
}
|
||||
);
|
||||
|
||||
res.is_ok()
|
||||
match res {
|
||||
Ok(_) => true,
|
||||
Err(err) => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_mime_headers(context: &Context, msg_id: uint32_t) -> *mut libc::c_char {
|
||||
@@ -706,7 +701,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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
|
||||
if !pathNfilename.is_null() {
|
||||
ret = dc_get_filename(pathNfilename)
|
||||
}
|
||||
@@ -723,7 +718,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, DC_PARAM_FILE as i32, 0 as *const libc::c_char);
|
||||
file = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
|
||||
if !file.is_null() {
|
||||
ret = dc_get_filebytes((*msg).context, file)
|
||||
}
|
||||
@@ -738,7 +733,7 @@ pub unsafe fn dc_msg_get_width(msg: *const dc_msg_t) -> libc::c_int {
|
||||
return 0i32;
|
||||
}
|
||||
|
||||
dc_param_get_int((*msg).param, DC_PARAM_WIDTH as i32, 0)
|
||||
dc_param_get_int((*msg).param, 'w' as i32, 0i32)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_msg_get_height(msg: *const dc_msg_t) -> libc::c_int {
|
||||
@@ -746,7 +741,7 @@ pub unsafe fn dc_msg_get_height(msg: *const dc_msg_t) -> libc::c_int {
|
||||
return 0i32;
|
||||
}
|
||||
|
||||
dc_param_get_int((*msg).param, DC_PARAM_HEIGHT as i32, 0)
|
||||
dc_param_get_int((*msg).param, 'h' as i32, 0i32)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_msg_get_duration(msg: *const dc_msg_t) -> libc::c_int {
|
||||
@@ -754,7 +749,7 @@ pub unsafe fn dc_msg_get_duration(msg: *const dc_msg_t) -> libc::c_int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0)
|
||||
dc_param_get_int((*msg).param, 'd' as i32, 0i32)
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
@@ -762,7 +757,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, DC_PARAM_GUARANTEE_E2EE as i32, 0) != 0i32 {
|
||||
if dc_param_get_int((*msg).param, 'c' as i32, 0i32) != 0i32 {
|
||||
return 1i32;
|
||||
}
|
||||
|
||||
@@ -845,13 +840,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, DC_PARAM_CMD as i32, 0) == 6i32 {
|
||||
if dc_param_get_int(param, 'S' as i32, 0i32) == 6i32 {
|
||||
prefix = dc_stock_str(context, 42i32);
|
||||
append_text = 0i32
|
||||
} else {
|
||||
pathNfilename = dc_param_get(
|
||||
param,
|
||||
DC_PARAM_FILE as i32,
|
||||
'f' as i32,
|
||||
b"ErrFilename\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
value = dc_get_filename(pathNfilename);
|
||||
@@ -871,7 +866,7 @@ pub unsafe fn dc_msg_get_summarytext_by_raw(
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if dc_param_get_int(param, DC_PARAM_CMD as i32, 0) == 9i32 {
|
||||
if dc_param_get_int(param, 'S' as i32, 0i32) == 9i32 {
|
||||
prefix = dc_stock_str(context, 66i32);
|
||||
append_text = 0i32
|
||||
}
|
||||
@@ -935,7 +930,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, DC_PARAM_FORWARDED as i32, 0) {
|
||||
return if 0 != dc_param_get_int((*msg).param, 'a' as i32, 0i32) {
|
||||
1i32
|
||||
} else {
|
||||
0i32
|
||||
@@ -947,7 +942,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, DC_PARAM_CMD as i32, 0);
|
||||
let cmd: libc::c_int = dc_param_get_int((*msg).param, 'S' as i32, 0i32);
|
||||
if (*msg).from_id == 2i32 as libc::c_uint
|
||||
|| (*msg).to_id == 2i32 as libc::c_uint
|
||||
|| 0 != cmd && cmd != 6i32
|
||||
@@ -981,7 +976,7 @@ pub unsafe fn dc_msg_is_setupmessage(msg: *const dc_msg_t) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
if dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0) == 6 {
|
||||
if dc_param_get_int((*msg).param, 'S' as i32, 0) == 6 {
|
||||
true
|
||||
} else {
|
||||
true
|
||||
@@ -1055,23 +1050,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, DC_PARAM_FILE as i32, file);
|
||||
dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, filemime);
|
||||
dc_param_set((*msg).param, 'f' as i32, file);
|
||||
dc_param_set((*msg).param, 'm' 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, DC_PARAM_WIDTH as i32, width);
|
||||
dc_param_set_int((*msg).param, DC_PARAM_HEIGHT as i32, height);
|
||||
dc_param_set_int((*msg).param, 'w' as i32, width);
|
||||
dc_param_set_int((*msg).param, 'h' 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, DC_PARAM_DURATION as i32, duration);
|
||||
dc_param_set_int((*msg).param, 'd' as i32, duration);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_msg_latefiling_mediasize(
|
||||
@@ -1082,11 +1077,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, DC_PARAM_WIDTH as i32, width);
|
||||
dc_param_set_int((*msg).param, DC_PARAM_HEIGHT as i32, height);
|
||||
dc_param_set_int((*msg).param, 'w' as i32, width);
|
||||
dc_param_set_int((*msg).param, 'h' as i32, height);
|
||||
}
|
||||
if duration > 0i32 {
|
||||
dc_param_set_int((*msg).param, DC_PARAM_DURATION as i32, duration);
|
||||
dc_param_set_int((*msg).param, 'd' as i32, duration);
|
||||
}
|
||||
dc_msg_save_param_to_disk(msg);
|
||||
};
|
||||
@@ -1120,15 +1115,13 @@ 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);
|
||||
}
|
||||
@@ -1185,7 +1178,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, DC_PARAM_ERROR as i32, error);
|
||||
dc_param_set((*msg).param, 'L' as i32, error);
|
||||
error!(context, 0, "{}", as_str(error),);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,61 +3,59 @@ use crate::types::*;
|
||||
use crate::x::*;
|
||||
|
||||
/// for msgs and jobs
|
||||
pub const DC_PARAM_FILE: char = 'f'; // string
|
||||
pub const DC_PARAM_FILE: char = 'f';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_WIDTH: char = 'w'; // int
|
||||
pub const DC_PARAM_WIDTH: char = 'w';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_HEIGHT: char = 'h'; // int
|
||||
pub const DC_PARAM_HEIGHT: char = 'h';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_DURATION: char = 'd'; // int
|
||||
pub const DC_PARAM_DURATION: char = 'd';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_MIMETYPE: char = 'm'; // string
|
||||
pub const DC_PARAM_MIMETYPE: char = 'm';
|
||||
/// for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send
|
||||
pub const DC_PARAM_GUARANTEE_E2EE: char = 'c'; // int (bool?)
|
||||
pub const DC_PARAM_GUARANTEE_E2EE: char = 'c';
|
||||
/// 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'; // int
|
||||
pub const DC_PARAM_ERRONEOUS_E2EE: char = 'e';
|
||||
/// 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'; // int (bool?)
|
||||
pub const DC_PARAM_FORCE_PLAINTEXT: char = 'u';
|
||||
/// for msgs: an incoming message which requests a MDN (aka read receipt)
|
||||
pub const DC_PARAM_WANTS_MDN: char = 'r'; // int (bool?)
|
||||
pub const DC_PARAM_WANTS_MDN: char = 'r';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_FORWARDED: char = 'a'; // int (bool?)
|
||||
pub const DC_PARAM_FORWARDED: char = 'a';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_CMD: char = 'S'; // int
|
||||
pub const DC_PARAM_CMD: char = 'S';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_CMD_ARG: char = 'E'; // string
|
||||
pub const DC_PARAM_CMD_ARG: char = 'E';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_CMD_ARG2: char = 'F'; // string
|
||||
pub const DC_PARAM_CMD_ARG2: char = 'F';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_CMD_ARG3: char = 'G'; // string
|
||||
pub const DC_PARAM_CMD_ARG3: char = 'G';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_CMD_ARG4: char = 'H'; // string
|
||||
pub const DC_PARAM_CMD_ARG4: char = 'H';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_ERROR: char = 'L'; // string
|
||||
pub const DC_PARAM_ERROR: char = 'L';
|
||||
/// for msgs in PREPARING: space-separated list of message IDs of forwarded copies
|
||||
pub const DC_PARAM_PREP_FORWARDS: char = 'P'; // string
|
||||
pub const DC_PARAM_PREP_FORWARDS: char = 'P';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_SET_LATITUDE: char = 'l'; // float
|
||||
pub const DC_PARAM_SET_LATITUDE: char = 'l';
|
||||
/// for msgs
|
||||
pub const DC_PARAM_SET_LONGITUDE: char = 'n'; // float
|
||||
pub const DC_PARAM_SET_LONGITUDE: char = 'n';
|
||||
|
||||
/// for jobs
|
||||
pub const DC_PARAM_SERVER_FOLDER: char = 'Z'; // string
|
||||
pub const DC_PARAM_SERVER_FOLDER: char = 'Z';
|
||||
/// for jobs
|
||||
pub const DC_PARAM_SERVER_UID: char = 'z'; // int
|
||||
pub const DC_PARAM_SERVER_UID: char = 'z';
|
||||
/// for jobs
|
||||
pub const DC_PARAM_ALSO_MOVE: char = 'M'; // int (bool?)
|
||||
pub const DC_PARAM_ALSO_MOVE: char = 'M';
|
||||
/// for jobs: space-separated list of message recipients
|
||||
pub const DC_PARAM_RECIPIENTS: char = 'R'; // stringap
|
||||
pub const DC_PARAM_RECIPIENTS: char = 'R';
|
||||
/// for groups
|
||||
pub const DC_PARAM_UNPROMOTED: char = 'U'; // int (bool?)
|
||||
pub const DC_PARAM_UNPROMOTED: char = 'U';
|
||||
/// for groups and contacts
|
||||
pub const DC_PARAM_PROFILE_IMAGE: char = 'i'; // string (bytes?)
|
||||
pub const DC_PARAM_PROFILE_IMAGE: char = 'i';
|
||||
/// 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;
|
||||
|
||||
15
src/dc_qr.rs
15
src/dc_qr.rs
@@ -56,23 +56,16 @@ 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, DC_PARAM_FORWARDED as i32, 0 as *const libc::c_char);
|
||||
addr = dc_param_get(param, 'a' as i32, 0 as *const libc::c_char);
|
||||
if !addr.is_null() {
|
||||
let mut urlencoded: *mut libc::c_char = dc_param_get(
|
||||
param,
|
||||
DC_PARAM_SET_LONGITUDE as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
let mut urlencoded: *mut libc::c_char =
|
||||
dc_param_get(param, 'n' 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,
|
||||
DC_PARAM_PROFILE_IMAGE as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
invitenumber = dc_param_get(param, 'i' 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() {
|
||||
|
||||
@@ -215,9 +215,7 @@ 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 mime_parser.is_system_message != DC_CMD_AUTOCRYPT_SETUP_MESSAGE
|
||||
&& msgrmsg == 0
|
||||
{
|
||||
if msgrmsg == 0 {
|
||||
let show_emails = context
|
||||
.sql
|
||||
.get_config_int(context, "show_emails")
|
||||
@@ -515,7 +513,9 @@ pub unsafe fn dc_receive_imf(
|
||||
(*part).bytes,
|
||||
hidden,
|
||||
if 0 != save_mime_headers {
|
||||
let body_string = std::str::from_utf8(std::slice::from_raw_parts(imf_raw_not_terminated as *const u8, imf_raw_bytes)).unwrap();
|
||||
let body_string = unsafe {
|
||||
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,24 +745,16 @@ 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,
|
||||
DC_PARAM_SERVER_FOLDER as i32,
|
||||
server_folder_c,
|
||||
);
|
||||
dc_param_set(param, 'Z' as i32, server_folder_c);
|
||||
free(server_folder_c as *mut _);
|
||||
dc_param_set_int(
|
||||
param,
|
||||
DC_PARAM_SERVER_UID as i32,
|
||||
server_uid as i32,
|
||||
);
|
||||
dc_param_set_int(param, 'z' 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, DC_PARAM_ALSO_MOVE as i32, 1);
|
||||
dc_param_set_int(param, 'M' as i32, 1);
|
||||
}
|
||||
dc_job_add(context, 120, 0, (*param).packed, 0);
|
||||
dc_param_unref(param);
|
||||
@@ -1229,7 +1221,7 @@ unsafe fn create_or_lookup_group(
|
||||
if (*part).type_0 == 20 {
|
||||
grpimage = dc_param_get(
|
||||
(*part).param,
|
||||
DC_PARAM_FILE as i32,
|
||||
'f' as i32,
|
||||
0 as *const libc::c_char,
|
||||
);
|
||||
ok = 1
|
||||
@@ -1250,11 +1242,7 @@ unsafe fn create_or_lookup_group(
|
||||
},
|
||||
);
|
||||
dc_chat_load_from_db(chat, chat_id);
|
||||
dc_param_set(
|
||||
(*chat).param,
|
||||
DC_PARAM_PROFILE_IMAGE as i32,
|
||||
grpimage,
|
||||
);
|
||||
dc_param_set((*chat).param, 'i' as i32, grpimage);
|
||||
dc_chat_update_param(chat);
|
||||
dc_chat_unref(chat);
|
||||
free(grpimage as *mut libc::c_void);
|
||||
@@ -1272,8 +1260,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -267,23 +267,23 @@ unsafe fn send_handshake_msg(
|
||||
step,
|
||||
);
|
||||
(*msg).hidden = 1i32;
|
||||
dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 7);
|
||||
dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, step);
|
||||
dc_param_set_int((*msg).param, 'S' as i32, 7i32);
|
||||
dc_param_set((*msg).param, 'E' as i32, step);
|
||||
if !param2.is_null() {
|
||||
dc_param_set((*msg).param, DC_PARAM_CMD_ARG2 as i32, param2);
|
||||
dc_param_set((*msg).param, 'F' as i32, param2);
|
||||
}
|
||||
if !fingerprint.is_null() {
|
||||
dc_param_set((*msg).param, DC_PARAM_CMD_ARG3 as i32, fingerprint);
|
||||
dc_param_set((*msg).param, 'G' as i32, fingerprint);
|
||||
}
|
||||
if !grpid.is_null() {
|
||||
dc_param_set((*msg).param, DC_PARAM_CMD_ARG4 as i32, grpid);
|
||||
dc_param_set((*msg).param, 'H' 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, DC_PARAM_FORCE_PLAINTEXT as i32, 1);
|
||||
dc_param_set_int((*msg).param, 'u' as i32, 1i32);
|
||||
} else {
|
||||
dc_param_set_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1);
|
||||
dc_param_set_int((*msg).param, 'c' as i32, 1i32);
|
||||
}
|
||||
dc_send_msg(context, contact_chat_id, msg);
|
||||
dc_msg_unref(msg);
|
||||
|
||||
@@ -1078,28 +1078,40 @@ pub unsafe fn dc_get_abs_path(
|
||||
context: &Context,
|
||||
pathNfilename: *const libc::c_char,
|
||||
) -> *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,
|
||||
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,
|
||||
context.get_blobdir(),
|
||||
);
|
||||
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
|
||||
}
|
||||
|
||||
pathNfilename_abs
|
||||
}
|
||||
|
||||
|
||||
21
src/imap.rs
21
src/imap.rs
@@ -1622,25 +1622,18 @@ impl Imap {
|
||||
}
|
||||
}
|
||||
|
||||
context
|
||||
.sql
|
||||
.set_config_int(context, "folders_configured", 3)
|
||||
.ok();
|
||||
context.sql.set_config_int(context, "folders_configured", 3);
|
||||
if let Some(ref mvbox_folder) = mvbox_folder {
|
||||
context
|
||||
.sql
|
||||
.set_config(context, "configured_mvbox_folder", Some(mvbox_folder))
|
||||
.ok();
|
||||
.set_config(context, "configured_mvbox_folder", Some(mvbox_folder));
|
||||
}
|
||||
if let Some(ref sentbox_folder) = sentbox_folder {
|
||||
context
|
||||
.sql
|
||||
.set_config(
|
||||
context,
|
||||
"configured_sentbox_folder",
|
||||
Some(sentbox_folder.name()),
|
||||
)
|
||||
.ok();
|
||||
context.sql.set_config(
|
||||
context,
|
||||
"configured_sentbox_folder",
|
||||
Some(sentbox_folder.name()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,17 +48,11 @@ pub fn dc_get_oauth2_url(
|
||||
redirect_uri: impl AsRef<str>,
|
||||
) -> Option<String> {
|
||||
if let Some(oauth2) = Oauth2::from_address(addr) {
|
||||
if context
|
||||
.sql
|
||||
.set_config(
|
||||
context,
|
||||
"oauth2_pending_redirect_uri",
|
||||
Some(redirect_uri.as_ref()),
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
context.sql.set_config(
|
||||
context,
|
||||
"oauth2_pending_redirect_uri",
|
||||
Some(redirect_uri.as_ref()),
|
||||
);
|
||||
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());
|
||||
|
||||
@@ -163,12 +157,10 @@ 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))
|
||||
.ok();
|
||||
.set_config(context, "oauth2_refresh_token", Some(token));
|
||||
context
|
||||
.sql
|
||||
.set_config(context, "oauth2_refresh_token_for", Some(code.as_ref()))
|
||||
.ok();
|
||||
.set_config(context, "oauth2_refresh_token_for", Some(code.as_ref()));
|
||||
}
|
||||
|
||||
// after that, save the access token.
|
||||
@@ -176,8 +168,7 @@ 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))
|
||||
.ok();
|
||||
.set_config(context, "oauth2_access_token", Some(token));
|
||||
let expires_in = response
|
||||
.expires_in
|
||||
// refresh a bet before
|
||||
@@ -185,14 +176,12 @@ pub fn dc_get_oauth2_access_token(
|
||||
.unwrap_or_else(|| 0);
|
||||
context
|
||||
.sql
|
||||
.set_config_int64(context, "oauth2_timestamp_expires", expires_in)
|
||||
.ok();
|
||||
.set_config_int64(context, "oauth2_timestamp_expires", expires_in);
|
||||
|
||||
if update_redirect_uri_on_success {
|
||||
context
|
||||
.sql
|
||||
.set_config(context, "oauth2_redirect_uri", Some(redirect_uri.as_ref()))
|
||||
.ok();
|
||||
.set_config(context, "oauth2_redirect_uri", Some(redirect_uri.as_ref()));
|
||||
}
|
||||
} else {
|
||||
warn!(context, 0, "Failed to find OAuth2 access token");
|
||||
|
||||
55
src/sql.rs
55
src/sql.rs
@@ -141,7 +141,6 @@ 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,
|
||||
@@ -185,9 +184,7 @@ impl Sql {
|
||||
}
|
||||
|
||||
/// Set private configuration options.
|
||||
///
|
||||
/// Setting `None` deletes the value. On failure an error message
|
||||
/// will already have been logged.
|
||||
/// Setting `None` deletes the value.
|
||||
pub fn set_config(
|
||||
&self,
|
||||
context: &Context,
|
||||
@@ -462,7 +459,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;
|
||||
@@ -487,7 +484,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(
|
||||
@@ -495,7 +492,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(
|
||||
@@ -509,7 +506,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(
|
||||
@@ -527,7 +524,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(
|
||||
@@ -539,7 +536,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(
|
||||
@@ -553,7 +550,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(
|
||||
@@ -562,7 +559,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![])?;
|
||||
@@ -579,7 +576,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(
|
||||
@@ -608,7 +605,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(
|
||||
@@ -638,7 +635,7 @@ fn open(
|
||||
)?;
|
||||
}
|
||||
dbversion = 39;
|
||||
sql.set_config_int(context, "dbversion", 39)?;
|
||||
sql.set_config_int(context, "dbversion", 39);
|
||||
}
|
||||
if dbversion < 40 {
|
||||
sql.execute(
|
||||
@@ -646,22 +643,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(
|
||||
@@ -673,7 +670,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");
|
||||
@@ -682,7 +679,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");
|
||||
@@ -696,7 +693,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");
|
||||
@@ -705,15 +702,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");
|
||||
@@ -746,7 +743,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");
|
||||
@@ -756,7 +753,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(
|
||||
@@ -764,7 +761,7 @@ fn open(
|
||||
params![],
|
||||
)?;
|
||||
|
||||
sql.set_config_int(context, "dbversion", 55)?;
|
||||
sql.set_config_int(context, "dbversion", 55);
|
||||
}
|
||||
|
||||
if 0 != recalc_fingerprints {
|
||||
@@ -812,7 +809,7 @@ fn open(
|
||||
NO_PARAMS,
|
||||
)?;
|
||||
|
||||
sql.set_config(context, "backup_for", None)?;
|
||||
sql.set_config(context, "backup_for", None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user