adding param to deliverHandshakeResult sync
authorVolker Birk <vb@pep-project.org>
Wed, 27 Mar 2019 20:17:29 +0100
branchsync
changeset 3407dabc9c3b13e6
parent 3406 c7540a618a4c
child 3408 78506867a9c0
adding param to deliverHandshakeResult
src/sync_api.c
src/sync_api.h
sync/gen_message_func.ysl2
     1.1 --- a/src/sync_api.c	Wed Mar 27 17:16:44 2019 +0100
     1.2 +++ b/src/sync_api.c	Wed Mar 27 20:17:29 2019 +0100
     1.3 @@ -39,15 +39,22 @@
     1.4  
     1.5  DYNAMIC_API PEP_STATUS deliverHandshakeResult(
     1.6          PEP_SESSION session,
     1.7 -        sync_handshake_result result
     1.8 +        sync_handshake_result result,
     1.9 +        const identity_list *identities_sharing
    1.10      )
    1.11  {
    1.12      assert(session);
    1.13      if (!session)
    1.14          return PEP_ILLEGAL_VALUE;
    1.15  
    1.16 +    for (const identity_list *_il = identities_sharing; _il && _il->ident;
    1.17 +            _il = _il->next) {
    1.18 +        if (!_il->ident->me || !_il->ident->user_id || !_il->ident->user_id[0]
    1.19 +                || !_il->ident->address || !_il->ident->address[0])
    1.20 +            return PEP_ILLEGAL_VALUE;
    1.21 +    }
    1.22 +
    1.23      PEP_STATUS status = PEP_STATUS_OK;
    1.24 -
    1.25      int event;
    1.26  
    1.27      switch (result) {
    1.28 @@ -68,7 +75,18 @@
    1.29              return PEP_ILLEGAL_VALUE;
    1.30      }
    1.31  
    1.32 -    status = signal_Sync_event(session, Sync_PR_keysync, event);
    1.33 +    free_identity_list(session->sync_state.common.own_identities);
    1.34 +    if (identities_sharing) {
    1.35 +        session->sync_state.common.own_identities = identity_list_dup(identities_sharing);
    1.36 +        if (session->sync_state.common.own_identities)
    1.37 +            status = PEP_OUT_OF_MEMORY;
    1.38 +    }
    1.39 +    else {
    1.40 +        status = own_identities_retrieve(session, &session->sync_state.common.own_identities);
    1.41 +    }
    1.42 +
    1.43 +    if (!status)
    1.44 +        status = signal_Sync_event(session, Sync_PR_keysync, event);
    1.45      return status;
    1.46  }
    1.47  
     2.1 --- a/src/sync_api.h	Wed Mar 27 17:16:44 2019 +0100
     2.2 +++ b/src/sync_api.h	Wed Mar 27 20:17:29 2019 +0100
     2.3 @@ -63,12 +63,19 @@
     2.4  // deliverHandshakeResult() - provide the result of the handshake dialog
     2.5  //
     2.6  //  parameters:
     2.7 -//      session (in)        session handle
     2.8 -//      result (in)         handshake result
     2.9 +//      session (in)            session handle
    2.10 +//      result (in)             handshake result
    2.11 +//      identities_sharing (in) own_identities sharing data in this group
    2.12 +//
    2.13 +//  caveat:
    2.14 +//      identities_sharing may be NULL; in this case all identities are sharing
    2.15 +//      data in the group
    2.16 +//      identities_sharing may only contain own identities
    2.17  
    2.18  DYNAMIC_API PEP_STATUS deliverHandshakeResult(
    2.19          PEP_SESSION session,
    2.20 -        sync_handshake_result result
    2.21 +        sync_handshake_result result,
    2.22 +        const identity_list *identities_sharing
    2.23      );
    2.24  
    2.25  
     3.1 --- a/sync/gen_message_func.ysl2	Wed Mar 27 17:16:44 2019 +0100
     3.2 +++ b/sync/gen_message_func.ysl2	Wed Mar 27 20:17:29 2019 +0100
     3.3 @@ -43,6 +43,7 @@
     3.4          pEp_identity *from;
     3.5          char *signature_fpr;
     3.6          stringlist_t *own_keys;
     3.7 +        identity_list *own_identities;
     3.8      } common;
     3.9  
    3.10      `` apply "fsm", mode=state
    3.11 @@ -100,6 +101,7 @@
    3.12      free_identity(session->«yml:lcase(@name)»_state.common.from);
    3.13      free(session->«yml:lcase(@name)»_state.common.signature_fpr);
    3.14      free_stringlist(session->«yml:lcase(@name)»_state.common.own_keys);
    3.15 +    free_identity_list(session->«yml:lcase(@name)»_state.common.own_identities);
    3.16  
    3.17  ||
    3.18  for "fsm"