diff --git a/account.cpp b/account.cpp index 23153b7..7b2a64f 100644 --- a/account.cpp +++ b/account.cpp @@ -33,8 +33,7 @@ char *account_options[ACCOUNT_NUM_OPTIONS][2] = { (char*)"autoconnect", (char*)"" }, { (char*)"resource", (char*)"" }, { (char*)"status", (char*)"probably about to segfault" }, - { (char*)"pgp_pubring_path", (char*)"${weechat_data_dir}/pubring.gpg" }, - { (char*)"pgp_secring_path", (char*)"${weechat_data_dir}/secring.gpg" }, + { (char*)"pgp_path", (char*)"" }, { (char*)"pgp_keyid", (char*)"" }, }; diff --git a/account.hh b/account.hh index 7861508..d51b63a 100644 --- a/account.hh +++ b/account.hh @@ -23,8 +23,7 @@ enum t_account_option ACCOUNT_OPTION_AUTOCONNECT, ACCOUNT_OPTION_RESOURCE, ACCOUNT_OPTION_STATUS, - ACCOUNT_OPTION_PGP_PUBRING_PATH, - ACCOUNT_OPTION_PGP_SECRING_PATH, + ACCOUNT_OPTION_PGP_PATH, ACCOUNT_OPTION_PGP_KEYID, ACCOUNT_NUM_OPTIONS, }; @@ -63,10 +62,8 @@ enum t_account_option weechat_config_string(account->options[ACCOUNT_OPTION_RESOURCE]) #define account_status(account) \ weechat_config_string(account->options[ACCOUNT_OPTION_STATUS]) -#define account_pgp_pubring_path(account) \ - weechat_config_string(account->options[ACCOUNT_OPTION_PGP_PUBRING_PATH]) -#define account_pgp_secring_path(account) \ - weechat_config_string(account->options[ACCOUNT_OPTION_PGP_SECRING_PATH]) +#define account_pgp_path(account) \ + weechat_config_string(account->options[ACCOUNT_OPTION_PGP_PATH]) #define account_pgp_keyid(account) \ weechat_config_string(account->options[ACCOUNT_OPTION_PGP_KEYID]) diff --git a/config.cpp b/config.cpp index 3944b3d..642bffd 100644 --- a/config.cpp +++ b/config.cpp @@ -204,27 +204,11 @@ config__account_new_option (struct t_config_file *config_file, callback_change_data, NULL, NULL, NULL); break; - case ACCOUNT_OPTION_PGP_PUBRING_PATH: + case ACCOUNT_OPTION_PGP_PATH: new_option = weechat_config_new_option ( config_file, section, option_name, "string", - N_("XMPP Account PGP Public Keyring Path"), - NULL, 0, 0, - default_value, value, - null_value_allowed, - callback_check_value, - callback_check_value_pointer, - callback_check_value_data, - callback_change, - callback_change_pointer, - callback_change_data, - NULL, NULL, NULL); - break; - case ACCOUNT_OPTION_PGP_SECRING_PATH: - new_option = weechat_config_new_option ( - config_file, section, - option_name, "string", - N_("XMPP Account PGP Secure Keyring Path"), + N_("XMPP Account PGP Keyring Dir"), NULL, 0, 0, default_value, value, null_value_allowed, diff --git a/connection.cpp b/connection.cpp index d2bce7a..066df66 100644 --- a/connection.cpp +++ b/connection.cpp @@ -1218,11 +1218,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status, xmpp_handler_add(conn, &connection__iq_handler, NULL, "iq", NULL, account); - pgp__init(&account->pgp, - weechat_string_eval_expression(account_pgp_pubring_path(account), - NULL, NULL, NULL), - weechat_string_eval_expression(account_pgp_secring_path(account), - NULL, NULL, NULL)); + pgp__init(&account->pgp); /* Send initial so that we appear online to contacts */ children = (xmpp_stanza_t**)malloc(sizeof(*children) * (3 + 1)); diff --git a/pgp.cpp b/pgp.cpp index 0f35a44..7b32d01 100644 --- a/pgp.cpp +++ b/pgp.cpp @@ -19,7 +19,7 @@ const char *PGP_ADVICE = "[PGP encrypted message (XEP-0027)]"; -void pgp__init(struct t_pgp **pgp, const char *pub, const char *sec) +void pgp__init(struct t_pgp **pgp) { struct t_pgp *new_pgp; gpgme_error_t err; @@ -31,35 +31,37 @@ void pgp__init(struct t_pgp **pgp, const char *pub, const char *sec) err = gpgme_new(&new_pgp->gpgme); if (err) { + weechat_printf(nullptr, "gpg (error): %s - %s", + gpgme_strsource(err), gpgme_strerror(err)); return; } gpgme_set_armor(new_pgp->gpgme, true); - err = gpgme_data_new_from_file(&keydata, pub, true); - if (err) { - return; - } + //err = gpgme_data_new_from_file(&keydata, pub, true); + //if (err) { + // return; + //} - err = gpgme_op_import(new_pgp->gpgme, keydata); - if (err) { - return; - } + //err = gpgme_op_import(new_pgp->gpgme, keydata); + //if (err) { + // return; + //} - gpgme_import_result_t impRes = gpgme_op_import_result(new_pgp->gpgme); - weechat_printf(nullptr, "(gpg) imported %d keys", impRes->imported); + //gpgme_import_result_t impRes = gpgme_op_import_result(new_pgp->gpgme); + //weechat_printf(nullptr, "(gpg) imported %d keys", impRes->imported); - err = gpgme_data_new_from_file(&keydata, sec, true); - if (err) { - return; - } + //err = gpgme_data_new_from_file(&keydata, sec, true); + //if (err) { + // return; + //} - err = gpgme_op_import(new_pgp->gpgme, keydata); - if (err) { - return; - } + //err = gpgme_op_import(new_pgp->gpgme, keydata); + //if (err) { + // return; + //} - impRes = gpgme_op_import_result(new_pgp->gpgme); - weechat_printf(nullptr, "(gpg) imported %d secret keys", impRes->imported); + //impRes = gpgme_op_import_result(new_pgp->gpgme); + //weechat_printf(nullptr, "(gpg) imported %d secret keys", impRes->imported); *pgp = new_pgp; } diff --git a/pgp.hh b/pgp.hh index 1a40706..7b4faff 100644 --- a/pgp.hh +++ b/pgp.hh @@ -14,7 +14,7 @@ struct t_pgp const char *keyid; }; -void pgp__init(struct t_pgp **pgp, const char *pub, const char *sec); +void pgp__init(struct t_pgp **pgp); void pgp__free(struct t_pgp *pgp);