merge sync Xcode-sync-session
authorbuff <andreas@pep-project.org>
Fri, 15 Nov 2019 16:52:42 +0100
branchXcode-sync-session
changeset 4199382b9432dc99
parent 4198 abb1cbfd80e8
parent 4193 4a3aeb20fefe
child 4200 bbbe91e9849e
child 4201 5fa6aa622efe
merge sync
build-mac/pEpEngine.xcodeproj/project.pbxproj
     1.1 --- a/src/identity_list.c	Fri Nov 15 10:25:34 2019 +0100
     1.2 +++ b/src/identity_list.c	Fri Nov 15 16:52:42 2019 +0100
     1.3 @@ -134,3 +134,20 @@
     1.4  
     1.5      return len;
     1.6  }
     1.7 +
     1.8 +PEP_STATUS set_all_userids_in_list(identity_list* id_list, const char* user_id) {
     1.9 +    identity_list* curr_list = id_list;
    1.10 +    
    1.11 +    while (curr_list) {
    1.12 +        if (curr_list->ident) {
    1.13 +            free(curr_list->ident->user_id);
    1.14 +            curr_list->ident->user_id = NULL;
    1.15 +            char* dup_userid = strdup(user_id);
    1.16 +            if (dup_userid == NULL)
    1.17 +                return PEP_OUT_OF_MEMORY;
    1.18 +            curr_list->ident->user_id = dup_userid;    
    1.19 +        }    
    1.20 +        curr_list = curr_list->next;
    1.21 +    }
    1.22 +    return PEP_STATUS_OK;
    1.23 +}
     2.1 --- a/src/identity_list.h	Fri Nov 15 10:25:34 2019 +0100
     2.2 +++ b/src/identity_list.h	Fri Nov 15 16:52:42 2019 +0100
     2.3 @@ -83,7 +83,10 @@
     2.4  //      length of identity_list in number of elements
     2.5  
     2.6  DYNAMIC_API int identity_list_length(const identity_list *id_list);
     2.7 -    
     2.8 +
     2.9 +// Internal
    2.10 +PEP_STATUS set_all_userids_in_list(identity_list* id_list, const char* user_id);
    2.11 +
    2.12  #ifdef __cplusplus
    2.13  }
    2.14  #endif
     3.1 --- a/src/map_asn1.h	Fri Nov 15 10:25:34 2019 +0100
     3.2 +++ b/src/map_asn1.h	Fri Nov 15 16:52:42 2019 +0100
     3.3 @@ -80,4 +80,3 @@
     3.4  #ifdef __cplusplus
     3.5  }
     3.6  #endif
     3.7 -
     4.1 --- a/src/pEpEngine.c	Fri Nov 15 10:25:34 2019 +0100
     4.2 +++ b/src/pEpEngine.c	Fri Nov 15 16:52:42 2019 +0100
     4.3 @@ -5382,3 +5382,20 @@
     4.4      session->debug_color = ansi_color;
     4.5  #endif
     4.6  }
     4.7 +
     4.8 +PEP_STATUS set_all_userids_to_own(PEP_SESSION session, identity_list* id_list) {
     4.9 +    static char* ownid = NULL;
    4.10 +    PEP_STATUS status = PEP_STATUS_OK;
    4.11 +    if (!ownid) {
    4.12 +        status = get_default_own_userid(session, &ownid);
    4.13 +    }    
    4.14 +    if (status == PEP_STATUS_OK) {
    4.15 +        if (ownid) {
    4.16 +            status = set_all_userids_in_list(id_list, ownid);
    4.17 +        }
    4.18 +        else {
    4.19 +            status = PEP_UNKNOWN_ERROR;
    4.20 +        }
    4.21 +    }
    4.22 +    return status;    
    4.23 +}
     5.1 --- a/src/pEpEngine.h	Fri Nov 15 10:25:34 2019 +0100
     5.2 +++ b/src/pEpEngine.h	Fri Nov 15 16:52:42 2019 +0100
     5.3 @@ -157,7 +157,7 @@
     5.4  //  parameters:
     5.5  //      ev (in)         event to free
     5.6  
     5.7 -void free_Sync_event(SYNC_EVENT ev);
     5.8 +DYNAMIC_API void free_Sync_event(SYNC_EVENT ev);
     5.9  
    5.10  
    5.11  // inject_sync_event - inject sync protocol message
    5.12 @@ -1422,6 +1422,9 @@
    5.13                       const char *fpr, 
    5.14                       char **sign, 
    5.15                       size_t *sign_size);
    5.16 +                     
    5.17 +PEP_STATUS set_all_userids_to_own(PEP_SESSION session, 
    5.18 +                                  identity_list* id_list);
    5.19  
    5.20  #ifdef __cplusplus
    5.21  }
     6.1 --- a/src/sync_api.h	Fri Nov 15 10:25:34 2019 +0100
     6.2 +++ b/src/sync_api.h	Fri Nov 15 16:52:42 2019 +0100
     6.3 @@ -201,7 +201,7 @@
     6.4      );
     6.5  
     6.6  
     6.7 -// leave_device_group() - leave a device group
     6.8 +// leave_device_group() - leave a device group and shutdown sync
     6.9  //
    6.10  //  parameters:
    6.11  //      session                 pEp session
     7.1 --- a/sync/cond_act_sync.yml2	Fri Nov 15 10:25:34 2019 +0100
     7.2 +++ b/sync/cond_act_sync.yml2	Fri Nov 15 16:52:42 2019 +0100
     7.3 @@ -368,6 +368,11 @@
     7.4          free(user_id);
     7.5          return PEP_OUT_OF_MEMORY;
     7.6      }
     7.7 +    status = set_all_userids_to_own(session, il);
     7.8 +    if (status != PEP_STATUS_OK) {
     7.9 +        free(user_id);
    7.10 +        return status;
    7.11 +    }
    7.12      
    7.13      identity_list *oil = session->sync_state.own.identities;
    7.14  
    7.15 @@ -452,6 +457,12 @@
    7.16      if (!il)
    7.17          return PEP_OUT_OF_MEMORY;
    7.18  
    7.19 +    status = set_all_userids_to_own(session, il);
    7.20 +    if (status != PEP_STATUS_OK) {
    7.21 +        free(user_id);
    7.22 +        return status;
    7.23 +    }
    7.24 +
    7.25      for (identity_list *_il = il; _il && _il->ident ; _il = _il->next) {
    7.26          // replace partner's user_id with own user_id
    7.27          free(_il->ident->user_id);
     8.1 --- a/sync/gen_message_func.ysl2	Fri Nov 15 10:25:34 2019 +0100
     8.2 +++ b/sync/gen_message_func.ysl2	Fri Nov 15 16:52:42 2019 +0100
     8.3 @@ -318,6 +318,11 @@
     8.4                      &session->«$state».«@name», NULL);
     8.5              if (!il)
     8.6                  return PEP_OUT_OF_MEMORY;
     8.7 +
     8.8 +            PEP_STATUS own_idents_status = set_all_userids_to_own(session, il);
     8.9 +            if (own_idents_status != PEP_STATUS_OK)
    8.10 +                return own_idents_status;
    8.11 +                
    8.12              IdentityList_t *_il = IdentityList_from_identity_list(il,
    8.13                      &msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name»);
    8.14              free_identity_list(il);
    8.15 @@ -398,6 +403,11 @@
    8.16                      &msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name», NULL);
    8.17              if (!il)
    8.18                  return PEP_OUT_OF_MEMORY;
    8.19 +                
    8.20 +            PEP_STATUS own_idents_status = set_all_userids_to_own(session, il);
    8.21 +            if (own_idents_status != PEP_STATUS_OK)
    8.22 +                return own_idents_status;
    8.23 +                
    8.24              IdentityList_t *_il = IdentityList_from_identity_list(il,
    8.25                      &session->«yml:lcase(../../../@name)»_state.«yml:lcase(../../@name)».«@name»);
    8.26              free_identity_list(il);
    8.27 @@ -427,4 +437,3 @@
    8.28  ||
    8.29  
    8.30  }
    8.31 -