/* 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; }
int main (int argc, char **argv ) { gpgme_engine_info_t info; gpgme_error_t err; gpgme_check_version (NULL); err = gpgme_get_engine_info (&info); fail_if_err (err); check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION); info = info->next; #ifdef GPGSM_PATH check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION); #else if (info) { fprintf (stderr, "Unexpected engine info.\n"); exit (1); } #endif return 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; }
/** * seahorse_gpgme_get_keytype_table: * * @table: The requested keytype table * * Based on the gpg version in use, sets @table * to contain the numbers that gpg uses in its CLI * for adding new subkeys. This tends to get broken * at random by new versions of gpg, but there's no good * API for this. * * Returns GPG_ERR_USER_2 if gpg is too old. * * Returns: gpgme_error_t **/ gpgme_error_t seahorse_gpgme_get_keytype_table (SeahorseKeyTypeTable *table) { gpgme_error_t gerr; gpgme_engine_info_t engine; SeahorseVersion ver; gerr = gpgme_get_engine_info (&engine); g_return_val_if_fail (GPG_IS_OK (gerr), gerr); while (engine && engine->protocol != GPGME_PROTOCOL_OpenPGP) engine = engine->next; g_return_val_if_fail (engine != NULL, GPG_E (GPG_ERR_GENERAL)); ver = seahorse_util_parse_version (engine->version); if (ver >= VER_2012 || (ver >= VER_1410 && ver < VER_190)) *table = &KEYTYPES_2012; else if (ver >= VER_140 || ver >= VER_190) *table = &KEYTYPES_140; else if (ver >= VER_124) *table = &KEYTYPES_124; else if (ver >= VER_120) *table = &KEYTYPES_120; else // older versions not supported gerr = GPG_E (GPG_ERR_USER_2); return gerr; }
/** * Initialize the GPGME library. * This can be safely called multiple times; however it is not thread-safe. * @param handle the context handle * @return 0 on success, -1 on error */ static int init_gpgme(alpm_handle_t *handle) { static int init = 0; const char *version, *sigdir; gpgme_error_t gpg_err; gpgme_engine_info_t enginfo; if(init) { /* we already successfully initialized the library */ return 0; } sigdir = handle->gpgdir; if(_alpm_access(handle, sigdir, "pubring.gpg", R_OK) || _alpm_access(handle, sigdir, "trustdb.gpg", R_OK)) { handle->pm_errno = ALPM_ERR_NOT_A_FILE; _alpm_log(handle, ALPM_LOG_DEBUG, "Signature verification will fail!\n"); _alpm_log(handle, ALPM_LOG_WARNING, _("Public keyring not found; have you run '%s'?\n"), "pacman-key --init"); } /* calling gpgme_check_version() returns the current version and runs * some internal library setup code */ version = gpgme_check_version(NULL); _alpm_log(handle, ALPM_LOG_DEBUG, "GPGME version: %s\n", version); gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); #ifdef LC_MESSAGES gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); #endif /* NOTE: * The GPGME library installs a SIGPIPE signal handler automatically if * the default signal hander is in use. The only time we set a handler * for SIGPIPE is in dload.c, and we reset it when we are done. Given that * we do this, we can let GPGME do its automagic. However, if we install * a library-wide SIGPIPE handler, we will have to be careful. */ /* check for OpenPGP support (should be a no-brainer, but be safe) */ gpg_err = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP); CHECK_ERR(); /* set and check engine information */ gpg_err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL, sigdir); CHECK_ERR(); gpg_err = gpgme_get_engine_info(&enginfo); CHECK_ERR(); _alpm_log(handle, ALPM_LOG_DEBUG, "GPGME engine info: file=%s, home=%s\n", enginfo->file_name, enginfo->home_dir); init = 1; return 0; gpg_error: _alpm_log(handle, ALPM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(gpg_err)); RET_ERR(handle, ALPM_ERR_GPGME, -1); }
static int init_gpgme(alpm_handle_t *handle) { static int init = 0; const char *version, *sigdir; gpgme_error_t err; gpgme_engine_info_t enginfo; if(init) { /* we already successfully initialized the library */ return 0; } sigdir = alpm_option_get_gpgdir(handle); /* calling gpgme_check_version() returns the current version and runs * some internal library setup code */ version = gpgme_check_version(NULL); _alpm_log(handle, ALPM_LOG_DEBUG, "GPGME version: %s\n", version); gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); #ifdef LC_MESSAGES gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); #endif /* NOTE: * The GPGME library installs a SIGPIPE signal handler automatically if * the default signal hander is in use. The only time we set a handler * for SIGPIPE is in dload.c, and we reset it when we are done. Given that * we do this, we can let GPGME do its automagic. However, if we install * a library-wide SIGPIPE handler, we will have to be careful. */ /* check for OpenPGP support (should be a no-brainer, but be safe) */ err = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP); CHECK_ERR(); /* set and check engine information */ err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL, sigdir); CHECK_ERR(); err = gpgme_get_engine_info(&enginfo); CHECK_ERR(); _alpm_log(handle, ALPM_LOG_DEBUG, "GPGME engine info: file=%s, home=%s\n", enginfo->file_name, enginfo->home_dir); init = 1; return 0; error: _alpm_log(handle, ALPM_LOG_ERROR, _("GPGME error: %s\n"), gpgme_strerror(err)); RET_ERR(handle, ALPM_ERR_GPGME, 1); }
int setup(gpgme_ctx_t* ctx) { char *p; gpgme_error_t err; gpgme_engine_info_t enginfo; setlocale (LC_ALL, ""); p = (char *) gpgme_check_version(NULL); printf("version=%s\n",p); /* set locale, because tests do also */ gpgme_set_locale(NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); /* check for OpenPGP support */ err = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP); if(err != GPG_ERR_NO_ERROR) return 1; p = (char *) gpgme_get_protocol_name(GPGME_PROTOCOL_OpenPGP); printf("Protocol name: %s\n",p); /* get engine information */ err = gpgme_get_engine_info(&enginfo); if(err != GPG_ERR_NO_ERROR) return 2; printf("file=%s, home=%s\n",enginfo->file_name,enginfo->home_dir); /* create our own context */ err = gpgme_new(ctx); if(err != GPG_ERR_NO_ERROR) return 3; /* set protocol to use in our context */ err = gpgme_set_protocol(*ctx,GPGME_PROTOCOL_OpenPGP); if(err != GPG_ERR_NO_ERROR) return 4; /* set engine info in our context; I changed it for ceof like this: err = gpgme_ctx_set_engine_info (*ctx, GPGME_PROTOCOL_OpenPGP, "/usr/bin/gpg","/home/user/nico/.ceof/gpg/"); but I'll use standard values for this example: */ err = gpgme_ctx_set_engine_info (*ctx, GPGME_PROTOCOL_OpenPGP, enginfo->file_name,enginfo->home_dir); if(err != GPG_ERR_NO_ERROR) return 5; return 0; }
void sgpgme_init() { gchar *ctype_locale = NULL, *messages_locale = NULL; gchar *ctype_utf8_locale = NULL, *messages_utf8_locale = NULL; gpgme_engine_info_t engineInfo; if (gpgme_check_version("1.0.0")) { #ifdef LC_CTYPE debug_print("setting gpgme CTYPE locale\n"); #ifdef G_OS_WIN32 ctype_locale = g_win32_getlocale(); #else ctype_locale = g_strdup(setlocale(LC_CTYPE, NULL)); #endif if (ctype_locale) { debug_print("setting gpgme CTYPE locale to: %s\n", ctype_locale); if (strchr(ctype_locale, '.')) *(strchr(ctype_locale, '.')) = '\0'; else if (strchr(ctype_locale, '@')) *(strchr(ctype_locale, '@')) = '\0'; ctype_utf8_locale = g_strconcat(ctype_locale, ".UTF-8", NULL); debug_print("setting gpgme locale to UTF8: %s\n", ctype_utf8_locale ? ctype_utf8_locale : "NULL"); gpgme_set_locale(NULL, LC_CTYPE, ctype_utf8_locale); debug_print("done\n"); g_free(ctype_utf8_locale); g_free(ctype_locale); } else { debug_print("couldn't set gpgme CTYPE locale\n"); } #endif #ifdef LC_MESSAGES debug_print("setting gpgme MESSAGES locale\n"); #ifdef G_OS_WIN32 messages_locale = g_win32_getlocale(); #else messages_locale = g_strdup(setlocale(LC_MESSAGES, NULL)); #endif if (messages_locale) { debug_print("setting gpgme MESSAGES locale to: %s\n", messages_locale); if (strchr(messages_locale, '.')) *(strchr(messages_locale, '.')) = '\0'; else if (strchr(messages_locale, '@')) *(strchr(messages_locale, '@')) = '\0'; messages_utf8_locale = g_strconcat(messages_locale, ".UTF-8", NULL); debug_print("setting gpgme locale to UTF8: %s\n", messages_utf8_locale ? messages_utf8_locale : "NULL"); gpgme_set_locale(NULL, LC_MESSAGES, messages_utf8_locale); debug_print("done\n"); g_free(messages_utf8_locale); g_free(messages_locale); } else { debug_print("couldn't set gpgme MESSAGES locale\n"); } #endif if (!gpgme_get_engine_info(&engineInfo)) { while (engineInfo) { debug_print("GpgME Protocol: %s\n" "Version: %s (req %s)\n" "Executable: %s\n", gpgme_get_protocol_name(engineInfo->protocol) ? gpgme_get_protocol_name(engineInfo->protocol):"???", engineInfo->version ? engineInfo->version:"???", engineInfo->req_version ? engineInfo->req_version:"???", engineInfo->file_name ? engineInfo->file_name:"???"); if (engineInfo->protocol == GPGME_PROTOCOL_OpenPGP && gpgme_engine_check_version(engineInfo->protocol) != GPG_ERR_NO_ERROR) { if (engineInfo->file_name && !engineInfo->version) { alertpanel_error(_("Gpgme protocol '%s' is unusable: " "Engine '%s' isn't installed properly."), gpgme_get_protocol_name(engineInfo->protocol), engineInfo->file_name); } else if (engineInfo->file_name && engineInfo->version && engineInfo->req_version) { alertpanel_error(_("Gpgme protocol '%s' is unusable: " "Engine '%s' version %s is installed, " "but version %s is required.\n"), gpgme_get_protocol_name(engineInfo->protocol), engineInfo->file_name, engineInfo->version, engineInfo->req_version); } else { alertpanel_error(_("Gpgme protocol '%s' is unusable " "(unknown problem)"), gpgme_get_protocol_name(engineInfo->protocol)); } } engineInfo = engineInfo->next; } } } else { sgpgme_disable_all(); if (prefs_gpg_get_config()->gpg_warning) { AlertValue val; val = alertpanel_full (_("Warning"), _("GnuPG is not installed properly, or needs " "to be upgraded.\n" "OpenPGP support disabled."), GTK_STOCK_CLOSE, NULL, NULL, TRUE, NULL, ALERT_WARNING, G_ALERTDEFAULT); if (val & G_ALERTDISABLE) prefs_gpg_get_config()->gpg_warning = FALSE; } } }
/** \brief Initialise GpgME * * \param get_passphrase Callback function to read a passphrase from the * user. Note that this function is used \em only for OpenPGP and * \em only if no GPG Agent is running and can therefore usually be * NULL. The first (HOOK) argument the passed function accepts * shall be the parent GtkWindow. * \param select_key Callback function to let the user select a key from a * list if more than one is available. * \param accept_low_trust Callback function to ask the user whether a low * trust key shall be accepted. * * Initialise the GpgME backend and remember the callback functions. * * \note This function \em must be called before using any other function * from this module. */ void libbalsa_gpgme_init(gpgme_passphrase_cb_t get_passphrase, lbgpgme_select_key_cb select_key, lbgpgme_accept_low_trust_cb accept_low_trust) { gpgme_engine_info_t e; const gchar *agent_info; /* initialise the gpgme library */ g_message("init gpgme version %s", gpgme_check_version(NULL)); #ifdef HAVE_GPG /* configure the GnuPG engine if a specific gpg path has been * detected */ gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, GPG_PATH, NULL); #endif #ifdef ENABLE_NLS gpgme_set_locale(NULL, LC_CTYPE, get_utf8_locale(LC_CTYPE)); gpgme_set_locale(NULL, LC_MESSAGES, get_utf8_locale(LC_MESSAGES)); #endif /* ENABLE_NLS */ /* dump the available engines */ if (gpgme_get_engine_info(&e) == GPG_ERR_NO_ERROR) { while (e) { g_message("protocol %s: engine %s (home %s, version %s)", gpgme_get_protocol_name(e->protocol), e->file_name, e->home_dir, e->version); e = e->next; } } /* check for gpg-agent */ agent_info = g_getenv("GPG_AGENT_INFO"); if (agent_info) { g_message("gpg-agent found: %s", agent_info); gpgme_passphrase_cb = NULL; } else { gpgme_passphrase_cb = get_passphrase; } /* verify that the engines we need are there */ if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) == GPG_ERR_NO_ERROR) { g_message("OpenPGP protocol supported"); has_proto_openpgp = TRUE; } else { g_warning ("OpenPGP protocol not supported, basic crypto will not work!"); has_proto_openpgp = FALSE; } #ifdef HAVE_SMIME if (gpgme_engine_check_version(GPGME_PROTOCOL_CMS) == GPG_ERR_NO_ERROR) { g_message("CMS (aka S/MIME) protocol supported"); has_proto_cms = TRUE; } else { g_warning("CMS protocol not supported, S/MIME will not work!"); has_proto_cms = FALSE; } #else g_message("built without CMS (aka S/MIME) protocol support"); has_proto_cms = FALSE; #endif /* remember callbacks */ select_key = select_key_cb; accept_low_trust = accept_low_trust_cb; }
int main() { int fd; gpgme_ctx_t g_context; gpgme_engine_info_t enginfo; gpgme_data_t data; gpgme_error_t gerr; gpg_err_code_t gpg_err; gpgme_data_t g_plain; gpgme_data_t g_plain_recv; gpgme_data_t g_encrypt; gpgme_data_t g_encrypt_send; gpgme_key_t g_recipient[MAX_RCP+1]; char *p; char b_encrypt[BIGBUF+1]; char msg[EOF_L_MESSAGE]; char msg_in[EOF_L_MESSAGE]; int i, tmp; for(i=0;i<EOF_L_MESSAGE; i++) msg_in[i] = 0; for(i=0;i<EOF_L_MESSAGE; i++) msg[i] = 0; for(i=0;i<=BIGBUF; i++) b_encrypt[i] = 0; gpgme_check_version(NULL); gerr = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP); if(gerr != GPG_ERR_NO_ERROR) return 10; p = (char *) gpgme_get_protocol_name(GPGME_PROTOCOL_OpenPGP); printf("Version: %s\n",p); gerr = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL, home); if(gerr == GPG_ERR_NO_ERROR) { printf("gpgme_set_engine_info: ok\n"); } else { printf("gpgme_set_engine_info: err\n"); } /* get engine information */ gerr = gpgme_get_engine_info(&enginfo); if(gerr != GPG_ERR_NO_ERROR) return 3; printf("file=%s, home=%s\n",enginfo->file_name,enginfo->home_dir); /* create our own context */ gerr = gpgme_new(&g_context); if(gerr != GPG_ERR_NO_ERROR) return 1; /* FIXME: both needed? */ /* FIXME: why is the path (FILE_NAME) needed? */ /* FIXME: /usr/bin/gpg must be changed to ~/.ceof/gpg/binary or similar */ gerr = gpgme_ctx_set_engine_info (g_context, GPGME_PROTOCOL_OpenPGP, "/usr/bin/gpg",home); if(gerr != GPG_ERR_NO_ERROR) return 4; /* do not ascii armor data; use 1 for testing */ //gpgme_set_armor(g_context, 0); gpgme_set_armor(g_context, 1); /* create buffers */ gerr = gpgme_data_new(&data); if(gerr != GPG_ERR_NO_ERROR) return 12; gerr = gpgme_data_new(&g_plain_recv); if(gerr != GPG_ERR_NO_ERROR) return 20; gerr = gpgme_data_new(&g_encrypt); if(gerr != GPG_ERR_NO_ERROR) return 14; gerr = gpgme_data_new(&g_encrypt_send); if(gerr != GPG_ERR_NO_ERROR) return 24; /* fill buffers */ /* gerr = gpgme_data_new(&g_plain); if(gerr != GPG_ERR_NO_ERROR) return 13; printf("strlen(%s) = %d\n",msg,i); i -= gpgme_data_write(g_plain, msg, i); if(i) { printf("size mismatch\n"); return 12; } */ strncpy(msg, "==> Erste Nachricht\n\n", EOF_L_MESSAGE); i = strlen(msg); gerr = gpgme_data_new_from_mem (&g_plain, msg, i, 0); /* setup recipient */ gerr = gpgme_op_keylist_start(g_context, "nico schottelius", 0); if(gerr != GPG_ERR_NO_ERROR) return 11; i=0; gerr = gpgme_op_keylist_next(g_context, &g_recipient[0]); while((gpg_err = gpg_err_code(gerr)) != GPG_ERR_EOF) { /* for testing: one call of gpgme_op_keylist_next is enough */ break; if(gerr == GPG_ERR_INV_VALUE) { printf("invalid pointer\n"); return 15; } else if(gerr == GPG_ERR_ENOMEM) { printf("no mem\n"); return 16; } printf ("%s: %s <%s> (%d)\n", g_recipient[0]->subkeys->keyid, g_recipient[0]->uids->name, g_recipient[0]->uids->email, i); i++; /* FIXME: this resets the good filled buffer ... */ gerr = gpgme_op_keylist_next(g_context, &g_recipient[0]); } g_recipient[1] = NULL; /* all above seems to be wrong ... */ gerr = gpgme_get_key(g_context,"775506B45998BF57D0D4AFF27C6E747C38616ADC", &g_recipient[0], 0); if(gerr != GPG_ERR_NO_ERROR) return 32; /* en/decrypt message */ //gerr = gpgme_op_encrypt_sign(g_context, g_recipient, 0, g_plain, g_encrypt); gerr = gpgme_op_encrypt(g_context, g_recipient, 0, g_plain, g_encrypt); if(gerr != GPG_ERR_NO_ERROR) { printf("gerr=%d\n",gerr); return 18; } /* transfer the data into our own buffer, * so the data is saved; you cannot * reuse the gpgme buffers directly as in * gerr = gpgme_op_decrypt(g_context, g_encrypt, g_plain_recv); * */ i = gpgme_data_seek(g_encrypt, 0, SEEK_END); if(i > BIGBUF) return 22; printf("buflen: %d\n",i); /* reset to the beginning */ gpgme_data_seek(g_encrypt, 0, SEEK_SET); if(gpgme_data_read(g_encrypt, b_encrypt, i) == -1) { perror("pgme_data_read"); return 23; } printf("crypt:\n%s\n", b_encrypt); fd = open("testcrypt",O_RDWR|O_CREAT); if(fd == -1) return 40; if(write_all(fd, b_encrypt, BIGBUF) <= 0) return 41; close(fd); /* until here it works, testcrypt contains * data and can be decrypted ... * * perhaps the context needs some reset? */ if((tmp = gpgme_data_write(g_encrypt_send, b_encrypt, i)) == -1) { perror("pgme_data_write"); return 23; } printf("crypt-wrote:%d\n", tmp); /* look for contexts */ gerr = gpgme_op_decrypt(g_context, g_encrypt_send, g_plain_recv); if(gerr != GPG_ERR_NO_ERROR) { printf("gerr=%d\n",gerr); return 19; } /* open communication channel: netcat */ /* listen for input from: * stdin * communication channel */ /* de/encode data from comm channel */ return 1; }
GPGME_Error GPGME::init(const QString & gpgHomeDir) { if (instancesStore.contains(gpgHomeDir)) { return GPG_ERR_NO_ERROR; } setlocale(LC_ALL, ""); gpgme_check_version(NULL); gpgme_set_locale(NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); #ifdef LC_MESSAGES gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); #endif gpgme_error_t err; gpgme_ctx_t context; err = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP); if (err != GPG_ERR_NO_ERROR) { return err; } QString protocolName = gpgme_get_protocol_name(GPGME_PROTOCOL_OpenPGP); qDebug() << "protocol: " << protocolName; gpgme_engine_info_t engineInfo; err = gpgme_get_engine_info(&engineInfo); if (err != GPG_ERR_NO_ERROR) { return err; } qDebug() << "Backend info"; qDebug() << "filename: " << engineInfo->file_name << ", homedir: " << engineInfo->home_dir; err = gpgme_new(&context); if (err != GPG_ERR_NO_ERROR) { return err; } err = gpgme_set_protocol(context, GPGME_PROTOCOL_OpenPGP); if (err != GPG_ERR_NO_ERROR) { return err; } // we don't need to set gnupg home dir explicitly QString gnupgHome; if (gpgHomeDir.isEmpty()) { // i.e. use default gnupg directory or one from environment QString gnupgHomeEnv = QString::fromLatin1(qgetenv("GNUPGHOME")); if (!gnupgHomeEnv.isEmpty()) { gnupgHome = gnupgHomeEnv; } else { // use default path: "~/.gnupg" QDir gh = QDir::home(); gh.cd(".gnupg"); gnupgHome = gh.canonicalPath(); } } else { QDir gh(gpgHomeDir); gnupgHome = gh.canonicalPath(); } qDebug() << "GNUPGHOME" << gnupgHome; err = gpgme_ctx_set_engine_info(context, GPGME_PROTOCOL_OpenPGP, engineInfo->file_name, gnupgHome.toLatin1().data() ); if (err != GPG_ERR_NO_ERROR) { return err; } GPGME * inst = new GPGME(context, gnupgHome); instancesStore[gpgHomeDir] = inst; qDebug() << "gpgme initalized for the directory " << gnupgHome << "[store key: " << gpgHomeDir << "]"; return GPG_ERR_NO_ERROR; }