From 4158b740c9425c1b15be951ea460e93a629cbf23 Mon Sep 17 00:00:00 2001 From: Carl-Anton Ingmarsson Date: Sat, 23 Jul 2011 22:18:42 +0200 Subject: afp: better error handling when server doesn't support anonymous login --- daemon/gvfsafpserver.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'daemon/gvfsafpserver.c') diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c index 35dc5522..acafb87e 100644 --- a/daemon/gvfsafpserver.c +++ b/daemon/gvfsafpserver.c @@ -678,7 +678,7 @@ do_login (GVfsAfpServer *afp_serv, if (!g_slist_find_custom (afp_serv->uams, AFP_UAM_NO_USER, g_str_equal)) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED, + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("AFP server %s doesn't support anonymous login"), afp_serv->server_name); return FALSE; @@ -703,19 +703,23 @@ do_login (GVfsAfpServer *afp_serv, if (res_code != AFP_RESULT_NO_ERROR) { - if (res_code == AFP_RESULT_USER_NOT_AUTH) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED, - _("AFP server %s declined anonymous login"), - afp_serv->server_name); - return FALSE; - } - else + switch (res_code) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - _("Anonymous login to AFP server %s failed"), afp_serv->server_name); - return FALSE; + case AFP_RESULT_USER_NOT_AUTH: + case AFP_RESULT_BAD_UAM: + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + _("AFP server %s doesn't support anonymous login"), + afp_serv->server_name); + break; + + default: + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + _("Anonymous login to AFP server %s failed, got error code: %d"), + afp_serv->server_name, res_code); + break; } + + return FALSE; } return TRUE; -- cgit v1.2.1