Commit Graph

111 Commits

Author SHA1 Message Date
Simon Laux 1d32e010ae Merge pull request #397 from deltachat/move_autoconfig_to_dedicated_file
Move moz- and outlk-autoconfig to dedicated files
2019-08-19 19:42:25 +02:00
Simon Laux 91481caf89 cargo fmt 2019-08-19 19:04:12 +02:00
Simon Laux 491826556b renaming dc_configure to configure
and renaming the autoconfigure modules
2019-08-19 19:03:46 +02:00
dignifiedquire 39abb0b0ad refactor(message): rename dc_msg to message 2019-08-19 12:13:11 +02:00
dignifiedquire cb6c8ac78b refactor(msg): use rust based allocations 2019-08-19 12:10:26 +02:00
Friedel Ziegelmayer a906faeb35 refactor: a rusty job
* refactor(jobthread): safe and rusty
* refactor(job): rusty and safe
2019-08-19 12:07:13 +02:00
Alexander Krotov 1a8e08e429 Merge pull request #396 from deltachat/chat-array
Remove dc_array_t from chat.rs
2019-08-19 06:55:58 +00:00
dignifiedquire d47a693611 refactor: rename dc_qr -> qr 2019-08-19 08:06:54 +02:00
dignifiedquire 886262539a refactor: save lot implementation and follow up refactors
rewrote qr code to match the now safe lot
2019-08-19 08:06:54 +02:00
dignifiedquire b5c66dd52a refactor(lot): rust memory management 2019-08-19 08:06:54 +02:00
Alexander Krotov e7cf5a546a Remove dc_array_t from chat.rs 2019-08-18 23:02:16 +03:00
Alexander Krotov 6b2fe03d08 Replace dc_array_t with Vec in context.rs 2019-08-18 12:44:49 +02:00
dignifiedquire 13d8306a7b refactor(chat): some minor cleanup and api improvements 2019-08-17 11:40:43 +02:00
dignifiedquire 9b1a74cc22 refactor(chat): remove C strings from the public interface 2019-08-17 11:40:43 +02:00
dignifiedquire 25e97df641 refactor(chat): store rust strings in the chat struct 2019-08-17 11:35:02 +02:00
dignifiedquire 001880e1f0 refactor(chat): first round of method renaming and restructuring 2019-08-17 11:34:10 +02:00
dignifiedquire ddfd067e97 refactor(chat): rust based memory management 2019-08-17 11:30:26 +02:00
dignifiedquire 64117c2964 refactor(chat): rename dc_chat to chat 2019-08-17 11:30:26 +02:00
dignifiedquire c8ce099f22 refactor(chat): improve field types by using enums and bools 2019-08-17 11:29:08 +02:00
Alexander Krotov 37622af55a Return Vec<dc_location> from dc_get_locations 2019-08-15 20:43:04 +02:00
dignifiedquire 712f5a9782 refactor(tools): cleanup and make clippy a little happier
Uses a crate now for extracing image meta data, instead of our own hand rolled code.
2019-08-15 11:26:32 +02:00
dignifiedquire 523141597e chore: remove no longer needed features 2019-08-13 12:20:53 +02:00
Jikstra 2445b12898 Merge pull request #342 from deltachat/rm_goto_cmdline
rm GOTO: cmdline
2019-08-13 02:09:14 +02:00
Alexander Krotov fb7bbac524 Return Vec from dc_get_chat_contacts 2019-08-13 02:37:18 +03:00
Jikstra 3ac1eaf7d2 Merge pull request #341 from deltachat/add_cmdline_quit_cmd
add quit command as alias to exit in cmdline
2019-08-13 00:49:27 +02:00
Simon Laux bdf8cd2dd5 add quit command as alias to exit in cmdline 2019-08-12 01:52:09 +02:00
B. Petersen 5554df29fd show full chatlist by just entering 'chats' in cmdline 2019-08-12 01:40:04 +02:00
Simon Laux 2dd3088f50 cargo fmt 2019-08-12 01:33:07 +02:00
Simon Laux b9bd128c7a goto to ok_to_continue 2019-08-12 01:32:34 +02:00
B. Petersen adb67d1910 off by one: show chats cnt-1..0 instead of cnt-1..1 2019-08-12 01:28:36 +02:00
Floris Bruynooghe 5438be891b Remove dc_context_unref from Rust API
This removes the dc_context_unref function from the Rust API which was
just an alias for dc_close.  It still exists on the C API where it
makes sure to free the memory.

It also implements Drop for the context which just calls dc_close to
make sure all the memory is freed.  Since you can call dc_close as
many times as you like this ensures that at the Rust level you can't
Drop the struct without releasing the memory.

Finally since memory is now freed by dropping the struct this removes
the #[repr(C)] for the struct.  This struct is fully opaque to the C
API.
2019-08-10 12:04:11 +02:00
Floris Bruynooghe f31f603c8b Turn dc_ensure_secret_key_existy into something more rusty
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.
2019-08-10 11:14:40 +02:00
Friedel Ziegelmayer ea6972118a refactor: rusty contact
* 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
2019-08-07 22:20:48 +02:00
Dmitry Bogatov 765ac2005e Change type of dc_msg_t.text to String
Also, remove `send-garbage' command from REPL, since it is not possible to send
non-utf8 string anymore.
2019-08-07 20:31:02 +02:00
Floris Bruynooghe d37dda6f50 Turn the function safe 2019-08-03 01:00:59 +02:00
Floris Bruynooghe b6b0849bce Remove to_cstring() naming convention ambiguity
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.
2019-08-01 19:06:39 +02:00
Dmitry Bogatov c04c8ff103 Introduce new enum: Viewtype
With this change, kind of message is represented by value of enum
`Viewtype' instead of raw libc::c_int, providing more type safety. This
enum replaces DC_MSG_* constants. The only way to create `Viewtype' from
libc::c_int is smart constructor.

With this change, functions `dc_get_chat_media' and `dc_get_next_media' became
less forgiving about invalid message type arguments. Previously, invalid
message types were implicitly interpreted as 0 (Viewtype::Unknown). Now,
function calls with invalid message type arguments are rejected (error code
returned) on FFI boundary.

Additionally, when `Viewtype' is read from database, it is checked to have
sensible value.

No tests assumed forgiving behaviour.
2019-08-01 06:05:56 +00:00
Friedel Ziegelmayer 3370b9cfcb Merge pull request #268 from KAction/string-os-name
Change Context.os_name field to String
2019-07-31 22:13:18 +02:00
Dmitry Bogatov 39e530f759 Change Context.os_name field to String 2019-07-31 15:45:35 +00:00
Dmitry Bogatov a41c0614cc Make dc_msg_is_starred() return bool 2019-07-30 22:57:28 +00:00
Friedel Ziegelmayer 7ba1a6f79f Merge pull request #255 from link2xt/dc_open-safer
Make dc_open arguments rusty
2019-07-30 00:21:03 +02:00
Alexander Krotov 27342f50b5 Remove unsafe version of dc_timestamp_to_str 2019-07-29 18:45:12 +03:00
Alexander Krotov 2d5b04148f Make dc_open arguments rusty 2019-07-29 04:05:21 +03:00
Alexander Krotov 0e6b12d7ae Move to_string out of dc_create_setup_code 2019-07-28 15:05:28 +03:00
Friedel Ziegelmayer b23ca26908 refactor(chatlist): rustify 2019-07-28 11:32:48 +02:00
Friedel Ziegelmayer 30668aaecf Merge pull request #237 from KAction/repl__do_not_treat_empty_string_as_command_
repl: do not treat empty string as command
2019-07-27 12:31:30 +02:00
Friedel Ziegelmayer 6dfc019163 Merge pull request #236 from KAction/Make_repl_program_more_robust_
Make repl program more robust
2019-07-27 12:31:02 +02:00
Dmitry Bogatov 36b5f4da53 Check if input to dc_send_text_msg is valid utf8
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.
2019-07-27 09:04:20 +00:00
Dmitry Bogatov d1968d8ccb New repl command: send-garbage
This new command attempts to send malformed utf8 string to current chat with
dc_send_text_msg() function. Currently, instead of error code it causes
application crash with following backtrace:

thread 'main' panicked at 'Non utf8 string: '[255]' (Utf8Error { valid_up_to: 0, error_len: Some(1) })', src/dc_t
ools.rs:1571:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
   7: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:384
   8: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:339
   9: deltachat::dc_tools::as_str::{{closure}}
             at src/dc_tools.rs:1571
  10: core::result::Result<T,E>::unwrap_or_else
             at /rustc/0b680cfce544ff9a59d720020e397c4bf3346650/src/libcore/result.rs:818
  11: deltachat::dc_tools::as_str
             at src/dc_tools.rs:1570
  12: deltachat::dc_chat::prepare_msg_raw
             at src/dc_chat.rs:726
  13: deltachat::dc_chat::prepare_msg_common
             at src/dc_chat.rs:461
  14: deltachat::dc_chat::dc_send_msg
             at src/dc_chat.rs:905
  15: deltachat::dc_chat::dc_send_text_msg
             at src/dc_chat.rs:981
  16: repl::cmdline::dc_cmdline
             at examples/repl/cmdline.rs:955
  17: repl::handle_cmd
             at examples/repl/main.rs:566
  18: repl::main_0
             at examples/repl/main.rs:445
  19: repl::main
             at examples/repl/main.rs:578
  20: std::rt::lang_start::{{closure}}
             at /rustc/0b680cfce544ff9a59d720020e397c4bf3346650/src/libstd/rt.rs:64
  21: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:49
  22: std::panicking::try::do_call
             at src/libstd/panicking.rs:296
  23: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:82
  24: std::panicking::try
             at src/libstd/panicking.rs:275
  25: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  26: std::rt::lang_start_internal
             at src/libstd/rt.rs:48
  27: std::rt::lang_start
             at /rustc/0b680cfce544ff9a59d720020e397c4bf3346650/src/libstd/rt.rs:64
  28: main
  29: __libc_start_main
  30: _start
2019-07-27 08:16:18 +00:00
Dmitry Bogatov a9c714748d Make repl program more robust
This change replaces calls to unwrap() function with "?" operator, propagating
error up the call stack. This way "chat foo" (for example) command results in

      Error: invalid digit found in string

message instead of crashing whole repl.
2019-07-27 07:43:45 +00:00