2006-10-09 [colin] 2.5.3cvs27
authorColin Leroy <colin@colino.net>
Mon, 9 Oct 2006 17:32:48 +0000 (17:32 +0000)
committerColin Leroy <colin@colino.net>
Mon, 9 Oct 2006 17:32:48 +0000 (17:32 +0000)
* src/main.c
* src/prefs_gtk.c
Prepare cache a bit later
If section already exists, skip the new one
(as previously); avoid writing the same block
twice - if we find a second block with the
same id, skip it.
* src/plugins/pgpcore/pgp_viewer.c
Set cursor to busy when retrieving a key
* src/plugins/pgpcore/sgpgme.c
allow 5 seconds for gpg to export the key

ChangeLog
PATCHSETS
configure.ac
src/main.c
src/plugins/pgpcore/pgp_viewer.c
src/plugins/pgpcore/sgpgme.c
src/prefs_gtk.c

index e4d7723101c65042e538a849e141b17599c6b7e7..46996fedf26305017628dbd4e7d9b1d6d6ffb5d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-10-09 [colin]     2.5.3cvs27
+
+       * src/main.c
+       * src/prefs_gtk.c
+               Prepare cache a bit later
+               If section already exists, skip the new one 
+               (as previously); avoid writing the same block
+               twice - if we find a second block with the 
+               same id, skip it.
+       * src/plugins/pgpcore/pgp_viewer.c
+               Set cursor to busy when retrieving a key
+       * src/plugins/pgpcore/sgpgme.c
+               allow 5 seconds for gpg to export the key
+               
+
 2006-10-09 [colin]     2.5.3cvs26
 
        * configure.ac
index 05ae4c623310f4183a3fc2f90807e905884fc3c0..38a152e9e5f8b1190adad5e471e16c3a4f1e6cfd 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.2.2.21 -r 1.2.2.22 po/sk.po;  ) > 2.5.3cvs24.patchset
 ( cvs diff -u -r 1.1.2.26 -r 1.1.2.27 src/prefs_summaries.c;  ) > 2.5.3cvs25.patchset
 ( cvs diff -u -r 1.654.2.2031 -r 1.654.2.2032 configure.ac;  cvs diff -u -r 1.16.2.45 -r 1.16.2.46 src/msgcache.c;  cvs diff -u -r 1.10.2.23 -r 1.10.2.24 src/prefs_gtk.c;  ) > 2.5.3cvs26.patchset
+( cvs diff -u -r 1.115.2.109 -r 1.115.2.110 src/main.c;  cvs diff -u -r 1.10.2.24 -r 1.10.2.25 src/prefs_gtk.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/pgpcore/pgp_viewer.c;  cvs diff -u -r 1.1.2.29 -r 1.1.2.30 src/plugins/pgpcore/sgpgme.c;  ) > 2.5.3cvs27.patchset
index 700835b46cec047f65cc76bea81393ce8677a100..936cb06ff7ec461817de255897f5401606158073 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=26
+EXTRA_VERSION=27
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index c7e6fd83ec8e69a459f6e0915c0de8ef3cdf13ab..007c40508af123372589ec4d9b434a8b07059240 100644 (file)
@@ -470,11 +470,11 @@ int main(int argc, char *argv[])
        gint num_folder_class = 0;
        START_TIMING("startup");
        
-       prefs_prepare_cache();
        if (!sylpheed_init(&argc, &argv)) {
                return 0;
        }
 
+       prefs_prepare_cache();
        prog_version = PROG_VERSION;
        argv0 = g_strdup(argv[0]);
 
@@ -646,7 +646,7 @@ int main(int argc, char *argv[])
        mh_gtk_init();
        imap_gtk_init();
        news_gtk_init();
-               
+
        mainwin = main_window_create
                (prefs_common.sep_folder | prefs_common.sep_msg << 1);
        manage_window_focus_in(mainwin->window, NULL, NULL);
index eb5f1167aaf0c8cb9d29384fa109accabcb742f0..6473e58857b8860a3c3de0626520779047c23503 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "version.h"
 #include "common/sylpheed.h"
+#include "mainwindow.h"
 #include "mimeview.h"
 #include "textview.h"
 #include "sgpgme.h"
@@ -122,6 +123,8 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                        gchar *cmd = g_strdup_printf("gpg --recv-keys %s", sig->fpr);
                        int res = 0;
                        pid_t pid = 0;
+
+                       main_window_cursor_wait(mainwindow_get_mainwindow());
                        GTK_EVENTS_FLUSH();
                        
                        pid = fork();
@@ -153,6 +156,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                                        }
                                } while(1);
                        }
+                       main_window_cursor_normal(mainwindow_get_mainwindow());
                        if (res == 0) {
                                TEXTVIEW_INSERT(_("   This key has been imported to your keyring.\n"));
                        } else {
index 50065751cd1c1a23659ad81e2ef9740a9d110237..70d0adbeb61cea4054cd96a420b2a69ecbfe2662 100644 (file)
@@ -30,6 +30,8 @@
 #include <glib/gi18n.h>
 #include <stdio.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #ifndef G_OS_WIN32
 #include <sys/mman.h>
 #endif
@@ -710,8 +712,36 @@ again:
 #ifndef G_OS_WIN32
                        gchar *cmd = g_strdup_printf("gpg --send-keys %s", key->fpr);
                        int res = 0;
-                       GTK_EVENTS_FLUSH();
-                       res = system(cmd);
+                       pid_t pid = 0;
+                       pid = fork();
+                       if (pid == -1) {
+                               res = -1;
+                       } else if (pid == 0) {
+                               /* son */
+                               res = system(cmd);
+                               _exit(res);
+                       } else {
+                               int status = 0;
+                               time_t start_wait = time(NULL);
+                               res = -1;
+                               do {
+                                       if (waitpid(pid, &status, WNOHANG) == 0 || !WIFEXITED(status)) {
+                                               usleep(200000);
+                                       } else {
+                                               res = WEXITSTATUS(status);
+                                               break;
+                                       }
+                                       if (time(NULL) - start_wait > 5) {
+                                               debug_print("SIGTERM'ing gpg\n");
+                                               kill(pid, SIGTERM);
+                                       }
+                                       if (time(NULL) - start_wait > 6) {
+                                               debug_print("SIGKILL'ing gpg\n");
+                                               kill(pid, SIGKILL);
+                                               break;
+                                       }
+                               } while(1);
+                       }
                        if (res == 0) {
                                alertpanel_notice(_("Key exported."));
                        } else {
index d53601b262c771129e6c56cbb633206a26bf6905..7c569a1eaa6db2a94a43ab3b0a905690f82fa770 100644 (file)
@@ -289,13 +289,12 @@ void prefs_write_config(PrefParam *param, const gchar *label,
        }
 
        TRY(fprintf(pfile->fp, "%s\n", block_label) > 0);
-       g_free(block_label);
-       block_label = NULL;
 
        /* write all param data to file */
        TRY(prefs_write_param(param, pfile->fp) == 0);
 
        if (block_matched) {
+               gboolean in_dup_block = FALSE;
                while (fgets(buf, sizeof(buf), orig_fp) != NULL) {
                        /* next block */
                        if (buf[0] == '[') {
@@ -304,10 +303,22 @@ void prefs_write_config(PrefParam *param, const gchar *label,
                                break;
                        }
                }
-               while (fgets(buf, sizeof(buf), orig_fp) != NULL)
-                       TRY(fputs(buf, pfile->fp) != EOF);
+               while (fgets(buf, sizeof(buf), orig_fp) != NULL) {
+                       if (buf[0] == '[') {
+                               if (!strncmp(buf, block_label,
+                                               strlen(block_label)))
+                                       in_dup_block = TRUE;
+                               else
+                                       in_dup_block = FALSE;
+                       }
+                       if (!in_dup_block)
+                               TRY(fputs(buf, pfile->fp) != EOF);
+               }
        }
 
+       g_free(block_label);
+       block_label = NULL;
+
        if (orig_fp) fclose(orig_fp);
        if (prefs_file_close(pfile) < 0)
                g_warning("failed to write configuration to file\n");
@@ -946,16 +957,23 @@ static int prefs_cache_sections(GHashTable *file_cache, const gchar *rcfile)
 
                        if (strrchr(blockname, ']'))
                                *strrchr(blockname, ']') = '\0';
-                       debug_print("new section '%s'\n", blockname);
-                       section_cache = g_hash_table_new_full(g_str_hash, g_str_equal,
+
+                       if ((section_cache = g_hash_table_lookup(file_cache, blockname)) == NULL) {
+                               debug_print("new section '%s'\n", blockname);
+                               section_cache = g_hash_table_new_full(g_str_hash, g_str_equal,
                                                g_free, NULL);
-                       g_hash_table_insert(file_cache, 
-                               blockname, section_cache);
+                               g_hash_table_insert(file_cache, 
+                                       blockname, section_cache);
+                       } else {
+                               debug_print("section '%s' already done\n", blockname);
+                               g_free(blockname);
+                               section_cache = NULL;
+                               continue;
+                       }
                } else {
                        if (!section_cache) {
-                               debug_print("no table at %s\n", buf);
-                               fclose(fp);
-                               return -1;
+                               debug_print("skipping stuff %s with no section\n", buf);
+                               continue;
                        } else {
                                gchar *pref;
                                
@@ -965,7 +983,7 @@ static int prefs_cache_sections(GHashTable *file_cache, const gchar *rcfile)
                                }
                                pref = g_strdup(buf);
                                
-                               debug_print("new pref '%s'\n", pref);
+                               //debug_print("new pref '%s'\n", pref);
                                g_hash_table_insert(section_cache, pref, GINT_TO_POINTER(1));
                        }
                }
@@ -1043,13 +1061,13 @@ static gboolean prefs_read_config_from_cache(PrefParam *param, const gchar *labe
        sections_table = g_hash_table_lookup(whole_cache, rcfile);
        
        if (sections_table == NULL) {
-               g_warning("can't find %s in the whole cache", rcfile);
+               g_warning("can't find %s in the whole cache\n", rcfile);
                return FALSE;
        }
        values_table = g_hash_table_lookup(sections_table, label);
        
        if (values_table == NULL) {
-               debug_print("no '%s' section in '%s' cache", label, rcfile);
+               debug_print("no '%s' section in '%s' cache\n", label, rcfile);
                return TRUE;
        }
        g_hash_table_foreach(values_table, prefs_parse_cache, param);