Browse Source

clearer

add_key_notification
Volker Birk 2 years ago
parent
commit
f9aca64aba
3 changed files with 60 additions and 45 deletions
  1. +4
    -1
      src/keymanagement.c
  2. +19
    -44
      sync/cond_act_sync.yml2
  3. +37
    -0
      sync/gen_actions.ysl2

+ 4
- 1
src/keymanagement.c View File

@ -1898,8 +1898,11 @@ DYNAMIC_API PEP_STATUS set_own_key(
assert(!EMPTYSTR(me->user_id));
assert(!EMPTYSTR(me->username));
// deliver a copy
assert(me->fpr != fpr);
if (!session || !me || EMPTYSTR(fpr) || EMPTYSTR(me->address) ||
EMPTYSTR(me->user_id) || EMPTYSTR(me->username))
EMPTYSTR(me->user_id) || EMPTYSTR(me->username) || me->fpr == fpr)
return PEP_ILLEGAL_VALUE;
status = _myself(session, me, false, true, false);


+ 19
- 44
sync/cond_act_sync.yml2 View File

@ -399,60 +399,35 @@ action saveGroupKeys
}
identity_list *oil = session->sync_state.own.identities;
char *fpr = NULL;
// BUG: this should be a transaction and been rolled back completely on error
for (identity_list *_il = il; _il && _il->ident; _il = _il->next) {
pEp_identity *ident = _il->ident;
bool is_own_already = false;
if (fpr)
free(fpr);
status = is_own_address(session, ident->address, &is_own_already);
if (status) {
free_identity_list(il);
free(user_id);
return status;
}
bool found = false;
status = _have_identity_in(oil, _il->ident, &found);
if (status)
break;
free(ident->user_id);
ident->user_id = strdup(user_id);
assert(ident->user_id);
if (!ident->user_id) {
free_identity_list(il);
free(user_id);
return PEP_OUT_OF_MEMORY;
}
if (!found) {
_il->ident->me = true;
if (is_own_already) {
ident->comm_type = PEP_ct_pEp;
status = set_trust(session, ident);
}
else {
pEp_identity *_ident = identity_dup(ident);
if (!_ident) {
free_identity_list(il);
free(user_id);
return PEP_OUT_OF_MEMORY;
fpr = strdup(_il->ident->fpr);
assert(fpr);
if (!fpr) {
status = PEP_OUT_OF_MEMORY;
break;
}
oil = identity_list_add(oil, _ident);
if (!oil) {
free_identity_list(il);
free(user_id);
return PEP_OUT_OF_MEMORY;
}
status = _myself(session, _ident, false, true, false);
if (status) {
free_identity_list(il);
free(user_id);
return status;
}
status = set_own_key(session, _ident, ident->fpr);
}
if (status) {
free_identity_list(il);
free(user_id);
return status;
status = set_own_key(session, _il->ident, fpr);
if (status)
break;
}
}
free(fpr);
free(user_id);
free_identity_list(il);
||


+ 37
- 0
sync/gen_actions.ysl2 View File

@ -53,6 +53,43 @@ tstylesheet {
return memcmp(t1->buf, t2->buf, t1->size) > 0;
}
static bool _same_identity(pEp_identity *ident1, pEp_identity *ident2)
{
if (!(ident1 && ident1->user_id && ident1->address && ident2 && ident2->user_id && ident2->address))
return false;
return strcmp(ident1->user_id, ident2->user_id) == 0
&& strcmp(ident1->address, ident2->address) == 0;
}
static PEP_STATUS _have_identity_in(identity_list *il, pEp_identity *ident, bool *found)
{
assert(il && ident);
if (!(il && ident))
return PEP_ILLEGAL_VALUE;
bool _found = false;
for (identity_list *_il = il; _il && _il->ident; _il = _il->next) {
if (_same_identity(_il->ident, ident)) {
_found = true;
break;
}
}
if (!_found) {
pEp_identity *_ident = identity_dup(ident);
if (!_ident)
return PEP_OUT_OF_MEMORY;
identity_list *_il = identity_list_add(il, _ident);
if (!_il) {
free(_ident);
return PEP_OUT_OF_MEMORY;
}
}
*found = _found;
return PEP_STATUS_OK;
}
||
apply "func:distinctName(//condition)", 0;
apply "func:distinctName(//action)", 0;


Loading…
Cancel
Save