Browse Source

ENGINE-226 identity->me => _identity_me()

doc_update_sequoia
Edouard Tisserant 5 years ago
parent
commit
b84a7282f1
15 changed files with 14 additions and 30 deletions
  1. +6
    -11
      src/keymanagement.c
  2. +1
    -1
      src/message_api.c
  3. +0
    -1
      src/pEpEngine.c
  4. +0
    -1
      src/pEpEngine.h
  5. +6
    -0
      src/pEp_internal.h
  6. +0
    -2
      test/apple_mail_test.cc
  7. +0
    -1
      test/decorate_test.cc
  8. +0
    -1
      test/encrypt_for_identity_test.cc
  9. +0
    -1
      test/encrypt_missing_private_key_test.cc
  10. +0
    -1
      test/external_revoke_test.cc
  11. +1
    -2
      test/identity_list_test.cc
  12. +0
    -2
      test/least_color_group_test.cc
  13. +0
    -3
      test/least_common_denom_color_test.cc
  14. +0
    -1
      test/message_api_test.cc
  15. +0
    -2
      test/pEp_subject_received_test.cc

+ 6
- 11
src/keymanagement.c View File

@ -93,8 +93,7 @@ DYNAMIC_API PEP_STATUS update_identity(
if (!(session && identity && !EMPTYSTR(identity->address)))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
identity->me = true;
if (_identity_me(identity)) {
return _myself(session, identity, false, true);
}
@ -319,7 +318,6 @@ DYNAMIC_API PEP_STATUS update_identity(
identity->lang[0] = temp_id->lang[0];
identity->lang[1] = temp_id->lang[1];
identity->lang[2] = 0;
identity->me = temp_id->me;
identity->flags = temp_id->flags;
exit_free :
@ -437,7 +435,6 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
identity->comm_type = PEP_ct_pEp;
identity->me = true;
if(ignore_flags)
identity->flags = 0;
@ -686,7 +683,7 @@ DYNAMIC_API PEP_STATUS do_keymanagement(
{
DEBUG_LOG("do_keymanagement", "retrieve_next_identity", identity->address);
if (identity->me) {
if (_identity_me(identity)) {
status = myself(session, identity);
} else {
status = recv_key(session, identity->address);
@ -719,7 +716,7 @@ DYNAMIC_API PEP_STATUS key_mistrusted(
if (!(session && ident && ident->fpr))
return PEP_ILLEGAL_VALUE;
if (ident->me)
if (_identity_me(ident))
{
revoke_key(session, ident->fpr, NULL);
myself(session, ident);
@ -741,12 +738,12 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
assert(session);
assert(ident);
assert(!ident->me);
assert(!_identity_me(ident));
assert(!EMPTYSTR(ident->fpr));
assert(!EMPTYSTR(ident->address));
assert(!EMPTYSTR(ident->user_id));
if (!(session && ident && !ident->me && ident->fpr && ident->address &&
if (!(session && ident && !_identity_me(ident) && ident->fpr && ident->address &&
ident->user_id))
return PEP_ILLEGAL_VALUE;
@ -780,10 +777,9 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
assert(!EMPTYSTR(ident->address));
assert(!EMPTYSTR(ident->user_id));
assert(!EMPTYSTR(ident->fpr));
// assert(!ident->me);
if (!ident || EMPTYSTR(ident->address) || EMPTYSTR(ident->user_id) ||
EMPTYSTR(ident->fpr)) // || ident->me)
EMPTYSTR(ident->fpr))
return PEP_ILLEGAL_VALUE;
status = update_identity(session, ident);
@ -896,7 +892,6 @@ PEP_STATUS _own_identities_retrieve(
ident->lang[1] = lang[1];
ident->lang[2] = 0;
}
ident->me = true;
ident->flags = flags;
_bl = identity_list_add(_bl, ident);


+ 1
- 1
src/message_api.c View File

@ -2269,7 +2269,7 @@ DYNAMIC_API PEP_STATUS identity_rating(
if (!(session && ident && rating))
return PEP_ILLEGAL_VALUE;
if (ident->me)
if (_identity_me(ident))
status = _myself(session, ident, false, true);
else
status = update_identity(session, ident);


+ 0
- 1
src/pEpEngine.c View File

@ -1146,7 +1146,6 @@ pEp_identity *identity_dup(const pEp_identity *src)
dup->lang[0] = src->lang[0];
dup->lang[1] = src->lang[1];
dup->lang[2] = 0;
dup->me = src->me;
dup->flags = src->flags;
return dup;


+ 0
- 1
src/pEpEngine.h View File

@ -484,7 +484,6 @@ typedef struct _pEp_identity {
PEP_comm_type comm_type; // type of communication with this ID
char lang[3]; // language of conversation
// ISO 639-1 ALPHA-2, last byte is 0
bool me; // if this is the local user herself/himself
identity_flags_t flags; // identity_flag1 | identity_flag2 | ...
} pEp_identity;


+ 6
- 0
src/pEp_internal.h View File

@ -313,6 +313,12 @@ static inline int _same_fpr(
return comparison == 0;
}
static inline bool _identity_me(
pEp_identity * identity
)
{
return identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0;
}
#ifdef DEBUG_ERRORSTACK
PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);


+ 0
- 2
test/apple_mail_test.cc View File

@ -34,11 +34,9 @@ int main(int argc, char** argv) {
const string mailtext = slurp(mailfile);
pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");
me->me = true;
PEP_STATUS status = myself(session, me);
pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");
you->me = false;
status = update_identity(session, you);
trust_personal_key(session, you);


+ 0
- 1
test/decorate_test.cc View File

@ -29,7 +29,6 @@ int main() {
cout << "creating message…\n";
pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
alice->me = true;
identity_list* to_list = new_identity_list(bob); // to bob
message* outgoing_message = new_message(PEP_dir_outgoing);
assert(outgoing_message);


+ 0
- 1
test/encrypt_for_identity_test.cc View File

@ -38,7 +38,6 @@ int main() {
cout << "creating message…\n";
pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
alice->me = true;
PEP_STATUS mystatus = myself(session, alice);
assert(mystatus == PEP_STATUS_OK);


+ 0
- 1
test/encrypt_missing_private_key_test.cc View File

@ -44,7 +44,6 @@ int main() {
bl_fpr_1,
PEP_OWN_USERID,
"Blacklist Self");
blacklisted_identity->me = true;
PEP_STATUS status8 = myself(session, blacklisted_identity);
assert (status8 == PEP_STATUS_OK);
PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);


+ 0
- 1
test/external_revoke_test.cc View File

@ -72,7 +72,6 @@ int main() {
cout << "Trusting personal key for " << uniqname << endl;
// Trust it
recip1->me = false;
status = update_identity(session, recip1);
status = trust_personal_key(session, recip1);
status = update_identity(session, recip1);


+ 1
- 2
test/identity_list_test.cc View File

@ -20,7 +20,6 @@ using namespace std;
PEP_comm_type comm_type; // type of communication with this ID
char lang[3]; // language of conversation
// ISO 639-1 ALPHA-2, last byte is 0
bool me; // if this is the local user herself/himself
*/
int test_identity_equals(pEp_identity* val1, pEp_identity* val2) {
@ -35,7 +34,7 @@ int test_identity_equals(pEp_identity* val1, pEp_identity* val2) {
return((strcmp(val1->address, val2->address) == 0) && (strcmp(val1->fpr, val2->fpr) == 0)
&& (strcmp(val1->username, val2->username) == 0) && (val1->comm_type == val2->comm_type)
&& (val1->lang[0] == val2->lang[0]) && (val1->lang[1] == val2->lang[1])
&& (val1->lang[2] == val2->lang[2]) && (val1->me == val2->me));
&& (val1->lang[2] == val2->lang[2]));
}
int main() {


+ 0
- 2
test/least_color_group_test.cc View File

@ -46,7 +46,6 @@ int main(int argc, char** argv) {
pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org",
"7EE6C60C68851954E1797F81EA59715E3EBE215C",
PEP_OWN_USERID, "Pep Color Test P (recip)");
me1->me = true;
PEP_STATUS status = update_identity(session, me1);
trust_personal_key(session, me1);
status = update_identity(session, me1);
@ -55,7 +54,6 @@ int main(int argc, char** argv) {
NULL, "TOFU_pep.color.test.V@kgrothoff.org",
"Pep Color Test V (sender)");
sender1->me = false;
status = update_identity(session, sender1);
trust_personal_key(session, sender1);
status = update_identity(session, sender1);


+ 0
- 3
test/least_common_denom_color_test.cc View File

@ -36,17 +36,14 @@ int main(int argc, char** argv) {
PEP_STATUS statuskey4 = import_key(session, keytextkey4.c_str(), keytextkey4.length(), NULL);
pEp_identity * sender = new_identity("pep.never.me.test@kgrothoff.org", NULL, "TOFU_pep.never.me.test@kgrothoff.org", "pEp Never Me Test");
sender->me = false;
PEP_STATUS status = update_identity(session, sender);
// reset the trust on both keys before we start
pEp_identity * recip1 = new_identity("banmeonce@kgrothoff.org", NULL, "TOFU_banemeonce@kgrothoff.org", "Ban Me Once");
recip1->me = false;
status = update_identity(session, recip1);
key_reset_trust(session, recip1);
pEp_identity * recip2 = new_identity("banmetwice@kgrothoff.org", NULL, "TOFU_banemetwice@kgrothoff.org", "Ban Me Twice");
recip2->me = false;
status = update_identity(session, recip2);
key_reset_trust(session, recip2);


+ 0
- 1
test/message_api_test.cc View File

@ -28,7 +28,6 @@ int main() {
cout << "creating message…\n";
pEp_identity * me2 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
// pEp_identity * me2 = new_identity("test@nokey.plop", NULL, PEP_OWN_USERID, "Test no key");
me2->me = true;
identity_list *to2 = new_identity_list(new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test"));
// identity_list *to2 = new_identity_list(new_identity("still@nokey.blup", NULL, "42", "Still no key"));
message *msg2 = new_message(PEP_dir_outgoing);


+ 0
- 2
test/pEp_subject_received_test.cc View File

@ -34,11 +34,9 @@ int main(int argc, char** argv) {
PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");
me->me = true;
PEP_STATUS status = myself(session, me);
pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");
you->me = false;
status = update_identity(session, you);
trust_personal_key(session, you);


Loading…
Cancel
Save