/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 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
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include <glib.h>
static gint pop3_getrange_stat_recv(Pop3Session *session, const gchar *msg)
{
if (sscanf(msg, "%d %d", &session->count, &session->total_bytes) != 2) {
- log_error(LOG_PROTOCOL, _("POP3 protocol error\n"));
+ log_error(LOG_PROTOCOL, _("POP protocol error\n"));
session->error_val = PS_PROTOCOL;
return -1;
} else {
gint last;
if (sscanf(msg, "%d", &last) == 0) {
- log_warning(LOG_PROTOCOL, _("POP3 protocol error\n"));
+ log_warning(LOG_PROTOCOL, _("POP protocol error\n"));
session->error_val = PS_PROTOCOL;
return -1;
} else {
va_end(args);
if (!g_ascii_strncasecmp(buf, "PASS ", 5))
- log_print(LOG_PROTOCOL, "POP3> PASS ********\n");
+ log_print(LOG_PROTOCOL, "POP> PASS ********\n");
else
- log_print(LOG_PROTOCOL, "POP3> %s\n", buf);
+ log_print(LOG_PROTOCOL, "POP> %s\n", buf);
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ session_send_msg(SESSION(session), buf);
}
Session *pop3_session_new(PrefsAccount *account)
cm_return_val_if_fail(account != NULL, NULL);
+ account->receive_in_progress = TRUE;
+
session = g_new0(Pop3Session, 1);
session_init(SESSION(session), account, FALSE);
SESSION(session)->recv_msg = pop3_session_recv_msg;
SESSION(session)->recv_data_finished = pop3_session_recv_data_finished;
SESSION(session)->send_data_finished = NULL;
-
+ SESSION(session)->ssl_cert_auto_accept = account->ssl_certs_auto_accept;
SESSION(session)->destroy = pop3_session_destroy;
+#ifdef USE_GNUTLS
+ if (account->set_gnutls_priority && account->gnutls_priority &&
+ strlen(account->gnutls_priority) != 0)
+ SESSION(session)->gnutls_priority = g_strdup(account->gnutls_priority);
+#endif
+
session->state = POP3_READY;
session->ac_prefs = account;
session->pop_before_smtp = FALSE;
g_free(pop3_session->user);
g_free(pop3_session->pass);
g_free(pop3_session->error_msg);
+
+ pop3_session->ac_prefs->receive_in_progress = FALSE;
}
static void pop3_get_uidl_table(PrefsAccount *ac_prefs, Pop3Session *session)
#define TRY(func) \
if (!(func)) \
{ \
- g_warning("failed to write\n"); \
+ g_warning("failed to write"); \
goto err_write; \
} \
if ((cur > prev && fwrite(prev, 1, cur - prev, fp) < 1) ||
fputc('\n', fp) == EOF) {
FILE_OP_ERROR(file, "fwrite");
- g_warning("can't write to file: %s\n", file);
+ g_warning("can't write to file: %s", file);
fclose(fp);
claws_unlink(file);
return -1;
if (prev - data < len &&
fwrite(prev, 1, len - (prev - data), fp) < 1) {
FILE_OP_ERROR(file, "fwrite");
- g_warning("can't write to file: %s\n", file);
+ g_warning("can't write to file: %s", file);
fclose(fp);
claws_unlink(file);
return -1;
if (data[len - 1] != '\r' && data[len - 1] != '\n') {
if (fputc('\n', fp) == EOF) {
FILE_OP_ERROR(file, "fputc");
- g_warning("can't write to file: %s\n", file);
+ g_warning("can't write to file: %s", file);
fclose(fp);
claws_unlink(file);
return -1;
((ac->msg_leave_time * 24 * 60 * 60) +
(ac->msg_leave_hour * 60 * 60))) {
log_message(LOG_PROTOCOL,
- _("POP3: Deleting expired message %d [%s]\n"),
+ _("POP: Deleting expired message %d [%s]\n"),
session->cur_msg, msg->uidl?msg->uidl:" ");
session->cur_total_bytes += size;
pop3_delete_send(session);
break;
log_message(LOG_PROTOCOL,
- _("POP3: Skipping message %d [%s] (%d bytes)\n"),
+ _("POP: Skipping message %d [%s] (%d bytes)\n"),
session->cur_msg, msg->uidl?msg->uidl:" ", size);
}
{
Pop3ErrorValue ok;
- log_print(LOG_PROTOCOL, "POP3< %s\n", msg);
+ log_print(LOG_PROTOCOL, "POP< %s\n", msg);
if (!strncmp(msg, "+OK", 3))
ok = PS_SUCCESS;
switch (session->state) {
#ifdef USE_GNUTLS
case POP3_STLS:
- log_error(LOG_PROTOCOL, _("couldn't start TLS session\n"));
+ log_error(LOG_PROTOCOL, _("couldn't start STARTTLS session\n"));
ok = PS_ERROR;
break;
#endif
break;
default:
- log_error(LOG_PROTOCOL, _("error occurred on POP3 session\n"));
+ log_error(LOG_PROTOCOL, _("error occurred on POP session\n"));
ok = PS_ERROR;
}
}
g_free(session->error_msg);
session->error_msg = g_strdup(msg);
- g_printerr("POP3: %s\n", msg);
+ g_printerr("POP: %s\n", msg);
} else
ok = PS_PROTOCOL;