[maemo-commits] [maemo-commits] r13778 - in projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink: . obex-module/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Sep 12 15:56:10 EEST 2007
- Previous message: [maemo-commits] r13777 - in projects/haf/trunk/gtk+: . gtk
- Next message: [maemo-commits] r13779 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll Date: 2007-09-12 15:56:08 +0300 (Wed, 12 Sep 2007) New Revision: 13778 Modified: projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/ChangeLog projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/obex-method.c projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-dbus.c projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.c projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.h Log: Do not declare the children of the virtual "obex:///" root folder to be symlinks. Instead, accept URIs of the form "obex:///[...]/..." everywhere (in addition to the old "obex://[...]/..." form). * obex-module/src/om-utils.c (utils_get_path_and_dev_from_uri, om_utils_get_path_and_dev_from_uri): Renamed former to latter and made public. Changed all callers. Handle URIs of the form "obex:///foo/bar" to be identical to "obex://foo/bar". * obex-module/src/om-dbus.c (om_append_paired_devices, append_fake_device): Declare a paired device to be a directory, not a symlink. * obex-module/src/obex-method.c (om_uri_is_virtual_obex_root): Use om_utils_get_path_and_dev_from_uri instead of gnome_vfs_uri_get_host_name. (om_uri_is_below_virtual_obex_root): Removed. (do_open, do_create, do_open_directory, do_get_file_info, do_make_directory, do_set_file_info): Do not call om_uri_is_below_virtual_obex_root, the virtual root children are no longer handled specially. Modified: projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/ChangeLog =================================================================== --- projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/ChangeLog 2007-09-12 11:24:16 UTC (rev 13777) +++ projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/ChangeLog 2007-09-12 12:56:08 UTC (rev 13778) @@ -1,3 +1,28 @@ +2007-09-12 Marius Vollmer <marius.vollmer at nokia.com> + + Do not declare the children of the virtual "obex:///" root folder + to be symlinks. Instead, accept URIs of the form + "obex:///[...]/..." everywhere (in addition to the old + "obex://[...]/..." form). + + * obex-module/src/om-utils.c (utils_get_path_and_dev_from_uri, + om_utils_get_path_and_dev_from_uri): Renamed former to latter and + made public. Changed all callers. Handle URIs of the form + "obex:///foo/bar" to be identical to "obex://foo/bar". + + * obex-module/src/om-dbus.c (om_append_paired_devices, + append_fake_device): Declare a paired device to be a directory, + not a symlink. + + * obex-module/src/obex-method.c (om_uri_is_virtual_obex_root): Use + om_utils_get_path_and_dev_from_uri instead of + gnome_vfs_uri_get_host_name. + (om_uri_is_below_virtual_obex_root): Removed. + (do_open, do_create, do_open_directory, do_get_file_info, + do_make_directory, do_set_file_info): Do not call + om_uri_is_below_virtual_obex_root, the virtual root children are + no longer handled specially. + 2007-08-10 Martyn Russell <martyn at imendio.com> * debian/rules: Fix building with the new Scratchbox toolchain, Modified: projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/obex-method.c =================================================================== --- projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/obex-method.c 2007-09-12 11:24:16 UTC (rev 13777) +++ projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/obex-method.c 2007-09-12 12:56:08 UTC (rev 13778) @@ -503,38 +503,18 @@ static gboolean om_uri_is_virtual_obex_root (const GnomeVFSURI *uri) { - const gchar *host; - const gchar *path; - - if (strcmp (gnome_vfs_uri_get_scheme (uri), "obex") != 0) { - return FALSE; - } + gchar *dev; + gboolean result; - host = gnome_vfs_uri_get_host_name (uri); - if (host) { + if (!om_utils_get_path_and_dev_from_uri (uri, &dev, NULL)) { return FALSE; } - path = gnome_vfs_uri_get_path (uri); - if (strcmp (path, "/") == 0) { - return TRUE; - } + result = (dev == NULL); - return FALSE; -} + g_free (dev); -static gboolean -om_uri_is_below_virtual_obex_root (const GnomeVFSURI *uri) -{ - const gchar *host; - - if (strcmp (gnome_vfs_uri_get_scheme (uri), "obex") != 0) { - return FALSE; - } - - host = gnome_vfs_uri_get_host_name (uri); - - return host == NULL; + return result; } static void @@ -727,11 +707,6 @@ GnomeVFSResult result; GwObexXfer *xfer; - if (om_uri_is_below_virtual_obex_root (uri)) { - /* There are no files on the virtual root. */ - return GNOME_VFS_ERROR_NOT_FOUND; - } - /* Only support either read or write */ if ((mode & GNOME_VFS_OPEN_READ) && (mode & GNOME_VFS_OPEN_WRITE)) { return GNOME_VFS_ERROR_INVALID_OPEN_MODE; @@ -818,13 +793,6 @@ GwObexXfer *xfer; gint error; - if (om_uri_is_below_virtual_obex_root (uri)) { - /* Files can't be created in the virtual root, it's - * read-only. - */ - return GNOME_VFS_ERROR_NOT_PERMITTED; - } - if (!(mode & GNOME_VFS_OPEN_WRITE)) { return GNOME_VFS_ERROR_INVALID_OPEN_MODE; } @@ -1085,22 +1053,8 @@ DirectoryHandle *handle; if (om_uri_is_virtual_obex_root (uri)) { - /* We can't support following symlinks in open_directory since - * the URI is different, just not the path. - */ - if (options & GNOME_VFS_FILE_INFO_FOLLOW_LINKS) { - /* Note: However, that makes things like gnomevfs-ls not - * work so we just ignore the flag instead. - */ - - /*return GNOME_VFS_ERROR_NOT_SUPPORTED;*/ - } - /* Get the list of paired devices. */ elements = om_dbus_get_dev_list (); - } - else if (om_uri_is_below_virtual_obex_root (uri)) { - return GNOME_VFS_ERROR_NOT_A_DIRECTORY; } else { ObexConnection *conn; @@ -1249,9 +1203,6 @@ GnomeVFSFileInfoOptions options, GnomeVFSContext *context) { - /* Special-case the obex:/// root, which is a virtual root containin - * symlinks to the paired devices. - */ if (om_uri_is_virtual_obex_root (uri)) { file_info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_NONE; file_info->name = g_strdup ("/"); @@ -1267,84 +1218,7 @@ return GNOME_VFS_OK; } - else if (om_uri_is_below_virtual_obex_root (uri)) { - GnomeVFSURI *parent, *virtual_root; - gchar *basename; - gboolean found; - GnomeVFSResult result; - GList *elements, *l; - /* Check if the URI is an immediate parent of the virtual root, - * otherwise bail, to save some expensive D-Bus traffic for - * obviously non-correct URIs. - */ - - parent = gnome_vfs_uri_get_parent (uri); - virtual_root = gnome_vfs_uri_new ("obex:///"); - - if (!gnome_vfs_uri_equal (parent, virtual_root)) { - gnome_vfs_uri_unref (parent); - gnome_vfs_uri_unref (virtual_root); - - return GNOME_VFS_ERROR_NOT_FOUND; - } - - gnome_vfs_uri_unref (parent); - gnome_vfs_uri_unref (virtual_root); - - /* Check if the URI is an actual paired device, if so, return - * the info for it. - */ - basename = gnome_vfs_uri_extract_short_name (uri); - found = FALSE; - - elements = om_dbus_get_dev_list (); - for (l = elements; l; l = l->next) { - GnomeVFSFileInfo *child_info; - - child_info = l->data; - - if (strcmp (child_info->name, basename) == 0) { - gnome_vfs_file_info_copy (file_info, child_info); - found = TRUE; - break; - } - } - - g_free (basename); - gnome_vfs_file_info_list_free (elements); - - if (found) { - if (options & GNOME_VFS_FILE_INFO_FOLLOW_LINKS) { - GnomeVFSURI *symlink_uri; - - /* Resolve the symlink, we only need to support - * one step since only the virtual root may - * contain symlinks. - */ - result = GNOME_VFS_ERROR_INVALID_URI; - symlink_uri = gnome_vfs_uri_new (file_info->symlink_name); - if (symlink_uri) { - gnome_vfs_file_info_clear (file_info); - result = om_get_file_info_helper (symlink_uri, - file_info, - context); - gnome_vfs_uri_unref (symlink_uri); - } - - /* Just use the symlink info when not following - * symklinks. - */ - return result; - } - - return GNOME_VFS_OK; - } else { - return GNOME_VFS_ERROR_NOT_FOUND; - } - } - - /* Normal obex://[BDA] form URI. */ return om_get_file_info_helper (uri, file_info, context); } @@ -1380,10 +1254,6 @@ ObexConnection *conn; gint error; - if (om_uri_is_below_virtual_obex_root (uri)) { - return GNOME_VFS_ERROR_NOT_SUPPORTED; - } - conn = om_get_connection (uri, &result); if (!conn) { return result; @@ -1581,10 +1451,6 @@ GnomeVFSURI *tmp_uri; GnomeVFSURI *new_uri; - if (om_uri_is_below_virtual_obex_root (uri)) { - return GNOME_VFS_ERROR_NOT_PERMITTED; - } - /* We can only support changing the name. */ if (!(mask & GNOME_VFS_SET_FILE_INFO_NAME)) { return GNOME_VFS_ERROR_NOT_SUPPORTED; Modified: projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-dbus.c =================================================================== --- projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-dbus.c 2007-09-12 11:24:16 UTC (rev 13777) +++ projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-dbus.c 2007-09-12 12:56:08 UTC (rev 13778) @@ -465,16 +465,13 @@ return; } - info->flags |= GNOME_VFS_FILE_FLAGS_SYMLINK; - info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_TYPE | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS | - GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE | - GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME; + GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE; info->name = g_strdup_printf ("[%s]", remote_devname); - info->type = GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK; + info->type = GNOME_VFS_FILE_TYPE_DIRECTORY; info->permissions = GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_GROUP_READ | @@ -484,16 +481,6 @@ info->gid = 0; info->mime_type = g_strdup ("x-directory/normal"); - info->symlink_name = g_strdup_printf ("obex://[%s]", remote_devname); - - /*g_print ("added name: %s, symlink name: %s\n", info->name, info->symlink_name);*/ - - if (!info->symlink_name) { - /* Extra caution. */ - gnome_vfs_file_info_unref (info); - continue; - } - *list = g_list_append (*list, info); } while (dbus_message_iter_next (&dsub)); } @@ -510,24 +497,20 @@ info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_TYPE | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS | - GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE | - GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME; + GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE; - info->flags |= GNOME_VFS_FILE_FLAGS_SYMLINK; - info->name = g_strdup_printf ("[%s]", bda); - info->type = GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK; + info->type = GNOME_VFS_FILE_TYPE_DIRECTORY; info->permissions = GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_OTHER_READ; - info->symlink_name = g_strdup_printf ("obex://[%s]", bda); - + info->uid = 0; info->gid = 0; info->mime_type = g_strdup ("x-directory/normal"); - /*g_print ("added fake: %s %s\n", info->name, info->symlink_name);*/ + /*g_print ("added fake: %s\n", info->name);*/ return g_list_append (list, info); } Modified: projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.c =================================================================== --- projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.c 2007-09-12 11:24:16 UTC (rev 13777) +++ projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.c 2007-09-12 12:56:08 UTC (rev 13778) @@ -31,51 +31,99 @@ #define d(x) -/* Note: Uses URIs on the form: - * obex://rfcommX/path/to/file, where "rfcommX" maps to /dev/rfcommX or - * obex://[00:00:00:00:00:00]/path/to/file, in which case gwcond is used to lookup - * the device with the specific BDA. - */ -static gboolean -utils_get_path_and_dev_from_uri (const GnomeVFSURI *uri, - gchar **dev, - gchar **path) +/* Extract device BDA and the absolute and unescaped path on the + device from a URI. Both are returned as freshly allocated strings + in *DEV and *PATH respectively, when this function returns TRUE. + When the URI is invalid, FALSE is returned and *DEV and *PATH are + invalid. + + *DEV might be NULL when no device BDA is present. Otherwise it is + usually a string of the form "XX:XX:XX:XX:XX:XX" or "/dev/XXX". + + *PATH is never NULL and never empty. It always starts with a '/'. + + Examples: + + obex:/// + => NULL, / + + obex://[00:00:00:00:00:00] + => 00:00:00:00:00:00, / + + obex:///[00:00:00:00:00:00] + => 00:00:00:00:00:00, / + + obex:///[00:00:00:00:00:00]/foo/bar + => 00:00:00:00:00:00, /foo/bar + + Note that BDAs are also recognize as the first path element when + the host is empty. This is done because listing "obex:///" will + lead to URIs of the form "obex:///[...]". Instead of redirceting + those URIs via symlinks to "obex://[...]" and then having to handle + these symlinks in all places, we just perform some canonicalization + here. +*/ + +gboolean +om_utils_get_path_and_dev_from_uri (const GnomeVFSURI *uri, + gchar **dev, + gchar **path) { - const gchar *host; - const gchar *full_path; + gchar *host; + gchar *full_path; if (strcmp (gnome_vfs_uri_get_scheme (uri), "obex") != 0) { return FALSE; } - host = gnome_vfs_uri_get_host_name (uri); - full_path = gnome_vfs_uri_get_path (uri); + host = g_strdup (gnome_vfs_uri_get_host_name (uri)); + full_path = gnome_vfs_unescape_string (gnome_vfs_uri_get_path (uri), + NULL); - if (!host) { - return FALSE; - } - - if (dev) { - if (strncmp (host, "rfcomm", 6) == 0) { - *dev = g_strdup_printf ("/dev/%s", host); + if (host == NULL) { + if (full_path[0] == '/') { + strcpy (full_path, full_path + 1); } - else if (strlen (host) == 17) { - *dev = g_strdup (host); + char *sep = strchr (full_path, '/'); + if (sep) { + host = g_strndup (full_path, sep-full_path); + strcpy (full_path, sep); } else { - return FALSE; + host = full_path; + full_path = g_strdup ("/"); } } + if (host[0] == '\0') { + g_free (host); + host = NULL; + } else if (host[0] == '[') { + int l; + strcpy (host, host + 1); + l = strlen (host); + if (l > 0 && host[l-1] == ']') + host[l-1] = '\0'; + } else if (strncmp (host, "rfcomm", 6) == 0) { + gchar *tmp = host; + g_free (host); + host = g_strdup_printf ("/dev/%s", tmp); + } + + if (full_path[0] == '\0') { + g_free (full_path); + full_path = g_strdup ("/"); + } + + if (dev) { + *dev = host; + } else { + g_free (host); + } + if (path) { - if (full_path) { - if (full_path[0] == '\0') { - full_path = "/"; - } - - *path = gnome_vfs_unescape_string (full_path, NULL); - } else { - *path = g_strdup ("/"); - } + *path = full_path; + } else { + g_free (full_path); } return TRUE; @@ -86,7 +134,7 @@ { gchar *dev; - if (utils_get_path_and_dev_from_uri (uri, &dev, NULL)) { + if (om_utils_get_path_and_dev_from_uri (uri, &dev, NULL)) { return dev; } else { return NULL; @@ -98,7 +146,7 @@ { gchar *path; - if (utils_get_path_and_dev_from_uri (uri, NULL, &path)) { + if (om_utils_get_path_and_dev_from_uri (uri, NULL, &path)) { return path; } else { return NULL; Modified: projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.h =================================================================== --- projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.h 2007-09-12 11:24:16 UTC (rev 13777) +++ projects/haf/branches/osso-gnomevfs-extra/mvo-nosymlink/obex-module/src/om-utils.h 2007-09-12 12:56:08 UTC (rev 13778) @@ -24,6 +24,9 @@ #include <glib.h> #include <libgnomevfs/gnome-vfs.h> +gboolean om_utils_get_path_and_dev_from_uri (const GnomeVFSURI *uri, + gchar **dev, + gchar **path); gchar * om_utils_get_dev_from_uri (const GnomeVFSURI *uri); gchar * om_utils_get_path_from_uri (const GnomeVFSURI *uri); gchar * om_utils_get_parent_path_from_uri (const GnomeVFSURI *uri);
- Previous message: [maemo-commits] r13777 - in projects/haf/trunk/gtk+: . gtk
- Next message: [maemo-commits] r13779 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]