/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail 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
#define MSGBUFSIZE 8192
static void inc_finished (MainWindow *mainwin,
- gboolean new_messages);
+ gboolean new_messages,
+ gboolean autocheck);
static gint inc_account_mail_real (MainWindow *mainwin,
PrefsAccount *account);
* messages. If @new_messages is FALSE, this function avoids unneeded
* updating.
**/
-static void inc_finished(MainWindow *mainwin, gboolean new_messages)
+static void inc_finished(MainWindow *mainwin, gboolean new_messages, gboolean autocheck)
{
- FolderItem *item;
-
if (prefs_common.scan_all_after_inc)
folderview_check_new(NULL);
- if (!new_messages && !prefs_common.scan_all_after_inc) return;
+ if (!autocheck && prefs_common.open_inbox_on_inc) {
+ FolderItem *item = NULL;
+
+ if (cur_account && cur_account->inbox)
+ item = folder_find_item_from_identifier(cur_account->inbox);
+ if (item == NULL && cur_account->folder)
+ item = cur_account->folder->inbox;
+ if (item == NULL)
+ item = folder_get_default_inbox();
- if (prefs_common.open_inbox_on_inc) {
- item = cur_account && cur_account->inbox
- ? folder_find_item_from_identifier(cur_account->inbox)
- : folder_get_default_inbox();
folderview_unselect(mainwin->folderview);
folderview_select(mainwin->folderview, item);
}
if (inc_lock_count) return;
if (prefs_common.work_offline &&
- !inc_offline_should_override(
+ !inc_offline_should_override(TRUE,
_("Claws Mail needs network access in order "
"to get mails.")))
return;
new_msgs += account_new_msgs;
}
- inc_finished(mainwin, new_msgs > 0);
+ inc_finished(mainwin, new_msgs > 0, FALSE);
main_window_unlock(mainwin);
inc_notify_cmd(new_msgs, notify);
inc_autocheck_timer_set();
if (inc_lock_count) return 0;
if (prefs_common.work_offline &&
- !inc_offline_should_override(
+ !inc_offline_should_override(TRUE,
_("Claws Mail needs network access in order "
"to get mails.")))
return 0;
new_msgs = inc_account_mail_real(mainwin, account);
- inc_finished(mainwin, new_msgs > 0);
+ inc_finished(mainwin, new_msgs > 0, FALSE);
main_window_unlock(mainwin);
inc_autocheck_timer_set();
gint account_new_msgs = 0;
if (prefs_common.work_offline &&
- !inc_offline_should_override(
+ !inc_offline_should_override( (autocheck == FALSE),
_("Claws Mail needs network access in order "
"to get mails.")))
return;
list = account_get_list();
if (!list) {
- inc_finished(mainwin, new_msgs > 0);
+ inc_finished(mainwin, new_msgs > 0, autocheck);
main_window_unlock(mainwin);
inc_notify_cmd(new_msgs, notify);
inc_autocheck_timer_set();
new_msgs += inc_start(inc_dialog);
}
- inc_finished(mainwin, new_msgs > 0);
+ inc_finished(mainwin, new_msgs > 0, autocheck);
main_window_unlock(mainwin);
inc_notify_cmd(new_msgs, notify);
inc_autocheck_timer_set();
buf = g_strdup_printf(_("Connecting to POP3 server: %s..."), server);
statusbar_print_all("%s", buf);
- log_message("%s\n", buf);
+ log_message(LOG_PROTOCOL, "%s\n", buf);
progress_dialog_set_label(inc_dialog->dialog, buf);
GTK_EVENTS_FLUSH();
server, port);
manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
} else {
- log_error(_("Can't connect to POP3 server: %s:%d\n"),
+ log_error(LOG_PROTOCOL, _("Can't connect to POP3 server: %s:%d\n"),
server, port);
}
session->inc_state = INC_CONNECT_ERROR;
if (log_msg) {
if (fatal_error)
- log_error("%s\n", log_msg);
+ log_error(LOG_PROTOCOL, "%s\n", log_msg);
else
- log_warning("%s\n", log_msg);
+ log_warning(LOG_PROTOCOL, "%s\n", log_msg);
}
if (prefs_common.no_recv_err_panel && fatal_error)
mainwindow_show_error();
session->inc_state = INC_CANCEL;
- log_message(_("Incorporation cancelled\n"));
+ log_message(LOG_PROTOCOL, _("Incorporation cancelled\n"));
}
gboolean inc_is_active(void)
if ((lockfd = lock_mbox(mbox, LOCK_FLOCK)) < 0)
return -1;
- g_snprintf(tmp_mbox, sizeof(tmp_mbox), "%s%ctmpmbox.%08x",
- get_tmp_dir(), G_DIR_SEPARATOR, (gint)mbox);
+ g_snprintf(tmp_mbox, sizeof(tmp_mbox), "%s%ctmpmbox.%p",
+ get_tmp_dir(), G_DIR_SEPARATOR, mbox);
- if (copy_mbox(mbox, tmp_mbox) < 0) {
+ if (copy_mbox(lockfd, tmp_mbox) < 0) {
unlock_mbox(mbox, lockfd, LOCK_FLOCK);
return -1;
}
the common preferences */
if (prefs_common.autochk_newmail && autocheck_data
&& prefs_common.work_offline == FALSE) {
- autocheck_timer = gtk_timeout_add
+ autocheck_timer = g_timeout_add
(interval, inc_autocheck_func, autocheck_data);
debug_print("added timer = %d\n", autocheck_timer);
}
{
if (autocheck_timer) {
debug_print("removed timer = %d\n", autocheck_timer);
- gtk_timeout_remove(autocheck_timer);
+ g_source_remove(autocheck_timer);
autocheck_timer = 0;
}
}
return FALSE;
}
-gboolean inc_offline_should_override(const gchar *msg)
+gboolean inc_offline_should_override(gboolean force_ask, const gchar *msg)
{
static time_t overridden_yes = 0;
static time_t overridden_no = 0;
if (prefs_common.autochk_newmail)
length = prefs_common.autochk_itv; /* minutes */
+ if (force_ask) {
+ overridden_no = (time_t)0;
+ }
+
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 */
+ else if (time(NULL) - overridden_no < length * 60) /* seconds */
return FALSE;
- tmp = g_strdup_printf(
+ if (!force_ask)
+ tmp = g_strdup_printf(
_("%s%sYou're working offline. Override for %d minutes?"),
msg?msg:"",
msg?"\n\n":"",
length);
+ else
+ tmp = g_strdup_printf(
+ _("%s%sYou're working offline. Override?"),
+ msg?msg:"",
+ msg?"\n\n":"");
answer = alertpanel(_("Offline warning"),
tmp,
- GTK_STOCK_NO, "+" GTK_STOCK_YES, _("On_ly once"));
+ GTK_STOCK_NO, "+" GTK_STOCK_YES,
+ !force_ask? _("On_ly once"):NULL);
g_free(tmp);
if (answer == G_ALERTALTERNATE) {
overridden_yes = time(NULL);
return TRUE;
} else if (answer == G_ALERTDEFAULT) {
- overridden_no = time(NULL);
+ if (!force_ask)
+ overridden_no = time(NULL);
return FALSE;
} else {
overridden_yes = (time_t)0;