webpg-npapi 0.6.1
std::string webpgPluginAPI::gpgGetPreference ( const std::string &  preference)

Attempts to retrieve the specified preference from the gpgconf utility.

Parameters:
preferenceThe gpgconf preference to retrieve.

Definition at line 1060 of file webpgPluginAPI.cpp.

References get_gpgme_ctx().

Referenced by 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::VariantMap response;
    response["error"] = false;

    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 arg;
    gpgme_conf_opt_t opt;

    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) {
            if (opt->value) {
                arg = opt->value;
                response["value"] = strdup(arg->value.string);
            } else {
                response["value"] = "";
            }
        } else {
            response["error"] = true;
            response["error_string"] = "unable to locate that option in this context";
        }
    }

    if (conf)
        gpgme_conf_release (conf);

    if (ctx)
        gpgme_release (ctx);

    return response;
}

Here is the call graph for this function:

 All Classes Functions