webpg-npapi 0.6.1
FB::variant webpgPluginAPI::gpgSetKeyExpire ( const std::string &  keyid,
long  key_idx,
long  expire 
)

Sets the expiration of the given key_idx on the key keyid with the expiration of expire.

Parameters:
keyidThe ID of the key to set the expiration on.
key_idxThe index of the subkey to set the expiration on.
expireThe expiration to assign.

Definition at line 2683 of file webpgPluginAPI.cpp.

References get_gpgme_ctx().

Referenced by gpgSetPubkeyExpire(), and gpgSetSubkeyExpire().

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

    key_index = i_to_str(key_idx);
    expiration = i_to_str(expire);

    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_data_new (&out);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    edit_status = "gpgSetKeyExpire(keyid='" + keyid + "', key_idx='" + i_to_str(key_idx) + 
        "', expire='" + i_to_str(expire) + "');\n";
    err = gpgme_op_edit (ctx, key, edit_fnc_set_key_expire, out, out);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);


    key_index = "";
    expiration = "";

    gpgme_data_release (out);
    gpgme_key_unref (key);
    gpgme_release (ctx);

    response["error"] = false;
    response["edit_status"] = edit_status;
    response["result"] = "Expiration changed";

    return response;
}

Here is the call graph for this function:

 All Classes Functions