Function `query_row` executes query and calls callback function to process
row returned. Function query_row_col() is special case, that provides
callback function, which returns value of one particular column of row,
ignoring others.
In all cases, that particular column was 0 (first and only column of
query result), since there is no point to select more than one column
with this function -- they are discarded anyway.
This commit removes that redundancy, removing column number argument of
query_row_col() function and adjusting call sites accordingly.
Adjust call sites as apporiate:
* src/dc_imex.rs(dc_continue_key_transfer): use if-let pattern
with dc_read_file_safe() and dc_msg_get_file()
* src/message.rs(dc_msg_get_setupcodebegin): ditto
* src/message.rs(dc_get_msg_info): simplify code to print information
about file inside a message.
* src/message.rs(dc_msg_get_file): simplify function using
dc_get_abs_path_safe()
* deltachat-ffi/src/lib.rs(dc_msg_get_file): convert PathBuf to `char *`
to preserve C API
The Message struct had a reference to the context which made a few
APIs a little easier. However it has surprising consequences a long
way down the line as shown in #335: it means any object which has such
a reference needs to keep open a lock if we want to do this refactor
of no longer having a "closed" Context struct on the Rust API (which
has many benefits which will simply that Context struct and is more
the Rust way - RAII etc).
By refactoring away the context reference on the rust API as done in
here however, we push this behaviour of how these references are
handled back to the C-API pointer behaviour: that is unsafe but just
works in a C-like way. The resulting complexity in the FFI layer is
also notably less than in the #335 alternative.
As a consequence all APIs which require the context, now explicitly
need to get the context passed in as an argument. It looks like this
is certainly no downside and maybe even beneficial for further API
refactors.
For this strategy to work out the same should be done to
dc_chatlist_t, dc_chat_t and dc_contact_t. But this working for
dc_msg_t give a reasonable confidence that this is a good approach.
Replace `if (ok) { }` pattern with `if (!ok) return` to reduce
indentation level.
Note: This commit fails CI due incorrect formatting. It is done
deliberately to simplify review process.
Previously, logging macros (info! warn! error!) accepted integer
argument (data1), that was passed to callback function verbatim. In all
call sites this argument was 0.
With this change, that data1 argument is no longer part of macro
interface, 0 is always passed to callback in internals of these macros.
Previously, boolean configurations were implemented on top of i32
(get_config_int, set_config_it) at call sites.
Having one canonical location, containing boolean <-> database
conversion may help to avoid serialization issues.
Currently, `src/top_evil_rs.py' script recursively scans current
directory for Rust sources and print statistics about them.
When run from git root, it also scans target/ directory, which is
useless.
This commit add cludge that checks if script is run from git root
directory, and `chdir' into `src/' before performing actions.
Unprincipled, but convenient.