This marks the function safe and returns Result, it also now returns
the ConfiguredAddr since it has to look this up anyway and it makes
testing more easy. Turns out it reduces some duplicate SQL query in
some callers too.
More test code has been moved from dc_imex to test_utils as it's
more genrally applicable.
* refactor(contact): rename and rusty memory allocations
* refactor(contact): use enum to indidcate origin
* refactor(contact): safe blocking and unblocking api
* refactor(contact): only safe and no more cstrings
Add a trait for str.strdup() to replace to_cstring() which avoid the
signature ambiguity with .to_string().
Also instruduce CString::yolo() as a shortcut to
CString::new().unwrap() and use it whenever the variable does can be
deallocated by going out of scope. This is less error prone.
Use some Path.to_c_string() functions where possible.
This change removes global override of `non_shake_case' warning and replaces it
with per-function overrrides. This way, compiler will complain about style
guide violation in new code.
It should be noted, that `rustc' is not smart enough to emit warning when
override is no longer needed, it must be checked manually.
With this change, passing invalid utf8 string to `dc_send_text_msg' does not
crash application, it prints warning and returns error code.
It should be admitted that this fix is sub-optimal: if input C string is valid
utf8 (which is likely), result of successful conversion to `&str' is discarded
in `dc_send_text_msg', and the same input C string is converted again with
`as_str' in `prepare_msg_raw'.
It is not clear how to fix it in non-disruptive way, since input C string is
passed down to call stack as part of `dc_msg_t' struct, which is part of C ABI.
pattern -- re-indentation will come after this commit with a pure application of "cargo fmt"
- bring back comment from C code
- make some path helpers return bool
* refactor: safe sql access
* Clean up the worst rebase mistakes
* Some more progress on the rebase fallout and this branch
* upgrade and compile again
* cleanup from rebase
* example of how to prepare now
* rebase fixes
* add sql.query_map
* less preparation
* more improvements in sql code
* fix string truncation
* more prepare conversions
* most prep done
* fix tests
* fix ffi
* fix last prepares
* fix segfaults and some queries
* use r2d2 pool
* fix dc_job sql call, to reduce contention
* try newer rust
* No more vararg printing (drop dc_log_)
* ignore expected errors
* fix: uses exists instead of execute where needed
* fix: get_contacts logic was broken
* fix: contact creation
* test on 32bit linux
* ci: try running 32bit without cross
* undo 32bit tests
* refactor: rename dc_sqlite3 to sql
* fix: safer string conversions
* more string fixes
* try fixing appveyor build to 64bit
* chore(ci): hardcode target
* chore(ci): appveyor
* some cleanup work
* try fix darwin
* fix and improve sql escaping
* fix various bugs
* fix chat deletion
* refactor: cleanup config values and move to their own file
* refactor: move more methods onto the sql struct
* dont panic on failed state loading
* first round of cr
* one more cr fix
* stop using strange defaults
* remove unused escapes
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.
This stops using the deprecated libc::uint32_t and libc::uint64_t
types in favour of the native u32 and u64 types.
It also uses a newer nightly compiler to get rid of the incorrect
"unused no_mangle" warning when compiling incrementally.
Finally the newer compiler prefers us to be explicit when implementing
traits using the new dyn keyword.
* Add utility to convert OsStr to CString
This is approach seems acceptable in the context of deltachat, it
should work correctly on unix and on Windows requires paths to be
valid utf-8.
* Use failure crate for error types
* Add OsStrExt impl for Path, fix windows and update docs
- Adds an OsStrExt impl for Path directly, a little more convenience.
- Fix the windows code to actually use the right function name. Test
the impl function on unix too since that was the point of having it
implemented in a separate function to begin with.
- Improve the docs, do hyperlinks a bit better.
* Another attempt at learing to type
Having your compiler in the cloud is just painful.
* Do not treat this as a fatal error
When PRs are made from forks the passwords are unavailable. We don't
want CI to fail because of this.
* Implement using the AsRef<OsStr> trait
This means any type with implements this trait will get this
implementation, thus covering both OsStr and Path instead of having
duplicate implementations for those like before.
* fix format
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.