Browse Source

ENGINE-140 clean'up own_identities_retrieve so that available pEpEngine API returns all own identities, not only those that can be synced

doc_update_sequoia
Edouard Tisserant 6 years ago
parent
commit
857449c676
6 changed files with 59 additions and 11 deletions
  1. +21
    -4
      src/keymanagement.c
  2. +31
    -0
      src/keymanagement.h
  3. +2
    -2
      src/pEpEngine.c
  4. +2
    -2
      src/sync_impl.c
  5. +2
    -2
      src/sync_send_actions.c
  6. +1
    -1
      sync/gen_actions_skeleton.ysl2

+ 21
- 4
src/keymanagement.c View File

@ -822,9 +822,10 @@ DYNAMIC_API PEP_STATUS own_key_is_listed(
return status;
}
DYNAMIC_API PEP_STATUS own_identities_retrieve(
PEP_STATUS _own_identities_retrieve(
PEP_SESSION session,
identity_list **own_identities
identity_list **own_identities,
identity_flags_t excluded_flags
)
{
PEP_STATUS status = PEP_STATUS_OK;
@ -852,6 +853,7 @@ DYNAMIC_API PEP_STATUS own_identities_retrieve(
identity_list *_bl = _own_identities;
do {
sqlite3_bind_int(session->own_identities_retrieve, 1, excluded_flags);
result = sqlite3_step(session->own_identities_retrieve);
switch (result) {
case SQLITE_ROW:
@ -913,9 +915,18 @@ the_end:
return status;
}
DYNAMIC_API PEP_STATUS own_keys_retrieve(
DYNAMIC_API PEP_STATUS own_identities_retrieve(
PEP_SESSION session,
identity_list **own_identities
)
{
return _own_identities_retrieve(session, own_identities, 0);
}
PEP_STATUS _own_keys_retrieve(
PEP_SESSION session,
stringlist_t **keylist
stringlist_t **keylist,
identity_flags_t excluded_flags
)
{
PEP_STATUS status = PEP_STATUS_OK;
@ -934,6 +945,7 @@ DYNAMIC_API PEP_STATUS own_keys_retrieve(
stringlist_t *_bl = _keylist;
do {
sqlite3_bind_int(session->own_keys_retrieve, 1, excluded_flags);
result = sqlite3_step(session->own_keys_retrieve);
switch (result) {
case SQLITE_ROW:
@ -976,6 +988,11 @@ the_end:
return status;
}
DYNAMIC_API PEP_STATUS own_keys_retrieve(PEP_SESSION session, stringlist_t **keylist)
{
return _own_keys_retrieve(session, keylist, 0);
}
// TODO: Unused for now, but should be used when sync receive old keys (ENGINE-145)
DYNAMIC_API PEP_STATUS set_own_key(
PEP_SESSION session,


+ 31
- 0
src/keymanagement.h View File

@ -171,6 +171,22 @@ DYNAMIC_API PEP_STATUS own_key_is_listed(
);
// _own_identities_retrieve() - retrieve all own identities
//
// parameters:
// session (in) session to use
// own_identities (out) list of own identities
// excluded_flags (int) flags to exclude from results
//
// caveat:
// the ownership of the copy of own_identities goes to the caller
DYNAMIC_API PEP_STATUS _own_identities_retrieve(
PEP_SESSION session,
identity_list **own_identities,
identity_flags_t excluded_flags
);
// own_identities_retrieve() - retrieve all own identities
//
// parameters:
@ -188,6 +204,21 @@ DYNAMIC_API PEP_STATUS own_identities_retrieve(
PEP_STATUS contains_priv_key(PEP_SESSION session, const char *fpr,
bool *has_private);
// _own_keys_retrieve() - retrieve all flagged keypair fingerprints
//
// parameters:
// session (in) session to use
// keylist (out) list of fingerprints
// excluded_flags (int) flags to exclude from results
//
// caveat:
// the ownership of the list goes to the caller
DYNAMIC_API PEP_STATUS _own_keys_retrieve(
PEP_SESSION session,
stringlist_t **keylist,
identity_flags_t excluded_flags
);
// own_keys_retrieve() - retrieve all flagged keypair fingerprints
//
// parameters:


+ 2
- 2
src/pEpEngine.c View File

@ -411,12 +411,12 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
" join trust on id = trust.user_id"
" and pgp_keypair_fpr = identity.main_key_id"
" where identity.user_id = '" PEP_OWN_USERID "'"
" and (identity.flags & 1) = 0;";
" and (identity.flags & ?1) = 0;";
sql_own_keys_retrieve =
"select fpr from own_keys"
" natural join identity"
" where (identity.flags & 1) = 0;"; // PEP_idf_not_for_sync
" where (identity.flags & ?1) = 0;";
sql_set_own_key = "insert or replace into own_keys (address, user_id, fpr)"
" values (?1, '" PEP_OWN_USERID "', upper(replace(?2,' ','')));";


+ 2
- 2
src/sync_impl.c View File

@ -579,7 +579,7 @@ PEP_STATUS unicast_msg(
}
stringlist_t *keylist = NULL;
status = own_keys_retrieve(session, &keylist);
status = _own_keys_retrieve(session, &keylist, PEP_idf_not_for_sync);
if (status != PEP_STATUS_OK)
goto error;
@ -641,7 +641,7 @@ PEP_STATUS multicast_self_msg(
return PEP_ILLEGAL_VALUE;
identity_list *own_identities = NULL;
status = own_identities_retrieve(session, &own_identities);
status = _own_identities_retrieve(session, &own_identities, PEP_idf_not_for_sync);
if (status != PEP_STATUS_OK)
return status;


+ 2
- 2
src/sync_send_actions.c View File

@ -134,7 +134,7 @@ PEP_STATUS sendGroupKeys(
if (!msg)
goto enomem;
status = own_identities_retrieve(session, &kl);
status = _own_identities_retrieve(session, &kl, PEP_idf_not_for_sync);
if (status != PEP_STATUS_OK)
goto error;
if (IdentityList_from_identity_list(kl, &msg->payload.choice.groupKeys.ownIdentities) == NULL)
@ -190,7 +190,7 @@ PEP_STATUS sendGroupUpdate(
if (!msg)
goto enomem;
status = own_identities_retrieve(session, &kl);
status = _own_identities_retrieve(session, &kl, PEP_idf_not_for_sync);
if (status != PEP_STATUS_OK)
goto error;
if (IdentityList_from_identity_list(kl, &msg->payload.choice.groupUpdate.ownIdentities) == NULL)


+ 1
- 1
sync/gen_actions_skeleton.ysl2 View File

@ -169,7 +169,7 @@ tstylesheet {
choose {
when "$name='GroupKeys' or $name='GroupUpdate'" {
|
|> status = own_identities_retrieve(session, &kl);
|> status = _own_identities_retrieve(session, &kl, PEP_idf_not_for_sync);
|> if (status != PEP_STATUS_OK)
|>> goto error;
|> if (IdentityList_from_identity_list(kl, &msg->payload.choice.«$lname».ownIdentities) == NULL)


Loading…
Cancel
Save