Browse Source

correct triggering of sync events on enable_key_reset_for_identity and key_reset on disable_... - also will now NOT generate a sync event in generate_keypair if the incoming identity's flags do not indicate the identity is grouped.

add_key_notification
parent
commit
ce586a6ade
3 changed files with 32 additions and 10 deletions
  1. +1
    -0
      src/keymanagement.c
  2. +1
    -1
      src/pEpEngine.c
  3. +30
    -9
      src/sync_api.c

+ 1
- 0
src/keymanagement.c View File

@ -1118,6 +1118,7 @@ PEP_STATUS _myself(PEP_SESSION session,
// this user_id + address
// DEBUG_LOG("myself", "debug", identity->address);
// This will grab the actual flags from the db
status = get_identity(session,
identity->address,
identity->user_id,


+ 1
- 1
src/pEpEngine.c View File

@ -4729,7 +4729,7 @@ PEP_STATUS _generate_keypair(PEP_SESSION session,
if (identity->fpr)
status = set_pgp_keypair(session, identity->fpr);
if (!suppress_event)
if ((!suppress_event) && (identity->flags & PEP_idf_devicegroup))
signal_Sync_event(session, Sync_PR_keysync, KeyGen, NULL);
// add to known keypair DB, as this might not end up being a default


+ 30
- 9
src/sync_api.c View File

@ -264,23 +264,38 @@ DYNAMIC_API PEP_STATUS enable_identity_for_sync(PEP_SESSION session,
if (!(session && ident))
return PEP_ILLEGAL_VALUE;
// create the identity in the database if it is not yet there
// create the identity in the database if it is not yet there.
// This generates no events.
PEP_STATUS status = _myself(session, ident, false, true, false);
if (status)
if (status != PEP_STATUS_OK)
return status;
status = unset_identity_flags(session, ident, PEP_idf_not_for_sync);
if (status)
if (status != PEP_STATUS_OK) // explicit. sorry, but lazy makes mistakes in C
return status;
bool grouped;
status = deviceGrouped(session, &grouped);
if (status)
status = set_identity_flags(session, ident, PEP_idf_devicegroup);
if (status != PEP_STATUS_OK)
return status;
if (grouped)
status = set_identity_flags(session, ident, PEP_idf_devicegroup);
return status;
// Let's make sure whatever flags are on the retval are at least correct
// so as to unnecessary reduce dev freakout.
ident->flags = (ident->flags | PEP_idf_devicegroup) & ~PEP_idf_not_for_sync;
// If no key was actually in the DB, make one now.
// This will trigger a sync event.
if (EMPTYSTR(ident->fpr)) {
status = _myself(session, ident, true, true, false);
if (status != PEP_STATUS_OK)
return status;
}
else {
// Ok, we actually had a key. We pretend we generated one to make
// sync play nice.
signal_Sync_event(session, Sync_PR_keysync, KeyGen, NULL);
}
return PEP_STATUS_OK;
}
DYNAMIC_API PEP_STATUS disable_identity_for_sync(PEP_SESSION session,
@ -300,5 +315,11 @@ DYNAMIC_API PEP_STATUS disable_identity_for_sync(PEP_SESSION session,
return status;
status = set_identity_flags(session, ident, PEP_idf_not_for_sync);
if (status)
return status;
ident->flags = (ident->flags | PEP_idf_not_for_sync) & ~PEP_idf_devicegroup;
status = key_reset_identity(session, ident, NULL);
return status;
}

Loading…
Cancel
Save