aboutsummaryrefslogtreecommitdiff
path: root/src/rpop3.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-09-18 02:11:42 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-09-18 02:11:42 +0000
commit6c99f53cc0cec575d9ee2b954f856d2848cc126f (patch)
tree056db18786315de4c2e35998454314394f1a2324 /src/rpop3.c
parentdb6cafdaf9a350bfda9435cfc035e00d1fd4401a (diff)
remote mailbox: added timeout. Show dialog on error.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2033 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/rpop3.c')
-rw-r--r--src/rpop3.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/rpop3.c b/src/rpop3.c
index 78048fdd..d6cc2bc9 100644
--- a/src/rpop3.c
+++ b/src/rpop3.c
@@ -51,6 +51,7 @@
#include "gtkutils.h"
#include "manage_window.h"
#include "alertpanel.h"
+#include "prefs_common.h"
#define POP3_TOP (N_POP3_STATE + 1000)
#define POP3_TOP_RECV (N_POP3_STATE + 1001)
@@ -211,6 +212,8 @@ gint rpop3_account(PrefsAccount *account)
}
}
+ session_set_timeout(session, prefs_common.io_timeout_secs * 1000);
+
ret = rpop3_start(session);
while (!rpop3_window.finished)
@@ -350,18 +353,62 @@ static gint rpop3_start(Session *session)
{
g_return_val_if_fail(session != NULL, -1);
- rpop3_status_label_set(_("Connecting to %s:%d"),
+ rpop3_status_label_set(_("Connecting to %s:%d ..."),
session->server, session->port);
if (session_connect(session, session->server, session->port) < 0) {
- log_warning(_("Can't connect to POP3 server: %s:%d\n"),
- session->server, session->port);
+ manage_window_focus_in(rpop3_window.window, NULL, NULL);
+ alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
+ session->server, session->port);
return -1;
}
while (session_is_connected(session))
gtk_main_iteration();
+ switch (POP3_SESSION(session)->error_val) {
+ case PS_AUTHFAIL:
+ manage_window_focus_in(rpop3_window.window, NULL, NULL);
+ if (POP3_SESSION(session)->error_msg)
+ alertpanel_error(_("Authentication failed:\n%s"),
+ POP3_SESSION(session)->error_msg);
+ else
+ alertpanel_error(_("Authentication failed."));
+ return -1;
+ case PS_SUCCESS:
+ break;
+ default:
+ manage_window_focus_in(rpop3_window.window, NULL, NULL);
+ if (POP3_SESSION(session)->error_msg)
+ alertpanel_error
+ (_("Error occurred during POP3 session:\n%s"),
+ POP3_SESSION(session)->error_msg);
+ else
+ alertpanel_error(_("Error occurred during POP3 session."));
+ return -1;
+ }
+
+ switch (session->state) {
+ case SESSION_EOF:
+ manage_window_focus_in(rpop3_window.window, NULL, NULL);
+ alertpanel_error(_("Connection closed by the remote host."));
+ return -1;
+ case SESSION_TIMEOUT:
+ manage_window_focus_in(rpop3_window.window, NULL, NULL);
+ alertpanel_error(_("Session timed out."));
+ return -1;
+ case SESSION_ERROR:
+ manage_window_focus_in(rpop3_window.window, NULL, NULL);
+ if (POP3_SESSION(session)->state == POP3_READY)
+ alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
+ session->server, session->port);
+ else
+ alertpanel_error(_("Error occurred during POP3 session."));
+ return -1;
+ default:
+ break;
+ }
+
return 0;
}