示例#1
0
/* Initializes the gpg-options static info */
static gboolean
gpg_options_init (GError **err)
{
    if (!gpg_options_inited) {
        gpgme_error_t gerr;
        gpgme_engine_info_t engine;

        gerr = gpgme_get_engine_info (&engine);
        g_return_val_if_fail (GPG_IS_OK (gerr),
                              (bastile_gpgme_to_error (gerr, err), FALSE));

        /* Look for the OpenPGP engine */
        while (engine && engine->protocol != GPGME_PROTOCOL_OpenPGP)
            engine = engine->next;

        /* 
         * Make sure it's the right version for us to be messing 
         * around with the configuration file.
         */
        g_return_val_if_fail (engine && engine->version && engine->file_name &&
                              (g_str_has_prefix (engine->version, GPG_VERSION_PREFIX1) ||
                               g_str_has_prefix (engine->version, GPG_VERSION_PREFIX2)),
                              (bastile_gpgme_to_error (GPG_E (GPG_ERR_INV_ENGINE), err), FALSE));

        /* Now run the binary and read in the home directory */
        if (!parse_home_directory (engine, err))
            return FALSE;

        gpg_options_inited = TRUE;
    }

    return TRUE;
}
示例#2
0
/* Initializes the gpg-options static info */
static gboolean
gpg_options_init (GError **err)
{
    gpgme_error_t gerr;
    gpgme_engine_info_t engine;

    if (gpg_options_inited)
        return TRUE;

    gerr = gpgme_get_engine_info (&engine);
    if (seahorse_gpgme_propagate_error (gerr, err))
        return FALSE;

    /* Look for the OpenPGP engine */
    while (engine && engine->protocol != GPGME_PROTOCOL_OpenPGP)
        engine = engine->next;

    /*
     * Make sure it's the right version for us to be messing
     * around with the configuration file.
     */
    if (!engine || !engine->version || !engine->file_name ||
            !(g_str_has_prefix (engine->version, GPG_VERSION_PREFIX1) ||
              g_str_has_prefix (engine->version, GPG_VERSION_PREFIX2))) {
        seahorse_gpgme_propagate_error (GPG_E (GPG_ERR_INV_ENGINE), err);
        return FALSE;
    }

    /* Now run the binary and read in the home directory */
    if (!parse_home_directory (engine, err))
        return FALSE;

    gpg_options_inited = TRUE;
    return TRUE;
}