[gvfs] http: Simplify job failure handling
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] http: Simplify job failure handling
- Date: Tue, 18 Dec 2012 13:24:04 +0000 (UTC)
commit d751f968d65fa287a8cbfa6e2a28f8dd421deb66
Author: Dan Winship <danw gnome org>
Date: Tue Dec 18 13:59:03 2012 +0100
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>
daemon/gvfsbackenddav.c | 23 +++++------------------
daemon/gvfsbackendhttp.c | 19 ++++++++-----------
daemon/gvfsbackendhttp.h | 3 +++
3 files changed, 16 insertions(+), 29 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index e5fc4c5..aa71a6d 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 1c0f370..377d4f3 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 b65e346..a380074 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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]