/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
#include <glib.h>
#include <glib/gi18n.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkwindow.h>
+#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
g_return_val_if_fail(command != NULL, -1);
g_return_val_if_fail(fp != NULL, -1);
- log_message(_("Sending message using command: %s\n"), command);
+ log_message(LOG_PROTOCOL, _("Sending message using command: %s\n"), command);
argv = strsplit_with_quote(command, " ", 0);
&pid, &child_stdin, NULL, NULL,
NULL) == FALSE) {
g_snprintf(buf, sizeof(buf),
- _("Can't execute command: %s"), command);
- log_warning("%s\n", buf);
+ _("Couldn't execute command: %s"), command);
+ log_warning(LOG_PROTOCOL, "%s\n", buf);
alertpanel_error("%s", buf);
g_strfreev(argv);
return -1;
g_snprintf(buf, sizeof(buf),
_("Error occurred while executing command: %s"),
command);
- log_warning("%s\n", buf);
+ log_warning(LOG_PROTOCOL, "%s\n", buf);
alertpanel_error("%s", buf);
return -1;
}
if (!ac_prefs->session) {
/* we can't reuse a previously initialised session */
- session = smtp_session_new();
+ session = smtp_session_new(ac_prefs);
smtp_session = SMTP_SESSION(session);
if (ac_prefs->set_domain && ac_prefs->domain && strlen(ac_prefs->domain)) {
if (ac_prefs->smtp_passwd)
smtp_session->pass =
g_strdup(ac_prefs->smtp_passwd);
- else if (ac_prefs->tmp_smtp_pass)
- smtp_session->pass =
- g_strdup(ac_prefs->tmp_smtp_pass);
else {
smtp_session->pass =
- input_dialog_query_password
+ input_dialog_query_password_keep
(ac_prefs->smtp_server,
- smtp_session->user);
+ smtp_session->user,
+ &(ac_prefs->session_smtp_passwd));
if (!smtp_session->pass) {
session_destroy(session);
return -1;
}
- ac_prefs->tmp_smtp_pass =
- g_strdup(smtp_session->pass);
}
} else {
smtp_session->user = g_strdup(ac_prefs->userid);
if (ac_prefs->passwd)
smtp_session->pass = g_strdup(ac_prefs->passwd);
- else if (ac_prefs->tmp_pass)
- smtp_session->pass =
- g_strdup(ac_prefs->tmp_pass);
else {
smtp_session->pass =
- input_dialog_query_password
+ input_dialog_query_password_keep
(ac_prefs->smtp_server,
- smtp_session->user);
+ smtp_session->user,
+ &(ac_prefs->session_smtp_passwd));
if (!smtp_session->pass) {
session_destroy(session);
return -1;
}
- ac_prefs->tmp_pass =
- g_strdup(smtp_session->pass);
}
}
} else {
smtp_session->pass = NULL;
}
- #if USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
port = ac_prefs->set_smtpport ? ac_prefs->smtpport :
ac_prefs->ssl_smtp == SSL_TUNNEL ? SSMTP_PORT : SMTP_PORT;
session->ssl_type = ac_prefs->ssl_smtp;
if (ac_prefs->ssl_smtp != SSL_NONE)
session->nonblocking = ac_prefs->use_nonblocking_ssl;
- #else
+#else
if (ac_prefs->ssl_smtp != 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"
+ "build of Claws Mail. \n\n"
"Do you want to continue connecting to this "
"server? The communication would not be "
"secure."),
}
}
port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT;
- #endif
+#endif
dialog = send_progress_dialog_create();
dialog->session = session;
&& (ac_prefs->protocol == A_APOP || ac_prefs->protocol == A_POP3)
&& (time(NULL) - ac_prefs->last_pop_login_time) > (60 * ac_prefs->pop_before_smtp_timeout)) {
g_snprintf(buf, sizeof(buf), _("Doing POP before SMTP..."));
- log_message(buf);
+ log_message(LOG_PROTOCOL, "%s\n", buf);
progress_dialog_set_label(dialog->dialog, buf);
progress_dialog_list_set_status(dialog->dialog, 0, _("POP before SMTP"));
GTK_EVENTS_FLUSH();
g_snprintf(buf, sizeof(buf), _("Connecting to SMTP server: %s ..."),
ac_prefs->smtp_server);
progress_dialog_set_label(dialog->dialog, buf);
- log_message("%s\n", buf);
+ log_message(LOG_PROTOCOL, "%s\n", buf);
session_set_recv_message_notify(session, send_recv_message, dialog);
session_set_send_data_progressive_notify
gtk_main_iteration();
if (SMTP_SESSION(session)->error_val == SM_AUTHFAIL) {
- if (ac_prefs->smtp_userid && ac_prefs->tmp_smtp_pass) {
- g_free(ac_prefs->tmp_smtp_pass);
- ac_prefs->tmp_smtp_pass = NULL;
- } else if (ac_prefs->tmp_pass) {
- g_free(ac_prefs->tmp_pass);
- ac_prefs->tmp_pass = NULL;
+ if (ac_prefs->session_smtp_passwd) {
+ g_free(ac_prefs->session_smtp_passwd);
+ ac_prefs->session_smtp_passwd = NULL;
}
ret = -1;
} else if (SMTP_SESSION(session)->state == SMTP_MAIL_SENT_OK) {
- log_message("%s\n", _("Mail sent successfully."));
+ log_message(LOG_PROTOCOL, "%s\n", _("Mail sent successfully."));
ret = 0;
} else if (session->state == SESSION_EOF &&
SMTP_SESSION(session)->state == SMTP_QUIT) {
/* consider EOF right after QUIT successful */
- log_warning("%s\n", _("Connection closed by the remote host."));
+ log_warning(LOG_PROTOCOL, "%s\n", _("Connection closed by the remote host."));
ret = 0;
} else if (session->state == SESSION_ERROR ||
session->state == SESSION_EOF ||
ac_prefs->session = SMTP_SESSION(session);
- statusbar_pop_all();
+ statuswindow_pop_all();
statusbar_verbosity_set(FALSE);
return ret;
}
case SMTP_HELO:
g_snprintf(buf, sizeof(buf), _("Sending HELO..."));
state_str = _("Authenticating");
- statusbar_print_all(_("Sending message..."));
+ statuswindow_print_all(_("Sending message..."));
break;
case SMTP_EHLO:
g_snprintf(buf, sizeof(buf), _("Sending EHLO..."));
state_str = _("Authenticating");
- statusbar_print_all(_("Sending message..."));
+ statuswindow_print_all(_("Sending message..."));
break;
case SMTP_AUTH:
g_snprintf(buf, sizeof(buf), _("Authenticating..."));
{
gchar buf[BUFFSIZE];
SendProgressDialog *dialog = (SendProgressDialog *)data;
-
+ MainWindow *mainwin = mainwindow_get_mainwindow();
+
g_return_val_if_fail(dialog != NULL, -1);
if (SMTP_SESSION(session)->state != SMTP_SEND_DATA &&
progress_dialog_set_fraction
(dialog->dialog, (total_len == 0) ? 0 : (gfloat)cur_len / (gfloat)total_len);
+ if (mainwin)
+ gtk_progress_bar_set_fraction
+ (GTK_PROGRESS_BAR(mainwin->progressbar),
+ (total_len == 0) ? 0 : (gfloat)cur_len / (gfloat)total_len);
+
return 0;
}
static gint send_send_data_finished(Session *session, guint len, gpointer data)
{
SendProgressDialog *dialog = (SendProgressDialog *)data;
+ MainWindow *mainwin = mainwindow_get_mainwindow();
g_return_val_if_fail(dialog != NULL, -1);
send_send_data_progressive(session, len, len, dialog);
+ if (mainwin)
+ gtk_progress_bar_set_fraction
+ (GTK_PROGRESS_BAR(mainwin->progressbar),(gfloat)0);
+
return 0;
}
+static void send_progress_dialog_size_allocate_cb(GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ g_return_if_fail(allocation != NULL);
+
+ prefs_common.sendwin_width = allocation->width;
+ prefs_common.sendwin_height = allocation->height;
+}
+
static SendProgressDialog *send_progress_dialog_create(void)
{
SendProgressDialog *dialog;
ProgressDialog *progress;
+ static GdkGeometry geometry;
dialog = g_new0(SendProgressDialog, 1);
g_signal_connect(G_OBJECT(progress->window), "delete_event",
G_CALLBACK(gtk_true), NULL);
gtk_window_set_modal(GTK_WINDOW(progress->window), TRUE);
+ g_signal_connect(G_OBJECT(progress->window), "size_allocate",
+ G_CALLBACK(send_progress_dialog_size_allocate_cb), NULL);
manage_window_set_transient(GTK_WINDOW(progress->window));
progress_dialog_get_fraction(progress);
- if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
+ if (!geometry.min_height) {
+ geometry.min_width = 460;
+ geometry.min_height = 250;
+ }
+
+ gtk_window_set_geometry_hints(GTK_WINDOW(progress->window), NULL, &geometry,
+ GDK_HINT_MIN_SIZE);
+ gtk_widget_set_size_request(progress->window, prefs_common.sendwin_width,
+ prefs_common.sendwin_height);
+
+ if (!prefs_common.send_dialog_invisible) {
gtk_widget_show_now(progress->window);
}
static void send_progress_dialog_destroy(SendProgressDialog *dialog)
{
g_return_if_fail(dialog != NULL);
- if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
+ if (!prefs_common.send_dialog_invisible) {
progress_dialog_destroy(dialog->dialog);
}
g_free(dialog);
err_msg = g_strdup(log_msg);
break;
case SESSION_TIMEOUT:
- log_msg = _("Session timed out.");
+ log_msg = _("Session timed out. You may be able to "
+ "recover by increasing the timeout value in "
+ "Preferences/Other.");
err_msg = g_strdup(log_msg);
break;
default:
break;
}
- if (log_msg)
- log_warning("%s\n", log_msg);
if (err_msg) {
- log_error("%s", err_msg);
+ log_error(LOG_PROTOCOL, "%s\n", err_msg);
g_free(err_msg);
+ } else {
+ if (log_msg)
+ log_warning(LOG_PROTOCOL, "%s\n", log_msg);
}
}