src/pEpEngine.c
branchENGINE-209
changeset 1793 74cf3813c28e
parent 1791 0253b2e1b8ff
child 1797 32581fade44d
     1.1 --- a/src/pEpEngine.c	Wed May 17 14:45:10 2017 +0200
     1.2 +++ b/src/pEpEngine.c	Wed May 17 15:07:34 2017 +0200
     1.3 @@ -29,6 +29,16 @@
     1.4      "       and pgp_keypair_fpr = identity.main_key_id"
     1.5      "   where address = ?1 and identity.user_id = ?2;";
     1.6  
     1.7 +static const char *sql_get_identities_by_fpr =  
     1.8 +    "select fpr, username, comm_type, lang,"
     1.9 +    "   identity.flags | pgp_keypair.flags"
    1.10 +    "   from identity"
    1.11 +    "   join person on id = identity.user_id"
    1.12 +    "   join pgp_keypair on fpr = identity.main_key_id"
    1.13 +    "   join trust on id = trust.user_id"
    1.14 +    "       and pgp_keypair_fpr = identity.main_key_id"
    1.15 +    "   where identity.main_key_id = ?1;";
    1.16 +
    1.17  // Set person, but if already exist, only update.
    1.18  // if main_key_id already set, don't touch.
    1.19  static const char *sql_set_person = 
    1.20 @@ -507,6 +517,11 @@
    1.21              (int)strlen(sql_get_identity), &_session->get_identity, NULL);
    1.22      assert(int_result == SQLITE_OK);
    1.23  
    1.24 +    int_result = sqlite3_prepare_v2(_session->db, sql_get_identities_by_fpr,
    1.25 +            (int)strlen(sql_get_identities_by_fpr), 
    1.26 +            &_session->get_identities_by_fpr, NULL);
    1.27 +    assert(int_result == SQLITE_OK);
    1.28 +
    1.29      int_result = sqlite3_prepare_v2(_session->db, sql_set_person,
    1.30              (int)strlen(sql_set_person), &_session->set_person, NULL);
    1.31      assert(int_result == SQLITE_OK);
    1.32 @@ -739,6 +754,8 @@
    1.33                  sqlite3_finalize(session->trustword);
    1.34              if (session->get_identity)
    1.35                  sqlite3_finalize(session->get_identity);
    1.36 +            if (session->get_identities_by_fpr)
    1.37 +                sqlite3_finalize(session->get_identities_by_fpr);        
    1.38              if (session->set_person)
    1.39                  sqlite3_finalize(session->set_person);
    1.40              if (session->set_device_group)
    1.41 @@ -1266,6 +1283,16 @@
    1.42          return PEP_COMMIT_FAILED;
    1.43  }
    1.44  
    1.45 +PEP_STATUS get_identities_by_fpr(PEP_SESSION session, 
    1.46 +                                 char* fpr, 
    1.47 +                                 identity_list** id_list) 
    1.48 +{
    1.49 +    PEP_STATUS status = PEP_STATUS_OK;
    1.50 +    
    1.51 +    return status;
    1.52 +}
    1.53 +
    1.54 +
    1.55  static PEP_STATUS set_trust(PEP_SESSION session, 
    1.56                              const char* user_id,
    1.57                              const char* fpr,