summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2008-02-28 14:32:43 +0000
committerBastien Nocera <hadess@src.gnome.org>2008-02-28 14:32:43 +0000
commit2ada4a0786a5c1f822fd9d36d1cd4845581c3c34 (patch)
tree5f275599df9145cdc9ef0e46ea19965efd3c6cd5
parentcbad6feb80ee1d029b7bc4cecef2b2eeff19e27c (diff)
downloadgvfs-2ada4a0786a5c1f822fd9d36d1cd4845581c3c34.tar.gz
Fix the content-type of directories (inode/directory, not
2008-02-28 Bastien Nocera <hadess@hadess.net> * daemon/gvfsbackendobexftp-fl-parser.c (fl_parser_start_node_cb): Fix the content-type of directories (inode/directory, not x-directory/normal as in gnome-vfs) Set file icons from the content-type * daemon/gvfsbackendobexftp.c (_change_directory): Add a FIXME, trying to change to a non-existant directory errors out with "permission denied", which isn't the case (_query_file_info_helper): set the right content-type and icon for the root folder (is_connected), (do_mount): Wait until we're connected to exit from do_mount() (do_open_for_read): Fix a crash when opening an inexistant file for read svn path=/trunk/; revision=1423
-rw-r--r--ChangeLog20
-rw-r--r--daemon/gvfsbackendobexftp-fl-parser.c21
-rw-r--r--daemon/gvfsbackendobexftp.c43
3 files changed, 81 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index bad775f8..0941e38f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-02-28 Bastien Nocera <hadess@hadess.net>
+
+ * daemon/gvfsbackendobexftp-fl-parser.c (fl_parser_start_node_cb):
+ Fix the content-type of directories (inode/directory, not
+ x-directory/normal as in gnome-vfs)
+ Set file icons from the content-type
+
+ * daemon/gvfsbackendobexftp.c (_change_directory):
+ Add a FIXME, trying to change to a non-existant directory
+ errors out with "permission denied", which isn't the case
+
+ (_query_file_info_helper): set the right content-type and icon
+ for the root folder
+
+ (is_connected), (do_mount): Wait until we're connected to exit from
+ do_mount()
+
+ (do_open_for_read): Fix a crash when opening an inexistant file for
+ read
+
2008-02-28 Benjamin Otte <otte@gnome.org>
* daemon/gvfsbackendftp.c: (ftp_error_set_from_response),
diff --git a/daemon/gvfsbackendobexftp-fl-parser.c b/daemon/gvfsbackendobexftp-fl-parser.c
index 70415baa..ddd64099 100644
--- a/daemon/gvfsbackendobexftp-fl-parser.c
+++ b/daemon/gvfsbackendobexftp-fl-parser.c
@@ -97,8 +97,13 @@ fl_parser_start_node_cb (void *user_data,
g_file_info_set_file_type (info, G_FILE_TYPE_REGULAR);
}
else if (strcmp (node_name, "folder") == 0) {
+ GIcon *icon;
g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
- g_file_info_set_content_type (info, "x-directory/normal");
+ g_file_info_set_content_type (info, "inode/directory");
+
+ icon = g_themed_icon_new ("folder");
+ g_file_info_set_icon (info, icon);
+ g_object_unref (icon);
} else {
g_set_error (data->error,
G_MARKUP_ERROR,
@@ -122,6 +127,20 @@ fl_parser_start_node_cb (void *user_data,
g_free (mime_type);
}
+ if (g_file_info_get_content_type (info) == NULL) {
+ g_file_info_set_content_type (info, "application/octet-stream");
+ }
+
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_REGULAR) {
+ GIcon *icon;
+
+ icon = g_content_type_get_icon (g_file_info_get_content_type (info));
+ if (icon != NULL) {
+ g_file_info_set_icon (info, icon);
+ g_object_unref (icon);
+ }
+ }
+
/* Permissions on folders in OBEX has different semantics than POSIX.
* In POSIX, if a folder is not writable, it means that it's content
* can't be removed, whereas in OBEX, it just means that the folder
diff --git a/daemon/gvfsbackendobexftp.c b/daemon/gvfsbackendobexftp.c
index 62fd7e94..175e656c 100644
--- a/daemon/gvfsbackendobexftp.c
+++ b/daemon/gvfsbackendobexftp.c
@@ -208,6 +208,8 @@ _change_directory (GVfsBackendObexftp *op_backend,
G_TYPE_INVALID) == FALSE)
{
g_message ("ChangeCurrentFolderToRoot failed");
+ //FIXME change the retval from org.openobex.Error.NotAuthorized to
+ //no such file or directory
return FALSE;
}
}
@@ -252,13 +254,17 @@ _query_file_info_helper (GVfsBackend *backend,
if (strcmp (filename, "/") == 0)
{
+ GIcon *icon;
char *display;
/* That happens when you want '/'
* and we don't have any info about it :( */
g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
- g_file_info_set_content_type (info, "x-directory/normal");
+ g_file_info_set_content_type (info, "inode/directory");
g_file_info_set_name (info, "/");
+ icon = g_themed_icon_new ("bluetooth");
+ g_file_info_set_icon (info, icon);
+ g_object_unref (icon);
display = g_strdup_printf (_("%s on %s"), "/", op_backend->display_name);
g_file_info_set_display_name (info, display);
g_free (display);
@@ -379,6 +385,24 @@ closed_cb (DBusGProxy *proxy, gpointer user_data)
_exit (1);
}
+static int
+is_connected (DBusGProxy *session_proxy, GVfsJob *job)
+{
+ GError *error = NULL;
+ gboolean connected;
+
+ if (dbus_g_proxy_call (session_proxy, "IsConnected", &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &connected, G_TYPE_INVALID) == FALSE)
+ {
+ g_vfs_job_failed_from_error (job, error);
+ g_error_free (error);
+ return -1;
+ }
+
+ return connected;
+}
+
static void
do_mount (GVfsBackend *backend,
GVfsJobMount *job,
@@ -392,6 +416,7 @@ do_mount (GVfsBackend *backend,
const gchar *path = NULL;
char *server, *bdaddr;
GMountSpec *obexftp_mount_spec;
+ gboolean connected;
g_print ("+ do_mount\n");
@@ -475,6 +500,21 @@ do_mount (GVfsBackend *backend,
dbus_g_proxy_add_signal(op_backend->session_proxy, "TransferStarted",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID);
+ /* Now wait until the device is connected */
+ connected = is_connected (op_backend->session_proxy, G_VFS_JOB (job));
+ while (connected == FALSE)
+ {
+ g_usleep (G_USEC_PER_SEC / 100);
+ connected = is_connected (op_backend->session_proxy, G_VFS_JOB (job));
+ }
+
+ if (connected < 0)
+ {
+ //FIXME bail out
+ g_message ("mount failed");
+ return;
+ }
+
g_free (bdaddr);
g_vfs_job_succeeded (G_VFS_JOB (job));
@@ -615,7 +655,6 @@ do_open_for_read (GVfsBackend *backend,
{
op_backend->doing_io = FALSE;
g_mutex_unlock (op_backend->mutex);
- g_free (basename);
close (fd);
g_vfs_job_failed_from_error (G_VFS_JOB (job),
op_backend->error);