sync with sylpheed 0.6.3cvs7
[claws.git] / src / inc.c
index b86a174c7b8a83f8ebcaf272738974451a43f129..2acd948bd2c72984d26de5f94efff66122248746 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -178,30 +178,14 @@ void inc_mail(MainWindow *mainwin)
        summary_write_cache(mainwin->summaryview);
        main_window_lock(mainwin);
 
-       if (prefs_common.use_extinc && prefs_common.extinc_path) {
-               gint pid;
-
+       if (prefs_common.use_extinc && prefs_common.extinc_cmd) {
                /* external incorporating program */
-               if ((pid = fork()) < 0) {
-                       perror("fork");
+               if (execute_command_line(prefs_common.extinc_cmd, FALSE) < 0) {
                        main_window_unlock(mainwin);
                        inc_autocheck_timer_set();
                        return;
                }
 
-               if (pid == 0) {
-                       execlp(prefs_common.extinc_path,
-                              g_basename(prefs_common.extinc_path),
-                              NULL);
-
-                       /* this will be called when failed */
-                       perror("exec");
-                       _exit(1);
-               }
-
-               /* wait until child process is terminated */
-               waitpid(pid, NULL, 0);
-
                if (prefs_common.inc_local)
                        new_msgs = inc_spool();
        } else {
@@ -315,6 +299,7 @@ static IncProgressDialog *inc_progress_dialog_create(void)
                           GTK_SIGNAL_FUNC(inc_cancel), dialog);
        gtk_signal_connect(GTK_OBJECT(progress->window), "delete_event",
                           GTK_SIGNAL_FUNC(gtk_true), NULL);
+       /* manage_window_set_transient(GTK_WINDOW(progress->window)); */
 
        progress_dialog_set_value(progress, 0.0);
 
@@ -680,7 +665,8 @@ static IncState inc_pop3_session_do(IncSession *session)
                                      automaton_input_cb, atm);
 #endif
 
-       gtk_main();
+       while (!atm->terminated)
+               gtk_main_iteration();
 
        log_verbosity_set(FALSE);
        recv_set_ui_func(NULL, NULL);
@@ -695,6 +681,8 @@ static IncState inc_pop3_session_do(IncSession *session)
 
 static gint pop3_automaton_terminate(SockInfo *source, Automaton *atm)
 {
+       if (atm->terminated) return 0;
+
        if (atm->tag > 0) {
                gdk_input_remove(atm->tag);
                atm->tag = 0;
@@ -703,10 +691,8 @@ static gint pop3_automaton_terminate(SockInfo *source, Automaton *atm)
                gtk_timeout_remove(atm->timeout_tag);
                atm->timeout_tag = 0;
        }
-       if (source) {
+       if (source)
                sock_close(source);
-               gtk_main_quit();
-       }
 
        atm->terminated = TRUE;
 
@@ -798,6 +784,7 @@ static gint connection_check_cb(Automaton *atm)
                        manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
                }
                pop3_automaton_terminate(sockinfo, atm);
+               state->sockinfo = NULL;
                return FALSE;
        } else if (sockinfo->state == CONN_ESTABLISHED) {
                atm->timeout_tag = 0;
@@ -988,6 +975,8 @@ static void inc_cancel(GtkWidget *widget, gpointer data)
        IncSession *session = dialog->queue_list->data;
        SockInfo *sockinfo = session->pop3_state->sockinfo;
 
+       if (!sockinfo || session->atm->terminated == TRUE) return;
+
 #if USE_THREADS
        if (sockinfo->state == CONN_READY ||
            sockinfo->state == CONN_LOOKUPSUCCESS) {
@@ -999,6 +988,7 @@ static void inc_cancel(GtkWidget *widget, gpointer data)
 
        session->pop3_state->inc_state = INC_CANCEL;
        pop3_automaton_terminate(sockinfo, session->atm);
+       session->pop3_state->sockinfo = NULL;
 }
 
 static gint inc_spool(void)