adding set_identity_flags_test
authorVolker Birk <vb@pep-project.org>
Wed, 27 Jul 2016 16:20:31 +0200
changeset 9346ec71cdedec1
parent 933 8fecdff2f957
child 935 9fb6e8fc131f
child 939 ed7dfdae3031
adding set_identity_flags_test
src/keymanagement.c
src/pEpEngine.c
src/pEpEngine.h
     1.1 --- a/src/keymanagement.c	Wed Jul 27 15:35:04 2016 +0200
     1.2 +++ b/src/keymanagement.c	Wed Jul 27 16:20:31 2016 +0200
     1.3 @@ -134,7 +134,7 @@
     1.4          snprintf(identity->user_id, strlen(identity->address) + 5,
     1.5                   "TOFU_%s", identity->address);
     1.6      }
     1.7 -    
     1.8 + 
     1.9      status = get_identity(session,
    1.10                            identity->address,
    1.11                            identity->user_id,
    1.12 @@ -207,6 +207,8 @@
    1.13          identity->flags = stored_identity->flags;
    1.14      }
    1.15      else /* stored_identity == NULL */ {
    1.16 +        identity->flags = 0;
    1.17 +
    1.18          if (!EMPTYSTR(identity->fpr)) {
    1.19              PEP_comm_type _comm_type_key;
    1.20  
    1.21 @@ -401,6 +403,8 @@
    1.22          // import of private key, or similar.
    1.23  
    1.24          // Take given fpr as-is.
    1.25 +
    1.26 +        identity->flags = 0;
    1.27      }
    1.28      else
    1.29      {
    1.30 @@ -409,6 +413,8 @@
    1.31          if (status != PEP_STATUS_OK) {
    1.32              return status;
    1.33          }
    1.34 +
    1.35 +        identity->flags = 0;
    1.36      }
    1.37  
    1.38      bool revoked = false;
     2.1 --- a/src/pEpEngine.c	Wed Jul 27 15:35:04 2016 +0200
     2.2 +++ b/src/pEpEngine.c	Wed Jul 27 16:20:31 2016 +0200
     2.3 @@ -994,7 +994,9 @@
     2.4  }
     2.5  
     2.6  DYNAMIC_API PEP_STATUS set_identity_flags(
     2.7 -        PEP_SESSION session, const pEp_identity *identity
     2.8 +        PEP_SESSION session,
     2.9 +        pEp_identity *identity,
    2.10 +        unsigned int flags
    2.11      )
    2.12  {
    2.13      int result;
    2.14 @@ -1008,7 +1010,7 @@
    2.15          return PEP_ILLEGAL_VALUE;
    2.16  
    2.17      sqlite3_reset(session->set_identity_flags);
    2.18 -    sqlite3_bind_int(session->set_identity_flags, 1, identity->flags);
    2.19 +    sqlite3_bind_int(session->set_identity_flags, 1, flags);
    2.20      sqlite3_bind_text(session->set_identity_flags, 2, identity->address, -1,
    2.21              SQLITE_STATIC);
    2.22      sqlite3_bind_text(session->set_identity_flags, 3, identity->user_id, -1,
    2.23 @@ -1018,6 +1020,7 @@
    2.24      if (result != SQLITE_DONE)
    2.25          return PEP_CANNOT_SET_IDENTITY;
    2.26  
    2.27 +    identity->flags = flags;
    2.28      return PEP_STATUS_OK;
    2.29  }
    2.30  
     3.1 --- a/src/pEpEngine.h	Wed Jul 27 15:35:04 2016 +0200
     3.2 +++ b/src/pEpEngine.h	Wed Jul 27 16:20:31 2016 +0200
     3.3 @@ -380,8 +380,8 @@
     3.4  } PEP_comm_type;
     3.5  
     3.6  typedef enum _identity_flags {
     3.7 -    PEP_idf_NOT_FOR_SYNC = 1,   // don't use this identity for sync
     3.8 -    PEP_idf_GROUP = 2           // identity of group of persons
     3.9 +    PEP_idf_not_for_sync = 1,   // don't use this identity for sync
    3.10 +    PEP_idf_group = 2           // identity of group of persons
    3.11  } identity_flags;
    3.12  
    3.13  typedef struct _pEp_identity {
    3.14 @@ -500,17 +500,20 @@
    3.15  //
    3.16  //    parameters:
    3.17  //        session (in)        session handle
    3.18 -//        identity (in)       pointer to pEp_identity structure
    3.19 +//        identity (in,out)   pointer to pEp_identity structure
    3.20 +//        flags (in)          new value for flags
    3.21  //
    3.22  //    return value:
    3.23  //        PEP_STATUS_OK = 0             encryption and signing succeeded
    3.24  //        PEP_CANNOT_SET_IDENTITY       update of identity failed
    3.25  //
    3.26  //    caveat:
    3.27 -//        address and user_id must be given
    3.28 +//        address and user_id must be given in identity
    3.29  
    3.30  DYNAMIC_API PEP_STATUS set_identity_flags(
    3.31 -        PEP_SESSION session, const pEp_identity *identity
    3.32 +        PEP_SESSION session,
    3.33 +        pEp_identity *identity,
    3.34 +        unsigned int flags
    3.35      );
    3.36  
    3.37