merged heads sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 03 Apr 2019 17:18:55 +0200
branchsync
changeset 343750ec7a39e522
parent 3436 bf27fae218c5
parent 3434 458a804f88e4
child 3438 e30150dc6007
merged heads
src/pEpEngine.c
     1.1 --- a/.hgignore	Wed Apr 03 17:15:17 2019 +0200
     1.2 +++ b/.hgignore	Wed Apr 03 17:18:55 2019 +0200
     1.3 @@ -78,4 +78,5 @@
     1.4  sync/.statemachines
     1.5  test/msg_2.0.asc
     1.6  test/*Tests
     1.7 -
     1.8 +test/*.txt
     1.9 +lldb-history
     2.1 --- a/src/pEpEngine.c	Wed Apr 03 17:15:17 2019 +0200
     2.2 +++ b/src/pEpEngine.c	Wed Apr 03 17:18:55 2019 +0200
     2.3 @@ -3958,6 +3958,8 @@
     2.4      PEP_STATUS status = session->cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify(
     2.5              session, ctext, csize, dsigtext, dsigsize, ptext, psize, keylist,
     2.6              filename_ptr);
     2.7 +
     2.8 +    if (status == PEP_DECRYPT_NO_KEY)
     2.9          signal_Sync_event(session, Sync_PR_keysync, CannotDecrypt);
    2.10  
    2.11      return status;
     3.1 --- a/sync/cond_act_sync.yml2	Wed Apr 03 17:15:17 2019 +0200
     3.2 +++ b/sync/cond_act_sync.yml2	Wed Apr 03 17:18:55 2019 +0200
     3.3 @@ -203,82 +203,19 @@
     3.4      free_identity_list(il);
     3.5  ||
     3.6  
     3.7 -action ownKeysAreGroupKeys {
     3.8 -    call "init_sql" with "sql" {
     3.9 -        ||
    3.10 -        "select fpr, username, comm_type, lang,"
    3.11 -                "   identity.flags | pgp_keypair.flags"
    3.12 -                "   from identity"
    3.13 -                "   join person on id = identity.user_id"
    3.14 -                "   join pgp_keypair on fpr = identity.main_key_id"
    3.15 -                "   join trust on id = trust.user_id"
    3.16 -                "       and pgp_keypair_fpr = identity.main_key_id"
    3.17 -                "   where identity.is_own = true ;"
    3.18 -        ||
    3.19 +action ownKeysAreGroupKeys
    3.20 +||
    3.21 +    PEP_STATUS status = PEP_STATUS_OK;
    3.22 +
    3.23 +    // set flag for current keys
    3.24 +    for (identity_list *il = session->sync_state.common.own_identities; il && il->ident ; il = il->next) {
    3.25 +        if (!(il->ident->flags && PEP_idf_not_for_sync)) {
    3.26 +            status = set_identity_flags(session, il->ident, PEP_idf_devicegroup);
    3.27 +            if (status)
    3.28 +                return status;
    3.29 +        }
    3.30      }
    3.31 -
    3.32 -    ||
    3.33 -        identity_list *il = new_identity_list(NULL);
    3.34 -        if (!il)
    3.35 -            return PEP_OUT_OF_MEMORY;
    3.36 -
    3.37 -        pEp_identity *from = session->sync_state.common.from;
    3.38 -        identity_list *_il = il;
    3.39 -
    3.40 -        int result;
    3.41 -        do {
    3.42 -            result = sqlite3_step(_sql);
    3.43 -            pEp_identity *_identity = NULL;
    3.44 -            switch (result) {
    3.45 -            case SQLITE_ROW:
    3.46 -                _identity = new_identity(
    3.47 -                        from->address,
    3.48 -                        (const char *) sqlite3_column_text(_sql, 0),
    3.49 -                        from->user_id,
    3.50 -                        (const char *) sqlite3_column_text(_sql, 1)
    3.51 -                    );
    3.52 -                assert(_identity);
    3.53 -                if (_identity == NULL)
    3.54 -                    return PEP_OUT_OF_MEMORY;
    3.55 -
    3.56 -                _identity->comm_type = (PEP_comm_type)
    3.57 -                    sqlite3_column_int(_sql, 2);
    3.58 -                const char* const _lang = (const char *)
    3.59 -                    sqlite3_column_text(_sql, 3);
    3.60 -                if (_lang && _lang[0]) {
    3.61 -                    assert(_lang[0] >= 'a' && _lang[0] <= 'z');
    3.62 -                    assert(_lang[1] >= 'a' && _lang[1] <= 'z');
    3.63 -                    assert(_lang[2] == 0);
    3.64 -                    _identity->lang[0] = _lang[0];
    3.65 -                    _identity->lang[1] = _lang[1];
    3.66 -                    _identity->lang[2] = 0;
    3.67 -                }
    3.68 -                _identity->flags = (unsigned int)
    3.69 -                    sqlite3_column_int(_sql, 4);
    3.70 -
    3.71 -                _il = identity_list_add(_il, _identity);
    3.72 -                if (!_il) {
    3.73 -                    free_identity_list(il);
    3.74 -                    free_identity(_identity);
    3.75 -                    return PEP_OUT_OF_MEMORY;
    3.76 -                }
    3.77 -                break;
    3.78 -
    3.79 -            case SQLITE_DONE:
    3.80 -                break;
    3.81 -
    3.82 -            default:
    3.83 -                free_identity_list(il);
    3.84 -                return PEP_UNKNOWN_ERROR;
    3.85 -            }
    3.86 -        } while (result != SQLITE_DONE);
    3.87 -
    3.88 -        IdentityList_t *r = IdentityList_from_identity_list(il, &session->sync_state.keysync.ownIdentities);
    3.89 -        free_identity_list(il);
    3.90 -        if (!r)
    3.91 -            return PEP_OUT_OF_MEMORY;
    3.92 -    ||
    3.93 -}
    3.94 +||
    3.95  
    3.96  action receivedKeysAreGroupKeys;
    3.97