A hopefully better fix for commit 9f1c5fef1 when building with GpgME < 1.7.0.
[claws.git] / src / plugins / pgpcore / pgp_viewer.c
index 22e9caefc4fdc28b9a5e0de8ea40a417a6fe094f..6826c4b2a42edeac7c7639bbd55bf9fe7c706757 100644 (file)
@@ -70,23 +70,6 @@ static GtkWidget *pgp_get_widget(MimeViewer *_viewer)
        return GTK_WIDGET(viewer->textview->vbox);
 }
 
-static gchar *_get_gpg_executable_name()
-{
-       gpgme_engine_info_t e;
-
-       if (!gpgme_get_engine_info(&e)) {
-               while (e != NULL) {
-                       if (e->protocol == GPGME_PROTOCOL_OpenPGP
-                                       && e->file_name != NULL) {
-                               debug_print("Found gpg executable: '%s'\n", e->file_name);
-                               return e->file_name;
-                       }
-               }
-       }
-
-       return NULL;
-}
-
 #ifdef G_OS_WIN32
 struct _ImportCtx {
        gboolean done;
@@ -182,8 +165,8 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        }
        gpgme_get_key(ctx, sig->fpr, &key, 0);
        if (!key) {
-               gchar *gpgbin = _get_gpg_executable_name();
-               gchar *cmd = g_strdup_printf("\"%s\" --no-tty --recv-keys %s",
+               gchar *gpgbin = get_gpg_executable_name();
+               gchar *cmd = g_strdup_printf("\"%s\" --batch --no-tty --recv-keys %s",
                                (gpgbin ? gpgbin : "gpg"), sig->fpr);
                AlertValue val = G_ALERTDEFAULT;
                if (!prefs_common_get_prefs()->work_offline) {
@@ -225,6 +208,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                                gchar **argv;
                                argv = strsplit_with_quote(cmd, " ", 0);
                                res = execvp(argv[0], argv);
+                               perror("execvp");
                                exit(255);
                        } else {
                                int status = 0;
@@ -261,7 +245,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                        ctx->exitcode = STILL_ACTIVE;
                        ctx->cmd = cmd;
 
-                       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE,
+                       if (pthread_create(&pt, NULL,
                                                _import_threaded, (void *)ctx) != 0) {
                                debug_print("Couldn't create thread, continuing unthreaded.\n");
                                _import_threaded(ctx);
@@ -294,7 +278,13 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                return;
        } else {
                TEXTVIEW_INSERT(_("\n  Key ID "));
+
+#if defined GPGME_VERSION_NUMBER && GPGME_VERSION_NUMBER >= 0x010700
+               TEXTVIEW_INSERT(key->fpr);
+#else
                TEXTVIEW_INSERT(sig->fpr);
+#endif
+
                TEXTVIEW_INSERT(":\n\n");
                TEXTVIEW_INSERT(_("   This key is in your keyring.\n"));
        }