- HTTP: Support g_file_input_stream_query_info()

- HTTP: Use libsoup header parsing function
- Set correct MIME type for MTP music players
This commit is contained in:
Tomas Bzatek 2009-10-16 12:26:34 +00:00
parent ec003f6253
commit 3134cdcf0c
7 changed files with 327 additions and 19 deletions

View File

@ -1,6 +1,6 @@
From a0c8d67cfea614c8c920af7c4ce2d90e4ce7256f Mon Sep 17 00:00:00 2001 From 37a559fdaf0b5cb880acd3718ed134fa7c48884d Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com> From: Tomas Bzatek <tbzatek@redhat.com>
Date: Fri, 2 Oct 2009 15:05:44 +0200 Date: Tue, 13 Oct 2009 17:11:23 +0200
Subject: [PATCH 1/3] Disallow mounting empty drives Subject: [PATCH 1/3] Disallow mounting empty drives
This concerns only removable media drives without any detected volumes. This concerns only removable media drives without any detected volumes.
@ -8,13 +8,13 @@ The end result is no Mount item in Nautilus popup menu and no action taken
on double-click over the drive icon. on double-click over the drive icon.
The exception is floppy drives, where we always allow mount without need The exception is floppy drives, where we always allow mount without need
to detecting media manually first. of detecting media manually first.
--- ---
daemon/gvfsbackendcomputer.c | 2 +- daemon/gvfsbackendcomputer.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-) 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemon/gvfsbackendcomputer.c b/daemon/gvfsbackendcomputer.c diff --git a/daemon/gvfsbackendcomputer.c b/daemon/gvfsbackendcomputer.c
index 4f4b9ca..59eadba 100644 index 4f4b9ca..7c6000c 100644
--- a/daemon/gvfsbackendcomputer.c --- a/daemon/gvfsbackendcomputer.c
+++ b/daemon/gvfsbackendcomputer.c +++ b/daemon/gvfsbackendcomputer.c
@@ -473,7 +473,7 @@ recompute_files (GVfsBackendComputer *backend) @@ -473,7 +473,7 @@ recompute_files (GVfsBackendComputer *backend)

View File

@ -1,23 +1,24 @@
From bef30fdc1cb0986326eac9acd7b5125cd8f4b61c Mon Sep 17 00:00:00 2001 From 441c8a2daa493228b0a0466006f784c63a31a01e Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com> From: Tomas Bzatek <tbzatek@redhat.com>
Date: Fri, 2 Oct 2009 15:21:51 +0200 Date: Tue, 13 Oct 2009 17:12:33 +0200
Subject: [PATCH 2/3] Disallow ejecting empty drives Subject: [PATCH 2/3] Disallow ejecting empty drives
Similar to previous commit, hide the Eject menu item when drive has no media. Similar to previous commit, hide the Eject menu item when drive has no media.
--- ---
monitor/gdu/ggdudrive.c | 3 ++- monitor/gdu/ggdudrive.c | 4 +++-
1 files changed, 2 insertions(+), 1 deletions(-) 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c
index b99ef6e..3509382 100644 index 20f8940..79c6809 100644
--- a/monitor/gdu/ggdudrive.c --- a/monitor/gdu/ggdudrive.c
+++ b/monitor/gdu/ggdudrive.c +++ b/monitor/gdu/ggdudrive.c
@@ -188,7 +188,8 @@ update_drive (GGduDrive *drive) @@ -188,7 +188,9 @@ update_drive (GGduDrive *drive)
* *
* See also below where we e.g. set can_eject to TRUE for non-removable drives. * See also below where we e.g. set can_eject to TRUE for non-removable drives.
*/ */
- drive->can_eject = gdu_device_drive_get_is_media_ejectable (device) || gdu_device_drive_get_requires_eject (device) || gdu_device_is_removable (device); - drive->can_eject = gdu_device_drive_get_is_media_ejectable (device) || gdu_device_drive_get_requires_eject (device) || gdu_device_is_removable (device);
+ drive->can_eject = ((gdu_device_drive_get_is_media_ejectable (device) || gdu_device_is_removable (device)) && gdu_device_is_media_available (device)) || + drive->can_eject = ((gdu_device_drive_get_is_media_ejectable (device) || gdu_device_is_removable (device)) &&
+ gdu_device_is_media_available (device) && ! _is_pc_floppy_drive (device)) ||
+ gdu_device_drive_get_requires_eject (device); + gdu_device_drive_get_requires_eject (device);
drive->is_media_check_automatic = gdu_device_is_media_change_detected (device); drive->is_media_check_automatic = gdu_device_is_media_change_detected (device);
drive->can_poll_for_media = gdu_device_is_removable (device); drive->can_poll_for_media = gdu_device_is_removable (device);

View File

@ -1,6 +1,6 @@
From 6d7f1a8a842376be8f72cc1fc90fc3101e9752a3 Mon Sep 17 00:00:00 2001 From becda6e9e9f8edb0042c0ca4844228ccfc907a7b Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com> From: Tomas Bzatek <tbzatek@redhat.com>
Date: Fri, 2 Oct 2009 15:35:41 +0200 Date: Tue, 13 Oct 2009 17:13:02 +0200
Subject: [PATCH 3/3] Silently drop eject error messages when detaching drive Subject: [PATCH 3/3] Silently drop eject error messages when detaching drive
If there's no media in drive and yet it's marked as detachable, If there's no media in drive and yet it's marked as detachable,
@ -11,10 +11,10 @@ This is the case with my USB SD card reader.
1 files changed, 13 insertions(+), 2 deletions(-) 1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c
index 3509382..eb70d75 100644 index 79c6809..309e18c 100644
--- a/monitor/gdu/ggdudrive.c --- a/monitor/gdu/ggdudrive.c
+++ b/monitor/gdu/ggdudrive.c +++ b/monitor/gdu/ggdudrive.c
@@ -648,6 +648,18 @@ eject_cb (GduDevice *device, @@ -641,6 +641,18 @@ eject_cb (GduDevice *device,
{ {
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data); GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
GGduDrive *drive; GGduDrive *drive;
@ -33,7 +33,7 @@ index 3509382..eb70d75 100644
if (error != NULL) if (error != NULL)
{ {
@@ -658,8 +670,7 @@ eject_cb (GduDevice *device, @@ -651,8 +663,7 @@ eject_cb (GduDevice *device,
goto out; goto out;
} }

View File

@ -0,0 +1,85 @@
From 67069c464a2cb827a2afe2b7886e79707c7149e2 Mon Sep 17 00:00:00 2001
From: Christian Kellner <gicmo@gnome.org>
Date: Fri, 16 Oct 2009 10:34:02 +0000
Subject: [HTTP] Use soup's (2.26) header parsing function
Libsoup has (since 2.26) specific functions for parsing various
well-known http headers, including Content-Type and Content-Length.
Bump the soup requirement accordingly. Based on a patch rom Robert
Ancell <robert.ancell@gmail.com>
---
diff --git a/configure.ac b/configure.ac
index a2c9932..5069d73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,7 +121,7 @@ HTTP_CFLAGS=
HTTP_LIBS=
if test "x$enable_http" != "xno"; then
- PKG_CHECK_EXISTS(libsoup-gnome-2.4 >= 2.25.1, msg_http=yes)
+ PKG_CHECK_EXISTS(libsoup-gnome-2.4 >= 2.26.0, msg_http=yes)
if test "x$msg_http" = "xyes"; then
PKG_CHECK_MODULES(HTTP, libsoup-gnome-2.4 libxml-2.0)
diff --git a/daemon/gvfsbackendhttp.c b/daemon/gvfsbackendhttp.c
index 23d1f97..ee531d1 100644
--- a/daemon/gvfsbackendhttp.c
+++ b/daemon/gvfsbackendhttp.c
@@ -549,40 +549,24 @@ file_info_from_message (SoupMessage *msg,
if (basename != NULL &&
g_file_attribute_matcher_matches (matcher,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
- {
- ed_name = gvfs_file_info_populate_names_as_local (info, basename);
- }
+ ed_name = gvfs_file_info_populate_names_as_local (info, basename);
if (ed_name != NULL &&
g_file_attribute_matcher_matches (matcher,
G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME))
- {
- g_file_info_set_edit_name (info, ed_name);
- }
+ g_file_info_set_edit_name (info, ed_name);
g_free (basename);
g_free (ed_name);
- text = soup_message_headers_get (msg->response_headers,
- "Content-Length");
- if (text)
- {
- guint64 size = g_ascii_strtoull (text, NULL, 10);
- g_file_info_set_size (info, size);
- }
-
+ if (soup_message_headers_get_encoding(msg->response_headers) == SOUP_ENCODING_CONTENT_LENGTH)
+ g_file_info_set_size (info, soup_message_headers_get_content_length (msg->response_headers));
- text = soup_message_headers_get (msg->response_headers,
- "Content-Type");
+ text = soup_message_headers_get_content_type (msg->response_headers, NULL);
if (text)
{
- char *p = strchr (text, ';');
- char *tmp = NULL;
GIcon *icon;
- if (p != NULL)
- text = tmp = g_strndup (text, p - text);
-
g_file_info_set_file_type (info, G_FILE_TYPE_REGULAR);
g_file_info_set_content_type (info, text);
g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, text);
@@ -590,9 +574,6 @@ file_info_from_message (SoupMessage *msg,
icon = g_content_type_get_icon (text);
g_file_info_set_icon (info, icon);
g_object_unref (icon);
-
- g_free (tmp);
-
}
--
cgit v0.8.2

View File

@ -0,0 +1,157 @@
From 47a6cb95996df5538bab4b9b07cdd8f944c0b24b Mon Sep 17 00:00:00 2001
From: Christian Kellner <gicmo@gnome.org>
Date: Fri, 16 Oct 2009 10:18:17 +0000
Subject: [HTTP] Support g_file_input_stream_query_info()
Fixes bug 598505. Based on a patch from Robert Ancell.
---
diff --git a/daemon/gvfsbackendhttp.c b/daemon/gvfsbackendhttp.c
index 97c6ce7..23d1f97 100644
--- a/daemon/gvfsbackendhttp.c
+++ b/daemon/gvfsbackendhttp.c
@@ -529,30 +529,15 @@ try_close_read (GVfsBackend *backend,
/* *** query_info () *** */
-static void
-query_info_ready (SoupSession *session,
- SoupMessage *msg,
- gpointer user_data)
+static void
+file_info_from_message (SoupMessage *msg,
+ GFileInfo *info,
+ GFileAttributeMatcher *matcher)
{
- GFileAttributeMatcher *matcher;
- GVfsJobQueryInfo *job;
- const SoupURI *uri;
- const char *text;
- GFileInfo *info;
- char *basename;
- char *ed_name;
-
- job = G_VFS_JOB_QUERY_INFO (user_data);
- info = job->file_info;
- matcher = job->attribute_matcher;
- ed_name = NULL;
-
- 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);
- return;
- }
+ const SoupURI *uri;
+ const char *text;
+ char *basename;
+ char *ed_name = NULL;
uri = soup_message_get_uri (msg);
basename = http_uri_get_basename (uri->path);
@@ -636,7 +621,29 @@ query_info_ready (SoupSession *session,
G_FILE_ATTRIBUTE_ETAG_VALUE,
text);
}
+}
+
+static void
+query_info_ready (SoupSession *session,
+ SoupMessage *msg,
+ gpointer user_data)
+{
+ GFileAttributeMatcher *matcher;
+ GVfsJobQueryInfo *job;
+ GFileInfo *info;
+
+ job = G_VFS_JOB_QUERY_INFO (user_data);
+ info = job->file_info;
+ matcher = job->attribute_matcher;
+
+ 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);
+ return;
+ }
+ file_info_from_message (msg, info, matcher);
g_vfs_job_succeeded (G_VFS_JOB (job));
}
@@ -663,6 +670,24 @@ try_query_info (GVfsBackend *backend,
}
+static gboolean
+try_query_info_on_read (GVfsBackend *backend,
+ GVfsJobQueryInfoRead *job,
+ GVfsBackendHandle handle,
+ GFileInfo *info,
+ GFileAttributeMatcher *attribute_matcher)
+{
+ SoupMessage *msg = soup_input_stream_get_message (G_INPUT_STREAM (handle));
+
+ file_info_from_message (msg, info, attribute_matcher);
+ g_object_unref (msg);
+
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+
+ return TRUE;
+}
+
+
static void
g_vfs_backend_http_class_init (GVfsBackendHttpClass *klass)
{
@@ -673,11 +698,11 @@ g_vfs_backend_http_class_init (GVfsBackendHttpClass *klass)
backend_class = G_VFS_BACKEND_CLASS (klass);
- backend_class->try_mount = try_mount;
- backend_class->try_open_for_read = try_open_for_read;
- backend_class->try_read = try_read;
- backend_class->try_seek_on_read = try_seek_on_read;
- backend_class->try_close_read = try_close_read;
- backend_class->try_query_info = try_query_info;
-
+ backend_class->try_mount = try_mount;
+ backend_class->try_open_for_read = try_open_for_read;
+ backend_class->try_read = try_read;
+ backend_class->try_seek_on_read = try_seek_on_read;
+ backend_class->try_close_read = try_close_read;
+ backend_class->try_query_info = try_query_info;
+ backend_class->try_query_info_on_read = try_query_info_on_read;
}
diff --git a/daemon/soup-input-stream.c b/daemon/soup-input-stream.c
index facce17..e1928af 100644
--- a/daemon/soup-input-stream.c
+++ b/daemon/soup-input-stream.c
@@ -912,6 +912,13 @@ soup_input_stream_truncate (GSeekable *seekable,
return FALSE;
}
+SoupMessage *
+soup_input_stream_get_message (GInputStream *stream)
+{
+ SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream);
+ return priv->msg ? g_object_ref (priv->msg) : NULL;
+}
+
GQuark
soup_http_error_quark (void)
{
diff --git a/daemon/soup-input-stream.h b/daemon/soup-input-stream.h
index dd2c540..f425291 100644
--- a/daemon/soup-input-stream.h
+++ b/daemon/soup-input-stream.h
@@ -70,6 +70,8 @@ gboolean soup_input_stream_send_finish (GInputStream *stream,
GAsyncResult *result,
GError **error);
+SoupMessage *soup_input_stream_get_message (GInputStream *stream);
+
#define SOUP_HTTP_ERROR soup_http_error_quark()
GQuark soup_http_error_quark (void);
--
cgit v0.8.2

View File

@ -0,0 +1,53 @@
From a8cfac72e68eca250799065c59e3722fc88c5b87 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Mon, 12 Oct 2009 14:31:58 +0000
Subject: Bug 597585 2.28 lists mtp devices as being cameras with gudev backend
Set correct MIME type for MTP music players based on whether it's a camera or a
music player.
Signed-off-by: David Zeuthen <davidz@redhat.com>
---
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index 3edd26f..45d030a 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -740,7 +740,9 @@ setup_for_device (GVfsBackendGphoto2 *gphoto2_backend)
{
gchar *devname;
char *comma;
+ gboolean is_media_player = FALSE;
char *camera_x_content_types[] = {"x-content/image-dcf", NULL};
+ char *media_player_x_content_types[] = {"x-content/audio-player", NULL};
/* turn usb:001,041 string into an udev device name */
if (!g_str_has_prefix (gphoto2_backend->gphoto2_port, "usb:"))
@@ -763,16 +765,25 @@ setup_for_device (GVfsBackendGphoto2 *gphoto2_backend)
/* determine icon name */
if (g_udev_device_has_property (gphoto2_backend->udev_device, "ID_MEDIA_PLAYER_ICON_NAME"))
+ {
gphoto2_backend->icon_name = g_strdup (g_udev_device_get_property (gphoto2_backend->udev_device, "ID_MEDIA_PLAYER_ICON_NAME"));
+ is_media_player = TRUE;
+ }
else if (g_udev_device_has_property (gphoto2_backend->udev_device, "ID_MEDIA_PLAYER"))
+ {
gphoto2_backend->icon_name = g_strdup ("multimedia-player");
+ is_media_player = TRUE;
+ }
else
gphoto2_backend->icon_name = g_strdup ("camera-photo");
}
else
DEBUG ("-> did not find matching udev device");
- g_vfs_backend_set_x_content_types (G_VFS_BACKEND (gphoto2_backend), camera_x_content_types);
+ if (is_media_player)
+ g_vfs_backend_set_x_content_types (G_VFS_BACKEND (gphoto2_backend), media_player_x_content_types);
+ else
+ g_vfs_backend_set_x_content_types (G_VFS_BACKEND (gphoto2_backend), camera_x_content_types);
}
static void
--
cgit v0.8.2

View File

@ -1,7 +1,7 @@
Summary: Backends for the gio framework in GLib Summary: Backends for the gio framework in GLib
Name: gvfs Name: gvfs
Version: 1.4.0 Version: 1.4.0
Release: 6%{?dist} Release: 7%{?dist}
License: LGPLv2+ License: LGPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
URL: http://www.gtk.org URL: http://www.gtk.org
@ -55,6 +55,10 @@ Patch9: 0002-Disallow-ejecting-empty-drives.patch
Patch10: 0003-Silently-drop-eject-error-messages-when-detaching-dr.patch Patch10: 0003-Silently-drop-eject-error-messages-when-detaching-dr.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=528181 # https://bugzilla.redhat.com/show_bug.cgi?id=528181
Patch11: obex-crasher.patch Patch11: obex-crasher.patch
# from upstream
Patch12: gvfs-1.4.1-http-suport-stream-query-info.patch
Patch13: gvfs-1.4.1-http-soup-header-parsing.patch
Patch14: gvfs-1.4.1-mtp-devices-mime.patch
%description %description
The gvfs package provides backend implementations for the gio The gvfs package provides backend implementations for the gio
@ -158,6 +162,9 @@ and iPod Touches to applications using gvfs.
%patch9 -p1 -b .eject-empty %patch9 -p1 -b .eject-empty
%patch10 -p1 -b .error-detaching %patch10 -p1 -b .error-detaching
%patch11 -p1 -b .push-fail %patch11 -p1 -b .push-fail
%patch12 -p1 -b .http-query-info
%patch13 -p1 -b .http-headers
%patch14 -p1 -b .mtp-mime
%build %build
@ -311,6 +318,11 @@ update-desktop-database &> /dev/null ||:
%{_datadir}/gvfs/remote-volume-monitors/afc.monitor %{_datadir}/gvfs/remote-volume-monitors/afc.monitor
%changelog %changelog
* Fri Oct 16 2009 Tomas Bzatek <tbzatek@redhat.com> - 1.4.0-7
- HTTP: Support g_file_input_stream_query_info()
- HTTP: Use libsoup header parsing function
- Set correct MIME type for MTP music players
* Wed Oct 14 2009 Bastien Nocera <bnocera@redhat.com> 1.4.0-6 * Wed Oct 14 2009 Bastien Nocera <bnocera@redhat.com> 1.4.0-6
- Fix crasher in ObexFTP (#528181) - Fix crasher in ObexFTP (#528181)
- Don't always overwrite on trash restore - Don't always overwrite on trash restore