|
webpg-npapi 0.6.1
|
Attempts to set the specified gpgconf preference with the value of pref_value.
Definition at line 968 of file webpgPluginAPI.cpp. References get_gpgme_ctx(). Referenced by gpgSignUID(), and webpgPluginAPI(). {
gpgme_error_t err;
gpgme_protocol_t proto = GPGME_PROTOCOL_OpenPGP;
err = gpgme_engine_check_version (proto);
if (err != GPG_ERR_NO_ERROR)
return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);
gpgme_ctx_t ctx = get_gpgme_ctx();
gpgme_conf_comp_t conf, comp;
FB::variant response;
std::string return_code;
err = gpgme_op_conf_load (ctx, &conf);
if (err != GPG_ERR_NO_ERROR)
return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);
gpgme_conf_arg_t original_arg, arg;
gpgme_conf_opt_t opt;
if (pref_value.length())
err = gpgme_conf_arg_new (&arg, GPGME_CONF_STRING, (char *) pref_value.c_str());
else
err = gpgme_conf_arg_new (&arg, GPGME_CONF_STRING, NULL);
if (err != GPG_ERR_NO_ERROR)
return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);
comp = conf;
while (comp && strcmp (comp->name, "gpg"))
comp = comp->next;
if (comp) {
opt = comp->options;
while (opt && strcmp (opt->name, (char *) preference.c_str())){
opt = opt->next;
}
if (!opt) {
return "unable to locate that option in this context";
}
if (opt->value && pref_value.length()) {
original_arg = opt->value;
} else {
original_arg = opt->value;
return_code = "blank";
}
/* if the new argument and original argument are the same, return 0,
there is nothing to do. */
if (pref_value.length() && original_arg &&
!strcmp (original_arg->value.string, arg->value.string)) {
return "0";
}
if (opt) {
if (!strcmp(pref_value.c_str(), "blank") || pref_value.length() < 1)
err = gpgme_conf_opt_change (opt, 0, NULL);
else
err = gpgme_conf_opt_change (opt, 0, arg);
if (err != GPG_ERR_NO_ERROR)
return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);
err = gpgme_op_conf_save (ctx, comp);
if (err != GPG_ERR_NO_ERROR)
return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);
}
}
if (conf)
gpgme_conf_release (conf);
if (ctx)
gpgme_release (ctx);
if (!return_code.length())
return_code = strdup(original_arg->value.string);
return return_code;
}
Here is the call graph for this function:
![]() |
1.7.4