Browse Source

set own ids in sync identity lists

add_key_notification
parent
commit
0b8ada1cc4
7 changed files with 62 additions and 3 deletions
  1. +17
    -0
      src/identity_list.c
  2. +4
    -1
      src/identity_list.h
  3. +0
    -1
      src/map_asn1.h
  4. +17
    -0
      src/pEpEngine.c
  5. +3
    -0
      src/pEpEngine.h
  6. +11
    -0
      sync/cond_act_sync.yml2
  7. +10
    -1
      sync/gen_message_func.ysl2

+ 17
- 0
src/identity_list.c View File

@ -134,3 +134,20 @@ DYNAMIC_API int identity_list_length(const identity_list *id_list)
return len;
}
PEP_STATUS set_all_userids_in_list(identity_list* id_list, const char* user_id) {
identity_list* curr_list = id_list;
while (curr_list) {
if (curr_list->ident) {
free(curr_list->ident->user_id);
curr_list->ident->user_id = NULL;
char* dup_userid = strdup(user_id);
if (dup_userid == NULL)
return PEP_OUT_OF_MEMORY;
curr_list->ident->user_id = dup_userid;
}
curr_list = id_list->next;
}
return PEP_STATUS_OK;
}

+ 4
- 1
src/identity_list.h View File

@ -83,7 +83,10 @@ DYNAMIC_API identity_list *identity_list_join(identity_list *first_list, identit
// length of identity_list in number of elements
DYNAMIC_API int identity_list_length(const identity_list *id_list);
// Internal
PEP_STATUS set_all_userids_in_list(identity_list* id_list, const char* user_id);
#ifdef __cplusplus
}
#endif

+ 0
- 1
src/map_asn1.h View File

@ -80,4 +80,3 @@ identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list
#ifdef __cplusplus
}
#endif

+ 17
- 0
src/pEpEngine.c View File

@ -5382,3 +5382,20 @@ DYNAMIC_API void set_debug_color(PEP_SESSION session, int ansi_color)
session->debug_color = ansi_color;
#endif
}
PEP_STATUS set_all_userids_to_own(PEP_SESSION session, identity_list* id_list) {
static char* ownid = NULL;
PEP_STATUS status = PEP_STATUS_OK;
if (!ownid) {
status = get_default_own_userid(session, &ownid);
}
if (status == PEP_STATUS_OK) {
if (ownid) {
status = set_all_userids_in_list(id_list, ownid);
}
else {
status = PEP_UNKNOWN_ERROR;
}
}
return status;
}

+ 3
- 0
src/pEpEngine.h View File

@ -1418,6 +1418,9 @@ PEP_STATUS sign_only(PEP_SESSION session,
const char *fpr,
char **sign,
size_t *sign_size);
PEP_STATUS set_all_userids_to_own(PEP_SESSION session,
identity_list* id_list);
#ifdef __cplusplus
}


+ 11
- 0
sync/cond_act_sync.yml2 View File

@ -368,6 +368,11 @@ action saveGroupKeys
free(user_id);
return PEP_OUT_OF_MEMORY;
}
status = set_all_userids_to_own(session, il);
if (status != PEP_STATUS_OK) {
free(user_id);
return status;
}
identity_list *oil = session->sync_state.own.identities;
@ -452,6 +457,12 @@ action receivedKeysAreDefaultKeys
if (!il)
return PEP_OUT_OF_MEMORY;
status = set_all_userids_to_own(session, il);
if (status != PEP_STATUS_OK) {
free(user_id);
return status;
}
for (identity_list *_il = il; _il && _il->ident ; _il = _il->next) {
// replace partner's user_id with own user_id
free(_il->ident->user_id);


+ 10
- 1
sync/gen_message_func.ysl2 View File

@ -318,6 +318,11 @@ template "field", mode=update_message {
&session->«$state».«@name», NULL);
if (!il)
return PEP_OUT_OF_MEMORY;
PEP_STATUS own_idents_status = set_all_userids_to_own(session, il);
if (own_idents_status != PEP_STATUS_OK)
return own_idents_status;
IdentityList_t *_il = IdentityList_from_identity_list(il,
&msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name»);
free_identity_list(il);
@ -398,6 +403,11 @@ template "field", mode=update_state {
&msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name», NULL);
if (!il)
return PEP_OUT_OF_MEMORY;
PEP_STATUS own_idents_status = set_all_userids_to_own(session, il);
if (own_idents_status != PEP_STATUS_OK)
return own_idents_status;
IdentityList_t *_il = IdentityList_from_identity_list(il,
&session->«yml:lcase(../../../@name)»_state.«yml:lcase(../../@name)».«@name»);
free_identity_list(il);
@ -427,4 +437,3 @@ case «../@name»_PR_«yml:lcase(@name)»:
||
}

Loading…
Cancel
Save