/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2005 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
*
* 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
#include <stdio.h>
#include <unistd.h>
#include <string.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
#include "main.h"
#include "inc.h"
static guint inc_lock_count = 0;
-static GdkPixbuf *current_pixbuf;
-static GdkPixbuf *error_pixbuf;
-static GdkPixbuf *ok_pixbuf;
+static GdkPixbuf *currentpix;
+static GdkPixbuf *errorpix;
+static GdkPixbuf *okpix;
#define MSGBUFSIZE 8192
if (inc_lock_count) return;
- if (prefs_common.work_offline)
- if (alertpanel(_("Offline warning"),
- _("You're working offline. Override?"),
- _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+ if (prefs_common.work_offline && !inc_offline_should_override())
return;
inc_lock();
if (inc_lock_count) return 0;
- if (prefs_common.work_offline)
- if (alertpanel(_("Offline warning"),
- _("You're working offline. Override?"),
- _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
- return 0;
+ if (prefs_common.work_offline && !inc_offline_should_override())
+ return 0;
inc_autocheck_timer_remove();
main_window_lock(mainwin);
gint new_msgs = 0;
gint account_new_msgs = 0;
- if (prefs_common.work_offline)
- if (alertpanel(_("Offline warning"),
- _("You're working offline. Override?"),
- _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+ if (prefs_common.work_offline && !inc_offline_should_override())
return;
if (inc_lock_count) return;
G_CALLBACK(inc_dialog_delete_cb), dialog);
/* manage_window_set_transient(GTK_WINDOW(progress->window)); */
- progress_dialog_set_value(progress, 0.0);
+ progress_dialog_get_fraction(progress);
- stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_COMPLETE, &ok_pixbuf);
+ stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_COMPLETE,
+ &okpix);
stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_CONTINUE,
- ¤t_pixbuf);
- stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_ERROR, &error_pixbuf);
+ ¤tpix);
+ stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_ERROR,
+ &errorpix);
if (prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS ||
(prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL &&
}
dialog->dialog = progress;
- gettimeofday(&dialog->progress_tv, NULL);
- gettimeofday(&dialog->folder_tv, NULL);
+ g_get_current_time(&dialog->progress_tv);
+ g_get_current_time(&dialog->folder_tv);
dialog->queue_list = NULL;
dialog->cur_row = 0;
Pop3Session *pop3_session = POP3_SESSION(session->session);
session->data = inc_dialog;
- progress_dialog_append(inc_dialog->dialog, NULL,
- pop3_session->ac_prefs->account_name,
- _("Standby"), NULL);
+
+ progress_dialog_list_set(inc_dialog->dialog,
+ -1, NULL,
+ pop3_session->ac_prefs->account_name,
+ _("Standby"));
}
}
static void inc_progress_dialog_clear(IncProgressDialog *inc_dialog)
{
- progress_dialog_set_value(inc_dialog->dialog, 0.0);
+ progress_dialog_get_fraction(inc_dialog->dialog);
progress_dialog_set_label(inc_dialog->dialog, "");
if (inc_dialog->mainwin)
main_window_progress_off(inc_dialog->mainwin);
qlist = next;
}
-#define SET_PIXMAP_AND_TEXT(pixbuf, str) \
-{ \
- progress_dialog_set_row_pixbuf(inc_dialog->dialog, \
- inc_dialog->cur_row, pixbuf); \
- progress_dialog_set_row_status(inc_dialog->dialog, \
- inc_dialog->cur_row, str); \
+#define SET_PIXMAP_AND_TEXT(pix, str) \
+{ \
+ progress_dialog_list_set(inc_dialog->dialog, \
+ inc_dialog->cur_row, \
+ pix, \
+ NULL, \
+ str); \
}
for (; inc_dialog->queue_list != NULL && !cancelled; inc_dialog->cur_row++) {
+ int cur = 0, total = 0;
session = inc_dialog->queue_list->data;
pop3_session = POP3_SESSION(session->session);
if (pop3_session->pass == NULL) {
- SET_PIXMAP_AND_TEXT(ok_pixbuf, _("Cancelled"));
+ SET_PIXMAP_AND_TEXT(okpix, _("Cancelled"));
inc_session_destroy(session);
inc_dialog->queue_list =
g_list_remove(inc_dialog->queue_list, session);
progress_dialog_scroll_to_row(inc_dialog->dialog,
inc_dialog->cur_row);
- SET_PIXMAP_AND_TEXT(current_pixbuf, _("Retrieving"));
+ SET_PIXMAP_AND_TEXT(currentpix, _("Retrieving"));
/* begin POP3 session */
inc_state = inc_pop3_session_do(session);
to_human_readable(pop3_session->cur_total_recv_bytes));
else
msg = g_strdup_printf(_("Done (no new messages)"));
- SET_PIXMAP_AND_TEXT(ok_pixbuf, msg);
+ SET_PIXMAP_AND_TEXT(okpix, msg);
g_free(msg);
break;
case INC_CONNECT_ERROR:
- SET_PIXMAP_AND_TEXT(error_pixbuf,
- _("Connection failed"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Connection failed"));
break;
case INC_AUTH_FAILED:
- SET_PIXMAP_AND_TEXT(error_pixbuf, _("Auth failed"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Auth failed"));
break;
case INC_LOCKED:
- SET_PIXMAP_AND_TEXT(error_pixbuf, _("Locked"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Locked"));
break;
case INC_ERROR:
case INC_NO_SPACE:
case INC_IO_ERROR:
case INC_SOCKET_ERROR:
case INC_EOF:
- SET_PIXMAP_AND_TEXT(error_pixbuf, _("Error"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Error"));
break;
case INC_TIMEOUT:
- SET_PIXMAP_AND_TEXT(error_pixbuf, _("Timeout"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Timeout"));
break;
case INC_CANCEL:
- SET_PIXMAP_AND_TEXT(ok_pixbuf, _("Cancelled"));
+ SET_PIXMAP_AND_TEXT(okpix, _("Cancelled"));
if (!inc_dialog->show_dialog)
cancelled = TRUE;
break;
/* process messages */
folder_item_update_freeze();
- for(msglist_element = msglist; msglist_element != NULL; msglist_element = msglist_element->next) {
+ if (pop3_session->ac_prefs->filter_on_recv)
+ statusbar_print_all(_("Filtering messages...\n"));
+ total = g_slist_length(msglist);
+
+ for(msglist_element = msglist; msglist_element != NULL;
+ msglist_element = msglist_element->next) {
gchar *filename;
msginfo = (MsgInfo *) msglist_element->data;
filename = folder_item_fetch_msg(processing, msginfo->msgnum);
g_free(filename);
+
+ if (pop3_session->ac_prefs->filter_on_recv)
+ 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();
+
+ statusbar_progress_all(0,0,0);
+ statusbar_pop_all();
+
g_slist_free(msglist);
statusbar_pop_all();
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
progress_dialog_set_label(inc_dialog->dialog, buf);
}
- progress_dialog_set_percentage
+ progress_dialog_set_fraction
(inc_dialog->dialog,(gfloat)cur_total / (gfloat)total);
- gtk_progress_set_show_text
- (GTK_PROGRESS(inc_dialog->mainwin->progressbar), TRUE);
g_snprintf(buf, sizeof(buf), "%d / %d",
pop3_session->cur_msg, pop3_session->count);
- gtk_progress_set_format_string
- (GTK_PROGRESS(inc_dialog->mainwin->progressbar), buf);
- gtk_progress_bar_update
+ gtk_progress_bar_set_text
+ (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), buf);
+ gtk_progress_bar_set_fraction
(GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar),
(gfloat)cur_total / (gfloat)total);
pop3_session->cur_total_num,
to_human_readable
(pop3_session->cur_total_recv_bytes));
- progress_dialog_set_row_status(inc_dialog->dialog,
- inc_dialog->cur_row, buf);
+ progress_dialog_list_set_status(inc_dialog->dialog,
+ inc_dialog->cur_row,
+ buf);
}
}
static void inc_progress_dialog_update_periodic(IncProgressDialog *inc_dialog,
IncSession *inc_session)
{
- struct timeval tv_cur;
- struct timeval tv_result;
+ GTimeVal tv_cur;
+ GTimeVal tv_result;
gint msec;
- gettimeofday(&tv_cur, NULL);
+ g_get_current_time(&tv_cur);
tv_result.tv_sec = tv_cur.tv_sec - inc_dialog->progress_tv.tv_sec;
tv_result.tv_usec = tv_cur.tv_usec - inc_dialog->progress_tv.tv_usec;
if (tv_result.tv_usec < 0) {
tv_result.tv_sec--;
- tv_result.tv_usec += 1000000;
+ tv_result.tv_usec += G_USEC_PER_SEC;
}
msec = tv_result.tv_sec * 1000 + tv_result.tv_usec / 1000;
} else
inbox = folder_get_default_inbox();
if (!inbox) {
- unlink(file);
+ g_unlink(file);
return -1;
}
/* add msg file to drop folder */
if ((msgnum = folder_item_add_msg(
dropfolder, file, NULL, TRUE)) < 0) {
- unlink(file);
+ g_unlink(file);
return -1;
}
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
msgs = proc_mbox(dest, tmp_mbox, TRUE);
- unlink(tmp_mbox);
+ g_unlink(tmp_mbox);
if (msgs >= 0) empty_mbox(mbox);
unlock_mbox(mbox, lockfd, LOCK_FLOCK);
return FALSE;
}
+
+gboolean inc_offline_should_override(void)
+{
+ 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 < length * 60) /* seconds */
+ return FALSE;
+
+ tmp = g_strdup_printf(
+ _("You're working offline. Override for %d minutes?"),
+ 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;
+}