diff options
author | Dan Winship <danw@gnome.org> | 2012-12-18 13:59:03 +0100 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2012-12-18 14:21:55 +0100 |
commit | d751f968d65fa287a8cbfa6e2a28f8dd421deb66 (patch) | |
tree | ef8a17b06eee05534b866043ec9efa9172a3a338 /daemon | |
parent | cac808508f1fcdb3c9c00cdb36ba6053a1f5dbbb (diff) | |
download | gvfs-d751f968d65fa287a8cbfa6e2a28f8dd421deb66.tar.gz |
http: Simplify job failure handling
gvfsbackendhttp defined g_vfs_job_failed_from_http_status(), but
didn't export this, so gvfsbackenddav was sort of forced to
reimplement it. Fix that by exporting it as http_job_failed().
https://bugzilla.gnome.org/show_bug.cgi?id=687757
Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gvfsbackenddav.c | 23 | ||||
-rw-r--r-- | daemon/gvfsbackendhttp.c | 19 | ||||
-rw-r--r-- | daemon/gvfsbackendhttp.h | 3 |
3 files changed, 16 insertions, 29 deletions
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c index e5fc4c5a..aa71a6d5 100644 --- a/daemon/gvfsbackenddav.c +++ b/daemon/gvfsbackenddav.c @@ -2219,16 +2219,10 @@ try_open_stat_done (SoupSession *session, GFileType target_type; SoupURI *uri; gboolean res; - guint status; - status = msg->status_code; - - if (status != 207) + if (msg->status_code != 207) { - g_vfs_job_failed_literal (job, - G_IO_ERROR, - http_error_code_from_status (status), - msg->reason_phrase); + http_job_failed (job, msg); return; } @@ -2557,9 +2551,7 @@ do_make_directory (GVfsBackend *backend, G_IO_ERROR_EXISTS, _("Target file already exists")); else - g_vfs_job_failed_literal (G_VFS_JOB (job), G_IO_ERROR, - http_error_code_from_status (status), - msg->reason_phrase); + http_job_failed (G_VFS_JOB (job), msg); else g_vfs_job_succeeded (G_VFS_JOB (job)); @@ -2604,10 +2596,7 @@ do_delete (GVfsBackend *backend, status = g_vfs_backend_dav_send_message (backend, msg); if (!SOUP_STATUS_IS_SUCCESSFUL (status)) - g_vfs_job_failed_literal (G_VFS_JOB (job), - G_IO_ERROR, - http_error_code_from_status (status), - msg->reason_phrase); + http_job_failed (G_VFS_JOB (job), msg); else g_vfs_job_succeeded (G_VFS_JOB (job)); @@ -2668,9 +2657,7 @@ do_set_display_name (GVfsBackend *backend, G_IO_ERROR_EXISTS, _("Target file already exists")); else - g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, - http_error_code_from_status (status), - "%s", msg->reason_phrase); + http_job_failed (G_VFS_JOB (job), msg); g_object_unref (msg); g_free (dirname); diff --git a/daemon/gvfsbackendhttp.c b/daemon/gvfsbackendhttp.c index 1c0f3702..377d4f35 100644 --- a/daemon/gvfsbackendhttp.c +++ b/daemon/gvfsbackendhttp.c @@ -239,25 +239,25 @@ http_error_code_from_status (guint status) } -static void -g_vfs_job_failed_from_http_status (GVfsJob *job, guint status_code, const char *message) +void +http_job_failed (GVfsJob *job, SoupMessage *msg) { - switch (status_code) { + switch (msg->status_code) { case SOUP_STATUS_NOT_FOUND: g_vfs_job_failed_literal (job, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, - message); + msg->reason_phrase); break; case SOUP_STATUS_UNAUTHORIZED: case SOUP_STATUS_PAYMENT_REQUIRED: case SOUP_STATUS_FORBIDDEN: g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED, - _("HTTP Client Error: %s"), message); + _("HTTP Client Error: %s"), msg->reason_phrase); break; default: g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_FAILED, - _("HTTP Error: %s"), message); + _("HTTP Error: %s"), msg->reason_phrase); } } @@ -369,9 +369,7 @@ open_for_read_ready (GObject *source_object, msg = g_vfs_http_input_stream_get_message (stream); if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { - g_vfs_job_failed_from_http_status (G_VFS_JOB (job), - msg->status_code, - msg->reason_phrase); + http_job_failed (G_VFS_JOB (job), msg); g_object_unref (msg); g_object_unref (stream); return; @@ -664,8 +662,7 @@ query_info_ready (SoupSession *session, if (! SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { - g_vfs_job_failed_from_http_status (G_VFS_JOB (job), msg->status_code, - msg->reason_phrase); + http_job_failed (G_VFS_JOB (job), msg); return; } diff --git a/daemon/gvfsbackendhttp.h b/daemon/gvfsbackendhttp.h index b65e346e..a3800743 100644 --- a/daemon/gvfsbackendhttp.h +++ b/daemon/gvfsbackendhttp.h @@ -77,6 +77,9 @@ void http_backend_open_for_read (GVfsBackend *backend, GVfsJob *job, SoupURI *uri); +void http_job_failed (GVfsJob *job, + SoupMessage *msg); + G_END_DECLS #endif /* __G_VFS_BACKEND_HTTP_H__ */ |