shelving changes ENGINE-293
authorKrista Bennett <krista@pep-project.org>
Fri, 27 Oct 2017 20:02:41 +0200
branchENGINE-293
changeset 221999b05a2f117e
parent 2216 ef23982e4744
child 2302 3fbe4956dd34
shelving changes
src/keymanagement.c
src/keymanagement.h
src/message.h
src/pEpEngine.h
src/pEp_internal.h
     1.1 --- a/src/keymanagement.c	Thu Oct 26 17:32:53 2017 +0200
     1.2 +++ b/src/keymanagement.c	Fri Oct 27 20:02:41 2017 +0200
     1.3 @@ -93,10 +93,14 @@
     1.4      if (!(session && identity && !EMPTYSTR(identity->address)))
     1.5          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     1.6  
     1.7 +    /* Ok, if I'm trying to indicate this is me in the identity struct, then
     1.8 +       call _myself */
     1.9      if (_identity_me(identity)) {
    1.10          return _myself(session, identity, false, true);
    1.11      }
    1.12  
    1.13 +    /* Otherwise, unless get_identity indicates that this is me, it's
    1.14 +       someone else as far as this syscall is concerned. */
    1.15      int _no_user_id = EMPTYSTR(identity->user_id);
    1.16      int _did_elect_new_key = 0;
    1.17  
    1.18 @@ -426,18 +430,23 @@
    1.19      assert(identity);
    1.20      assert(!EMPTYSTR(identity->address));
    1.21  
    1.22 -    assert(EMPTYSTR(identity->user_id) ||
    1.23 -           strcmp(identity->user_id, PEP_OWN_USERID) == 0);
    1.24 +    // assert(EMPTYSTR(identity->user_id) ||
    1.25 +    //        strcmp(identity->user_id, PEP_OWN_USERID) == 0);
    1.26  
    1.27 -    if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.28 -            (EMPTYSTR(identity->user_id) ||
    1.29 -            strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
    1.30 +    // if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.31 +    //         (EMPTYSTR(identity->user_id) ||
    1.32 +    //         strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
    1.33 +    //     return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.34 +
    1.35 +    if (!(session && identity && !EMPTYSTR(identity->address)))
    1.36          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.37  
    1.38      identity->comm_type = PEP_ct_pEp;
    1.39      if(ignore_flags)
    1.40          identity->flags = 0;
    1.41      
    1.42 +    // FIXME: do we replace DB user_id and username if they WERE defaults?
    1.43 +
    1.44      if (EMPTYSTR(identity->user_id))
    1.45      {
    1.46          free(identity->user_id);
    1.47 @@ -450,7 +459,7 @@
    1.48      if (EMPTYSTR(identity->username))
    1.49      {
    1.50          free(identity->username);
    1.51 -        identity->username = strdup("anonymous");
    1.52 +        identity->username = strdup("Anonymous");
    1.53          assert(identity->username);
    1.54          if (identity->username == NULL)
    1.55              return PEP_OUT_OF_MEMORY;
     2.1 --- a/src/keymanagement.h	Thu Oct 26 17:32:53 2017 +0200
     2.2 +++ b/src/keymanagement.h	Fri Oct 27 20:02:41 2017 +0200
     2.3 @@ -35,12 +35,16 @@
     2.4      );
     2.5  
     2.6  
     2.7 -// myself() - ensures that the own identity is being complete
     2.8 +// myself() - ensures that an own identity is complete
     2.9  //
    2.10  //  parameters:
    2.11  //      session (in)        session to use
    2.12  //      identity (inout)    identity of local user
    2.13 -//                          at least .address, .username, .user_id must be set
    2.14 +//                          at least .address must be set.
    2.15 +//                          if no .user_id is set, AND the DB doesn't contain
    2.16 +//                          a user_id, PEP_OWN_USERID will be used.
    2.17 +//                          if no .username is set and none is in the DB,
    2.18 +//                          username will be set to "Anonymous"
    2.19  //
    2.20  //  return value:
    2.21  //      PEP_STATUS_OK if identity could be completed or was already complete,
     3.1 --- a/src/message.h	Thu Oct 26 17:32:53 2017 +0200
     3.2 +++ b/src/message.h	Fri Oct 27 20:02:41 2017 +0200
     3.3 @@ -42,6 +42,7 @@
     3.4  typedef struct _message {
     3.5      PEP_msg_direction dir;
     3.6      char *id;                               // UTF-8 string of message ID
     3.7 +    bool me;                                // true if own identity
     3.8      char *shortmsg;                         // UTF-8 string of short message
     3.9      char *longmsg;                          // UTF-8 string of long message
    3.10                                              // (plain)
     4.1 --- a/src/pEpEngine.h	Thu Oct 26 17:32:53 2017 +0200
     4.2 +++ b/src/pEpEngine.h	Fri Oct 27 20:02:41 2017 +0200
     4.3 @@ -470,7 +470,7 @@
     4.4      // the first octet flags are app defined settings
     4.5      PEP_idf_not_for_sync = 0x0001,   // don't use this identity for sync
     4.6      PEP_idf_list = 0x0002,           // identity of list of persons
     4.7 -
     4.8 +    PEP_idf_me = 0x0004,             // This identity is connected to own user_id
     4.9      // the second octet flags are calculated
    4.10      PEP_idf_devicegroup = 0x0100     // identity of a device group member
    4.11  } identity_flags;
     5.1 --- a/src/pEp_internal.h	Thu Oct 26 17:32:53 2017 +0200
     5.2 +++ b/src/pEp_internal.h	Fri Oct 27 20:02:41 2017 +0200
     5.3 @@ -344,7 +344,8 @@
     5.4          pEp_identity * identity
     5.5      )
     5.6  {
     5.7 -    return identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0;
     5.8 +    return identity->flags & PEP_idf_me || identity->me || 
     5.9 +           (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0);
    5.10  }
    5.11  
    5.12  // size is the length of the bytestr that's coming in. This is really only intended