Commit Graph
338 Commits
Author SHA1 Message Date
Floris BruynoogheandAlexander Krotov 145fd8657f Update deltachat-ffi/src/lib.rs
Co-Authored-By: Alexander Krotov <ilabdsf@gmail.com>
2020-02-06 22:00:29 +01:00
Floris BruynoogheandAlexander Krotov 01b55d1d29 Update deltachat-ffi/src/lib.rs
Co-Authored-By: Alexander Krotov <ilabdsf@gmail.com>
2020-02-06 22:00:29 +01:00
Floris Bruynooghe 98b3151c5f Refactor keypair handling and expose storing keypairs on ffi
The user-visible change here is that it allows the FFI API to save
keys in the database for a context.  This is primarily intended for
testing purposes as it allows you to get a key without having to
generate it.

Internally the most important change is to start using the
SignedPublicKey and SignedPrivateKey types from rpgp instead of
wrapping them into a single Key object.  This allows APIs to be
specific about which they want instead of having to do runtime checks
like .is_public() or so.  This means some of the functionality of the
Key impl now needs to be a trait.

A thid API change is to introduce the KeyPair struct, which binds
together the email address, public and private key for a keypair.

All these changes result in a bunch of cleanups, though more more
should be done to completely replace the Key type with the
SignedPublicKye/SignedPrivateKey + traits.  But this change is large
enough already.

Testing-wise this adds two new keys which can be loaded from disk and
and avoids a few more key-generating tests.  The encrypt/decrypt tests
are moved from the stress tests into the pgp tests and split up.
2020-02-06 22:00:29 +01:00
B. Petersen cce32229e0 do not bubble up errors on dc_has_import()
error!() will show the error directly to the user,
this is not useful in this case,
and also the message with the function-name is not for the end-user.

instead, the ui shall (and already does)
show some explaining text if dc_has_import() returns false;
the error!() is disturbing here as this results in two hints shown to the user.
2020-02-01 22:33:18 +00:00
B. Petersen 748e54d4c2 add basic provider-functions 2020-01-30 17:47:40 +01:00
B. Petersen fbe57c4c71 adapt provider-db api to real need 2020-01-30 17:47:39 +01:00
Alexander Krotov 033a44580c Turn get_[fresh_]msg_cnt() into ChatId members 2020-01-25 22:11:13 +00:00
Alexander Krotov 889327b5f6 Rename Chat.archive() into Chat.set_archived() 2020-01-25 22:11:13 +00:00
Alexander Krotov a2845f44ab Turn ChatId-related functions into methods 2020-01-25 22:11:13 +00:00
Floris Bruynooghe 186f5553b8 Introduce a ChatId newtype
This doesn't try and change the way ChatId is used.  It still allows
creating them with 0 and lets some function use a ChatId(0) as error
return.
2020-01-19 23:42:08 +01:00
Alexander Krotov ffa6378108 Fix clippy warnings in deltachat-ffi 2019-12-27 10:28:50 +00:00
B. Petersen f73ba895af remove some meanwhile unneeded allow-statements 2019-12-26 16:26:06 +00:00
Alexander Krotov 8e0a29e9b5 Stop using Event callback return values
Since stock string callback has been deprecated, all event callbacks
return 0.

For compatibility, C declarations are not changed and FFI users are
expected to return 0 from their callbacks.
2019-12-21 22:51:44 +00:00
Floris Bruynooghe ec40dd1b6f Change the JSON API function to be from a serialised struct
This is the first experiment towards using structs to define the API.
It adds it as a new method on the existing Chat struct.

The types in this struct could improve as well as many other things.
But this is a straight forward translation of the existing json! macro
into a struct.
2019-12-20 10:39:39 +01:00
holger krekel a7b55edb9b more call sites 2019-12-19 12:06:01 +01:00
Alexander Krotov 2cebed4f77 Move dc_array.rs to deltachat-ffi package 2019-12-08 00:30:43 +01:00
jikstra 965d41990e change return to "" for errors 2019-12-05 18:57:19 +01:00
jikstra a7e1b4653e Apply requested changes 2019-12-05 18:57:19 +01:00
holger krekel 74825a0f57 working example 2019-12-05 18:57:19 +01:00
dignifiedquire db88212a64 refactor: unsafe, CStr and libc moved out 2019-12-03 12:25:22 +01:00
B. Petersen 521e44bd54 add ffi for update_device_chats() 2019-12-02 16:33:24 +01:00
holger krekel 76610f1e72 rename to more specific name, also not using the difficult to type "succeeded" word :) 2019-11-27 13:02:07 +01:00
B. Petersen f53b3c2e7b add DC_EVENT_SECUREJOIN_SUCCEEDED 2019-11-27 00:43:50 +01:00
holger krekel eae9ad6f8b remove context.inbox in favour of a context.inbox_thread following the mvbox_thread and sentbox_thread patterns. Also some streamlining of shutdown logic. 2019-11-22 12:28:19 +01:00
B. Petersen e4e6a00fe4 rename has_device_msg() to was_device_msg_ever_added() what describes better what the function is doing 2019-11-19 13:21:02 +01:00
B. Petersen 700e10bc0e use dc_add_device_msg() also to add labels-only, this is clearer as having a function with 'skip' in the name 2019-11-19 13:05:01 +01:00
B. Petersen d3fa289f27 streamline dc_add_device_msg_once|unlabelled() to one function 2019-11-19 11:49:02 +01:00
B. Petersen 1534a07ded add dc_has_device_msg() 2019-11-18 17:31:03 +01:00
B. Petersen a4e92694ba name unlabelled device-messages as such 2019-11-18 16:47:18 +01:00
B. Petersen 035da9e5d7 add dc_skip_device_msg() and belonging tests 2019-11-18 16:47:18 +01:00
B. Petersen b42d8799b4 add dc_add_device_msg_once() to fii 2019-11-12 16:10:48 +01:00
B. Petersen 4c30bf80ce target comments of @flub 2019-11-06 13:33:30 +01:00
B. Petersen b5d5d98645 implement add_device_msg() 2019-11-06 13:33:30 +01:00
B. Petersen cbaa4e03b3 basic devicetalk implementation 2019-11-06 13:33:30 +01:00
B. Petersen e4b3e23769 prefer to_string_lossy() over as_str() as the latter pancis on non-wellformatted utf-8 2019-11-01 00:46:48 +01:00
holger krekel c56c10bced remove unneccessary check of is_special() + cleanups 2019-10-30 19:29:13 +01:00
holger krekel b0ccbc36d9 fix FFI-behaviour: return default empty messages when asked for special ones 2019-10-30 19:29:13 +01:00
holger krekel 9cdfc3409d systematically ignore invalid message ids when passed in through CFFI 2019-10-30 19:29:13 +01:00
holger krekel 911c0e45dc expose empty server functionality and test it (also introducing a new DC_EVENT_IMAP_FOLDER_EMPTIED event) 2019-10-29 22:19:13 +01:00
Floris Bruynooghe c8d296ea0e A MsgId newtype
This more strongly types the ubiquitous message id type by no longer
making it an integer.  It keeps the actual ID opaque.  Only for the
generic job API the number keeps being used.  Some locations also need
to create it from an integer and call MsgId::new().
2019-10-29 15:30:53 +01:00
B. Petersen 51f43842cf cargo fmt 2019-10-27 11:42:56 +01:00
B. Petersen 8015ba1d64 dc_get_chat_id_by_contact_id() returns 0 if no chat is found.
this is no error;
in fact, the function is used to probe
if there is a chat with a given contact at several places
eg. in the android-ui.
2019-10-26 18:37:33 +02:00
Dmitry Bogatov a9dd78f622 Narrow return type of location::set: cint -> bool 2019-10-19 22:38:43 +02:00
B. Petersen 7b958a20fd prefer to_string_lossy() over as_str() as the latter pancis on non-wellformatted utf-8 2019-10-19 22:30:25 +02:00
B. Petersen 4519071718 prefer to_opt_string_lossy() over as_opt_str() as the latter pancis on non-wellformatted utf-8 2019-10-19 22:30:25 +02:00
B. Petersen bb08b39c71 remove duplicated code 2019-10-19 22:30:25 +02:00
holger krekel 24c0a833bd address @flub comments 2019-10-09 15:59:31 +02:00
holger krekel 45f011c63c expose and test set_stock_translation to Python 2019-10-09 15:59:31 +02:00
holger krekel b82af9fff3 introduce set_stock_translation and remove call to DC_EVENT_GET_STRING 2019-10-09 15:59:31 +02:00
holger krekel b8f211a013 cargo fmt 2019-10-07 00:55:33 +02:00