2006-03-01 [colin] 2.0.0cvs96
[claws.git] / src / inc.c
index ebbb159b425759ad49e02c1b33bde27a183a7ab6..e428ed04c82e29854ca6edc692b69b26321102ec 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -166,10 +166,10 @@ void inc_mail(MainWindow *mainwin, gboolean notify)
 
        if (inc_lock_count) return;
 
-       if (prefs_common.work_offline)
-               if (alertpanel(_("Offline warning"), 
-                              _("You're working offline. Override?"),
-                              GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
+       if (prefs_common.work_offline && 
+           !inc_offline_should_override(
+               _("Sylpheed-Claws needs network access in order "
+                 "to get mails.")))
                return;
 
        inc_lock();
@@ -271,11 +271,11 @@ gint inc_account_mail(MainWindow *mainwin, PrefsAccount *account)
 
        if (inc_lock_count) return 0;
 
-       if (prefs_common.work_offline)
-               if (alertpanel(_("Offline warning"), 
-                              _("You're working offline. Override?"),
-                              GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
-                       return 0;
+       if (prefs_common.work_offline && 
+           !inc_offline_should_override(
+               _("Sylpheed-Claws needs network access in order "
+                 "to get mails.")))
+               return 0;
 
        inc_autocheck_timer_remove();
        main_window_lock(mainwin);
@@ -297,10 +297,10 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean autocheck,
        gint new_msgs = 0;
        gint account_new_msgs = 0;
        
-       if (prefs_common.work_offline)
-               if (alertpanel(_("Offline warning"), 
-                              _("You're working offline. Override?"),
-                              GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
+       if (prefs_common.work_offline && 
+           !inc_offline_should_override(
+               _("Sylpheed-Claws needs network access in order "
+                 "to get mails.")))
                return;
 
        if (inc_lock_count) return;
@@ -641,11 +641,16 @@ static gint inc_start(IncProgressDialog *inc_dialog)
                        g_free(filename);
 
                        if (pop3_session->ac_prefs->filter_on_recv)
-                               statusbar_progress_all(cur++,total, 10);
+                               statusbar_progress_all(cur++,total, prefs_common.statusbar_update_step);
 
                        if (!pop3_session->ac_prefs->filter_on_recv || 
                            !procmsg_msginfo_filter(msginfo))
                                folder_item_move_msg(inbox, msginfo);
+               }
+               filtering_move_and_copy_msgs(msglist);
+               for(msglist_element = msglist; msglist_element != NULL; 
+                   msglist_element = msglist_element->next) {
+                       MsgInfo *msginfo = (MsgInfo *)msglist_element->data;
                        procmsg_msginfo_free(msginfo);
                }
                folder_item_update_thaw();
@@ -699,18 +704,6 @@ static gint inc_start(IncProgressDialog *inc_dialog)
 
        progress_dialog_set_label(inc_dialog->dialog, fin_msg);
 
-#if 0
-       if (error_num && !prefs_common.no_recv_err_panel) {
-               if (inc_dialog->show_dialog)
-                       manage_window_focus_in(inc_dialog->dialog->window,
-                                              NULL, NULL);
-               alertpanel_error_log(_("Some errors occurred while getting mail."));
-               if (inc_dialog->show_dialog)
-                       manage_window_focus_out(inc_dialog->dialog->window,
-                                               NULL, NULL);
-       }
-#endif
-
        while (inc_dialog->queue_list != NULL) {
                session = inc_dialog->queue_list->data;
                inc_session_destroy(session);
@@ -760,6 +753,20 @@ static IncState inc_pop3_session_do(IncSession *session)
                SESSION(pop3_session)->nonblocking =
                        pop3_session->ac_prefs->use_nonblocking_ssl;
 #else
+       if (pop3_session->ac_prefs->ssl_pop != SSL_NONE) {
+               if (alertpanel_full(_("Insecure connection"),
+                       _("This connection is configured to be secured "
+                         "using SSL, but SSL is not available in this "
+                         "build of Sylpheed-Claws. \n\n"
+                         "Do you want to continue connecting to this "
+                         "server? The communication would not be "
+                         "secure."),
+                         _("Con_tinue connecting"), 
+                         GTK_STOCK_CANCEL, NULL,
+                         FALSE, NULL, ALERT_WARNING,
+                         G_ALERTALTERNATE) != G_ALERTDEFAULT)
+                       return INC_CONNECT_ERROR;
+       }
        port = pop3_session->ac_prefs->set_popport ?
                pop3_session->ac_prefs->popport : 110;
 #endif
@@ -885,17 +892,7 @@ static void inc_progress_dialog_set_label(IncProgressDialog *inc_dialog,
                break;
        case POP3_RETR:
        case POP3_RETR_RECV:
-               break;
        case POP3_DELETE:
-#if 0
-               if (session->msg[session->cur_msg].recv_time <
-                       session->current_time) {
-                       gchar buf[MSGBUFSIZE];
-                       g_snprintf(buf, sizeof(buf), _("Deleting message %d"),
-                                  session->cur_msg);
-                       progress_dialog_set_label(dialog, buf);
-               }
-#endif
                break;
        case POP3_LOGOUT:
                progress_dialog_set_label(dialog, _("Quitting"));
@@ -1239,8 +1236,8 @@ static gint inc_spool_account(PrefsAccount *account)
        gchar *mbox;
        gint result;
 
-       if (account->inbox) {
-               inbox = folder_find_item_from_path(account->inbox);
+       if (account->local_inbox) {
+               inbox = folder_find_item_from_identifier(account->local_inbox);
                if (!inbox)
                        inbox = folder_get_default_inbox();
        } else
@@ -1418,3 +1415,46 @@ static gint inc_autocheck_func(gpointer data)
 
        return FALSE;
 }
+
+gboolean inc_offline_should_override(const gchar *msg)
+{
+       static time_t overridden_yes = 0;
+       static time_t overridden_no  = 0;
+       int length = 10; /* minutes */
+       gint answer = G_ALERTDEFAULT;
+       
+       if (prefs_common.autochk_newmail)
+               length = prefs_common.autochk_itv; /* minutes */
+
+       if (prefs_common.work_offline) {
+               gchar *tmp = NULL;
+               
+               if (time(NULL) - overridden_yes < length * 60) /* seconds */
+                        return TRUE;
+               else if (time(NULL) - overridden_no < 3) /* seconds */
+                        return FALSE;
+
+               tmp = g_strdup_printf(
+                               _("%s%sYou're working offline. Override for %d minutes?"),
+                               msg?msg:"", 
+                               msg?"\n\n":"",
+                               length);
+
+               answer = alertpanel(_("Offline warning"), 
+                              tmp,
+                              GTK_STOCK_NO, "+" GTK_STOCK_YES, _("On_ly once"));
+               g_free(tmp);
+               if (answer == G_ALERTALTERNATE) {
+                       overridden_yes = time(NULL);
+                       return TRUE;
+               } else if (answer == G_ALERTDEFAULT) {
+                       overridden_no  = time(NULL);
+                       return FALSE;
+               } else {
+                       overridden_yes = (time_t)0;
+                       overridden_no  = (time_t)0;
+                       return TRUE;
+               }
+       }
+       return TRUE;
+}