webpg-npapi 0.6.1
FB::variant webpgPluginAPI::gpgDeleteKey ( const std::string &  keyid,
int  allow_secret 
)

Deletes the key specified in keyid from the keyring.

Parameters:
allow_secretEnables/disables deleting the key from the private keyring.
keyidThe ID of the key to delete.
allow_secretEnables/disables deleting the key from the private keyring.

Definition at line 2271 of file webpgPluginAPI.cpp.

References get_gpgme_ctx().

Referenced by gpgDeletePrivateKey(), and gpgDeletePublicKey().

{
    gpgme_ctx_t ctx = get_gpgme_ctx();
    gpgme_error_t err;
    gpgme_key_t key = NULL;
    FB::VariantMap response;

    err = gpgme_op_keylist_start (ctx, keyid.c_str(), 0);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    err = gpgme_op_keylist_next (ctx, &key);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    err = gpgme_op_keylist_end (ctx);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    err = gpgme_op_delete(ctx, key, allow_secret);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    gpgme_key_unref (key);
    gpgme_release (ctx);

    response["error"] = false;
    response["result"] = "Key deleted";

    return response;
}

Here is the call graph for this function:

 All Classes Functions