Prepare for android builds (#88)

* upgrade ci

* fixup

* update ci script

* Update run.sh

* refactor(time): drop libc time functions

* fix(ffi): use i64 instead off time_t

* fix(ci): install croos

* fix: remove unused dc_check_password

* fix(ffi): enable ssl vendoring by default

* chore: remove unused import

* fix(deps): add vendored flag for reqwest

* chore(ci): use cross fork

* fix: handle invalid  server configurations

Closes #90

* Disable android from circle ci for now
This commit is contained in:
Friedel Ziegelmayer
2019-05-28 17:41:50 +02:00
committed by Lars-Magnus Skog
parent 2a5d0c64d5
commit 0d51c7dd2e
30 changed files with 459 additions and 547 deletions

View File

@@ -12,7 +12,6 @@ use crate::dc_configure::*;
use crate::dc_e2ee::*;
use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_loginparam::*;
use crate::dc_msg::*;
use crate::dc_param::*;
use crate::dc_sqlite3::*;
@@ -49,7 +48,7 @@ pub unsafe fn dc_imex_has_backup(
dir_name: *const libc::c_char,
) -> *mut libc::c_char {
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
let mut ret_backup_time: time_t = 0i32 as time_t;
let mut ret_backup_time = 0;
let dir_handle: *mut DIR;
let mut dir_entry: *mut dirent;
let prefix_len = strlen(b"delta-chat\x00" as *const u8 as *const libc::c_char);
@@ -97,12 +96,12 @@ pub unsafe fn dc_imex_has_backup(
}
let mut sql = dc_sqlite3_new();
if 0 != dc_sqlite3_open(context, &mut sql, curr_pathNfilename, 0x1i32) {
let curr_backup_time: time_t = dc_sqlite3_get_config_int(
let curr_backup_time = dc_sqlite3_get_config_int(
context,
&mut sql,
b"backup_time\x00" as *const u8 as *const libc::c_char,
0i32,
) as time_t;
) as u64;
if curr_backup_time > 0 && curr_backup_time > ret_backup_time {
free(ret as *mut libc::c_void);
ret = curr_pathNfilename;
@@ -124,35 +123,6 @@ pub unsafe fn dc_imex_has_backup(
ret
}
pub unsafe fn dc_check_password(context: &Context, test_pw: *const libc::c_char) -> libc::c_int {
/* Check if the given password matches the configured mail_pw.
This is to prompt the user before starting eg. an export; this is mainly to avoid doing people bad thinkgs if they have short access to the device.
When we start supporting OAuth some day, we should think this over, maybe force the user to re-authenticate himself with the Android password. */
let loginparam: *mut dc_loginparam_t = dc_loginparam_new();
let mut success: libc::c_int = 0i32;
dc_loginparam_read(
context,
loginparam,
&context.sql.clone().read().unwrap(),
b"configured_\x00" as *const u8 as *const libc::c_char,
);
if ((*loginparam).mail_pw.is_null()
|| *(*loginparam).mail_pw.offset(0isize) as libc::c_int == 0i32)
&& (test_pw.is_null() || *test_pw.offset(0isize) as libc::c_int == 0i32)
{
success = 1i32
} else if (*loginparam).mail_pw.is_null() || test_pw.is_null() {
success = 0i32
} else if strcmp((*loginparam).mail_pw, test_pw) == 0i32 {
success = 1i32
}
dc_loginparam_unref(loginparam);
success
}
pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
let current_block: u64;
let mut success: libc::c_int = 0i32;
@@ -1141,7 +1111,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
let mut success: libc::c_int = 0i32;
let mut closed: libc::c_int = 0i32;
let dest_pathNfilename: *mut libc::c_char;
let mut now = time(0 as *mut time_t);
let now = time();
let mut dir_handle: *mut DIR = 0 as *mut DIR;
let mut dir_entry: *mut dirent;
let prefix_len = strlen(b"delta-chat\x00" as *const u8 as *const libc::c_char);
@@ -1156,16 +1126,11 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
let mut dest_sql: Option<dc_sqlite3_t> = None;
/* get a fine backup file name (the name includes the date so that multiple backup instances are possible)
FIXME: we should write to a temporary file first and rename it on success. this would guarantee the backup is complete. however, currently it is not clear it the import exists in the long run (may be replaced by a restore-from-imap)*/
let timeinfo: *mut tm;
let mut buffer: [libc::c_char; 256] = [0; 256];
timeinfo = localtime(&mut now);
strftime(
buffer.as_mut_ptr(),
256i32 as size_t,
b"delta-chat-%Y-%m-%d.bak\x00" as *const u8 as *const libc::c_char,
timeinfo,
);
dest_pathNfilename = dc_get_fine_pathNfilename(context, dir, buffer.as_mut_ptr());
let res = chrono::NaiveDateTime::from_timestamp(now as i64, 0)
.format("delta-chat-%Y-%m-%d.bak")
.to_string();
let buffer = to_cstring(res);
dest_pathNfilename = dc_get_fine_pathNfilename(context, dir, buffer.as_ptr());
if dest_pathNfilename.is_null() {
dc_log_error(
context,