From fc0292bf8ac1af59aaee97cd0c0e286db3a7e4f1 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Thu, 6 Feb 2020 21:32:17 +0100 Subject: [PATCH] Rename save_self_keypair For the ffi rename to dc_preconfigure_keypair. For the internal API to store_self_keypair. --- deltachat-ffi/deltachat.h | 2 +- deltachat-ffi/src/lib.rs | 4 ++-- python/src/deltachat/account.py | 10 +++++----- python/tests/test_account.py | 8 ++++---- src/e2ee.rs | 2 +- src/imex.rs | 2 +- src/key.rs | 8 ++++---- src/test_utils.rs | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 9ee3dc012..ff9128fd3 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -870,7 +870,7 @@ void dc_maybe_network (dc_context_t* context); * @param secret_data The secret key as base64. * @return 1 on success, 0 on failure. */ -int _dc_save_self_keypair (dc_context_t* context, const char *addr, const char *public_data, const char *secret_data); +int dc_preconfigure_keypair (dc_context_t* context, const char *addr, const char *public_data, const char *secret_data); // handle chatlists diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index c81a361ab..28cfb4d42 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -691,7 +691,7 @@ pub unsafe extern "C" fn dc_maybe_network(context: *mut dc_context_t) { } #[no_mangle] -pub unsafe extern "C" fn _dc_save_self_keypair( +pub unsafe extern "C" fn dc_preconfigure_keypair( context: *mut dc_context_t, addr: *const libc::c_char, public_data: *const libc::c_char, @@ -712,7 +712,7 @@ pub unsafe extern "C" fn _dc_save_self_keypair( public, secret, }; - key::save_self_keypair(ctx, &keypair, key::KeyPairUse::Default)?; + key::store_self_keypair(ctx, &keypair, key::KeyPairUse::Default)?; Ok(1) }) .log_warn(ffi_context, "Failed to save keypair") diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index bf1e5afb4..bab846cd3 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -118,15 +118,15 @@ class Account(object): assert res != ffi.NULL, "config value not found for: {!r}".format(name) return from_dc_charpointer(res) - def _save_self_keypair(self, addr, public, secret): + def _preconfigure_keypair(self, addr, public, secret): """See _dc_save_self_keypair() in deltachat.h. In other words, you don't need this. """ - res = lib._dc_save_self_keypair(self._dc_context, - as_dc_charpointer(addr), - as_dc_charpointer(public), - as_dc_charpointer(secret)) + res = lib.dc_preconfigure_keypair(self._dc_context, + as_dc_charpointer(addr), + as_dc_charpointer(public), + as_dc_charpointer(secret)) if res == 0: raise Exception("Failed to set key") diff --git a/python/tests/test_account.py b/python/tests/test_account.py index f924ab2c4..4d9b379c1 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -35,11 +35,11 @@ class TestOfflineAccountBasic: ac1 = Account(p.strpath, os_name="solarpunk") ac1.get_info() - def test_save_self_keypair(self, acfactory, datadir): + def test_preconfigure_keypair(self, acfactory, datadir): ac = acfactory.get_unconfigured_account() - ac._save_self_keypair("alice@example.com", - datadir.join('key/alice-public.asc').read(), - datadir.join('key/alice-secret.asc').read()) + ac._preconfigure_keypair("alice@example.com", + datadir.join('key/alice-public.asc').read(), + datadir.join('key/alice-secret.asc').read()) def test_getinfo(self, acfactory): ac1 = acfactory.get_unconfigured_account() diff --git a/src/e2ee.rs b/src/e2ee.rs index cc13abcf2..d19b9e965 100644 --- a/src/e2ee.rs +++ b/src/e2ee.rs @@ -215,7 +215,7 @@ fn load_or_generate_self_public_key( "Generating keypair with {} bits, e={} ...", 2048, 65537, ); let keypair = pgp::create_keypair(EmailAddress::new(self_addr.as_ref())?)?; - key::save_self_keypair(context, &keypair, KeyPairUse::Default)?; + key::store_self_keypair(context, &keypair, KeyPairUse::Default)?; info!( context, "Keypair generated in {:.3}s.", diff --git a/src/imex.rs b/src/imex.rs index be30a6bcd..c261b5bd4 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -324,7 +324,7 @@ fn set_self_key( public, secret, }; - key::save_self_keypair( + key::store_self_keypair( context, &keypair, if set_default { diff --git a/src/key.rs b/src/key.rs index e543b40c6..372e16dad 100644 --- a/src/key.rs +++ b/src/key.rs @@ -335,7 +335,7 @@ impl SaveKeyError { } } -/// Save the keypair as an owned keypair for addr. +/// Store the keypair as an owned keypair for addr in the database. /// /// This will save the keypair as keys for the given address. The /// "self" here refers to the fact that this DC instance owns the @@ -347,7 +347,7 @@ impl SaveKeyError { /// same key again overwrites it. /// /// [Config::ConfiguredAddr]: crate::config::Config::ConfiguredAddr -pub fn save_self_keypair( +pub fn store_self_keypair( context: &Context, keypair: &KeyPair, default: KeyPairUse, @@ -590,9 +590,9 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD .unwrap() }; assert_eq!(nrows(), 0); - save_self_keypair(&t.ctx, &KEYPAIR, KeyPairUse::Default).unwrap(); + store_self_keypair(&t.ctx, &KEYPAIR, KeyPairUse::Default).unwrap(); assert_eq!(nrows(), 1); - save_self_keypair(&t.ctx, &KEYPAIR, KeyPairUse::Default).unwrap(); + store_self_keypair(&t.ctx, &KEYPAIR, KeyPairUse::Default).unwrap(); assert_eq!(nrows(), 1); } } diff --git a/src/test_utils.rs b/src/test_utils.rs index fa98bcd6c..34dd02012 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -85,7 +85,7 @@ pub(crate) fn configure_alice_keypair(ctx: &Context) -> String { let keypair = alice_keypair(); ctx.set_config(Config::ConfiguredAddr, Some(&keypair.addr.to_string())) .unwrap(); - key::save_self_keypair(&ctx, &keypair, key::KeyPairUse::Default) + key::store_self_keypair(&ctx, &keypair, key::KeyPairUse::Default) .expect("Failed to save Alice's key"); keypair.addr.to_string() }