ENGINE-73 #comment gpgme version working and tests pass. Time to switch over to netpgp. ENGINE-73
authorKrista Grothoff <krista@pep-project.org>
Thu, 18 Aug 2016 15:01:37 +0200
branchENGINE-73
changeset 1032b4004d33c2a2
parent 1031 ed718acfd6fe
child 1033 67e21fb43c77
ENGINE-73 #comment gpgme version working and tests pass. Time to switch over to netpgp.
src/openpgp_compat.c
src/openpgp_compat.h
src/pEpEngine.c
src/pgp_gpg.c
test/pgp_list_keys_test.cc
     1.1 --- a/src/openpgp_compat.c	Thu Aug 18 14:20:25 2016 +0200
     1.2 +++ b/src/openpgp_compat.c	Thu Aug 18 15:01:37 2016 +0200
     1.3 @@ -3,8 +3,8 @@
     1.4  #include "openpgp_compat.h"
     1.5  
     1.6  DYNAMIC_API PEP_STATUS OpenPGP_list_keyinfo (
     1.7 -        PEP_SESSION session, stringpair_list_t** keyinfo_list, char* search_pattern
     1.8 -    );
     1.9 +        PEP_SESSION session, const char* search_pattern, stringpair_list_t** keyinfo_list
    1.10 +    )
    1.11  {
    1.12      assert(session);
    1.13      assert(keyinfo_list);
    1.14 @@ -14,7 +14,7 @@
    1.15  
    1.16      stringpair_list_t* _keyinfo_list = NULL;
    1.17      
    1.18 -    PEP_STATUS retval = pgp_list_keyinfo(session, _keyinfo_list, search_pattern);
    1.19 +    PEP_STATUS retval = pgp_list_keyinfo(session, search_pattern, &_keyinfo_list);
    1.20          
    1.21      if (retval == PEP_STATUS_OK)
    1.22          *keyinfo_list = _keyinfo_list;
     2.1 --- a/src/openpgp_compat.h	Thu Aug 18 14:20:25 2016 +0200
     2.2 +++ b/src/openpgp_compat.h	Thu Aug 18 15:01:37 2016 +0200
     2.3 @@ -39,7 +39,7 @@
     2.4  //        identity objects derived from the keyring only have the available information
     2.5  //           from the keyring; some fields may be NULL
     2.6  DYNAMIC_API PEP_STATUS OpenPGP_list_keyinfo (
     2.7 -        PEP_SESSION session, stringpair_list_t** keyinfo_list, char* search_pattern
     2.8 +        PEP_SESSION session, const char* search_pattern, stringpair_list_t** keyinfo_list
     2.9      );
    2.10      
    2.11  #ifdef __cplusplus
     3.1 --- a/src/pEpEngine.c	Thu Aug 18 14:20:25 2016 +0200
     3.2 +++ b/src/pEpEngine.c	Thu Aug 18 15:01:37 2016 +0200
     3.3 @@ -56,9 +56,6 @@
     3.4      static const char *sql_set_revoked;
     3.5      static const char *sql_get_revoked;
     3.6      
     3.7 -    // Get full list of keys in database
     3.8 -    static const char *sql_get_keylist;
     3.9 -    
    3.10      bool in_first = false;
    3.11  
    3.12      assert(sqlite3_threadsafe());
    3.13 @@ -366,8 +363,6 @@
    3.14          
    3.15          sql_get_revoked =     "select revoked_fpr, revocation_date from revoked_keys"
    3.16                                "    where replacement_fpr = upper(replace(?1,' ','')) ;";
    3.17 -        
    3.18 -        sql_get_keylist =     "
    3.19      }
    3.20  
    3.21      int_result = sqlite3_prepare_v2(_session->db, sql_log, (int)strlen(sql_log),
     4.1 --- a/src/pgp_gpg.c	Thu Aug 18 14:20:25 2016 +0200
     4.2 +++ b/src/pgp_gpg.c	Thu Aug 18 15:01:37 2016 +0200
     4.3 @@ -1305,7 +1305,7 @@
     4.4          }
     4.5      } while (gpgme_error != GPG_ERR_EOF);
     4.6      
     4.7 -    if (_keyinfo_list->ident == NULL) {
     4.8 +    if (_keyinfo_list->value == NULL) {
     4.9          free_stringpair_list(_keyinfo_list);
    4.10          _keyinfo_list = NULL;
    4.11      }
     5.1 --- a/test/pgp_list_keys_test.cc	Thu Aug 18 14:20:25 2016 +0200
     5.2 +++ b/test/pgp_list_keys_test.cc	Thu Aug 18 15:01:37 2016 +0200
     5.3 @@ -2,28 +2,25 @@
     5.4  #include <string>
     5.5  #include <assert.h>
     5.6  #include "pEpEngine.h"
     5.7 -#include "identity_list.h"
     5.8 +#include "stringpair.h"
     5.9 +#include "openpgp_compat.h"
    5.10  
    5.11  using namespace std;
    5.12  
    5.13 -void print_id_list(identity_list* idl) {
    5.14 -    for ( ; idl != NULL; idl = idl->next) {
    5.15 -        if (idl->ident) {
    5.16 -            cout << "Identity:" << endl;
    5.17 -            if (idl->ident->fpr)
    5.18 -                cout << "\tFPR: " << idl->ident->fpr << endl;
    5.19 -            if (idl->ident->address)
    5.20 -                cout << "\tAddress: " << idl->ident->address << endl; 
    5.21 -            if (idl->ident->user_id)
    5.22 -                cout << "\tUID: " << idl->ident->user_id << endl;
    5.23 -            if (idl->ident->username)
    5.24 -                cout << "\tName: " << idl->ident->username << endl << endl;
    5.25 +void print_stringpair_list(stringpair_list_t* spl) {
    5.26 +    for ( ; spl != NULL; spl = spl->next) {
    5.27 +        if (spl->value) {
    5.28 +            cout << "Key:" << endl;
    5.29 +            if (spl->value->key)
    5.30 +                cout << "\tFPR: " << spl->value->key << endl;
    5.31 +            if (spl->value->value)
    5.32 +                cout << "\tUID: " << spl->value->value << endl;
    5.33          }
    5.34      }
    5.35  }
    5.36  
    5.37  int main() {
    5.38 -    cout << "\n*** pgp_list_keys_test ***\n\n";
    5.39 +    cout << "\n*** openpgp_compat test ***\n\n";
    5.40  
    5.41      PEP_SESSION session;
    5.42      
    5.43 @@ -33,10 +30,29 @@
    5.44      assert(session);
    5.45      cout << "init() completed.\n";
    5.46  
    5.47 -    identity_list* all_the_ids = NULL;
    5.48 -    list_keys(session, &all_the_ids);
    5.49 -    print_id_list(all_the_ids);
    5.50 -    free_identity_list(all_the_ids);
    5.51 +    cout << "Listing all the keys:" << endl;
    5.52 +    stringpair_list_t* all_the_ids = NULL;
    5.53 +    OpenPGP_list_keyinfo(session, "", &all_the_ids);
    5.54 +    print_stringpair_list(all_the_ids);
    5.55 +    free_stringpair_list(all_the_ids);
    5.56 +    
    5.57 +    cout << "**********************" << endl << endl << "Checking on Alice, Bob and John" << endl;
    5.58 +    all_the_ids = NULL;
    5.59 +    OpenPGP_list_keyinfo(session, "pEp Test", &all_the_ids);
    5.60 +    print_stringpair_list(all_the_ids);
    5.61 +    free_stringpair_list(all_the_ids);
    5.62 +
    5.63 +    cout << "**********************" << endl << endl << "Checking FPR" << endl;
    5.64 +    all_the_ids = NULL;
    5.65 +    OpenPGP_list_keyinfo(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &all_the_ids);
    5.66 +    print_stringpair_list(all_the_ids);
    5.67 +    free_stringpair_list(all_the_ids);
    5.68 +
    5.69 +    cout << "**********************" << endl << endl << "Checking on nothing" << endl;
    5.70 +    all_the_ids = NULL;
    5.71 +    OpenPGP_list_keyinfo(session, "ekhwr89234uh4rknfjsklejfnlskjflselkflkserjs", &all_the_ids);
    5.72 +    print_stringpair_list(all_the_ids);
    5.73 +    free_stringpair_list(all_the_ids);
    5.74  
    5.75      cout << "calling release()\n";
    5.76      release(session);