RSSyl: Allow use of .netrc by libcurl. Bug/enhancement #3309, by Vincent Pelletier
[claws.git] / src / plugins / pgpcore / pgp_viewer.c
index d87e6c345e4327fcdd822f7a4dc8ac7c005d9001..29a86988ca80ddf5ae7923ae8330dc951efb14e7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 the Claws Mail team
+ * Copyright (C) 1999-2012 the Claws Mail team
  * This file Copyright (C) 2006 Colin Leroy <colin@colino.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include <stddef.h>
@@ -29,7 +30,7 @@
 #ifndef G_OS_WIN32
 #  include <sys/wait.h>
 #endif
-#if (defined(__DragonFly__) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__OpenBSD__))
+#if (defined(__DragonFly__) || defined(SOLARIS) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__OpenBSD__))
 #  include <sys/signal.h>
 #endif
 
@@ -116,7 +117,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        if (!key) {
                gchar *cmd = g_strdup_printf("gpg --no-tty --recv-keys %s", sig->fpr);
                AlertValue val = G_ALERTDEFAULT;
-               if (!prefs_common.work_offline) {
+               if (!prefs_common_get_prefs()->work_offline) {
                        val = alertpanel(_("Key import"),
                                _("This key is not in your keyring. Do you want "
                                  "Claws Mail to try and import it from a "
@@ -130,7 +131,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                        TEXTVIEW_INSERT(":\n\n");
                        TEXTVIEW_INSERT(_("   This key is not in your keyring.\n"));
                        TEXTVIEW_INSERT(_("   It should be possible to import it "));
-                       if (prefs_common.work_offline)
+                       if (prefs_common_get_prefs()->work_offline)
                                TEXTVIEW_INSERT(_("when working online,\n   or "));
                        TEXTVIEW_INSERT(_("with the following command: \n\n     "));
                        TEXTVIEW_INSERT(cmd);
@@ -144,6 +145,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                        TEXTVIEW_INSERT(":\n\n");
 
                        main_window_cursor_wait(mainwindow_get_mainwindow());
+                       textview_cursor_wait(textview);
                        GTK_EVENTS_FLUSH();
 
                        pid = fork();
@@ -151,9 +153,10 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                                res = -1;
                        } else if (pid == 0) {
                                /* son */
-                               res = system(cmd);
-                               res = WEXITSTATUS(res);
-                               _exit(res);
+                               gchar **argv;
+                               argv = strsplit_with_quote(cmd, " ", 0);
+                               res = execvp(argv[0], argv);
+                               exit(255);
                        } else {
                                int status = 0;
                                time_t start_wait = time(NULL);
@@ -165,22 +168,25 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                                                res = WEXITSTATUS(status);
                                                break;
                                        }
-                                       if (time(NULL) - start_wait > 5) {
-                                               debug_print("SIGTERM'ing gpg\n");
+                                       if (time(NULL) - start_wait > 9) {
+                                               debug_print("SIGTERM'ing gpg %d\n", pid);
                                                kill(pid, SIGTERM);
                                        }
-                                       if (time(NULL) - start_wait > 6) {
-                                               debug_print("SIGKILL'ing gpg\n");
+                                       if (time(NULL) - start_wait > 10) {
+                                               debug_print("SIGKILL'ing gpg %d\n", pid);
                                                kill(pid, SIGKILL);
                                                break;
                                        }
                                } while(1);
                        }
                        main_window_cursor_normal(mainwindow_get_mainwindow());
+                       textview_cursor_normal(textview);
+                       debug_print("res %d\n", res);
                        if (res == 0) {
                                TEXTVIEW_INSERT(_("   This key has been imported to your keyring.\n"));
                        } else {
                                TEXTVIEW_INSERT(_("   This key couldn't be imported to your keyring.\n"));
+                               TEXTVIEW_INSERT(_("   Key servers are sometimes slow.\n"));
                                TEXTVIEW_INSERT(_("   You can try to import it manually with the command:\n\n     "));
                                TEXTVIEW_INSERT(cmd);
                        }