ENGINE-226 identity->me => _identity_me() ENGINE-226
authorEdouard Tisserant <edouard@pep-project.org>
Wed, 09 Aug 2017 14:23:23 +0200
branchENGINE-226
changeset 19459503c962f746
parent 1943 7c1de6525863
child 1946 277ee707f5cb
ENGINE-226 identity->me => _identity_me()
src/keymanagement.c
src/message_api.c
src/pEpEngine.c
src/pEpEngine.h
src/pEp_internal.h
test/apple_mail_test.cc
test/decorate_test.cc
test/encrypt_for_identity_test.cc
test/encrypt_missing_private_key_test.cc
test/external_revoke_test.cc
test/identity_list_test.cc
test/least_color_group_test.cc
test/least_common_denom_color_test.cc
test/message_api_test.cc
test/pEp_subject_received_test.cc
     1.1 --- a/src/keymanagement.c	Mon Aug 07 16:42:49 2017 +0200
     1.2 +++ b/src/keymanagement.c	Wed Aug 09 14:23:23 2017 +0200
     1.3 @@ -93,8 +93,7 @@
     1.4      if (!(session && identity && !EMPTYSTR(identity->address)))
     1.5          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     1.6  
     1.7 -    if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
     1.8 -        identity->me = true;
     1.9 +    if (_identity_me(identity)) {
    1.10          return _myself(session, identity, false, true);
    1.11      }
    1.12  
    1.13 @@ -319,7 +318,6 @@
    1.14      identity->lang[0] = temp_id->lang[0];
    1.15      identity->lang[1] = temp_id->lang[1];
    1.16      identity->lang[2] = 0;
    1.17 -    identity->me = temp_id->me;
    1.18      identity->flags = temp_id->flags;
    1.19  
    1.20  exit_free :
    1.21 @@ -437,7 +435,6 @@
    1.22          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.23  
    1.24      identity->comm_type = PEP_ct_pEp;
    1.25 -    identity->me = true;
    1.26      if(ignore_flags)
    1.27          identity->flags = 0;
    1.28      
    1.29 @@ -686,7 +683,7 @@
    1.30          {
    1.31              DEBUG_LOG("do_keymanagement", "retrieve_next_identity", identity->address);
    1.32  
    1.33 -            if (identity->me) {
    1.34 +            if (_identity_me(identity)) {
    1.35                  status = myself(session, identity);
    1.36              } else {
    1.37                  status = recv_key(session, identity->address);
    1.38 @@ -719,7 +716,7 @@
    1.39      if (!(session && ident && ident->fpr))
    1.40          return PEP_ILLEGAL_VALUE;
    1.41  
    1.42 -    if (ident->me)
    1.43 +    if (_identity_me(ident))
    1.44      {
    1.45          revoke_key(session, ident->fpr, NULL);
    1.46          myself(session, ident);
    1.47 @@ -741,12 +738,12 @@
    1.48  
    1.49      assert(session);
    1.50      assert(ident);
    1.51 -    assert(!ident->me);
    1.52 +    assert(!_identity_me(ident));
    1.53      assert(!EMPTYSTR(ident->fpr));
    1.54      assert(!EMPTYSTR(ident->address));
    1.55      assert(!EMPTYSTR(ident->user_id));
    1.56  
    1.57 -    if (!(session && ident && !ident->me && ident->fpr && ident->address &&
    1.58 +    if (!(session && ident && !_identity_me(ident) && ident->fpr && ident->address &&
    1.59              ident->user_id))
    1.60          return PEP_ILLEGAL_VALUE;
    1.61  
    1.62 @@ -780,10 +777,9 @@
    1.63      assert(!EMPTYSTR(ident->address));
    1.64      assert(!EMPTYSTR(ident->user_id));
    1.65      assert(!EMPTYSTR(ident->fpr));
    1.66 -//    assert(!ident->me);
    1.67  
    1.68      if (!ident || EMPTYSTR(ident->address) || EMPTYSTR(ident->user_id) ||
    1.69 -            EMPTYSTR(ident->fpr)) // || ident->me)
    1.70 +            EMPTYSTR(ident->fpr))
    1.71          return PEP_ILLEGAL_VALUE;
    1.72  
    1.73      status = update_identity(session, ident);
    1.74 @@ -896,7 +892,6 @@
    1.75                      ident->lang[1] = lang[1];
    1.76                      ident->lang[2] = 0;
    1.77                  }
    1.78 -                ident->me = true;
    1.79                  ident->flags = flags;
    1.80  
    1.81                  _bl = identity_list_add(_bl, ident);
     2.1 --- a/src/message_api.c	Mon Aug 07 16:42:49 2017 +0200
     2.2 +++ b/src/message_api.c	Wed Aug 09 14:23:23 2017 +0200
     2.3 @@ -2269,7 +2269,7 @@
     2.4      if (!(session && ident && rating))
     2.5          return PEP_ILLEGAL_VALUE;
     2.6  
     2.7 -    if (ident->me)
     2.8 +    if (_identity_me(ident))
     2.9          status = _myself(session, ident, false, true);
    2.10      else
    2.11          status = update_identity(session, ident);
     3.1 --- a/src/pEpEngine.c	Mon Aug 07 16:42:49 2017 +0200
     3.2 +++ b/src/pEpEngine.c	Wed Aug 09 14:23:23 2017 +0200
     3.3 @@ -1146,7 +1146,6 @@
     3.4      dup->lang[0] = src->lang[0];
     3.5      dup->lang[1] = src->lang[1];
     3.6      dup->lang[2] = 0;
     3.7 -    dup->me = src->me;
     3.8      dup->flags = src->flags;
     3.9  
    3.10      return dup;
     4.1 --- a/src/pEpEngine.h	Mon Aug 07 16:42:49 2017 +0200
     4.2 +++ b/src/pEpEngine.h	Wed Aug 09 14:23:23 2017 +0200
     4.3 @@ -484,7 +484,6 @@
     4.4      PEP_comm_type comm_type;    // type of communication with this ID
     4.5      char lang[3];               // language of conversation
     4.6                                  // ISO 639-1 ALPHA-2, last byte is 0
     4.7 -    bool me;                    // if this is the local user herself/himself
     4.8      identity_flags_t flags;     // identity_flag1 | identity_flag2 | ...
     4.9  } pEp_identity;
    4.10  
     5.1 --- a/src/pEp_internal.h	Mon Aug 07 16:42:49 2017 +0200
     5.2 +++ b/src/pEp_internal.h	Wed Aug 09 14:23:23 2017 +0200
     5.3 @@ -313,6 +313,12 @@
     5.4      return comparison == 0;
     5.5  }
     5.6  
     5.7 +static inline bool _identity_me(
     5.8 +        pEp_identity * identity
     5.9 +    )
    5.10 +{
    5.11 +    return identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0;
    5.12 +}
    5.13  
    5.14  #ifdef DEBUG_ERRORSTACK
    5.15      PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
     6.1 --- a/test/apple_mail_test.cc	Mon Aug 07 16:42:49 2017 +0200
     6.2 +++ b/test/apple_mail_test.cc	Wed Aug 09 14:23:23 2017 +0200
     6.3 @@ -34,11 +34,9 @@
     6.4          
     6.5      const string mailtext = slurp(mailfile);
     6.6      pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
     6.7 -    me->me = true;    
     6.8      PEP_STATUS status = myself(session, me);
     6.9      
    6.10      pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");    
    6.11 -    you->me = false;    
    6.12      status = update_identity(session, you);
    6.13  
    6.14      trust_personal_key(session, you);
     7.1 --- a/test/decorate_test.cc	Mon Aug 07 16:42:49 2017 +0200
     7.2 +++ b/test/decorate_test.cc	Wed Aug 09 14:23:23 2017 +0200
     7.3 @@ -29,7 +29,6 @@
     7.4      cout << "creating message…\n";
     7.5      pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
     7.6      pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
     7.7 -    alice->me = true;
     7.8      identity_list* to_list = new_identity_list(bob); // to bob
     7.9      message* outgoing_message = new_message(PEP_dir_outgoing);
    7.10      assert(outgoing_message);
     8.1 --- a/test/encrypt_for_identity_test.cc	Mon Aug 07 16:42:49 2017 +0200
     8.2 +++ b/test/encrypt_for_identity_test.cc	Wed Aug 09 14:23:23 2017 +0200
     8.3 @@ -38,7 +38,6 @@
     8.4      cout << "creating message…\n";
     8.5      pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
     8.6      pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
     8.7 -    alice->me = true;
     8.8  
     8.9      PEP_STATUS mystatus = myself(session, alice);
    8.10      assert(mystatus == PEP_STATUS_OK);
     9.1 --- a/test/encrypt_missing_private_key_test.cc	Mon Aug 07 16:42:49 2017 +0200
     9.2 +++ b/test/encrypt_missing_private_key_test.cc	Wed Aug 09 14:23:23 2017 +0200
     9.3 @@ -44,7 +44,6 @@
     9.4                                                        bl_fpr_1,
     9.5                                                        PEP_OWN_USERID,
     9.6                                                        "Blacklist Self");
     9.7 -    blacklisted_identity->me = true;
     9.8      PEP_STATUS status8 = myself(session, blacklisted_identity);
     9.9      assert (status8 == PEP_STATUS_OK);
    9.10      PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);
    10.1 --- a/test/external_revoke_test.cc	Mon Aug 07 16:42:49 2017 +0200
    10.2 +++ b/test/external_revoke_test.cc	Wed Aug 09 14:23:23 2017 +0200
    10.3 @@ -72,7 +72,6 @@
    10.4  
    10.5      cout << "Trusting personal key for " << uniqname << endl;
    10.6      // Trust it
    10.7 -    recip1->me = false;
    10.8      status = update_identity(session, recip1);
    10.9      status = trust_personal_key(session, recip1);
   10.10      status = update_identity(session, recip1);
    11.1 --- a/test/identity_list_test.cc	Mon Aug 07 16:42:49 2017 +0200
    11.2 +++ b/test/identity_list_test.cc	Wed Aug 09 14:23:23 2017 +0200
    11.3 @@ -20,7 +20,6 @@
    11.4      PEP_comm_type comm_type;    // type of communication with this ID
    11.5      char lang[3];               // language of conversation
    11.6                                  // ISO 639-1 ALPHA-2, last byte is 0
    11.7 -    bool me;                    // if this is the local user herself/himself
    11.8      */
    11.9  
   11.10  int test_identity_equals(pEp_identity* val1, pEp_identity* val2) {
   11.11 @@ -35,7 +34,7 @@
   11.12      return((strcmp(val1->address, val2->address) == 0) && (strcmp(val1->fpr, val2->fpr) == 0)
   11.13          && (strcmp(val1->username, val2->username) == 0) && (val1->comm_type == val2->comm_type)
   11.14          && (val1->lang[0] == val2->lang[0]) && (val1->lang[1] == val2->lang[1])
   11.15 -        && (val1->lang[2] == val2->lang[2]) && (val1->me == val2->me));
   11.16 +        && (val1->lang[2] == val2->lang[2]));
   11.17  }
   11.18  
   11.19  int main() {
    12.1 --- a/test/least_color_group_test.cc	Mon Aug 07 16:42:49 2017 +0200
    12.2 +++ b/test/least_color_group_test.cc	Wed Aug 09 14:23:23 2017 +0200
    12.3 @@ -46,7 +46,6 @@
    12.4      pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org", 
    12.5                                        "7EE6C60C68851954E1797F81EA59715E3EBE215C", 
    12.6                                        PEP_OWN_USERID, "Pep Color Test P (recip)");
    12.7 -    me1->me = true;
    12.8      PEP_STATUS status = update_identity(session, me1);
    12.9      trust_personal_key(session, me1);
   12.10      status = update_identity(session, me1);
   12.11 @@ -55,7 +54,6 @@
   12.12                                            NULL, "TOFU_pep.color.test.V@kgrothoff.org",
   12.13                                            "Pep Color Test V (sender)");
   12.14      
   12.15 -    sender1->me = false;
   12.16      status = update_identity(session, sender1);
   12.17      trust_personal_key(session, sender1);
   12.18      status = update_identity(session, sender1);
    13.1 --- a/test/least_common_denom_color_test.cc	Mon Aug 07 16:42:49 2017 +0200
    13.2 +++ b/test/least_common_denom_color_test.cc	Wed Aug 09 14:23:23 2017 +0200
    13.3 @@ -36,17 +36,14 @@
    13.4      PEP_STATUS statuskey4 = import_key(session, keytextkey4.c_str(), keytextkey4.length(), NULL);
    13.5  
    13.6      pEp_identity * sender = new_identity("pep.never.me.test@kgrothoff.org", NULL, "TOFU_pep.never.me.test@kgrothoff.org", "pEp Never Me Test");    
    13.7 -    sender->me = false;    
    13.8      PEP_STATUS status = update_identity(session, sender);
    13.9          
   13.10      // reset the trust on both keys before we start
   13.11      pEp_identity * recip1 = new_identity("banmeonce@kgrothoff.org", NULL, "TOFU_banemeonce@kgrothoff.org", "Ban Me Once");    
   13.12 -    recip1->me = false;    
   13.13      status = update_identity(session, recip1);
   13.14      key_reset_trust(session, recip1);
   13.15      
   13.16      pEp_identity * recip2 = new_identity("banmetwice@kgrothoff.org", NULL, "TOFU_banemetwice@kgrothoff.org", "Ban Me Twice");    
   13.17 -    recip2->me = false;    
   13.18      status = update_identity(session, recip2);
   13.19      key_reset_trust(session, recip2);
   13.20          
    14.1 --- a/test/message_api_test.cc	Mon Aug 07 16:42:49 2017 +0200
    14.2 +++ b/test/message_api_test.cc	Wed Aug 09 14:23:23 2017 +0200
    14.3 @@ -28,7 +28,6 @@
    14.4      cout << "creating message…\n";
    14.5      pEp_identity * me2 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
    14.6      // pEp_identity * me2 = new_identity("test@nokey.plop", NULL, PEP_OWN_USERID, "Test no key");
    14.7 -    me2->me = true;
    14.8      identity_list *to2 = new_identity_list(new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test"));
    14.9      // identity_list *to2 = new_identity_list(new_identity("still@nokey.blup", NULL, "42", "Still no key"));
   14.10      message *msg2 = new_message(PEP_dir_outgoing);
    15.1 --- a/test/pEp_subject_received_test.cc	Mon Aug 07 16:42:49 2017 +0200
    15.2 +++ b/test/pEp_subject_received_test.cc	Wed Aug 09 14:23:23 2017 +0200
    15.3 @@ -34,11 +34,9 @@
    15.4      PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
    15.5  
    15.6      pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
    15.7 -    me->me = true;    
    15.8      PEP_STATUS status = myself(session, me);
    15.9      
   15.10      pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");    
   15.11 -    you->me = false;    
   15.12      
   15.13      status = update_identity(session, you);
   15.14      trust_personal_key(session, you);