58 Commits

Author SHA1 Message Date
dignifiedquire 8714599655 refactor: rename dc_sqlite3 to sql 2019-07-12 21:57:34 +02:00
dignifiedquire 45f7eba1f4 fix segfaults and some queries 2019-07-10 22:41:20 +02:00
dignifiedquire ab41679855 refactor: safe sql access 2019-07-10 16:45:05 +02:00
Floris Bruynooghe 4c646dc1e0 Rename dc_chat_t to Chat
This clears the way to start working on making the functions safe.
But small PRs are good PRs so let's get this rename out of the way and
have future PRs less noisy.

Also stop making this #[repr(C)] and start making fields that are not
used private. Lastly clean up some comments by moving them or
deleting them, so they make sense again after the translation.
2019-07-09 21:46:31 +02:00
Floris Bruynooghe a6102d1039 Refactor the internal sql interface somewhat
Experiment with refactoring the internal sql interface a bit.  My
original goal was to modify the schema and thus refactor to a state
where it would be sane to write tests for dc_sqlite_open() (and/or
however it ends up refactored) to assert schame changes before/after.
2019-06-17 22:31:36 +02:00
Floris Bruynooghe db9bc15d3e Make the callback optional again
The C API allows passing a NULL pointer is for the callback function.
However when calling the callback nothing checks for this null pointer
and thus things fail badly.  Even worse since the C API is defined
using an "fn pointer" rather than a "*-ptr" or raw pointer to the
function rust does not realise this can be invalid and therefore the
typechecker does not catch this even though there are no unsafe casts.

Fix this by making the callback an Option in rust, this can be easily
checked when calling.  Also add a Context.call_cb() function which
simplifies calling the callback, hides the weird syntax due to the
function pointer and makes the call a little easier.  Finally it also
means the option checking is only needed in one place.

For the C API this needs to check if this is a NULL pointer or not,
this is implicitly done by rust using the "nullable pointer
optimisation":
https://doc.rust-lang.org/nomicon/ffi.html#the-nullable-pointer-optimization
2019-06-17 20:06:15 +02:00
Floris Bruynooghe 855c7844b5 Rename to_str() -> as_str() to match stdlib naming convention
The function does a cast and does not create a new objects.  The
stdlib convention is to use to_*() for functions which return new
objects and as_*() for functions which keep referring to the same data
but using a different type.  Follow that convention.
2019-06-07 22:19:39 +02:00
Lars-Magnus Skog 9a0a451999 chore: use rustyline@4.1.0 for now (#128)
* switch to rustyline 4.1.0

* adapt highlight_prompt to 4.1.0 format

* fix rust fmt
2019-06-06 13:13:16 +02:00
B. Petersen 05e097baaa trim() commandline as rustyline adds lineends to commands eg. from inside IntelliJ IDEA 2019-06-06 13:13:16 +02:00
dignifiedquire 983ccaaccd feat(examples): refactor repl to use rustyline and safe rust 2019-06-06 13:13:16 +02:00
dignifiedquire 95d4df6027 refactor: reduce dependencies on libc 2019-06-05 00:56:59 +02:00
dignifiedquire 62e54c7291 refactor: drop libc based directory reading 2019-05-29 20:21:59 +02:00
dignifiedquire 31daa425cf refactor: remove usage of printf 2019-05-29 19:06:36 +02:00
Friedel Ziegelmayer d033667433 Fix bugs (#93)
* fix(repl): pass null pointer instead of empty string

* fix(peerstate): ensure load and store to the db works
2019-05-28 17:59:41 +02:00
Friedel Ziegelmayer 0d51c7dd2e 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
2019-05-28 17:41:50 +02:00
dignifiedquire 22868abe0e refactor: rename dc_context to context 2019-05-27 09:32:50 +02:00
dignifiedquire 5237c19f4e refactor: remove dc prefix from cleaned up modules 2019-05-27 09:21:42 +02:00
Friedel Ziegelmayer 41cecb32c7 refactor: remove dc_hash in favor of HashMap and HashSet 2019-05-27 09:07:24 +02:00
Friedel Ziegelmayer f0cfcef864 refactor: use reqwest to handle http-get requests
Closes #82
2019-05-27 09:06:55 +02:00
dignifiedquire 66d8421a90 refactor: remove dc_hash in favor of HashMap and HashSet
Closes #49
2019-05-26 23:01:17 +02:00
Friedel Ziegelmayer a247e5b143 refactor(oauth): safe oauth2 and remove custom json parser (#80)
* refactor(oauth): safe oauth2 and remove custom json parser

Closes #46,#53
2019-05-26 22:49:52 +02:00
Friedel Ziegelmayer 94aa314f30 refactor(peerstate): safe implementation of peerstate 2019-05-26 22:33:39 +02:00
Friedel Ziegelmayer 342e416b4e Ci updates & closer to windows builds
* chore: update some ci

* feat: no more libiconv

* refactor: updates for updated mmime api

* fixup: correct mmime path

* cleanup

* use newer visual studio

* Update appveyor.yml

* unify libc imports and improve windows situation

* refactor: use rust based sleep

* improve cross platform state of types

* docs: update readme badges
2019-05-16 17:16:07 +02:00
dignifiedquire dfb989e0d0 finish it 2019-05-14 00:44:59 +02:00
Hocuri 569c924a0c Replace types that use only 0 and 1 with bool (#18) (#58)
* Start replacing int with bool where possible (#18)

* Continue replacing int with bool where possible (#18)

* Continue replacing int with bool where possible (#18)

* Run fmt
2019-05-11 12:07:09 +02:00
dignifiedquire 76f982a1f5 fix: mvbox and sentbox lock contention 2019-05-10 03:39:23 +01:00
Lars-Magnus Skog 3a7dcd14ab chore: stop allowing unused_attributes (#54) 2019-05-08 12:40:18 +02:00
Lars-Magnus Skog 0bbda91e77 Fix warnings on variables not needing mut (#48)
chore: fix compiler warnings (unused mut)
2019-05-08 00:44:40 +02:00
dignifiedquire 0ba0c0a3c0 examples(repl): load chat 2019-05-07 18:44:49 +01:00
dignifiedquire 127677223e cleanup logging a bit 2019-05-07 18:28:16 +01:00
dignifiedquire 671271a999 example(repl): better arg parsing 2019-05-07 16:34:21 +01:00
dignifiedquire eac0c201bd fix locking in the repl 2019-05-07 15:46:02 +01:00
dignifiedquire 83917ef93e wip - use mmime instead of libetpan 2019-05-07 10:45:46 +01:00
dignifiedquire fc36070f59 implement imap idle 2019-05-06 00:24:49 +02:00
Lars-Magnus Skog 2cf6cde5d1 chore: fix compiler warnings (mut + unused assignments) (#40)
* Stop allowing unused assignments

* test: remove unused assignments in cmdline

* chore: fix compiler warnings in dc_tools.rs

* chore: fix compiler warnings in dc_token.rs

* chore: fix compiler warnings in dc_strencode.rs

* chore: fix compiler warnings in dc_stock.rs

* chore: fix compiler warnings in dc_sqlite3.rs

* chore: fix compiler warnings in dc_simplify.rs

* chore: fix compiler warnings in dc_securejoin.rs

* chore: fix compiler warnings in dc_saxparser.rs

* chore: fix compiler warnings in dc_pgp.rs

* chore: fix compiler warnings in dc_param.rs

* chore: fix compiler warnings in dc_oauth2.rs

* chore: fix compiler warnings in dc_msg.rs

* chore: fix compiler warnings in dc_mimeparser.rs

* chore: fix compiler warnings in dc_mimefactory.rs

* chore: fix compiler warnings in dc_lot.rs

* chore: fix compiler warnings in dc_loginparams.rs

* chore: fix compiler warnings in dc_log.rs

* chore: fix compiler warnings in dc_location.rs

* chore: fix compiler warnings in dc_keyring.rs

* chore: fix compiler warnings in dc_key.rs

* chore: fix compiler warnings in dc_jsmn.rs

* chore: fix compiler warnings in dc_jobthread.rs

* chore: fix compiler warnings in dc_imex.rs

* chore: fix compiler warnings in dc_hash.rs

* chore: fix compiler warnings in dc_e2ee.rs

* chore: fix compiler warnings in dc_context.rs

* chore: fix compiler warnings in dc_contact.rs

* chore: fix compiler warnings in dc_chatlist.rs

* chore: fix compiler warnings in dc_chat.rs

* chore: fix compiler warnings in dc_array.rs

* chore: fix compiler warnings in dc_apeerstate.rs

* chore: fix compiler warnings in dc_aheader.rs

* chore: fix compiler warnings in dc_array.rs

* test: remove compiler warnings in test/stress.rs

* test: reduce compiler warnings in examples/repl/main.rs

* test: std::thread::sleep_ms() is deprecated

* chore: remove unused variable in dc_sqlite3.rs

* chore: fix compiler warnings in dc_receive_imf.rs

* chore: fix compiler warnings in dc_job.rs

* chore: fix compiler warnings in dc_configure.rs

* Fix formatting
2019-05-05 21:58:59 +02:00
dignifiedquire 2fd38cd533 imap: fetch_from_folder 2019-05-05 00:15:45 +02:00
dignifiedquire 424e9db112 more fetch progress 2019-05-05 00:15:45 +02:00
dignifiedquire e7d72dfdd4 fix some locking issues, start rust-imap impl 2019-05-05 00:15:45 +02:00
Lars-Magnus Skog 227a61e16f refactor: remove dc_cleanup_contacts() 🔥 2019-05-03 13:02:14 +02:00
Lars-Magnus Skog e65284ff9d refactor: remove poke_public_key() and dc_key_set_from_file() 🔥 2019-05-03 12:47:24 +02:00
dignifiedquire e187f0f250 fix: allow concurrent access to dc_sqlite3_t 2019-05-02 23:36:09 +02:00
Lars-Magnus Skog 2e4bc048fb test: run stress tests in the regular test setup
Closes #13
2019-05-02 20:48:31 +02:00
dignifiedquire 2c69d6e767 fix dc_tools handling of deletion and reading 2019-05-02 19:31:49 +02:00
dignifiedquire 4ed2d1204c fix(example): improve lock handling in the repl 2019-05-02 17:28:56 +02:00
dignifiedquire fa6dd07dec refactor(tools): use rust-natie for file operations 2019-05-02 16:05:15 +02:00
dignifiedquire ba7d690617 cleanup pthreads 2019-05-02 00:00:54 +02:00
dignifiedquire 3308767b24 examples compile again 2019-05-01 23:41:11 +02:00
dignifiedquire 313f71a004 it compiles 2019-05-01 23:41:11 +02:00
dignifiedquire 75319dbf67 continue rustification 2019-05-01 23:41:11 +02:00
dignifiedquire 72e9fe6150 start reworking context references and smtp, imap 2019-05-01 23:41:11 +02:00