gvfs r1117 - in trunk: . client
- From: gicmo svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1117 - in trunk: . client
- Date: Sun, 13 Jan 2008 21:56:42 +0000 (GMT)
Author: gicmo
Date: Sun Jan 13 21:56:42 2008
New Revision: 1117
URL: http://svn.gnome.org/viewvc/gvfs?rev=1117&view=rev
Log:
2008-01-13 Christian Kellner <gicmo gnome org>
* client/httpuri.c:
Also handle dav uris in the http mapper.
* daemon/dav.mount.in:
* daemon/Makefile.am:
Add the new dav backend.
* daemon/gvfsbackendhttp.c:
* daemon/gvfsbackendhttp.h:
Implement a utility function so dav and http
backend can share uri from filename creation.
* daemon/gvfsbackenddav.c:
First attempt to write the dav backend as a subclass of http.
Mount, QueryInfo, Enumerate should work and Read is provided
by the base class.
Modified:
trunk/ChangeLog
trunk/client/httpuri.c
Modified: trunk/client/httpuri.c
==============================================================================
--- trunk/client/httpuri.c (original)
+++ trunk/client/httpuri.c Sun Jan 13 21:56:42 2008
@@ -58,6 +58,8 @@
static const char *schemes[] = {
"http",
"https",
+ "dav",
+ "davs",
NULL
};
return schemes;
@@ -65,14 +67,55 @@
static GVfsUriMountInfo *
http_from_uri (GVfsUriMapper *mapper,
- const char *uri_str)
+ const char *uri_str)
{
GVfsUriMountInfo *info;
+ gboolean ssl;
+ char *path;
- info = g_vfs_uri_mount_info_new ("http");
- info->path = g_strdup ("/");
-
- g_vfs_uri_mount_info_set (info, "uri", uri_str);
+ if (!g_ascii_strncasecmp (uri_str, "http", 4))
+ {
+ ssl = !g_ascii_strncasecmp (uri_str, "https", 5);
+ info = g_vfs_uri_mount_info_new ("http");
+ path = g_strdup ("/");
+
+ g_vfs_uri_mount_info_set (info, "uri", uri_str);
+
+ }
+ else
+ {
+ GDecodedUri *uri;
+
+ uri = g_vfs_decode_uri (uri_str);
+
+ if (uri == NULL)
+ return NULL;
+
+ info = g_vfs_uri_mount_info_new ("dav");
+ ssl = !g_ascii_strcasecmp (uri->scheme, "davs");
+
+ if (uri->host && *uri->host)
+ g_vfs_uri_mount_info_set (info, "host", uri->host);
+
+ if (uri->userinfo && *uri->userinfo)
+ g_vfs_uri_mount_info_set (info, "user", uri->userinfo);
+
+ if (uri->port != -1)
+ {
+ char *port = g_strdup_printf ("%d", uri->port);
+ g_vfs_uri_mount_info_set (info, "port", port);
+ g_free (port);
+ }
+
+ path = uri->path;
+ uri->path = NULL;
+ info->mount_prefix = g_strdup (path);
+ g_vfs_decoded_uri_free (uri);
+ }
+
+
+ info->path = path;
+ g_vfs_uri_mount_info_set (info, "ssl", ssl ? "true" : "false");
return info;
}
@@ -81,7 +124,8 @@
http_get_handled_mount_types (GVfsUriMapper *mapper)
{
static const char *types[] = {
- "http",
+ "http",
+ "dav",
NULL
};
return types;
@@ -89,24 +133,85 @@
static char *
http_to_uri (GVfsUriMapper *mapper,
- GVfsUriMountInfo *info,
- gboolean allow_utf8)
+ GVfsUriMountInfo *info,
+ gboolean allow_utf8)
{
- return g_strdup (g_vfs_uri_mount_info_get (info, "uri"));
+ char *res;
+ const char *uri;
+ const char *type;
+ const char *host;
+ const char *user;
+ const char *port;
+ const char *ssl;
+
+ type = g_vfs_uri_mount_info_get (info, "type");
+
+ if (strcmp (type, "http") == 0)
+ {
+ uri = g_vfs_uri_mount_info_get (info, "uri");
+ res = g_strdup (g_vfs_uri_mount_info_get (info, "uri"));
+ }
+ else
+ {
+ GDecodedUri *uri;
+ int port_num;
+
+ uri = g_new0 (GDecodedUri, 1);
+
+ ssl = g_vfs_uri_mount_info_get (info, "ssl");
+ host = g_vfs_uri_mount_info_get (info, "host");
+ user = g_vfs_uri_mount_info_get (info, "user");
+ port = g_vfs_uri_mount_info_get (info, "port");
+
+ if (ssl && strcmp (ssl, "true") == 0)
+ uri->scheme = g_strdup ("davs");
+ else
+ uri->scheme = g_strdup ("dav");
+
+ uri->host = g_strdup (host);
+ uri->userinfo = g_strdup (user);
+
+ if (port && (port_num = atoi (port)))
+ uri->port = port_num;
+
+ uri->path = g_strdup (info->path);
+
+ res = g_vfs_encode_uri (uri, allow_utf8);
+ g_vfs_decoded_uri_free (uri);
+ }
+
+ return res;
}
static const char *
http_to_uri_scheme (GVfsUriMapper *mapper,
GVfsUriMountInfo *info)
{
- const gchar *uri = g_vfs_uri_mount_info_get (info, "uri");
+ const gchar *ssl;
+ const gchar *type;
+ gboolean is_dav;
+ gboolean is_ssl;
+
+ ssl = g_vfs_uri_mount_info_get (info, "ssl");
+ type = g_vfs_uri_mount_info_get (info, "ssl");
- if (g_ascii_strncasecmp (uri, "https", 5) == 0)
- return "https";
- else if (g_ascii_strncasecmp (uri, "http", 4) == 0)
- return "http";
+ if (strcmp (type, "dav") == 0)
+ is_dav = TRUE;
+ else if (strcmp (type, "http") == 0)
+ is_dav = FALSE;
+ else
+ return NULL;
+
+ is_ssl = strcmp (ssl, "true") == 0;
+
+ if (is_dav && is_ssl)
+ return "davs";
+ else if (is_dav && !is_ssl)
+ return "dav";
+ else if (!is_dav && is_ssl)
+ return "https";
else
- return NULL;
+ return "http";
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]